diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle')
7 files changed, 601 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch new file mode 100644 index 0000000000..9ba7ab24fd --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -0,0 +1,218 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java +@@ -46,6 +48,14 @@ + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.util.CraftLocation; ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; ++import org.bukkit.util.Vector; ++// CraftBukkit end ++ + public abstract class AbstractMinecart extends VehicleEntity { + private static final float LOWERED_PASSENGER_ATTACHMENT_Y = 0.0F; + private static final float PASSENGER_ATTACHMENT_Y = 0.1875F; +@@ -86,6 +96,17 @@ + map.put(RailShape.NORTH_EAST, Pair.of(normal2, normal1)); + }); + ++ // CraftBukkit start ++ public boolean slowWhenEmpty = true; ++ private double derailedX = 0.5; ++ private double derailedY = 0.5; ++ private double derailedZ = 0.5; ++ private double flyingX = 0.95; ++ private double flyingY = 0.95; ++ private double flyingZ = 0.95; ++ public double maxSpeed = 0.4D; ++ // CraftBukkit end ++ + protected AbstractMinecart(EntityType<?> entityType, Level level) { + super(entityType, level); + this.blocksBuilding = true; +@@ -230,6 +286,14 @@ + + @Override + public void tick() { ++ // CraftBukkit start ++ double prevX = this.getX(); ++ double prevY = this.getY(); ++ double prevZ = this.getZ(); ++ float prevYaw = this.getYRot(); ++ float prevPitch = this.getXRot(); ++ // CraftBukkit end ++ + if (this.getHurtTime() > 0) { + this.setHurtTime(this.getHurtTime() - 1); + } +@@ -239,7 +303,7 @@ + } + + this.checkBelowWorld(); +- this.handleNetherPortal(); ++ // this.handleNetherPortal(); // CraftBukkit - handled in postTick + if (this.level().isClientSide) { + if (this.lerpSteps > 0) { + this.lerpPositionAndRotationStep(this.lerpSteps, this.lerpX, this.lerpY, this.lerpZ, this.lerpYRot, this.lerpXRot); +@@ -291,17 +361,48 @@ + } + + this.setRot(this.getYRot(), this.getXRot()); +- if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01) { +- List<Entity> entities = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F), EntitySelector.pushableBy(this)); +- if (!entities.isEmpty()) { +- for (Entity entity : entities) { +- if (!(entity instanceof Player) +- && !(entity instanceof IronGolem) +- && !(entity instanceof AbstractMinecart) +- && !this.isVehicle() +- && !entity.isPassenger()) { ++ // CraftBukkit start ++ org.bukkit.World bworld = this.level().getWorld(); ++ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch); ++ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot()); ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ ++ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); ++ ++ if (!from.equals(to)) { ++ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to)); ++ } ++ // CraftBukkit end ++ if (this.getMinecartType() == AbstractMinecart.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { ++ List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this)); ++ ++ if (!list.isEmpty()) { ++ Iterator iterator = list.iterator(); ++ ++ while (iterator.hasNext()) { ++ Entity entity = (Entity) iterator.next(); ++ ++ if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + entity.startRiding(this); + } else { ++ // CraftBukkit start ++ if (!this.isPassengerOfSameVehicle(entity)) { ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + entity.push(this); + } + } +@@ -309,6 +414,14 @@ + } else { + for (Entity entity1 : this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, 0.0, 0.2F))) { + if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ continue; ++ } ++ // CraftBukkit end + entity1.push(this); + } + } +@@ -325,7 +438,7 @@ + } + + protected double getMaxSpeed() { +- return (this.isInWater() ? 4.0 : 8.0) / 20.0; ++ return (this.isInWater() ? this.maxSpeed / 2.0D: this.maxSpeed); // CraftBukkit + } + + public void activateMinecart(int x, int y, int z, boolean powered) { +@@ -336,12 +449,16 @@ + Vec3 deltaMovement = this.getDeltaMovement(); + this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); + if (this.onGround()) { +- this.setDeltaMovement(this.getDeltaMovement().scale(0.5)); ++ // CraftBukkit start - replace magic numbers with our variables ++ this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ)); ++ // CraftBukkit end + } + + this.move(MoverType.SELF, this.getDeltaMovement()); + if (!this.onGround()) { +- this.setDeltaMovement(this.getDeltaMovement().scale(0.95)); ++ // CraftBukkit start - replace magic numbers with our variables ++ this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.flyingX, this.getDeltaMovement().y * this.flyingY, this.getDeltaMovement().z * this.flyingZ)); ++ // CraftBukkit end + } + } + +@@ -514,9 +654,10 @@ + } + + protected void applyNaturalSlowdown() { +- double d = this.isVehicle() ? 0.997 : 0.96; +- Vec3 deltaMovement = this.getDeltaMovement(); +- Vec3 var4 = deltaMovement.multiply(d, 0.0, d); ++ double d0 = this.isVehicle() || !this.slowWhenEmpty ? 0.997D : 0.96D; // CraftBukkit - add !this.slowWhenEmpty ++ Vec3 vec3d = this.getDeltaMovement(); ++ ++ vec3d = vec3d.multiply(d0, 0.0D, d0); + if (this.isInWater()) { + var4 = var4.scale(0.95F); + } +@@ -641,7 +793,15 @@ + if (!this.level().isClientSide) { + if (!entity.noPhysics && !this.noPhysics) { + if (!this.hasPassenger(entity)) { +- double d = entity.getX() - this.getX(); ++ // CraftBukkit start ++ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent); ++ ++ if (collisionEvent.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end ++ double d0 = entity.getX() - this.getX(); + double d1 = entity.getZ() - this.getZ(); + double d2 = d * d + d1 * d1; + if (d2 >= 1.0E-4F) { +@@ -803,4 +975,26 @@ + HOPPER, + COMMAND_BLOCK; + } ++ ++ // CraftBukkit start - Methods for getting and setting flying and derailed velocity modifiers ++ public Vector getFlyingVelocityMod() { ++ return new Vector(flyingX, flyingY, flyingZ); ++ } ++ ++ public void setFlyingVelocityMod(Vector flying) { ++ flyingX = flying.getX(); ++ flyingY = flying.getY(); ++ flyingZ = flying.getZ(); ++ } ++ ++ public Vector getDerailedVelocityMod() { ++ return new Vector(derailedX, derailedY, derailedZ); ++ } ++ ++ public void setDerailedVelocityMod(Vector derailed) { ++ derailedX = derailed.getX(); ++ derailedY = derailed.getY(); ++ derailedZ = derailed.getZ(); ++ } ++ // CraftBukkit end + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch new file mode 100644 index 0000000000..31135f280a --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -0,0 +1,74 @@ +--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +@@ -16,6 +17,13 @@ + import net.minecraft.world.inventory.AbstractContainerMenu; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.Level; ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.inventory.InventoryHolder; ++// CraftBukkit end + + public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { + private NonNullList<ItemStack> itemStacks = NonNullList.withSize(36, ItemStack.EMPTY); +@@ -23,12 +32,55 @@ + private ResourceLocation lootTable; + private long lootTableSeed; + ++ // CraftBukkit start ++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); ++ private int maxStack = MAX_STACK; ++ ++ public List<ItemStack> getContents() { ++ return this.itemStacks; ++ } ++ ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ public List<HumanEntity> getViewers() { ++ return transaction; ++ } ++ ++ public InventoryHolder getOwner() { ++ org.bukkit.entity.Entity cart = getBukkitEntity(); ++ if(cart instanceof InventoryHolder) return (InventoryHolder) cart; ++ return null; ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ } ++ ++ @Override ++ public Location getLocation() { ++ return getBukkitEntity().getLocation(); ++ } ++ // CraftBukkit end ++ + protected AbstractMinecartContainer(EntityType<?> entityType, Level level) { + super(entityType, level); ++ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 + } + +- protected AbstractMinecartContainer(EntityType<?> entityType, double x, double y, double z, Level level) { +- super(entityType, level, x, y, z); ++ protected AbstractMinecartContainer(EntityType<?> entityType, double x, double d1, double y, Level world) { ++ super(entityType, world, x, d1, y); ++ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 + } + + @Override diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/Boat.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/Boat.java.patch new file mode 100644 index 0000000000..4fb52855db --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/Boat.java.patch @@ -0,0 +1,114 @@ +--- a/net/minecraft/world/entity/vehicle/Boat.java ++++ b/net/minecraft/world/entity/vehicle/Boat.java +@@ -52,6 +55,15 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + import org.joml.Vector3f; + ++// CraftBukkit start ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.util.CraftLocation; ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleDestroyEvent; ++import org.bukkit.event.vehicle.VehicleEntityCollisionEvent; ++import org.bukkit.event.vehicle.VehicleMoveEvent; ++// CraftBukkit end ++ + public class Boat extends VehicleEntity implements VariantHolder<Boat.Type> { + private static final EntityDataAccessor<Integer> DATA_ID_TYPE = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.INT); + private static final EntityDataAccessor<Boolean> DATA_ID_PADDLE_LEFT = SynchedEntityData.defineId(Boat.class, EntityDataSerializers.BOOLEAN); +@@ -88,6 +101,14 @@ + private float bubbleAngle; + private float bubbleAngleO; + ++ // CraftBukkit start ++ // PAIL: Some of these haven't worked since a few updates, and since 1.9 they are less and less applicable. ++ public double maxSpeed = 0.4D; ++ public double occupiedDeceleration = 0.2D; ++ public double unoccupiedDeceleration = -1; ++ public boolean landBoats = false; ++ // CraftBukkit end ++ + public Boat(EntityType<? extends Boat> entityType, Level level) { + super(entityType, level); + this.blocksBuilding = true; +@@ -198,9 +209,29 @@ + public void push(Entity entity) { + if (entity instanceof Boat) { + if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { ++ // CraftBukkit start ++ if (!this.isPassengerOfSameVehicle(entity)) { ++ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ } ++ // CraftBukkit end + super.push(entity); + } + } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) { ++ // CraftBukkit start ++ if (!this.isPassengerOfSameVehicle(entity)) { ++ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ } ++ // CraftBukkit end + super.push(entity); + } + } +@@ -272,6 +325,7 @@ + return this.getDirection().getClockWise(); + } + ++ private Location lastLocation; // CraftBukkit + @Override + public void tick() { + this.oldStatus = this.status; +@@ -312,6 +366,22 @@ + this.setDeltaMovement(Vec3.ZERO); + } + ++ // CraftBukkit start ++ org.bukkit.Server server = this.level().getCraftServer(); ++ org.bukkit.World bworld = this.level().getWorld(); ++ ++ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot()); ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ ++ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle)); ++ ++ if (lastLocation != null && !lastLocation.equals(to)) { ++ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, lastLocation, to); ++ server.getPluginManager().callEvent(event); ++ } ++ lastLocation = vehicle.getLocation(); ++ // CraftBukkit end ++ + this.tickBubbleColumn(); + + for (int i = 0; i <= 1; i++) { +@@ -782,6 +867,11 @@ + + this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall()); + if (!this.level().isClientSide && !this.isRemoved()) { ++ // CraftBukkit start ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null); ++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); ++ if (!destroyEvent.isCancelled()) { + this.kill(); + if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + for (int i = 0; i < 3; i++) { +@@ -793,6 +885,7 @@ + } + } + } ++ } // CraftBukkit end + } + + this.resetFallDistance(); diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/ChestBoat.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/ChestBoat.java.patch new file mode 100644 index 0000000000..9d7239e776 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/ChestBoat.java.patch @@ -0,0 +1,68 @@ +--- a/net/minecraft/world/entity/vehicle/ChestBoat.java ++++ b/net/minecraft/world/entity/vehicle/ChestBoat.java +@@ -22,6 +23,13 @@ + import net.minecraft.world.item.Items; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.gameevent.GameEvent; ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.entity.HumanEntity; ++import org.bukkit.inventory.InventoryHolder; ++// CraftBukkit end + + public class ChestBoat extends Boat implements HasCustomInventoryScreen, ContainerEntity { + private static final int CONTAINER_SIZE = 27; +@@ -212,4 +245,51 @@ + public void stopOpen(Player player) { + this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(player)); + } ++ ++ // CraftBukkit start ++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); ++ private int maxStack = MAX_STACK; ++ ++ @Override ++ public List<ItemStack> getContents() { ++ return this.itemStacks; ++ } ++ ++ @Override ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ @Override ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ } ++ ++ @Override ++ public List<HumanEntity> getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public InventoryHolder getOwner() { ++ org.bukkit.entity.Entity entity = getBukkitEntity(); ++ if (entity instanceof InventoryHolder) return (InventoryHolder) entity; ++ return null; ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ @Override ++ public void setMaxStackSize(int size) { ++ maxStack = size; ++ } ++ ++ @Override ++ public Location getLocation() { ++ return getBukkitEntity().getLocation(); ++ } ++ // CraftBukkit end + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch new file mode 100644 index 0000000000..b008b28e5d --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java ++++ b/net/minecraft/world/entity/vehicle/MinecartCommandBlock.java +@@ -146,5 +143,12 @@ + public boolean isValid() { + return !MinecartCommandBlock.this.isRemoved(); + } ++ ++ // CraftBukkit start ++ @Override ++ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) { ++ return (org.bukkit.craftbukkit.entity.CraftMinecartCommand) MinecartCommandBlock.this.getBukkitEntity(); ++ } ++ // CraftBukkit end + } + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch new file mode 100644 index 0000000000..ddd764dafa --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/world/entity/vehicle/MinecartTNT.java ++++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java +@@ -19,6 +22,9 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.state.BlockState; + 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; +@@ -99,18 +118,15 @@ + squareRoot = 5.0; + } + +- 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(); + } + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch new file mode 100644 index 0000000000..3300c9d219 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch @@ -0,0 +1,72 @@ +--- a/net/minecraft/world/entity/vehicle/VehicleEntity.java ++++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java +@@ -13,6 +13,12 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.gameevent.GameEvent; + ++// CraftBukkit start ++import org.bukkit.entity.Vehicle; ++import org.bukkit.event.vehicle.VehicleDamageEvent; ++import org.bukkit.event.vehicle.VehicleDestroyEvent; ++// CraftBukkit end ++ + public abstract class VehicleEntity extends Entity { + protected static final EntityDataAccessor<Integer> DATA_ID_HURT = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); + protected static final EntityDataAccessor<Integer> DATA_ID_HURTDIR = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.INT); +@@ -40,9 +35,54 @@ + this.discard(); + } + } else { +- this.destroy(source); +- } ++ // CraftBukkit start ++ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); ++ org.bukkit.entity.Entity attacker = (source.getEntity() == null) ? null : source.getEntity().getBukkitEntity(); + ++ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) amount); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return false; ++ } ++ amount = (float) event.getDamage(); ++ // CraftBukkit end ++ this.setHurtDir(-this.getHurtDir()); ++ this.setHurtTime(10); ++ this.markHurt(); ++ this.setDamage(this.getDamage() + amount * 10.0F); ++ this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity()); ++ boolean flag = source.getEntity() instanceof Player && ((Player) source.getEntity()).getAbilities().instabuild; ++ ++ if ((flag || this.getDamage() <= 40.0F) && !this.shouldSourceDestroy(source)) { ++ if (flag) { ++ // CraftBukkit start ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); ++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); ++ ++ if (destroyEvent.isCancelled()) { ++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end ++ this.discard(); ++ } ++ } else { ++ // CraftBukkit start ++ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker); ++ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent); ++ ++ if (destroyEvent.isCancelled()) { ++ this.setDamage(40.0F); // Maximize damage so this doesn't get triggered again right away ++ return true; ++ } ++ // CraftBukkit end ++ this.destroy(source); ++ } ++ ++ return true; ++ } ++ } else { + return true; + } + } |