Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
|
||||
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -52,6 +52,11 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start;
|
||||
@@ -9,24 +9,26 @@
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityFallingBlock extends Entity {
|
||||
public class FallingBlockEntity extends Entity {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -87,10 +92,17 @@
|
||||
}
|
||||
|
||||
public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) {
|
||||
- FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, state.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) state.setValue(BlockStateProperties.WATERLOGGED, false) : state);
|
||||
+ // CraftBukkit start
|
||||
+ return fall(world, blockposition, iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return FallingBlockEntity.fall(world, pos, state, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockProperties.WATERLOGGED) ? (IBlockData) iblockdata.setValue(BlockProperties.WATERLOGGED, false) : iblockdata);
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
|
||||
|
||||
world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
|
||||
- world.setBlock(pos, state.getFluidState().createLegacyBlock(), 3);
|
||||
- world.addFreshEntity(entityfallingblock);
|
||||
+ public static FallingBlockEntity fall(Level world, BlockPos blockposition, BlockState iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
+ FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) iblockdata.setValue(BlockStateProperties.WATERLOGGED, false) : iblockdata);
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
|
||||
+
|
||||
+ world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
|
||||
+ world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
|
||||
return entityfallingblock;
|
||||
}
|
||||
@@ -41,16 +43,16 @@
|
||||
Block block = this.blockState.getBlock();
|
||||
|
||||
@@ -174,7 +186,7 @@
|
||||
this.spawnAtLocation(worldserver, (IMaterial) block);
|
||||
this.spawnAtLocation(worldserver, (ItemLike) block);
|
||||
}
|
||||
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
} else {
|
||||
IBlockData iblockdata = this.level().getBlockState(blockposition);
|
||||
BlockState iblockdata = this.level().getBlockState(blockposition);
|
||||
@@ -191,9 +203,15 @@
|
||||
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
|
||||
this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -60,7 +62,7 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.level().setBlock(blockposition, this.blockState, 3)) {
|
||||
((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition)));
|
||||
((ServerLevel) this.level()).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level().getBlockState(blockposition)));
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
if (block instanceof Fallable) {
|
||||
@@ -73,14 +75,14 @@
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
this.callOnBrokenAfterFall(block, blockposition);
|
||||
this.spawnAtLocation(worldserver, (IMaterial) block);
|
||||
this.spawnAtLocation(worldserver, (ItemLike) block);
|
||||
}
|
||||
} else {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
this.callOnBrokenAfterFall(block, blockposition);
|
||||
this.spawnAtLocation(worldserver, (IMaterial) block);
|
||||
this.spawnAtLocation(worldserver, (ItemLike) block);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1,30 +1,68 @@
|
||||
--- a/net/minecraft/world/entity/item/EntityItem.java
|
||||
+++ b/net/minecraft/world/entity/item/EntityItem.java
|
||||
@@ -34,6 +34,15 @@
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -5,18 +5,6 @@
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
-import net.minecraft.core.BlockPos;
|
||||
-import net.minecraft.nbt.CompoundTag;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
-import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
-import net.minecraft.network.syncher.SynchedEntityData;
|
||||
-import net.minecraft.server.level.ServerLevel;
|
||||
-import net.minecraft.sounds.SoundSource;
|
||||
-import net.minecraft.stats.Stats;
|
||||
-import net.minecraft.tags.FluidTags;
|
||||
-import net.minecraft.tags.ItemTags;
|
||||
-import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -24,7 +12,6 @@
|
||||
import net.minecraft.world.entity.MoverType;
|
||||
import net.minecraft.world.entity.SlotAccess;
|
||||
import net.minecraft.world.entity.TraceableEntity;
|
||||
-import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
@@ -33,6 +20,26 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.portal.TeleportTransition;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.network.chat.Component;
|
||||
+import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
+import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
+import net.minecraft.network.syncher.SynchedEntityData;
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.sounds.SoundSource;
|
||||
+import net.minecraft.stats.Stats;
|
||||
+import net.minecraft.tags.FluidTags;
|
||||
+import net.minecraft.tags.ItemTags;
|
||||
+import net.minecraft.util.Mth;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityItem extends Entity implements TraceableEntity {
|
||||
|
||||
private static final DataWatcherObject<ItemStack> DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK);
|
||||
@@ -52,6 +61,7 @@
|
||||
public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
||||
@@ -52,6 +59,7 @@
|
||||
@Nullable
|
||||
public UUID target;
|
||||
public final float bobOffs;
|
||||
+ private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
||||
|
||||
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -133,12 +143,15 @@
|
||||
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -133,12 +141,15 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.getItem().isEmpty()) {
|
||||
@@ -44,7 +82,7 @@
|
||||
|
||||
this.xo = this.getX();
|
||||
this.yo = this.getY();
|
||||
@@ -188,9 +201,11 @@
|
||||
@@ -188,9 +199,11 @@
|
||||
this.mergeWithNeighbours();
|
||||
}
|
||||
|
||||
@@ -56,7 +94,7 @@
|
||||
|
||||
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -202,7 +217,13 @@
|
||||
@@ -202,7 +215,13 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide && this.age >= 6000) {
|
||||
@@ -71,36 +109,36 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -287,11 +308,16 @@
|
||||
@@ -287,11 +306,16 @@
|
||||
}
|
||||
|
||||
private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) {
|
||||
private static void merge(ItemEntity targetEntity, ItemStack targetStack, ItemEntity sourceEntity, ItemStack sourceStack) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callItemMergeEvent(entityitem1, entityitem)) {
|
||||
+ if (!CraftEventFactory.callItemMergeEvent(sourceEntity, targetEntity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
merge(entityitem, itemstack, itemstack1);
|
||||
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
|
||||
entityitem.age = Math.min(entityitem.age, entityitem1.age);
|
||||
if (itemstack1.isEmpty()) {
|
||||
- entityitem1.discard();
|
||||
+ entityitem1.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause);
|
||||
ItemEntity.merge(targetEntity, targetStack, sourceStack);
|
||||
targetEntity.pickupDelay = Math.max(targetEntity.pickupDelay, sourceEntity.pickupDelay);
|
||||
targetEntity.age = Math.min(targetEntity.age, sourceEntity.age);
|
||||
if (sourceStack.isEmpty()) {
|
||||
- sourceEntity.discard();
|
||||
+ sourceEntity.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -320,12 +346,17 @@
|
||||
} else if (!this.getItem().canBeHurtBy(damagesource)) {
|
||||
@@ -320,12 +344,17 @@
|
||||
} else if (!this.getItem().canBeHurtBy(source)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
|
||||
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, source, amount)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.markHurt();
|
||||
this.health = (int) ((float) this.health - f);
|
||||
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
|
||||
this.health = (int) ((float) this.health - amount);
|
||||
this.gameEvent(GameEvent.ENTITY_DAMAGE, source.getEntity());
|
||||
if (this.health <= 0) {
|
||||
this.getItem().onDestroyed(this);
|
||||
- this.discard();
|
||||
@@ -108,7 +146,7 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -382,7 +413,7 @@
|
||||
@@ -382,22 +411,62 @@
|
||||
}
|
||||
|
||||
if (this.getItem().isEmpty()) {
|
||||
@@ -117,18 +155,23 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -394,10 +425,50 @@
|
||||
|
||||
@Override
|
||||
- public void playerTouch(Player player) {
|
||||
+ public void playerTouch(net.minecraft.world.entity.player.Player player) {
|
||||
if (!this.level().isClientSide) {
|
||||
ItemStack itemstack = this.getItem();
|
||||
Item item = itemstack.getItem();
|
||||
int i = itemstack.getCount();
|
||||
|
||||
+ // CraftBukkit start - fire PlayerPickupItemEvent
|
||||
+ int canHold = entityhuman.getInventory().canHold(itemstack);
|
||||
+ int canHold = player.getInventory().canHold(itemstack);
|
||||
+ int remaining = i - canHold;
|
||||
+
|
||||
+ if (this.pickupDelay <= 0 && canHold > 0) {
|
||||
+ itemstack.setCount(canHold);
|
||||
+ // Call legacy event
|
||||
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(playerEvent);
|
||||
+ if (playerEvent.isCancelled()) {
|
||||
@@ -137,7 +180,7 @@
|
||||
+ }
|
||||
+
|
||||
+ // Call newer event afterwards
|
||||
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(entityEvent);
|
||||
+ if (entityEvent.isCancelled()) {
|
||||
@@ -161,8 +204,8 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
|
||||
entityhuman.take(this, i);
|
||||
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(player.getUUID())) && player.getInventory().add(itemstack)) {
|
||||
player.take(this, i);
|
||||
if (itemstack.isEmpty()) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
||||
+++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
||||
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -27,6 +27,12 @@
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.portal.TeleportTransition;
|
||||
|
||||
+// CraftBukkit start;
|
||||
@@ -10,17 +10,17 @@
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityTNTPrimed extends Entity implements TraceableEntity {
|
||||
public class PrimedTnt extends Entity implements TraceableEntity {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT);
|
||||
private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT);
|
||||
@@ -51,6 +57,7 @@
|
||||
public EntityLiving owner;
|
||||
public LivingEntity owner;
|
||||
private boolean usedPortal;
|
||||
public float explosionPower;
|
||||
+ public boolean isIncendiary = false; // CraftBukkit - add field
|
||||
|
||||
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -107,10 +114,13 @@
|
||||
|
||||
this.setFuse(i);
|
||||
@@ -40,13 +40,13 @@
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, World.a.TNT);
|
||||
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, Level.ExplosionInteraction.TNT);
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
|
||||
+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? PrimedTnt.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user