@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
|
||||
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
|
||||
@@ -43,6 +43,8 @@
|
||||
@@ -45,6 +45,8 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -8,35 +8,44 @@
|
||||
+
|
||||
public class EntityFallingBlock extends Entity {
|
||||
|
||||
private IBlockData block;
|
||||
@@ -109,7 +111,7 @@
|
||||
private IBlockData blockState;
|
||||
@@ -114,7 +116,7 @@
|
||||
|
||||
if (this.ticksLived++ == 0) {
|
||||
if (this.time++ == 0) {
|
||||
blockposition = this.getChunkCoordinates();
|
||||
- if (this.world.getType(blockposition).a(block)) {
|
||||
+ if (this.world.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
this.world.a(blockposition, false);
|
||||
} else if (!this.world.isClientSide) {
|
||||
- if (this.level.getType(blockposition).a(block)) {
|
||||
+ if (this.level.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
this.level.a(blockposition, false);
|
||||
} else if (!this.level.isClientSide) {
|
||||
this.die();
|
||||
@@ -161,6 +163,11 @@
|
||||
this.block = (IBlockData) this.block.set(BlockProperties.C, true);
|
||||
@@ -165,6 +167,11 @@
|
||||
this.blockState = (IBlockData) this.blockState.set(BlockProperties.WATERLOGGED, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.world.setTypeAndData(blockposition, this.block, 3)) {
|
||||
if (block instanceof BlockFalling) {
|
||||
((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata, this);
|
||||
@@ -217,7 +224,9 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
if (this.level.setTypeAndData(blockposition, this.blockState, 3)) {
|
||||
((WorldServer) this.level).getChunkProvider().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getType(blockposition)));
|
||||
this.die();
|
||||
@@ -238,7 +245,7 @@
|
||||
if (i < 0) {
|
||||
return false;
|
||||
} else {
|
||||
- Predicate predicate;
|
||||
+ Predicate<Entity> predicate; // CraftBukkit - decompile error
|
||||
DamageSource damagesource1;
|
||||
|
||||
if (this.blockState.getBlock() instanceof Fallable) {
|
||||
@@ -254,7 +261,9 @@
|
||||
float f2 = (float) Math.min(MathHelper.d((float) i * this.fallDamagePerDistance), this.fallDamageMax);
|
||||
|
||||
this.level.getEntities(this, this.getBoundingBox(), predicate).forEach((entity) -> {
|
||||
+ CraftEventFactory.entityDamage = this; // CraftBukkit
|
||||
entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax));
|
||||
entity.damageEntity(damagesource1, f2);
|
||||
+ CraftEventFactory.entityDamage = null; // CraftBukkit
|
||||
}
|
||||
});
|
||||
boolean flag = this.blockState.a((Tag) TagsBlock.ANVIL);
|
||||
|
||||
if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/item/EntityItem.java
|
||||
+++ b/net/minecraft/world/entity/item/EntityItem.java
|
||||
@@ -31,6 +31,12 @@
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -33,6 +33,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -12,16 +12,16 @@
|
||||
+
|
||||
public class EntityItem extends Entity {
|
||||
|
||||
private static final DataWatcherObject<ItemStack> ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.g);
|
||||
@@ -40,6 +46,7 @@
|
||||
private static final DataWatcherObject<ItemStack> DATA_ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.ITEM_STACK);
|
||||
@@ -45,6 +51,7 @@
|
||||
private UUID thrower;
|
||||
private UUID owner;
|
||||
public final float b;
|
||||
public final float bobOffs;
|
||||
+ private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
||||
|
||||
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -75,9 +82,12 @@
|
||||
@@ -94,9 +101,12 @@
|
||||
this.die();
|
||||
} else {
|
||||
super.tick();
|
||||
@@ -35,10 +35,10 @@
|
||||
+ this.lastTick = MinecraftServer.currentTick;
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.lastX = this.locX();
|
||||
this.lastY = this.locY();
|
||||
@@ -133,9 +143,11 @@
|
||||
}
|
||||
this.xo = this.locX();
|
||||
this.yo = this.locY();
|
||||
@@ -148,9 +158,11 @@
|
||||
this.mergeNearby();
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start - moved up
|
||||
@@ -47,12 +47,12 @@
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.impulse |= this.aK();
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -147,6 +159,12 @@
|
||||
this.hasImpulse |= this.aR();
|
||||
if (!this.level.isClientSide) {
|
||||
@@ -162,6 +174,12 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide && this.age >= 6000) {
|
||||
if (!this.level.isClientSide && this.age >= 6000) {
|
||||
+ // CraftBukkit start - fire ItemDespawnEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
+ this.age = 0;
|
||||
@@ -62,7 +62,7 @@
|
||||
this.die();
|
||||
}
|
||||
|
||||
@@ -222,10 +240,11 @@
|
||||
@@ -237,10 +255,11 @@
|
||||
private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
|
||||
ItemStack itemstack2 = a(itemstack, itemstack1, 64);
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
a(entityitem, itemstack, itemstack1);
|
||||
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
|
||||
entityitem.age = Math.min(entityitem.age, entityitem1.age);
|
||||
@@ -249,6 +268,11 @@
|
||||
@@ -264,6 +283,11 @@
|
||||
} else if (!this.getItemStack().getItem().a(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -85,22 +85,22 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.velocityChanged();
|
||||
this.f = (int) ((float) this.f - f);
|
||||
if (this.f <= 0) {
|
||||
@@ -310,6 +334,46 @@
|
||||
this.health = (int) ((float) this.health - f);
|
||||
this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
|
||||
@@ -327,6 +351,46 @@
|
||||
Item item = itemstack.getItem();
|
||||
int i = itemstack.getCount();
|
||||
|
||||
+ // CraftBukkit start - fire PlayerPickupItemEvent
|
||||
+ int canHold = entityhuman.inventory.canHold(itemstack);
|
||||
+ int canHold = entityhuman.getInventory().canHold(itemstack);
|
||||
+ int remaining = i - canHold;
|
||||
+
|
||||
+ if (this.pickupDelay <= 0 && canHold > 0) {
|
||||
+ itemstack.setCount(canHold);
|
||||
+ // Call legacy event
|
||||
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ playerEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(playerEvent);
|
||||
+ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
|
||||
+ this.level.getServer().getPluginManager().callEvent(playerEvent);
|
||||
+ if (playerEvent.isCancelled()) {
|
||||
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||
+ return;
|
||||
@@ -108,8 +108,8 @@
|
||||
+
|
||||
+ // Call newer event afterwards
|
||||
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ entityEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(entityEvent);
|
||||
+ entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems());
|
||||
+ this.level.getServer().getPluginManager().callEvent(entityEvent);
|
||||
+ if (entityEvent.isCancelled()) {
|
||||
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||
+ return;
|
||||
@@ -131,16 +131,16 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
|
||||
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.getInventory().pickup(itemstack)) {
|
||||
entityhuman.receive(this, i);
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -353,7 +417,9 @@
|
||||
@@ -370,7 +434,9 @@
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
|
||||
this.getDataWatcher().set(EntityItem.ITEM, itemstack);
|
||||
+ this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
|
||||
this.getDataWatcher().set(EntityItem.DATA_ITEM, itemstack);
|
||||
+ this.getDataWatcher().markDirty(EntityItem.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,31 +8,31 @@
|
||||
+
|
||||
public class EntityTNTPrimed extends Entity {
|
||||
|
||||
private static final DataWatcherObject<Integer> FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
|
||||
private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.INT);
|
||||
private static final int DEFAULT_FUSE_TIME = 80;
|
||||
@Nullable
|
||||
public EntityLiving source;
|
||||
private int fuseTicks;
|
||||
public EntityLiving owner;
|
||||
+ public float yield = 4; // CraftBukkit - add field
|
||||
+ public boolean isIncendiary = false; // CraftBukkit - add field
|
||||
|
||||
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -72,10 +76,13 @@
|
||||
@@ -73,10 +77,13 @@
|
||||
|
||||
--this.fuseTicks;
|
||||
if (this.fuseTicks <= 0) {
|
||||
this.setFuseTicks(i);
|
||||
if (i <= 0) {
|
||||
- this.die();
|
||||
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
|
||||
+ // this.die();
|
||||
if (!this.world.isClientSide) {
|
||||
if (!this.level.isClientSide) {
|
||||
this.explode();
|
||||
}
|
||||
+ this.die();
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.aK();
|
||||
if (this.world.isClientSide) {
|
||||
@@ -86,9 +93,16 @@
|
||||
this.aR();
|
||||
if (this.level.isClientSide) {
|
||||
@@ -87,9 +94,16 @@
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
@@ -40,12 +40,12 @@
|
||||
+ // CraftBukkit start
|
||||
+ // float f = 4.0F;
|
||||
|
||||
- this.world.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK);
|
||||
- this.level.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK);
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ this.level.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.world.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
|
||||
+ this.level.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user