mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes : 2db85c5 fix: origin world can be unknown while knowing location 903fa9a Enable chunk load for feature search by default
216 lines
12 KiB
Diff
216 lines
12 KiB
Diff
From 0000000000000000000000000000000000000000 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] Giants AI settings
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 6c4d3aab0a9efcc039071e48d9b9596f1a222694..1b773fa6c2ff30ca3463c88ccc28c360e15f3fdb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -228,7 +228,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
|
public double D;
|
|
public double E;
|
|
public double F;
|
|
- public float G; public final float getStepHeight() { return this.G; } // Tuinity - OBFHELPER
|
|
+ public float G; public final float getStepHeight() { return this.G; } public void setStepHeight(float stepHeight) { this.G = stepHeight; } // Tuinity - OBFHELPER // Purpur - OBFHELPER
|
|
public boolean noclip;
|
|
public float I;
|
|
protected final Random random;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityInsentient.java b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
index 7ba59ff9a7ed39bf69c46973a85f874c43134dc1..46e9a232ca5df81cafd4c3fc6af43b933c95d04f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
|
|
@@ -1021,6 +1021,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);
|
|
@@ -1128,6 +1129,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/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
index 7d0bb706fb106709432c3fae8758d2cea1d14db8..032b1a519de56583990fe47a216665ce71cf93ab 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -260,6 +260,7 @@ public abstract class EntityLiving extends Entity {
|
|
this.activeItem = ItemStack.b;
|
|
this.by = Optional.empty();
|
|
this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes));
|
|
+ this.initAttributes(); // Purpur
|
|
this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
|
|
// CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
|
|
this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue());
|
|
@@ -275,6 +276,8 @@ public abstract class EntityLiving extends Entity {
|
|
this.bg = this.a(new Dynamic(dynamicopsnbt, dynamicopsnbt.createMap((Map) ImmutableMap.of(dynamicopsnbt.createString("memories"), dynamicopsnbt.emptyMap()))));
|
|
}
|
|
|
|
+ protected void initAttributes() {} // Purpur
|
|
+
|
|
public BehaviorController<?> getBehaviorController() {
|
|
return this.bg;
|
|
}
|
|
@@ -2273,7 +2276,7 @@ public abstract class EntityLiving extends Entity {
|
|
this.enderTeleportTo(vec3d.x, vec3d.y, vec3d.z);
|
|
}
|
|
|
|
- protected float dJ() {
|
|
+ protected float dJ() { return getJumpHeight(); } public float getJumpHeight() { // Purpur - OBFHELPER
|
|
return 0.42F * this.getBlockJumpFactor();
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityGiantZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityGiantZombie.java
|
|
index 5e6a92dcdbca686d5a8cfc4aaff72b70b81b111f..a188a89143cb1b0243dacdec33c446ca4120219f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/monster/EntityGiantZombie.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityGiantZombie.java
|
|
@@ -1,21 +1,99 @@
|
|
package net.minecraft.world.entity.monster;
|
|
|
|
import net.minecraft.core.BlockPosition;
|
|
+import net.minecraft.nbt.NBTTagCompound;
|
|
+import net.minecraft.world.DifficultyDamageScaler;
|
|
+import net.minecraft.world.EnumDifficulty;
|
|
import net.minecraft.world.entity.EntityPose;
|
|
import net.minecraft.world.entity.EntitySize;
|
|
import net.minecraft.world.entity.EntityTypes;
|
|
+import net.minecraft.world.entity.EnumItemSlot;
|
|
+import net.minecraft.world.entity.EnumMobSpawn;
|
|
+import net.minecraft.world.entity.GroupDataEntity;
|
|
import net.minecraft.world.entity.ai.attributes.AttributeProvider;
|
|
import net.minecraft.world.entity.ai.attributes.GenericAttributes;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalFloat;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalLookAtPlayer;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalMoveTowardsRestriction;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomLookaround;
|
|
+import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStrollLand;
|
|
+import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget;
|
|
+import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget;
|
|
+import net.minecraft.world.entity.animal.EntityIronGolem;
|
|
+import net.minecraft.world.entity.animal.EntityTurtle;
|
|
+import net.minecraft.world.entity.npc.EntityVillager;
|
|
+import net.minecraft.world.entity.player.EntityHuman;
|
|
+import net.minecraft.world.item.ItemStack;
|
|
+import net.minecraft.world.item.Items;
|
|
import net.minecraft.world.level.IWorldReader;
|
|
import net.minecraft.world.level.World;
|
|
+import net.minecraft.world.level.WorldAccess;
|
|
|
|
public class EntityGiantZombie extends EntityMonster {
|
|
|
|
public EntityGiantZombie(EntityTypes<? extends EntityGiantZombie> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
- this.safeFallDistance = 10.0F; // Purpur
|
|
+ // Purpur start
|
|
+ this.safeFallDistance = 10.0F;
|
|
+ setStepHeight(world.purpurConfig.giantStepHeight);
|
|
+ // Purpur end
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ protected void initPathfinder() {
|
|
+ if (world.purpurConfig.giantHaveAI) {
|
|
+ this.goalSelector.a(0, new PathfinderGoalFloat(this));
|
|
+ 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(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
|
|
+ protected void initAttributes() {
|
|
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(this.world.purpurConfig.giantMaxHealth);
|
|
+ this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(this.world.purpurConfig.giantMovementSpeed);
|
|
+ this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(this.world.purpurConfig.giantAttackDamage);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public GroupDataEntity prepare(WorldAccess worldaccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @javax.annotation.Nullable GroupDataEntity groupdataentity, @javax.annotation.Nullable NBTTagCompound nbttagcompound) {
|
|
+ GroupDataEntity groupData = super.prepare(worldaccess, difficultydamagescaler, enummobspawn, groupdataentity, nbttagcompound);
|
|
+ if (groupData == null) {
|
|
+ setEquipmentBasedOnDifficulty(difficultydamagescaler);
|
|
+ setEnchantmentBasedOnDifficulty(difficultydamagescaler);
|
|
+ }
|
|
+ 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
|
|
+ // 1.0 makes bottom of feet about as high as their waist when they jump
|
|
+ return world.purpurConfig.giantJumpHeight;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
protected float b(EntityPose entitypose, EntitySize entitysize) {
|
|
return 10.440001F;
|
|
@@ -27,6 +105,6 @@ public class EntityGiantZombie extends EntityMonster {
|
|
|
|
@Override
|
|
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
|
- return iworldreader.y(blockposition) - 0.5F;
|
|
+ return super.a(blockposition, iworldreader); // Purpur - fix light requirements for natural spawns
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 2f18ca7ae23e913155f25fd07627f376e401ab0f..1c87c929aaae17631100d1aa30b3e7ecce52686f 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -113,6 +113,28 @@ public class PurpurWorldConfig {
|
|
turtleEggsBreakFromMinecarts = getBoolean("blocks.turtle_egg.break-from-minecarts", turtleEggsBreakFromMinecarts);
|
|
}
|
|
|
|
+ public float giantStepHeight = 2.0F;
|
|
+ public float giantJumpHeight = 1.0F;
|
|
+ public double giantMovementSpeed = 0.5D;
|
|
+ public double giantAttackDamage = 50.0D;
|
|
+ public boolean giantHaveAI = false;
|
|
+ public boolean giantHaveHostileAI = false;
|
|
+ public double giantMaxHealth = 100.0D;
|
|
+ private void giantSettings() {
|
|
+ giantStepHeight = (float) getDouble("mobs.giant.step-height", giantStepHeight);
|
|
+ giantJumpHeight = (float) getDouble("mobs.giant.jump-height", giantJumpHeight);
|
|
+ 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);
|
|
+ if (PurpurConfig.version < 8) {
|
|
+ double oldValue = getDouble("mobs.giant.max-health", giantMaxHealth);
|
|
+ set("mobs.giant.attributes.max-health", oldValue);
|
|
+ set("mobs.giant.max-health", null);
|
|
+ }
|
|
+ giantMaxHealth = getDouble("mobs.giant.attributes.max-health", giantMaxHealth);
|
|
+ }
|
|
+
|
|
public int villagerBrainTicks = 1;
|
|
public boolean villagerUseBrainTicksOnlyWhenLagging = true;
|
|
private void villagerSettings() {
|