Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 4deda9501f
commit 65bc2541a3
524 changed files with 7788 additions and 6181 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
@@ -28,6 +28,12 @@
@@ -31,6 +31,12 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -13,7 +13,7 @@
public class BrushableBlockEntity extends TileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -153,7 +159,10 @@
@@ -156,7 +162,10 @@
EntityItem entityitem = new EntityItem(this.level, d3, d4, d5, this.item.split(this.level.random.nextInt(21) + 10));
entityitem.setDeltaMovement(Vec3D.ZERO);
@@ -25,11 +25,3 @@
this.item = ItemStack.EMPTY;
}
@@ -230,6 +239,7 @@
@Override
public void load(NBTTagCompound nbttagcompound) {
+ super.load(nbttagcompound); // CraftBukkit - SPIGOT-7393: Load super Bukkit data
if (!this.tryLoadLootTable(nbttagcompound) && nbttagcompound.contains("item")) {
this.item = ItemStack.of(nbttagcompound.getCompound("item"));
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
@@ -18,12 +18,54 @@
@@ -23,12 +23,54 @@
import net.minecraft.world.level.gameevent.GameEvent;
import org.slf4j.Logger;
@@ -55,15 +55,7 @@
public ChiseledBookShelfBlockEntity(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.CHISELED_BOOKSHELF, blockposition, iblockdata);
@@ -52,6 +94,7 @@
@Override
public void load(NBTTagCompound nbttagcompound) {
+ super.load(nbttagcompound); // CraftBukkit - SPIGOT-7393: Load super Bukkit data
this.items.clear();
ContainerUtil.loadAllItems(nbttagcompound, this.items);
this.lastInteractedSlot = nbttagcompound.getInt("last_interacted_slot");
@@ -93,7 +136,7 @@
@@ -100,7 +142,7 @@
this.items.set(i, ItemStack.EMPTY);
if (!itemstack.isEmpty()) {
@@ -72,7 +64,7 @@
}
return itemstack;
@@ -108,7 +151,7 @@
@@ -115,7 +157,7 @@
public void setItem(int i, ItemStack itemstack) {
if (itemstack.is(TagsItem.BOOKSHELF_BOOKS)) {
this.items.set(i, itemstack);
@@ -81,7 +73,7 @@
} else if (itemstack.isEmpty()) {
this.removeItem(i, 1);
}
@@ -124,7 +167,7 @@
@@ -131,7 +173,7 @@
@Override
public int getMaxStackSize() {

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
+++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
@@ -13,6 +13,7 @@
@@ -17,6 +17,7 @@
private static final int CHECK_TICK_DELAY = 5;
private int openCount;
private double maxInteractionRange;
+ public boolean opened; // CraftBukkit
public ContainerOpenersCounter() {}
@@ -22,11 +23,36 @@
@@ -26,11 +27,36 @@
protected abstract void openerCountChanged(World world, BlockPosition blockposition, IBlockData iblockdata, int i, int j);
@@ -44,8 +44,8 @@
+
if (i == 0) {
this.onOpen(world, blockposition, iblockdata);
world.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
@@ -37,8 +63,19 @@
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, blockposition);
@@ -42,8 +68,19 @@
}
public void decrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
@@ -64,11 +64,11 @@
+
if (this.openCount == 0) {
this.onClose(world, blockposition, iblockdata);
world.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
@@ -59,6 +96,7 @@
world.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, blockposition);
@@ -72,6 +109,7 @@
}
public void recheckOpeners(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.getOpenCount(world, blockposition);
int i = list.size();
+ if (opened) i++; // CraftBukkit - add dummy count from API
int j = this.openCount;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
@@ -21,6 +21,12 @@
@@ -23,6 +23,12 @@
import net.minecraft.world.level.block.CrafterBlock;
import net.minecraft.world.level.block.state.IBlockData;
@@ -13,7 +13,7 @@
public class CrafterBlockEntity extends TileEntityLootable implements InventoryCrafting {
public static final int CONTAINER_WIDTH = 3;
@@ -33,6 +39,46 @@
@@ -35,12 +41,52 @@
private NonNullList<ItemStack> items;
public int craftingTicksRemaining;
protected final IContainerProperties containerData;
@@ -60,3 +60,10 @@
public CrafterBlockEntity(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.CRAFTER, blockposition, iblockdata);
this.items = NonNullList.withSize(9, ItemStack.EMPTY);
this.craftingTicksRemaining = 0;
- this.containerData = new IContainerProperties(this) {
+ this.containerData = new IContainerProperties() { // CraftBukkit - decompile error
private final int[] slotStates = new int[9];
private int triggered = 0;

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
@@ -21,8 +21,59 @@
import net.minecraft.world.level.block.state.properties.BlockProperties;
@@ -20,8 +20,59 @@
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.ticks.ContainerSingleItem;
+// CraftBukkit start
@@ -14,7 +14,7 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class DecoratedPotBlockEntity extends TileEntity implements RandomizableContainer, ContainerSingleItem {
public class DecoratedPotBlockEntity extends TileEntity implements RandomizableContainer, ContainerSingleItem.a {
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new ArrayList<>();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java
@@ -32,14 +32,18 @@
@@ -34,10 +34,13 @@
public SculkCatalystBlockEntity(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.SCULK_CATALYST, blockposition, iblockdata);
this.catalystListener = new SculkCatalystBlockEntity.CatalystListener(iblockdata, new BlockPositionSource(blockposition));
@@ -14,12 +14,7 @@
}
@Override
public void load(NBTTagCompound nbttagcompound) {
+ super.load(nbttagcompound); // CraftBukkit - SPIGOT-7393: Load super Bukkit data
this.catalystListener.sculkSpreader.load(nbttagcompound);
}
@@ -60,11 +64,13 @@
@@ -63,11 +66,13 @@
final SculkSpreader sculkSpreader;
private final IBlockData blockState;
private final PositionSource positionSource;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntity.java
+++ b/net/minecraft/world/level/block/entity/TileEntity.java
@@ -15,8 +15,18 @@
@@ -26,8 +26,18 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.slf4j.Logger;
@@ -19,13 +19,13 @@
private static final Logger LOGGER = LogUtils.getLogger();
private final TileEntityTypes<?> type;
@Nullable
@@ -48,7 +58,16 @@
@@ -61,7 +71,16 @@
return this.level != null;
}
- public void load(NBTTagCompound nbttagcompound) {}
- protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {}
+ // CraftBukkit start - read container
+ public void load(NBTTagCompound nbttagcompound) {
+ protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
+
+ net.minecraft.nbt.NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues");
@@ -35,12 +35,12 @@
+ }
+ // CraftBukkit end
protected void saveAdditional(NBTTagCompound nbttagcompound) {}
@@ -70,6 +89,11 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.saveAdditional(nbttagcompound);
public final void loadWithComponents(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
this.loadAdditional(nbttagcompound, holderlookup_a);
@@ -101,6 +120,11 @@
}).ifPresent((nbtbase) -> {
nbttagcompound.merge((NBTTagCompound) nbtbase);
});
+ // CraftBukkit start - store container
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
@@ -49,11 +49,19 @@
return nbttagcompound;
}
@@ -202,4 +226,13 @@
public void setBlockState(IBlockData iblockdata) {
this.blockState = iblockdata;
@@ -264,7 +288,7 @@
set.add(DataComponents.BLOCK_ENTITY_DATA);
final PatchedDataComponentMap patcheddatacomponentmap = PatchedDataComponentMap.fromPatch(datacomponentmap, datacomponentpatch);
- this.applyImplicitComponents(new TileEntity.b(this) {
+ this.applyImplicitComponents(new TileEntity.b() { // CraftBukkit - decompile error
@Nullable
@Override
public <T> T get(DataComponentType<T> datacomponenttype) {
@@ -306,6 +330,15 @@
this.components = datacomponentmap;
}
+
+ // CraftBukkit start - add method
+ public InventoryHolder getOwner() {
+ if (level == null) return null;
@@ -62,4 +70,7 @@
+ return null;
+ }
+ // CraftBukkit end
}
+
private static class a {
public static final Codec<DataComponentMap> COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY).codec();

View File

@@ -1,14 +1,45 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBanner.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java
@@ -102,6 +102,11 @@
@@ -19,6 +19,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.util.List;
+// CraftBukkit end
+
public class TileEntityBanner extends TileEntity implements INamableTileEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -80,7 +84,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) -> {
- this.patterns = bannerpatternlayers;
+ this.setPatterns(bannerpatternlayers); // CraftBukkit - apply limits
});
}
this.itemPatterns = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (this.itemPatterns.size() > 20) {
+ this.itemPatterns.remove(20);
+ }
+ // CraftBukkit end
this.patterns = null;
@@ -114,7 +118,7 @@
@Override
protected void applyImplicitComponents(TileEntity.b tileentity_b) {
super.applyImplicitComponents(tileentity_b);
- this.patterns = (BannerPatternLayers) tileentity_b.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY);
+ this.setPatterns((BannerPatternLayers) tileentity_b.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits
this.name = (IChatBaseComponent) tileentity_b.get(DataComponents.CUSTOM_NAME);
}
@@ -130,4 +134,13 @@
nbttagcompound.remove("patterns");
nbttagcompound.remove("CustomName");
}
+
+ // CraftBukkit start
+ public void setPatterns(BannerPatternLayers bannerpatternlayers) {
+ if (bannerpatternlayers.layers().size() > 20) {
+ bannerpatternlayers = new BannerPatternLayers(List.copyOf(bannerpatternlayers.layers().subList(0, 20)));
+ }
+ this.patterns = bannerpatternlayers;
+ }
+ // CraftBukkit end
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBarrel.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBarrel.java
@@ -20,8 +20,49 @@
@@ -21,8 +21,49 @@
import net.minecraft.world.level.block.BlockBarrel;
import net.minecraft.world.level.block.state.IBlockData;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java
@@ -40,6 +40,11 @@
@@ -46,6 +46,11 @@
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.phys.AxisAlignedBB;
@@ -12,7 +12,7 @@
public class TileEntityBeacon extends TileEntity implements ITileInventory, INamableTileEntity {
private static final int MAX_LEVELS = 4;
@@ -65,6 +70,15 @@
@@ -71,6 +76,15 @@
public IChatBaseComponent name;
public ChestLock lockKey;
private final IContainerProperties dataAccess;
@@ -27,20 +27,20 @@
+ // CraftBukkit end
@Nullable
static MobEffectList filterEffect(@Nullable MobEffectList mobeffectlist) {
@@ -245,38 +259,77 @@
static Holder<MobEffectList> filterEffect(@Nullable Holder<MobEffectList> holder) {
@@ -251,38 +265,77 @@
super.setRemoved();
}
- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
- if (!world.isClientSide && mobeffectlist != null) {
- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable Holder<MobEffectList> holder, @Nullable Holder<MobEffectList> holder1) {
- if (!world.isClientSide && holder != null) {
- double d0 = (double) (i * 10 + 10);
+ // CraftBukkit start - split into components
+ private static byte getAmplification(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ private static byte getAmplification(int i, @Nullable Holder<MobEffectList> holder, @Nullable Holder<MobEffectList> holder1) {
+ {
byte b0 = 0;
if (i >= 4 && mobeffectlist == mobeffectlist1) {
if (i >= 4 && Objects.equals(holder, holder1)) {
b0 = 1;
}
@@ -66,7 +66,7 @@
+ }
+ }
+
+ private static void applyEffect(List list, MobEffectList mobeffectlist, int j, int b0) {
+ private static void applyEffect(List list, @Nullable Holder<MobEffectList> holder, int j, int b0) {
+ {
Iterator iterator = list.iterator();
@@ -74,20 +74,20 @@
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true));
+ entityhuman.addEffect(new MobEffect(mobeffectlist, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
- entityhuman.addEffect(new MobEffect(holder, j, b0, true, true));
+ entityhuman.addEffect(new MobEffect(holder, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
}
+ }
+ }
+ private static boolean hasSecondaryEffect(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ private static boolean hasSecondaryEffect(int i, @Nullable Holder<MobEffectList> holder, @Nullable Holder<MobEffectList> holder1) {
+ {
if (i >= 4 && mobeffectlist != mobeffectlist1 && mobeffectlist1 != null) {
if (i >= 4 && !Objects.equals(holder, holder1) && holder1 != null) {
- iterator = list.iterator();
-
- while (iterator.hasNext()) {
- entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(mobeffectlist1, j, 0, true, true));
- entityhuman.addEffect(new MobEffect(holder1, j, 0, true, true));
- }
+ return true;
}
@@ -96,18 +96,18 @@
+ }
+ }
+
+ private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ if (!world.isClientSide && mobeffectlist != null) {
+ private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable Holder<MobEffectList> holder, @Nullable Holder<MobEffectList> holder1) {
+ if (!world.isClientSide && holder != null) {
+ double d0 = (double) (i * 10 + 10);
+ byte b0 = getAmplification(i, mobeffectlist, mobeffectlist1);
+ byte b0 = getAmplification(i, holder, holder1);
+
+ int j = getLevel(i);
+ List list = getHumansInRange(world, blockposition, i);
+
+ applyEffect(list, mobeffectlist, j, b0);
+ applyEffect(list, holder, j, b0);
+
+ if (hasSecondaryEffect(i, mobeffectlist, mobeffectlist1)) {
+ applyEffect(list, mobeffectlist1, j, 0);
+ if (hasSecondaryEffect(i, holder, holder1)) {
+ applyEffect(list, holder1, j, 0);
+ }
}
+
@@ -116,20 +116,20 @@
public static void playSound(World world, BlockPosition blockposition, SoundEffect soundeffect) {
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
@@ -312,7 +365,7 @@
@@ -316,7 +369,7 @@
if (nbttagcompound.contains(s, 8)) {
MinecraftKey minecraftkey = MinecraftKey.tryParse(nbttagcompound.getString(s));
- return filterEffect((MobEffectList) BuiltInRegistries.MOB_EFFECT.get(minecraftkey));
+ return (MobEffectList) BuiltInRegistries.MOB_EFFECT.get(minecraftkey); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598)
- 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)
} else {
return null;
}
@@ -323,6 +376,7 @@
super.load(nbttagcompound);
@@ -327,6 +380,7 @@
super.loadAdditional(nbttagcompound, holderlookup_a);
this.primaryPower = loadEffect(nbttagcompound, "primary_effect");
this.secondaryPower = loadEffect(nbttagcompound, "secondary_effect");
+ this.levels = nbttagcompound.getInt("Levels"); // CraftBukkit - SPIGOT-5053, use where available
if (nbttagcompound.contains("CustomName", 8)) {
this.name = IChatBaseComponent.ChatSerializer.fromJson(nbttagcompound.getString("CustomName"));
this.name = IChatBaseComponent.ChatSerializer.fromJson(nbttagcompound.getString("CustomName"), holderlookup_a);
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java
@@ -27,6 +27,10 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -42,6 +42,10 @@
import net.minecraft.world.level.gameevent.GameEvent;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
@@ -10,8 +10,8 @@
+
public class TileEntityBeehive extends TileEntity {
public static final String TAG_FLOWER_POS = "FlowerPos";
@@ -43,6 +47,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
@@ -55,6 +59,7 @@
private final 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);
@@ -82,7 +87,7 @@
@@ -94,7 +99,7 @@
}
public boolean isFull() {
@@ -28,7 +28,7 @@
}
public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -99,7 +104,7 @@
@@ -111,7 +116,7 @@
if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) {
if (!this.isSedated()) {
@@ -37,7 +37,7 @@
} else {
entitybee.setStayOutOfHiveCountdown(400);
}
@@ -111,10 +116,16 @@
@@ -123,10 +128,16 @@
}
private List<Entity> releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -49,16 +49,16 @@
List<Entity> list = Lists.newArrayList();
this.stored.removeIf((tileentitybeehive_hivebee) -> {
- return releaseOccupant(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos);
+ return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
- return releaseOccupant(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee.toOccupant(), list, tileentitybeehive_releasestatus, this.savedFlowerPos);
+ return releaseOccupant(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee.toOccupant(), list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
+ // CraftBukkit end
});
if (!list.isEmpty()) {
super.setChanged();
@@ -142,7 +153,19 @@
@@ -150,7 +161,19 @@
}
public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) {
public void addOccupant(Entity entity) {
- if (this.stored.size() < 3) {
+ if (this.stored.size() < this.maxBees) { // CraftBukkit
+ // CraftBukkit start
@@ -75,9 +75,9 @@
+ // CraftBukkit end
entity.stopRiding();
entity.ejectPassengers();
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -164,7 +187,7 @@
this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState()));
this.storeBee(TileEntityBeehive.c.of(entity));
@@ -169,7 +192,7 @@
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, this.getBlockState()));
}
- entity.discard();
@@ -85,77 +85,79 @@
super.setChanged();
}
}
@@ -174,7 +197,13 @@
@@ -179,7 +202,13 @@
}
private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) {
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) {
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
+ return releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, blockposition1, false);
+ return releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_c, list, tileentitybeehive_releasestatus, blockposition1, false);
+ }
+
+ private static boolean releaseBee(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1, boolean force) {
+ 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) {
+ // CraftBukkit end
return false;
} else {
NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData.copy();
@@ -197,6 +226,18 @@
if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) {
return false;
} else {
+ // CraftBukkit start
+ if (entity instanceof EntityBee) {
+ 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();
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getBbHeight() / 2.0F);
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockBeehive.FACING);
@@ -192,6 +221,18 @@
Entity entity = tileentitybeehive_c.createEntity(world, blockposition);
if (entity != null) {
+ // CraftBukkit start
+ if (entity instanceof EntityBee) {
+ 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();
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getBbHeight() / 2.0F);
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
+
+ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ }
+ if (!world.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ // CraftBukkit end
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
+ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ }
+ if (!world.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ // CraftBukkit end
if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity;
@@ -228,6 +269,7 @@
list.add(entitybee);
}
+ /* // CraftBukkit start
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();
@@ -235,11 +277,12 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ */ // CraftBukkit end
@@ -222,6 +263,7 @@
list.add(entitybee);
}
world.playSound((EntityHuman) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, world.getBlockState(blockposition)));
- return world.addFreshEntity(entity);
+ return true; // return this.world.addFreshEntity(entity); // CraftBukkit - moved up
+ /* // CraftBukkit start
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 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ */ // CraftBukkit end
}
world.playSound((EntityHuman) null, blockposition, SoundEffects.BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(entity, world.getBlockState(blockposition)));
- return world.addFreshEntity(entity);
+ return true; // return this.world.addFreshEntity(entity); // CraftBukkit - moved up
} else {
return false;
@@ -288,6 +331,10 @@
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
}
@@ -258,6 +301,10 @@
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee.toOccupant(), (List) null, tileentitybeehive_releasestatus, blockposition1)) {
flag = true;
iterator.remove();
+ // CraftBukkit start
+ } else {
+ tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
+ tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.occupant.minTicksInHive / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
+ // CraftBukkit end
}
}
}
@@ -329,6 +376,11 @@
this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos"));
@@ -293,7 +340,12 @@
});
}
- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null);
+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error
+ // CraftBukkit start
+ if (nbttagcompound.contains("Bukkit.MaxEntities")) {
+ this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities");
@@ -164,11 +166,29 @@
}
@Override
@@ -338,6 +390,7 @@
@@ -303,6 +355,7 @@
if (this.hasSavedFlowerPos()) {
nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
}
+ nbttagcompound.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
}
@@ -350,7 +403,7 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
entity.save(nbttagcompound);
- List list = TileEntityBeehive.IGNORED_BEE_TAGS;
+ List<String> list = TileEntityBeehive.IGNORED_BEE_TAGS; // CraftBukkit - decompile error
Objects.requireNonNull(nbttagcompound);
list.forEach(nbttagcompound::remove);
@@ -369,7 +422,7 @@
@Nullable
public Entity createEntity(World world, BlockPosition blockposition) {
NBTTagCompound nbttagcompound = this.entityData.copyTag();
- List list = TileEntityBeehive.IGNORED_BEE_TAGS;
+ List<String> list = TileEntityBeehive.IGNORED_BEE_TAGS; // CraftBukkit - decompile error
Objects.requireNonNull(nbttagcompound);
list.forEach(nbttagcompound::remove);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
@@ -25,6 +25,20 @@
@@ -23,6 +23,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;
@@ -42,6 +56,36 @@
@@ -40,6 +54,36 @@
private Item ingredient;
public int fuel;
protected final IContainerProperties dataAccess;
@@ -58,7 +58,7 @@
public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata);
@@ -109,8 +153,19 @@
@@ -106,8 +150,19 @@
ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4);
if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) {
@@ -80,7 +80,7 @@
setChanged(world, blockposition, iblockdata);
}
@@ -118,12 +173,17 @@
@@ -115,12 +170,17 @@
boolean flag1 = tileentitybrewingstand.brewTime > 0;
ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3);
@@ -101,7 +101,7 @@
setChanged(world, blockposition, iblockdata);
} else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) {
tileentitybrewingstand.brewTime = 0;
@@ -131,7 +191,11 @@
@@ -128,7 +188,11 @@
}
} else if (flag && tileentitybrewingstand.fuel > 0) {
--tileentitybrewingstand.fuel;
@@ -114,20 +114,21 @@
tileentitybrewingstand.ingredient = itemstack1.getItem();
setChanged(world, blockposition, iblockdata);
}
@@ -187,11 +251,33 @@
@@ -184,12 +248,34 @@
}
}
- private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) {
+ // CraftBukkit start
+ private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) {
+ private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) { // CraftBukkit
ItemStack itemstack = (ItemStack) nonnulllist.get(3);
PotionBrewer potionbrewer = world.potionBrewing();
+ // CraftBukkit start
+ InventoryHolder owner = tileentitybrewingstand.getOwner();
+ List<org.bukkit.inventory.ItemStack> brewResults = new ArrayList<>(3);
for (int i = 0; i < 3; ++i) {
- nonnulllist.set(i, PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i)));
+ brewResults.add(i, CraftItemStack.asCraftMirror(PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i))));
- nonnulllist.set(i, potionbrewer.mix(itemstack, (ItemStack) nonnulllist.get(i)));
+ brewResults.add(i, CraftItemStack.asCraftMirror(potionbrewer.mix(itemstack, (ItemStack) nonnulllist.get(i))));
+ }
+
+ if (owner != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java
@@ -26,6 +26,14 @@
@@ -31,6 +31,14 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -15,7 +15,7 @@
public class TileEntityCampfire extends TileEntity implements Clearable {
private static final int BURN_COOL_SPEED = 2;
@@ -60,6 +68,20 @@
@@ -65,6 +73,20 @@
}).orElse(itemstack);
if (itemstack1.isItemEnabled(world.enabledFeatures())) {
@@ -36,7 +36,7 @@
InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -172,7 +194,11 @@
@@ -177,7 +199,11 @@
ItemStack itemstack1 = (ItemStack) this.items.get(j);
if (itemstack1.isEmpty()) {
@@ -48,4 +48,4 @@
+ // CraftBukkit end
this.cookingProgress[j] = 0;
this.items.set(j, itemstack.split(1));
this.level.gameEvent(GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entity, this.getBlockState()));
this.level.gameEvent((Holder) GameEvent.BLOCK_CHANGE, this.getBlockPos(), GameEvent.a.of(entity, this.getBlockState()));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityChest.java
+++ b/net/minecraft/world/level/block/entity/TileEntityChest.java
@@ -23,6 +23,12 @@
@@ -24,6 +24,12 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.properties.BlockPropertyChestType;
@@ -13,7 +13,7 @@
public class TileEntityChest extends TileEntityLootable implements LidBlockEntity {
private static final int EVENT_SET_OPEN_COUNT = 1;
@@ -30,6 +36,36 @@
@@ -31,6 +37,36 @@
public final ContainerOpenersCounter openersCounter;
private final ChestLidController chestLidController;
@@ -50,7 +50,7 @@
protected TileEntityChest(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.withSize(27, ItemStack.EMPTY);
@@ -198,4 +234,11 @@
@@ -199,4 +235,11 @@
world.blockEvent(blockposition, block, 1, j);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCommand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCommand.java
@@ -20,6 +20,13 @@
@@ -24,6 +24,13 @@
private boolean auto;
private boolean conditionMet;
private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() {

View File

@@ -1,21 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityConduit.java
+++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java
@@ -40,11 +40,11 @@
private float activeRotation;
private boolean isActive;
private boolean isHunting;
- private final List<BlockPosition> effectBlocks = Lists.newArrayList();
+ public final List<BlockPosition> effectBlocks = Lists.newArrayList();
@Nullable
- private EntityLiving destroyTarget;
+ public EntityLiving destroyTarget;
@Nullable
- private UUID destroyTargetUUID;
+ public UUID destroyTargetUUID;
private long nextAmbientSoundActivation;
public TileEntityConduit(BlockPosition blockposition, IBlockData iblockdata) {
@@ -186,8 +186,20 @@
@@ -187,8 +187,20 @@
}
private static void applyEffects(World world, BlockPosition blockposition, List<BlockPosition> list) {
@@ -36,7 +21,7 @@
int k = blockposition.getX();
int l = blockposition.getY();
int i1 = blockposition.getZ();
@@ -201,7 +213,7 @@
@@ -202,7 +214,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
@@ -45,7 +30,7 @@
}
}
@@ -209,6 +221,12 @@
@@ -210,6 +222,12 @@
}
private static void updateDestroyTarget(World world, BlockPosition blockposition, IBlockData iblockdata, List<BlockPosition> list, TileEntityConduit tileentityconduit) {
@@ -58,7 +43,7 @@
EntityLiving entityliving = tileentityconduit.destroyTarget;
int i = list.size();
@@ -229,9 +247,12 @@
@@ -230,9 +248,12 @@
tileentityconduit.destroyTarget = null;
}
@@ -74,12 +59,3 @@
}
if (entityliving != tileentityconduit.destroyTarget) {
@@ -252,7 +273,7 @@
}
- private static AxisAlignedBB getDestroyRangeAABB(BlockPosition blockposition) {
+ public static AxisAlignedBB getDestroyRangeAABB(BlockPosition blockposition) {
int i = blockposition.getX();
int j = blockposition.getY();
int k = blockposition.getZ();

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/level/block/entity/TileEntityContainer.java
+++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java
@@ -89,4 +89,12 @@
@@ -178,4 +178,12 @@
nbttagcompound.remove("Lock");
nbttagcompound.remove("Items");
}
protected abstract Container createMenu(int i, PlayerInventory playerinventory);
+
+ // CraftBukkit start
+ @Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityDispenser.java
+++ b/net/minecraft/world/level/block/entity/TileEntityDispenser.java
@@ -13,11 +13,47 @@
@@ -14,11 +14,47 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.IBlockData;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
+++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
@@ -33,6 +33,15 @@
@@ -34,6 +34,15 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -16,7 +16,7 @@
public class TileEntityEndGateway extends TileEntityEnderPortal {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -169,7 +178,7 @@
@@ -163,7 +172,7 @@
tileentityendgateway.teleportCooldown = 100;
BlockPosition blockposition1;
@@ -25,7 +25,7 @@
blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition);
blockposition1 = blockposition1.above(10);
TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1);
@@ -190,7 +199,7 @@
@@ -184,7 +193,7 @@
if (entity2 != null) {
entity1 = entity2;
@@ -34,7 +34,7 @@
} else {
entity1 = entity;
}
@@ -198,8 +207,34 @@
@@ -192,8 +201,34 @@
entity1 = entity.getRootVehicle();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java
+++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java
@@ -47,6 +47,21 @@
@@ -48,6 +48,21 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
@@ -22,7 +22,7 @@
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeCraftingHolder, AutoRecipeOutput {
protected static final int SLOT_INPUT = 0;
@@ -115,7 +130,7 @@
@@ -118,7 +133,7 @@
}
};
this.recipesUsed = new Object2IntOpenHashMap();
@@ -30,9 +30,9 @@
+ this.quickCheck = CraftingManager.createCheck((Recipes<RecipeCooking>) recipes); // CraftBukkit - decompile error // Eclipse fail
}
public static Map<Item, Integer> getFuel() {
@@ -183,6 +198,40 @@
return map;
public static void invalidateCache() {
@@ -197,6 +212,40 @@
}
}
+ // CraftBukkit start - add fields and methods
@@ -72,7 +72,7 @@
private static boolean isNeverAFurnaceFuel(Item item) {
return item.builtInRegistryHolder().is(TagsItem.NON_FLAMMABLE_WOOD);
}
@@ -271,7 +320,7 @@
@@ -285,7 +334,7 @@
RecipeHolder recipeholder;
if (flag2) {
@@ -81,7 +81,7 @@
} else {
recipeholder = null;
}
@@ -279,9 +328,20 @@
@@ -293,9 +342,20 @@
int i = tileentityfurnace.getMaxStackSize();
if (!tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) {
@@ -104,7 +104,7 @@
flag1 = true;
if (flag3) {
Item item = itemstack.getItem();
@@ -297,11 +357,23 @@
@@ -311,11 +371,23 @@
}
if (tileentityfurnace.isLit() && canBurn(world.registryAccess(), recipeholder, tileentityfurnace.items, i)) {
@@ -129,7 +129,7 @@
tileentityfurnace.setRecipeUsed(recipeholder);
}
@@ -340,17 +412,44 @@
@@ -354,17 +426,44 @@
}
}
@@ -167,7 +167,7 @@
+ /*
if (itemstack2.isEmpty()) {
nonnulllist.set(2, itemstack1.copy());
} else if (itemstack2.is(itemstack1.getItem())) {
} else if (ItemStack.isSameItemSameComponents(itemstack2, itemstack1)) {
itemstack2.grow(1);
}
+ */
@@ -175,7 +175,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));
@@ -374,6 +473,7 @@
@@ -388,6 +487,7 @@
}
private static int getTotalCookTime(World world, TileEntityFurnace tileentityfurnace) {
@@ -183,7 +183,7 @@
return (Integer) tileentityfurnace.quickCheck.getRecipeFor(tileentityfurnace, world).map((recipeholder) -> {
return ((RecipeCooking) recipeholder.value()).getCookingTime();
}).orElse(200);
@@ -495,8 +595,8 @@
@@ -474,8 +574,8 @@
@Override
public void awardUsedRecipes(EntityHuman entityhuman, List<ItemStack> list) {}
@@ -194,7 +194,7 @@
entityplayer.awardRecipes(list);
Iterator iterator = list.iterator();
@@ -513,6 +613,12 @@
@@ -492,6 +592,12 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) {
@@ -207,7 +207,7 @@
List<RecipeHolder<?>> list = Lists.newArrayList();
ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator();
@@ -521,14 +627,14 @@
@@ -500,14 +606,14 @@
worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((recipeholder) -> {
list.add(recipeholder);
@@ -224,7 +224,7 @@
int j = MathHelper.floor((float) i * f);
float f1 = MathHelper.frac((float) i * f);
@@ -536,6 +642,17 @@
@@ -515,6 +621,17 @@
++j;
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/entity/TileEntityHopper.java
+++ b/net/minecraft/world/level/block/entity/TileEntityHopper.java
@@ -32,6 +32,22 @@
import net.minecraft.world.phys.shapes.OperatorBoolean;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -30,6 +30,22 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.world.InventoryLargeChest;
@@ -24,8 +24,8 @@
public static final int MOVE_ITEM_SPEED = 8;
@@ -40,6 +56,36 @@
private int cooldownTime;
private long tickedGameTime;
private EnumDirection facing;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -60,62 +60,41 @@
public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.HOPPER, blockposition, iblockdata);
this.items = NonNullList.withSize(5, ItemStack.EMPTY);
@@ -113,7 +159,7 @@
boolean flag = false;
@@ -167,7 +213,28 @@
if (!tileentityhopper.isEmpty()) {
- flag = ejectItems(world, blockposition, iblockdata, tileentityhopper);
+ flag = ejectItems(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit
}
if (!tileentityhopper.inventoryFull()) {
@@ -147,7 +193,7 @@
return false;
}
- private static boolean ejectItems(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory) {
+ private static boolean ejectItems(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory, TileEntityHopper hopper) { // CraftBukkit
IInventory iinventory1 = getAttachedContainer(world, blockposition, iblockdata);
if (iinventory1 == null) {
@@ -161,7 +207,30 @@
for (int i = 0; i < iinventory.getContainerSize(); ++i) {
if (!iinventory.getItem(i).isEmpty()) {
ItemStack itemstack = iinventory.getItem(i).copy();
- ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
+ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.removeItem(i, 1), enumdirection);
+
if (!itemstack.isEmpty()) {
int j = itemstack.getCount();
- ItemStack itemstack1 = addItem(tileentityhopper, iinventory, tileentityhopper.removeItem(i, 1), enumdirection);
+ // CraftBukkit start - Call event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1));
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(tileentityhopper.removeItem(i, 1));
+
+ Inventory destinationInventory;
+ // Have to special case large chests as they work oddly
+ if (iinventory1 instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory1);
+ } else if (iinventory1.getOwner() != null) {
+ destinationInventory = iinventory1.getOwner().getInventory();
+ if (iinventory instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ } else if (iinventory.getOwner() != null) {
+ destinationInventory = iinventory.getOwner().getInventory();
+ } else {
+ destinationInventory = new CraftInventory(iinventory);
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack, destinationInventory, true);
+ world.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ hopper.setItem(i, itemstack);
+ hopper.setCooldown(8); // Delay hopper checks
+ tileentityhopper.setItem(i, itemstack);
+ tileentityhopper.setCooldown(8); // Delay hopper checks
+ return false;
+ }
+ ItemStack itemstack1 = addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ ItemStack itemstack1 = addItem(tileentityhopper, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ // CraftBukkit end
if (itemstack1.isEmpty()) {
iinventory1.setChanged();
@@ -226,7 +295,34 @@
iinventory.setChanged();
@@ -279,7 +346,33 @@
if (!itemstack.isEmpty() && canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) {
ItemStack itemstack1 = itemstack.copy();
- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
int j = itemstack.getCount();
- ItemStack itemstack1 = addItem(iinventory, ihopper, iinventory.removeItem(i, 1), (EnumDirection) null);
+ // CraftBukkit start - Call event on collection of items from inventories into the hopper
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1));
+
@@ -129,11 +108,11 @@
+ sourceInventory = new CraftInventory(iinventory);
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack, ihopper.getOwner().getInventory(), false);
+
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ iinventory.setItem(i, itemstack1);
+ iinventory.setItem(i, itemstack);
+
+ if (ihopper instanceof TileEntityHopper) {
+ ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks
@@ -141,12 +120,12 @@
+
+ return false;
+ }
+ ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
+ ItemStack itemstack1 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
+ // CraftBukkit end
if (itemstack2.isEmpty()) {
if (itemstack1.isEmpty()) {
iinventory.setChanged();
@@ -241,13 +337,20 @@
@@ -297,13 +390,20 @@
public static boolean addItem(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
@@ -168,7 +147,7 @@
} else {
entityitem.setItem(itemstack1);
}
@@ -367,16 +470,40 @@
@@ -421,14 +521,38 @@
return itemstack;
}
@@ -183,13 +162,11 @@
+ // CraftBukkit end
+
@Nullable
private static IInventory getAttachedContainer(World world, BlockPosition blockposition, IBlockData iblockdata) {
EnumDirection enumdirection = (EnumDirection) iblockdata.getValue(BlockHopper.FACING);
- return getContainerAt(world, blockposition.relative(enumdirection));
private static IInventory getAttachedContainer(World world, BlockPosition blockposition, TileEntityHopper tileentityhopper) {
- return getContainerAt(world, blockposition.relative(tileentityhopper.facing));
+ // CraftBukkit start
+ BlockPosition searchPosition = blockposition.relative(enumdirection);
+ IInventory inventory = getContainerAt(world, blockposition.relative(enumdirection));
+ BlockPosition searchPosition = blockposition.relative(tileentityhopper.facing);
+ IInventory inventory = getContainerAt(world, searchPosition);
+
+ CraftBlock hopper = CraftBlock.at(world, blockposition);
+ CraftBlock searchBlock = CraftBlock.at(world, searchPosition);
@@ -198,10 +175,10 @@
}
@Nullable
private static IInventory getSourceContainer(World world, IHopper ihopper) {
- return getContainerAt(world, ihopper.getLevelX(), ihopper.getLevelY() + 1.0D, ihopper.getLevelZ());
private static IInventory getSourceContainer(World world, IHopper ihopper, BlockPosition blockposition, IBlockData iblockdata) {
- return getContainerAt(world, blockposition, iblockdata, ihopper.getLevelX(), ihopper.getLevelY() + 1.0D, ihopper.getLevelZ());
+ // CraftBukkit start
+ IInventory inventory = getContainerAt(world, ihopper.getLevelX(), ihopper.getLevelY() + 1.0D, ihopper.getLevelZ());
+ IInventory inventory = getContainerAt(world, blockposition, iblockdata, ihopper.getLevelX(), ihopper.getLevelY() + 1.0D, ihopper.getLevelZ());
+
+ BlockPosition blockPosition = BlockPosition.containing(ihopper.getLevelX(), ihopper.getLevelY(), ihopper.getLevelZ());
+ CraftBlock hopper = CraftBlock.at(world, blockPosition);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
@@ -22,6 +22,14 @@
@@ -24,6 +24,14 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.ticks.ContainerSingleItem;
@@ -12,10 +12,10 @@
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem {
public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem.a {
private static final int SONG_END_PADDING = 20;
@@ -30,6 +38,42 @@
@@ -32,6 +40,42 @@
public long tickCount;
public long recordStartedTick;
public boolean isPlaying;
@@ -58,7 +58,7 @@
public TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.JUKEBOX, blockposition, iblockdata);
@@ -150,7 +194,7 @@
@@ -154,7 +198,7 @@
@Override
public int getMaxStackSize() {
@@ -67,7 +67,7 @@
}
@Override
@@ -203,7 +247,11 @@
@@ -206,7 +250,11 @@
@VisibleForTesting
public void setRecordWithoutPlaying(ItemStack itemstack) {
this.item = itemstack;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityLectern.java
+++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java
@@ -25,13 +25,72 @@
@@ -29,13 +29,72 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@@ -75,7 +75,7 @@
@Override
public int getContainerSize() {
return 1;
@@ -76,11 +135,20 @@
@@ -80,11 +139,20 @@
}
@Override
@@ -98,7 +98,7 @@
}
@Override
@@ -160,7 +228,7 @@
@@ -164,7 +232,7 @@
if (j != this.page) {
this.page = j;
this.setChanged();
@@ -107,7 +107,7 @@
}
}
@@ -183,6 +251,32 @@
@@ -187,6 +255,32 @@
return itemstack;
}
@@ -140,7 +140,7 @@
private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) {
String s;
Object object;
@@ -197,7 +291,8 @@
@@ -201,7 +295,8 @@
Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition);
@@ -150,7 +150,7 @@
}
@Override
@@ -235,7 +330,7 @@
@@ -239,7 +334,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
@@ -32,6 +32,11 @@
@@ -34,6 +34,11 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -12,7 +12,7 @@
public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory {
public static final int COLUMNS = 9;
@@ -51,6 +56,37 @@
@@ -52,6 +57,37 @@
@Nullable
private final EnumColor color;
@@ -50,19 +50,19 @@
public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata);
this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
@@ -172,6 +208,7 @@
@@ -173,6 +209,7 @@
}
++this.openCount;
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount);
if (this.openCount == 1) {
this.level.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition);
@@ -185,6 +222,7 @@
this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_OPEN, this.worldPosition);
@@ -186,6 +223,7 @@
public void stopOpen(EntityHuman entityhuman) {
if (!this.remove && !entityhuman.isSpectator()) {
--this.openCount;
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount);
if (this.openCount <= 0) {
this.level.gameEvent((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition);
this.level.gameEvent((Entity) entityhuman, (Holder) GameEvent.CONTAINER_CLOSE, this.worldPosition);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntitySign.java
+++ b/net/minecraft/world/level/block/entity/TileEntitySign.java
@@ -33,7 +33,17 @@
@@ -36,7 +36,17 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -19,25 +19,25 @@
private static final Logger LOGGER = LogUtils.getLogger();
private static final int MAX_TEXT_LINE_WIDTH = 90;
@@ -98,7 +108,7 @@
@Override
protected void saveAdditional(NBTTagCompound nbttagcompound) {
super.saveAdditional(nbttagcompound);
- DataResult dataresult = SignText.DIRECT_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.frontText);
+ DataResult<NBTBase> dataresult = SignText.DIRECT_CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.frontText); // CraftBukkit - decompile error
@@ -101,7 +111,7 @@
protected void saveAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
super.saveAdditional(nbttagcompound, holderlookup_a);
DynamicOps<NBTBase> dynamicops = holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE);
- DataResult dataresult = SignText.DIRECT_CODEC.encodeStart(dynamicops, this.frontText);
+ DataResult<NBTBase> dataresult = SignText.DIRECT_CODEC.encodeStart(dynamicops, this.frontText); // CraftBukkit - decompile error
Logger logger = TileEntitySign.LOGGER;
Objects.requireNonNull(logger);
@@ -117,7 +127,7 @@
@Override
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
@@ -121,7 +131,7 @@
protected void loadAdditional(NBTTagCompound nbttagcompound, HolderLookup.a holderlookup_a) {
super.loadAdditional(nbttagcompound, holderlookup_a);
DynamicOps<NBTBase> dynamicops = holderlookup_a.createSerializationContext(DynamicOpsNBT.INSTANCE);
- DataResult dataresult;
+ DataResult<SignText> dataresult; // CraftBukkit - decompile error
Logger logger;
if (nbttagcompound.contains("front_text")) {
@@ -171,12 +181,13 @@
@@ -173,12 +183,13 @@
public void updateSignText(EntityHuman entityhuman, boolean flag, List<FilteredText> list) {
if (!this.isWaxed() && entityhuman.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) {
this.updateText((signtext) -> {
@@ -52,7 +52,7 @@
}
}
@@ -186,7 +197,8 @@
@@ -188,7 +199,8 @@
return this.setText((SignText) unaryoperator.apply(signtext), flag);
}
@@ -62,7 +62,7 @@
for (int i = 0; i < list.size(); ++i) {
FilteredText filteredtext = (FilteredText) list.get(i);
ChatModifier chatmodifier = signtext.getMessage(i, entityhuman.isTextFilteringEnabled()).getStyle();
@@ -198,6 +210,29 @@
@@ -200,6 +212,29 @@
}
}
@@ -92,7 +92,7 @@
return signtext;
}
@@ -248,11 +283,37 @@
@@ -250,11 +285,37 @@
return flag1;
}
@@ -132,7 +132,7 @@
}
@Override
@@ -276,12 +337,17 @@
@@ -278,12 +339,17 @@
@Nullable
public UUID getPlayerWhoMayEdit() {

View File

@@ -1,19 +0,0 @@
--- a/net/minecraft/world/level/block/entity/TileEntitySkull.java
+++ b/net/minecraft/world/level/block/entity/TileEntitySkull.java
@@ -194,6 +194,16 @@
if (!SystemUtils.isBlank(s)) {
resolveGameProfile(nbttagcompound, s);
+ // CraftBukkit start
+ } else {
+ net.minecraft.nbt.NBTTagList textures = nbttagcompound.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10); // Safe due to method contracts
+ for (int i = 0; i < textures.size(); i++) {
+ if (textures.get(i) instanceof NBTTagCompound && !((NBTTagCompound) textures.get(i)).contains("Signature", 8) && ((NBTTagCompound) textures.get(i)).getString("Value").trim().isEmpty()) {
+ nbttagcompound.remove("SkullOwner");
+ break;
+ }
+ }
+ // CraftBukkit end
}
}

View File

@@ -0,0 +1,18 @@
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
@@ -179,13 +179,13 @@
}
public void resetAfterBecomingOminous(TrialSpawner trialspawner, WorldServer worldserver) {
- Stream stream = this.currentMobs.stream();
+ Stream<UUID> stream = this.currentMobs.stream(); // CraftBukkit - decompile error
Objects.requireNonNull(worldserver);
stream.map(worldserver::getEntity).forEach((entity) -> {
if (entity != null) {
worldserver.levelEvent(3012, entity.blockPosition(), TrialSpawner.a.NORMAL.encode());
- entity.remove(Entity.RemovalReason.DISCARDED);
+ entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - Add bukkit remove cause;
}
});
if (!trialspawner.getOminousConfig().spawnPotentialsDefinition().isEmpty()) {