Configurable jockey options

This commit is contained in:
William Blake Galbreath
2020-03-26 21:42:02 -05:00
parent 814f6b2a86
commit 17b869a1a8
2 changed files with 333 additions and 0 deletions

View File

@@ -613,6 +613,16 @@ mobs
* require-shift-to-mount
- **default**: true
- **description**: Required to crouch (hold shift) and right click to mount
* jockey
* chance
- **default**: 0.05
- **description**: Chance of riding a chicken when spawned
* only-babies
- **default**: true
- **description**: Only babies can ride chickens
* try-existing-chickens
- **default**: true
- **description**: Scan for existing chickens to spawn on
* elder_guardian
* ridable
@@ -762,6 +772,16 @@ mobs
* require-shift-to-mount
- **default**: true
- **description**: Required to crouch (hold shift) and right click to mount
* jockey
* chance
- **default**: 0.05
- **description**: Chance of riding a chicken when spawned
* only-babies
- **default**: true
- **description**: Only babies can ride chickens
* try-existing-chickens
- **default**: true
- **description**: Scan for existing chickens to spawn on
* horse
* ridable-in-water
@@ -1272,6 +1292,16 @@ mobs
* transform-to-villager-chance
- **default**: -0.1
- **description**: Chance that a villager can turn into a zombie upon death. Overrides world difficulty. Set to a negative number to use vanilla's default behavior
* jockey
* chance
- **default**: 0.05
- **description**: Chance of riding a chicken when spawned
* only-babies
- **default**: true
- **description**: Only babies can ride chickens
* try-existing-chickens
- **default**: true
- **description**: Scan for existing chickens to spawn on
* zombie_horse
* ridable
@@ -1297,6 +1327,16 @@ mobs
* dont-target-unless-hit
- **default**: false
- **description**: Prevent pigmen from targetting players unless they are hit. (fixes MC-56653)
* jockey
* chance
- **default**: 0.05
- **description**: Chance of riding a chicken when spawned
* only-babies
- **default**: true
- **description**: Only babies can ride chickens
* try-existing-chickens
- **default**: true
- **description**: Scan for existing chickens to spawn on
* zombie-villager
* ridable
@@ -1308,3 +1348,13 @@ mobs
* require-shift-to-mount
- **default**: true
- **description**: Required to crouch (hold shift) and right click to mount
* jockey
* chance
- **default**: 0.05
- **description**: Chance of riding a chicken when spawned
* only-babies
- **default**: true
- **description**: Only babies can ride chickens
* try-existing-chickens
- **default**: true
- **description**: Scan for existing chickens to spawn on

View File

@@ -0,0 +1,283 @@
From d5aeec1dd7fca371c66e149c03477e2c3337044d Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 26 Mar 2020 21:39:32 -0500
Subject: [PATCH] Configurable jockey options
---
.../net/minecraft/server/EntityDrowned.java | 15 ++++++++++
.../net/minecraft/server/EntityPigZombie.java | 15 ++++++++++
.../net/minecraft/server/EntityZombie.java | 29 +++++++++++++-----
.../minecraft/server/EntityZombieHusk.java | 15 ++++++++++
.../server/EntityZombieVillager.java | 15 ++++++++++
.../net/pl3x/purpur/PurpurWorldConfig.java | 30 +++++++++++++++++++
6 files changed, 112 insertions(+), 7 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EntityDrowned.java b/src/main/java/net/minecraft/server/EntityDrowned.java
index 63f5969b10..f32950cc9b 100644
--- a/src/main/java/net/minecraft/server/EntityDrowned.java
+++ b/src/main/java/net/minecraft/server/EntityDrowned.java
@@ -34,6 +34,21 @@ public class EntityDrowned extends EntityZombie implements IRangedEntity {
public boolean requireShiftToMount() {
return world.purpurConfig.drownedRequireShiftToMount;
}
+
+ @Override
+ public boolean jockeyOnlyBaby() {
+ return world.purpurConfig.drownedJockeyOnlyBaby;
+ }
+
+ @Override
+ public double jockeyChance() {
+ return world.purpurConfig.drownedJockeyChance;
+ }
+
+ @Override
+ public boolean jockeyTryExistingChickens() {
+ return world.purpurConfig.drownedJockeyTryExistingChickens;
+ }
// Purpur end
@Override
diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java
index 227fff3f1d..c78876fc42 100644
--- a/src/main/java/net/minecraft/server/EntityPigZombie.java
+++ b/src/main/java/net/minecraft/server/EntityPigZombie.java
@@ -32,6 +32,21 @@ public class EntityPigZombie extends EntityZombie {
public boolean requireShiftToMount() {
return world.purpurConfig.zombiePigmanRequireShiftToMount;
}
+
+ @Override
+ public boolean jockeyOnlyBaby() {
+ return world.purpurConfig.zombiePigmanJockeyOnlyBaby;
+ }
+
+ @Override
+ public double jockeyChance() {
+ return world.purpurConfig.zombiePigmanJockeyChance;
+ }
+
+ @Override
+ public boolean jockeyTryExistingChickens() {
+ return world.purpurConfig.zombiePigmanJockeyTryExistingChickens;
+ }
// Purpur end
@Override
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index 95ae6f3494..e90a93eaa6 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -3,6 +3,7 @@ package net.minecraft.server;
import com.mojang.datafixers.types.DynamicOps;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
+import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;
@@ -59,6 +60,18 @@ public class EntityZombie extends EntityMonster {
public boolean requireShiftToMount() {
return world.purpurConfig.zombieRequireShiftToMount;
}
+
+ public boolean jockeyOnlyBaby() {
+ return world.purpurConfig.zombieJockeyOnlyBaby;
+ }
+
+ public double jockeyChance() {
+ return world.purpurConfig.zombieJockeyChance;
+ }
+
+ public boolean jockeyTryExistingChickens() {
+ return world.purpurConfig.zombieJockeyTryExistingChickens;
+ }
// Purpur end
@Override
@@ -542,18 +555,19 @@ public class EntityZombie extends EntityMonster {
if (object instanceof EntityZombie.GroupDataZombie) {
EntityZombie.GroupDataZombie entityzombie_groupdatazombie = (EntityZombie.GroupDataZombie) object;
- if (entityzombie_groupdatazombie.a) {
- this.setBaby(true);
- if ((double) generatoraccess.getRandom().nextFloat() < 0.05D) {
- List<EntityChicken> list = generatoraccess.a(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), IEntitySelector.c);
+ // Purpur start
+ if (!world.purpurConfig.zombieJockeyOnlyBaby || entityzombie_groupdatazombie.isBaby()) {
+ this.setBaby(entityzombie_groupdatazombie.isBaby());
+ if ((double) generatoraccess.getRandom().nextFloat() < world.purpurConfig.zombieJockeyChance) {
+ List<EntityChicken> list = world.purpurConfig.zombieJockeyTryExistingChickens ? generatoraccess.a(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), IEntitySelector.c) : Collections.emptyList();
+ // Purpur end
if (!list.isEmpty()) {
EntityChicken entitychicken = (EntityChicken) list.get(0);
entitychicken.r(true);
this.startRiding(entitychicken);
- }
- } else if ((double) generatoraccess.getRandom().nextFloat() < 0.05D) {
+ } else { // Purpur
EntityChicken entitychicken1 = (EntityChicken) EntityTypes.CHICKEN.a(this.world);
entitychicken1.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, 0.0F);
@@ -561,6 +575,7 @@ public class EntityZombie extends EntityMonster {
entitychicken1.r(true);
generatoraccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
this.startRiding(entitychicken1);
+ } // Purpur
}
}
@@ -653,7 +668,7 @@ public class EntityZombie extends EntityMonster {
public class GroupDataZombie implements GroupDataEntity {
- public final boolean a;
+ public final boolean a; public boolean isBaby() { return a; } // Purpur - OBFHELPER
private GroupDataZombie(boolean flag) {
this.a = flag;
diff --git a/src/main/java/net/minecraft/server/EntityZombieHusk.java b/src/main/java/net/minecraft/server/EntityZombieHusk.java
index db252ba4e0..e8b099d6c8 100644
--- a/src/main/java/net/minecraft/server/EntityZombieHusk.java
+++ b/src/main/java/net/minecraft/server/EntityZombieHusk.java
@@ -23,6 +23,21 @@ public class EntityZombieHusk extends EntityZombie {
public boolean requireShiftToMount() {
return world.purpurConfig.huskRequireShiftToMount;
}
+
+ @Override
+ public boolean jockeyOnlyBaby() {
+ return world.purpurConfig.huskJockeyOnlyBaby;
+ }
+
+ @Override
+ public double jockeyChance() {
+ return world.purpurConfig.huskJockeyChance;
+ }
+
+ @Override
+ public boolean jockeyTryExistingChickens() {
+ return world.purpurConfig.huskJockeyTryExistingChickens;
+ }
// Purpur end
public static boolean b(EntityTypes<EntityZombieHusk> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) {
diff --git a/src/main/java/net/minecraft/server/EntityZombieVillager.java b/src/main/java/net/minecraft/server/EntityZombieVillager.java
index ebbfcb75a4..8532385d8d 100644
--- a/src/main/java/net/minecraft/server/EntityZombieVillager.java
+++ b/src/main/java/net/minecraft/server/EntityZombieVillager.java
@@ -40,6 +40,21 @@ public class EntityZombieVillager extends EntityZombie implements VillagerDataHo
public boolean requireShiftToMount() {
return world.purpurConfig.zombieVillagerRequireShiftToMount;
}
+
+ @Override
+ public boolean jockeyOnlyBaby() {
+ return world.purpurConfig.zombieVillagerJockeyOnlyBaby;
+ }
+
+ @Override
+ public double jockeyChance() {
+ return world.purpurConfig.zombieVillagerJockeyChance;
+ }
+
+ @Override
+ public boolean jockeyTryExistingChickens() {
+ return world.purpurConfig.zombieVillagerJockeyTryExistingChickens;
+ }
// Purpur end
@Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index bb48a9232e..459c49289e 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -421,10 +421,16 @@ public class PurpurWorldConfig {
public boolean drownedRidable = false;
public boolean drownedRidableInWater = false;
public boolean drownedRequireShiftToMount = true;
+ public boolean drownedJockeyOnlyBaby = true;
+ public double drownedJockeyChance = 0.05D;
+ public boolean drownedJockeyTryExistingChickens = true;
private void drownedSettings() {
drownedRidable = getBoolean("mobs.drowned.ridable", drownedRidable);
drownedRidableInWater = getBoolean("mobs.drowned.ridable-in-water", drownedRidableInWater);
drownedRequireShiftToMount = getBoolean("mobs.drowned.require-shift-to-mount", drownedRequireShiftToMount);
+ drownedJockeyOnlyBaby = getBoolean("mobs.drowned.jockey.only-babies", drownedJockeyOnlyBaby);
+ drownedJockeyChance = getDouble("mobs.drowned.jockey.chance", drownedJockeyChance);
+ drownedJockeyTryExistingChickens = getBoolean("mobs.drowned.jockey.try-existing-chickens", drownedJockeyTryExistingChickens);
}
public boolean elderGuardianRidable = false;
@@ -535,10 +541,16 @@ public class PurpurWorldConfig {
public boolean huskRidable = false;
public boolean huskRidableInWater = false;
public boolean huskRequireShiftToMount = true;
+ public boolean huskJockeyOnlyBaby = true;
+ public double huskJockeyChance = 0.05D;
+ public boolean huskJockeyTryExistingChickens = true;
private void huskSettings() {
huskRidable = getBoolean("mobs.husk.ridable", huskRidable);
huskRidableInWater = getBoolean("mobs.husk.ridable-in-water", huskRidableInWater);
huskRequireShiftToMount = getBoolean("mobs.husk.require-shift-to-mount", huskRequireShiftToMount);
+ huskJockeyOnlyBaby = getBoolean("mobs.husk.jockey.only-babies", huskJockeyOnlyBaby);
+ huskJockeyChance = getDouble("mobs.husk.jockey.chance", huskJockeyChance);
+ huskJockeyTryExistingChickens = getBoolean("mobs.husk.jockey.try-existing-chickens", huskJockeyTryExistingChickens);
}
public boolean horseRidableInWater = false;
@@ -939,11 +951,17 @@ public class PurpurWorldConfig {
public boolean zombieRidableInWater = false;
public boolean zombieRequireShiftToMount = true;
public boolean zombieTargetTurtleEggs = true;
+ public boolean zombieJockeyOnlyBaby = true;
+ public double zombieJockeyChance = 0.05D;
+ public boolean zombieJockeyTryExistingChickens = true;
private void zombieSettings() {
zombieRidable = getBoolean("mobs.zombie.ridable", zombieRidable);
zombieRidableInWater = getBoolean("mobs.zombie.ridable-in-water", zombieRidableInWater);
zombieRequireShiftToMount = getBoolean("mobs.zombie.require-shift-to-mount", zombieRequireShiftToMount);
zombieTargetTurtleEggs = getBoolean("mobs.zombie.target-turtle-eggs", zombieTargetTurtleEggs);
+ zombieJockeyOnlyBaby = getBoolean("mobs.zombie.jockey.only-babies", zombieJockeyOnlyBaby);
+ zombieJockeyChance = getDouble("mobs.zombie.jockey.chance", zombieJockeyChance);
+ zombieJockeyTryExistingChickens = getBoolean("mobs.zombie.jockey.try-existing-chickens", zombieJockeyTryExistingChickens);
}
public boolean zombieHorseCanSwim = false;
@@ -959,19 +977,31 @@ public class PurpurWorldConfig {
public boolean zombiePigmanRidableInWater = false;
public boolean zombiePigmanRequireShiftToMount = true;
public boolean zombiePigmanDontTargetUnlessHit = false;
+ public boolean zombiePigmanJockeyOnlyBaby = true;
+ public double zombiePigmanJockeyChance = 0.05D;
+ public boolean zombiePigmanJockeyTryExistingChickens = true;
private void zombiePigmanSettings() {
zombiePigmanRidable = getBoolean("mobs.zombie_pigman.ridable", zombiePigmanRidable);
zombiePigmanRidableInWater = getBoolean("mobs.zombie_pigman.ridable-in-water", zombiePigmanRidableInWater);
zombiePigmanRequireShiftToMount = getBoolean("mobs.zombie_pigman.require-shift-to-mount", zombiePigmanRequireShiftToMount);
zombiePigmanDontTargetUnlessHit = getBoolean("mobs.zombie_pigman.dont-target-unless-hit", zombiePigmanDontTargetUnlessHit);
+ zombiePigmanJockeyOnlyBaby = getBoolean("mobs.zombie_pigman.jockey.only-babies", zombiePigmanJockeyOnlyBaby);
+ zombiePigmanJockeyChance = getDouble("mobs.zombie_pigman.jockey.chance", zombiePigmanJockeyChance);
+ zombiePigmanJockeyTryExistingChickens = getBoolean("mobs.zombie_pigman.jockey.try-existing-chickens", zombiePigmanJockeyTryExistingChickens);
}
public boolean zombieVillagerRidable = false;
public boolean zombieVillagerRidableInWater = false;
public boolean zombieVillagerRequireShiftToMount = true;
+ public boolean zombieVillagerJockeyOnlyBaby = true;
+ public double zombieVillagerJockeyChance = 0.05D;
+ public boolean zombieVillagerJockeyTryExistingChickens = true;
private void zombieVillagerSettings() {
zombieVillagerRidable = getBoolean("mobs.zombie_villager.ridable", zombieVillagerRidable);
zombieVillagerRidableInWater = getBoolean("mobs.zombie_villager.ridable-in-water", zombieVillagerRidableInWater);
zombieVillagerRequireShiftToMount = getBoolean("mobs.zombie_villager.require-shift-to-mount", zombieVillagerRequireShiftToMount);
+ zombieVillagerJockeyOnlyBaby = getBoolean("mobs.zombie_villager.jockey.only-babies", zombieVillagerJockeyOnlyBaby);
+ zombieVillagerJockeyChance = getDouble("mobs.zombie_villager.jockey.chance", zombieVillagerJockeyChance);
+ zombieVillagerJockeyTryExistingChickens = getBoolean("mobs.zombie_villager.jockey.try-existing-chickens", zombieVillagerJockeyTryExistingChickens);
}
}
--
2.24.0