Files
Purpur/patches/server/0013-Make-giants-naturally-spawn-and-have-AI.patch
William Blake Galbreath 02e31ae620 Implement metrics
2019-07-11 21:43:54 -05:00

125 lines
7.6 KiB
Diff

From e769430304cb6645c09200ebfa17f11c8e94d0e7 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] Make giants naturally spawn and have AI
---
.../java/net/minecraft/server/BiomeBase.java | 1 +
.../java/net/minecraft/server/Biomes.java | 25 ++++++++++++++++
.../minecraft/server/EntityGiantZombie.java | 30 +++++++++++++++++--
.../java/net/pl3x/purpur/PurpurConfig.java | 7 +++++
4 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
index 72eb669c5..f1500f7a0 100644
--- a/src/main/java/net/minecraft/server/BiomeBase.java
+++ b/src/main/java/net/minecraft/server/BiomeBase.java
@@ -97,6 +97,7 @@ public abstract class BiomeBase {
return this.m != null;
}
+ protected void addMobSpawn(EnumCreatureType creaturetype, BiomeBase.BiomeMeta biomemeta) { a(creaturetype, biomemeta); } // Purpur - OBFHELPER
protected void a(EnumCreatureType enumcreaturetype, BiomeBase.BiomeMeta biomebase_biomemeta) {
((List) this.u.get(enumcreaturetype)).add(biomebase_biomemeta);
}
diff --git a/src/main/java/net/minecraft/server/Biomes.java b/src/main/java/net/minecraft/server/Biomes.java
index f4698a680..3f7f7a2de 100644
--- a/src/main/java/net/minecraft/server/Biomes.java
+++ b/src/main/java/net/minecraft/server/Biomes.java
@@ -92,5 +92,30 @@ public abstract class Biomes {
static {
Collections.addAll(BiomeBase.b, new BiomeBase[]{Biomes.OCEAN, Biomes.PLAINS, Biomes.DESERT, Biomes.MOUNTAINS, Biomes.FOREST, Biomes.TAIGA, Biomes.SWAMP, Biomes.RIVER, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.MUSHROOM_FIELDS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.BEACH, Biomes.DESERT_HILLS, Biomes.WOODED_HILLS, Biomes.TAIGA_HILLS, Biomes.JUNGLE, Biomes.JUNGLE_HILLS, Biomes.JUNGLE_EDGE, Biomes.DEEP_OCEAN, Biomes.STONE_SHORE, Biomes.SNOWY_BEACH, Biomes.BIRCH_FOREST, Biomes.BIRCH_FOREST_HILLS, Biomes.DARK_FOREST, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.WOODED_MOUNTAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.BADLANDS, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.BADLANDS_PLATEAU});
+
+ // Purpur start - add natural mob spawns (maybe find a better place for this?)
+ if (net.pl3x.purpur.PurpurConfig.giantsNaturallySpawn) {
+ addSpawn("plains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
+ addSpawn("sunflower_plains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
+ addSpawn("desert", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
+ addSpawn("desert_hills", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
+ addSpawn("desert_lakes", EnumCreatureType.MONSTER, EntityTypes.GIANT, 2, 1, 1);
+ addSpawn("mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
+ addSpawn("gravelly_mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
+ addSpawn("modified_gravelly_mountains", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 1);
+ addSpawn("savanna", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
+ addSpawn("savanna_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
+ addSpawn("shattered_savanna", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
+ addSpawn("shattered_savanna_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 5, 1, 2);
+ addSpawn("badlands", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
+ addSpawn("badlands_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
+ addSpawn("eroded_badlands", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 1, 2);
+ addSpawn("modified_badlands_plateau", EnumCreatureType.MONSTER, EntityTypes.GIANT, 10, 2, 1);
+ }
+ }
+
+ private static void addSpawn(String biome, EnumCreatureType ct, EntityTypes et, int weight, int min_group, int max_group) {
+ IRegistry.BIOME.get(new MinecraftKey(biome)).addMobSpawn(ct, new BiomeBase.BiomeMeta(et, weight, min_group, max_group));
}
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
index b7e2022b1..e69e7a456 100644
--- a/src/main/java/net/minecraft/server/EntityGiantZombie.java
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
@@ -21,11 +21,37 @@ public class EntityGiantZombie extends EntityMonster {
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.ATTACK_DAMAGE).setValue(12.0D); // Purpur - match ravager damage
}
+ // Purpur start
+ @Override
+ protected void initPathfinder() {
+ if (net.pl3x.purpur.PurpurConfig.giantsHaveAI) {
+ this.goalSelector.a(0, new PathfinderGoalFloat(this));
+ this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
+ 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));
+ 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 float cX() { // jump height
+ // 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 1.0F;
+ }
+ // Purpur end
+
@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/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
index 8bf8384a2..bb91a4a67 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -141,6 +141,13 @@ public class PurpurConfig {
feedMushroomsToCows = getInt("settings.mobs.cow.feed-mushrooms-for-mooshroom", feedMushroomsToCows);
}
+ public static boolean giantsNaturallySpawn = true;
+ public static boolean giantsHaveAI = true;
+ private static void giantsSettings() {
+ giantsNaturallySpawn = getBoolean("settings.mobs.giant.naturally-spawn", giantsNaturallySpawn);
+ giantsHaveAI = getBoolean("settings.mobs.giant.have-ai", giantsHaveAI);
+ }
+
public static boolean snowmanDropsPumpkin = true;
public static boolean snowmanPumpkinPutBack = true;
private static void snowmansSettings() {
--
2.20.1