1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -1,18 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -49,6 +_,11 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class FallingBlockEntity extends Entity {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public BlockState blockState = Blocks.SAND.defaultBlockState();
|
||||
@@ -62,6 +_,7 @@
|
||||
@@ -69,6 +_,7 @@
|
||||
public CompoundTag blockData;
|
||||
public boolean forceTickAfterTeleportToDuplicate;
|
||||
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
|
||||
@@ -20,20 +8,20 @@
|
||||
|
||||
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -89,6 +_,7 @@
|
||||
? blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false))
|
||||
: blockState
|
||||
@@ -94,6 +_,7 @@
|
||||
pos.getZ() + 0.5,
|
||||
blockState.hasProperty(BlockStateProperties.WATERLOGGED) ? blockState.setValue(BlockStateProperties.WATERLOGGED, false) : blockState
|
||||
);
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit
|
||||
level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3);
|
||||
level.addFreshEntity(fallingBlockEntity);
|
||||
return fallingBlockEntity;
|
||||
@@ -139,13 +_,22 @@
|
||||
@@ -144,13 +_,22 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.blockState.isAir()) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
Block block = this.blockState.getBlock();
|
||||
this.time++;
|
||||
@@ -45,14 +33,14 @@
|
||||
+ if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
+ this.spawnAtLocation(serverLevel, block);
|
||||
+ }
|
||||
+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable falling blocks height nerf
|
||||
this.handlePortal();
|
||||
if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) {
|
||||
BlockPos blockPos = this.blockPosition();
|
||||
@@ -166,12 +_,12 @@
|
||||
@@ -171,12 +_,12 @@
|
||||
}
|
||||
|
||||
if (!this.onGround() && !flag1) {
|
||||
@@ -63,17 +51,17 @@
|
||||
}
|
||||
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
} else {
|
||||
BlockState blockState = this.level().getBlockState(blockPos);
|
||||
@@ -189,12 +_,18 @@
|
||||
this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(true));
|
||||
@@ -194,12 +_,18 @@
|
||||
this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockPos, this.blockState)) {
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockPos, this.blockState)) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -83,22 +71,22 @@
|
||||
.chunkMap
|
||||
.broadcast(this, new ClientboundBlockUpdatePacket(blockPos, this.level().getBlockState(blockPos)));
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
if (block instanceof Fallable) {
|
||||
((Fallable)block).onLand(this.level(), blockPos, this.blockState, blockState, this);
|
||||
}
|
||||
@@ -218,19 +_,19 @@
|
||||
@@ -220,19 +_,19 @@
|
||||
}
|
||||
}
|
||||
} else if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
this.callOnBrokenAfterFall(block, blockPos);
|
||||
this.spawnAtLocation(serverLevel, block);
|
||||
}
|
||||
} else {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
|
||||
if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
this.callOnBrokenAfterFall(block, blockPos);
|
||||
this.spawnAtLocation(serverLevel, block);
|
||||
@@ -106,11 +94,11 @@
|
||||
}
|
||||
} else {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
this.callOnBrokenAfterFall(block, blockPos);
|
||||
}
|
||||
}
|
||||
@@ -290,6 +_,7 @@
|
||||
@@ -293,6 +_,7 @@
|
||||
}
|
||||
|
||||
compound.putBoolean("CancelDrop", this.cancelDrop);
|
||||
@@ -118,29 +106,18 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -308,7 +_,7 @@
|
||||
this.dropItem = compound.getBoolean("DropItem");
|
||||
}
|
||||
|
||||
- if (compound.contains("TileEntityData", 10)) {
|
||||
+ if (compound.contains("TileEntityData", 10) && !(this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock)) { // Paper - Filter bad block entity nbt data from falling blocks
|
||||
this.blockData = compound.getCompound("TileEntityData").copy();
|
||||
}
|
||||
|
||||
@@ -316,6 +_,12 @@
|
||||
if (this.blockState.isAir()) {
|
||||
this.blockState = Blocks.SAND.defaultBlockState();
|
||||
}
|
||||
+
|
||||
+ // Paper start - Expand FallingBlock API
|
||||
+ if (compound.contains("Paper.AutoExpire")) {
|
||||
+ this.autoExpire = compound.getBoolean("Paper.AutoExpire");
|
||||
+ }
|
||||
+ // Paper end - Expand FallingBlock API
|
||||
@@ -305,8 +_,9 @@
|
||||
this.fallDamagePerDistance = compound.getFloatOr("FallHurtAmount", 0.0F);
|
||||
this.fallDamageMax = compound.getIntOr("FallHurtMax", 40);
|
||||
this.dropItem = compound.getBooleanOr("DropItem", true);
|
||||
- this.blockData = compound.getCompound("TileEntityData").map(CompoundTag::copy).orElse(null);
|
||||
+ this.blockData = compound.getCompound("TileEntityData").map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks
|
||||
this.cancelDrop = compound.getBooleanOr("CancelDrop", false);
|
||||
+ this.autoExpire = compound.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API
|
||||
}
|
||||
|
||||
public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) {
|
||||
@@ -372,7 +_,7 @@
|
||||
@@ -363,7 +_,7 @@
|
||||
ResourceKey<Level> resourceKey1 = this.level().dimension();
|
||||
boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey;
|
||||
Entity entity = super.teleport(teleportTransition);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -49,6 +_,9 @@
|
||||
@@ -56,6 +_,9 @@
|
||||
@Nullable
|
||||
public UUID target;
|
||||
public final float bobOffs;
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
public ItemEntity(EntityType<? extends ItemEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -57,7 +_,12 @@
|
||||
@@ -64,7 +_,12 @@
|
||||
}
|
||||
|
||||
public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack itemStack) {
|
||||
@@ -24,7 +24,7 @@
|
||||
}
|
||||
|
||||
public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack itemStack, double deltaX, double deltaY, double deltaZ) {
|
||||
@@ -119,7 +_,7 @@
|
||||
@@ -126,7 +_,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.getItem().isEmpty()) {
|
||||
@@ -33,7 +33,7 @@
|
||||
} else {
|
||||
super.tick();
|
||||
if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
|
||||
@@ -147,11 +_,15 @@
|
||||
@@ -154,11 +_,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
float f = 0.98F;
|
||||
- if (this.onGround()) {
|
||||
+ // Paper start - Friction API
|
||||
+ if (frictionState == net.kyori.adventure.util.TriState.FALSE) {
|
||||
+ if (this.frictionState == net.kyori.adventure.util.TriState.FALSE) {
|
||||
+ f = 1F;
|
||||
+ } else if (this.onGround()) {
|
||||
+ // Paper end - Friction API
|
||||
f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
|
||||
}
|
||||
|
||||
@@ -184,8 +_,14 @@
|
||||
@@ -191,8 +_,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,9 +_,18 @@
|
||||
@@ -217,9 +_,18 @@
|
||||
|
||||
private void mergeWithNeighbours() {
|
||||
if (this.isMergable()) {
|
||||
@@ -88,7 +88,7 @@
|
||||
this.tryToMerge(itemEntity);
|
||||
if (this.isRemoved()) {
|
||||
break;
|
||||
@@ -224,14 +_,14 @@
|
||||
@@ -231,7 +_,7 @@
|
||||
|
||||
private boolean isMergable() {
|
||||
ItemStack item = this.getItem();
|
||||
@@ -97,15 +97,7 @@
|
||||
}
|
||||
|
||||
private void tryToMerge(ItemEntity itemEntity) {
|
||||
ItemStack item = this.getItem();
|
||||
ItemStack item1 = itemEntity.getItem();
|
||||
if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) {
|
||||
- if (item1.getCount() < item.getCount()) {
|
||||
+ if (true || item1.getCount() < item.getCount()) { // Spigot
|
||||
merge(this, item, itemEntity, item1);
|
||||
} else {
|
||||
merge(itemEntity, item1, this, item);
|
||||
@@ -257,11 +_,16 @@
|
||||
@@ -264,11 +_,16 @@
|
||||
}
|
||||
|
||||
private static void merge(ItemEntity destinationEntity, ItemStack destinationStack, ItemEntity originEntity, ItemStack originStack) {
|
||||
@@ -123,7 +115,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +_,17 @@
|
||||
@@ -296,12 +_,17 @@
|
||||
} else if (!this.getItem().canBeHurtBy(damageSource)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -142,9 +134,9 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -322,6 +_,11 @@
|
||||
if (!this.getItem().isEmpty()) {
|
||||
compound.put("Item", this.getItem().save(this.registryAccess()));
|
||||
@@ -324,6 +_,11 @@
|
||||
RegistryOps<Tag> registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE);
|
||||
compound.store("Item", ItemStack.CODEC, registryOps, this.getItem());
|
||||
}
|
||||
+ // Paper start - Friction API
|
||||
+ if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) {
|
||||
@@ -154,28 +146,28 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -347,9 +_,19 @@
|
||||
} else {
|
||||
this.setItem(ItemStack.EMPTY);
|
||||
}
|
||||
@@ -336,8 +_,19 @@
|
||||
this.cachedThrower = null;
|
||||
RegistryOps<Tag> registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE);
|
||||
this.setItem(compound.read("Item", ItemStack.CODEC, registryOps).orElse(ItemStack.EMPTY));
|
||||
+
|
||||
+ // Paper start - Friction API
|
||||
+ if (compound.contains("Paper.FrictionState")) {
|
||||
+ String fs = compound.getString("Paper.FrictionState");
|
||||
+ compound.getString("Paper.FrictionState").ifPresent(frictionState -> {
|
||||
+ try {
|
||||
+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs);
|
||||
+ this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState);
|
||||
+ } catch (Exception ignored) {
|
||||
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", fs, this);
|
||||
+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", frictionState, this);
|
||||
+ }
|
||||
+ }
|
||||
+ });
|
||||
+ // Paper end - Friction API
|
||||
|
||||
+
|
||||
if (this.getItem().isEmpty()) {
|
||||
- this.discard();
|
||||
+ this.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,10 +_,73 @@
|
||||
@@ -347,10 +_,73 @@
|
||||
ItemStack item = this.getItem();
|
||||
Item item1 = item.getItem();
|
||||
int count = item.getCount();
|
||||
@@ -250,7 +242,7 @@
|
||||
item.setCount(count);
|
||||
}
|
||||
|
||||
@@ -400,6 +_,7 @@
|
||||
@@ -388,6 +_,7 @@
|
||||
|
||||
public void setItem(ItemStack stack) {
|
||||
this.getEntityData().set(DATA_ITEM, stack);
|
||||
@@ -258,7 +250,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -453,7 +_,7 @@
|
||||
@@ -441,7 +_,7 @@
|
||||
|
||||
public void makeFakeItem() {
|
||||
this.setNeverPickUp();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -27,6 +_,12 @@
|
||||
@@ -29,6 +_,12 @@
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.portal.TeleportTransition;
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
public class PrimedTnt extends Entity implements TraceableEntity {
|
||||
private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT);
|
||||
private static final EntityDataAccessor<BlockState> DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE);
|
||||
@@ -50,6 +_,7 @@
|
||||
@@ -53,6 +_,7 @@
|
||||
public LivingEntity owner;
|
||||
private boolean usedPortal;
|
||||
public float explosionPower = 4.0F;
|
||||
+ public boolean isIncendiary = false; // CraftBukkit - add field
|
||||
+ public boolean isIncendiary = false; // CraftBukkit
|
||||
|
||||
public PrimedTnt(EntityType<? extends PrimedTnt> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -59,7 +_,7 @@
|
||||
@@ -62,7 +_,7 @@
|
||||
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
|
||||
this(EntityType.TNT, level);
|
||||
this.setPos(x, y, z);
|
||||
@@ -30,7 +30,7 @@
|
||||
this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02);
|
||||
this.setFuse(80);
|
||||
this.xo = x;
|
||||
@@ -91,10 +_,17 @@
|
||||
@@ -94,10 +_,17 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -48,7 +48,7 @@
|
||||
this.setDeltaMovement(this.getDeltaMovement().scale(0.98));
|
||||
if (this.onGround()) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7));
|
||||
@@ -103,19 +_,49 @@
|
||||
@@ -106,20 +_,50 @@
|
||||
int i = this.getFuse() - 1;
|
||||
this.setFuse(i);
|
||||
if (i <= 0) {
|
||||
@@ -90,27 +90,28 @@
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level()
|
||||
.explode(
|
||||
this,
|
||||
@@ -124,8 +_,8 @@
|
||||
this.getX(),
|
||||
this.getY(0.0625),
|
||||
this.getZ(),
|
||||
- this.explosionPower,
|
||||
- false,
|
||||
+ event.getRadius(), // CraftBukkit
|
||||
+ event.getFire(), // CraftBukkit
|
||||
Level.ExplosionInteraction.TNT
|
||||
);
|
||||
}
|
||||
@@ -200,4 +_,11 @@
|
||||
if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) {
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level()
|
||||
.explode(
|
||||
this,
|
||||
@@ -128,8 +_,8 @@
|
||||
this.getX(),
|
||||
this.getY(0.0625),
|
||||
this.getZ(),
|
||||
- this.explosionPower,
|
||||
- false,
|
||||
+ event.getRadius(), // CraftBukkit
|
||||
+ event.getFire(), // CraftBukkit
|
||||
Level.ExplosionInteraction.TNT
|
||||
);
|
||||
}
|
||||
@@ -202,4 +_,11 @@
|
||||
public final boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user