From 778098e56d469023e8e06966f2acb51eaa56d98f Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Thu, 29 Feb 2024 21:02:28 +0100 Subject: [PATCH] Let scorpions drop eggs, enable babies for all types --- .../entity/hostile/MoCEntityScorpion.java | 55 +++++++++++++++---- .../drzhark/mocreatures/proxy/MoCProxy.java | 4 ++ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/main/java/drzhark/mocreatures/entity/hostile/MoCEntityScorpion.java b/src/main/java/drzhark/mocreatures/entity/hostile/MoCEntityScorpion.java index af112f5f1..e79908df7 100644 --- a/src/main/java/drzhark/mocreatures/entity/hostile/MoCEntityScorpion.java +++ b/src/main/java/drzhark/mocreatures/entity/hostile/MoCEntityScorpion.java @@ -7,6 +7,7 @@ import drzhark.mocreatures.MoCreatures; import drzhark.mocreatures.entity.MoCEntityMob; import drzhark.mocreatures.entity.hunter.MoCEntityPetScorpion; +import drzhark.mocreatures.init.MoCItems; import drzhark.mocreatures.init.MoCSoundEvents; import drzhark.mocreatures.network.MoCMessageHandler; import drzhark.mocreatures.network.message.MoCMessageAnimation; @@ -18,6 +19,7 @@ import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; @@ -49,8 +51,7 @@ public MoCEntityScorpion(World world, int type) { this.poisontimer = 0; this.getType = type; - // Fire and Undead Scorpions won't spawn with babies - if (!this.world.isRemote && getType != 3 && getType != 5) { + if (!this.world.isRemote) { setHasBabies(this.getIsAdult() && this.rand.nextInt(4) == 0); } experienceValue = 5; @@ -230,17 +231,47 @@ public boolean swingingTail() { public void onDeath(DamageSource damagesource) { super.onDeath(damagesource); - if (!this.world.isRemote && getIsAdult() && getHasBabies()) { - int k = this.rand.nextInt(5); - for (int i = 0; i < k; i++) { - MoCEntityPetScorpion entityscorpy = new MoCEntityPetScorpion(this.world); - entityscorpy.setPosition(this.posX, this.posY, this.posZ); - entityscorpy.setAdult(false); - entityscorpy.setAge(20); - entityscorpy.setType(getType); - this.world.spawnEntity(entityscorpy); - MoCTools.playCustomSound(entityscorpy, SoundEvents.ENTITY_SLIME_SQUISH); + if (!this.world.isRemote && getIsAdult()) { + if (getHasBabies()) { + int k = this.rand.nextInt(5); + for (int i = 0; i < k; i++) { + MoCEntityScorpion babyScorpion; + switch (this.getType) { + case 2: + babyScorpion = new MoCEntityCaveScorpion(this.world); + break; + case 3: + babyScorpion = new MoCEntityFireScorpion(this.world); + break; + case 4: + babyScorpion = new MoCEntityFrostScorpion(this.world); + break; + case 5: + babyScorpion = new MoCEntityUndeadScorpion(this.world); + break; + default: + babyScorpion = new MoCEntityDirtScorpion(this.world); + break; + } + babyScorpion.setPosition(this.posX, this.posY, this.posZ); + babyScorpion.setAdult(false); + babyScorpion.setAge(20); + babyScorpion.setType(this.getType); + this.world.spawnEntity(babyScorpion); + MoCTools.playCustomSound(babyScorpion, SoundEvents.ENTITY_SLIME_SQUISH); + } } + dropLegacyEgg(); + } + } + + public void dropLegacyEgg() { + int chance = MoCreatures.proxy.scorpionEggDropChance; + if (getHasBabies()) { + chance = MoCreatures.proxy.motherScorpionEggDropChance; + } + if (this.rand.nextInt(100) < chance) { + entityDropItem(new ItemStack(MoCItems.mocegg, 1, this.getType + 40), 0.0F); } } diff --git a/src/main/java/drzhark/mocreatures/proxy/MoCProxy.java b/src/main/java/drzhark/mocreatures/proxy/MoCProxy.java index 1e1f95b40..82b7aec44 100644 --- a/src/main/java/drzhark/mocreatures/proxy/MoCProxy.java +++ b/src/main/java/drzhark/mocreatures/proxy/MoCProxy.java @@ -84,10 +84,12 @@ public class MoCProxy implements IGuiHandler { public int kittyVillageChance; public int maxOPTamed; public int maxTamed; + public int motherScorpionEggDropChance; public int motherWyvernEggDropChance; public int ostrichEggDropChance; public int particleFX; public int rareItemDropChance; + public int scorpionEggDropChance; public int wyvernDimension; public int wyvernEggDropChance; public short ogreAttackRange; @@ -288,6 +290,7 @@ public void readGlobalConfigValues() { this.legacyWyvernLairSky = this.mocSettingsConfig.get(CATEGORY_MOC_GENERAL_SETTINGS, "LegacyWyvernLairSky", false, "Enables legacy wyvern lair sky.").getBoolean(false); this.maxOPTamed = this.mocSettingsConfig.get(CATEGORY_OWNERSHIP_SETTINGS, "MaxTamedPerOP", 20, "Maximum tamed creatures an OP can have. Requires EnableOwnership to be enabled.").getInt(); this.maxTamed = this.mocSettingsConfig.get(CATEGORY_OWNERSHIP_SETTINGS, "MaxTamedPerPlayer", 10, "Maximum tamed creatures a player can have. Requires EnableOwnership to be enabled.").getInt(); + this.motherScorpionEggDropChance = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "MotherScorpionEggDropChance", 33, "The percentage for mother scorpions to drop an egg.").getInt(); this.motherWyvernEggDropChance = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "MotherWyvernEggDropChance", 66, "The percentage for mother wyverns to drop an egg.").getInt(); this.ogreAttackRange = (short) this.mocSettingsConfig.get(CATEGORY_MOC_MONSTER_GENERAL_SETTINGS, "OgreAttackRange", 12, "The block radius where ogres 'smell' players.").getInt(); this.ogreCaveStrength = Float.parseFloat(this.mocSettingsConfig.get(CATEGORY_MOC_MONSTER_GENERAL_SETTINGS, "CaveOgreStrength", 2.5F, "The block destruction radius of cave ogres.").getString()); @@ -296,6 +299,7 @@ public void readGlobalConfigValues() { this.ostrichEggDropChance = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "OstrichEggDropChance", 3, "The percentage for ostriches to drop an egg.").getInt(); this.particleFX = this.mocSettingsConfig.get(CATEGORY_MOC_GENERAL_SETTINGS, "ParticleFX", 3, "The density of MoCreatures particle effects.").getInt(); this.rareItemDropChance = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "RareItemDropChance", 25, "The percentage for certain creatures to drop a rare item when killed. Most creatures use loot tables and can be configured with a loot table editor instead.").getInt(); + this.scorpionEggDropChance = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "ScorpionEggDropChance", 17, "The percentage for scorpions to drop an egg.").getInt(); this.spawnMultiplier = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "SpawnMultiplier", 2.0D, "Multiplier for entity spawns during world generation.").getDouble(2.0D); this.staticBed = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "StaticBed", true, "Makes the kitty bed not pushable.").getBoolean(true); this.staticLitter = this.mocSettingsConfig.get(CATEGORY_MOC_CREATURE_GENERAL_SETTINGS, "StaticLitter", true, "Makes the kitty litter box not pushable.").getBoolean(true);