mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
130 lines
7.1 KiB
Diff
130 lines
7.1 KiB
Diff
From 32ed6366b03dbec3921692e4297a0674beb0615c Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sun, 12 May 2019 00:43:12 -0500
|
|
Subject: [PATCH] Give giants AI
|
|
|
|
---
|
|
.../minecraft/server/EntityGiantZombie.java | 47 +++++++++++++++++--
|
|
.../minecraft/server/EntityInsentient.java | 2 +
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 10 ++++
|
|
3 files changed, 55 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
index ff8a41a539..4296aaa074 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
|
|
@@ -23,6 +23,45 @@ public class EntityGiantZombie extends EntityMonster {
|
|
return world.purpurConfig.giantRequireShiftToMount;
|
|
}
|
|
|
|
+ protected void initPathfinder() {
|
|
+ if (world.purpurConfig.giantHaveAI) {
|
|
+ this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
|
+ this.goalSelector.a(0, new net.pl3x.purpur.pathfinder.PathfinderGoalHasRider(this)); // Purpur
|
|
+ this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D));
|
|
+ this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 16.0F));
|
|
+ this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
|
+ this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
|
|
+ if (world.purpurConfig.giantHaveHostileAI) {
|
|
+ this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
|
|
+ this.targetSelector.a(0, new net.pl3x.purpur.pathfinder.PathfinderGoalHasRider(this)); // Purpur
|
|
+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(EntityPigZombie.class));
|
|
+ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
|
+ this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillager.class, false));
|
|
+ this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
|
|
+ this.targetSelector.a(5, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, true));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public GroupDataEntity prepare(GeneratorAccess world, DifficultyDamageScaler difficulty, EnumMobSpawn enummobspawn, GroupDataEntity groupDataEntity, NBTTagCompound nbt) {
|
|
+ GroupDataEntity groupData = super.prepare(world, difficulty, enummobspawn, groupDataEntity, nbt);
|
|
+ if (groupData == null) {
|
|
+ setEquipmentBasedOnDifficulty(difficulty);
|
|
+ setEnchantmentBasedOnDifficulty(difficulty);
|
|
+ }
|
|
+ return groupData;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected void setEquipmentBasedOnDifficulty(DifficultyDamageScaler difficulty) {
|
|
+ super.setEquipmentBasedOnDifficulty(difficulty);
|
|
+ // TODO make configurable
|
|
+ if (random.nextFloat() < (world.getDifficulty() == EnumDifficulty.HARD ? 0.1F : 0.05F)) {
|
|
+ setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.IRON_SWORD));
|
|
+ }
|
|
+ }
|
|
+
|
|
@Override
|
|
public float getJumpHeight() {
|
|
// make giants jump as high as everything else relative to their size
|
|
@@ -39,13 +78,13 @@ public class EntityGiantZombie extends EntityMonster {
|
|
@Override
|
|
protected void initAttributes() {
|
|
super.initAttributes();
|
|
- this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(100.0D);
|
|
- this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.5D);
|
|
- this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D);
|
|
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(world.purpurConfig.giantMaxHealth); // Purpur
|
|
+ this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(world.purpurConfig.giantMovementSpeed); // Purpur
|
|
+ this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(world.purpurConfig.giantAttackDamage); // Purpur
|
|
}
|
|
|
|
@Override
|
|
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
|
- return iworldreader.w(blockposition) - 0.5F;
|
|
+ return super.a(blockposition, iworldreader); // Purpur - fix light requirements for natural spawns
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
index cbbbc875be..fbca429090 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -867,6 +867,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
return f;
|
|
}
|
|
|
|
+ protected void setEquipmentBasedOnDifficulty(DifficultyDamageScaler difficultydamagescaler) { a(difficultydamagescaler); } // Purpur - OBFHELPER
|
|
protected void a(DifficultyDamageScaler difficultydamagescaler) {
|
|
if (this.random.nextFloat() < 0.15F * difficultydamagescaler.d()) {
|
|
int i = this.random.nextInt(2);
|
|
@@ -974,6 +975,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
|
}
|
|
}
|
|
|
|
+ protected void setEnchantmentBasedOnDifficulty(DifficultyDamageScaler difficultydamagescaler) { b(difficultydamagescaler); } // Purpur - OBFHELPER
|
|
protected void b(DifficultyDamageScaler difficultydamagescaler) {
|
|
float f = difficultydamagescaler.d();
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 69f99a993d..7cf7ae3dcb 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -255,12 +255,22 @@ public class PurpurWorldConfig {
|
|
public boolean giantRequireShiftToMount = true;
|
|
public float giantStepHeight = 2.0F;
|
|
public float giantJumpHeight = 1.0F;
|
|
+ public double giantMaxHealth = 100.0D;
|
|
+ public double giantMovementSpeed = 0.5D;
|
|
+ public double giantAttackDamage = 50.0D;
|
|
+ public boolean giantHaveAI = false;
|
|
+ public boolean giantHaveHostileAI = false;
|
|
private void giantSettings() {
|
|
giantRidable = getBoolean("mobs.giant.ridable", giantRidable);
|
|
giantRidableInWater = getBoolean("mobs.giant.ridable-in-water", giantRidableInWater);
|
|
giantRequireShiftToMount = getBoolean("mobs.giant.require-shift-to-mount", giantRequireShiftToMount);
|
|
giantStepHeight = (float) getDouble("mobs.giant.step-height", giantStepHeight);
|
|
giantJumpHeight = (float) getDouble("mobs.giant.jump-height", giantJumpHeight);
|
|
+ giantMaxHealth = getDouble("mobs.giant.max-health", giantMaxHealth);
|
|
+ giantMovementSpeed = getDouble("mobs.giant.movement-speed", giantMovementSpeed);
|
|
+ giantAttackDamage = getDouble("mobs.giant.attack-damage", giantAttackDamage);
|
|
+ giantHaveAI = getBoolean("mobs.giant.have-ai", giantHaveAI);
|
|
+ giantHaveHostileAI = getBoolean("mobs.giant.have-hostile-ai", giantHaveHostileAI);
|
|
}
|
|
|
|
public boolean guardianRidable = false;
|
|
--
|
|
2.24.0
|
|
|