Update to Minecraft 1.21.4

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-12-04 03:20:00 +11:00
parent 267ae64dd6
commit 5381ea78f7
125 changed files with 1383 additions and 1093 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntity.java
+++ b/net/minecraft/world/level/block/entity/TileEntity.java
@@ -27,8 +27,18 @@
@@ -26,8 +26,18 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.slf4j.Logger;
@@ -19,7 +19,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
private final TileEntityTypes<?> type;
@Nullable
@@ -75,7 +85,16 @@
@@ -74,7 +84,16 @@
return this.level != null;
}
@@ -37,7 +37,7 @@
public final void loadWithComponents(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
this.loadAdditional(nbttagcompound, holderlookup_a);
@@ -115,6 +134,11 @@
@@ -114,6 +133,11 @@
}).ifPresent((nbtbase) -> {
nbttagcompound.merge((NBTTagCompound) nbtbase);
});
@@ -49,7 +49,7 @@
return nbttagcompound;
}
@@ -277,12 +301,18 @@
@@ -263,13 +287,19 @@
}
public final void applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) {
@@ -62,6 +62,7 @@
final Set<DataComponentType<?>> set = new HashSet();
set.add(DataComponents.BLOCK_ENTITY_DATA);
set.add(DataComponents.BLOCK_STATE);
final PatchedDataComponentMap patcheddatacomponentmap = PatchedDataComponentMap.fromPatch(datacomponentmap, datacomponentpatch);
- this.applyImplicitComponents(new TileEntity.b(this) {
@@ -69,7 +70,7 @@
@Nullable
@Override
public <T> T get(DataComponentType<T> datacomponenttype) {
@@ -300,6 +330,10 @@
@@ -287,6 +317,10 @@
DataComponentPatch datacomponentpatch1 = datacomponentpatch.forget(set::contains);
this.components = datacomponentpatch1.split().added();
@@ -80,7 +81,7 @@
}
protected void collectImplicitComponents(DataComponentMap.a datacomponentmap_a) {}
@@ -334,6 +368,15 @@
@@ -321,6 +355,15 @@
}
}

View File

@@ -11,7 +11,7 @@
public class TileEntityBanner extends TileEntity implements INamableTileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -80,7 +84,7 @@
@@ -74,7 +78,7 @@
BannerPatternLayers.CODEC.parse(holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("patterns")).resultOrPartial((s) -> {
TileEntityBanner.LOGGER.error("Failed to parse banner patterns: '{}'", s);
}).ifPresent((bannerpatternlayers) -> {
@@ -20,7 +20,7 @@
});
}
@@ -114,7 +118,7 @@
@@ -108,7 +112,7 @@
@Override
protected void applyImplicitComponents(TileEntity.b tileentity_b) {
super.applyImplicitComponents(tileentity_b);
@@ -29,7 +29,7 @@
this.name = (IChatBaseComponent) tileentity_b.get(DataComponents.CUSTOM_NAME);
}
@@ -130,4 +134,13 @@
@@ -124,4 +128,13 @@
nbttagcompound.remove("patterns");
nbttagcompound.remove("CustomName");
}

View File

@@ -55,37 +55,35 @@
});
if (!list.isEmpty()) {
super.setChanged();
@@ -151,7 +162,19 @@
@@ -151,7 +162,17 @@
}
public void addOccupant(Entity entity) {
public void addOccupant(EntityBee entitybee) {
- if (this.stored.size() < 3) {
+ if (this.stored.size() < this.maxBees) { // CraftBukkit
+ // CraftBukkit start
+ if (this.level != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos()));
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entitybee.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos()));
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (entity instanceof EntityBee) {
+ ((EntityBee) entity).setStayOutOfHiveCountdown(400);
+ }
+ entitybee.setStayOutOfHiveCountdown(400);
+ return;
+ }
+ }
+ // CraftBukkit end
entity.stopRiding();
entity.ejectPassengers();
this.storeBee(TileEntityBeehive.c.of(entity));
@@ -170,7 +193,7 @@
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState()));
entitybee.stopRiding();
entitybee.ejectPassengers();
entitybee.dropLeash();
@@ -167,7 +188,7 @@
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entitybee, this.getBlockState()));
}
- entity.discard();
+ entity.discard(EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause
- entitybee.discard();
+ entitybee.discard(EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause
super.setChanged();
}
}
@@ -180,7 +203,13 @@
@@ -177,7 +198,13 @@
}
private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.c tileentitybeehive_c, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) {
@@ -100,7 +98,7 @@
return false;
} else {
EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING);
@@ -193,6 +222,18 @@
@@ -190,6 +217,18 @@
Entity entity = tileentitybeehive_c.createEntity(world, blockposition);
if (entity != null) {
@@ -119,7 +117,7 @@
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
@@ -223,6 +264,7 @@
@@ -220,6 +259,7 @@
list.add(entitybee);
}
@@ -127,7 +125,7 @@
float f = entity.getBbWidth();
double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX();
@@ -230,11 +272,12 @@
@@ -227,11 +267,12 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
@@ -141,7 +139,7 @@
} else {
return false;
}
@@ -259,6 +302,10 @@
@@ -256,6 +297,10 @@
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) {
flag = true;
iterator.remove();
@@ -152,7 +150,7 @@
}
}
}
@@ -285,7 +332,7 @@
@@ -282,7 +327,7 @@
@Override
protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
super.loadAdditional(nbttagcompound, holderlookup_a);
@@ -161,7 +159,7 @@
if (nbttagcompound.contains("bees")) {
TileEntityBeehive.c.LIST_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("bees")).resultOrPartial((s) -> {
TileEntityBeehive.LOGGER.error("Failed to parse bees: '{}'", s);
@@ -294,7 +341,12 @@
@@ -291,7 +336,12 @@
});
}
@@ -175,7 +173,7 @@
}
@Override
@@ -304,13 +356,14 @@
@@ -301,13 +351,14 @@
if (this.hasSavedFlowerPos()) {
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
}
@@ -191,7 +189,7 @@
List<TileEntityBeehive.c> list = (List) tileentity_b.getOrDefault(DataComponents.BEES, List.of());
list.forEach(this::storeBee);
@@ -351,7 +404,7 @@
@@ -348,7 +399,7 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
entity.save(nbttagcompound);
@@ -200,7 +198,7 @@
Objects.requireNonNull(nbttagcompound);
list.forEach(nbttagcompound::remove);
@@ -370,7 +423,7 @@
@@ -367,7 +418,7 @@
@Nullable
public Entity createEntity(World world, BlockPosition blockposition) {
NBTTagCompound nbttagcompound = this.entityData.copyTag();

View File

@@ -50,15 +50,3 @@
protected TileEntityChest(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.withSize(27, ItemStack.EMPTY);
@@ -199,4 +235,11 @@
world.blockEvent(blockposition, block, 1, j);
}
+
+ // CraftBukkit start
+ @Override
+ public boolean onlyOpCanSetNbt() {
+ return true;
+ }
+ // CraftBukkit end
}

View File

@@ -22,7 +22,7 @@
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput {
protected static final int SLOT_INPUT = 0;
@@ -112,9 +127,39 @@
@@ -110,9 +125,39 @@
}
};
this.recipesUsed = new Reference2IntOpenHashMap();
@@ -61,9 +61,9 @@
+ // CraftBukkit end
+
private boolean isLit() {
return this.litTime > 0;
return this.litTimeRemaining > 0;
}
@@ -180,7 +225,7 @@
@@ -175,7 +220,7 @@
RecipeHolder recipeholder;
if (flag2) {
@@ -72,11 +72,11 @@
} else {
recipeholder = null;
}
@@ -188,9 +233,20 @@
@@ -183,9 +228,20 @@
int i = tileentityfurnace.getMaxStackSize();
if (!tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack);
- tileentityfurnace.litTimeRemaining = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack);
+ // CraftBukkit start
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
+
@@ -87,20 +87,20 @@
+ return;
+ }
+
+ tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime();
tileentityfurnace.litDuration = tileentityfurnace.litTime;
+ tileentityfurnace.litTimeRemaining = furnaceBurnEvent.getBurnTime();
tileentityfurnace.litTotalTime = tileentityfurnace.litTimeRemaining;
- if (tileentityfurnace.isLit()) {
+ if (tileentityfurnace.isLit() && furnaceBurnEvent.isBurning()) {
+ // CraftBukkit end
flag1 = true;
if (flag3) {
Item item = itemstack.getItem();
@@ -204,11 +260,23 @@
@@ -199,11 +255,23 @@
}
if (tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) {
+ // CraftBukkit start
+ if (recipeholder != null && tileentityfurnace.cookingProgress == 0) {
+ if (recipeholder != null && tileentityfurnace.cookingTimer == 0) {
+ CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0));
+ CookingRecipe<?> recipe = (CookingRecipe<?>) recipeholder.toBukkitRecipe();
+
@@ -111,16 +111,16 @@
+ }
+ // CraftBukkit end
+
++tileentityfurnace.cookingProgress;
if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) {
tileentityfurnace.cookingProgress = 0;
++tileentityfurnace.cookingTimer;
if (tileentityfurnace.cookingTimer == tileentityfurnace.cookingTotalTime) {
tileentityfurnace.cookingTimer = 0;
tileentityfurnace.cookingTotalTime = getTotalCookTime(worldserver, tileentityfurnace);
- if (burn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) {
+ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) { // CraftBukkit
tileentityfurnace.setRecipeUsed(recipeholder);
}
@@ -247,17 +315,44 @@
@@ -242,17 +310,44 @@
}
}
@@ -166,7 +166,7 @@
if (itemstack.is(Blocks.WET_SPONGE.asItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).is(Items.BUCKET)) {
nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET));
@@ -275,6 +370,7 @@
@@ -270,6 +365,7 @@
}
private static int getTotalCookTime(WorldServer worldserver, TileEntityFurnace tileentityfurnace) {
@@ -174,7 +174,7 @@
SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0));
return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).map((recipeholder) -> {
@@ -365,8 +461,8 @@
@@ -360,8 +456,8 @@
@Override
public void awardUsedRecipes(EntityHuman entityhuman, List<ItemStack> list) {}
@@ -185,7 +185,7 @@
entityplayer.awardRecipes(list);
Iterator iterator = list.iterator();
@@ -383,22 +479,28 @@
@@ -378,22 +474,28 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) {
@@ -217,7 +217,7 @@
int j = MathHelper.floor((float) i * f);
float f1 = MathHelper.frac((float) i * f);
@@ -406,6 +508,17 @@
@@ -401,6 +503,17 @@
++j;
}

View File

@@ -57,7 +57,7 @@
public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.JUKEBOX, blockposition, iblockdata);
@@ -133,7 +177,7 @@
@@ -137,7 +181,7 @@
@Override
public int getMaxStackSize() {
@@ -66,7 +66,7 @@
}
@Override
@@ -152,12 +196,17 @@
@@ -156,12 +200,17 @@
}
@VisibleForTesting

View File

@@ -152,7 +152,7 @@
}
@Override
@@ -241,7 +339,7 @@
@@ -236,7 +334,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {

View File

@@ -50,7 +50,7 @@
public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata);
this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
@@ -173,6 +209,7 @@
@@ -184,6 +220,7 @@
}
++this.openCount;
@@ -58,7 +58,7 @@
this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount);
if (this.openCount == 1) {
this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition);
@@ -186,6 +223,7 @@
@@ -197,6 +234,7 @@
public void stopOpen(EntityHuman entityhuman) {
if (!this.remove && !entityhuman.isSpectator()) {
--this.openCount;

View File

@@ -133,7 +133,7 @@
}
@Override
@@ -278,12 +342,17 @@
@@ -273,12 +337,17 @@
@Nullable
public UUID getPlayerWhoMayEdit() {

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/world/level/block/entity/TileEntityTypes.java
+++ b/net/minecraft/world/level/block/entity/TileEntityTypes.java
@@ -66,7 +66,7 @@
public static final TileEntityTypes<CrafterBlockEntity> CRAFTER = register("crafter", CrafterBlockEntity::new, Blocks.CRAFTER);
public static final TileEntityTypes<TrialSpawnerBlockEntity> TRIAL_SPAWNER = register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER);
public static final TileEntityTypes<VaultBlockEntity> VAULT = register("vault", VaultBlockEntity::new, Blocks.VAULT);
- private static final Set<TileEntityTypes<?>> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER);
+ private static final Set<TileEntityTypes<?>> OP_ONLY_CUSTOM_DATA = Set.of(TileEntityTypes.COMMAND_BLOCK, TileEntityTypes.LECTERN, TileEntityTypes.SIGN, TileEntityTypes.HANGING_SIGN, TileEntityTypes.MOB_SPAWNER, TileEntityTypes.TRIAL_SPAWNER, TileEntityTypes.CHEST); // CraftBukkit
private final TileEntityTypes.a<? extends T> factory;
private final Set<Block> validBlocks;
private final Holder.c<TileEntityTypes<?>> builtInRegistryHolder;
@@ -110,7 +110,7 @@
public T getBlockEntity(IBlockAccess iblockaccess, BlockPosition blockposition) {
TileEntity tileentity = iblockaccess.getBlockEntity(blockposition);
- return tileentity != null && tileentity.getType() == this ? tileentity : null;
+ return tileentity != null && tileentity.getType() == this ? (T) tileentity : null; // CraftBukkit - decompile error
}
public boolean onlyOpCanSetNbt() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
@@ -211,7 +211,7 @@
@@ -210,7 +210,7 @@
}
public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) {
@@ -9,7 +9,7 @@
Objects.requireNonNull(worldserver);
stream.map(worldserver::getEntity).forEach((entity) -> {
@@ -223,7 +223,7 @@
@@ -222,7 +222,7 @@
entityinsentient.dropPreservedEquipment(worldserver);
}