Update to Minecraft 1.21.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-10-23 02:15:00 +11:00
parent 2c4beb962b
commit d3a23f42c3
522 changed files with 8501 additions and 6477 deletions

View File

@@ -13,15 +13,15 @@
public class BrushableBlockEntity extends TileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -156,7 +162,10 @@
EntityItem entityitem = new EntityItem(this.level, d3, d4, d5, this.item.split(this.level.random.nextInt(21) + 10));
@@ -151,7 +157,10 @@
EntityItem entityitem = new EntityItem(worldserver, d3, d4, d5, this.item.split(worldserver.random.nextInt(21) + 10));
entityitem.setDeltaMovement(Vec3D.ZERO);
- this.level.addFreshEntity(entityitem);
+ // CraftBukkit start
+ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition);
+ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem));
+ // CraftBukkit end
this.item = ItemStack.EMPTY;
}
entityitem.setDeltaMovement(Vec3D.ZERO);
- worldserver.addFreshEntity(entityitem);
+ // CraftBukkit start
+ org.bukkit.block.Block bblock = CraftBlock.at(this.level, this.worldPosition);
+ CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (EntityPlayer) entityhuman, Arrays.asList(entityitem));
+ // CraftBukkit end
this.item = ItemStack.EMPTY;
}

View File

@@ -49,7 +49,7 @@
return nbttagcompound;
}
@@ -276,12 +300,18 @@
@@ -277,12 +301,18 @@
}
public final void applyComponents(DataComponentMap datacomponentmap, DataComponentPatch datacomponentpatch) {
@@ -69,7 +69,7 @@
@Nullable
@Override
public <T> T get(DataComponentType<T> datacomponenttype) {
@@ -299,6 +329,10 @@
@@ -300,6 +330,10 @@
DataComponentPatch datacomponentpatch1 = datacomponentpatch.forget(set::contains);
this.components = datacomponentpatch1.split().added();
@@ -80,7 +80,7 @@
}
protected void collectImplicitComponents(DataComponentMap.a datacomponentmap_a) {}
@@ -333,6 +367,15 @@
@@ -334,6 +368,15 @@
}
}

View File

@@ -120,8 +120,8 @@
if (nbttagcompound.contains(s, 8)) {
MinecraftKey minecraftkey = MinecraftKey.tryParse(nbttagcompound.getString(s));
- return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.getHolder(minecraftkey).map(TileEntityBeacon::filterEffect).orElse((Object) null);
+ return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.getHolder(minecraftkey).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598)
- return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).map(TileEntityBeacon::filterEffect).orElse((Object) null);
+ return minecraftkey == null ? null : (Holder) BuiltInRegistries.MOB_EFFECT.get(minecraftkey).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598)
} else {
return null;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java
@@ -42,6 +42,10 @@
@@ -43,6 +43,10 @@
import net.minecraft.world.level.gameevent.GameEvent;
import org.slf4j.Logger;
@@ -11,7 +11,7 @@
public class TileEntityBeehive extends TileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -55,6 +59,7 @@
@@ -56,6 +60,7 @@
private List<TileEntityBeehive.HiveBee> stored = Lists.newArrayList();
@Nullable
public BlockPosition savedFlowerPos;
@@ -19,7 +19,7 @@
public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEEHIVE, blockposition, iblockdata);
@@ -94,7 +99,7 @@
@@ -95,7 +100,7 @@
}
public boolean isFull() {
@@ -28,7 +28,7 @@
}
public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -111,7 +116,7 @@
@@ -112,7 +117,7 @@
if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) {
if (!this.isSedated()) {
@@ -37,7 +37,7 @@
} else {
entitybee.setStayOutOfHiveCountdown(400);
}
@@ -123,10 +128,16 @@
@@ -124,10 +129,16 @@
}
private List<Entity> releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -55,7 +55,7 @@
});
if (!list.isEmpty()) {
super.setChanged();
@@ -150,7 +161,19 @@
@@ -151,7 +162,19 @@
}
public void addOccupant(Entity entity) {
@@ -76,7 +76,7 @@
entity.stopRiding();
entity.ejectPassengers();
this.storeBee(TileEntityBeehive.c.of(entity));
@@ -169,7 +192,7 @@
@@ -170,7 +193,7 @@
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState()));
}
@@ -85,22 +85,22 @@
super.setChanged();
}
}
@@ -179,7 +202,13 @@
@@ -180,7 +203,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) {
- if ((world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
- if (EntityBee.isNightOrRaining(world) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
+ return releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_c, list, tileentitybeehive_releasestatus, blockposition1, false);
+ }
+
+ 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, boolean force) {
+ if (!force && (world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ if (!force && EntityBee.isNightOrRaining(world) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit end
return false;
} else {
EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING);
@@ -192,6 +221,18 @@
@@ -193,6 +222,18 @@
Entity entity = tileentitybeehive_c.createEntity(world, blockposition);
if (entity != null) {
@@ -119,7 +119,7 @@
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
@@ -222,6 +263,7 @@
@@ -223,6 +264,7 @@
list.add(entitybee);
}
@@ -127,7 +127,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();
@@ -229,11 +271,12 @@
@@ -230,11 +272,12 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
@@ -141,7 +141,7 @@
} else {
return false;
}
@@ -258,6 +301,10 @@
@@ -259,6 +302,10 @@
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) {
flag = true;
iterator.remove();
@@ -152,7 +152,7 @@
}
}
}
@@ -284,7 +331,7 @@
@@ -285,7 +332,7 @@
@Override
protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
super.loadAdditional(nbttagcompound, holderlookup_a);
@@ -161,7 +161,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);
@@ -293,7 +340,12 @@
@@ -294,7 +341,12 @@
});
}
@@ -175,7 +175,7 @@
}
@Override
@@ -303,13 +355,14 @@
@@ -304,13 +356,14 @@
if (this.hasSavedFlowerPos()) {
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
}
@@ -191,7 +191,7 @@
List<TileEntityBeehive.c> list = (List) tileentity_b.getOrDefault(DataComponents.BEES, List.of());
list.forEach(this::storeBee);
@@ -350,7 +403,7 @@
@@ -351,7 +404,7 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
entity.save(nbttagcompound);
@@ -200,7 +200,7 @@
Objects.requireNonNull(nbttagcompound);
list.forEach(nbttagcompound::remove);
@@ -369,7 +422,7 @@
@@ -370,7 +423,7 @@
@Nullable
public Entity createEntity(World world, BlockPosition blockposition) {
NBTTagCompound nbttagcompound = this.entityData.copyTag();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
@@ -23,6 +23,20 @@
@@ -24,6 +24,20 @@
import net.minecraft.world.level.block.BlockBrewingStand;
import net.minecraft.world.level.block.state.IBlockData;
@@ -21,7 +21,7 @@
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory {
private static final int INGREDIENT_SLOT = 3;
@@ -40,6 +54,36 @@
@@ -41,6 +55,36 @@
private Item ingredient;
public int fuel;
protected final IContainerProperties dataAccess;
@@ -58,10 +58,10 @@
public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata);
@@ -106,8 +150,19 @@
@@ -107,8 +151,19 @@
ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4);
if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) {
if (tileentitybrewingstand.fuel <= 0 && itemstack.is(TagsItem.BREWING_FUEL)) {
- tileentitybrewingstand.fuel = 20;
- itemstack.shrink(1);
+ // CraftBukkit start
@@ -80,7 +80,7 @@
setChanged(world, blockposition, iblockdata);
}
@@ -115,12 +170,17 @@
@@ -116,12 +171,17 @@
boolean flag1 = tileentitybrewingstand.brewTime > 0;
ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3);
@@ -101,7 +101,7 @@
} else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) {
tileentitybrewingstand.brewTime = 0;
}
@@ -128,7 +188,11 @@
@@ -129,7 +189,11 @@
setChanged(world, blockposition, iblockdata);
} else if (flag && tileentitybrewingstand.fuel > 0) {
--tileentitybrewingstand.fuel;
@@ -114,7 +114,7 @@
tileentitybrewingstand.ingredient = itemstack1.getItem();
setChanged(world, blockposition, iblockdata);
}
@@ -184,12 +248,34 @@
@@ -185,12 +249,34 @@
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java
@@ -30,6 +30,14 @@
@@ -31,6 +31,14 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -15,16 +15,16 @@
public class TileEntityCampfire extends TileEntity implements Clearable {
private static final int BURN_COOL_SPEED = 2;
@@ -64,6 +72,20 @@
@@ -63,6 +71,20 @@
}).orElse(itemstack);
if (itemstack1.isItemEnabled(world.enabledFeatures())) {
if (itemstack1.isItemEnabled(worldserver.enabledFeatures())) {
+ // CraftBukkit start - fire BlockCookEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result);
+ world.getCraftServer().getPluginManager().callEvent(blockCookEvent);
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(worldserver, blockposition), source, result);
+ worldserver.getCraftServer().getPluginManager().callEvent(blockCookEvent);
+
+ if (blockCookEvent.isCancelled()) {
+ return;
@@ -33,19 +33,19 @@
+ result = blockCookEvent.getResult();
+ itemstack1 = CraftItemStack.asNMSCopy(result);
+ // CraftBukkit end
InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
InventoryUtils.dropItemStack(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -176,7 +198,11 @@
ItemStack itemstack1 = (ItemStack) this.items.get(j);
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -177,7 +199,11 @@
return false;
}
if (itemstack1.isEmpty()) {
- this.cookingTime[j] = i;
- this.cookingTime[i] = ((RecipeCampfire) ((RecipeHolder) optional.get()).value()).cookingTime();
+ // CraftBukkit start
+ CampfireStartEvent event = new CampfireStartEvent(CraftBlock.at(this.level,this.worldPosition), CraftItemStack.asCraftMirror(itemstack), (CampfireRecipe) getCookableRecipe(itemstack).get().toBukkitRecipe());
+ CampfireStartEvent event = new CampfireStartEvent(CraftBlock.at(this.level,this.worldPosition), CraftItemStack.asCraftMirror(itemstack), (CampfireRecipe) optional.get().toBukkitRecipe());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.cookingTime[j] = event.getTotalCookTime(); // i -> event.getTotalCookTime()
+ this.cookingTime[i] = event.getTotalCookTime(); // i -> event.getTotalCookTime()
+ // CraftBukkit end
this.cookingProgress[j] = 0;
this.items.set(j, itemstack.consumeAndReturn(1, entityliving));
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState()));
this.cookingProgress[i] = 0;
this.items.set(i, itemstack.consumeAndReturn(1, entityliving));
worldserver.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entityliving, this.getBlockState()));

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/level/block/entity/TileEntityConduit.java
+++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java
@@ -187,8 +187,20 @@
@@ -28,6 +28,10 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.server.level.WorldServer;
+// CraftBukkit end
+
public class TileEntityConduit extends TileEntity {
private static final int BLOCK_REFRESH_RATE = 2;
@@ -187,8 +191,20 @@
}
private static void applyEffects(World world, BlockPosition blockposition, List<BlockPosition> list) {
@@ -21,7 +32,7 @@
int k = blockposition.getX();
int l = blockposition.getY();
int i1 = blockposition.getZ();
@@ -202,7 +214,7 @@
@@ -202,7 +218,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
@@ -30,7 +41,7 @@
}
}
@@ -210,6 +222,12 @@
@@ -210,6 +226,12 @@
}
private static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List<BlockPosition> list, TileEntityConduit tileentityconduit) {
@@ -43,7 +54,7 @@
EntityLiving entityliving = tileentityconduit.destroyTarget;
int i = list.size();
@@ -230,9 +248,12 @@
@@ -230,9 +252,12 @@
tileentityconduit.destroyTarget = null;
}
@@ -52,7 +63,7 @@
- tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F);
+ // CraftBukkit start
+ if (damageTarget && tileentityconduit.destroyTarget != null) {
+ if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic().directBlock(world, blockposition), 4.0F)) {
+ if (tileentityconduit.destroyTarget.hurtServer((WorldServer) world, world.damageSources().magic().directBlock(world, blockposition), 4.0F)) {
+ world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ }
+ // CraftBukkit end

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/entity/TileEntityContainer.java
+++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java
@@ -178,4 +178,12 @@
nbttagcompound.remove("Lock");
nbttagcompound.remove("lock");
nbttagcompound.remove("Items");
}
+

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java
+++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java
@@ -48,6 +48,21 @@
@@ -42,6 +42,21 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
@@ -22,19 +22,14 @@
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput {
protected static final int SLOT_INPUT = 0;
@@ -118,7 +133,7 @@
@@ -112,9 +127,39 @@
}
};
this.recipesUsed = new Object2IntOpenHashMap();
this.recipesUsed = new Reference2IntOpenHashMap();
- this.quickCheck = CraftingManager.createCheck(recipes);
+ this.quickCheck = CraftingManager.createCheck((Recipes<RecipeCooking>) recipes); // CraftBukkit - decompile error // Eclipse fail
}
public static void invalidateCache() {
@@ -197,6 +212,40 @@
}
}
+ }
+
+ // CraftBukkit start - add fields and methods
+ private int maxStack = MAX_STACK;
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -53,8 +48,8 @@
+
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
}
+ @Override
+ public int getMaxStackSize() {
+ return maxStack;
@@ -63,34 +58,30 @@
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+
+ public Object2IntOpenHashMap<MinecraftKey> getRecipesUsed() {
+ return this.recipesUsed; // PAIL private -> public
+ }
+ // CraftBukkit end
+
private static boolean isNeverAFurnaceFuel(Item item) {
return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD);
private boolean isLit() {
return this.litTime > 0;
}
@@ -286,7 +335,7 @@
@@ -180,7 +225,7 @@
RecipeHolder recipeholder;
if (flag2) {
- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse((Object) null);
+ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(new SingleRecipeInput(itemstack1), world).orElse(null); // CraftBukkit - decompile error
- recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).orElse((Object) null);
+ recipeholder = (RecipeHolder) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).orElse(null); // CraftBukkit - decompile error
} else {
recipeholder = null;
}
@@ -294,9 +343,20 @@
@@ -188,9 +233,20 @@
int i = tileentityfurnace.getMaxStackSize();
if (!tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(itemstack);
if (!tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack);
+ // CraftBukkit start
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
+
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.getBurnDuration(itemstack));
+ world.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent);
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(worldserver, blockposition), fuel, tileentityfurnace.getBurnDuration(worldserver.fuelValues(), itemstack));
+ worldserver.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent);
+
+ if (furnaceBurnEvent.isCancelled()) {
+ return;
@@ -104,17 +95,17 @@
flag1 = true;
if (flag3) {
Item item = itemstack.getItem();
@@ -312,11 +372,23 @@
@@ -204,11 +260,23 @@
}
if (tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) {
if (tileentityfurnace.isLit() && canBurn(worldserver.registryAccess(), recipeholder, singlerecipeinput, tileentityfurnace.items, i)) {
+ // CraftBukkit start
+ if (recipeholder != null && tileentityfurnace.cookingProgress == 0) {
+ CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0));
+ CookingRecipe<?> recipe = (CookingRecipe<?>) recipeholder.toBukkitRecipe();
+
+ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(world, blockposition), source, recipe);
+ world.getCraftServer().getPluginManager().callEvent(event);
+ FurnaceStartSmeltEvent event = new FurnaceStartSmeltEvent(CraftBlock.at(worldserver, blockposition), source, recipe);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+
+ tileentityfurnace.cookingTotalTime = event.getTotalCookTime();
+ }
@@ -123,21 +114,21 @@
++tileentityfurnace.cookingProgress;
if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) {
tileentityfurnace.cookingProgress = 0;
tileentityfurnace.cookingTotalTime = getTotalCookTime(world, tileentityfurnace);
- if (burn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) {
+ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, world.registryAccess(), recipeholder, tileentityfurnace.items, i)) { // CraftBukkit
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);
}
@@ -355,17 +427,44 @@
@@ -247,17 +315,44 @@
}
}
- private static boolean burn(IRegistryCustom iregistrycustom, @Nullable RecipeHolder<?> recipeholder, NonNullList<ItemStack> nonnulllist, int i) {
+ private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable RecipeHolder<?> recipeholder, NonNullList<ItemStack> nonnulllist, int i) { // CraftBukkit
if (recipeholder != null && canBurn(iregistrycustom, recipeholder, nonnulllist, i)) {
- private static boolean burn(IRegistryCustom iregistrycustom, @Nullable RecipeHolder<? extends RecipeCooking> recipeholder, SingleRecipeInput singlerecipeinput, NonNullList<ItemStack> nonnulllist, int i) {
+ private static boolean burn(World world, BlockPosition blockposition, IRegistryCustom iregistrycustom, @Nullable RecipeHolder<? extends RecipeCooking> recipeholder, SingleRecipeInput singlerecipeinput, NonNullList<ItemStack> nonnulllist, int i) { // CraftBukkit
if (recipeholder != null && canBurn(iregistrycustom, recipeholder, singlerecipeinput, nonnulllist, i)) {
ItemStack itemstack = (ItemStack) nonnulllist.get(0);
ItemStack itemstack1 = recipeholder.value().getResultItem(iregistrycustom);
ItemStack itemstack1 = ((RecipeCooking) recipeholder.value()).assemble(singlerecipeinput, iregistrycustom);
ItemStack itemstack2 = (ItemStack) nonnulllist.get(2);
+ // CraftBukkit start - fire FurnaceSmeltEvent
@@ -175,15 +166,15 @@
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));
@@ -389,6 +488,7 @@
@@ -275,6 +370,7 @@
}
private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) {
+ if (world == null) return 200; // CraftBukkit - SPIGOT-4302
private static int getTotalCookTime(WorldServer worldserver, TileEntityFurnace tileentityfurnace) {
+ if (worldserver == null) return 200; // CraftBukkit - SPIGOT-4302
SingleRecipeInput singlerecipeinput = new SingleRecipeInput(tileentityfurnace.getItem(0));
return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, world).map((recipeholder) -> {
@@ -477,8 +577,8 @@
return (Integer) tileentityfurnace.quickCheck.getRecipeFor(singlerecipeinput, worldserver).map((recipeholder) -> {
@@ -365,8 +461,8 @@
@Override
public void awardUsedRecipes(EntityHuman entityhuman, List<ItemStack> list) {}
@@ -194,7 +185,7 @@
entityplayer.awardRecipes(list);
Iterator iterator = list.iterator();
@@ -495,6 +595,12 @@
@@ -383,22 +479,28 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) {
@@ -205,14 +196,16 @@
+ public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) {
+ // CraftBukkit end
List<RecipeHolder<?>> list = Lists.newArrayList();
ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator();
ObjectIterator objectiterator = this.recipesUsed.reference2IntEntrySet().iterator();
@@ -503,14 +609,14 @@
while (objectiterator.hasNext()) {
Entry<ResourceKey<IRecipe<?>>> entry = (Entry) objectiterator.next();
worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((recipeholder) -> {
- worldserver.recipeAccess().byKey((ResourceKey) entry.getKey()).ifPresent((recipeholder) -> {
+ worldserver.recipeAccess().byKey(entry.getKey()).ifPresent((recipeholder) -> { // CraftBukkit - decompile error
list.add(recipeholder);
- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).getExperience());
+ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience());
+ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) recipeholder.value()).experience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
});
}
@@ -224,7 +217,7 @@
int j = MathHelper.floor((float) i * f);
float f1 = MathHelper.frac((float) i * f);
@@ -518,6 +624,17 @@
@@ -406,6 +508,17 @@
++j;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
@@ -20,12 +20,56 @@
@@ -19,12 +19,56 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.ticks.ContainerSingleItem;
@@ -12,7 +12,7 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem.a {
public class TileEntityJukeBox extends TileEntity implements ContainerSingleItem.a {
public static final String SONG_ITEM_TAG_ID = "RecordItem";
public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started";
@@ -57,7 +57,7 @@
public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.JUKEBOX, blockposition, iblockdata);
@@ -134,7 +178,7 @@
@@ -133,7 +177,7 @@
@Override
public int getMaxStackSize() {
@@ -66,7 +66,7 @@
}
@Override
@@ -153,12 +197,17 @@
@@ -152,12 +196,17 @@
}
@VisibleForTesting

View File

@@ -4,7 +4,6 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
-public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory {
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.Arrays;
@@ -17,7 +16,7 @@
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
+public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener
public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory {
public static final int DATA_PAGE = 0;
public static final int NUM_DATA = 1;
@@ -107,50 +106,53 @@
}
}
@@ -187,6 +255,32 @@
@@ -189,6 +257,35 @@
return itemstack;
}
+ // CraftBukkit start
+ @Override
+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
+ }
+ private final ICommandListener commandSource = new ICommandListener() {
+
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
+ }
+ @Override
+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
+ }
+
+ @Override
+ public boolean acceptsSuccess() {
+ return false;
+ }
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitEntity() : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntityLectern.this);
+ }
+
+ @Override
+ public boolean acceptsFailure() {
+ return false;
+ }
+ @Override
+ public boolean acceptsSuccess() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ @Override
+ public boolean acceptsFailure() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ };
+ // CraftBukkit end
private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) {
+
private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, WorldServer worldserver) {
String s;
Object object;
@@ -201,7 +295,8 @@
@@ -203,7 +300,8 @@
Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition);
- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman);
- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman);
+ // CraftBukkit - commandSource
+ return new CommandListenerWrapper(commandSource, vec3d, Vec2F.ZERO, worldserver, 2, s, (IChatBaseComponent) object, worldserver.getServer(), entityhuman);
}
@Override
@@ -239,7 +334,7 @@
@@ -241,7 +339,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {

View File

@@ -1,10 +1,9 @@
--- a/net/minecraft/world/level/block/entity/TileEntitySign.java
+++ b/net/minecraft/world/level/block/entity/TileEntitySign.java
@@ -36,7 +36,17 @@
@@ -36,6 +36,16 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
-public class TileEntitySign extends TileEntity {
+// CraftBukkit start
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.server.level.EntityPlayer;
@@ -15,10 +14,9 @@
+import org.bukkit.event.block.SignChangeEvent;
+// CraftBukkit end
+
+public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements
public class TileEntitySign extends TileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TEXT_LINE_WIDTH = 90;
@@ -101,7 +111,7 @@
protected void saveAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
super.saveAdditional(nbttagcompound, holderlookup_a);
@@ -92,34 +90,37 @@
return signtext;
}
@@ -250,11 +285,37 @@
@@ -250,11 +285,40 @@
return flag1;
}
- private static CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ @Override
+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {}
+ private final ICommandListener commandSource = new ICommandListener() {
+
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
+ }
+ @Override
+ public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {}
+
+ @Override
+ public boolean acceptsSuccess() {
+ return false;
+ }
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitEntity() : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntitySign.this);
+ }
+
+ @Override
+ public boolean acceptsFailure() {
+ return false;
+ }
+ @Override
+ public boolean acceptsSuccess() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ @Override
+ public boolean acceptsFailure() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ };
+
+ private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition) {
+ // CraftBukkit end
@@ -127,12 +128,12 @@
Object object = entityhuman == null ? IChatBaseComponent.literal("Sign") : entityhuman.getDisplayName();
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman);
+ // CraftBukkit - commandSource
+ return new CommandListenerWrapper(commandSource, Vec3D.atCenterOf(blockposition), Vec2F.ZERO, (WorldServer) world, 2, s, (IChatBaseComponent) object, world.getServer(), entityhuman);
}
@Override
@@ -278,12 +339,17 @@
@@ -278,12 +342,17 @@
@Nullable
public UUID getPlayerWhoMayEdit() {

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
@@ -206,7 +206,7 @@
@@ -211,7 +211,7 @@
}
public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) {
@@ -9,8 +9,8 @@
Objects.requireNonNull(worldserver);
stream.map(worldserver::getEntity).forEach((entity) -> {
@@ -218,7 +218,7 @@
entityinsentient.dropPreservedEquipment();
@@ -223,7 +223,7 @@
entityinsentient.dropPreservedEquipment(worldserver);
}
- entity.remove(Entity.RemovalReason.DISCARDED);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java
@@ -47,6 +47,13 @@
@@ -46,6 +46,13 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -14,7 +14,7 @@
public class VaultBlockEntity extends TileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -97,18 +104,18 @@
@@ -96,18 +103,18 @@
dataresult = VaultServerData.CODEC.parse(dynamicops, nbttagcompound.get("server_data"));
logger = VaultBlockEntity.LOGGER;
Objects.requireNonNull(logger);
@@ -36,7 +36,7 @@
this.config = vaultconfig;
});
}
@@ -117,11 +124,11 @@
@@ -116,11 +123,11 @@
dataresult = VaultSharedData.CODEC.parse(dynamicops, nbttagcompound.get("shared_data"));
logger = VaultBlockEntity.LOGGER;
Objects.requireNonNull(logger);
@@ -50,7 +50,7 @@
}
}
@@ -321,6 +328,14 @@
@@ -320,6 +327,14 @@
if (!list.isEmpty()) {
entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
itemstack.consume(vaultconfig.keyItem().getCount(), entityhuman);
@@ -65,7 +65,7 @@
unlock(worldserver, iblockdata, blockposition, vaultconfig, vaultserverdata, vaultshareddata, list);
vaultserverdata.addToRewardedPlayers(entityhuman);
vaultshareddata.updateConnectedPlayersWithinRange(worldserver, blockposition, vaultserverdata, vaultconfig, vaultconfig.deactivationRange());
@@ -342,6 +357,14 @@
@@ -341,6 +356,14 @@
vaultshareddata.setDisplayItem(ItemStack.EMPTY);
} else {
ItemStack itemstack = getRandomDisplayItemFromLootTable(worldserver, blockposition, (ResourceKey) vaultconfig.overrideLootTableToDisplay().orElse(vaultconfig.lootTable()));