Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -9,14 +9,14 @@
public ContainerOpenersCounter() {}
@@ -25,8 +26,19 @@
protected abstract boolean a(EntityHuman entityhuman);
protected abstract boolean isOwnContainer(EntityHuman entityhuman);
public void a(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
public void incrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
+ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added
int i = this.openCount++;
+ // CraftBukkit start - Call redstone event
+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ if (world.getBlockState(blockposition).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
@@ -26,17 +26,17 @@
+ // CraftBukkit end
+
if (i == 0) {
this.a(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
this.onOpen(world, blockposition, iblockdata);
world.gameEvent(entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
@@ -37,8 +49,19 @@
}
public void b(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
public void decrementOpeners(EntityHuman entityhuman, World world, BlockPosition blockposition, IBlockData iblockdata) {
+ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added
int i = this.openCount--;
+ // CraftBukkit start - Call redstone event
+ if (world.getType(blockposition).a(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ if (world.getBlockState(blockposition).is(net.minecraft.world.level.block.Blocks.TRAPPED_CHEST)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
@@ -46,12 +46,12 @@
+ // CraftBukkit end
+
if (this.openCount == 0) {
this.b(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
this.onClose(world, blockposition, iblockdata);
world.gameEvent(entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
@@ -59,6 +82,7 @@
public void c(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.a(world, blockposition);
public void recheckOpeners(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.getOpenCount(world, blockposition);
+ 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/TileEntity.java
+++ b/net/minecraft/world/level/block/entity/TileEntity.java
@@ -12,8 +12,18 @@
@@ -15,8 +15,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -19,7 +19,7 @@
private static final Logger LOGGER = LogManager.getLogger();
private final TileEntityTypes<?> type;
@Nullable
@@ -41,7 +51,16 @@
@@ -48,7 +58,16 @@
return this.level != null;
}
@@ -35,22 +35,22 @@
+ }
+ // CraftBukkit end
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
return this.c(nbttagcompound);
@@ -57,6 +76,11 @@
nbttagcompound.setInt("x", this.worldPosition.getX());
nbttagcompound.setInt("y", this.worldPosition.getY());
nbttagcompound.setInt("z", this.worldPosition.getZ());
+ // CraftBukkit start - store container
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return nbttagcompound;
}
protected void saveAdditional(NBTTagCompound nbttagcompound) {}
@@ -70,6 +89,11 @@
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.saveAdditional(nbttagcompound);
+ // CraftBukkit start - store container
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
+ nbttagcompound.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return nbttagcompound;
}
@@ -164,4 +188,15 @@
public void b(IBlockData iblockdata) {
@@ -201,4 +225,15 @@
public void setBlockState(IBlockData iblockdata) {
this.blockState = iblockdata;
}
+

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBanner.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java
@@ -99,6 +99,11 @@
@@ -101,6 +101,11 @@
}
this.itemPatterns = nbttagcompound.getList("Patterns", 10);
@@ -10,5 +10,5 @@
+ }
+ // CraftBukkit end
this.patterns = null;
this.receivedData = true;
}

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 @@
@@ -39,6 +39,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 {
private static final int MAX_LEVELS = 4;
@@ -62,6 +67,15 @@
@@ -61,6 +66,15 @@
public IChatBaseComponent name;
public ChestLock lockKey;
private final IContainerProperties dataAccess;
@@ -28,8 +28,8 @@
public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEACON, blockposition, iblockdata);
@@ -230,39 +244,78 @@
super.aa_();
@@ -229,39 +243,78 @@
super.setRemoved();
}
- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
@@ -59,8 +59,8 @@
+ {
+ double d0 = (double) (i * 10 + 10);
+
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).g(d0).b(0.0D, (double) world.getHeight(), 0.0D);
List<EntityHuman> list = world.a(EntityHuman.class, axisalignedbb);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).inflate(d0).expandTowards(0.0D, (double) world.getHeight(), 0.0D);
List<EntityHuman> list = world.getEntitiesOfClass(EntityHuman.class, axisalignedbb);
+
+ return list;
+ }
@@ -114,20 +114,20 @@
+ }
+ // CraftBukkit end
+
public static void a(World world, BlockPosition blockposition, SoundEffect soundeffect) {
public static void playSound(World world, BlockPosition blockposition, SoundEffect soundeffect) {
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -292,8 +345,11 @@
@@ -290,8 +343,11 @@
@Override
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
- this.primaryPower = a(nbttagcompound.getInt("Primary"));
- this.secondaryPower = a(nbttagcompound.getInt("Secondary"));
- this.primaryPower = getValidEffectById(nbttagcompound.getInt("Primary"));
- this.secondaryPower = getValidEffectById(nbttagcompound.getInt("Secondary"));
+ // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
+ this.primaryPower = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryPower = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
+ this.primaryPower = MobEffectList.byId(nbttagcompound.getInt("Primary"));
+ this.secondaryPower = MobEffectList.byId(nbttagcompound.getInt("Secondary"));
+ this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available
+ // CraftBukkit end
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
this.name = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
if (nbttagcompound.contains("CustomName", 8)) {
this.name = IChatBaseComponent.ChatSerializer.fromJson(nbttagcompound.getString("CustomName"));
}

View File

@@ -16,20 +16,20 @@
+ return this.stored.size() == this.maxBees; // CraftBukkit
}
public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
public void emptyAllLivingFromHive(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -99,7 +100,7 @@
if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) {
if (entityhuman.position().distanceToSqr(entity.position()) <= 16.0D) {
if (!this.isSedated()) {
- entitybee.setGoalTarget(entityhuman);
+ entitybee.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit
- entitybee.setTarget(entityhuman);
+ entitybee.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit
} else {
entitybee.setCannotEnterHiveTicks(400);
entitybee.setStayOutOfHiveCountdown(400);
}
@@ -111,10 +112,16 @@
}
private List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
private List<Entity> releaseAllOccupants(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
+ return releaseBees(iblockdata, tileentitybeehive_releasestatus, false);
+ }
@@ -38,7 +38,7 @@
List<Entity> list = Lists.newArrayList();
this.stored.removeIf((tileentitybeehive_hivebee) -> {
- return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos);
- 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);
+ // CraftBukkit end
});
@@ -47,16 +47,16 @@
@@ -138,7 +145,19 @@
}
public void a(Entity entity, boolean flag, int i) {
public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) {
- if (this.stored.size() < 3) {
+ if (this.stored.size() < this.maxBees) { // CraftBukkit
+ // CraftBukkit start
+ if (this.level != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getPosition()));
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, getBlockPos()));
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (entity instanceof EntityBee) {
+ ((EntityBee) entity).setCannotEnterHiveTicks(400);
+ ((EntityBee) entity).setStayOutOfHiveCountdown(400);
+ }
+ return;
+ }
@@ -68,7 +68,7 @@
@@ -168,7 +187,13 @@
}
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) {
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) {
- 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);
@@ -81,20 +81,20 @@
} else {
NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData;
@@ -191,6 +216,18 @@
if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) {
if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) {
return false;
} else {
+ // CraftBukkit start
+ if (entity instanceof EntityBee) {
+ float f = entity.getWidth();
+ 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.getAdjacentX();
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F);
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
+ 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.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ }
+ if (!world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ 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;
@@ -104,25 +104,25 @@
}
+ /* // CraftBukkit start
float f = entity.getWidth();
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.getAdjacentX();
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX();
@@ -227,10 +265,11 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
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);
- return world.addEntity(entity);
+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
- return world.addFreshEntity(entity);
+ return true; // return this.world.addFreshEntity(entity); // CraftBukkit - moved up
}
} else {
return false;
@@ -276,6 +315,10 @@
if (releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
iterator.remove();
+ // CraftBukkit start
+ } else {
@@ -132,11 +132,11 @@
}
}
@@ -313,6 +356,11 @@
this.savedFlowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos"));
}
+ // CraftBukkit start
+ if (nbttagcompound.hasKey("Bukkit.MaxEntities")) {
+ if (nbttagcompound.contains("Bukkit.MaxEntities")) {
+ this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities");
+ }
+ // CraftBukkit end
@@ -144,10 +144,10 @@
@Override
@@ -322,6 +370,7 @@
if (this.s()) {
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.savedFlowerPos));
if (this.hasSavedFlowerPos()) {
nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
}
+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
+ nbttagcompound.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
return nbttagcompound;
}

View File

@@ -60,9 +60,9 @@
@@ -109,8 +152,19 @@
ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4);
if (tileentitybrewingstand.fuel <= 0 && itemstack.a(Items.BLAZE_POWDER)) {
if (tileentitybrewingstand.fuel <= 0 && itemstack.is(Items.BLAZE_POWDER)) {
- tileentitybrewingstand.fuel = 20;
- itemstack.subtract(1);
- itemstack.shrink(1);
+ // CraftBukkit start
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(CraftBlock.at(world, blockposition), CraftItemStack.asCraftMirror(itemstack), 20);
+ world.getCraftServer().getPluginManager().callEvent(event);
@@ -73,10 +73,10 @@
+
+ tileentitybrewingstand.fuel = event.getFuelPower();
+ if (tileentitybrewingstand.fuel > 0 && event.isConsuming()) {
+ itemstack.subtract(1);
+ itemstack.shrink(1);
+ }
+ // CraftBukkit end
a(world, blockposition, iblockdata);
setChanged(world, blockposition, iblockdata);
}
@@ -118,12 +172,17 @@
@@ -95,24 +95,24 @@
+ // CraftBukkit end
if (flag2 && flag) {
- a(world, blockposition, tileentitybrewingstand.items);
+ a(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit
a(world, blockposition, iblockdata);
} else if (!flag || !itemstack1.a(tileentitybrewingstand.ingredient)) {
- doBrew(world, blockposition, tileentitybrewingstand.items);
+ doBrew(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit
setChanged(world, blockposition, iblockdata);
} else if (!flag || !itemstack1.is(tileentitybrewingstand.ingredient)) {
tileentitybrewingstand.brewTime = 0;
@@ -187,11 +246,33 @@
}
}
- private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) {
- private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) {
+ // CraftBukkit start
+ private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) {
+ private static void doBrew(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) {
ItemStack itemstack = (ItemStack) nonnulllist.get(3);
+ InventoryHolder owner = tileentitybrewingstand.getOwner();
+
+ List<org.bukkit.inventory.ItemStack> brewResults = new ArrayList<>(3);
+
+ for (int i = 0; i < 3; ++i) {
+ brewResults.add(i, CraftItemStack.asCraftMirror(PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i))));
+ brewResults.add(i, CraftItemStack.asCraftMirror(PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i))));
+ }
+
+ if (owner != null) {
@@ -125,7 +125,7 @@
+ // CraftBukkit end
for (int i = 0; i < 3; ++i) {
- nonnulllist.set(i, PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i)));
- nonnulllist.set(i, PotionBrewer.mix(itemstack, (ItemStack) nonnulllist.get(i)));
+ // CraftBukkit start - validate index in case it is cleared by plugins
+ if (i < brewResults.size()) {
+ nonnulllist.set(i, CraftItemStack.asNMSCopy(brewResults.get(i)));
@@ -135,4 +135,4 @@
+ // CraftBukkit end
}
itemstack.subtract(1);
itemstack.shrink(1);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCampfire.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCampfire.java
@@ -21,6 +21,12 @@
@@ -20,6 +20,12 @@
import net.minecraft.world.level.block.BlockCampfire;
import net.minecraft.world.level.block.state.IBlockData;
@@ -13,8 +13,8 @@
public class TileEntityCampfire extends TileEntity implements Clearable {
private static final int BURN_COOL_SPEED = 2;
@@ -52,6 +58,20 @@
return recipecampfire.a(inventorysubcontainer);
@@ -51,6 +57,20 @@
return recipecampfire.assemble(inventorysubcontainer);
}).orElse(itemstack);
+ // CraftBukkit start - fire BlockCookEvent
@@ -31,6 +31,6 @@
+ result = blockCookEvent.getResult();
+ itemstack1 = CraftItemStack.asNMSCopy(result);
+ // CraftBukkit end
InventoryUtils.dropItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
InventoryUtils.dropItemStack(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
world.notify(blockposition, iblockdata, iblockdata, 3);
world.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);

View File

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

View File

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

View File

@@ -12,25 +12,25 @@
public class TileEntityConduit extends TileEntity {
private static final int BLOCK_REFRESH_RATE = 2;
@@ -205,7 +210,7 @@
@@ -203,7 +208,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (blockposition.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) {
if (blockposition.closerThan((BaseBlockPosition) entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
- entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+ entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
}
}
@@ -234,8 +239,13 @@
@@ -232,8 +237,13 @@
}
if (tileentityconduit.destroyTarget != null) {
- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.locX(), tileentityconduit.destroyTarget.locY(), tileentityconduit.destroyTarget.locZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- tileentityconduit.destroyTarget.damageEntity(DamageSource.MAGIC, 4.0F);
- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F);
+ // CraftBukkit start
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition);
+ if (tileentityconduit.destroyTarget.damageEntity(DamageSource.MAGIC, 4.0F)) {
+ world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.locX(), tileentityconduit.destroyTarget.locY(), tileentityconduit.destroyTarget.locZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ if (tileentityconduit.destroyTarget.hurt(DamageSource.MAGIC, 4.0F)) {
+ world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ }
+ CraftEventFactory.blockDamage = null;
+ // CraftBukkit end

View File

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

View File

@@ -1,12 +1,11 @@
--- a/net/minecraft/world/level/block/entity/TileEntityDispenser.java
+++ b/net/minecraft/world/level/block/entity/TileEntityDispenser.java
@@ -14,12 +14,49 @@
@@ -14,12 +14,48 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import java.util.List;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
@@ -49,4 +48,4 @@
+
protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.a(9, ItemStack.EMPTY);
this.items = NonNullList.withSize(9, ItemStack.EMPTY);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
+++ b/net/minecraft/world/level/block/entity/TileEntityEndGateway.java
@@ -32,6 +32,14 @@
@@ -31,6 +31,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,16 +15,16 @@
public class TileEntityEndGateway extends TileEntityEnderPortal {
private static final Logger LOGGER = LogManager.getLogger();
@@ -170,7 +178,7 @@
@@ -167,7 +175,7 @@
tileentityendgateway.teleportCooldown = 100;
BlockPosition blockposition1;
- if (tileentityendgateway.exitPortal == null && world.getDimensionKey() == World.END) {
- if (tileentityendgateway.exitPortal == null && world.dimension() == World.END) {
+ if (tileentityendgateway.exitPortal == null && world.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit - work in alternate worlds
blockposition1 = a(worldserver, blockposition);
blockposition1 = blockposition1.up(10);
blockposition1 = findOrCreateValidTeleportPos(worldserver, blockposition);
blockposition1 = blockposition1.above(10);
TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1);
@@ -199,6 +207,27 @@
@@ -196,6 +204,27 @@
entity1 = entity.getRootVehicle();
}
@@ -41,23 +41,14 @@
+ return;
+ }
+
+ entity1.resetPortalCooldown();
+ entity1.setPortalCooldown();
+ ((EntityPlayer) entity1).connection.teleport(teleEvent.getTo());
+ c(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method
+ triggerCooldown(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method
+ return;
+
+ }
+ // CraftBukkit end
+
entity1.resetPortalCooldown();
entity1.enderTeleportAndLoad((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D);
entity1.setPortalCooldown();
entity1.teleportToWithTicket((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D);
}
@@ -310,7 +339,7 @@
}
private static void a(WorldServer worldserver, BlockPosition blockposition, WorldGenEndGatewayConfiguration worldgenendgatewayconfiguration) {
- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) worldgenendgatewayconfiguration).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition);
+ WorldGenerator.END_GATEWAY.b(worldgenendgatewayconfiguration).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error
}
@Override

View File

@@ -55,23 +55,23 @@
+ }
+ // CraftBukkit end
+
private static boolean b(Item item) {
return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item);
private static boolean isNeverAFurnaceFuel(Item item) {
return TagsItem.NON_FLAMMABLE_WOOD.contains(item);
}
@@ -266,13 +310,24 @@
tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, 0, tileentityfurnace.cookingTotalTime);
@@ -265,13 +309,24 @@
tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, (int) 0, tileentityfurnace.cookingTotalTime);
}
} else {
- IRecipe<?> irecipe = (IRecipe) world.getCraftingManager().craft(tileentityfurnace.recipeType, tileentityfurnace, world).orElse((Object) null);
+ IRecipe<?> irecipe = (IRecipe) world.getCraftingManager().craft((Recipes<RecipeCooking>) tileentityfurnace.recipeType, tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail
- IRecipe<?> irecipe = (IRecipe) world.getRecipeManager().getRecipeFor(tileentityfurnace.recipeType, tileentityfurnace, world).orElse((Object) null);
+ IRecipe<?> irecipe = (IRecipe) world.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) tileentityfurnace.recipeType, tileentityfurnace, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail
int i = tileentityfurnace.getMaxStackSize();
if (!tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.fuelTime(itemstack);
if (!tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.getBurnDuration(itemstack);
+ // CraftBukkit start
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
+
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.fuelTime(itemstack));
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.getBurnDuration(itemstack));
+ world.getCraftServer().getPluginManager().callEvent(furnaceBurnEvent);
+
+ if (furnaceBurnEvent.isCancelled()) {
@@ -80,16 +80,16 @@
+
+ tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime();
tileentityfurnace.litDuration = tileentityfurnace.litTime;
- if (tileentityfurnace.isBurning()) {
+ if (tileentityfurnace.isBurning() && furnaceBurnEvent.isBurning()) {
- if (tileentityfurnace.isLit()) {
+ if (tileentityfurnace.isLit() && furnaceBurnEvent.isBurning()) {
+ // CraftBukkit end
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
@@ -288,11 +343,23 @@
@@ -287,11 +342,23 @@
}
if (tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) {
if (tileentityfurnace.isLit() && canBurn(irecipe, tileentityfurnace.items, i)) {
+ // CraftBukkit start
+ if (irecipe != null && tileentityfurnace.cookingProgress == 0) {
+ CraftItemStack source = CraftItemStack.asCraftMirror(tileentityfurnace.items.get(0));
@@ -105,13 +105,13 @@
++tileentityfurnace.cookingProgress;
if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) {
tileentityfurnace.cookingProgress = 0;
tileentityfurnace.cookingTotalTime = getRecipeCookingTime(world, tileentityfurnace.recipeType, tileentityfurnace);
tileentityfurnace.cookingTotalTime = getTotalCookTime(world, tileentityfurnace.recipeType, tileentityfurnace);
- if (burn(irecipe, tileentityfurnace.items, i)) {
+ if (burn(tileentityfurnace.level, tileentityfurnace.worldPosition, irecipe, tileentityfurnace.items, i)) { // CraftBukkit
tileentityfurnace.setRecipeUsed(irecipe);
}
@@ -331,17 +398,44 @@
@@ -330,17 +397,44 @@
}
}
@@ -119,7 +119,7 @@
+ private static boolean burn(World world, BlockPosition blockposition, @Nullable IRecipe<?> irecipe, NonNullList<ItemStack> nonnulllist, int i) { // CraftBukkit
if (irecipe != null && canBurn(irecipe, nonnulllist, i)) {
ItemStack itemstack = (ItemStack) nonnulllist.get(0);
ItemStack itemstack1 = irecipe.getResult();
ItemStack itemstack1 = irecipe.getResultItem();
ItemStack itemstack2 = (ItemStack) nonnulllist.get(2);
+ // CraftBukkit start - fire FurnaceSmeltEvent
@@ -138,9 +138,9 @@
+
+ if (!itemstack1.isEmpty()) {
+ if (itemstack2.isEmpty()) {
+ nonnulllist.set(2, itemstack1.cloneItemStack());
+ nonnulllist.set(2, itemstack1.copy());
+ } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) {
+ itemstack2.add(itemstack1.getCount());
+ itemstack2.grow(itemstack1.getCount());
+ } else {
+ return false;
+ }
@@ -148,65 +148,65 @@
+
+ /*
if (itemstack2.isEmpty()) {
nonnulllist.set(2, itemstack1.cloneItemStack());
} else if (itemstack2.a(itemstack1.getItem())) {
itemstack2.add(1);
nonnulllist.set(2, itemstack1.copy());
} else if (itemstack2.is(itemstack1.getItem())) {
itemstack2.grow(1);
}
+ */
+ // CraftBukkit end
if (itemstack.a(Blocks.WET_SPONGE.getItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).a(Items.BUCKET)) {
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));
@@ -365,7 +459,7 @@
@@ -364,7 +458,7 @@
}
private static int getRecipeCookingTime(World world, Recipes<? extends RecipeCooking> recipes, IInventory iinventory) {
- return (Integer) world.getCraftingManager().craft(recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200);
+ return (world != null) ? (Integer) world.getCraftingManager().craft((Recipes<RecipeCooking>) recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
private static int getTotalCookTime(World world, Recipes<? extends RecipeCooking> recipes, IInventory iinventory) {
- return (Integer) world.getRecipeManager().getRecipeFor(recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200);
+ return (world != null) ? (Integer) world.getRecipeManager().getRecipeFor((Recipes<RecipeCooking>) recipes, iinventory, world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
}
public static boolean isFuel(ItemStack itemstack) {
@@ -484,14 +578,20 @@
@@ -483,14 +577,20 @@
@Override
public void awardUsedRecipes(EntityHuman entityhuman) {}
- public void a(EntityPlayer entityplayer) {
- List<IRecipe<?>> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector());
+ public void a(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit
+ List<IRecipe<?>> list = this.a(entityplayer.getWorldServer(), entityplayer.getPositionVector(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit
- public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer) {
- List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position());
+ public void awardUsedRecipesAndPopExperience(EntityPlayer entityplayer, ItemStack itemstack, int amount) { // CraftBukkit
+ List<IRecipe<?>> list = this.getRecipesToAwardAndPopExperience(entityplayer.getLevel(), entityplayer.position(), this.worldPosition, entityplayer, itemstack, amount); // CraftBukkit
entityplayer.discoverRecipes(list);
entityplayer.awardRecipes(list);
this.recipesUsed.clear();
}
public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d) {
public List<IRecipe<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d) {
+ // CraftBukkit start
+ return this.a(worldserver, vec3d, this.worldPosition, null, null, 0);
+ return this.getRecipesToAwardAndPopExperience(worldserver, vec3d, this.worldPosition, null, null, 0);
+ }
+
+ public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) {
+ public List<IRecipe<?>> getRecipesToAwardAndPopExperience(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) {
+ // CraftBukkit end
List<IRecipe<?>> list = Lists.newArrayList();
ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator();
@@ -500,14 +600,14 @@
@@ -499,14 +599,14 @@
worldserver.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
worldserver.getRecipeManager().byKey((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
list.add(irecipe);
- a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience());
+ a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
- createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience());
+ createExperience(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
});
}
return list;
}
- private static void a(WorldServer worldserver, Vec3D vec3d, int i, float f) {
+ private static void a(WorldServer worldserver, Vec3D vec3d, int i, float f, BlockPosition blockposition, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
int j = MathHelper.d((float) i * f);
float f1 = MathHelper.h((float) i * f);
- private static void createExperience(WorldServer worldserver, Vec3D vec3d, int i, float f) {
+ private static void createExperience(WorldServer worldserver, Vec3D vec3d, int i, float f, BlockPosition blockposition, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
int j = MathHelper.floor((float) i * f);
float f1 = MathHelper.frac((float) i * f);
@@ -515,6 +615,17 @@
@@ -514,6 +614,17 @@
++j;
}
@@ -221,6 +221,6 @@
+ j = event.getExpToDrop();
+ // CraftBukkit end
+
EntityExperienceOrb.a(worldserver, vec3d, j);
EntityExperienceOrb.award(worldserver, vec3d, j);
}

View File

@@ -55,34 +55,34 @@
+
public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.HOPPER, blockposition, iblockdata);
this.items = NonNullList.a(5, ItemStack.EMPTY);
@@ -115,7 +157,7 @@
this.items = NonNullList.withSize(5, ItemStack.EMPTY);
@@ -114,7 +156,7 @@
boolean flag = false;
if (!tileentityhopper.isEmpty()) {
- flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper);
+ flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit
- flag = ejectItems(world, blockposition, iblockdata, tileentityhopper);
+ flag = ejectItems(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit
}
if (!tileentityhopper.i()) {
@@ -149,7 +191,7 @@
if (!tileentityhopper.inventoryFull()) {
@@ -148,7 +190,7 @@
return false;
}
- private static boolean a(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory) {
+ private static boolean a(World world, BlockPosition blockposition, IBlockData iblockdata, IInventory iinventory, TileEntityHopper hopper) { // CraftBukkit
IInventory iinventory1 = b(world, blockposition, iblockdata);
- 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) {
@@ -163,7 +205,28 @@
for (int i = 0; i < iinventory.getSize(); ++i) {
@@ -162,7 +204,28 @@
for (int i = 0; i < iinventory.getContainerSize(); ++i) {
if (!iinventory.getItem(i).isEmpty()) {
ItemStack itemstack = iinventory.getItem(i).cloneItemStack();
- ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.splitStack(i, 1), enumdirection);
+ // ItemStack itemstack1 = addItem(iinventory, iinventory1, iinventory.splitStack(i, 1), enumdirection);
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);
+
+ // CraftBukkit start - Call event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1));
+
+ Inventory destinationInventory;
+ // Have to special case large chests as they work oddly
@@ -103,15 +103,15 @@
+ // CraftBukkit end
if (itemstack1.isEmpty()) {
iinventory1.update();
@@ -228,7 +291,34 @@
iinventory1.setChanged();
@@ -227,7 +290,34 @@
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
ItemStack itemstack1 = itemstack.cloneItemStack();
- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
if (!itemstack.isEmpty() && canTakeItemFromContainer(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);
+ // CraftBukkit start - Call event on collection of items from inventories into the hopper
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, 1));
+
+ Inventory sourceInventory;
+ // Have to special case large chests as they work oddly
@@ -139,10 +139,10 @@
+ // CraftBukkit end
if (itemstack2.isEmpty()) {
iinventory.update();
@@ -243,6 +333,13 @@
iinventory.setChanged();
@@ -242,6 +332,13 @@
public static boolean a(IInventory iinventory, EntityItem entityitem) {
public static boolean addItem(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
+ // CraftBukkit start
+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
@@ -151,6 +151,6 @@
+ return false;
+ }
+ // CraftBukkit end
ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
ItemStack itemstack = entityitem.getItem().copy();
ItemStack itemstack1 = addItem((IInventory) null, iinventory, itemstack, (EnumDirection) null);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityLectern.java
+++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java
@@ -27,13 +27,71 @@
@@ -26,13 +26,71 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@@ -72,9 +72,9 @@
+ // CraftBukkit end
+
@Override
public int getSize() {
public int getContainerSize() {
return 1;
@@ -78,11 +136,20 @@
@@ -77,11 +135,20 @@
}
@Override
@@ -83,8 +83,8 @@
+ public void setItem(int i, ItemStack itemstack) {
+ if (i == 0) {
+ TileEntityLectern.this.setBook(itemstack);
+ if (TileEntityLectern.this.getWorld() != null) {
+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook());
+ if (TileEntityLectern.this.getLevel() != null) {
+ BlockLectern.resetBookState(TileEntityLectern.this.getLevel(), TileEntityLectern.this.getBlockPos(), TileEntityLectern.this.getBlockState(), TileEntityLectern.this.hasBook());
+ }
+ }
+ }
@@ -97,16 +97,16 @@
}
@Override
@@ -162,7 +229,7 @@
@@ -161,7 +228,7 @@
if (j != this.page) {
this.page = j;
this.update();
- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock());
+ if (this.level != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
this.setChanged();
- BlockLectern.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState());
+ if (this.level != null) BlockLectern.signalPageChange(this.getLevel(), this.getBlockPos(), this.getBlockState()); // CraftBukkit
}
}
@@ -185,6 +252,32 @@
@@ -184,6 +251,32 @@
return itemstack;
}
@@ -121,35 +121,35 @@
+ }
+
+ @Override
+ public boolean shouldSendSuccess() {
+ public boolean acceptsSuccess() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldSendFailure() {
+ public boolean acceptsFailure() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldBroadcastCommands() {
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+
+ // CraftBukkit end
private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) {
private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) {
String s;
Object object;
@@ -199,7 +292,8 @@
@@ -198,7 +291,8 @@
Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.worldPosition);
Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition);
- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman);
- 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.getMinecraftServer(), entityhuman);
+ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityhuman);
}
@Override
@@ -238,7 +332,7 @@
@@ -236,7 +330,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {

View File

@@ -49,20 +49,20 @@
+
public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata);
this.itemStacks = NonNullList.a(27, ItemStack.EMPTY);
this.itemStacks = NonNullList.withSize(27, ItemStack.EMPTY);
@@ -163,6 +199,7 @@
}
++this.openCount;
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount);
this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount);
if (this.openCount == 1) {
this.level.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition);
this.level.gameEvent(entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition);
@@ -176,6 +213,7 @@
public void closeContainer(EntityHuman entityhuman) {
public void stopOpen(EntityHuman entityhuman) {
if (!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.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount);
this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount);
if (this.openCount <= 0) {
this.level.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition);
this.level.gameEvent(entityhuman, 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
@@ -25,7 +25,7 @@
@@ -24,7 +24,7 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@@ -9,22 +9,22 @@
public static final int LINES = 4;
private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"};
@@ -65,6 +65,12 @@
@@ -64,6 +64,12 @@
}
}
+ // CraftBukkit start
+ if (Boolean.getBoolean("convertLegacySigns")) {
+ nbttagcompound.setBoolean("Bukkit.isConverted", true);
+ nbttagcompound.putBoolean("Bukkit.isConverted", true);
+ }
+ // CraftBukkit end
+
nbttagcompound.setString("Color", this.color.b());
nbttagcompound.setBoolean("GlowingText", this.hasGlowingText);
return nbttagcompound;
@@ -76,8 +82,24 @@
nbttagcompound.putString("Color", this.color.getName());
nbttagcompound.putBoolean("GlowingText", this.hasGlowingText);
}
@@ -74,8 +80,24 @@
super.load(nbttagcompound);
this.color = EnumColor.a(nbttagcompound.getString("Color"), EnumColor.BLACK);
this.color = EnumColor.byName(nbttagcompound.getString("Color"), EnumColor.BLACK);
+ // CraftBukkit start - Add an option to convert signs correctly
+ // This is done with a flag instead of all the time because
@@ -44,10 +44,10 @@
+ continue;
+ }
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = this.a(s);
IChatBaseComponent ichatbasecomponent = this.loadLine(s);
this.messages[i] = ichatbasecomponent;
@@ -115,6 +137,10 @@
@@ -113,6 +135,10 @@
if (ichatmutablecomponent != null) {
return ichatmutablecomponent;
}
@@ -58,7 +58,7 @@
} catch (Exception exception) {
;
}
@@ -207,11 +233,37 @@
@@ -204,11 +230,37 @@
return true;
}
@@ -72,36 +72,36 @@
+ }
+
+ @Override
+ public boolean shouldSendSuccess() {
+ public boolean acceptsSuccess() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldSendFailure() {
+ public boolean acceptsFailure() {
+ return false;
+ }
+
+ @Override
+ public boolean shouldBroadcastCommands() {
+ public boolean shouldInformAdmins() {
+ return false;
+ }
+ // CraftBukkit end
+
public CommandListenerWrapper b(@Nullable EntityPlayer entityplayer) {
String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString();
Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName();
public CommandListenerWrapper createCommandSourceStack(@Nullable EntityPlayer entityplayer) {
String s = entityplayer == null ? "Sign" : entityplayer.getName().getString();
Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getDisplayName();
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer);
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer);
+ return new CommandListenerWrapper(this, Vec3D.atCenterOf(this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getServer(), entityplayer);
}
public EnumColor getColor() {
@@ -244,6 +296,6 @@
@@ -241,6 +293,6 @@
private void i() {
this.update();
- this.level.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3);
+ if (this.level != null) this.level.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122)
private void markUpdated() {
this.setChanged();
- this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
+ if (this.level != null) this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122)
}
}