#1181: Consolidate Location conversion code

By: Doc <nachito94@msn.com>
This commit is contained in:
CraftBukkit/Spigot
2023-04-19 19:59:19 +10:00
parent 2ffb1d2479
commit b99d3df2d8
43 changed files with 424 additions and 316 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -78,6 +78,21 @@
@@ -78,6 +78,22 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import org.slf4j.Logger;
@@ -12,6 +12,7 @@
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+import org.bukkit.event.block.BlockDispenseArmorEvent;
+import org.bukkit.event.block.BlockDispenseEvent;
@@ -22,7 +23,7 @@
public interface IDispenseBehavior {
Logger LOGGER = LogUtils.getLogger();
@@ -202,14 +217,42 @@
@@ -202,14 +218,42 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag());
@@ -67,7 +68,7 @@
isourceblock.getLevel().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, isourceblock.getPos());
return itemstack;
}
@@ -228,13 +271,41 @@
@@ -228,13 +272,41 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
WorldServer worldserver = isourceblock.getLevel();
@@ -110,7 +111,7 @@
}
return itemstack;
@@ -255,8 +326,35 @@
@@ -255,8 +327,35 @@
});
if (!list.isEmpty()) {
@@ -147,7 +148,7 @@
this.setSuccess(true);
return itemstack;
} else {
@@ -283,7 +381,35 @@
@@ -283,7 +382,35 @@
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
} while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed());
@@ -184,7 +185,7 @@
this.setSuccess(true);
return itemstack;
}
@@ -326,9 +452,35 @@
@@ -326,9 +453,35 @@
}
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
@@ -222,7 +223,7 @@
this.setSuccess(true);
return itemstack;
}
@@ -337,12 +489,41 @@
@@ -337,12 +490,41 @@
@Override
public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
@@ -265,7 +266,7 @@
return itemstack;
}
@@ -364,12 +545,40 @@
@@ -364,12 +546,40 @@
double d3 = randomsource.triangle((double) enumdirection.getStepX(), 0.11485000000000001D);
double d4 = randomsource.triangle((double) enumdirection.getStepY(), 0.11485000000000001D);
double d5 = randomsource.triangle((double) enumdirection.getStepZ(), 0.11485000000000001D);
@@ -311,7 +312,7 @@
return itemstack;
}
@@ -405,9 +614,52 @@
@@ -405,9 +615,52 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
WorldServer worldserver = isourceblock.getLevel();
@@ -365,7 +366,7 @@
} else {
return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack);
}
@@ -434,7 +686,7 @@
@@ -434,7 +687,7 @@
Block block = iblockdata.getBlock();
if (block instanceof IFluidSource) {
@@ -374,7 +375,7 @@
if (itemstack1.isEmpty()) {
return super.execute(isourceblock, itemstack);
@@ -442,6 +694,32 @@
@@ -442,6 +695,32 @@
worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
Item item = itemstack1.getItem();
@@ -407,7 +408,7 @@
itemstack.shrink(1);
if (itemstack.isEmpty()) {
return new ItemStack(item);
@@ -463,14 +741,42 @@
@@ -463,14 +742,42 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
@@ -452,7 +453,7 @@
} else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
if (iblockdata.getBlock() instanceof BlockTNT) {
BlockTNT.explode(worldserver, blockposition);
@@ -496,12 +802,62 @@
@@ -496,12 +803,62 @@
this.setSuccess(true);
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@@ -492,7 +493,7 @@
+ if (worldserver.capturedBlockStates.size() > 0) {
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ Location location = CraftLocation.toBukkit(blockposition, worldserver.getWorld());
+ List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
+ worldserver.capturedBlockStates.clear();
+ StructureGrowEvent structureEvent = null;
@@ -515,7 +516,7 @@
return itemstack;
}
@@ -511,12 +867,41 @@
@@ -511,12 +868,41 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@@ -559,7 +560,7 @@
return itemstack;
}
});
@@ -541,6 +926,30 @@
@@ -541,6 +927,30 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
@@ -590,7 +591,7 @@
if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) {
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3);
worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
@@ -566,6 +975,30 @@
@@ -566,6 +976,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
@@ -621,7 +622,7 @@
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
if (!worldserver.isClientSide) {
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
@@ -615,6 +1048,30 @@
@@ -615,6 +1049,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getBlockState(blockposition);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -155,6 +155,37 @@
@@ -155,6 +155,38 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
@@ -23,6 +23,7 @@
+import org.bukkit.craftbukkit.event.CraftPortalEvent;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftDimensionUtil;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.player.PlayerBedLeaveEvent;
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
@@ -38,7 +39,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -212,6 +243,21 @@
@@ -212,6 +244,21 @@
public int latency;
public boolean wonGame;
@@ -60,7 +61,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -275,12 +321,56 @@
@@ -275,12 +322,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.setMaxUpStep(1.0F);
this.fudgeSpawnLocation(worldserver);
@@ -118,7 +119,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -329,7 +419,7 @@
@@ -329,7 +420,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
@@ -127,7 +128,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -348,17 +438,26 @@
@@ -348,17 +439,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@@ -155,7 +156,7 @@
Logger logger1 = EntityPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -371,7 +470,7 @@
@@ -371,7 +471,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -164,7 +165,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -392,7 +491,20 @@
@@ -392,7 +492,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -186,7 +187,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -417,8 +529,32 @@
@@ -417,8 +530,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@@ -201,17 +202,17 @@
+ this.unsetRemoved();
+ Vec3D position = null;
+ if (this.respawnDimension != null) {
+ world = this.getLevel().getCraftServer().getHandle().getServer().getLevel(this.respawnDimension);
+ world = this.server.getLevel(this.respawnDimension);
+ if (world != null && this.getRespawnPosition() != null) {
+ position = EntityHuman.findRespawnPositionAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).orElse(null);
+ }
+ }
+ if (world == null || position == null) {
+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ position = Vec3D.atCenterOf(((WorldServer) world).getSharedSpawnPos());
+ position = Vec3D.atCenterOf(world.getSharedSpawnPos());
+ }
+ this.level = world;
+ this.setPos(position.x(), position.y(), position.z());
+ this.setPos(position);
+ }
+ this.gameMode.setLevel((WorldServer) world);
}
@@ -219,7 +220,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
@@ -478,6 +614,11 @@
@@ -478,6 +615,11 @@
@Override
public void tick() {
@@ -231,7 +232,7 @@
this.gameMode.tick();
this.wardenSpawnTracker.tick();
--this.spawnInvulnerableTime;
@@ -534,7 +675,7 @@
@@ -534,7 +676,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -240,7 +241,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -565,6 +706,12 @@
@@ -565,6 +707,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@@ -253,7 +254,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -579,6 +726,20 @@
@@ -579,6 +727,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@@ -274,7 +275,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -621,7 +782,8 @@
@@ -621,7 +783,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@@ -284,7 +285,7 @@
scoreboardscore.setScore(i);
});
}
@@ -630,9 +792,47 @@
@@ -630,9 +793,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@@ -334,7 +335,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
@@ -663,12 +863,18 @@
@@ -663,12 +864,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@@ -357,7 +358,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -706,10 +912,12 @@
@@ -706,10 +913,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@@ -372,7 +373,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -727,7 +935,8 @@
@@ -727,7 +936,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@@ -382,7 +383,7 @@
}
}
@@ -777,18 +986,20 @@
@@ -777,18 +987,20 @@
}
private boolean isPvpAllowed() {
@@ -406,7 +407,7 @@
} else {
return shapedetectorshape;
}
@@ -797,11 +1008,20 @@
@@ -797,11 +1009,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@@ -430,7 +431,7 @@
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -812,6 +1032,8 @@
@@ -812,6 +1033,8 @@
return this;
} else {
@@ -439,7 +440,7 @@
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation()));
@@ -821,20 +1043,50 @@
@@ -821,20 +1044,50 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@@ -463,7 +464,7 @@
+ return null;
+ }
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = (worldserver == null) ? null : new Location(worldserver.getWorld(), shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(shapedetectorshape.pos, worldserver.getWorld(), shapedetectorshape.yRot, shapedetectorshape.xRot);
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, cause);
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
@@ -495,7 +496,7 @@
this.connection.resetPosition();
worldserver.addDuringPortalTeleport(this);
worldserver1.getProfiler().pop();
@@ -854,39 +1106,66 @@
@@ -854,39 +1107,66 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -514,7 +515,7 @@
+ @Override
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.x(), exitPosition.y(), exitPosition.z(), getYRot(), getXRot());
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld(), getYRot(), getXRot());
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) {
@@ -568,7 +569,7 @@
}
return optional1;
@@ -896,13 +1175,21 @@
@@ -896,13 +1176,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
@@ -593,7 +594,7 @@
this.enteredNetherPosition = null;
}
@@ -919,19 +1206,17 @@
@@ -919,19 +1207,17 @@
this.containerMenu.broadcastChanges();
}
@@ -617,7 +618,7 @@
if (this.level.isDay()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
} else {
@@ -948,7 +1233,36 @@
@@ -948,7 +1234,36 @@
}
}
@@ -655,7 +656,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -961,9 +1275,8 @@
@@ -961,9 +1276,8 @@
return either;
}
}
@@ -666,7 +667,7 @@
}
@Override
@@ -990,6 +1303,24 @@
@@ -990,6 +1304,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@@ -691,7 +692,7 @@
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1038,8 +1369,9 @@
@@ -1038,8 +1370,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
}
@@ -702,7 +703,7 @@
}
@Override
@@ -1047,13 +1379,35 @@
@@ -1047,13 +1380,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@@ -738,7 +739,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1061,9 +1415,11 @@
@@ -1061,9 +1416,11 @@
return OptionalInt.empty();
} else {
@@ -752,7 +753,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1076,13 +1432,24 @@
@@ -1076,13 +1433,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -779,7 +780,7 @@
this.initMenu(this.containerMenu);
}
@@ -1105,6 +1472,7 @@
@@ -1105,6 +1473,7 @@
@Override
public void closeContainer() {
@@ -787,7 +788,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1127,6 +1495,16 @@
@@ -1127,6 +1496,16 @@
}
this.jumping = flag;
@@ -804,7 +805,7 @@
this.setShiftKeyDown(flag1);
}
@@ -1135,7 +1513,7 @@
@@ -1135,7 +1514,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@@ -813,7 +814,7 @@
scoreboardscore.add(i);
});
}
@@ -1143,7 +1521,7 @@
@@ -1143,7 +1522,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@@ -822,7 +823,7 @@
}
@Override
@@ -1159,7 +1537,7 @@
@@ -1159,7 +1538,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@@ -831,7 +832,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1194,6 +1572,7 @@
@@ -1194,6 +1573,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@@ -839,7 +840,7 @@
}
@Override
@@ -1252,7 +1631,7 @@
@@ -1252,7 +1632,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -848,7 +849,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1302,6 +1681,12 @@
@@ -1302,6 +1682,12 @@
@Override
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
@@ -861,7 +862,7 @@
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
@@ -1311,9 +1696,9 @@
@@ -1311,9 +1697,9 @@
}
if (worldserver == this.level) {
@@ -873,7 +874,7 @@
}
this.setYHeadRot(f);
@@ -1417,7 +1802,20 @@
@@ -1417,7 +1803,20 @@
}
}
@@ -894,7 +895,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1492,7 +1890,7 @@
@@ -1492,7 +1891,7 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
@@ -903,7 +904,7 @@
}
if (entity != null) {
@@ -1529,7 +1927,7 @@
@@ -1529,7 +1928,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@@ -912,7 +913,7 @@
}
@Override
@@ -1550,9 +1948,16 @@
@@ -1550,9 +1949,16 @@
return this.advancements;
}
@@ -929,7 +930,7 @@
if (worldserver == this.level) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1572,6 +1977,9 @@
@@ -1572,6 +1978,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@@ -939,7 +940,7 @@
}
@@ -1593,6 +2001,32 @@
@@ -1593,6 +2002,32 @@
}
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
@@ -949,7 +950,7 @@
+
+ public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) {
+ WorldServer newWorld = this.server.getLevel(resourcekey);
+ Location newSpawn = (blockposition != null) ? new Location(newWorld.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ(), f, 0) : null;
+ Location newSpawn = (blockposition != null) ? CraftLocation.toBukkit(blockposition, newWorld.getWorld(), f, 0) : null;
+
+ PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, flag, cause);
+ Bukkit.getServer().getPluginManager().callEvent(event);
@@ -972,7 +973,7 @@
if (blockposition != null) {
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
@@ -1762,4 +2196,146 @@
@@ -1762,4 +2197,146 @@
this.hurtDir = (float) (MathHelper.atan2(d1, d0) * 57.2957763671875D - (double) this.getYRot());
this.connection.send(new ClientboundHurtAnimationPacket(this));
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java
@@ -184,6 +184,68 @@
@@ -184,6 +184,69 @@
import net.minecraft.world.phys.shapes.VoxelShapes;
import org.slf4j.Logger;
@@ -29,6 +29,7 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
+import org.bukkit.craftbukkit.util.Waitable;
@@ -69,7 +70,7 @@
public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn {
static final Logger LOGGER = LogUtils.getLogger();
@@ -200,7 +262,9 @@
@@ -200,7 +263,9 @@
private long keepAliveTime;
private boolean keepAlivePending;
private long keepAliveChallenge;
@@ -80,7 +81,7 @@
private int dropSpamTickCount;
private double firstGoodX;
private double firstGoodY;
@@ -246,8 +310,31 @@
@@ -246,8 +311,31 @@
this.keepAliveTime = SystemUtils.getMillis();
entityplayer.getTextFilter().join();
this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID());
@@ -113,7 +114,7 @@
@Override
public void tick() {
@@ -302,7 +389,7 @@
@@ -302,7 +390,7 @@
this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis();
@@ -122,7 +123,7 @@
if (this.keepAlivePending) {
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
} else {
@@ -314,15 +401,21 @@
@@ -314,15 +402,21 @@
}
this.server.getProfiler().pop();
@@ -144,7 +145,7 @@
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
}
@@ -346,16 +439,67 @@
@@ -346,16 +440,67 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile());
}
@@ -213,7 +214,7 @@
}
private <T, R> CompletableFuture<R> filterTextPacket(T t0, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -419,7 +563,34 @@
@@ -419,7 +564,34 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@@ -249,7 +250,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new PacketPlayOutVehicleMove(entity));
return;
@@ -451,14 +622,72 @@
@@ -451,14 +623,72 @@
}
entity.absMoveTo(d3, d4, d5, f, f1);
@@ -322,7 +323,7 @@
this.player.getLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
@@ -492,6 +721,7 @@
@@ -492,6 +722,7 @@
}
this.awaitingPositionFromClient = null;
@@ -330,7 +331,7 @@
}
}
@@ -499,7 +729,7 @@
@@ -499,7 +730,7 @@
@Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
@@ -339,7 +340,7 @@
RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver);
@@ -529,6 +759,12 @@
@@ -529,6 +760,12 @@
@Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
@@ -352,7 +353,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -538,6 +774,7 @@
@@ -538,6 +775,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@@ -360,7 +361,7 @@
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
});
}
@@ -787,6 +1024,13 @@
@@ -787,6 +1025,13 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@@ -374,7 +375,7 @@
if (!containermerchant.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
@@ -801,6 +1045,13 @@
@@ -801,6 +1046,13 @@
@Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@@ -388,7 +389,7 @@
int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -809,7 +1060,7 @@
@@ -809,7 +1061,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -397,7 +398,7 @@
Objects.requireNonNull(list);
stream.forEach(list::add);
@@ -827,7 +1078,7 @@
@@ -827,7 +1079,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) {
@@ -406,7 +407,7 @@
}
}
@@ -852,16 +1103,16 @@
@@ -852,16 +1104,16 @@
this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
@@ -427,7 +428,7 @@
return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
});
@@ -887,6 +1138,7 @@
@@ -887,6 +1139,7 @@
}
itemstack.addTagElement("pages", nbttaglist);
@@ -435,7 +436,7 @@
}
@Override
@@ -923,7 +1175,7 @@
@@ -923,7 +1176,7 @@
} else {
WorldServer worldserver = this.player.getLevel();
@@ -444,7 +445,7 @@
if (this.tickCount == 0) {
this.resetPosition();
}
@@ -933,7 +1185,7 @@
@@ -933,7 +1186,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@@ -453,7 +454,7 @@
} else {
this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -945,7 +1197,15 @@
@@ -945,7 +1198,15 @@
if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.getLevel().getChunkSource().move(this.player);
@@ -469,7 +470,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -965,15 +1225,33 @@
@@ -965,15 +1226,33 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@@ -505,7 +506,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -994,6 +1272,7 @@
@@ -994,6 +1273,7 @@
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@@ -513,7 +514,7 @@
double d12 = d8;
d7 = d0 - this.player.getX();
@@ -1013,9 +1292,72 @@
@@ -1013,9 +1293,72 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
@@ -587,7 +588,7 @@
this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
this.player.getLevel().getChunkSource().move(this.player);
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
@@ -1054,11 +1396,68 @@
@@ -1054,11 +1397,68 @@
return true;
}
@@ -657,7 +658,7 @@
double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D;
double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D;
double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D;
@@ -1070,6 +1469,14 @@
@@ -1070,6 +1470,14 @@
this.awaitingTeleport = 0;
}
@@ -672,7 +673,7 @@
this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
@@ -1078,6 +1485,7 @@
@@ -1078,6 +1486,7 @@
@Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
@@ -680,7 +681,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime();
@@ -1088,14 +1496,46 @@
@@ -1088,14 +1497,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@@ -729,7 +730,7 @@
this.player.drop(false);
}
@@ -1133,6 +1573,7 @@
@@ -1133,6 +1574,7 @@
@Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
@@ -737,7 +738,7 @@
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinuseitem.getHand();
@@ -1156,6 +1597,7 @@
@@ -1156,6 +1598,7 @@
if (blockposition.getY() < i) {
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
@@ -745,7 +746,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
@@ -1184,6 +1626,7 @@
@@ -1184,6 +1627,7 @@
@Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
@@ -753,7 +754,7 @@
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinblockplace.getHand();
@@ -1191,6 +1634,49 @@
@@ -1191,6 +1635,49 @@
this.player.resetLastActionTime();
if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) {
@@ -803,7 +804,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) {
@@ -1211,7 +1697,7 @@
@@ -1211,7 +1698,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) {
@@ -812,7 +813,7 @@
return;
}
}
@@ -1226,6 +1712,7 @@
@@ -1226,6 +1713,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
@@ -820,7 +821,7 @@
}
@@ -1247,12 +1734,27 @@
@@ -1247,12 +1735,27 @@
@Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@@ -849,7 +850,7 @@
this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1275,6 +1777,15 @@
@@ -1275,6 +1778,15 @@
}
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
@@ -858,14 +859,14 @@
+ return;
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
+ this.player.compassTarget = new Location(this.getCraftPlayer().getWorld(), packet6.pos.getX(), packet6.pos.getY(), packet6.pos.getZ());
+ this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
+ }
+ // CraftBukkit end
+
try {
this.connection.send(packet, packetsendlistener);
} catch (Throwable throwable) {
@@ -1291,7 +1802,16 @@
@@ -1291,7 +1803,16 @@
@Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
@@ -882,7 +883,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1300,18 +1820,25 @@
@@ -1300,18 +1821,25 @@
this.player.resetLastActionTime();
} else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@@ -909,7 +910,7 @@
PlayerChatMessage playerchatmessage;
try {
@@ -1329,9 +1856,9 @@
@@ -1329,9 +1857,9 @@
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask());
this.broadcastChatMessage(playerchatmessage1);
@@ -921,7 +922,7 @@
}
}
@@ -1355,12 +1882,25 @@
@@ -1355,12 +1883,25 @@
}
private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) {
@@ -949,7 +950,7 @@
} catch (SignedMessageChain.a signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a);
return;
@@ -1368,10 +1908,10 @@
@@ -1368,10 +1909,10 @@
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
@@ -962,7 +963,7 @@
}
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
@@ -1412,7 +1952,7 @@
@@ -1412,7 +1953,7 @@
} else {
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(lastseenmessages_b);
@@ -971,7 +972,7 @@
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
return Optional.empty();
} else {
@@ -1460,6 +2000,122 @@
@@ -1460,6 +2001,122 @@
return false;
}
@@ -1094,7 +1095,7 @@
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
@@ -1467,13 +2123,33 @@
@@ -1467,13 +2124,33 @@
}
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
@@ -1131,7 +1132,7 @@
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
}
@@ -1495,13 +2171,59 @@
@@ -1495,13 +2172,59 @@
@Override
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.getLevel());
@@ -1191,7 +1192,7 @@
this.player.resetLastActionTime();
Entity entity;
IJumpable ijumpable;
@@ -1583,6 +2305,12 @@
@@ -1583,6 +2306,12 @@
}
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
@@ -1204,7 +1205,7 @@
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level.registryAccess())));
this.addPendingMessage(playerchatmessage);
}
@@ -1598,6 +2326,7 @@
@@ -1598,6 +2327,7 @@
@Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
@@ -1212,7 +1213,7 @@
final WorldServer worldserver = this.player.getLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1612,13 +2341,51 @@
@@ -1612,13 +2342,51 @@
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
@@ -1265,7 +1266,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
if (enuminteractionresult.shouldSwing()) {
@@ -1631,23 +2398,29 @@
@@ -1631,23 +2399,29 @@
@Override
public void onInteraction(EnumHand enumhand) {
@@ -1298,7 +1299,7 @@
}
} else {
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
@@ -1670,14 +2443,14 @@
@@ -1670,14 +2444,14 @@
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
@@ -1315,7 +1316,7 @@
if (this.server.isHardcore()) {
this.player.setGameMode(EnumGamemode.SPECTATOR);
((GameRules.GameRuleBoolean) this.player.getLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
@@ -1693,15 +2466,21 @@
@@ -1693,15 +2467,21 @@
@Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
@@ -1339,7 +1340,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1714,7 +2493,284 @@
@@ -1714,7 +2494,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@@ -1625,7 +1626,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1754,6 +2810,7 @@
@@ -1754,6 +2811,7 @@
@Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
@@ -1633,7 +1634,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1796,6 +2853,43 @@
@@ -1796,6 +2854,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@@ -1677,7 +1678,7 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
@@ -1818,6 +2912,7 @@
@@ -1818,6 +2913,7 @@
}
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
@@ -1685,7 +1686,7 @@
this.player.resetLastActionTime();
WorldServer worldserver = this.player.getLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1834,18 +2929,37 @@
@@ -1834,18 +2930,37 @@
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
@@ -1725,7 +1726,7 @@
tileentitysign.setChanged();
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -1855,6 +2969,7 @@
@@ -1855,6 +2970,7 @@
@Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
@@ -1733,7 +1734,7 @@
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1869,7 +2984,17 @@
@@ -1869,7 +2985,17 @@
@Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
@@ -1752,7 +1753,7 @@
}
@Override
@@ -1878,8 +3003,50 @@
@@ -1878,8 +3004,50 @@
this.player.updateOptions(packetplayinsettings);
}

View File

@@ -1,13 +1,11 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -108,6 +108,27 @@
@@ -108,6 +108,26 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.util.stream.Collectors;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.syncher.DataWatcher;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.network.LoginListener;
+import org.bukkit.Location;
@@ -15,6 +13,7 @@
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
@@ -28,7 +27,7 @@
public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -119,14 +140,16 @@
@@ -119,14 +139,16 @@
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server;
@@ -48,7 +47,7 @@
public final WorldNBTStorage playerIo;
private boolean doWhiteList;
private final LayeredRegistryAccess<RegistryLayer> registries;
@@ -138,13 +161,23 @@
@@ -138,13 +160,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@@ -74,7 +73,7 @@
this.server = minecraftserver;
this.registries = layeredregistryaccess;
this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze();
@@ -161,9 +194,15 @@
@@ -161,9 +193,15 @@
usercache.add(gameprofile);
NBTTagCompound nbttagcompound = this.load(entityplayer);
ResourceKey resourcekey;
@@ -91,7 +90,7 @@
Logger logger = PlayerList.LOGGER;
Objects.requireNonNull(logger);
@@ -190,7 +229,8 @@
@@ -190,7 +228,8 @@
s1 = networkmanager.getRemoteAddress().toString();
}
@@ -101,7 +100,7 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer.loadGameTypes(nbttagcompound);
@@ -200,6 +240,7 @@
@@ -200,6 +239,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation()));
@@ -109,7 +108,7 @@
playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures())));
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
@@ -219,8 +260,10 @@
@@ -219,8 +259,10 @@
} else {
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
}
@@ -121,7 +120,7 @@
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
ServerPing serverping = this.server.getStatus();
@@ -231,10 +274,61 @@
@@ -231,10 +273,61 @@
entityplayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players));
this.players.add(entityplayer);
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
@@ -186,7 +185,7 @@
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
});
@@ -248,8 +342,11 @@
@@ -248,8 +341,11 @@
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@@ -200,7 +199,7 @@
});
if (entity != null) {
@@ -292,6 +389,8 @@
@@ -292,6 +388,8 @@
}
entityplayer.initInventoryMenu();
@@ -209,7 +208,7 @@
}
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -324,30 +423,31 @@
@@ -324,30 +422,31 @@
}
public void addWorldborderListener(WorldServer worldserver) {
@@ -246,7 +245,7 @@
}
@Override
@@ -375,14 +475,15 @@
@@ -375,14 +474,15 @@
}
protected void save(EntityPlayer entityplayer) {
@@ -264,7 +263,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -390,10 +491,24 @@
@@ -390,10 +490,24 @@
}
@@ -290,7 +289,7 @@
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -417,18 +532,66 @@
@@ -417,18 +531,66 @@
if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid);
@@ -363,7 +362,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -436,10 +599,12 @@
@@ -436,10 +598,12 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
}
@@ -379,7 +378,7 @@
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -447,13 +612,25 @@
@@ -447,13 +611,25 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
}
@@ -408,7 +407,7 @@
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
List<EntityPlayer> list = Lists.newArrayList();
@@ -480,14 +657,24 @@
@@ -480,14 +656,24 @@
}
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
@@ -434,7 +433,7 @@
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
Optional optional;
@@ -499,6 +686,11 @@
@@ -499,6 +685,11 @@
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
@@ -446,7 +445,7 @@
entityplayer1.connection = entityplayer.connection;
entityplayer1.restoreFrom(entityplayer, flag);
@@ -514,50 +706,112 @@
@@ -514,50 +705,112 @@
boolean flag2 = false;
@@ -489,7 +488,7 @@
+ // entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false); // CraftBukkit - not required, just copies old location into reused entity
+ flag2 = !flag && flag3;
+ isBedSpawn = true;
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
+ location = CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f1, 0.0F);
+ } else if (blockposition != null) {
+ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
@@ -500,7 +499,7 @@
+ if (location == null) {
+ worldserver1 = this.server.getLevel(World.OVERWORLD);
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
+ location = CraftLocation.toBukkit(blockposition, worldserver1.getWorld()).add(0.5F, 0.1F, 0.5F);
}
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
@@ -533,7 +532,7 @@
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation()));
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.unsetRemoved();
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot()));
+ entityplayer1.setShiftKeyDown(false);
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), (byte) i, entityplayer1.getLastDeathLocation()));
@@ -582,7 +581,7 @@
return entityplayer1;
}
@@ -570,7 +824,18 @@
@@ -570,7 +823,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@@ -602,7 +601,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -587,6 +852,25 @@
@@ -587,6 +851,25 @@
}
@@ -628,7 +627,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -665,7 +949,7 @@
@@ -665,7 +948,7 @@
}
public void deop(GameProfile gameprofile) {
@@ -637,7 +636,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -689,6 +973,7 @@
@@ -689,6 +972,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@@ -645,7 +644,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -721,6 +1006,12 @@
@@ -721,6 +1005,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@@ -658,7 +657,7 @@
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -760,23 +1051,35 @@
@@ -760,23 +1050,35 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -699,7 +698,7 @@
}
public int getPlayerCount() {
@@ -832,12 +1135,22 @@
@@ -832,12 +1134,22 @@
}
public void removeAll() {
@@ -724,7 +723,7 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -895,16 +1208,23 @@
@@ -895,16 +1207,23 @@
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
}
@@ -752,7 +751,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -913,7 +1233,7 @@
@@ -913,7 +1232,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@@ -761,7 +760,7 @@
}
return serverstatisticmanager;
@@ -921,13 +1241,13 @@
@@ -921,13 +1240,13 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@@ -777,7 +776,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -978,13 +1298,20 @@
@@ -978,13 +1297,20 @@
}
public void reloadResources() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -124,8 +124,65 @@
@@ -124,8 +124,66 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@@ -25,6 +25,7 @@
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.Pose;
+import org.bukkit.event.entity.EntityAirChangeEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
@@ -66,7 +67,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -236,6 +293,25 @@
@@ -236,6 +294,25 @@
public boolean hasVisualFire;
@Nullable
private IBlockData feetBlockState;
@@ -92,7 +93,7 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -367,6 +443,12 @@
@@ -367,6 +444,12 @@
public void onClientRemoval() {}
public void setPose(EntityPose entitypose) {
@@ -105,7 +106,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -391,6 +473,33 @@
@@ -391,6 +474,33 @@
}
protected void setRot(float f, float f1) {
@@ -139,7 +140,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -432,6 +541,15 @@
@@ -432,6 +542,15 @@
this.baseTick();
}
@@ -155,7 +156,7 @@
public void baseTick() {
this.level.getProfiler().push("entityBaseTick");
this.feetBlockState = null;
@@ -446,7 +564,7 @@
@@ -446,7 +565,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@@ -164,7 +165,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -481,6 +599,10 @@
@@ -481,6 +600,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@@ -175,7 +176,7 @@
}
this.checkOutOfWorld();
@@ -524,15 +646,48 @@
@@ -524,15 +647,48 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@@ -225,7 +226,7 @@
int j = i * 20;
if (this instanceof EntityLiving) {
@@ -646,6 +801,28 @@
@@ -646,6 +802,28 @@
block.updateEntityAfterFallOn(this.level, this);
}
@@ -254,7 +255,7 @@
if (this.onGround) {
block.stepOn(this.level, blockposition, iblockdata, this);
}
@@ -948,6 +1125,20 @@
@@ -948,6 +1126,20 @@
return SoundEffects.GENERIC_SPLASH;
}
@@ -275,7 +276,7 @@
protected void checkInsideBlocks() {
AxisAlignedBB axisalignedbb = this.getBoundingBox();
BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D);
@@ -1311,6 +1502,7 @@
@@ -1311,6 +1503,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@@ -283,7 +284,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1505,6 +1697,12 @@
@@ -1505,6 +1698,12 @@
return false;
}
@@ -296,7 +297,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1538,7 +1736,7 @@
@@ -1538,7 +1737,7 @@
} else {
String s = this.getEncodeId();
@@ -305,7 +306,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1563,6 +1761,18 @@
@@ -1563,6 +1762,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@@ -324,7 +325,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1571,6 +1781,25 @@
@@ -1571,6 +1782,25 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@@ -350,7 +351,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1638,6 +1867,11 @@
@@ -1638,6 +1868,11 @@
}
}
@@ -362,7 +363,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1721,6 +1955,45 @@
@@ -1721,6 +1956,45 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@@ -408,7 +409,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1796,9 +2069,22 @@
@@ -1796,9 +2070,22 @@
} else if (this.level.isClientSide) {
return null;
} else {
@@ -431,7 +432,7 @@
this.level.addFreshEntity(entityitem);
return entityitem;
}
@@ -1894,7 +2180,7 @@
@@ -1894,7 +2181,7 @@
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@@ -440,7 +441,7 @@
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -1925,7 +2211,7 @@
@@ -1925,7 +2212,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@@ -449,7 +450,7 @@
}
}
@@ -1934,10 +2220,31 @@
@@ -1934,10 +2221,31 @@
this.removeVehicle();
}
@@ -482,7 +483,7 @@
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -1954,12 +2261,32 @@
@@ -1954,12 +2262,32 @@
this.gameEvent(GameEvent.ENTITY_MOUNT, entity);
}
@@ -516,7 +517,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -1971,6 +2298,7 @@
@@ -1971,6 +2299,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@@ -524,7 +525,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2037,14 +2365,20 @@
@@ -2037,14 +2366,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@@ -548,7 +549,7 @@
this.level.getProfiler().pop();
}
@@ -2164,6 +2498,13 @@
@@ -2164,6 +2499,13 @@
}
public void setSwimming(boolean flag) {
@@ -562,7 +563,7 @@
this.setSharedFlag(4, flag);
}
@@ -2209,8 +2550,12 @@
@@ -2209,8 +2551,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@@ -576,7 +577,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2229,7 +2574,7 @@
@@ -2229,7 +2575,7 @@
}
public int getMaxAirSupply() {
@@ -585,7 +586,7 @@
}
public int getAirSupply() {
@@ -2237,7 +2582,18 @@
@@ -2237,7 +2583,18 @@
}
public void setAirSupply(int i) {
@@ -605,7 +606,7 @@
}
public int getTicksFrozen() {
@@ -2264,11 +2620,41 @@
@@ -2264,11 +2621,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -649,7 +650,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2433,15 +2819,38 @@
@@ -2433,15 +2820,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@@ -690,7 +691,7 @@
this.level.getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2450,9 +2859,17 @@
@@ -2450,9 +2860,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@@ -710,7 +711,7 @@
}
this.removeAfterChangingDimensions();
@@ -2473,20 +2890,34 @@
@@ -2473,20 +2891,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@@ -750,7 +751,7 @@
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2503,8 +2934,8 @@
@@ -2503,8 +2935,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@@ -761,7 +762,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2514,8 +2945,14 @@
@@ -2514,8 +2946,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@@ -777,7 +778,7 @@
}
}
@@ -2523,8 +2960,23 @@
@@ -2523,8 +2961,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@@ -787,7 +788,7 @@
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
+ Location enter = bukkitEntity.getLocation();
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.x(), exitPosition.y(), exitPosition.z());
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld());
+
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
@@ -803,7 +804,7 @@
}
public boolean canChangeDimensions() {
@@ -2644,6 +3096,12 @@
@@ -2644,6 +3097,12 @@
}
}
@@ -816,7 +817,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2773,7 +3231,26 @@
@@ -2773,7 +3232,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@@ -844,7 +845,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3084,6 +3561,11 @@
@@ -3084,6 +3562,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View File

@@ -5,8 +5,8 @@
import org.joml.Vector3f;
+// CraftBukkit start
+import net.minecraft.server.level.WorldServer;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
@@ -18,7 +18,7 @@
if (enumdirection != null) {
+ // CraftBukkit start
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.level.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()));
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), CraftLocation.toBukkit(blockposition1, this.level.getWorld()));
+ this.level.getCraftServer().getPluginManager().callEvent(teleport);
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();

View File

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/entity/vehicle/EntityBoat.java
+++ b/net/minecraft/world/entity/vehicle/EntityBoat.java
@@ -53,6 +53,15 @@
@@ -53,6 +53,16 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
@@ -16,7 +17,7 @@
public class EntityBoat extends Entity implements VariantHolder<EntityBoat.EnumBoatType> {
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityBoat.class, DataWatcherRegistry.INT);
@@ -93,6 +102,14 @@
@@ -93,6 +103,14 @@
private float bubbleAngle;
private float bubbleAngleO;
@@ -31,7 +32,7 @@
public EntityBoat(EntityTypes<? extends EntityBoat> entitytypes, World world) {
super(entitytypes, world);
this.paddlePositions = new float[2];
@@ -162,6 +179,19 @@
@@ -162,6 +180,19 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else if (!this.level.isClientSide && !this.isRemoved()) {
@@ -51,7 +52,7 @@
this.setHurtDir(-this.getHurtDir());
this.setHurtTime(10);
this.setDamage(this.getDamage() + f * 10.0F);
@@ -170,6 +200,15 @@
@@ -170,6 +201,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
@@ -67,7 +68,7 @@
if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.destroy(damagesource);
}
@@ -209,9 +248,29 @@
@@ -209,9 +249,29 @@
public void push(Entity entity) {
if (entity instanceof EntityBoat) {
if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) {
@@ -97,7 +98,7 @@
super.push(entity);
}
@@ -279,6 +338,7 @@
@@ -279,6 +339,7 @@
return this.getDirection().getClockWise();
}
@@ -105,7 +106,7 @@
@Override
public void tick() {
this.oldStatus = this.status;
@@ -319,6 +379,22 @@
@@ -319,6 +380,22 @@
this.setDeltaMovement(Vec3D.ZERO);
}
@@ -113,7 +114,7 @@
+ org.bukkit.Server server = this.level.getCraftServer();
+ org.bukkit.World bworld = this.level.getWorld();
+
+ Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
@@ -128,7 +129,7 @@
this.tickBubbleColumn();
for (int i = 0; i <= 1; ++i) {
@@ -830,6 +906,11 @@
@@ -830,6 +907,11 @@
this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall());
if (!this.level.isClientSide && !this.isRemoved()) {
@@ -140,7 +141,7 @@
this.kill();
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
int i;
@@ -843,6 +924,7 @@
@@ -843,6 +925,7 @@
}
}
}

View File

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
@@ -47,6 +47,15 @@
@@ -47,6 +47,16 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
@@ -16,7 +17,7 @@
public abstract class EntityMinecartAbstract extends Entity {
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityMinecartAbstract.class, DataWatcherRegistry.INT);
@@ -89,6 +98,17 @@
@@ -89,6 +99,17 @@
private double lyd;
private double lzd;
@@ -34,7 +35,7 @@
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.blocksBuilding = true;
@@ -215,6 +235,19 @@
@@ -215,6 +236,19 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
@@ -54,7 +55,7 @@
this.setHurtDir(-this.getHurtDir());
this.setHurtTime(10);
this.markHurt();
@@ -223,6 +256,15 @@
@@ -223,6 +257,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
@@ -70,7 +71,7 @@
this.ejectPassengers();
if (flag && !this.hasCustomName()) {
this.discard();
@@ -284,6 +326,14 @@
@@ -284,6 +327,14 @@
@Override
public void tick() {
@@ -85,7 +86,7 @@
if (this.getHurtTime() > 0) {
this.setHurtTime(this.getHurtTime() - 1);
}
@@ -293,7 +343,7 @@
@@ -293,7 +344,7 @@
}
this.checkOutOfWorld();
@@ -94,14 +95,14 @@
double d0;
if (this.level.isClientSide) {
@@ -359,6 +409,18 @@
@@ -359,6 +410,18 @@
}
this.setRot(this.getYRot(), this.getXRot());
+ // CraftBukkit start
+ org.bukkit.World bworld = this.level.getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
@@ -113,7 +114,7 @@
if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this));
@@ -367,8 +429,26 @@
@@ -367,8 +430,26 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
@@ -140,7 +141,7 @@
entity.push(this);
}
}
@@ -380,6 +460,14 @@
@@ -380,6 +461,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
@@ -155,7 +156,7 @@
entity1.push(this);
}
}
@@ -396,7 +484,7 @@
@@ -396,7 +485,7 @@
}
protected double getMaxSpeed() {
@@ -164,7 +165,7 @@
}
public void activateMinecart(int i, int j, int k, boolean flag) {}
@@ -407,12 +495,16 @@
@@ -407,12 +496,16 @@
this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0));
if (this.onGround) {
@@ -183,7 +184,7 @@
}
}
@@ -603,7 +695,7 @@
@@ -603,7 +696,7 @@
}
protected void applyNaturalSlowdown() {
@@ -192,7 +193,7 @@
Vec3D vec3d = this.getDeltaMovement();
vec3d = vec3d.multiply(d0, 0.0D, d0);
@@ -742,6 +834,14 @@
@@ -742,6 +835,14 @@
if (!this.level.isClientSide) {
if (!entity.noPhysics && !this.noPhysics) {
if (!this.hasPassenger(entity)) {
@@ -207,7 +208,7 @@
double d0 = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ();
double d2 = d0 * d0 + d1 * d1;
@@ -916,4 +1016,26 @@
@@ -916,4 +1017,26 @@
private EnumMinecartType() {}
}

View File

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/inventory/InventoryEnderChest.java
+++ b/net/minecraft/world/inventory/InventoryEnderChest.java
@@ -8,13 +8,31 @@
@@ -8,13 +8,32 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.TileEntityEnderChest;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
@@ -22,7 +23,7 @@
+
+ @Override
+ public Location getLocation() {
+ return this.activeChest != null ? new Location(this.activeChest.getLevel().getWorld(), this.activeChest.getBlockPos().getX(), this.activeChest.getBlockPos().getY(), this.activeChest.getBlockPos().getZ()) : null;
+ return this.activeChest != null ? CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel().getWorld()) : null;
+ }
- public InventoryEnderChest() {

View File

@@ -6,7 +6,6 @@
+// CraftBukkit start
+import com.mojang.serialization.Dynamic;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import net.minecraft.core.EnumDirection;
@@ -33,6 +32,7 @@
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.entity.Player;
+import org.bukkit.event.block.BlockFertilizeEvent;
@@ -122,7 +122,7 @@
+ world.captureBlockStates = false;
+ if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) {
+ world.captureTreeGeneration = false;
+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ Location location = CraftLocation.toBukkit(blockposition, world.getWorld());
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ List<CraftBlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());

View File

@@ -97,7 +97,7 @@
+
+ List<org.bukkit.block.Block> blockList = new ObjectArrayList<>();
+ for (int i1 = this.toBlow.size() - 1; i1 >= 0; i1--) {
+ BlockPosition cpos = (BlockPosition) this.toBlow.get(i1);
+ BlockPosition cpos = this.toBlow.get(i1);
+ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ());
+ if (!bblock.getType().isAir()) {
+ blockList.add(bblock);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/BlockSapling.java
+++ b/net/minecraft/world/level/block/BlockSapling.java
@@ -15,12 +15,20 @@
@@ -15,12 +15,21 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
@@ -8,6 +8,7 @@
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
+
@@ -21,7 +22,7 @@
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
super(blockbase_info);
@@ -45,7 +53,32 @@
@@ -45,7 +54,32 @@
if ((Integer) iblockdata.getValue(BlockSapling.STAGE) == 0) {
worldserver.setBlock(blockposition, (IBlockData) iblockdata.cycle(BlockSapling.STAGE), 4);
} else {
@@ -36,7 +37,7 @@
+ if (worldserver.capturedBlockStates.size() > 0) {
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ Location location = CraftLocation.toBukkit(blockposition, worldserver.getWorld());
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
+ worldserver.capturedBlockStates.clear();
+ StructureGrowEvent event = null;

View File

@@ -7,8 +7,8 @@
+// CraftBukkit start
+import net.minecraft.world.level.dimension.WorldDimension;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
@@ -31,7 +31,7 @@
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ if (entity1 instanceof EntityPlayer) {
+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity();
+ org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.5D, (double) blockposition1.getZ() + 0.5D);
+ org.bukkit.Location location = CraftLocation.toBukkit(blockposition1, world.getWorld()).add(0.5D, 0.5D, 0.5D);
+ location.setPitch(player.getLocation().getPitch());
+ location.setYaw(player.getLocation().getYaw());
+

View File

@@ -9,10 +9,10 @@
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import org.bukkit.Location;
+import org.bukkit.block.Lectern;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
@@ -59,7 +59,7 @@
+ @Override
+ public Location getLocation() {
+ if (level == null) return null;
+ return new Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
+ return CraftLocation.toBukkit(worldPosition, level.getWorld());
+ }
+
+ @Override

View File

@@ -7,7 +7,7 @@
+// CraftBukkit start
+import net.minecraft.core.registries.BuiltInRegistries;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.event.world.GenericGameEvent;
+// CraftBukkit end
@@ -20,7 +20,7 @@
int i = gameevent.getNotificationRadius();
BlockPosition blockposition = BlockPosition.containing(vec3d);
+ // CraftBukkit start
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), new Location(level.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.GAME_EVENT.getKey(gameevent))), CraftLocation.toBukkit(blockposition, level.getWorld()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
+ level.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;