mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Cocoons can now be forced to spawn rare mobs with gaia spirits
Tweaks to cocoon emerald particles to reduce overlap
This commit is contained in:
1 parent
d14fba628b
commit
cacb5121b3
3 files changed
+26
-6
No files matched your search
@@ -28,7 +28,10 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import vazkii.botania.client.fx.WispParticleData;
|
||||
import vazkii.botania.common.block.tile.TileCocoon;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -74,18 +77,25 @@ public class BlockCocoon extends BlockMod {
|
||||
TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos);
|
||||
Item item = stack.getItem();
|
||||
|
||||
if(cocoon != null && (item == Items.EMERALD || item == Items.CHORUS_FRUIT)) {
|
||||
if(cocoon != null && (item == Items.EMERALD || item == Items.CHORUS_FRUIT || item == ModItems.lifeEssence)) {
|
||||
if(!world.isRemote) {
|
||||
if(item == Items.EMERALD && cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS) {
|
||||
if(!creative)
|
||||
stack.shrink(1);
|
||||
cocoon.emeraldsGiven++;
|
||||
((ServerWorld) world).spawnParticle(ParticleTypes.HAPPY_VILLAGER, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0, 0, 0, 0.5);
|
||||
((ServerWorld) world).spawnParticle(ParticleTypes.HAPPY_VILLAGER, pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 1, 0.1, 0.05, 0.1, 0.5);
|
||||
} else if(item == Items.CHORUS_FRUIT && cocoon.chorusFruitGiven < TileCocoon.MAX_CHORUS_FRUITS) {
|
||||
if(!creative)
|
||||
stack.shrink(1);
|
||||
cocoon.chorusFruitGiven++;
|
||||
((ServerWorld) world).spawnParticle(ParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 32, 0, 0, 0, 0.5);
|
||||
} else if (item == ModItems.lifeEssence && !cocoon.gaiaSpiritGiven) {
|
||||
if(!creative) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
cocoon.forceRare();
|
||||
WispParticleData data = WispParticleData.wisp(0.6F, 0F, 1F, 0F);
|
||||
((ServerWorld) world).spawnParticle(data, pos.getX() + 0.5, pos.getY() + 0.7, pos.getZ() + 0.5, 8, 0.1, 0.1, 0.1, 0.04);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
private static final String TAG_TIME_PASSED = "timePassed";
|
||||
private static final String TAG_EMERALDS_GIVEN = "emeraldsGiven";
|
||||
private static final String TAG_CHORUS_FRUIT_GIVEN = "chorusFruitGiven";
|
||||
private static final String TAG_GAIA_SPIRIT_GIVEN = "gaiaSpiritGiven";
|
||||
|
||||
private static final List<EntityType<? extends MobEntity>> SPECIALS = ImmutableList.of(
|
||||
EntityType.HORSE, EntityType.DONKEY, EntityType.WOLF, EntityType.OCELOT,
|
||||
EntityType.CAT, EntityType.PARROT, EntityType.LLAMA, EntityType.FOX,
|
||||
@@ -58,6 +60,7 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
public int timePassed;
|
||||
public int emeraldsGiven;
|
||||
public int chorusFruitGiven;
|
||||
public boolean gaiaSpiritGiven;
|
||||
|
||||
public TileCocoon() {
|
||||
super(TYPE);
|
||||
@@ -77,6 +80,7 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
|
||||
MobEntity entity = null;
|
||||
BlockPos placePos = pos;
|
||||
float rareChance = gaiaSpiritGiven ? 1F : SPECIAL_CHANCE;
|
||||
|
||||
float villagerChance = Math.min(1F, (float) emeraldsGiven / (float) MAX_EMERALDS);
|
||||
float shulkerChance = Math.min(1F, (float) chorusFruitGiven / (float) MAX_CHORUS_FRUITS);
|
||||
@@ -103,13 +107,13 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
entity = villager;
|
||||
} else if (!validWater.isEmpty()) {
|
||||
placePos = validWater.get(world.rand.nextInt(validWater.size()));
|
||||
if (Math.random() < SPECIAL_CHANCE) {
|
||||
if (Math.random() < rareChance) {
|
||||
entity = EntityType.DOLPHIN.create(world);
|
||||
} else {
|
||||
entity = AQUATIC.get(world.rand.nextInt(AQUATIC.size())).create(world);
|
||||
}
|
||||
} else {
|
||||
if(Math.random() < SPECIAL_CHANCE) {
|
||||
if(Math.random() < rareChance) {
|
||||
entity = SPECIALS.get(world.rand.nextInt(SPECIALS.size())).create(world);
|
||||
} else {
|
||||
EntityType<? extends MobEntity> type = NORMALS.get(world.rand.nextInt(NORMALS.size()));
|
||||
@@ -131,11 +135,17 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
}
|
||||
}
|
||||
|
||||
public void forceRare() {
|
||||
gaiaSpiritGiven = true;
|
||||
timePassed = Math.min(timePassed, TOTAL_TIME / 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(CompoundNBT cmp) {
|
||||
cmp.putInt(TAG_TIME_PASSED, timePassed);
|
||||
cmp.putInt(TAG_EMERALDS_GIVEN, emeraldsGiven);
|
||||
cmp.putInt(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven);
|
||||
cmp.putBoolean(TAG_GAIA_SPIRIT_GIVEN, gaiaSpiritGiven);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,6 +153,6 @@ public class TileCocoon extends TileMod implements ITickableTileEntity{
|
||||
timePassed = cmp.getInt(TAG_TIME_PASSED);
|
||||
emeraldsGiven = cmp.getInt(TAG_EMERALDS_GIVEN);
|
||||
chorusFruitGiven = cmp.getInt(TAG_CHORUS_FRUIT_GIVEN);
|
||||
gaiaSpiritGiven = cmp.getBoolean(TAG_GAIA_SPIRIT_GIVEN);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2433,7 +2433,7 @@
|
||||
"botania.entry.cocoon": "Cocoon of Caprice",
|
||||
"botania.tagline.cocoon": "Hatch your own animals",
|
||||
"botania.page.cocoon0": "A cocoon is a symbol of change, of evolution.$(p)A $(item)Cocoon of Caprice$(0), when placed, will slowly evolve the rudimentary bits of life inside into a $(item)Baby Animal$(0). More often than not, the cocoon will hatch into a farm animal, but on rare occasions, different animals such as $(item)Wolves$(0) or $(item)Horses$(0) can be created.",
|
||||
"botania.page.cocoon1": "A cocoon near water seems to create aquatic animals instead.$(p)Rumor has it that giving a cocoon $(item)Emeralds$(0) or $(item)Chorus Fruit$(0) will influence its outcome towards something... different. What such experiments would yield is anyone's guess, really.$(p)(Giving a cocoon an item can be done via right-click or by simply tossing the item.)",
|
||||
"botania.page.cocoon1": "A cocoon near water seems to create aquatic animals instead.$(p)Rumor has it that giving a cocoon $(item)Emeralds$(0), $(item)Chorus Fruit$(0), or a certain $(l:alfhomancy/gaia_ritual)$(item)otherworldly essence$(0)$(/l) will influence its outcome towards something... different. What such experiments would yield is anyone's guess, really.$(p)(Giving a cocoon an item can be done via right-click or by simply tossing the item.)",
|
||||
"botania.page.cocoon2": "New World, Perfect World",
|
||||
|
||||
"botania.entry.manaBomb": "Manastorm Charge",
|
||||
|
||||
Reference in new issue
Block a user