Add config options for giants

This commit is contained in:
William Blake Galbreath
2019-05-19 06:23:06 -05:00
parent ecbb480661
commit b1e7212ff9

View File

@@ -1,13 +1,14 @@
From 43efafd95754423de1ddcfbc5c5e2bba5bb230b6 Mon Sep 17 00:00:00 2001
From 05b0ff051a20b48b0495aac5b2a6de2a534cc277 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 | 23 ++++++++++++++++
.../minecraft/server/EntityGiantZombie.java | 26 ++++++++++++++++++-
3 files changed, 49 insertions(+), 1 deletion(-)
.../java/net/minecraft/server/Biomes.java | 25 ++++++++++++++++
.../minecraft/server/EntityGiantZombie.java | 30 ++++++++++++++++++-
.../java/net/pl3x/purpur/PurpurConfig.java | 7 +++++
4 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/BiomeBase.java b/src/main/java/net/minecraft/server/BiomeBase.java
index 72eb669c5..f1500f7a0 100644
@@ -22,31 +23,33 @@ index 72eb669c5..f1500f7a0 100644
((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 317db4b12..69ba98b66 100644
index 317db4b12..e3c25309e 100644
--- a/src/main/java/net/minecraft/server/Biomes.java
+++ b/src/main/java/net/minecraft/server/Biomes.java
@@ -92,5 +92,28 @@ public abstract class Biomes {
@@ -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?)
+ 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);
+ 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) {
@@ -55,27 +58,37 @@ index 317db4b12..69ba98b66 100644
+ // Purpur end
}
diff --git a/src/main/java/net/minecraft/server/EntityGiantZombie.java b/src/main/java/net/minecraft/server/EntityGiantZombie.java
index 19b8312f2..1731e0fe3 100644
index 19b8312f2..b58b681a9 100644
--- a/src/main/java/net/minecraft/server/EntityGiantZombie.java
+++ b/src/main/java/net/minecraft/server/EntityGiantZombie.java
@@ -23,8 +23,32 @@ public class EntityGiantZombie extends EntityMonster {
@@ -1,5 +1,7 @@
package net.minecraft.server;
+import net.pl3x.purpur.PurpurConfig;
+
public class EntityGiantZombie extends EntityMonster {
public EntityGiantZombie(EntityTypes<? extends EntityGiantZombie> entitytypes, World world) {
@@ -23,8 +25,34 @@ public class EntityGiantZombie extends EntityMonster {
this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(50.0D);
}
+ // Purpur start
+ @Override
+ protected void initPathfinder() {
+ 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));
+ if (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
@@ -92,6 +105,22 @@ index 19b8312f2..1731e0fe3 100644
+ 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 734b8026d..5cc9a27db 100644
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
@@ -109,4 +109,11 @@ public class PurpurConfig {
showDuplicateEntityUUIDErrors = getBoolean("settings.logger.show-duplicate-entity-uuid-errors", showDuplicateEntityUUIDErrors);
showUnknownAttributeWarnings = getBoolean("settings.logger.show-unknown-attribute-warnings", showUnknownAttributeWarnings);
}
+
+ 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);
+ }
}
--
2.20.1