Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -0,0 +1,58 @@
--- a/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
+++ b/net/minecraft/world/level/block/entity/ContainerOpenersCounter.java
@@ -13,6 +13,7 @@
private static final int CHECK_TICK_DELAY = 5;
private int openCount;
+ public boolean opened; // CraftBukkit
public ContainerOpenersCounter() {}
@@ -25,8 +26,19 @@
protected abstract boolean a(EntityHuman entityhuman);
public void a(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)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
+
if (i == 0) {
this.a(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, blockposition);
@@ -37,8 +49,19 @@
}
public void b(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)) {
+ int newPower = Math.max(0, Math.min(15, this.openCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
+
if (this.openCount == 0) {
this.b(world, blockposition, iblockdata);
world.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, blockposition);
@@ -59,6 +82,7 @@
public void c(World world, BlockPosition blockposition, IBlockData iblockdata) {
int i = this.a(world, blockposition);
+ if (opened) i++; // CraftBukkit - add dummy count from API
int j = this.openCount;
if (j != i) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/level/block/entity/TileEntity.java
+++ b/net/minecraft/world/level/block/entity/TileEntity.java
@@ -15,8 +15,18 @@
@@ -12,8 +12,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Supplier;
+// CraftBukkit start
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
@@ -17,27 +17,30 @@
+ public CraftPersistentDataContainer persistentDataContainer;
+ // CraftBukkit end
private static final Logger LOGGER = LogManager.getLogger();
private final TileEntityTypes<?> tileType;
private final TileEntityTypes<?> type;
@Nullable
@@ -48,6 +58,14 @@
@@ -41,7 +51,16 @@
return this.level != null;
}
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
+ // CraftBukkit start - read container
- public void load(NBTTagCompound nbttagcompound) {}
+ // CraftBukkit start - read container
+ public void load(NBTTagCompound nbttagcompound) {
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
+
+ net.minecraft.nbt.NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues");
+ if (persistentDataTag instanceof NBTTagCompound) {
+ this.persistentDataContainer.putAll((NBTTagCompound) persistentDataTag);
+ }
+ // CraftBukkit end
}
+ }
+ // CraftBukkit end
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
@@ -64,6 +82,11 @@
nbttagcompound.setInt("x", this.position.getX());
nbttagcompound.setInt("y", this.position.getY());
nbttagcompound.setInt("z", this.position.getZ());
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());
@@ -46,15 +49,15 @@
return nbttagcompound;
}
}
@@ -179,4 +202,13 @@
}, this::getPosition});
}
@@ -164,4 +188,13 @@
public void b(IBlockData iblockdata) {
this.blockState = iblockdata;
}
+
+ // CraftBukkit start - add method
+ public InventoryHolder getOwner() {
+ if (world == null) return null;
+ org.bukkit.block.BlockState state = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState();
+ if (level == null) return null;
+ org.bukkit.block.BlockState state = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()).getState();
+ if (state instanceof InventoryHolder) return (InventoryHolder) state;
+ return null;
+ }

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBanner.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBanner.java
@@ -80,6 +80,11 @@
@@ -99,6 +99,11 @@
}
this.patterns = nbttagcompound.getList("Patterns", 10);
this.itemPatterns = nbttagcompound.getList("Patterns", 10);
+ // CraftBukkit start
+ while (this.patterns.size() > 20) {
+ this.patterns.remove(20);
+ while (this.itemPatterns.size() > 20) {
+ this.itemPatterns.remove(20);
+ }
+ // CraftBukkit end
this.h = null;
this.g = true;
this.patterns = null;
this.receivedData = true;
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBarrel.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBarrel.java
@@ -19,8 +19,50 @@
import net.minecraft.world.level.block.Blocks;
@@ -21,8 +21,49 @@
import net.minecraft.world.level.block.BlockBarrel;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
@@ -16,7 +16,6 @@
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new ArrayList<>();
+ private int maxStack = MAX_STACK;
+ public boolean opened;
+
+ @Override
+ public List<ItemStack> getContents() {
@@ -49,14 +48,5 @@
+ }
+ // CraftBukkit end
private NonNullList<ItemStack> items;
private int b;
public ContainerOpenersCounter openersCounter;
@@ -119,7 +161,7 @@
return;
}
- boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN);
+ boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API.
if (flag) {
this.playOpenSound(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeacon.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeacon.java
@@ -38,6 +38,11 @@
@@ -40,6 +40,11 @@
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.phys.AxisAlignedBB;
@@ -9,38 +9,38 @@
+import org.bukkit.potion.PotionEffect;
+// CraftBukkit end
+
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
public class TileEntityBeacon extends TileEntity implements ITileInventory {
public static final MobEffectList[][] a = new MobEffectList[][]{{MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, {MobEffects.RESISTANCE, MobEffects.JUMP}, {MobEffects.INCREASE_DAMAGE}, {MobEffects.REGENERATION}};
@@ -54,6 +59,15 @@
public IChatBaseComponent customName;
public ChestLock chestLock;
private final IContainerProperties containerProperties;
private static final int MAX_LEVELS = 4;
@@ -62,6 +67,15 @@
public IChatBaseComponent name;
public ChestLock lockKey;
private final IContainerProperties dataAccess;
+ // CraftBukkit start - add fields and methods
+ public PotionEffect getPrimaryEffect() {
+ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null;
+ return (this.primaryPower != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null;
+ }
+
+ public PotionEffect getSecondaryEffect() {
+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null;
+ return (hasSecondaryEffect(levels, primaryPower, secondaryPower)) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryPower, getLevel(this.levels), getAmplification(levels, primaryPower, secondaryPower), true, true)) : null;
+ }
+ // CraftBukkit end
public TileEntityBeacon() {
super(TileEntityTypes.BEACON);
@@ -222,39 +236,78 @@
super.al_();
public TileEntityBeacon(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEACON, blockposition, iblockdata);
@@ -230,39 +244,78 @@
super.aa_();
}
- private void applyEffects() {
- if (!this.world.isClientSide && this.primaryEffect != null) {
- double d0 = (double) (this.levels * 10 + 10);
- private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
- if (!world.isClientSide && mobeffectlist != null) {
- double d0 = (double) (i * 10 + 10);
+ // CraftBukkit start - split into components
+ private byte getAmplification() {
+ private static byte getAmplification(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ {
byte b0 = 0;
if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) {
if (i >= 4 && mobeffectlist == mobeffectlist1) {
b0 = 1;
}
@@ -48,25 +48,25 @@
+ }
+ }
+
+ private int getLevel() {
+ private static int getLevel(int i) {
+ {
int i = (9 + this.levels * 2) * 20;
+ return i;
int j = (9 + i * 2) * 20;
+ return j;
+ }
+ }
+
+ public List getHumansInRange() {
+ public static List getHumansInRange(World world, BlockPosition blockposition, int i) {
+ {
+ double d0 = (double) (this.levels * 10 + 10);
+ double d0 = (double) (i * 10 + 10);
+
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getBuildHeight(), 0.0D);
List<EntityHuman> list = this.world.a(EntityHuman.class, axisalignedbb);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition)).g(d0).b(0.0D, (double) world.getHeight(), 0.0D);
List<EntityHuman> list = world.a(EntityHuman.class, axisalignedbb);
+
+ return list;
+ }
+ }
+
+ private void applyEffect(List list, MobEffectList effects, int i, int b0) {
+ private static void applyEffect(List list, MobEffectList mobeffectlist, int j, int b0) {
+ {
Iterator iterator = list.iterator();
@@ -74,20 +74,20 @@
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.primaryEffect, i, b0, true, true));
+ entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
- 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);
}
+ }
+ }
+ private boolean hasSecondaryEffect() {
+ private static boolean hasSecondaryEffect(int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ {
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) {
if (i >= 4 && mobeffectlist != mobeffectlist1 && mobeffectlist1 != null) {
- iterator = list.iterator();
-
- while (iterator.hasNext()) {
- entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true));
- entityhuman.addEffect(new MobEffect(mobeffectlist1, j, 0, true, true));
- }
+ return true;
}
@@ -96,38 +96,38 @@
}
}
+ private void applyEffects() {
+ if (!this.world.isClientSide && this.primaryEffect != null) {
+ double d0 = (double) (this.levels * 10 + 10);
+ byte b0 = getAmplification();
+ private static void applyEffects(World world, BlockPosition blockposition, int i, @Nullable MobEffectList mobeffectlist, @Nullable MobEffectList mobeffectlist1) {
+ if (!world.isClientSide && mobeffectlist != null) {
+ double d0 = (double) (i * 10 + 10);
+ byte b0 = getAmplification(i, mobeffectlist, mobeffectlist1);
+
+ int i = getLevel();
+ List list = getHumansInRange();
+ int j = getLevel(i);
+ List list = getHumansInRange(world, blockposition, i);
+
+ applyEffect(list, this.primaryEffect, i, b0);
+ applyEffect(list, mobeffectlist, j, b0);
+
+ if (hasSecondaryEffect()) {
+ applyEffect(list, this.secondaryEffect, i, 0);
+ if (hasSecondaryEffect(i, mobeffectlist, mobeffectlist1)) {
+ applyEffect(list, mobeffectlist1, j, 0);
+ }
+ }
+
+ }
+ // CraftBukkit end
+
public void a(SoundEffect soundeffect) {
this.world.playSound((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
public static void a(World world, BlockPosition blockposition, SoundEffect soundeffect) {
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
@@ -284,8 +337,11 @@
@@ -292,8 +345,11 @@
@Override
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
super.load(iblockdata, nbttagcompound);
- this.primaryEffect = b(nbttagcompound.getInt("Primary"));
- this.secondaryEffect = b(nbttagcompound.getInt("Secondary"));
public void load(NBTTagCompound nbttagcompound) {
super.load(nbttagcompound);
- this.primaryPower = a(nbttagcompound.getInt("Primary"));
- this.secondaryPower = a(nbttagcompound.getInt("Secondary"));
+ // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
+ this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
+ this.primaryPower = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
+ this.secondaryPower = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
+ this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available
+ // CraftBukkit end
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
this.name = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
}

View File

@@ -1,23 +1,23 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBeehive.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBeehive.java
@@ -29,6 +29,7 @@
private final List<TileEntityBeehive.HiveBee> bees = Lists.newArrayList();
@@ -43,6 +43,7 @@
private final List<TileEntityBeehive.HiveBee> stored = Lists.newArrayList();
@Nullable
public BlockPosition flowerPos = null;
public BlockPosition savedFlowerPos;
+ public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold
public TileEntityBeehive() {
super(TileEntityTypes.BEEHIVE);
@@ -68,7 +69,7 @@
public TileEntityBeehive(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BEEHIVE, blockposition, iblockdata);
@@ -82,7 +83,7 @@
}
public boolean isFull() {
- return this.bees.size() == 3;
+ return this.bees.size() == this.maxBees; // CraftBukkit
- return this.stored.size() == 3;
+ return this.stored.size() == this.maxBees; // CraftBukkit
}
public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -85,7 +86,7 @@
@@ -99,7 +100,7 @@
if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) {
if (!this.isSedated()) {
@@ -26,7 +26,7 @@
} else {
entitybee.setCannotEnterHiveTicks(400);
}
@@ -97,10 +98,16 @@
@@ -111,10 +112,16 @@
}
private List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
@@ -37,22 +37,22 @@
+ public List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
List<Entity> list = Lists.newArrayList();
this.bees.removeIf((tileentitybeehive_hivebee) -> {
- return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus);
+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, force);
this.stored.removeIf((tileentitybeehive_hivebee) -> {
- return releaseBee(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
});
return list;
}
@@ -126,7 +133,19 @@
@@ -138,7 +145,19 @@
}
public void a(Entity entity, boolean flag, int i) {
- if (this.bees.size() < 3) {
+ if (this.bees.size() < this.maxBees) { // CraftBukkit
- if (this.stored.size() < 3) {
+ if (this.stored.size() < this.maxBees) { // CraftBukkit
+ // CraftBukkit start
+ if (this.world != null) {
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, getPosition()));
+ 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.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (entity instanceof EntityBee) {
@@ -65,22 +65,22 @@
entity.stopRiding();
entity.ejectPassengers();
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -152,7 +171,13 @@
@@ -168,7 +187,13 @@
}
private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
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) {
- if ((world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
+ return releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false);
+ return releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, blockposition1, false);
+ }
+
+ private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
+ if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ 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) {
+ if (!force && (world.isNight() || world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
+ // CraftBukkit end
return false;
} else {
BlockPosition blockposition = this.getPosition();
@@ -176,6 +201,18 @@
NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData;
@@ -191,6 +216,18 @@
if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) {
return false;
} else {
@@ -92,14 +92,14 @@
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F);
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
+
+ entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
+ entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ }
+ if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
+ if (!world.addEntity(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;
@@ -205,6 +242,7 @@
@@ -220,6 +257,7 @@
list.add(entitybee);
}
@@ -107,22 +107,22 @@
float f = entity.getWidth();
double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
@@ -212,10 +250,11 @@
@@ -227,10 +265,11 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
entity.setPositionRotation(d1, d2, d3, entity.getYRot(), entity.getXRot());
+ */ // CraftBukkit end
}
this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
- return this.world.addEntity(entity);
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
}
} else {
return false;
@@ -253,6 +292,10 @@
@@ -276,6 +315,10 @@
if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) {
if (releaseBee(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
iterator.remove();
+ // CraftBukkit start
+ } else {
@@ -131,8 +131,8 @@
}
}
}
@@ -295,6 +338,11 @@
this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
@@ -313,6 +356,11 @@
this.savedFlowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
}
+ // CraftBukkit start
@@ -143,9 +143,9 @@
}
@Override
@@ -304,6 +352,7 @@
if (this.x()) {
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos));
@@ -322,6 +370,7 @@
if (this.s()) {
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.savedFlowerPos));
}
+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityBrewingStand.java
@@ -24,6 +24,17 @@
@@ -25,6 +25,18 @@
import net.minecraft.world.level.block.BlockBrewingStand;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import java.util.List;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
@@ -15,13 +16,13 @@
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable {
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory {
private static final int[] b = new int[]{3};
@@ -35,6 +46,36 @@
private Item k;
public int fuelLevel;
protected final IContainerProperties a;
private static final int INGREDIENT_SLOT = 3;
@@ -42,6 +54,36 @@
private Item ingredient;
public int fuel;
protected final IContainerProperties dataAccess;
+ // CraftBukkit start - add fields and methods
+ private int lastTick = MinecraftServer.currentTick;
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -53,55 +54,62 @@
+ }
+ // CraftBukkit end
public TileEntityBrewingStand() {
super(TileEntityTypes.BREWING_STAND);
@@ -103,8 +144,19 @@
ItemStack itemstack = (ItemStack) this.items.get(4);
public TileEntityBrewingStand(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.BREWING_STAND, blockposition, iblockdata);
@@ -109,8 +151,19 @@
ItemStack itemstack = (ItemStack) tileentitybrewingstand.items.get(4);
if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) {
- this.fuelLevel = 20;
if (tileentitybrewingstand.fuel <= 0 && itemstack.a(Items.BLAZE_POWDER)) {
- tileentitybrewingstand.fuel = 20;
- itemstack.subtract(1);
+ // CraftBukkit start
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), CraftItemStack.asCraftMirror(itemstack), 20);
+ this.world.getServer().getPluginManager().callEvent(event);
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(CraftBlock.at(world, blockposition), CraftItemStack.asCraftMirror(itemstack), 20);
+ world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+
+ this.fuelLevel = event.getFuelPower();
+ if (this.fuelLevel > 0 && event.isConsuming()) {
+ tileentitybrewingstand.fuel = event.getFuelPower();
+ if (tileentitybrewingstand.fuel > 0 && event.isConsuming()) {
+ itemstack.subtract(1);
+ }
+ // CraftBukkit end
this.update();
a(world, blockposition, iblockdata);
}
@@ -112,9 +164,14 @@
boolean flag1 = this.brewTime > 0;
ItemStack itemstack1 = (ItemStack) this.items.get(3);
@@ -118,12 +171,17 @@
boolean flag1 = tileentitybrewingstand.brewTime > 0;
ItemStack itemstack1 = (ItemStack) tileentitybrewingstand.items.get(3);
+ // CraftBukkit start - Use wall time instead of ticks for brewing
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ int elapsedTicks = MinecraftServer.currentTick - tileentitybrewingstand.lastTick;
+ tileentitybrewingstand.lastTick = MinecraftServer.currentTick;
+
if (flag1) {
- --this.brewTime;
- boolean flag2 = this.brewTime == 0;
+ this.brewTime -= elapsedTicks;
+ boolean flag2 = this.brewTime <= 0; // == -> <=
- --tileentitybrewingstand.brewTime;
- boolean flag2 = tileentitybrewingstand.brewTime == 0;
+ tileentitybrewingstand.brewTime -= elapsedTicks;
+ boolean flag2 = tileentitybrewingstand.brewTime <= 0; // == -> <=
+ // CraftBukkit end
if (flag2 && flag) {
this.j();
@@ -188,6 +245,16 @@
- a(world, blockposition, tileentitybrewingstand.items);
+ a(world, blockposition, tileentitybrewingstand.items, tileentitybrewingstand); // CraftBukkit
a(world, blockposition, iblockdata);
} else if (!flag || !itemstack1.a(tileentitybrewingstand.ingredient)) {
tileentitybrewingstand.brewTime = 0;
@@ -187,8 +245,18 @@
}
}
private void j() {
ItemStack itemstack = (ItemStack) this.items.get(3);
+ // CraftBukkit start
+ InventoryHolder owner = this.getOwner();
- private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist) {
+ // CraftBukkit start
+ private static void a(World world, BlockPosition blockposition, NonNullList<ItemStack> nonnulllist, TileEntityBrewingStand tileentitybrewingstand) {
ItemStack itemstack = (ItemStack) nonnulllist.get(3);
+ InventoryHolder owner = tileentitybrewingstand.getOwner();
+ if (owner != null) {
+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), this.fuelLevel);
+ BrewEvent event = new BrewEvent(CraftBlock.at(world, blockposition), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), tileentitybrewingstand.fuel);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
@@ -110,4 +118,4 @@
+ // CraftBukkit end
for (int i = 0; i < 3; ++i) {
this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i)));
nonnulllist.set(i, PotionBrewer.d(itemstack, (ItemStack) nonnulllist.get(i)));

View File

@@ -10,19 +10,19 @@
+import org.bukkit.event.block.BlockCookEvent;
+// CraftBukkit end
+
public class TileEntityCampfire extends TileEntity implements Clearable, ITickable {
public class TileEntityCampfire extends TileEntity implements Clearable {
private final NonNullList<ItemStack> items;
@@ -72,6 +78,20 @@
private static final int BURN_COOL_SPEED = 2;
@@ -52,6 +58,20 @@
return recipecampfire.a(inventorysubcontainer);
}).orElse(itemstack);
BlockPosition blockposition = this.getPosition();
+ // CraftBukkit start - fire BlockCookEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.world, this.position), source, result);
+ this.world.getServer().getPluginManager().callEvent(blockCookEvent);
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(world, blockposition), source, result);
+ world.getServer().getPluginManager().callEvent(blockCookEvent);
+
+ if (blockCookEvent.isCancelled()) {
+ return;
@@ -31,6 +31,6 @@
+ result = blockCookEvent.getResult();
+ itemstack1 = CraftItemStack.asNMSCopy(result);
+ // CraftBukkit end
InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
this.items.set(i, ItemStack.b);
this.k();
InventoryUtils.dropItem(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
tileentitycampfire.items.set(i, ItemStack.EMPTY);
world.notify(blockposition, iblockdata, iblockdata, 3);

View File

@@ -1,26 +1,25 @@
--- a/net/minecraft/world/level/block/entity/TileEntityChest.java
+++ b/net/minecraft/world/level/block/entity/TileEntityChest.java
@@ -27,6 +27,12 @@
@@ -24,6 +24,12 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.properties.BlockPropertyChestType;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.world.level.block.Blocks;
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityChest extends TileEntityLootable implements ITickable {
public class TileEntityChest extends TileEntityLootable implements LidBlockEntity {
private NonNullList<ItemStack> items;
@@ -35,6 +41,37 @@
public int viewingCount;
private int j;
private static final int EVENT_SET_OPEN_COUNT = 1;
@@ -31,6 +37,36 @@
public final ContainerOpenersCounter openersCounter;
private final ChestLidController chestLidController;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+ public boolean opened;
+
+ public List<ItemStack> getContents() {
+ return this.items;
@@ -48,75 +47,12 @@
+ }
+ // CraftBukkit end
+
protected TileEntityChest(TileEntityTypes<?> tileentitytypes) {
super(tileentitytypes);
this.items = NonNullList.a(27, ItemStack.b);
@@ -85,6 +122,13 @@
this.b = this.a;
float f = 0.1F;
protected TileEntityChest(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.a(27, ItemStack.EMPTY);
@@ -200,4 +236,11 @@
+ // CraftBukkit start - If chest is forced open by API, remove a viewer due to playBlockAction() call and don't tick to prevent sound effects.
+ if (opened) {
+ this.viewingCount--;
+ return;
+ }
+ // CraftBukkit end
+
if (this.viewingCount > 0 && this.a == 0.0F) {
this.playOpenSound(SoundEffects.BLOCK_CHEST_OPEN);
}
@@ -179,8 +223,20 @@
if (this.viewingCount < 0) {
this.viewingCount = 0;
}
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
++this.viewingCount;
+ if (this.world == null) return; // CraftBukkit
+
+ // CraftBukkit start - Call redstone event
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
this.onOpen();
}
@@ -189,7 +245,18 @@
@Override
public void closeContainer(EntityHuman entityhuman) {
if (!entityhuman.isSpectator()) {
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
--this.viewingCount;
+
+ // CraftBukkit start - Call redstone event
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
+
+ if (oldPower != newPower) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
+ }
+ }
+ // CraftBukkit end
this.onOpen();
}
@@ -199,7 +266,7 @@
Block block = this.getBlock().getBlock();
if (block instanceof BlockChest) {
- this.world.playBlockAction(this.position, block, 1, this.viewingCount);
+ if (!opened) this.world.playBlockAction(this.position, block, 1, this.viewingCount); // CraftBukkit
this.world.applyPhysics(this.position, block);
}
@@ -240,4 +307,11 @@
protected Container createContainer(int i, PlayerInventory playerinventory) {
return ContainerChest.a(i, playerinventory, this);
world.playBlockAction(blockposition, block, 1, j);
}
+
+ // CraftBukkit start

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/level/block/entity/TileEntityCommand.java
+++ b/net/minecraft/world/level/block/entity/TileEntityCommand.java
@@ -24,6 +24,13 @@
private boolean c;
private boolean g;
private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() {
private boolean conditionMet;
private boolean sendToClient;
private final CommandBlockListenerAbstract commandBlock = new CommandBlockListenerAbstract() {
+ // CraftBukkit start
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityConduit.java
+++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java
@@ -27,6 +27,11 @@
@@ -29,6 +29,11 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -9,49 +9,31 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class TileEntityConduit extends TileEntity implements ITickable {
public class TileEntityConduit extends TileEntity {
private static final Block[] b = new Block[]{Blocks.PRISMARINE, Blocks.PRISMARINE_BRICKS, Blocks.SEA_LANTERN, Blocks.DARK_PRISMARINE};
@@ -178,7 +183,7 @@
private static final int BLOCK_REFRESH_RATE = 2;
@@ -205,7 +210,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (this.position.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) {
if (blockposition.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (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
}
}
@@ -195,7 +200,7 @@
this.target = this.x();
this.k = null;
} else if (this.target == null) {
- List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (entityliving1) -> {
+ List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate<EntityLiving>) (entityliving1) -> { // CraftBukkit - decompile error
return entityliving1 instanceof IMonster && entityliving1.isInWaterOrRain();
});
@@ -207,8 +212,13 @@
@@ -234,8 +239,13 @@
}
if (this.target != null) {
- this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.target.damageEntity(DamageSource.MAGIC, 4.0F);
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);
+ // CraftBukkit start
+ CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position);
+ if (this.target.damageEntity(DamageSource.MAGIC, 4.0F)) {
+ this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ 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);
+ }
+ CraftEventFactory.blockDamage = null;
+ // CraftBukkit end
}
if (entityliving != this.target) {
@@ -241,7 +251,7 @@
@Nullable
private EntityLiving x() {
- List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (entityliving) -> {
+ List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
return entityliving.getUniqueID().equals(this.k);
});
if (entityliving != tileentityconduit.destroyTarget) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityContainer.java
+++ b/net/minecraft/world/level/block/entity/TileEntityContainer.java
@@ -89,4 +89,12 @@
@@ -90,4 +90,12 @@
}
protected abstract Container createContainer(int i, PlayerInventory playerinventory);
@@ -8,8 +8,8 @@
+ // CraftBukkit start
+ @Override
+ public org.bukkit.Location getLocation() {
+ if (world == null) return null;
+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
+ if (level == null) return null;
+ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
+ }
+ // CraftBukkit end
}

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,48 @@
@@ -14,12 +14,49 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.IBlockData;
@@ -13,7 +13,8 @@
+
public class TileEntityDispenser extends TileEntityLootable {
private static final Random a = new Random();
private static final Random RANDOM = new Random();
public static final int CONTAINER_SIZE = 9;
private NonNullList<ItemStack> items;
+ // CraftBukkit start - add fields and methods
@@ -46,6 +47,6 @@
+ }
+ // CraftBukkit end
+
protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes) {
super(tileentitytypes);
this.items = NonNullList.a(9, ItemStack.b);
protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes, BlockPosition blockposition, IBlockData iblockdata) {
super(tileentitytypes, blockposition, iblockdata);
this.items = NonNullList.a(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
@@ -30,6 +30,14 @@
@@ -32,6 +32,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -12,19 +12,19 @@
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable {
public class TileEntityEndGateway extends TileEntityEnderPortal {
private static final Logger LOGGER = LogManager.getLogger();
@@ -140,7 +148,7 @@
public void b(Entity entity) {
if (this.world instanceof WorldServer && !this.f()) {
this.c = 100;
- if (this.exitPortal == null && this.world.getDimensionKey() == World.THE_END) {
+ if (this.exitPortal == null && this.world.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - work in alternate worlds
this.a((WorldServer) this.world);
}
@@ -170,7 +178,7 @@
tileentityendgateway.teleportCooldown = 100;
BlockPosition blockposition1;
@@ -165,6 +173,27 @@
- if (tileentityendgateway.exitPortal == null && world.getDimensionKey() == World.END) {
+ if (tileentityendgateway.exitPortal == null && world.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit - work in alternate worlds
blockposition1 = a(worldserver, blockposition);
blockposition1 = blockposition1.up(10);
TileEntityEndGateway.LOGGER.debug("Creating portal at {}", blockposition1);
@@ -199,6 +207,27 @@
entity1 = entity.getRootVehicle();
}
@@ -42,22 +42,22 @@
+ }
+
+ entity1.resetPortalCooldown();
+ ((EntityPlayer) entity1).playerConnection.teleport(teleEvent.getTo());
+ this.h(); // CraftBukkit - call at end of method
+ ((EntityPlayer) entity1).connection.teleport(teleEvent.getTo());
+ c(world, blockposition, iblockdata, tileentityendgateway); // CraftBukkit - call at end of method
+ return;
+
+ }
+ // CraftBukkit end
+
entity1.resetPortalCooldown();
entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
entity1.enderTeleportAndLoad((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D);
}
@@ -269,7 +298,7 @@
@@ -310,7 +339,7 @@
}
private void a(WorldServer worldserver, BlockPosition blockposition) {
- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition);
+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error
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
}
public void a(BlockPosition blockposition, boolean flag) {
@Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityFurnace.java
+++ b/net/minecraft/world/level/block/entity/TileEntityFurnace.java
@@ -39,6 +39,17 @@
@@ -43,6 +43,17 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
@@ -15,10 +15,10 @@
+import org.bukkit.event.inventory.FurnaceSmeltEvent;
+// CraftBukkit end
+
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable {
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput {
private static final int[] g = new int[]{0};
@@ -166,6 +177,36 @@
protected static final int SLOT_INPUT = 0;
@@ -182,6 +193,36 @@
return map;
}
@@ -55,46 +55,63 @@
private static boolean b(Item item) {
return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item);
}
@@ -252,12 +293,23 @@
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
}
} else {
- IRecipe<?> irecipe = (IRecipe) this.world.getCraftingManager().craft(this.c, this, this.world).orElse((Object) null);
+ IRecipe irecipe = this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).orElse(null); // Eclipse fail
@@ -266,13 +307,24 @@
tileentityfurnace.cookingProgress = MathHelper.clamp(tileentityfurnace.cookingProgress - 2, 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
int i = tileentityfurnace.getMaxStackSize();
if (!this.isBurning() && this.canBurn(irecipe)) {
- this.burnTime = this.fuelTime(itemstack);
+ // CraftBukkit start
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
if (!tileentityfurnace.isBurning() && canBurn(irecipe, tileentityfurnace.items, i)) {
- tileentityfurnace.litTime = tileentityfurnace.fuelTime(itemstack);
+ // CraftBukkit start
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
+
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(this.world, this.position), fuel, fuelTime(itemstack));
+ this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(world, blockposition), fuel, tileentityfurnace.fuelTime(itemstack));
+ world.getServer().getPluginManager().callEvent(furnaceBurnEvent);
+
+ if (furnaceBurnEvent.isCancelled()) {
+ return;
+ }
+ if (furnaceBurnEvent.isCancelled()) {
+ return;
+ }
+
+ this.burnTime = furnaceBurnEvent.getBurnTime();
this.ticksForCurrentFuel = this.burnTime;
- if (this.isBurning()) {
+ if (this.isBurning() && furnaceBurnEvent.isBurning()) {
+ // CraftBukkit end
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
@@ -319,11 +371,38 @@
+ tileentityfurnace.litTime = furnaceBurnEvent.getBurnTime();
tileentityfurnace.litDuration = tileentityfurnace.litTime;
- if (tileentityfurnace.isBurning()) {
+ if (tileentityfurnace.isBurning() && furnaceBurnEvent.isBurning()) {
+ // CraftBukkit end
flag1 = true;
if (!itemstack.isEmpty()) {
Item item = itemstack.getItem();
@@ -292,7 +344,7 @@
if (tileentityfurnace.cookingProgress == tileentityfurnace.cookingTotalTime) {
tileentityfurnace.cookingProgress = 0;
tileentityfurnace.cookingTotalTime = getRecipeCookingTime(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 +383,44 @@
}
}
- private static boolean burn(@Nullable IRecipe<?> irecipe, NonNullList<ItemStack> nonnulllist, int i) {
+ 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 itemstack2 = (ItemStack) this.items.get(2);
ItemStack itemstack2 = (ItemStack) nonnulllist.get(2);
+ // CraftBukkit start - fire FurnaceSmeltEvent
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
+
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result);
+ this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(CraftBlock.at(world, blockposition), source, result);
+ world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
+
+ if (furnaceSmeltEvent.isCancelled()) {
+ return;
+ return false;
+ }
+
+ result = furnaceSmeltEvent.getResult();
@@ -102,86 +119,86 @@
+
+ if (!itemstack1.isEmpty()) {
+ if (itemstack2.isEmpty()) {
+ this.items.set(2, itemstack1.cloneItemStack());
+ nonnulllist.set(2, itemstack1.cloneItemStack());
+ } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) {
+ itemstack2.add(itemstack1.getCount());
+ } else {
+ return;
+ return false;
+ }
+ }
+
+ /*
if (itemstack2.isEmpty()) {
this.items.set(2, itemstack1.cloneItemStack());
} else if (itemstack2.getItem() == itemstack1.getItem()) {
nonnulllist.set(2, itemstack1.cloneItemStack());
} else if (itemstack2.a(itemstack1.getItem())) {
itemstack2.add(1);
}
+ */
+ // CraftBukkit end
if (!this.world.isClientSide) {
this.a(irecipe);
@@ -348,7 +427,7 @@
if (itemstack.a(Blocks.WET_SPONGE.getItem()) && !((ItemStack) nonnulllist.get(1)).isEmpty() && ((ItemStack) nonnulllist.get(1)).a(Items.BUCKET)) {
nonnulllist.set(1, new ItemStack(Items.WATER_BUCKET));
@@ -365,7 +444,7 @@
}
protected int getRecipeCookingTime() {
- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200);
+ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
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
}
public static boolean isFuel(ItemStack itemstack) {
@@ -475,14 +554,20 @@
@@ -484,14 +563,20 @@
@Override
public void b(EntityHuman entityhuman) {}
public void awardUsedRecipes(EntityHuman entityhuman) {}
- public void d(EntityHuman entityhuman) {
- List<IRecipe<?>> list = this.a(entityhuman.world, entityhuman.getPositionVector());
+ public void d(EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
+ List<IRecipe<?>> list = this.a(entityhuman.world, entityhuman.getPositionVector(), entityhuman, itemstack, amount); // CraftBukkit
- 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
entityhuman.discoverRecipes(list);
this.n.clear();
entityplayer.discoverRecipes(list);
this.recipesUsed.clear();
}
public List<IRecipe<?>> a(World world, Vec3D vec3d) {
public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d) {
+ // CraftBukkit start
+ return this.a(world, vec3d, null, null, 0);
+ return this.a(worldserver, vec3d, this.worldPosition, null, null, 0);
+ }
+
+ public List<IRecipe<?>> a(World world, Vec3D vec3d, EntityHuman entityhuman, ItemStack itemstack, int amount) {
+ public List<IRecipe<?>> a(WorldServer worldserver, Vec3D vec3d, BlockPosition blockposition, EntityPlayer entityplayer, ItemStack itemstack, int amount) {
+ // CraftBukkit end
List<IRecipe<?>> list = Lists.newArrayList();
ObjectIterator objectiterator = this.n.object2IntEntrySet().iterator();
ObjectIterator objectiterator = this.recipesUsed.object2IntEntrySet().iterator();
@@ -491,14 +576,14 @@
@@ -500,14 +585,14 @@
world.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
worldserver.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
list.add(irecipe);
- a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience());
+ a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), entityhuman, itemstack, amount); // CraftBukkit
- a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience());
+ a(worldserver, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
});
}
return list;
}
- private static void a(World world, Vec3D vec3d, int i, float f) {
+ private void a(World world, Vec3D vec3d, int i, float f, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
- 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);
@@ -506,6 +591,14 @@
@@ -515,6 +600,14 @@
++j;
}
+ // CraftBukkit start - fire FurnaceExtractEvent
+ if (amount != 0) {
+ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j);
+ world.getServer().getPluginManager().callEvent(event);
+ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(worldserver, blockposition), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j);
+ worldserver.getServer().getPluginManager().callEvent(event);
+ j = event.getExpToDrop();
+ }
+ // CraftBukkit end
+
while (j > 0) {
int k = EntityExperienceOrb.getOrbValue(j);
EntityExperienceOrb.a(worldserver, vec3d, j);
}

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/world/level/block/entity/TileEntityHopper.java
+++ b/net/minecraft/world/level/block/entity/TileEntityHopper.java
@@ -33,12 +33,53 @@
@@ -33,6 +33,18 @@
import net.minecraft.world.phys.shapes.OperatorBoolean;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import net.minecraft.world.InventoryLargeChest;
+import net.minecraft.world.entity.vehicle.EntityMinecartHopper;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
@@ -15,11 +16,12 @@
+import org.bukkit.inventory.Inventory;
+// CraftBukkit end
+
public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable {
public class TileEntityHopper extends TileEntityLootable implements IHopper {
private NonNullList<ItemStack> items;
private int j;
private long k;
public static final int MOVE_ITEM_SPEED = 8;
@@ -41,6 +53,36 @@
private int cooldownTime;
private long tickedGameTime;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -51,40 +53,58 @@
+ }
+ // CraftBukkit end
+
public TileEntityHopper() {
super(TileEntityTypes.HOPPER);
this.items = NonNullList.a(5, ItemStack.b);
@@ -164,7 +205,28 @@
for (int i = 0; i < this.getSize(); ++i) {
if (!this.getItem(i).isEmpty()) {
ItemStack itemstack = this.getItem(i).cloneItemStack();
- ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection);
+ // ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection);
public TileEntityHopper(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.HOPPER, blockposition, iblockdata);
this.items = NonNullList.a(5, ItemStack.EMPTY);
@@ -115,7 +157,7 @@
boolean flag = false;
if (!tileentityhopper.isEmpty()) {
- flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper);
+ flag = a(world, blockposition, iblockdata, (IInventory) tileentityhopper, tileentityhopper); // CraftBukkit
}
if (!tileentityhopper.i()) {
@@ -149,7 +191,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);
if (iinventory1 == null) {
@@ -163,7 +205,28 @@
for (int i = 0; i < iinventory.getSize(); ++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);
+
+ // CraftBukkit start - Call event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));
+
+ Inventory destinationInventory;
+ // Have to special case large chests as they work oddly
+ if (iinventory instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ if (iinventory1 instanceof InventoryLargeChest) {
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory1);
+ } else {
+ destinationInventory = iinventory.getOwner().getInventory();
+ destinationInventory = iinventory1.getOwner().getInventory();
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ this.getWorld().getServer().getPluginManager().callEvent(event);
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(iinventory.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.setItem(i, itemstack);
+ this.setCooldown(8); // Delay hopper checks
+ hopper.setItem(i, itemstack);
+ hopper.setCooldown(8); // Delay hopper checks
+ return false;
+ }
+ ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ ItemStack itemstack1 = addItem(iinventory, iinventory1, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
+ // CraftBukkit end
if (itemstack1.isEmpty()) {
iinventory.update();
@@ -229,7 +291,34 @@
iinventory1.update();
@@ -228,7 +291,34 @@
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
ItemStack itemstack1 = itemstack.cloneItemStack();
@@ -103,7 +123,7 @@
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
+
+ ihopper.getWorld().getServer().getPluginManager().callEvent(event);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ iinventory.setItem(i, itemstack1);
+
@@ -120,13 +140,13 @@
if (itemstack2.isEmpty()) {
iinventory.update();
@@ -244,6 +333,13 @@
@@ -243,6 +333,13 @@
public static boolean a(IInventory iinventory, EntityItem entityitem) {
boolean flag = false;
+ // CraftBukkit start
+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ entityitem.world.getServer().getPluginManager().callEvent(event);
+ entityitem.level.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }

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,9 +27,67 @@
@@ -27,13 +27,71 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@@ -18,9 +18,14 @@
+// CraftBukkit end
+
+public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener
+
public static final int DATA_PAGE = 0;
public static final int NUM_DATA = 1;
public static final int SLOT_BOOK = 0;
public static final int NUM_SLOTS = 1;
- public final IInventory bookAccess = new IInventory() {
+ // CraftBukkit start - add fields and methods
+ public final IInventory inventory = new LecternInventory();
+ public final IInventory bookAccess = new LecternInventory();
+ public class LecternInventory implements IInventory {
+
+ public List<HumanEntity> transaction = new ArrayList<>();
@@ -53,7 +58,7 @@
+
+ @Override
+ public Location getLocation() {
+ return new Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
+ return new Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
+ }
+
+ @Override
@@ -65,12 +70,11 @@
+ return TileEntityLectern.this;
+ }
+ // CraftBukkit end
- public final IInventory inventory = new IInventory() {
+
@Override
public int getSize() {
return 1;
@@ -74,11 +132,20 @@
@@ -78,11 +136,20 @@
}
@Override
@@ -93,16 +97,16 @@
}
@Override
@@ -160,7 +227,7 @@
@@ -162,7 +229,7 @@
if (j != this.page) {
this.page = j;
this.update();
- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock());
+ if (this.world != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
+ if (this.level != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
}
}
@@ -183,6 +250,32 @@
@@ -185,6 +252,32 @@
return itemstack;
}
@@ -135,22 +139,22 @@
private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) {
String s;
Object object;
@@ -197,7 +290,8 @@
@@ -199,7 +292,8 @@
Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position);
Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.worldPosition);
- return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
- return new CommandListenerWrapper(ICommandListener.NULL, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
+ return new CommandListenerWrapper(this, vec3d, Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityhuman);
}
@Override
@@ -236,7 +330,7 @@
@@ -238,7 +332,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
- return new ContainerLectern(i, this.inventory, this.containerProperties);
+ return new ContainerLectern(i, this.inventory, this.containerProperties, playerinventory); // CraftBukkit
- return new ContainerLectern(i, this.bookAccess, this.dataAccess);
+ return new ContainerLectern(i, this.bookAccess, this.dataAccess, playerinventory); // CraftBukkit
}
@Override

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityShulkerBox.java
@@ -29,6 +29,11 @@
@@ -32,6 +32,11 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable {
public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory {
private static final int[] a = IntStream.range(0, 27).toArray();
@@ -41,6 +46,37 @@
private EnumColor l;
private boolean m;
public static final int COLUMNS = 9;
@@ -51,6 +56,37 @@
@Nullable
private final EnumColor color;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -22,7 +22,7 @@
+ public boolean opened;
+
+ public List<ItemStack> getContents() {
+ return this.contents;
+ return this.itemStacks;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
@@ -47,22 +47,22 @@
+ }
+ // CraftBukkit end
+
public TileEntityShulkerBox(@Nullable EnumColor enumcolor) {
super(TileEntityTypes.SHULKER_BOX);
this.contents = NonNullList.a(27, ItemStack.b);
@@ -203,6 +239,7 @@
public TileEntityShulkerBox(@Nullable EnumColor enumcolor, BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.SHULKER_BOX, blockposition, iblockdata);
this.itemStacks = NonNullList.a(27, ItemStack.EMPTY);
@@ -163,6 +199,7 @@
}
++this.viewingCount;
++this.openCount;
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount);
if (this.viewingCount == 1) {
this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
@@ -215,6 +252,7 @@
this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount);
if (this.openCount == 1) {
this.level.a((Entity) entityhuman, GameEvent.CONTAINER_OPEN, this.worldPosition);
@@ -176,6 +213,7 @@
public void closeContainer(EntityHuman entityhuman) {
if (!entityhuman.isSpectator()) {
--this.viewingCount;
--this.openCount;
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount);
if (this.viewingCount <= 0) {
this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
this.level.playBlockAction(this.worldPosition, this.getBlock().getBlock(), 1, this.openCount);
if (this.openCount <= 0) {
this.level.a((Entity) entityhuman, GameEvent.CONTAINER_CLOSE, this.worldPosition);

View File

@@ -1,16 +1,16 @@
--- a/net/minecraft/world/level/block/entity/TileEntitySign.java
+++ b/net/minecraft/world/level/block/entity/TileEntitySign.java
@@ -23,7 +23,7 @@
@@ -25,7 +25,7 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
-public class TileEntitySign extends TileEntity {
+public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements
public final IChatBaseComponent[] lines;
public boolean isEditable;
@@ -49,6 +49,12 @@
nbttagcompound.setString("Text" + (i + 1), s);
public static final int LINES = 4;
private static final String[] RAW_TEXT_FIELD_NAMES = new String[]{"Text1", "Text2", "Text3", "Text4"};
@@ -65,6 +65,12 @@
}
}
+ // CraftBukkit start
@@ -19,56 +19,46 @@
+ }
+ // CraftBukkit end
+
nbttagcompound.setString("Color", this.color.c());
nbttagcompound.setString("Color", this.color.b());
nbttagcompound.setBoolean("GlowingText", this.hasGlowingText);
return nbttagcompound;
}
@@ -59,18 +65,38 @@
super.load(iblockdata, nbttagcompound);
@@ -76,8 +82,24 @@
super.load(nbttagcompound);
this.color = EnumColor.a(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
+ // we have no way to tell whether a sign is from 1.7.10 or 1.8
+
+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted");
+ // CraftBukkit end
+
for (int i = 0; i < 4; ++i) {
String s = nbttagcompound.getString("Text" + (i + 1));
- IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s);
String s = nbttagcompound.getString(TileEntitySign.RAW_TEXT_FIELD_NAMES[i]);
+ // CraftBukkit start
+ if (s != null && s.length() > 2048) {
+ s = "\"\"";
+ }
+
+ try {
+ IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s);
+ if (oldSign) {
+ messages[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = this.a(s);
- if (this.world instanceof WorldServer) {
- try {
- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0);
- } catch (CommandSyntaxException commandsyntaxexception) {
+ if (oldSign) {
+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
+ continue;
+ }
+ // CraftBukkit end
+
+ if (this.world instanceof WorldServer) {
+ try {
+ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0);
+ } catch (CommandSyntaxException commandsyntaxexception) {
+ this.lines[i] = ichatmutablecomponent;
+ }
+ } else {
this.lines[i] = ichatmutablecomponent;
}
- } else {
- this.lines[i] = ichatmutablecomponent;
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ this.lines[i] = new ChatComponentText(s);
this.messages[i] = ichatbasecomponent;
@@ -115,6 +137,10 @@
if (ichatmutablecomponent != null) {
return ichatmutablecomponent;
}
this.g[i] = null;
@@ -131,11 +157,37 @@
+ // CraftBukkit start
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
+ return new ChatComponentText(s);
+ // CraftBukkit end
} catch (Exception exception) {
;
}
@@ -207,11 +233,37 @@
return true;
}
@@ -97,22 +87,21 @@
+ }
+ // CraftBukkit end
+
public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) {
public CommandListenerWrapper b(@Nullable EntityPlayer entityplayer) {
String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString();
Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName();
- return new CommandListenerWrapper(ICommandListener.DUMMY, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer);
- return new CommandListenerWrapper(ICommandListener.NULL, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer);
+ // CraftBukkit - this
+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer);
+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.worldPosition), Vec2F.ZERO, (WorldServer) this.level, 2, s, (IChatBaseComponent) object, this.level.getMinecraftServer(), entityplayer);
}
public EnumColor getColor() {
@@ -146,7 +198,7 @@
if (enumcolor != this.getColor()) {
this.color = enumcolor;
this.update();
- this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3);
+ if (this.world != null) this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122)
return true;
} else {
return false;
@@ -244,6 +296,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)
}
}