mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
Add in bandaid anti-dupe mechanism for entropinnyums
This commit is contained in:
1 parent
83b40c7b00
commit
f878ee11d7
3 files changed
+69
-3
No files matched your search
+64
-3
@@ -8,12 +8,18 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.subtile.generating;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.TNTEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.tileentity.PistonTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
|
||||
import vazkii.botania.api.subtile.RadiusDescriptor;
|
||||
import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
|
||||
@@ -23,11 +29,55 @@ import vazkii.botania.common.block.ModSubtiles;
|
||||
import java.util.List;
|
||||
|
||||
public class SubTileEntropinnyum extends TileEntityGeneratingFlower {
|
||||
private static final String TAG_UNETHICAL = "botania:unethical";
|
||||
private static final int RANGE = 12;
|
||||
private static final int EXPLODE_EFFECT_EVENT = 0;
|
||||
private static final int ANGRY_EFFECT_EVENT = 1;
|
||||
|
||||
public SubTileEntropinnyum() {
|
||||
super(ModSubtiles.ENTROPINNYUM);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onEntityJoin);
|
||||
}
|
||||
|
||||
private void onEntityJoin(EntityJoinWorldEvent evt) {
|
||||
if (!evt.getWorld().isRemote && evt.getEntity() instanceof TNTEntity && isUnethical(evt.getEntity())) {
|
||||
evt.getEntity().getPersistentData().putBoolean(TAG_UNETHICAL, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isUnethical(Entity e) {
|
||||
BlockPos center = e.func_233580_cy_();
|
||||
int x = center.getX();
|
||||
int y = center.getY();
|
||||
int z = center.getZ();
|
||||
int range = 3;
|
||||
|
||||
// Should actually check for corals too, but it gets broken when the piston extends
|
||||
int movingPistons = 0;
|
||||
int rails = 0;
|
||||
int slimes = 0;
|
||||
for (BlockPos pos : BlockPos.getAllInBoxMutable(x - range, y - range, z - range, x + range + 1, y + range + 1, z + range + 1)) {
|
||||
BlockState state = e.world.getBlockState(pos);
|
||||
if (state.getBlock() == Blocks.MOVING_PISTON) {
|
||||
movingPistons++;
|
||||
TileEntity te = e.world.getTileEntity(pos);
|
||||
if (te instanceof PistonTileEntity) {
|
||||
state = ((PistonTileEntity) te).getPistonState();
|
||||
}
|
||||
}
|
||||
|
||||
if (state.getBlock() instanceof DetectorRailBlock) {
|
||||
rails++;
|
||||
} else if (state.getBlock() instanceof SlimeBlock || state.getBlock() instanceof HoneyBlock) {
|
||||
slimes++;
|
||||
}
|
||||
|
||||
if (movingPistons > 0 && rails > 0 && slimes > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,12 +89,13 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower {
|
||||
for (TNTEntity tnt : tnts) {
|
||||
FluidState fluid = getWorld().getFluidState(tnt.func_233580_cy_());
|
||||
if (tnt.getFuse() == 1 && tnt.isAlive() && fluid.isEmpty()) {
|
||||
tnt.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 0.2F, (1F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
boolean unethical = tnt.getPersistentData().getBoolean(TAG_UNETHICAL);
|
||||
tnt.playSound(unethical ? SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE : SoundEvents.ENTITY_GENERIC_EXPLODE, 0.2F, (1F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
tnt.remove();
|
||||
addMana(getMaxMana());
|
||||
addMana(unethical ? 3 : getMaxMana());
|
||||
sync();
|
||||
|
||||
getWorld().addBlockEvent(getPos(), getBlockState().getBlock(), EXPLODE_EFFECT_EVENT, tnt.getEntityId());
|
||||
getWorld().addBlockEvent(getPos(), getBlockState().getBlock(), unethical ? ANGRY_EFFECT_EVENT : EXPLODE_EFFECT_EVENT, tnt.getEntityId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -64,6 +115,16 @@ public class SubTileEntropinnyum extends TileEntityGeneratingFlower {
|
||||
|
||||
getWorld().addParticle(ParticleTypes.EXPLOSION_EMITTER, e.getPosX(), e.getPosY(), e.getPosZ(), 1D, 0D, 0D);
|
||||
}
|
||||
return true;
|
||||
} else if (event == ANGRY_EFFECT_EVENT) {
|
||||
if (getWorld().isRemote && getWorld().getEntityByID(param) instanceof TNTEntity) {
|
||||
Entity e = getWorld().getEntityByID(param);
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
world.addParticle(ParticleTypes.ANGRY_VILLAGER, e.getPosX() + Math.random() * 4 - 2, e.getPosY() + Math.random() * 4 - 2, e.getPosZ() + Math.random() * 4 - 2, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return super.receiveClientEvent(event, param);
|
||||
|
||||
@@ -2160,6 +2160,7 @@
|
||||
"botania.tagline.entropinnyum": "Mana from TNT",
|
||||
"botania.page.entropinnyum0": "To generate a blast of $(thing)Mana$(0), in fact, a blast might be required. Igniting a block of $(item)TNT$(0) on dry land near an $(item)Entropinnyum$(0) will have the latter absorb all the entropy generated by the blast, converting it into $(thing)Mana$(0) and nullifying any damage in the process. However, to absorb the explosion, the flower must not have any $(thing)Mana$(0) stored in it-- otherwise, explosions as usual.",
|
||||
"botania.page.entropinnyum1": "$(o)Cool guys don't look at explosions$().",
|
||||
"botania.page.entropinnyum2": "Note that the Entropinnyum has taken a liking to $(o)ethically-sourced$() TNT, produced by natural means. Feeding the flower unethically-sourced (for example, duplicated) TNT will incur a severe efficiency loss.$(p)The flower's detection abilities are limited; for best results, remove all nearby $(item)rails$(0), $(item)sticky blocks$(0), and $(item)pistons$(0).",
|
||||
|
||||
"botania.entry.kekimurus": "Kekimurus",
|
||||
"botania.tagline.kekimurus": "Mana from cake",
|
||||
|
||||
+4
@@ -12,6 +12,10 @@
|
||||
"type": "botania:petal_apothecary",
|
||||
"text": "botania.page.entropinnyum1",
|
||||
"recipe": "botania:petal_apothecary/entropinnyum"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "botania.page.entropinnyum2"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user