aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch180
1 files changed, 180 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch
new file mode 100644
index 0000000000..844e4e4634
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/item/PrimedTnt.java.patch
@@ -0,0 +1,180 @@
+--- a/net/minecraft/world/entity/item/PrimedTnt.java
++++ b/net/minecraft/world/entity/item/PrimedTnt.java
+@@ -10,45 +10,54 @@
+ import net.minecraft.network.syncher.SynchedEntityData;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityDimensions;
++import net.minecraft.world.entity.EntityPose;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.EnumMoveType;
+ import net.minecraft.world.entity.LivingEntity;
+-import net.minecraft.world.entity.MoverType;
+-import net.minecraft.world.entity.Pose;
+ import net.minecraft.world.entity.TraceableEntity;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.block.Blocks;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+
++// CraftBukkit start;
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++import org.bukkit.event.entity.ExplosionPrimeEvent;
++// CraftBukkit end
++
+ public class PrimedTnt extends Entity implements TraceableEntity {
++
+ private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT);
+- private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE);
++ private static final EntityDataAccessor<IBlockData> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE);
+ private static final int DEFAULT_FUSE_TIME = 80;
+ private static final String TAG_BLOCK_STATE = "block_state";
+ public static final String TAG_FUSE = "fuse";
+ @Nullable
+- private LivingEntity owner;
++ public LivingEntity owner;
++ public float yield = 4; // CraftBukkit - add field
++ public boolean isIncendiary = false; // CraftBukkit - add field
+
+ public PrimedTnt(EntityType<? extends PrimedTnt> entityType, Level level) {
+ super(entityType, level);
+ this.blocksBuilding = true;
+ }
+
+- public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
++ public PrimedTnt(Level level, double x, double d1, double y, @Nullable LivingEntity entityliving) {
+ this(EntityType.TNT, level);
+- this.setPos(x, y, z);
+- double d = level.random.nextDouble() * (float) (Math.PI * 2);
+- this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02);
++ this.setPos(x, d1, y);
++ double d3 = level.random.nextDouble() * 6.2831854820251465D;
++
++ this.setDeltaMovement(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
+ this.setFuse(80);
+ this.xo = x;
+- this.yo = y;
+- this.zo = z;
+- this.owner = owner;
++ this.yo = d1;
++ this.zo = y;
++ this.owner = entityliving;
+ }
+
+ @Override
+ protected void defineSynchedData() {
+- this.entityData.define(DATA_FUSE_ID, 80);
+- this.entityData.define(DATA_BLOCK_STATE_ID, Blocks.TNT.defaultBlockState());
++ this.entityData.define(PrimedTnt.DATA_FUSE_ID, 80);
++ this.entityData.define(PrimedTnt.DATA_BLOCK_STATE_ID, Blocks.TNT.defaultBlockState());
+ }
+
+ @Override
+@@ -64,38 +73,49 @@
+ @Override
+ public void tick() {
+ if (!this.isNoGravity()) {
+- this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0));
++ this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
+ }
+
+- this.move(MoverType.SELF, this.getDeltaMovement());
+- this.setDeltaMovement(this.getDeltaMovement().scale(0.98));
++ this.move(EnumMoveType.SELF, this.getDeltaMovement());
++ this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
+ if (this.onGround()) {
+- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7));
++ this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
+ }
+
+ int i = this.getFuse() - 1;
++
+ this.setFuse(i);
+ if (i <= 0) {
+- this.discard();
++ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
++ // this.discard();
+ if (!this.level().isClientSide) {
+ this.explode();
+ }
++ this.discard();
++ // CraftBukkit end
+ } else {
+ this.updateInWaterStateAndDoFluidPushing();
+ if (this.level().isClientSide) {
+- this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0);
++ this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
+ }
+ }
++
+ }
+
+ private void explode() {
+- float f = 4.0F;
+- this.level().explode(this, this.getX(), this.getY(0.0625), this.getZ(), 4.0F, Level.ExplosionInteraction.TNT);
++ // CraftBukkit start
++ // float f = 4.0F;
++ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity());
++
++ if (!event.isCancelled()) {
++ this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.a.TNT);
++ }
++ // CraftBukkit end
+ }
+
+ @Override
+ protected void addAdditionalSaveData(CompoundTag compound) {
+- compound.putShort("fuse", (short)this.getFuse());
++ compound.putShort("fuse", (short) this.getFuse());
+ compound.put("block_state", NbtUtils.writeBlockState(this.getBlockState()));
+ }
+
+@@ -105,6 +125,7 @@
+ if (compound.contains("block_state", 10)) {
+ this.setBlockState(NbtUtils.readBlockState(this.level().holderLookup(Registries.BLOCK), compound.getCompound("block_state")));
+ }
++
+ }
+
+ @Nullable
+@@ -116,29 +137,32 @@
+ @Override
+ public void restoreFrom(Entity entity) {
+ super.restoreFrom(entity);
+- if (entity instanceof PrimedTnt primedTnt) {
+- this.owner = primedTnt.owner;
++ if (entity instanceof PrimedTnt) {
++ PrimedTnt entitytntprimed = (PrimedTnt) entity;
++
++ this.owner = entitytntprimed.owner;
+ }
++
+ }
+
+ @Override
+- protected float getEyeHeight(Pose pose, EntityDimensions size) {
++ protected float getEyeHeight(EntityPose pose, EntityDimensions size) {
+ return 0.15F;
+ }
+
+ public void setFuse(int life) {
+- this.entityData.set(DATA_FUSE_ID, life);
++ this.entityData.set(PrimedTnt.DATA_FUSE_ID, life);
+ }
+
+ public int getFuse() {
+- return this.entityData.get(DATA_FUSE_ID);
++ return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID);
+ }
+
+- public void setBlockState(BlockState blockState) {
+- this.entityData.set(DATA_BLOCK_STATE_ID, blockState);
++ public void setBlockState(IBlockData iblockdata) {
++ this.entityData.set(PrimedTnt.DATA_BLOCK_STATE_ID, iblockdata);
+ }
+
+- public BlockState getBlockState() {
+- return this.entityData.get(DATA_BLOCK_STATE_ID);
++ public IBlockData getBlockState() {
++ return (IBlockData) this.entityData.get(PrimedTnt.DATA_BLOCK_STATE_ID);
+ }
+ }