aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch249
1 files changed, 249 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
new file mode 100644
index 0000000000..93a8cb523b
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
@@ -0,0 +1,249 @@
+--- a/net/minecraft/world/entity/vehicle/MinecartTNT.java
++++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java
+@@ -9,36 +9,43 @@
+ import net.minecraft.tags.BlockTags;
+ import net.minecraft.tags.DamageTypeTags;
+ import net.minecraft.world.damagesource.DamageSource;
++import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.player.Player;
+ import net.minecraft.world.entity.projectile.AbstractArrow;
+ import net.minecraft.world.item.Item;
+ import net.minecraft.world.item.Items;
+ import net.minecraft.world.level.BlockGetter;
+ import net.minecraft.world.level.Explosion;
++import net.minecraft.world.level.ExplosionDamageCalculator;
+ 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;
+ import net.minecraft.world.level.material.FluidState;
++// CraftBukkit start
++import org.bukkit.event.entity.ExplosionPrimeEvent;
++// CraftBukkit end
+
+ public class MinecartTNT extends AbstractMinecart {
++
+ private static final byte EVENT_PRIME = 10;
+- private int fuse = -1;
++ public int fuse = -1;
+
+ public MinecartTNT(EntityType<? extends MinecartTNT> entityType, Level level) {
+ super(entityType, level);
+ }
+
+- public MinecartTNT(Level level, double x, double y, double z) {
+- super(EntityType.TNT_MINECART, level, x, y, z);
++ public MinecartTNT(Level level, double x, double d1, double y) {
++ super(EntityType.TNT_MINECART, level, x, d1, y);
+ }
+
+ @Override
+- public AbstractMinecart.Type getMinecartType() {
+- return AbstractMinecart.Type.TNT;
++ public AbstractMinecart.EnumMinecartType getMinecartType() {
++ return AbstractMinecart.EnumMinecartType.TNT;
+ }
+
+ @Override
+- public BlockState getDefaultDisplayBlockState() {
++ public IBlockData getDefaultDisplayBlockState() {
+ return Blocks.TNT.defaultBlockState();
+ }
+
+@@ -46,25 +53,34 @@
+ public void tick() {
+ super.tick();
+ if (this.fuse > 0) {
+- this.fuse--;
+- this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0);
++ --this.fuse;
++ this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
+ } else if (this.fuse == 0) {
+ this.explode(this.getDeltaMovement().horizontalDistanceSqr());
+ }
+
+ if (this.horizontalCollision) {
+- double d = this.getDeltaMovement().horizontalDistanceSqr();
+- if (d >= 0.01F) {
+- this.explode(d);
++ double d0 = this.getDeltaMovement().horizontalDistanceSqr();
++
++ if (d0 >= 0.009999999776482582D) {
++ this.explode(d0);
+ }
+ }
++
+ }
+
+ @Override
+ public boolean hurt(DamageSource source, float amount) {
+- if (source.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.isOnFire()) {
+- DamageSource damageSource = this.damageSources().explosion(this, source.getEntity());
+- this.explode(damageSource, abstractArrow.getDeltaMovement().lengthSqr());
++ Entity entity = source.getDirectEntity();
++
++ if (entity instanceof AbstractArrow) {
++ AbstractArrow entityarrow = (AbstractArrow) entity;
++
++ if (entityarrow.isOnFire()) {
++ DamageSource damagesource1 = this.damageSources().explosion(this, source.getEntity());
++
++ this.explode(damagesource1, entityarrow.getDeltaMovement().lengthSqr());
++ }
+ }
+
+ return super.hurt(source, amount);
+@@ -72,14 +88,16 @@
+
+ @Override
+ public void destroy(DamageSource source) {
+- double d = this.getDeltaMovement().horizontalDistanceSqr();
+- if (!damageSourceIgnitesTnt(source) && !(d >= 0.01F)) {
++ double d0 = this.getDeltaMovement().horizontalDistanceSqr();
++
++ if (!damageSourceIgnitesTnt(source) && d0 < 0.009999999776482582D) {
+ this.destroy(this.getDropItem());
+ } else {
+ if (this.fuse < 0) {
+ this.primeFuse();
+ this.fuse = this.random.nextInt(20) + this.random.nextInt(20);
+ }
++
+ }
+ }
+
+@@ -88,38 +106,38 @@
+ return Items.TNT_MINECART;
+ }
+
+- protected void explode(double radiusModifier) {
+- this.explode(null, radiusModifier);
++ public void explode(double radiusModifier) {
++ this.explode((DamageSource) null, radiusModifier);
+ }
+
+ protected void explode(@Nullable DamageSource damageSource, double radiusModifier) {
+ if (!this.level().isClientSide) {
+- double squareRoot = Math.sqrt(radiusModifier);
+- if (squareRoot > 5.0) {
+- squareRoot = 5.0;
++ double d1 = Math.sqrt(radiusModifier);
++
++ if (d1 > 5.0D) {
++ d1 = 5.0D;
+ }
+
+- this.level()
+- .explode(
+- this,
+- damageSource,
+- null,
+- this.getX(),
+- this.getY(),
+- this.getZ(),
+- (float)(4.0 + this.random.nextDouble() * 1.5 * squareRoot),
+- false,
+- Level.ExplosionInteraction.TNT
+- );
++ // CraftBukkit start
++ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false);
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ fuse = -1;
++ return;
++ }
++ this.level().explode(this, damageSource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.a.TNT);
++ // CraftBukkit end
+ this.discard();
+ }
++
+ }
+
+ @Override
+ public boolean causeFallDamage(float fallDistance, float multiplier, DamageSource source) {
+ if (fallDistance >= 3.0F) {
+- float f = fallDistance / 10.0F;
+- this.explode((double)(f * f));
++ float f2 = fallDistance / 10.0F;
++
++ this.explode((double) (f2 * f2));
+ }
+
+ return super.causeFallDamage(fallDistance, multiplier, source);
+@@ -130,6 +148,7 @@
+ if (receivingPower && this.fuse < 0) {
+ this.primeFuse();
+ }
++
+ }
+
+ @Override
+@@ -139,16 +158,18 @@
+ } else {
+ super.handleEntityEvent(id);
+ }
++
+ }
+
+ public void primeFuse() {
+ this.fuse = 80;
+ if (!this.level().isClientSide) {
+- this.level().broadcastEntityEvent(this, (byte)10);
++ this.level().broadcastEntityEvent(this, (byte) 10);
+ if (!this.isSilent()) {
+- this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
++ this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
+ }
+ }
++
+ }
+
+ public int getFuse() {
+@@ -160,18 +181,13 @@
+ }
+
+ @Override
+- public float getBlockExplosionResistance(
+- Explosion explosion, BlockGetter level, BlockPos pos, BlockState blockState, FluidState fluidState, float explosionPower
+- ) {
+- return !this.isPrimed() || !blockState.is(BlockTags.RAILS) && !level.getBlockState(pos.above()).is(BlockTags.RAILS)
+- ? super.getBlockExplosionResistance(explosion, level, pos, blockState, fluidState, explosionPower)
+- : 0.0F;
++ public float getBlockExplosionResistance(Explosion explosion, BlockGetter level, BlockPos pos, IBlockData blockState, FluidState fluidState, float explosionPower) {
++ return this.isPrimed() && (blockState.is(BlockTags.RAILS) || level.getBlockState(pos.above()).is(BlockTags.RAILS)) ? 0.0F : super.getBlockExplosionResistance(explosion, level, pos, blockState, fluidState, explosionPower);
+ }
+
+ @Override
+- public boolean shouldBlockExplode(Explosion explosion, BlockGetter level, BlockPos pos, BlockState blockState, float explosionPower) {
+- return (!this.isPrimed() || !blockState.is(BlockTags.RAILS) && !level.getBlockState(pos.above()).is(BlockTags.RAILS))
+- && super.shouldBlockExplode(explosion, level, pos, blockState, explosionPower);
++ public boolean shouldBlockExplode(Explosion explosion, BlockGetter level, BlockPos pos, IBlockData blockState, float explosionPower) {
++ return this.isPrimed() && (blockState.is(BlockTags.RAILS) || level.getBlockState(pos.above()).is(BlockTags.RAILS)) ? false : super.shouldBlockExplode(explosion, level, pos, blockState, explosionPower);
+ }
+
+ @Override
+@@ -180,6 +196,7 @@
+ if (compound.contains("TNTFuse", 99)) {
+ this.fuse = compound.getInt("TNTFuse");
+ }
++
+ }
+
+ @Override
+@@ -189,11 +206,11 @@
+ }
+
+ @Override
+- boolean shouldSourceDestroy(DamageSource damageSource) {
+- return damageSourceIgnitesTnt(damageSource);
++ boolean shouldSourceDestroy(DamageSource damagesource) {
++ return damageSourceIgnitesTnt(damagesource);
+ }
+
+- private static boolean damageSourceIgnitesTnt(DamageSource damageSource) {
+- return damageSource.is(DamageTypeTags.IS_FIRE) || damageSource.is(DamageTypeTags.IS_EXPLOSION);
++ private static boolean damageSourceIgnitesTnt(DamageSource damagesource) {
++ return damagesource.is(DamageTypeTags.IS_FIRE) || damagesource.is(DamageTypeTags.IS_EXPLOSION);
+ }
+ }