Skip to content

Commit

Permalink
Let scorpions drop eggs, enable babies for all types
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Feb 29, 2024
1 parent 04d3e7a commit 778098e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/drzhark/mocreatures/proxy/MoCProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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);
Expand Down

0 comments on commit 778098e

Please sign in to comment.