Compare commits

..

No commits in common. "d63a32ec566f6d7cd1554c274cb91d836e5365b4" and "ba251cc06809f40ad25535b3aa6ffa6c5e65e6ed" have entirely different histories.

10 changed files with 99 additions and 165 deletions

View File

@ -1,12 +1,11 @@
--- a/net/minecraft/server/level/PlayerInteractManager.java
+++ b/net/minecraft/server/level/PlayerInteractManager.java
@@ -26,6 +26,28 @@
@@ -26,6 +26,27 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.util.ArrayList;
+import net.minecraft.network.protocol.game.ClientboundBlockChangedAckPacket;
+import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.entity.EnumItemSlot;
@ -29,7 +28,7 @@
public class PlayerInteractManager {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -56,9 +78,16 @@
@@ -56,9 +77,16 @@
if (enumgamemode == this.gameModeForPlayer) {
return false;
} else {
@ -47,7 +46,7 @@
this.level.updateSleepingPlayerList();
if (enumgamemode == EnumGamemode.CREATIVE) {
this.player.resetCurrentImpulseContext();
@@ -92,7 +121,7 @@
@@ -92,7 +120,7 @@
}
public void tick() {
@ -56,7 +55,7 @@
if (this.hasDelayedDestroy) {
IBlockData iblockdata = this.level.getBlockState(this.delayedDestroyPos);
@@ -144,10 +173,36 @@
@@ -144,11 +172,33 @@
} else {
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, blockposition)) {
@ -64,36 +63,33 @@
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND);
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
this.debugLogging(blockposition, false, j, "may not interact");
+ // SPIGOT-8042: Need to ACK above changes first
+ this.player.connection.send(new ClientboundBlockChangedAckPacket(j));
+ // Update any tile entity data for this block
+ TileEntity tileentity = level.getBlockEntity(blockposition);
+ if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
+ // CraftBukkit end
+ return;
+ }
+
return;
}
+ // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND);
+ if (event.isCancelled()) {
+ // Let the client know the block still exists
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
+ // SPIGOT-8042: Need to ACK above changes first
+ this.player.connection.send(new ClientboundBlockChangedAckPacket(j));
+ // Update any tile entity data for this block
+ TileEntity tileentity = this.level.getBlockEntity(blockposition);
+ if (tileentity != null) {
+ this.player.connection.send(tileentity.getUpdatePacket());
+ }
return;
}
+ return;
+ }
+ // CraftBukkit end
+
if (this.player.getAbilities().instabuild) {
this.destroyAndAck(blockposition, j, "creative destroy");
@@ -164,7 +219,19 @@
return;
@@ -164,7 +214,19 @@
float f = 1.0F;
IBlockData iblockdata = this.level.getBlockState(blockposition);
@ -114,7 +110,7 @@
EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> {
this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND);
});
@@ -172,6 +239,26 @@
@@ -172,6 +234,26 @@
f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition);
}
@ -141,7 +137,7 @@
if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, j, "insta mine");
} else {
@@ -216,20 +303,22 @@
@@ -216,13 +298,15 @@
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, blockposition)) {
@ -158,24 +154,9 @@
}
}
}
public void destroyAndAck(BlockPosition blockposition, int i, String s) {
- if (this.destroyBlock(blockposition)) {
+ if (this.destroyBlock(blockposition, i)) { // CraftBukkit - add ack
this.debugLogging(blockposition, true, i, s);
} else {
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
@@ -239,11 +328,74 @@
}
@@ -240,10 +324,65 @@
public boolean destroyBlock(BlockPosition blockposition) {
+ // CraftBukkit start
+ return this.destroyBlock(blockposition, -1);
+ }
+
+ public boolean destroyBlock(BlockPosition blockposition, int ack) {
+ // CraftBukkit end
IBlockData iblockdata = this.level.getBlockState(blockposition);
+ // CraftBukkit start - fire BlockBreakEvent
+ org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
@ -222,8 +203,6 @@
+ this.player.connection.send(new PacketPlayOutBlockChange(level, blockposition.relative(dir)));
+ }
+
+ // SPIGOT-8042: Need to ACK above changes first
+ this.player.connection.send(new ClientboundBlockChangedAckPacket(ack));
+ // Update any tile entity data for this block
+ TileEntity tileentity = this.level.getBlockEntity(blockposition);
+ if (tileentity != null) {
@ -242,7 +221,7 @@
TileEntity tileentity = this.level.getBlockEntity(blockposition);
Block block = iblockdata.getBlock();
@@ -253,6 +405,10 @@
@@ -253,6 +392,10 @@
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
return false;
} else {
@ -253,7 +232,7 @@
IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
boolean flag = this.level.removeBlock(blockposition, false);
@@ -261,19 +417,32 @@
@@ -261,19 +404,32 @@
}
if (this.player.preventsBlockDrops()) {
@ -276,20 +255,20 @@
+ // CraftBukkit start
+ if (event.isDropItems()) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops);
}
+ }
+ level.captureDrops = null;
+
+ // Drop event experience
+ if (flag && event != null) {
+ iblockdata.getBlock().popExperience(this.level, blockposition, event.getExpToDrop());
+ }
}
+
+ return true;
+ // CraftBukkit end
}
}
}
@@ -319,14 +488,53 @@
@@ -319,14 +475,53 @@
}
}
@ -343,7 +322,7 @@
if (itileinventory != null) {
entityplayer.openMenu(itileinventory);
@@ -357,7 +565,7 @@
@@ -357,7 +552,7 @@
}
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -169,6 +169,26 @@
@@ -169,6 +169,24 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
@ -15,19 +15,17 @@
+import org.bukkit.WeatherType;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.WorldUUID;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.server.MapInitializeEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+import org.bukkit.event.world.SpawnChangeEvent;
+import org.bukkit.event.world.TimeSkipEvent;
+// CraftBukkit end
+
public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -182,7 +202,7 @@
@@ -182,7 +200,7 @@
final List<EntityPlayer> players = Lists.newArrayList();
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@ -36,7 +34,7 @@
private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager;
@@ -209,13 +229,47 @@
@@ -209,13 +227,47 @@
private final boolean tickTime;
private final RandomSequences randomSequences;
@ -86,7 +84,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(new SimpleRegionStorage(new RegionStorageInfo(convertable_conversionsession.getLevelId(), resourcekey, "entities"), convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, DataFixTypes.ENTITY_CHUNK), this, minecraftserver);
@@ -243,9 +297,9 @@
@@ -243,9 +295,9 @@
long l = minecraftserver.getWorldData().worldGenOptions().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -99,7 +97,7 @@
} else {
this.dragonFight = null;
}
@@ -255,6 +309,7 @@
@@ -255,6 +307,7 @@
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.TYPE);
});
@ -107,7 +105,7 @@
}
/** @deprecated */
@@ -299,13 +354,22 @@
@@ -299,13 +352,22 @@
int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -132,7 +130,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -341,7 +405,7 @@
@@ -341,7 +403,7 @@
this.handlingTick = false;
gameprofilerfiller.pop();
@ -141,7 +139,7 @@
if (flag1) {
this.resetEmptyTime();
@@ -421,7 +485,7 @@
@@ -421,7 +483,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -150,7 +148,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -498,7 +562,7 @@
@@ -498,7 +560,7 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -159,7 +157,7 @@
}
}
@@ -507,7 +571,7 @@
@@ -507,7 +569,7 @@
if (entitylightning != null) {
entitylightning.snapTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1);
@ -168,7 +166,7 @@
}
}
}
@@ -522,7 +586,7 @@
@@ -522,7 +584,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
if (biomebase.shouldFreeze(this, blockposition2)) {
@ -177,7 +175,7 @@
}
if (this.isRaining()) {
@@ -538,10 +602,10 @@
@@ -538,10 +600,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
@ -190,7 +188,7 @@
}
}
@@ -698,6 +762,7 @@
@@ -698,6 +760,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -198,7 +196,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -716,15 +781,48 @@
@@ -716,15 +779,48 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
@ -249,7 +247,7 @@
}
public void resetEmptyTime() {
@@ -760,6 +858,7 @@
@@ -760,6 +856,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -257,7 +255,7 @@
gameprofilerfiller.pop();
for (Entity entity1 : entity.getPassengers()) {
@@ -780,6 +879,7 @@
@@ -780,6 +877,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@ -265,7 +263,7 @@
gameprofilerfiller.pop();
for (Entity entity2 : entity1.getPassengers()) {
@@ -811,6 +911,7 @@
@@ -811,6 +909,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
@ -273,7 +271,7 @@
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -828,11 +929,19 @@
@@ -828,11 +927,19 @@
}
}
@ -294,7 +292,7 @@
}
WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage();
@@ -901,18 +1010,40 @@
@@ -901,18 +1008,40 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -338,7 +336,7 @@
}
}
@@ -937,24 +1068,37 @@
@@ -937,24 +1066,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@ -380,14 +378,14 @@
return true;
}
}
@@ -965,17 +1109,45 @@
@@ -965,17 +1107,45 @@
}
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
- entityplayer.remove(entity_removalreason);
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
+ }
+
}
+ // CraftBukkit start
+ public boolean strikeLightning(Entity entitylightning) {
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
@ -401,9 +399,9 @@
+ }
+
+ return this.addFreshEntity(entitylightning);
}
+ }
+ // CraftBukkit end
+
@Override
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
+ // CraftBukkit start
@ -427,7 +425,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -1078,8 +1250,21 @@
@@ -1078,8 +1248,21 @@
if (VoxelShapes.joinIsNotEmpty(voxelshape, voxelshape1, OperatorBoolean.NOT_SAME)) {
List<NavigationAbstract> list = new ObjectArrayList();
@ -450,7 +448,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1142,6 +1327,12 @@
@@ -1142,6 +1325,12 @@
@Override
public void explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder<SoundEffect> holder) {
@ -463,7 +461,7 @@
Explosion.Effect explosion_effect;
switch (world_a) {
@@ -1160,6 +1351,11 @@
@@ -1160,6 +1349,11 @@
case TRIGGER:
explosion_effect = Explosion.Effect.TRIGGER_BLOCK;
break;
@ -475,7 +473,7 @@
default:
throw new MatchException((String) null, (Throwable) null);
}
@@ -1169,6 +1365,11 @@
@@ -1169,6 +1363,11 @@
ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
serverexplosion.explode();
@ -487,7 +485,7 @@
ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1;
for (EntityPlayer entityplayer : this.players) {
@@ -1179,6 +1380,7 @@
@@ -1179,6 +1378,7 @@
}
}
@ -495,7 +493,7 @@
}
private Explosion.Effect getDestroyType(GameRules.GameRuleKey<GameRules.GameRuleBoolean> gamerules_gamerulekey) {
@@ -1239,15 +1441,22 @@
@@ -1239,15 +1439,22 @@
}
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -519,7 +517,7 @@
if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) {
++j;
@@ -1300,7 +1509,7 @@
@@ -1300,7 +1507,7 @@
@Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -528,7 +526,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey);
@@ -1342,10 +1551,21 @@
@@ -1342,10 +1549,21 @@
@Nullable
@Override
public WorldMap getMapData(MapId mapid) {
@ -551,18 +549,7 @@
this.getServer().overworld().getDataStorage().set(WorldMap.type(mapid), worldmap);
}
@@ -1359,6 +1579,10 @@
if (!blockposition1.equals(blockposition) || f1 != f) {
this.levelData.setSpawn(blockposition, f);
+ // CraftBukkit start - Notify anyone who's listening.
+ SpawnChangeEvent event = new SpawnChangeEvent(getWorld(), CraftLocation.toBukkit(blockposition, getWorld(), f1, 0.0F));
+ getCraftServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
this.getServer().getPlayerList().broadcastAll(new PacketPlayOutSpawnPosition(blockposition, f));
}
@@ -1557,12 +1781,12 @@
@@ -1557,12 +1775,12 @@
}
public boolean isFlat() {
@ -577,7 +564,7 @@
}
@Nullable
@@ -1592,7 +1816,7 @@
@@ -1592,7 +1810,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -586,28 +573,16 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1716,7 +1940,11 @@
a() {}
- public void onCreated(Entity entity) {}
+ // CraftBukkit start - Mark entity as in world
+ public void onCreated(Entity entity) {
+ entity.inWorld = true;
+ // CraftBukkit end
+ }
public void onDestroyed(Entity entity) {
WorldServer.this.getScoreboard().entityRemoved(entity);
@@ -1754,6 +1982,7 @@
@@ -1754,6 +1972,8 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
+ entity.inWorld = true; // CraftBukkit - Mark entity as in world
+ entity.valid = true; // CraftBukkit
}
public void onTrackingEnd(Entity entity) {
@@ -1780,6 +2009,14 @@
@@ -1780,6 +2000,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -215,7 +215,7 @@
+ if ((i & 1) != 0) {
+ this.updateNeighborsAt(blockposition, iblockdata1.getBlock());
+ if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) {
+ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock());
+ this.updateNeighborsAt(blockposition, newBlock.getBlock());
+ }
+ }
+

View File

@ -146,19 +146,10 @@ public enum CraftStatistic {
}
public static net.minecraft.stats.Statistic getMaterialStatistic(org.bukkit.Statistic stat, Material material) {
Type type = stat.getType();
switch (type) {
case BLOCK:
Preconditions.checkArgument(material.isBlock(), "statistic type is BLOCK but got non-block Material, %s", material);
try {
if (stat == Statistic.MINE_BLOCK) {
return StatisticList.BLOCK_MINED.get(CraftBlockType.bukkitToMinecraft(material));
}
break;
case ITEM:
Preconditions.checkArgument(material.isItem(), "statistic type is ITEM but got non-item Material, %s", material);
if (stat == Statistic.CRAFT_ITEM) {
return StatisticList.ITEM_CRAFTED.get(CraftItemType.bukkitToMinecraft(material));
}
@ -174,12 +165,10 @@ public enum CraftStatistic {
if (stat == Statistic.DROP) {
return StatisticList.ITEM_DROPPED.get(CraftItemType.bukkitToMinecraft(material));
}
break;
default:
throw new IllegalArgumentException("statistic type must be either BLOCK or ITEM, given " + type);
} catch (ArrayIndexOutOfBoundsException e) {
return null;
}
throw new IllegalArgumentException("Unknwon material statistic " + stat);
return null;
}
public static net.minecraft.stats.Statistic getEntityStatistic(org.bukkit.Statistic stat, EntityType entity) {

View File

@ -132,6 +132,7 @@ import org.bukkit.entity.TippedArrow;
import org.bukkit.entity.Trident;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.bukkit.event.world.SpawnChangeEvent;
import org.bukkit.event.world.TimeSkipEvent;
import org.bukkit.generator.BiomeProvider;
import org.bukkit.generator.BlockPopulator;
@ -202,7 +203,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean setSpawnLocation(int x, int y, int z, float angle) {
try {
world.setDefaultSpawnPos(new BlockPosition(x, y, z), angle);
Location previousLocation = getSpawnLocation();
world.levelData.setSpawn(new BlockPosition(x, y, z), angle);
// Notify anyone who's listening.
SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
server.getPluginManager().callEvent(event);
return true;
} catch (Exception e) {
return false;

View File

@ -29,7 +29,7 @@ public class CraftPig extends CraftAnimals implements Pig {
@Override
public void setSaddle(boolean saddled) {
getHandle().setItemSlot(EnumItemSlot.SADDLE, (saddled) ? new ItemStack(Items.SADDLE) : ItemStack.EMPTY);
getHandle().setItemSlot(EnumItemSlot.SADDLE, new ItemStack(Items.SADDLE));
}
@Override

View File

@ -32,7 +32,7 @@ public class CraftStrider extends CraftAnimals implements Strider {
@Override
public void setSaddle(boolean saddled) {
getHandle().setItemSlot(EnumItemSlot.SADDLE, (saddled) ? new ItemStack(Items.SADDLE) : ItemStack.EMPTY);
getHandle().setItemSlot(EnumItemSlot.SADDLE, new ItemStack(Items.SADDLE));
}
@Override

View File

@ -1981,11 +1981,6 @@ public class CraftEventFactory {
return;
}
// SPIGOT-8041: Do not call event unless entity has been spawned into world
if (!entity.inWorld) {
return;
}
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
}

View File

@ -12,7 +12,6 @@ import net.minecraft.world.inventory.InventoryMerchant;
import net.minecraft.world.level.block.BlockComposter;
import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity;
import net.minecraft.world.level.block.entity.CrafterBlockEntity;
import net.minecraft.world.level.block.entity.DecoratedPotBlockEntity;
import net.minecraft.world.level.block.entity.IHopper;
import net.minecraft.world.level.block.entity.TileEntityBarrel;
import net.minecraft.world.level.block.entity.TileEntityBlastFurnace;
@ -285,10 +284,6 @@ public class CraftInventory implements Inventory {
for (int i = 0; i < items.length; i++) {
ItemStack item = items[i];
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
// SPIGOT-8038: Cannot add/remove air. Probably should be an exception, but ignored for compatibility
if (item.getType().isAir()) {
continue;
}
while (true) {
// Do we already have a stack of it?
int firstPartial = firstPartial(item);
@ -353,10 +348,6 @@ public class CraftInventory implements Inventory {
for (int i = 0; i < items.length; i++) {
ItemStack item = items[i];
Preconditions.checkArgument(item != null, "ItemStack cannot be null");
// SPIGOT-8038: Cannot add/remove air. Probably should be an exception, but ignored for compatibility
if (item.getType().isAir()) {
continue;
}
int toDelete = item.getAmount();
while (true) {
@ -507,8 +498,6 @@ public class CraftInventory implements Inventory {
return InventoryType.COMPOSTER;
} else if (inventory instanceof TileEntityJukeBox) {
return InventoryType.JUKEBOX;
} else if (inventory instanceof DecoratedPotBlockEntity) {
return InventoryType.DECORATED_POT;
} else {
return InventoryType.CHEST;
}

View File

@ -327,7 +327,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.lore = new ArrayList<IChatBaseComponent>(meta.lore);
}
if (meta.hasCustomModelDataComponent()) {
if (meta.hasCustomModelData()) {
this.customModelData = new CraftCustomModelDataComponent(meta.customModelData);
}
this.enchantableValue = meta.enchantableValue;
@ -950,7 +950,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
itemTag.put(LORE, new ItemLore(lore));
}
if (hasCustomModelDataComponent()) {
if (hasCustomModelData()) {
itemTag.put(CUSTOM_MODEL_DATA, customModelData.getHandle());
}
@ -1140,7 +1140,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Overridden
boolean isEmpty() {
return !(hasDisplayName() || hasItemName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelDataComponent() || hasEnchantable() || hasBlockData() || hasRepairCost() || !unhandledTags.build().isEmpty() || !removedTags.isEmpty() || !persistentDataContainer.isEmpty() || hasItemFlags() || isHideTooltip() || hasTooltipStyle() || hasItemModel() || isUnbreakable() || hasEnchantmentGlintOverride() || isGlider() || hasDamageResistant() || hasMaxStackSize() || hasRarity() || hasUseRemainder() || hasUseCooldown() || hasFood() || hasConsumable() || hasTool() || hasBlocksAttacks() || hasWeapon() || hasJukeboxPlayable() || hasBreakSound() || hasEquippable() || hasDamage() || hasMaxDamage() || hasAttributeModifiers() || customTag != null);
return !(hasDisplayName() || hasItemName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasEnchantable() || hasBlockData() || hasRepairCost() || !unhandledTags.build().isEmpty() || !removedTags.isEmpty() || !persistentDataContainer.isEmpty() || hasItemFlags() || isHideTooltip() || hasTooltipStyle() || hasItemModel() || isUnbreakable() || hasEnchantmentGlintOverride() || isGlider() || hasDamageResistant() || hasMaxStackSize() || hasRarity() || hasUseRemainder() || hasUseCooldown() || hasFood() || hasConsumable() || hasTool() || hasBlocksAttacks() || hasWeapon() || hasJukeboxPlayable() || hasBreakSound() || hasEquippable() || hasDamage() || hasMaxDamage() || hasAttributeModifiers() || customTag != null);
}
@Override
@ -1932,7 +1932,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasItemName() ? that.hasItemName() && this.itemName.equals(that.itemName) : !that.hasItemName())
&& (this.hasEnchants() ? that.hasEnchants() && this.enchantments.equals(that.enchantments) : !that.hasEnchants())
&& (Objects.equals(this.lore, that.lore))
&& (this.hasCustomModelDataComponent() ? that.hasCustomModelDataComponent() && this.customModelData.equals(that.customModelData) : !that.hasCustomModelDataComponent())
&& (this.hasCustomModelData() ? that.hasCustomModelData() && this.customModelData.equals(that.customModelData) : !that.hasCustomModelData())
&& (this.hasEnchantable() ? that.hasEnchantable() && this.enchantableValue.equals(that.enchantableValue) : !that.hasEnchantable())
&& (this.hasBlockData() ? that.hasBlockData() && this.blockData.equals(that.blockData) : !that.hasBlockData())
&& (this.hasRepairCost() ? that.hasRepairCost() && this.repairCost == that.repairCost : !that.hasRepairCost())
@ -1987,7 +1987,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (hasDisplayName() ? this.displayName.hashCode() : 0);
hash = 61 * hash + (hasItemName() ? this.itemName.hashCode() : 0);
hash = 61 * hash + ((lore != null) ? this.lore.hashCode() : 0);
hash = 61 * hash + (hasCustomModelDataComponent() ? this.customModelData.hashCode() : 0);
hash = 61 * hash + (hasCustomModelData() ? this.customModelData.hashCode() : 0);
hash = 61 * hash + (hasEnchantable() ? this.enchantableValue.hashCode() : 0);
hash = 61 * hash + (hasBlockData() ? this.blockData.hashCode() : 0);
hash = 61 * hash + (hasEnchants() ? this.enchantments.hashCode() : 0);
@ -2031,7 +2031,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.lore != null) {
clone.lore = new ArrayList<IChatBaseComponent>(this.lore);
}
if (this.hasCustomModelDataComponent()) {
if (this.hasCustomModelData()) {
clone.customModelData = new CraftCustomModelDataComponent(customModelData);
}
clone.enchantableValue = this.enchantableValue;
@ -2125,7 +2125,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
builder.put(LORE.BUKKIT, jsonLore);
}
if (hasCustomModelDataComponent()) {
if (hasCustomModelData()) {
builder.put(CUSTOM_MODEL_DATA.BUKKIT, customModelData);
}
if (hasEnchantable()) {