@@ -1,19 +1,21 @@
|
||||
--- a/net/minecraft/server/DispenserRegistry.java
|
||||
+++ b/net/minecraft/server/DispenserRegistry.java
|
||||
@@ -29,6 +29,12 @@
|
||||
@@ -30,7 +30,13 @@
|
||||
import net.minecraft.world.level.block.state.BlockBase;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-@SuppressForbidden(a = "System.out setup")
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.util.datafix.fixes.DataConverterFlattenData;
|
||||
+import net.minecraft.util.datafix.fixes.DataConverterMaterialId;
|
||||
+import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
+@SuppressForbidden(reason = "System.out setup")
|
||||
+// CraftBukkit end
|
||||
public class DispenserRegistry {
|
||||
|
||||
public static final PrintStream STDOUT = System.out;
|
||||
@@ -40,6 +46,23 @@
|
||||
@@ -42,6 +48,23 @@
|
||||
|
||||
public static void bootStrap() {
|
||||
if (!DispenserRegistry.isBootstrapped) {
|
||||
@@ -37,7 +39,7 @@
|
||||
DispenserRegistry.isBootstrapped = true;
|
||||
Instant instant = Instant.now();
|
||||
|
||||
@@ -59,6 +82,69 @@
|
||||
@@ -61,6 +84,69 @@
|
||||
wrapStreams();
|
||||
DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -60,6 +60,17 @@
|
||||
@@ -61,16 +61,28 @@
|
||||
import net.minecraft.world.level.storage.WorldInfo;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
public class Main {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -67,8 +78,9 @@
|
||||
|
||||
public Main() {}
|
||||
|
||||
- @SuppressForbidden(a = "System.out needed before bootstrap")
|
||||
+ @SuppressForbidden(reason = "System.out needed before bootstrap") // CraftBukkit - decompile error
|
||||
@DontObfuscate
|
||||
- public static void main(String[] astring) {
|
||||
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
|
||||
@@ -29,7 +31,7 @@
|
||||
OptionParser optionparser = new OptionParser();
|
||||
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
|
||||
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
|
||||
@@ -94,15 +106,18 @@
|
||||
@@ -96,15 +108,18 @@
|
||||
optionparser.printHelpOn(System.err);
|
||||
return;
|
||||
}
|
||||
@@ -50,7 +52,7 @@
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
@@ -110,14 +125,27 @@
|
||||
@@ -112,14 +127,27 @@
|
||||
DispenserRegistry.validate();
|
||||
SystemUtils.startTimerHackThread();
|
||||
Path path1 = Paths.get("server.properties");
|
||||
@@ -80,7 +82,7 @@
|
||||
Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
@@ -127,11 +155,13 @@
|
||||
@@ -129,11 +157,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,7 +99,7 @@
|
||||
Dynamic dynamic;
|
||||
|
||||
if (convertable_conversionsession.hasWorldData()) {
|
||||
@@ -172,13 +202,31 @@
|
||||
@@ -174,13 +204,31 @@
|
||||
}
|
||||
|
||||
Dynamic<?> dynamic1 = dynamic;
|
||||
@@ -130,7 +132,7 @@
|
||||
|
||||
WorldStem worldstem;
|
||||
|
||||
@@ -187,6 +235,7 @@
|
||||
@@ -189,6 +237,7 @@
|
||||
|
||||
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
|
||||
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
|
||||
@@ -138,7 +140,7 @@
|
||||
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM);
|
||||
|
||||
if (dynamic1 != null) {
|
||||
@@ -199,7 +248,7 @@
|
||||
@@ -201,7 +250,7 @@
|
||||
WorldOptions worldoptions;
|
||||
WorldDimensions worlddimensions;
|
||||
|
||||
@@ -147,7 +149,7 @@
|
||||
worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
worldoptions = WorldOptions.DEMO_OPTIONS;
|
||||
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
|
||||
@@ -207,7 +256,7 @@
|
||||
@@ -209,7 +258,7 @@
|
||||
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
|
||||
|
||||
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration());
|
||||
@@ -156,7 +158,7 @@
|
||||
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
}
|
||||
|
||||
@@ -223,6 +272,7 @@
|
||||
@@ -225,6 +274,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
|
||||
boolean flag1 = optionset.has(optionspec6);
|
||||
|
||||
@@ -235,20 +285,31 @@
|
||||
@@ -237,20 +287,31 @@
|
||||
SaveData savedata = worldstem.worldData();
|
||||
|
||||
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
|
||||
@@ -198,7 +200,7 @@
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.halt(true);
|
||||
@@ -257,6 +318,7 @@
|
||||
@@ -259,6 +320,7 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@@ -206,7 +208,7 @@
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
|
||||
}
|
||||
@@ -293,7 +355,7 @@
|
||||
@@ -295,7 +357,7 @@
|
||||
}
|
||||
|
||||
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) {
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
- this.forceDifficulty();
|
||||
- this.prepareLevels(worldloadlistener);
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
profiledduration.finish(true);
|
||||
}
|
||||
@@ -387,23 +448,217 @@
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
commandlistenerwrapper.sendSuccess(() -> {
|
||||
@@ -64,12 +75,18 @@
|
||||
commandlistenerwrapper.getServer().forceTimeSynchronization();
|
||||
@@ -65,12 +76,18 @@
|
||||
}
|
||||
|
||||
public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) {
|
||||
@@ -53,4 +53,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
int j = getDayTime(commandlistenerwrapper.getLevel());
|
||||
commandlistenerwrapper.getServer().forceTimeSynchronization();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/level/EntityPlayer.java
|
||||
@@ -184,6 +184,41 @@
|
||||
@@ -183,6 +183,41 @@
|
||||
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
public class EntityPlayer extends EntityHuman {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -227,7 +262,7 @@
|
||||
@@ -225,7 +260,7 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance;
|
||||
@@ -51,7 +51,7 @@
|
||||
@Nullable
|
||||
private Vec3D startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -261,6 +296,22 @@
|
||||
@@ -259,6 +294,22 @@
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
|
||||
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
|
||||
this.chatVisibility = EnumChatVisibility.FULL;
|
||||
@@ -342,6 +393,13 @@
|
||||
@@ -340,6 +391,13 @@
|
||||
public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
|
||||
EntityPlayer.this.sendSystemMessage(ichatbasecomponent);
|
||||
}
|
||||
@@ -88,7 +88,7 @@
|
||||
};
|
||||
this.textFilter = minecraftserver.createTextFilterForPlayer(this);
|
||||
this.gameMode = minecraftserver.createGameModeForPlayer(this);
|
||||
@@ -354,14 +412,67 @@
|
||||
@@ -352,14 +410,67 @@
|
||||
this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
|
||||
this.updateOptions(clientinformation);
|
||||
this.object = null;
|
||||
@@ -157,7 +157,7 @@
|
||||
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -397,14 +508,20 @@
|
||||
@@ -395,14 +506,20 @@
|
||||
|
||||
Objects.requireNonNull(blockposition);
|
||||
crashreportsystemdetails.setDetail("Origin", blockposition::toString);
|
||||
@@ -180,7 +180,7 @@
|
||||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@@ -442,7 +559,7 @@
|
||||
@@ -440,7 +557,7 @@
|
||||
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker")));
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -189,7 +189,7 @@
|
||||
this.wardenSpawnTracker = wardenspawntracker;
|
||||
});
|
||||
}
|
||||
@@ -459,17 +576,26 @@
|
||||
@@ -457,17 +574,26 @@
|
||||
return this.server.getRecipeManager().byKey(resourcekey).isPresent();
|
||||
});
|
||||
}
|
||||
@@ -217,7 +217,7 @@
|
||||
Logger logger1 = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -484,7 +610,7 @@
|
||||
@@ -482,7 +608,7 @@
|
||||
dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -226,7 +226,7 @@
|
||||
this.raidOmenPosition = blockposition;
|
||||
});
|
||||
}
|
||||
@@ -494,7 +620,7 @@
|
||||
@@ -492,7 +618,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@@ -235,7 +235,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -528,6 +654,7 @@
|
||||
@@ -526,6 +652,7 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
@@ -243,7 +243,7 @@
|
||||
|
||||
nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
if (this.raidOmenPosition != null) {
|
||||
@@ -546,7 +673,20 @@
|
||||
@@ -544,7 +671,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
@@ -265,7 +265,7 @@
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
|
||||
@@ -600,12 +740,12 @@
|
||||
@@ -598,12 +738,12 @@
|
||||
|
||||
if (!this.isPassenger()) {
|
||||
EntityPlayer.LOGGER.warn("Couldn't reattach entity to player");
|
||||
@@ -280,7 +280,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,7 +767,7 @@
|
||||
@@ -625,7 +765,7 @@
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
|
||||
entityenderpearl.save(nbttagcompound1);
|
||||
@@ -289,7 +289,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -653,7 +793,7 @@
|
||||
@@ -651,7 +791,7 @@
|
||||
nbttaglist.forEach((nbtbase1) -> {
|
||||
if (nbtbase1 instanceof NBTTagCompound nbttagcompound) {
|
||||
if (nbttagcompound.contains("ender_pearl_dimension")) {
|
||||
@@ -298,7 +298,7 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -688,6 +828,29 @@
|
||||
@@ -686,6 +826,29 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@
|
||||
public void setExperiencePoints(int i) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -746,6 +909,11 @@
|
||||
@@ -744,6 +907,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -337,10 +337,10 @@
|
||||
+ this.joining = false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
--this.spawnInvulnerableTime;
|
||||
@@ -822,7 +990,7 @@
|
||||
@@ -820,7 +988,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@@ -349,7 +349,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -853,6 +1021,12 @@
|
||||
@@ -851,6 +1019,12 @@
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
|
||||
@@ -867,6 +1041,20 @@
|
||||
@@ -865,6 +1039,20 @@
|
||||
CriterionTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -895,7 +1083,7 @@
|
||||
@@ -893,7 +1081,7 @@
|
||||
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (this.tickCount % 20 == 0) {
|
||||
if (this.getHealth() < this.getMaxHealth()) {
|
||||
@@ -392,7 +392,7 @@
|
||||
}
|
||||
|
||||
float f = this.foodData.getSaturationLevel();
|
||||
@@ -948,7 +1136,8 @@
|
||||
@@ -946,7 +1134,8 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
@@ -402,7 +402,7 @@
|
||||
scoreaccess.set(i);
|
||||
});
|
||||
}
|
||||
@@ -957,9 +1146,47 @@
|
||||
@@ -955,9 +1144,47 @@
|
||||
public void die(DamageSource damagesource) {
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
@@ -452,7 +452,7 @@
|
||||
|
||||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
|
||||
boolean flag1 = true;
|
||||
@@ -990,12 +1217,18 @@
|
||||
@@ -988,12 +1215,18 @@
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
@@ -475,10 +475,10 @@
|
||||
EntityLiving entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -1030,10 +1263,12 @@
|
||||
@@ -1028,10 +1261,12 @@
|
||||
public void awardKillScore(Entity entity, DamageSource damagesource) {
|
||||
if (entity != this) {
|
||||
super.awardKillScore(entity, i, damagesource);
|
||||
this.increaseScore(i);
|
||||
super.awardKillScore(entity, damagesource);
|
||||
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment);
|
||||
+ // CraftBukkit - Get our scores instead
|
||||
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment);
|
||||
@@ -490,7 +490,7 @@
|
||||
} else {
|
||||
this.awardStat(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -1051,7 +1286,8 @@
|
||||
@@ -1049,7 +1284,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
@@ -500,7 +500,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1101,10 +1337,16 @@
|
||||
@@ -1093,10 +1329,16 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@@ -519,7 +519,7 @@
|
||||
BlockPosition blockposition = this.getRespawnPosition();
|
||||
float f = this.getRespawnAngle();
|
||||
boolean flag1 = this.isRespawnForced();
|
||||
@@ -1116,13 +1358,32 @@
|
||||
@@ -1108,13 +1350,32 @@
|
||||
if (optional.isPresent()) {
|
||||
EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get();
|
||||
|
||||
@@ -555,7 +555,7 @@
|
||||
}
|
||||
|
||||
public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -1137,11 +1398,11 @@
|
||||
@@ -1129,11 +1390,11 @@
|
||||
}
|
||||
|
||||
return optional.map((vec3d) -> {
|
||||
@@ -569,7 +569,7 @@
|
||||
});
|
||||
} else if (!flag) {
|
||||
return Optional.empty();
|
||||
@@ -1150,7 +1411,7 @@
|
||||
@@ -1142,7 +1403,7 @@
|
||||
IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above());
|
||||
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
|
||||
|
||||
@@ -578,7 +578,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1168,6 +1429,7 @@
|
||||
@@ -1160,6 +1421,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public EntityPlayer teleport(TeleportTransition teleporttransition) {
|
||||
@@ -586,7 +586,7 @@
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -1177,18 +1439,38 @@
|
||||
@@ -1169,18 +1431,38 @@
|
||||
|
||||
WorldServer worldserver = teleporttransition.newLevel();
|
||||
WorldServer worldserver1 = this.serverLevel();
|
||||
@@ -628,7 +628,7 @@
|
||||
this.isChangingDimension = true;
|
||||
WorldData worlddata = worldserver.getLevelData();
|
||||
|
||||
@@ -1199,17 +1481,31 @@
|
||||
@@ -1191,17 +1473,31 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
@@ -662,7 +662,7 @@
|
||||
this.connection.resetPosition();
|
||||
worldserver.addDuringTeleport(this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -1223,11 +1519,29 @@
|
||||
@@ -1215,11 +1511,29 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -692,7 +692,7 @@
|
||||
@Override
|
||||
public void forceSetRotation(float f, float f1) {
|
||||
this.connection.send(new ClientboundPlayerRotationPacket(f, f1));
|
||||
@@ -1236,13 +1550,21 @@
|
||||
@@ -1228,13 +1542,21 @@
|
||||
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
|
||||
ResourceKey<World> resourcekey = worldserver.dimension();
|
||||
ResourceKey<World> resourcekey1 = this.level().dimension();
|
||||
@@ -717,7 +717,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -1259,19 +1581,17 @@
|
||||
@@ -1251,19 +1573,17 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@
|
||||
if (this.level().isDay()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -1288,7 +1608,36 @@
|
||||
@@ -1280,7 +1600,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@
|
||||
this.awardStat(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1301,9 +1650,8 @@
|
||||
@@ -1293,9 +1642,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
@@ -790,7 +790,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1330,13 +1678,31 @@
|
||||
@@ -1322,13 +1670,31 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean flag, boolean flag1) {
|
||||
@@ -823,7 +823,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1403,8 +1769,9 @@
|
||||
@@ -1387,8 +1753,9 @@
|
||||
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1412,13 +1779,35 @@
|
||||
@@ -1396,13 +1763,35 @@
|
||||
if (itileinventory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -870,7 +870,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
|
||||
@@ -1426,9 +1815,11 @@
|
||||
@@ -1410,9 +1799,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -884,7 +884,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1441,15 +1832,26 @@
|
||||
@@ -1425,15 +1816,26 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
@@ -913,7 +913,7 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1472,6 +1874,7 @@
|
||||
@@ -1456,6 +1858,7 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@@ -921,7 +921,7 @@
|
||||
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1501,19 +1904,19 @@
|
||||
@@ -1485,19 +1888,19 @@
|
||||
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(StatisticList.SWIM_ONE_CM, i);
|
||||
@@ -944,7 +944,7 @@
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (d1 > 0.0D) {
|
||||
@@ -1524,13 +1927,13 @@
|
||||
@@ -1508,13 +1911,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
|
||||
@@ -961,7 +961,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1573,7 +1976,7 @@
|
||||
@@ -1557,7 +1960,7 @@
|
||||
@Override
|
||||
public void awardStat(Statistic<?> statistic, int i) {
|
||||
this.stats.increment(this, statistic, i);
|
||||
@@ -970,7 +970,7 @@
|
||||
scoreaccess.add(i);
|
||||
});
|
||||
}
|
||||
@@ -1581,7 +1984,7 @@
|
||||
@@ -1565,7 +1968,7 @@
|
||||
@Override
|
||||
public void resetStat(Statistic<?> statistic) {
|
||||
this.stats.setValue(this, statistic, 0);
|
||||
@@ -979,7 +979,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1613,9 +2016,9 @@
|
||||
@@ -1597,9 +2000,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(StatisticList.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
@@ -991,7 +991,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1641,6 +2044,7 @@
|
||||
@@ -1625,6 +2028,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -999,7 +999,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1677,7 +2081,7 @@
|
||||
@@ -1661,7 +2065,7 @@
|
||||
this.onUpdateAbilities();
|
||||
if (flag) {
|
||||
this.getAttributes().assignBaseValues(entityplayer.getAttributes());
|
||||
@@ -1008,7 +1008,7 @@
|
||||
this.setHealth(entityplayer.getHealth());
|
||||
this.foodData = entityplayer.foodData;
|
||||
Iterator iterator = entityplayer.getActiveEffects().iterator();
|
||||
@@ -1685,7 +2089,7 @@
|
||||
@@ -1669,7 +2073,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
@@ -1017,7 +1017,7 @@
|
||||
}
|
||||
|
||||
this.getInventory().replaceWith(entityplayer.getInventory());
|
||||
@@ -1696,7 +2100,7 @@
|
||||
@@ -1680,7 +2084,7 @@
|
||||
this.portalProcess = entityplayer.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(entityplayer.getAttributes());
|
||||
@@ -1026,7 +1026,7 @@
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) {
|
||||
this.getInventory().replaceWith(entityplayer.getInventory());
|
||||
this.experienceLevel = entityplayer.experienceLevel;
|
||||
@@ -1712,7 +2116,7 @@
|
||||
@@ -1696,7 +2100,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -1035,16 +1035,16 @@
|
||||
this.seenCredits = entityplayer.seenCredits;
|
||||
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = entityplayer.chunkTrackingView;
|
||||
@@ -1768,7 +2172,7 @@
|
||||
@@ -1752,7 +2156,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
|
||||
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, TeleportCause cause) { // CraftBukkit
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
|
||||
|
||||
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
|
||||
@@ -1780,7 +2184,7 @@
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, true);
|
||||
}
|
||||
@@ -1761,7 +2165,7 @@
|
||||
this.setCamera(this);
|
||||
}
|
||||
|
||||
@@ -1053,7 +1053,7 @@
|
||||
|
||||
if (flag1) {
|
||||
this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f);
|
||||
@@ -1897,6 +2301,16 @@
|
||||
@@ -1878,6 +2282,16 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientinformation) {
|
||||
@@ -1070,7 +1070,7 @@
|
||||
this.language = clientinformation.language();
|
||||
this.requestedViewDistance = clientinformation.viewDistance();
|
||||
this.chatVisibility = clientinformation.chatVisibility();
|
||||
@@ -1981,7 +2395,7 @@
|
||||
@@ -1962,7 +2376,7 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
@@ -1079,7 +1079,7 @@
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -2018,11 +2432,11 @@
|
||||
@@ -1999,11 +2413,11 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getTabListDisplayName() {
|
||||
@@ -1093,7 +1093,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2065,6 +2479,32 @@
|
||||
@@ -2046,6 +2460,32 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -1126,7 +1126,7 @@
|
||||
if (blockposition != null) {
|
||||
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
|
||||
|
||||
@@ -2107,12 +2547,38 @@
|
||||
@@ -2088,12 +2528,38 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1166,7 +1166,7 @@
|
||||
this.level().addFreshEntity(entityitem);
|
||||
ItemStack itemstack1 = entityitem.getItem();
|
||||
|
||||
@@ -2394,10 +2860,12 @@
|
||||
@@ -2375,10 +2841,12 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
@@ -1182,7 +1182,7 @@
|
||||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) {
|
||||
@@ -2406,4 +2874,146 @@
|
||||
@@ -2387,4 +2855,146 @@
|
||||
return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/server/level/TicketType.java
|
||||
+++ b/net/minecraft/server/level/TicketType.java
|
||||
@@ -23,6 +23,8 @@
|
||||
@@ -22,6 +22,8 @@
|
||||
public static final TicketType<BlockPosition> PORTAL = create("portal", BaseBlockPosition::compareTo, 300);
|
||||
public static final TicketType<ChunkCoordIntPair> ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40);
|
||||
public static final TicketType<Integer> POST_TELEPORT = create("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1);
|
||||
+ public static final TicketType<Unit> PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit
|
||||
+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/WorldServer.java
|
||||
+++ b/net/minecraft/server/level/WorldServer.java
|
||||
@@ -173,6 +173,23 @@
|
||||
@@ -174,6 +174,23 @@
|
||||
import net.minecraft.world.ticks.TickListServer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
|
||||
@@ -186,7 +203,7 @@
|
||||
@@ -187,7 +204,7 @@
|
||||
final List<EntityPlayer> players = Lists.newArrayList();
|
||||
private final ChunkProviderServer chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@@ -33,7 +33,7 @@
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList = new EntityTickList();
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -213,13 +230,47 @@
|
||||
@@ -214,13 +231,47 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
@@ -83,7 +83,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);
|
||||
@@ -247,9 +298,9 @@
|
||||
@@ -248,9 +299,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);
|
||||
@@ -96,7 +96,7 @@
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -259,6 +310,7 @@
|
||||
@@ -260,6 +311,7 @@
|
||||
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
|
||||
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences");
|
||||
});
|
||||
@@ -104,7 +104,7 @@
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -304,12 +356,20 @@
|
||||
@@ -305,12 +357,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
@@ -128,7 +128,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -344,7 +404,7 @@
|
||||
@@ -345,7 +405,7 @@
|
||||
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@@ -137,7 +137,7 @@
|
||||
|
||||
if (flag1) {
|
||||
this.resetEmptyTime();
|
||||
@@ -428,7 +488,7 @@
|
||||
@@ -429,7 +489,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@@ -146,7 +146,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -455,7 +515,7 @@
|
||||
@@ -456,7 +516,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@@ -155,7 +155,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,7 +524,7 @@
|
||||
@@ -465,7 +525,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@@ -164,7 +164,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -520,7 +580,7 @@
|
||||
@@ -521,7 +581,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition2)) {
|
||||
@@ -173,7 +173,7 @@
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -536,10 +596,10 @@
|
||||
@@ -537,10 +597,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
|
||||
@@ -186,7 +186,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,6 +760,7 @@
|
||||
@@ -701,6 +761,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -718,15 +779,48 @@
|
||||
@@ -719,15 +780,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));
|
||||
}
|
||||
@@ -245,7 +245,7 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -762,6 +856,7 @@
|
||||
@@ -763,6 +857,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
@@ -253,7 +253,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -785,6 +880,7 @@
|
||||
@@ -786,6 +881,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
@@ -261,7 +261,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -809,6 +905,7 @@
|
||||
@@ -810,6 +906,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
@@ -269,7 +269,7 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -826,11 +923,19 @@
|
||||
@@ -827,11 +924,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -290,7 +290,7 @@
|
||||
}
|
||||
|
||||
WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage();
|
||||
@@ -902,18 +1007,40 @@
|
||||
@@ -903,18 +1008,40 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@@ -334,7 +334,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -938,24 +1065,37 @@
|
||||
@@ -939,24 +1066,37 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
@@ -376,19 +376,19 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -966,13 +1106,35 @@
|
||||
@@ -967,13 +1107,35 @@
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) {
|
||||
+ LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
|
||||
+
|
||||
@@ -413,7 +413,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -981,6 +1143,12 @@
|
||||
@@ -982,6 +1144,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
@@ -426,7 +426,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1059,7 +1227,18 @@
|
||||
@@ -1060,7 +1228,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -446,7 +446,7 @@
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(blockposition)) {
|
||||
@@ -1125,6 +1304,12 @@
|
||||
@@ -1126,6 +1305,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) {
|
||||
@@ -459,7 +459,7 @@
|
||||
Explosion.Effect explosion_effect;
|
||||
|
||||
switch (world_a) {
|
||||
@@ -1143,6 +1328,11 @@
|
||||
@@ -1144,6 +1329,11 @@
|
||||
case TRIGGER:
|
||||
explosion_effect = Explosion.Effect.TRIGGER_BLOCK;
|
||||
break;
|
||||
@@ -471,7 +471,7 @@
|
||||
default:
|
||||
throw new MatchException((String) null, (Throwable) null);
|
||||
}
|
||||
@@ -1152,6 +1342,11 @@
|
||||
@@ -1153,6 +1343,11 @@
|
||||
ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
|
||||
|
||||
serverexplosion.explode();
|
||||
@@ -483,7 +483,7 @@
|
||||
ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1;
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -1165,6 +1360,7 @@
|
||||
@@ -1166,6 +1361,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,30 +491,28 @@
|
||||
}
|
||||
|
||||
private Explosion.Effect getDestroyType(GameRules.GameRuleKey<GameRules.GameRuleBoolean> gamerules_gamerulekey) {
|
||||
@@ -1225,13 +1421,20 @@
|
||||
@@ -1226,15 +1422,18 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
- return this.sendParticles(t0, false, false, d0, d1, d2, i, d3, d4, d5, d6);
|
||||
+ // CraftBukkit - visibility api support
|
||||
+ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false);
|
||||
+ }
|
||||
+
|
||||
+ public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
|
||||
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
+ return this.sendParticlesSource(null, t0, false, false, d0, d1, d2, i, d3, d4, d5, d6);
|
||||
}
|
||||
|
||||
- public <T extends ParticleParam> int sendParticles(T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
+ public <T extends ParticleParam> int sendParticlesSource(EntityPlayer sender, T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
+ // CraftBukkit end
|
||||
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, flag, flag1, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
int j = 0;
|
||||
|
||||
for (int k = 0; k < this.players.size(); ++k) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(k);
|
||||
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
|
||||
|
||||
- if (this.sendParticles(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
|
||||
+ if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
|
||||
if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) {
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1282,7 +1485,7 @@
|
||||
@@ -1292,7 +1491,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
|
||||
@@ -523,7 +521,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey);
|
||||
@@ -1324,11 +1527,22 @@
|
||||
@@ -1334,11 +1533,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap getMapData(MapId mapid) {
|
||||
@@ -547,7 +545,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap);
|
||||
}
|
||||
|
||||
@@ -1639,6 +1853,11 @@
|
||||
@@ -1649,6 +1859,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@@ -559,7 +557,7 @@
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1658,12 +1877,12 @@
|
||||
@@ -1668,12 +1883,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -574,7 +572,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1686,7 +1905,7 @@
|
||||
@@ -1696,7 +1911,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@@ -583,7 +581,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1695,7 +1914,7 @@
|
||||
@@ -1705,7 +1920,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@@ -592,7 +590,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1854,6 +2073,8 @@
|
||||
@@ -1864,6 +2079,8 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -601,7 +599,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1885,6 +2106,14 @@
|
||||
@@ -1895,6 +2112,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -196,6 +196,71 @@
|
||||
@@ -198,6 +198,71 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -245,7 +310,7 @@
|
||||
@@ -247,7 +312,7 @@
|
||||
private boolean waitingForSwitchToConfig;
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
@@ -81,7 +81,7 @@
|
||||
this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection());
|
||||
this.player = entityplayer;
|
||||
entityplayer.connection = this;
|
||||
@@ -254,9 +319,25 @@
|
||||
@@ -256,9 +321,25 @@
|
||||
|
||||
Objects.requireNonNull(minecraftserver);
|
||||
this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile);
|
||||
@@ -108,7 +108,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -311,6 +392,7 @@
|
||||
@@ -313,6 +394,7 @@
|
||||
this.chatSpamThrottler.tick();
|
||||
this.dropSpamThrottler.tick();
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
@@ -116,7 +116,7 @@
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -374,6 +456,12 @@
|
||||
@@ -376,6 +458,12 @@
|
||||
@Override
|
||||
public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel());
|
||||
@@ -129,7 +129,7 @@
|
||||
this.player.setLastClientInput(packetplayinsteervehicle.input());
|
||||
}
|
||||
|
||||
@@ -399,6 +487,13 @@
|
||||
@@ -401,6 +489,13 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -143,7 +143,7 @@
|
||||
double d0 = entity.getX();
|
||||
double d1 = entity.getY();
|
||||
double d2 = entity.getZ();
|
||||
@@ -413,7 +508,33 @@
|
||||
@@ -415,7 +510,33 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@@ -176,9 +176,9 @@
|
||||
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
||||
+ // CraftBukkit end
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
this.send(PacketPlayOutVehicleMove.fromEntity(entity));
|
||||
return;
|
||||
@@ -453,14 +574,76 @@
|
||||
@@ -455,14 +576,67 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@@ -188,7 +188,7 @@
|
||||
if (flag && (flag2 || !flag3)) {
|
||||
entity.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
this.send(PacketPlayOutVehicleMove.fromEntity(entity));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,16 +203,7 @@
|
||||
+ this.hasMoved = true;
|
||||
+ }
|
||||
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
|
||||
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
|
||||
+
|
||||
+ // If the packet contains movement information then we update the To location with the correct XYZ.
|
||||
+ to.setX(packetplayinvehiclemove.getX());
|
||||
+ to.setY(packetplayinvehiclemove.getY());
|
||||
+ to.setZ(packetplayinvehiclemove.getZ());
|
||||
+
|
||||
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
|
||||
+ to.setYaw(packetplayinvehiclemove.getYRot());
|
||||
+ to.setPitch(packetplayinvehiclemove.getXRot());
|
||||
+ Location to = CraftLocation.toBukkit(packetplayinvehiclemove.position(), player.getWorld(), packetplayinvehiclemove.yRot(), packetplayinvehiclemove.xRot());
|
||||
+
|
||||
+ // Prevent 40 event-calls for less than a single pixel of movement >.>
|
||||
+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
|
||||
@@ -255,15 +246,15 @@
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position());
|
||||
Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
@@ -498,6 +681,7 @@
|
||||
}
|
||||
|
||||
@@ -499,6 +673,7 @@
|
||||
this.lastGoodZ = this.awaitingPositionFromClient.z;
|
||||
this.player.hasChangedDimension();
|
||||
this.awaitingPositionFromClient = null;
|
||||
+ this.player.serverLevel().getChunkSource().move(this.player); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -521,6 +705,7 @@
|
||||
@@ -528,6 +703,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel());
|
||||
@@ -271,7 +262,7 @@
|
||||
this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering());
|
||||
}
|
||||
|
||||
@@ -541,6 +726,12 @@
|
||||
@@ -548,6 +724,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
||||
@@ -284,7 +275,7 @@
|
||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -550,6 +741,7 @@
|
||||
@@ -557,6 +739,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
@@ -292,7 +283,7 @@
|
||||
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
|
||||
|
||||
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1));
|
||||
@@ -796,6 +988,13 @@
|
||||
@@ -866,6 +1049,13 @@
|
||||
Container container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof ContainerMerchant containermerchant) {
|
||||
@@ -306,7 +297,7 @@
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -809,6 +1008,13 @@
|
||||
@@ -879,6 +1069,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||
@@ -320,7 +311,7 @@
|
||||
int i = packetplayinbedit.slot();
|
||||
|
||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -829,12 +1035,16 @@
|
||||
@@ -899,12 +1096,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> list, int i) {
|
||||
@@ -338,7 +329,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,12 +1055,13 @@
|
||||
@@ -915,12 +1116,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
@@ -354,7 +345,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,7 +1123,7 @@
|
||||
@@ -982,7 +1184,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
|
||||
@@ -363,7 +354,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -927,7 +1138,15 @@
|
||||
@@ -997,7 +1199,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@@ -379,7 +370,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -949,15 +1168,33 @@
|
||||
@@ -1019,15 +1229,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@@ -415,7 +406,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -979,6 +1216,7 @@
|
||||
@@ -1049,6 +1277,7 @@
|
||||
boolean flag2 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
||||
@@ -423,7 +414,7 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -997,9 +1235,75 @@
|
||||
@@ -1067,9 +1296,75 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
@@ -500,7 +491,7 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1049,6 +1353,7 @@
|
||||
@@ -1119,6 +1414,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
@@ -508,7 +499,7 @@
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1077,10 +1382,62 @@
|
||||
@@ -1147,10 +1443,62 @@
|
||||
}
|
||||
|
||||
public void teleport(double d0, double d1, double d2, float f, float f1) {
|
||||
@@ -572,7 +563,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
if (++this.awaitingTeleport == Integer.MAX_VALUE) {
|
||||
this.awaitingTeleport = 0;
|
||||
@@ -1088,12 +1445,20 @@
|
||||
@@ -1158,12 +1506,20 @@
|
||||
|
||||
this.player.teleportSetPosition(positionmoverotation, set);
|
||||
this.awaitingPositionFromClient = this.player.position();
|
||||
@@ -590,131 +581,131 @@
|
||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
if (this.player.hasClientLoaded()) {
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
@@ -1104,14 +1469,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
@@ -1175,14 +1531,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
|
||||
- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.cserver.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)"));
|
||||
- this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
- this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ // CraftBukkit start - inspiration taken from DispenserRegistry (See SpigotCraft#394)
|
||||
+ CraftItemStack mainHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ CraftItemStack offHand = CraftItemStack.asCraftMirror(this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ PlayerSwapHandItemsEvent swapItemsEvent = new PlayerSwapHandItemsEvent(getCraftPlayer(), mainHand.clone(), offHand.clone());
|
||||
+ this.cserver.getPluginManager().callEvent(swapItemsEvent);
|
||||
+ if (swapItemsEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.drop(false);
|
||||
}
|
||||
+ if (swapItemsEvent.getOffHandItem().equals(offHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, this.player.getItemInHand(EnumHand.MAIN_HAND));
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.OFF_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getOffHandItem()));
|
||||
+ }
|
||||
+ if (swapItemsEvent.getMainHandItem().equals(mainHand)) {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, itemstack);
|
||||
+ } else {
|
||||
+ this.player.setItemInHand(EnumHand.MAIN_HAND, CraftItemStack.asNMSCopy(swapItemsEvent.getMainHandItem()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
|
||||
@@ -1149,6 +1546,7 @@
|
||||
return;
|
||||
case DROP_ITEM:
|
||||
if (!this.player.isSpectator()) {
|
||||
+ // limit how quickly items can be dropped
|
||||
+ // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick.
|
||||
+ if (this.lastDropTick != MinecraftServer.currentTick) {
|
||||
+ this.dropCount = 0;
|
||||
+ this.lastDropTick = MinecraftServer.currentTick;
|
||||
+ } else {
|
||||
+ // Else we increment the drop count and check the amount.
|
||||
+ this.dropCount++;
|
||||
+ if (this.dropCount >= 20) {
|
||||
+ LOGGER.warn(this.player.getScoreboardName() + " dropped their items too quickly!");
|
||||
+ this.disconnect(IChatBaseComponent.literal("You dropped your items too quickly (Hacking?)"));
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1221,6 +1609,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||
@@ -1171,6 +1569,7 @@
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -1244,6 +1633,7 @@
|
||||
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1207,6 +1606,7 @@
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1281,6 +1671,7 @@
|
||||
@Override
|
||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinblockplace.getHand();
|
||||
@@ -1221,6 +1621,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
if (this.player.hasClientLoaded()) {
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@@ -1296,6 +1687,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
+ double d1 = this.player.getY() + (double) this.player.getEyeHeight();
|
||||
+ double d2 = this.player.getZ();
|
||||
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
|
||||
+ // CraftBukkit start
|
||||
+ // Raytrace to look for 'rogue armswings'
|
||||
+ double d0 = this.player.getX();
|
||||
+ double d1 = this.player.getY() + (double) this.player.getEyeHeight();
|
||||
+ double d2 = this.player.getZ();
|
||||
+ Vec3D vec3d = new Vec3D(d0, d1, d2);
|
||||
+
|
||||
+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
+ float f7 = f4 * f5;
|
||||
+ float f8 = f3 * f5;
|
||||
+ double d3 = player.blockInteractionRange();
|
||||
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player));
|
||||
+ float f3 = MathHelper.cos(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f4 = MathHelper.sin(-f * 0.017453292F - 3.1415927F);
|
||||
+ float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
+ float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
+ float f7 = f4 * f5;
|
||||
+ float f8 = f3 * f5;
|
||||
+ double d3 = player.blockInteractionRange();
|
||||
+ Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
+ MovingObjectPosition movingobjectposition = this.player.level().clip(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.OUTLINE, RayTrace.FluidCollisionOption.NONE, player));
|
||||
+
|
||||
+ boolean cancelled;
|
||||
+ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ } else {
|
||||
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
|
||||
+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) {
|
||||
+ cancelled = player.gameMode.interactResult;
|
||||
+ } else {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation());
|
||||
+ boolean cancelled;
|
||||
+ if (movingobjectposition == null || movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack, enumhand);
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ } else {
|
||||
+ MovingObjectPositionBlock movingobjectpositionblock = (MovingObjectPositionBlock) movingobjectposition;
|
||||
+ if (player.gameMode.firedInteract && player.gameMode.interactPosition.equals(movingobjectpositionblock.getBlockPos()) && player.gameMode.interactHand == enumhand && ItemStack.isSameItemSameComponents(player.gameMode.interactItemStack, itemstack)) {
|
||||
+ cancelled = player.gameMode.interactResult;
|
||||
+ } else {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), itemstack, true, enumhand, movingobjectpositionblock.getLocation());
|
||||
+ cancelled = event.useItemInHand() == Event.Result.DENY;
|
||||
+ }
|
||||
+ player.gameMode.firedInteract = false;
|
||||
+ }
|
||||
+ player.gameMode.firedInteract = false;
|
||||
+ }
|
||||
+
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event
|
||||
+ if (itemstack.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
+ if (cancelled) {
|
||||
+ this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = this.player.getItemInHand(enumhand); // Update in case it was changed in the event
|
||||
+ if (itemstack.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
@@ -1245,7 +1686,7 @@
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
@@ -1321,7 +1753,7 @@
|
||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
@@ -723,7 +714,7 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1266,6 +1707,13 @@
|
||||
@@ -1342,6 +1774,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails disconnectiondetails) {
|
||||
@@ -737,7 +728,7 @@
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(disconnectiondetails);
|
||||
@@ -1273,10 +1721,18 @@
|
||||
@@ -1349,10 +1788,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@@ -757,7 +748,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1291,7 +1747,16 @@
|
||||
@@ -1367,7 +1814,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
||||
@@ -774,7 +765,7 @@
|
||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1300,11 +1765,18 @@
|
||||
@@ -1376,11 +1832,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@@ -793,7 +784,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1318,7 +1790,7 @@
|
||||
@@ -1394,7 +1857,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -802,7 +793,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
|
||||
|
||||
this.chatMessageChain.append(completablefuture, (filteredtext) -> {
|
||||
@@ -1326,19 +1798,36 @@
|
||||
@@ -1402,19 +1865,36 @@
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
});
|
||||
@@ -841,7 +832,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1355,19 +1844,37 @@
|
||||
@@ -1431,19 +1911,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> {
|
||||
@@ -882,7 +873,7 @@
|
||||
} catch (SignedMessageChain.a signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1375,10 +1882,10 @@
|
||||
@@ -1451,10 +1949,10 @@
|
||||
|
||||
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
||||
|
||||
@@ -895,7 +886,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
||||
@@ -1454,14 +1961,20 @@
|
||||
@@ -1530,14 +2028,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@@ -919,7 +910,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,6 +2003,116 @@
|
||||
@@ -1566,6 +2070,116 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1036,7 +1027,7 @@
|
||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||
|
||||
@@ -1497,13 +2120,33 @@
|
||||
@@ -1573,13 +2187,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||
@@ -1073,7 +1064,7 @@
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1525,13 +2168,62 @@
|
||||
@@ -1601,7 +2235,33 @@
|
||||
@Override
|
||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||
@@ -1107,36 +1098,37 @@
|
||||
this.player.swing(packetplayinarmanimation.getHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1609,6 +2269,29 @@
|
||||
public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel());
|
||||
+ // CraftBukkit start
|
||||
+ if (this.player.isRemoved()) return;
|
||||
+ switch (packetplayinentityaction.getAction()) {
|
||||
+ case PRESS_SHIFT_KEY:
|
||||
+ case RELEASE_SHIFT_KEY:
|
||||
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY);
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
if (this.player.hasClientLoaded()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.player.isRemoved()) return;
|
||||
+ switch (packetplayinentityaction.getAction()) {
|
||||
+ case PRESS_SHIFT_KEY:
|
||||
+ case RELEASE_SHIFT_KEY:
|
||||
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.PRESS_SHIFT_KEY);
|
||||
+ this.cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ case START_SPRINTING:
|
||||
+ case STOP_SPRINTING:
|
||||
+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
|
||||
+ this.cserver.getPluginManager().callEvent(e2);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ case START_SPRINTING:
|
||||
+ case STOP_SPRINTING:
|
||||
+ PlayerToggleSprintEvent e2 = new PlayerToggleSprintEvent(this.getCraftPlayer(), packetplayinentityaction.getAction() == PacketPlayInEntityAction.EnumPlayerAction.START_SPRINTING);
|
||||
+ this.cserver.getPluginManager().callEvent(e2);
|
||||
+
|
||||
+ if (e2.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
|
||||
@@ -1608,6 +2300,12 @@
|
||||
+ if (e2.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
IJumpable ijumpable;
|
||||
@@ -1691,6 +2374,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||
@@ -1149,104 +1141,104 @@
|
||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a));
|
||||
this.addPendingMessage(playerchatmessage);
|
||||
}
|
||||
@@ -1635,6 +2333,7 @@
|
||||
@@ -1718,6 +2407,7 @@
|
||||
@Override
|
||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||
+ if (this.player.isImmobile()) return; // CraftBukkit
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
if (this.player.hasClientLoaded()) {
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
@@ -1733,13 +2423,51 @@
|
||||
|
||||
@@ -1649,13 +2348,51 @@
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
|
||||
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
|
||||
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
ItemStack itemstack = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
|
||||
+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem();
|
||||
if (itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand);
|
||||
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
|
||||
+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem();
|
||||
+
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(player);
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+
|
||||
+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ // Refresh the current leash state
|
||||
+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) {
|
||||
+ // Refresh the current entity metadata
|
||||
+ entity.refreshEntityData(player);
|
||||
+ // SPIGOT-7136 - Allays
|
||||
+ if (entity instanceof Allay) {
|
||||
+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList())));
|
||||
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
|
||||
+ if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ entity.getBukkitEntity().update(player);
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) {
|
||||
+ // Refresh the current leash state
|
||||
+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
|
||||
+ }
|
||||
+
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
|
||||
@@ -1671,19 +2408,20 @@
|
||||
+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) {
|
||||
+ // Refresh the current entity metadata
|
||||
+ entity.refreshEntityData(player);
|
||||
+ // SPIGOT-7136 - Allays
|
||||
+ if (entity instanceof Allay) {
|
||||
+ send(new PacketPlayOutEntityEquipment(entity.getId(), Arrays.stream(EnumItemSlot.values()).map((slot) -> Pair.of(slot, ((EntityLiving) entity).getItemBySlot(slot).copy())).collect(Collectors.toList())));
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = playerconnection_a.run(PlayerConnection.this.player, entity, enumhand);
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
- this.performInteraction(enumhand, EntityHuman::interactOn);
|
||||
+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand, Vec3D vec3d) {
|
||||
this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> {
|
||||
return entity1.interactAt(entityplayer, vec3d, enumhand1);
|
||||
- });
|
||||
+ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack() {
|
||||
- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) {
|
||||
+ // CraftBukkit
|
||||
+ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) {
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1701,6 +2439,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) {
|
||||
+ if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return;
|
||||
}
|
||||
+
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
|
||||
@@ -1755,19 +2483,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
- this.performInteraction(enumhand, EntityHuman::interactOn);
|
||||
+ this.performInteraction(enumhand, EntityHuman::interactOn, new PlayerInteractEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
@@ -1724,7 +2467,7 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand, Vec3D vec3d) {
|
||||
this.performInteraction(enumhand, (entityplayer, entity1, enumhand1) -> {
|
||||
return entity1.interactAt(entityplayer, vec3d, enumhand1);
|
||||
- });
|
||||
+ }, new PlayerInteractAtEntityEvent(getCraftPlayer(), entity.getBukkitEntity(), new org.bukkit.util.Vector(vec3d.x, vec3d.y, vec3d.z), (enumhand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttack() {
|
||||
- if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && entity != PlayerConnection.this.player) {
|
||||
+ // CraftBukkit
|
||||
+ if (!(entity instanceof EntityItem) && !(entity instanceof EntityExperienceOrb) && (entity != PlayerConnection.this.player || player.isSpectator())) {
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1785,6 +2514,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
+ // CraftBukkit start
|
||||
+ if (!itemstack.isEmpty() && itemstack.getCount() <= -1) {
|
||||
+ player.containerMenu.sendAllDataToRemote();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1809,7 +2543,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
@@ -1255,7 +1247,7 @@
|
||||
this.resetPosition();
|
||||
CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD);
|
||||
} else {
|
||||
@@ -1732,11 +2475,11 @@
|
||||
@@ -1817,11 +2551,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1269,7 +1261,7 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1749,15 +2492,21 @@
|
||||
@@ -1834,15 +2568,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||
@@ -1293,7 +1285,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);
|
||||
@@ -1770,7 +2519,284 @@
|
||||
@@ -1855,7 +2595,284 @@
|
||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@@ -1579,7 +1571,7 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1816,7 +2842,21 @@
|
||||
@@ -1901,7 +2918,21 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1602,7 +1594,7 @@
|
||||
|
||||
if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
@@ -1832,6 +2872,7 @@
|
||||
@@ -1917,6 +2948,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||
@@ -1610,7 +1602,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1875,6 +2916,43 @@
|
||||
@@ -1945,6 +2977,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@@ -1654,7 +1646,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1902,6 +2980,7 @@
|
||||
@@ -1972,6 +3041,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||
@@ -1662,7 +1654,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||
@@ -1923,7 +3002,17 @@
|
||||
@@ -1993,7 +3063,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||
@@ -1681,7 +1673,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1982,7 +3071,7 @@
|
||||
@@ -2058,7 +3138,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@@ -1690,7 +1682,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2007,8 +3096,10 @@
|
||||
@@ -2083,8 +3163,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user