aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch156
1 files changed, 156 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
new file mode 100644
index 0000000000..ffeffb251f
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/vehicle/VehicleEntity.java.patch
@@ -0,0 +1,156 @@
+--- a/net/minecraft/world/entity/vehicle/VehicleEntity.java
++++ b/net/minecraft/world/entity/vehicle/VehicleEntity.java
+@@ -13,7 +13,14 @@
+ 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);
+ protected static final EntityDataAccessor<Float> DATA_ID_DAMAGE = SynchedEntityData.defineId(VehicleEntity.class, EntityDataSerializers.FLOAT);
+@@ -24,74 +31,108 @@
+
+ @Override
+ public boolean hurt(DamageSource source, float amount) {
+- if (this.level().isClientSide || this.isRemoved()) {
+- return true;
+- } else if (this.isInvulnerableTo(source)) {
+- return false;
+- } else {
+- 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) {
+- this.discard();
+- }
++ if (!this.level().isClientSide && !this.isRemoved()) {
++ if (this.isInvulnerableTo(source)) {
++ return false;
+ } 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;
+ }
+ }
+
+- boolean shouldSourceDestroy(DamageSource damageSource) {
++ boolean shouldSourceDestroy(DamageSource damagesource) {
+ return false;
+ }
+
+ public void destroy(Item item) {
+ this.kill();
+ if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
+- ItemStack itemStack = new ItemStack(item);
++ ItemStack itemstack = new ItemStack(item);
++
+ if (this.hasCustomName()) {
+- itemStack.setHoverName(this.getCustomName());
++ itemstack.setHoverName(this.getCustomName());
+ }
+
+- this.spawnAtLocation(itemStack);
++ this.spawnAtLocation(itemstack);
+ }
+ }
+
+ @Override
+ protected void defineSynchedData() {
+- this.entityData.define(DATA_ID_HURT, 0);
+- this.entityData.define(DATA_ID_HURTDIR, 1);
+- this.entityData.define(DATA_ID_DAMAGE, 0.0F);
++ this.entityData.define(VehicleEntity.DATA_ID_HURT, 0);
++ this.entityData.define(VehicleEntity.DATA_ID_HURTDIR, 1);
++ this.entityData.define(VehicleEntity.DATA_ID_DAMAGE, 0.0F);
+ }
+
+ public void setHurtTime(int i) {
+- this.entityData.set(DATA_ID_HURT, i);
++ this.entityData.set(VehicleEntity.DATA_ID_HURT, i);
+ }
+
+ public void setHurtDir(int i) {
+- this.entityData.set(DATA_ID_HURTDIR, i);
++ this.entityData.set(VehicleEntity.DATA_ID_HURTDIR, i);
+ }
+
+ public void setDamage(float f) {
+- this.entityData.set(DATA_ID_DAMAGE, f);
++ this.entityData.set(VehicleEntity.DATA_ID_DAMAGE, f);
+ }
+
+ public float getDamage() {
+- return this.entityData.get(DATA_ID_DAMAGE);
++ return (Float) this.entityData.get(VehicleEntity.DATA_ID_DAMAGE);
+ }
+
+ public int getHurtTime() {
+- return this.entityData.get(DATA_ID_HURT);
++ return (Integer) this.entityData.get(VehicleEntity.DATA_ID_HURT);
+ }
+
+ public int getHurtDir() {
+- return this.entityData.get(DATA_ID_HURTDIR);
++ return (Integer) this.entityData.get(VehicleEntity.DATA_ID_HURTDIR);
+ }
+
+ protected void destroy(DamageSource damageSource) {