Update to Minecraft 1.21.5

This commit is contained in:
md_5 2025-03-26 03:05:00 +11:00
parent fb3f2b6452
commit 050057d315
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
556 changed files with 7427 additions and 6656 deletions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/CrashReport.java --- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java
@@ -36,6 +36,7 @@ @@ -35,6 +35,7 @@
public CrashReport(String s, Throwable throwable) { public CrashReport(String s, Throwable throwable) {
this.title = s; this.title = s;
this.exception = throwable; this.exception = throwable;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/AdvancementTree.java --- a/net/minecraft/advancements/AdvancementTree.java
+++ b/net/minecraft/advancements/AdvancementTree.java +++ b/net/minecraft/advancements/AdvancementTree.java
@@ -77,7 +77,7 @@ @@ -69,7 +69,7 @@
} }
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java --- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java
@@ -139,6 +139,14 @@ @@ -138,6 +138,14 @@
import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -15,7 +15,7 @@
public class CommandDispatcher { public class CommandDispatcher {
private static final ThreadLocal<ExecutionContext<CommandListenerWrapper>> CURRENT_EXECUTION_CONTEXT = new ThreadLocal(); private static final ThreadLocal<ExecutionContext<CommandListenerWrapper>> CURRENT_EXECUTION_CONTEXT = new ThreadLocal();
@@ -151,6 +159,7 @@ @@ -150,6 +158,7 @@
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher(); private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) { public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) {
@ -23,7 +23,7 @@
CommandAdvancement.register(this.dispatcher); CommandAdvancement.register(this.dispatcher);
CommandAttribute.register(this.dispatcher, commandbuildcontext); CommandAttribute.register(this.dispatcher, commandbuildcontext);
CommandExecute.register(this.dispatcher, commandbuildcontext); CommandExecute.register(this.dispatcher, commandbuildcontext);
@@ -252,6 +261,11 @@ @@ -251,6 +260,11 @@
CommandPublish.register(this.dispatcher); CommandPublish.register(this.dispatcher);
} }
@ -35,7 +35,7 @@
this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer()); this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer());
} }
@@ -262,18 +276,65 @@ @@ -261,18 +275,65 @@
return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions()); return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions());
} }
@ -103,7 +103,7 @@
try { try {
if (contextchain != null) { if (contextchain != null) {
@@ -307,7 +368,7 @@ @@ -306,7 +367,7 @@
} }
@Nullable @Nullable
@ -112,16 +112,16 @@
try { try {
validateParseResults(parseresults); validateParseResults(parseresults);
return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> { return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> {
@@ -318,7 +379,7 @@ @@ -317,7 +378,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> { IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, "/" + s)); - return chatmodifier.withClickEvent(new ChatClickable.SuggestCommand("/" + s));
+ return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit + return chatmodifier.withClickEvent(new ChatClickable.SuggestCommand("/" + label)); // CraftBukkit
}); });
if (i > 10) { if (i > 10) {
@@ -368,7 +429,7 @@ @@ -367,7 +428,7 @@
executioncontext1.close(); executioncontext1.close();
} finally { } finally {
@ -130,7 +130,7 @@
} }
} else { } else {
consumer.accept(executioncontext); consumer.accept(executioncontext);
@@ -377,11 +438,36 @@ @@ -376,18 +437,43 @@
} }
public void sendCommands(EntityPlayer entityplayer) { public void sendCommands(EntityPlayer entityplayer) {
@ -168,16 +168,15 @@
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode)); entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
} }
@@ -392,7 +478,7 @@ private void fillUsableCommands(CommandNode<CommandListenerWrapper> commandnode, CommandNode<ICompletionProvider> commandnode1, CommandListenerWrapper commandlistenerwrapper, Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map) {
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next(); for (CommandNode<CommandListenerWrapper> commandnode2 : commandnode.getChildren()) {
if (commandnode2.canUse(commandlistenerwrapper)) { if (commandnode2.canUse(commandlistenerwrapper)) {
- ArgumentBuilder<ICompletionProvider, ?> argumentbuilder = commandnode2.createBuilder(); - ArgumentBuilder<ICompletionProvider, ?> argumentbuilder = commandnode2.createBuilder();
+ ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error + ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
argumentbuilder.requires((icompletionprovider) -> { argumentbuilder.requires((icompletionprovider) -> {
return true; return true;
@@ -415,7 +501,7 @@ @@ -410,7 +496,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
} }
@ -186,12 +185,3 @@
map.put(commandnode2, commandnode3); map.put(commandnode2, commandnode3);
commandnode1.addChild(commandnode3); commandnode1.addChild(commandnode3);
@@ -481,7 +567,7 @@
}
private <T> HolderLookup.b.a<T> createLookup(final HolderLookup.b<T> holderlookup_b) {
- return new HolderLookup.b.a<T>(this) {
+ return new HolderLookup.b.a<T>() { // CraftBukkit - decompile error
@Override
public HolderLookup.b<T> parent() {
return holderlookup_b;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandListenerWrapper.java --- a/net/minecraft/commands/CommandListenerWrapper.java
+++ b/net/minecraft/commands/CommandListenerWrapper.java +++ b/net/minecraft/commands/CommandListenerWrapper.java
@@ -46,6 +46,8 @@ @@ -44,6 +44,8 @@
import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -9,7 +9,7 @@
public class CommandListenerWrapper implements ExecutionCommandSource<CommandListenerWrapper>, ICompletionProvider { public class CommandListenerWrapper implements ExecutionCommandSource<CommandListenerWrapper>, ICompletionProvider {
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player"));
@@ -65,6 +67,7 @@ @@ -63,6 +65,7 @@
private final Vec2F rotation; private final Vec2F rotation;
private final CommandSigningContext signingContext; private final CommandSigningContext signingContext;
private final TaskChainer chatMessageChainer; private final TaskChainer chatMessageChainer;
@ -17,7 +17,7 @@
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) { public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, CommandResultCallback.EMPTY, ArgumentAnchor.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(minecraftserver)); this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, CommandResultCallback.EMPTY, ArgumentAnchor.Anchor.FEET, CommandSigningContext.ANONYMOUS, TaskChainer.immediate(minecraftserver));
@@ -171,9 +174,23 @@ @@ -169,9 +172,23 @@
@Override @Override
public boolean hasPermission(int i) { public boolean hasPermission(int i) {
@ -41,16 +41,16 @@
public Vec3D getPosition() { public Vec3D getPosition() {
return this.worldPosition; return this.worldPosition;
} }
@@ -302,7 +319,7 @@ @@ -296,7 +313,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) {
for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) {
- if (entityplayer.commandSource() != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) { - if (entityplayer.commandSource() != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) {
+ if (entityplayer.commandSource() != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit + if (entityplayer.commandSource() != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendSystemMessage(ichatmutablecomponent); entityplayer.sendSystemMessage(ichatbasecomponent1);
} }
} }
@@ -400,4 +417,10 @@ @@ -394,4 +411,10 @@
public boolean isSilent() { public boolean isSilent() {
return this.silent; return this.silent;
} }

View File

@ -10,7 +10,7 @@
+ +
+ public EntitySelector parse(StringReader stringreader, boolean flag, boolean overridePermissions) throws CommandSyntaxException { + public EntitySelector parse(StringReader stringreader, boolean flag, boolean overridePermissions) throws CommandSyntaxException {
+ // CraftBukkit end + // CraftBukkit end
boolean flag1 = false; int i = 0;
ArgumentParserSelector argumentparserselector = new ArgumentParserSelector(stringreader, flag); ArgumentParserSelector argumentparserselector = new ArgumentParserSelector(stringreader, flag);
- EntitySelector entityselector = argumentparserselector.parse(); - EntitySelector entityselector = argumentparserselector.parse();
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit + EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java --- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
+++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java +++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
@@ -67,7 +67,7 @@ @@ -65,7 +65,7 @@
private final StringReader reader; private final StringReader reader;
private final boolean forTesting; private final boolean forTesting;
private final boolean allowNbt; private final boolean allowNbt;
@ -9,16 +9,7 @@
private final Map<String, String> vagueProperties = Maps.newHashMap(); private final Map<String, String> vagueProperties = Maps.newHashMap();
private MinecraftKey id = MinecraftKey.withDefaultNamespace(""); private MinecraftKey id = MinecraftKey.withDefaultNamespace("");
@Nullable @Nullable
@@ -275,7 +275,7 @@ @@ -516,7 +516,7 @@
Iterator iterator = iblockstate.getPossibleValues().iterator();
while (iterator.hasNext()) {
- T t0 = (Comparable) iterator.next();
+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error
if (t0 instanceof Integer integer) {
suggestionsbuilder.suggest(integer);
@@ -545,7 +545,7 @@
Optional<T> optional = iblockstate.getValue(s); Optional<T> optional = iblockstate.getValue(s);
if (optional.isPresent()) { if (optional.isPresent()) {
@ -27,7 +18,7 @@
this.properties.put(iblockstate, (Comparable) optional.get()); this.properties.put(iblockstate, (Comparable) optional.get());
} else { } else {
this.reader.setCursor(i); this.reader.setCursor(i);
@@ -581,7 +581,7 @@ @@ -551,7 +551,7 @@
private static <T extends Comparable<T>> void appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) { private static <T extends Comparable<T>> void appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.getName()); stringbuilder.append(iblockstate.getName());
stringbuilder.append('='); stringbuilder.append('=');

View File

@ -1,14 +1,5 @@
--- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
+++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
@@ -158,7 +158,7 @@
axisalignedbb = this.createAabb(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
}
- Function function;
+ Function<Vec3D, Vec3D> function; // CraftBukkit - decompile error
if (this.x == null && this.y == null && this.z == null) {
function = (vec3d) -> {
@@ -215,8 +215,10 @@ @@ -215,8 +215,10 @@
}; };
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java --- a/net/minecraft/commands/arguments/selector/EntitySelector.java
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
@@ -93,7 +93,7 @@ @@ -92,7 +92,7 @@
} }
private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
@ -9,3 +9,26 @@
throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create(); throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create();
} }
} }
@@ -254,19 +254,19 @@
list1.addAll(this.contextFreePredicates);
if (flag) {
- list1.add((Predicate) (entity) -> {
+ list1.add((entity) -> { // CraftBukkit - decompile error
return entity.getType().isEnabled(featureflagset);
});
}
if (flag1) {
- list1.add((Predicate) (entity) -> {
+ list1.add((entity) -> { // CraftBukkit - decompile error
return axisalignedbb.intersects(entity.getBoundingBox());
});
}
if (flag2) {
- list1.add((Predicate) (entity) -> {
+ list1.add((entity) -> { // CraftBukkit - decompile error
return this.range.matchesSqr(entity.distanceToSqr(vec3d));
});
}

View File

@ -42,12 +42,12 @@
entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
- world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); - world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState());
+ // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit + // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
} }
@@ -93,12 +104,17 @@ @@ -93,12 +104,17 @@
}); });
map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { map1.put(Items.GLASS_BOTTLE, (CauldronInteraction) (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
if (!world.isClientSide) { if (!world.isClientSide) {
+ // CraftBukkit start + // CraftBukkit start
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) { + if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
@ -61,7 +61,7 @@
entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); - LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit + // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F); world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
} }
@@ -113,10 +129,15 @@ @@ -113,10 +129,15 @@
@ -78,7 +78,7 @@
entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
- world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); - world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL));
+ // world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit + // world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); world.playSound((Entity) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
} }
@@ -194,12 +215,17 @@ @@ -194,12 +215,17 @@
@ -97,7 +97,7 @@
entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
- world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); - world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState());
+ // world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit + // world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.playSound((Entity) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
} }
@@ -210,12 +236,17 @@ @@ -210,12 +236,17 @@
@ -116,7 +116,7 @@
entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
- world.setBlockAndUpdate(blockposition, iblockdata); - world.setBlockAndUpdate(blockposition, iblockdata);
+ // world.setBlockAndUpdate(blockposition, iblockdata); // CraftBukkit + // world.setBlockAndUpdate(blockposition, iblockdata); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F); world.playSound((Entity) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
} }
@@ -242,11 +273,16 @@ @@ -242,11 +273,16 @@

View File

@ -1,24 +1,24 @@
--- a/net/minecraft/core/component/DataComponentPatch.java --- a/net/minecraft/core/component/DataComponentPatch.java
+++ b/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java
@@ -61,7 +61,7 @@ @@ -60,7 +60,7 @@
} }
} }
- return reference2objectmap; - return reference2objectmap;
+ return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error + return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error
}); });
public static final StreamCodec<RegistryFriendlyByteBuf, DataComponentPatch> STREAM_CODEC = new StreamCodec<RegistryFriendlyByteBuf, DataComponentPatch>() { public static final StreamCodec<RegistryFriendlyByteBuf, DataComponentPatch> STREAM_CODEC = createStreamCodec(new DataComponentPatch.b() {
public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) { @Override
@@ -144,7 +144,7 @@ @@ -159,7 +159,7 @@
} }
private static <T> void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType<T> datacomponenttype, Object object) { private <T> void encodeComponent(RegistryFriendlyByteBuf registryfriendlybytebuf, DataComponentType<T> datacomponenttype, Object object) {
- datacomponenttype.streamCodec().encode(registryfriendlybytebuf, object); - datacomponentpatch_b.apply(datacomponenttype).encode(registryfriendlybytebuf, object);
+ datacomponenttype.streamCodec().encode(registryfriendlybytebuf, (T) object); // CraftBukkit - decompile error + datacomponentpatch_b.apply(datacomponenttype).encode(registryfriendlybytebuf, (T) object); // CraftBukkit - decompile error
} }
}; };
private static final String REMOVED_PREFIX = "!"; }
@@ -271,6 +271,42 @@ @@ -321,6 +321,42 @@
a() {} a() {}

View File

@ -43,12 +43,12 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
AbstractBoat abstractboat = (AbstractBoat) this.type.create(worldserver, EntitySpawnReason.DISPENSER); AbstractBoat abstractboat = this.type.create(worldserver, EntitySpawnReason.DISPENSER);
if (abstractboat != null) { if (abstractboat != null) {
- abstractboat.setInitialPos(d1, d2 + d4, d3); - abstractboat.setInitialPos(d1, d2 + d4, d3);
+ abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit + abstractboat.setInitialPos(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); // CraftBukkit
EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(abstractboat); EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityLiving) null).accept(abstractboat);
abstractboat.setYRot(enumdirection.toYRot()); abstractboat.setYRot(enumdirection.toYRot());
- worldserver.addFreshEntity(abstractboat); - worldserver.addFreshEntity(abstractboat);
- itemstack.shrink(1); - itemstack.shrink(1);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java --- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java
@@ -23,6 +23,13 @@ @@ -21,6 +21,13 @@
import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
@ -14,7 +14,7 @@
public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public class DispenseBehaviorShears extends DispenseBehaviorMaybe {
public DispenseBehaviorShears() {} public DispenseBehaviorShears() {}
@@ -30,11 +37,34 @@ @@ -28,11 +35,34 @@
@Override @Override
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level(); WorldServer worldserver = sourceblock.level();
@ -50,17 +50,13 @@
if (this.isSuccess()) { if (this.isSuccess()) {
itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> { itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> {
}); });
@@ -64,7 +94,7 @@ @@ -62,10 +92,15 @@
return false; return false;
} }
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { - private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args + private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS); for (EntityLiving entityliving : worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS)) {
Iterator iterator = list.iterator();
@@ -73,6 +103,11 @@
if (entityliving instanceof IShearable ishearable) { if (entityliving instanceof IShearable ishearable) {
if (ishearable.readyForShearing()) { if (ishearable.readyForShearing()) {
+ // CraftBukkit start + // CraftBukkit start

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java --- a/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -63,6 +63,22 @@ @@ -64,6 +64,22 @@
import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionBlock;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -23,7 +23,7 @@
public interface IDispenseBehavior { public interface IDispenseBehavior {
Logger LOGGER = LogUtils.getLogger(); Logger LOGGER = LogUtils.getLogger();
@@ -90,14 +106,42 @@ @@ -93,14 +109,42 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(sourceblock.level().registryAccess(), itemstack); EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(sourceblock.level().registryAccess(), itemstack);
@ -55,7 +55,7 @@
+ } + }
+ +
try { try {
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false); entitytypes.spawn(sourceblock.level(), itemstack, (EntityLiving) null, sourceblock.pos().relative(enumdirection), EntitySpawnReason.DISPENSER, enumdirection != EnumDirection.UP, false);
} catch (Exception exception) { } catch (Exception exception) {
- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); - null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception);
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); // CraftBukkit - decompile error + LOGGER.error("Error while dispensing spawn egg from dispenser at {}", sourceblock.pos(), exception); // CraftBukkit - decompile error
@ -100,10 +100,10 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
Consumer<EntityArmorStand> consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> { Consumer<EntityArmorStand> consumer = EntityTypes.<EntityArmorStand>appendDefaultStackConfig((entityarmorstand) -> {
entityarmorstand.setYRot(enumdirection.toYRot()); entityarmorstand.setYRot(enumdirection.toYRot());
}, worldserver, itemstack, (EntityHuman) null); }, worldserver, itemstack, (EntityLiving) null);
EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false); EntityArmorStand entityarmorstand = EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false);
if (entityarmorstand != null) { if (entityarmorstand != null) {
- itemstack.shrink(1); - itemstack.shrink(1);
@ -111,63 +111,26 @@
} }
return itemstack; return itemstack;
@@ -141,7 +213,34 @@ @@ -136,11 +208,35 @@
}); for (EntityHorseChestedAbstract entityhorsechestedabstract : sourceblock.level().getEntitiesOfClass(EntityHorseChestedAbstract.class, new AxisAlignedBB(blockposition), (entityhorsechestedabstract1) -> {
return entityhorsechestedabstract1.isAlive() && !entityhorsechestedabstract1.hasChest();
if (!list.isEmpty()) { })) {
- ((ISaddleable) list.get(0)).equipSaddle(itemstack.split(1), SoundCategory.BLOCKS); - if (entityhorsechestedabstract.isTamed() && entityhorsechestedabstract.getSlot(499).set(itemstack)) {
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
+ WorldServer world = sourceblock.level();
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity());
+ if (!BlockDispenser.eventFired) {
+ world.getCraftServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ itemstack.grow(1);
+ return itemstack;
+ }
+
+ if (!event.getItem().equals(craftItem)) {
+ itemstack.grow(1);
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ ((ISaddleable) list.get(0)).equipSaddle(itemstack1, SoundCategory.BLOCKS);
+ // CraftBukkit end
this.setSuccess(true);
return itemstack;
} else {
@@ -166,9 +265,35 @@
}
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.getSlot(499).set(itemstack));
+ // CraftBukkit start
+ } while (!entityhorsechestedabstract.isTamed());
+ ItemStack itemstack1 = itemstack.split(1);
+ WorldServer world = sourceblock.level();
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
- itemstack.shrink(1); - itemstack.shrink(1);
- this.setSuccess(true);
+ ItemStack itemstack1 = itemstack.split(1);
+ WorldServer world = sourceblock.level();
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity());
+ if (!BlockDispenser.eventFired) { + if (!BlockDispenser.eventFired) {
+ world.getCraftServer().getPluginManager().callEvent(event); + world.getCraftServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return itemstack; return itemstack;
+ } }
+ +
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
@ -182,13 +145,17 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
+ // itemstack.shrink(1); // CraftBukkit - handled above + // itemstack.shrink(1); // CraftBukkit - handled above
this.setSuccess(true); + this.setSuccess(true);
return itemstack; + return itemstack;
} }
@@ -202,6 +327,38 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
WorldServer worldserver = sourceblock.level();
return super.execute(sourceblock, itemstack);
@@ -175,6 +271,40 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
World world = sourceblock.level();
+ WorldServer worldserver = sourceblock.level();
+
+ // CraftBukkit start + // CraftBukkit start
+ int x = blockposition.getX(); + int x = blockposition.getX();
+ int y = blockposition.getY(); + int y = blockposition.getY();
@ -221,29 +188,29 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) { if (dispensiblecontaineritem.emptyContents((EntityLiving) null, world, blockposition, (MovingObjectPositionBlock) null)) {
dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition); dispensiblecontaineritem.checkExtraContent((EntityLiving) null, world, itemstack, blockposition);
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET)); return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET));
@@ -229,7 +386,7 @@ @@ -202,7 +332,7 @@
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
if (block instanceof IFluidSource ifluidsource) { if (block instanceof IFluidSource ifluidsource) {
- ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); - ItemStack itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, generatoraccess, blockposition, iblockdata);
+ ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit + ItemStack itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
if (itemstack1.isEmpty()) { if (itemstack1.isEmpty()) {
return super.execute(sourceblock, itemstack); return super.execute(sourceblock, itemstack);
@@ -237,6 +394,32 @@ @@ -210,6 +340,32 @@
worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition); generatoraccess.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
Item item = itemstack1.getItem(); Item item = itemstack1.getItem();
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); + org.bukkit.block.Block bukkitBlock = CraftBlock.at(generatoraccess, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ if (!BlockDispenser.eventFired) { + if (!BlockDispenser.eventFired) {
+ worldserver.getCraftServer().getPluginManager().callEvent(event); + sourceblock.level().getCraftServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -260,13 +227,13 @@
+ } + }
+ } + }
+ +
+ itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); // From above + itemstack1 = ifluidsource.pickupBlock((EntityLiving) null, generatoraccess, blockposition, iblockdata); // From above
+ // CraftBukkit end + // CraftBukkit end
+ +
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item)); return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item));
} }
} else { } else {
@@ -249,16 +432,44 @@ @@ -222,16 +378,44 @@
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level(); WorldServer worldserver = sourceblock.level();
@ -311,20 +278,20 @@
} else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) { } else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
- if (iblockdata.getBlock() instanceof BlockTNT) { - if (iblockdata.getBlock() instanceof BlockTNT) {
+ if (iblockdata.getBlock() instanceof BlockTNT && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(worldserver, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, sourceblock.pos())) { // CraftBukkit - TNTPrimeEvent + if (iblockdata.getBlock() instanceof BlockTNT && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(worldserver, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, sourceblock.pos())) { // CraftBukkit - TNTPrimeEvent
BlockTNT.explode(worldserver, blockposition); if (BlockTNT.prime(worldserver, blockposition)) {
worldserver.removeBlock(blockposition, false); worldserver.removeBlock(blockposition, false);
} else { } else {
@@ -283,12 +494,62 @@ @@ -259,12 +443,62 @@
this.setSuccess(true); this.setSuccess(true);
WorldServer worldserver = sourceblock.level(); World world = sourceblock.level();
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos()); + org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); + BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
+ if (!BlockDispenser.eventFired) { + if (!BlockDispenser.eventFired) {
+ worldserver.getCraftServer().getPluginManager().callEvent(event); + world.getCraftServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -341,22 +308,22 @@
+ } + }
+ } + }
+ +
+ worldserver.captureTreeGeneration = true; + world.captureTreeGeneration = true;
+ // CraftBukkit end + // CraftBukkit end
if (!ItemBoneMeal.growCrop(itemstack, worldserver, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, worldserver, blockposition, (EnumDirection) null)) { if (!ItemBoneMeal.growCrop(itemstack, world, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, world, blockposition, (EnumDirection) null)) {
this.setSuccess(false); this.setSuccess(false);
} else if (!worldserver.isClientSide) { } else if (!world.isClientSide) {
worldserver.levelEvent(1505, blockposition, 15); world.levelEvent(1505, blockposition, 15);
} }
+ // CraftBukkit start + // CraftBukkit start
+ worldserver.captureTreeGeneration = false; + world.captureTreeGeneration = false;
+ if (worldserver.capturedBlockStates.size() > 0) { + if (world.capturedBlockStates.size() > 0) {
+ TreeType treeType = BlockSapling.treeType; + TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null; + BlockSapling.treeType = null;
+ Location location = CraftLocation.toBukkit(blockposition, worldserver.getWorld()); + Location location = CraftLocation.toBukkit(blockposition, world.getWorld());
+ List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values()); + List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
+ worldserver.capturedBlockStates.clear(); + world.capturedBlockStates.clear();
+ StructureGrowEvent structureEvent = null; + StructureGrowEvent structureEvent = null;
+ if (treeType != null) { + if (treeType != null) {
+ structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); + structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks);
@ -377,9 +344,9 @@
return itemstack; return itemstack;
} }
@@ -298,12 +559,41 @@ @@ -279,12 +513,41 @@
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) { return itemstack;
WorldServer worldserver = sourceblock.level(); } else {
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ // CraftBukkit start + // CraftBukkit start
@ -414,24 +381,24 @@
+ // CraftBukkit end + // CraftBukkit end
worldserver.addFreshEntity(entitytntprimed); worldserver.addFreshEntity(entitytntprimed);
worldserver.playSound((EntityHuman) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); worldserver.playSound((Entity) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
worldserver.gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, blockposition); worldserver.gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, blockposition);
- itemstack.shrink(1); - itemstack.shrink(1);
+ // itemstack.shrink(1); // CraftBukkit - handled above + // itemstack.shrink(1); // CraftBukkit - handled above
this.setSuccess(true);
return itemstack; return itemstack;
} }
}); @@ -297,6 +560,30 @@
@@ -314,6 +604,30 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection); BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); + org.bukkit.block.Block bukkitBlock = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ if (!BlockDispenser.eventFired) { + if (!BlockDispenser.eventFired) {
+ worldserver.getCraftServer().getPluginManager().callEvent(event); + world.getCraftServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -449,20 +416,20 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) { if (world.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(world, blockposition, itemstack)) {
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3); world.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3);
worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition); world.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition);
@@ -339,6 +653,30 @@ @@ -322,6 +609,30 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos()); + org.bukkit.block.Block bukkitBlock = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ if (!BlockDispenser.eventFired) { + if (!BlockDispenser.eventFired) {
+ worldserver.getCraftServer().getPluginManager().callEvent(event); + world.getCraftServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -480,10 +447,10 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) { if (world.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(world, blockposition)) {
if (!worldserver.isClientSide) { if (!world.isClientSide) {
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3); world.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
@@ -377,6 +715,30 @@ @@ -356,6 +667,30 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING)); BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getBlockState(blockposition); IBlockData iblockdata = worldserver.getBlockState(blockposition);
@ -514,7 +481,7 @@
if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> { if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> {
return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive; return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL) && blockbase_blockdata.getBlock() instanceof BlockBeehive;
}) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) { }) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) {
@@ -426,6 +788,31 @@ @@ -405,6 +740,31 @@
this.setSuccess(false); this.setSuccess(false);
return itemstack; return itemstack;
} else { } else {
@ -543,6 +510,6 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
Iterator iterator1 = list.iterator(); for (Armadillo armadillo : list) {
if (armadillo.brushOffScute()) {
Armadillo armadillo; itemstack.hurtAndBreak(16, worldserver, (EntityPlayer) null, (item) -> {

View File

@ -4,4 +4,4 @@
+// mc-dev import +// mc-dev import
package net.minecraft.nbt; package net.minecraft.nbt;
import java.io.BufferedOutputStream; import com.google.common.annotations.VisibleForTesting;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/network/NetworkManager.java --- a/net/minecraft/network/NetworkManager.java
+++ b/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java
@@ -114,6 +114,7 @@ @@ -113,6 +113,7 @@
private volatile DisconnectionDetails delayedDisconnect; private volatile DisconnectionDetails delayedDisconnect;
@Nullable @Nullable
BandwidthDebugMonitor bandwidthDebugMonitor; BandwidthDebugMonitor bandwidthDebugMonitor;
@ -8,7 +8,7 @@
public NetworkManager(EnumProtocolDirection enumprotocoldirection) { public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
this.receiving = enumprotocoldirection; this.receiving = enumprotocoldirection;
@@ -205,7 +206,7 @@ @@ -204,7 +205,7 @@
} }
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) { private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
@ -17,7 +17,16 @@
} }
private void validateListener(ProtocolInfo<?> protocolinfo, PacketListener packetlistener) { private void validateListener(ProtocolInfo<?> protocolinfo, PacketListener packetlistener) {
@@ -469,7 +470,7 @@ @@ -331,7 +332,7 @@
this.flushQueue();
this.sendPacket(packet, packetsendlistener, flag);
} else {
- this.pendingActions.add((Consumer) (networkmanager) -> {
+ this.pendingActions.add((networkmanager) -> { // CraftBukkit - decompile error
networkmanager.sendPacket(packet, packetsendlistener, flag);
});
}
@@ -467,7 +468,7 @@
} }
if (this.isConnected()) { if (this.isConnected()) {
@ -26,12 +35,3 @@
this.disconnectionDetails = disconnectiondetails; this.disconnectionDetails = disconnectiondetails;
} }
@@ -537,7 +538,7 @@
}
public void configurePacketHandler(ChannelPipeline channelpipeline) {
- channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter(this) {
+ channelpipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter() { // CraftBukkit - decompile error
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
super.write(channelhandlercontext, object, channelpromise);
}

View File

@ -1,24 +1,6 @@
--- a/net/minecraft/network/PacketDataSerializer.java --- a/net/minecraft/network/PacketDataSerializer.java
+++ b/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java
@@ -139,7 +139,7 @@ @@ -173,7 +173,7 @@
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, StreamDecoder<? super PacketDataSerializer, T> streamdecoder) {
int i = this.readVarInt();
- C c0 = (Collection) intfunction.apply(i);
+ C c0 = intfunction.apply(i); // CraftBukkit - decompile error
for (int j = 0; j < i; ++j) {
c0.add(streamdecoder.decode(this));
@@ -150,7 +150,7 @@
public <T> void writeCollection(Collection<T> collection, StreamEncoder<? super PacketDataSerializer, T> streamencoder) {
this.writeVarInt(collection.size());
- Iterator iterator = collection.iterator();
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -177,12 +177,12 @@
public void writeIntIdList(IntList intlist) { public void writeIntIdList(IntList intlist) {
this.writeVarInt(intlist.size()); this.writeVarInt(intlist.size());
@ -27,43 +9,10 @@
} }
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, StreamDecoder<? super PacketDataSerializer, K> streamdecoder, StreamDecoder<? super PacketDataSerializer, V> streamdecoder1) { public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, StreamDecoder<? super PacketDataSerializer, K> streamdecoder, StreamDecoder<? super PacketDataSerializer, V> streamdecoder1) {
int i = this.readVarInt(); @@ -566,7 +566,7 @@
- M m0 = (Map) intfunction.apply(i);
+ M m0 = intfunction.apply(i); // CraftBukkit - decompile error
for (int j = 0; j < i; ++j) {
K k0 = streamdecoder.decode(this);
@@ -216,7 +216,7 @@
}
public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) {
- E[] ae = (Enum[]) oclass.getEnumConstants();
+ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error
BitSet bitset = new BitSet(ae.length);
for (int i = 0; i < ae.length; ++i) {
@@ -227,7 +227,7 @@
}
public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass) {
- E[] ae = (Enum[]) oclass.getEnumConstants();
+ E[] ae = oclass.getEnumConstants(); // CraftBukkit - decompile error
BitSet bitset = this.readFixedBitSet(ae.length);
EnumSet<E> enumset = EnumSet.noneOf(oclass);
@@ -498,7 +498,7 @@
}
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
- return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()];
+ return ((T[]) oclass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error
}
public PacketDataSerializer writeEnum(Enum<?> oenum) {
@@ -565,7 +565,7 @@
try { try {
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(bytebuf)); NBTCompressedStreamTools.writeAnyTag(nbtbase, new ByteBufOutputStream(bytebuf));
- } catch (IOException ioexception) { - } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception + } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception); throw new EncoderException(ioexception);

View File

@ -1,11 +1,12 @@
--- a/net/minecraft/network/chat/IChatBaseComponent.java --- a/net/minecraft/network/chat/IChatBaseComponent.java
+++ b/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java
@@ -38,7 +38,22 @@ @@ -37,7 +37,23 @@
import net.minecraft.util.FormattedString; import net.minecraft.util.FormattedString;
import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.ChunkCoordIntPair;
-public interface IChatBaseComponent extends Message, IChatFormatted { -public interface IChatBaseComponent extends Message, IChatFormatted {
+// CraftBukkit start +// CraftBukkit start
+import java.util.Iterator;
+import java.util.stream.Stream; +import java.util.stream.Stream;
+// CraftBukkit end +// CraftBukkit end
+ +

View File

@ -4,7 +4,7 @@
private static final int MAX_PAYLOAD_SIZE = 32767; private static final int MAX_PAYLOAD_SIZE = 32767;
public static final StreamCodec<PacketDataSerializer, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.codec((minecraftkey) -> { public static final StreamCodec<PacketDataSerializer, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.codec((minecraftkey) -> {
return DiscardedPayload.codec(minecraftkey, 32767); return DiscardedPayload.codec(minecraftkey, 32767);
- }, (List) SystemUtils.make(Lists.newArrayList(new CustomPacketPayload.c[]{new CustomPacketPayload.c<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> { - }, (List) SystemUtils.make(Lists.newArrayList(new CustomPacketPayload.c[]{new CustomPacketPayload.c(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)}), (arraylist) -> {
- })).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); - })).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload);
+ }, java.util.Collections.emptyList()).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); // CraftBukkit - treat all packets the same + }, java.util.Collections.emptyList()).map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload); // CraftBukkit - treat all packets the same

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/network/syncher/DataWatcher.java --- a/net/minecraft/network/syncher/DataWatcher.java
+++ b/net/minecraft/network/syncher/DataWatcher.java +++ b/net/minecraft/network/syncher/DataWatcher.java
@@ -14,6 +14,11 @@ @@ -13,6 +13,11 @@
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -12,7 +12,7 @@
public class DataWatcher { public class DataWatcher {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -51,7 +56,7 @@ @@ -50,7 +55,7 @@
} }
private <T> DataWatcher.Item<T> getItem(DataWatcherObject<T> datawatcherobject) { private <T> DataWatcher.Item<T> getItem(DataWatcherObject<T> datawatcherobject) {
@ -21,7 +21,7 @@
} }
public <T> T get(DataWatcherObject<T> datawatcherobject) { public <T> T get(DataWatcherObject<T> datawatcherobject) {
@@ -74,6 +79,13 @@ @@ -73,6 +78,13 @@
} }
@ -35,7 +35,7 @@
public boolean isDirty() { public boolean isDirty() {
return this.isDirty; return this.isDirty;
} }
@@ -140,7 +152,7 @@ @@ -128,7 +140,7 @@
if (!Objects.equals(datawatcher_c.serializer(), datawatcher_item.accessor.serializer())) { if (!Objects.equals(datawatcher_c.serializer(), datawatcher_item.accessor.serializer())) {
throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.id(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_c.value, datawatcher_c.value.getClass())); throw new IllegalStateException(String.format(Locale.ROOT, "Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.id(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_c.value, datawatcher_c.value.getClass()));
} else { } else {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java --- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java +++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -196,6 +196,7 @@ @@ -155,6 +155,7 @@
AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey); AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey);
if (advancementholder == null) { if (advancementholder == null) {
@ -8,7 +8,7 @@
AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath); AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
} else { } else {
this.startProgress(advancementholder, advancementprogress); this.startProgress(advancementholder, advancementprogress);
@@ -227,6 +228,7 @@ @@ -186,6 +187,7 @@
this.progressChanged.add(advancementholder); this.progressChanged.add(advancementholder);
flag = true; flag = true;
if (!flag1 && advancementprogress.isDone()) { if (!flag1 && advancementprogress.isDone()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataWorld.java --- a/net/minecraft/server/AdvancementDataWorld.java
+++ b/net/minecraft/server/AdvancementDataWorld.java +++ b/net/minecraft/server/AdvancementDataWorld.java
@@ -21,10 +21,14 @@ @@ -19,10 +19,14 @@
import net.minecraft.util.profiling.GameProfilerFiller; import net.minecraft.util.profiling.GameProfilerFiller;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -16,12 +16,12 @@
private AdvancementTree tree = new AdvancementTree(); private AdvancementTree tree = new AdvancementTree();
private final HolderLookup.a registries; private final HolderLookup.a registries;
@@ -40,7 +44,7 @@ @@ -38,7 +42,7 @@
this.validate(minecraftkey, advancement); this.validate(minecraftkey, advancement);
builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement)); immutablemap_builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement));
}); });
- this.advancements = builder.buildOrThrow(); - this.advancements = immutablemap_builder.buildOrThrow();
+ this.advancements = new HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable + this.advancements = new HashMap<>(immutablemap_builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable
AdvancementTree advancementtree = new AdvancementTree(); AdvancementTree advancementtree = new AdvancementTree();
advancementtree.addAll(this.advancements.values()); advancementtree.addAll(this.advancements.values());

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/CustomFunctionData.java --- a/net/minecraft/server/CustomFunctionData.java
+++ b/net/minecraft/server/CustomFunctionData.java +++ b/net/minecraft/server/CustomFunctionData.java
@@ -37,7 +37,7 @@ @@ -36,7 +36,7 @@
} }
public CommandDispatcher<CommandListenerWrapper> getDispatcher() { public CommandDispatcher<CommandListenerWrapper> getDispatcher() {

View File

@ -1,11 +1,12 @@
--- a/net/minecraft/server/DispenserRegistry.java --- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java
@@ -30,7 +30,13 @@ @@ -30,7 +30,14 @@
import net.minecraft.world.level.block.state.BlockBase; import net.minecraft.world.level.block.state.BlockBase;
import org.slf4j.Logger; import org.slf4j.Logger;
-@SuppressForbidden(a = "System.out setup") -@SuppressForbidden(a = "System.out setup")
+// CraftBukkit start +// CraftBukkit start
+import java.util.Map;
+import net.minecraft.util.datafix.fixes.DataConverterFlattenData; +import net.minecraft.util.datafix.fixes.DataConverterFlattenData;
+import net.minecraft.util.datafix.fixes.DataConverterMaterialId; +import net.minecraft.util.datafix.fixes.DataConverterMaterialId;
+import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg; +import net.minecraft.util.datafix.fixes.DataConverterSpawnEgg;
@ -15,7 +16,7 @@
public class DispenserRegistry { public class DispenserRegistry {
public static final PrintStream STDOUT = System.out; public static final PrintStream STDOUT = System.out;
@@ -42,6 +48,23 @@ @@ -42,6 +49,23 @@
public static void bootStrap() { public static void bootStrap() {
if (!DispenserRegistry.isBootstrapped) { if (!DispenserRegistry.isBootstrapped) {
@ -39,30 +40,30 @@
DispenserRegistry.isBootstrapped = true; DispenserRegistry.isBootstrapped = true;
Instant instant = Instant.now(); Instant instant = Instant.now();
@@ -61,6 +84,69 @@ @@ -61,6 +85,69 @@
wrapStreams(); wrapStreams();
DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis()); DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
} }
+ // CraftBukkit start - easier than fixing the decompile + // CraftBukkit start - easier than fixing the decompile
+ DataConverterFlattenData.register(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); + DataConverterFlattenData.register(1008, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "0")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "0")));
+ DataConverterFlattenData.register(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); + DataConverterFlattenData.register(1009, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "1")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "1")));
+ DataConverterFlattenData.register(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); + DataConverterFlattenData.register(1010, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "2")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "2")));
+ DataConverterFlattenData.register(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); + DataConverterFlattenData.register(1011, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "3")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "3")));
+ DataConverterFlattenData.register(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); + DataConverterFlattenData.register(1012, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "4")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "4")));
+ DataConverterFlattenData.register(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); + DataConverterFlattenData.register(1013, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "5")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "5")));
+ DataConverterFlattenData.register(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); + DataConverterFlattenData.register(1014, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "6")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "6")));
+ DataConverterFlattenData.register(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); + DataConverterFlattenData.register(1015, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "7")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "7")));
+ DataConverterFlattenData.register(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); + DataConverterFlattenData.register(1016, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "8")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "8")));
+ DataConverterFlattenData.register(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); + DataConverterFlattenData.register(1017, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "9")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "9")));
+ DataConverterFlattenData.register(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); + DataConverterFlattenData.register(1018, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "10")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "10")));
+ DataConverterFlattenData.register(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); + DataConverterFlattenData.register(1019, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "11")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "11")));
+ DataConverterFlattenData.register(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); + DataConverterFlattenData.register(1020, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "12")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "12")));
+ DataConverterFlattenData.register(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); + DataConverterFlattenData.register(1021, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "13")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "13")));
+ DataConverterFlattenData.register(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); + DataConverterFlattenData.register(1022, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "14")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "14")));
+ DataConverterFlattenData.register(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); + DataConverterFlattenData.register(1023, DataConverterFlattenData.create("minecraft:oak_sign", Map.of("rotation", "15")), DataConverterFlattenData.create("minecraft:standing_sign", Map.of("rotation", "15")));
+ DataConverterMaterialId.ITEM_NAMES.put(323, "minecraft:oak_sign"); + DataConverterMaterialId.ITEM_NAMES.put(323, "minecraft:oak_sign");
+ +
+ DataConverterFlattenData.register(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); + DataConverterFlattenData.register(1440, DataConverterFlattenData.create("minecraft:portal", Map.of("axis", "x")), DataConverterFlattenData.create("minecraft:portal", Map.of("axis", "x")));
+ +
+ DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); + DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard");
+ DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); + DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals");

View File

@ -96,7 +96,7 @@
- Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s); - Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s);
+ Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s, WorldDimension.OVERWORLD); + Convertable.ConversionSession convertable_conversionsession = convertable.validateAndCreateAccess(s, WorldDimension.OVERWORLD);
+ // CraftBukkit end + // CraftBukkit end
Dynamic dynamic; Dynamic<?> dynamic;
if (convertable_conversionsession.hasWorldData()) { if (convertable_conversionsession.hasWorldData()) {
@@ -174,13 +204,31 @@ @@ -174,13 +204,31 @@
@ -164,10 +164,10 @@
+ /* + /*
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess(); IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
boolean flag1 = optionset.has(optionspec6);
@@ -237,20 +287,31 @@
SaveData savedata = worldstem.worldData(); SaveData savedata = worldstem.worldData();
boolean flag1 = optionset.has(optionspec6);
@@ -236,20 +286,31 @@
}
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata); convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
+ */ + */
@ -200,7 +200,7 @@
Thread thread = new Thread("Server Shutdown Thread") { Thread thread = new Thread("Server Shutdown Thread") {
public void run() { public void run() {
dedicatedserver.halt(true); dedicatedserver.halt(true);
@@ -259,6 +320,7 @@ @@ -258,6 +319,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);
@ -208,12 +208,12 @@
} catch (Exception exception1) { } catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1); Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
} }
@@ -295,7 +357,7 @@ @@ -294,7 +356,7 @@
} }
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) { public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, SaveData savedata, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistryCustom iregistrycustom, boolean flag1) {
- Main.LOGGER.info("Forcing world upgrade!"); - Main.LOGGER.info("Forcing world upgrade!");
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit + Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, iregistrycustom, flag, flag1);
try { try (WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, savedata, iregistrycustom, flag, flag1)) {
IChatBaseComponent ichatbasecomponent = null;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java --- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java
@@ -180,13 +180,38 @@ @@ -176,13 +176,38 @@
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -40,7 +40,7 @@
private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final int OVERLOADED_TICKS_THRESHOLD = 20;
private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeRange.NANOSECONDS_PER_SECOND;
private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100;
@@ -277,6 +302,19 @@ @@ -273,6 +298,19 @@
private final SuppressedExceptionCollector suppressedExceptions; private final SuppressedExceptionCollector suppressedExceptions;
private final DiscontinuousFrame tickFrame; private final DiscontinuousFrame tickFrame;
@ -60,15 +60,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) { public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference(); AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
@@ -290,14 +328,14 @@ @@ -293,7 +331,7 @@
thread.setPriority(8);
}
- S s0 = (MinecraftServer) function.apply(thread);
+ S s0 = function.apply(thread); // CraftBukkit - decompile error
atomicreference.set(s0);
thread.start();
return s0; return s0;
} }
@ -77,7 +69,7 @@
super("Server"); super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.onMetricsRecordingStopped = (methodprofilerresults) -> { this.onMetricsRecordingStopped = (methodprofilerresults) -> {
@@ -321,7 +359,7 @@ @@ -317,7 +355,7 @@
this.suppressedExceptions = new SuppressedExceptionCollector(); this.suppressedExceptions = new SuppressedExceptionCollector();
this.registries = worldstem.registries(); this.registries = worldstem.registries();
this.worldData = worldstem.worldData(); this.worldData = worldstem.worldData();
@ -86,7 +78,7 @@
throw new IllegalStateException("Missing Overworld dimension data"); throw new IllegalStateException("Missing Overworld dimension data");
} else { } else {
this.proxy = proxy; this.proxy = proxy;
@@ -349,6 +387,33 @@ @@ -345,6 +383,33 @@
this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures());
this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick");
} }
@ -120,7 +112,7 @@
} }
private void readScoreboard(WorldPersistentData worldpersistentdata) { private void readScoreboard(WorldPersistentData worldpersistentdata) {
@@ -357,7 +422,7 @@ @@ -353,7 +418,7 @@
protected abstract boolean initServer() throws IOException; protected abstract boolean initServer() throws IOException;
@ -129,7 +121,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) { if (!JvmProfiler.INSTANCE.isRunning()) {
; ;
} }
@@ -365,12 +430,8 @@ @@ -361,12 +426,8 @@
boolean flag = false; boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted(); ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@ -143,7 +135,7 @@
if (profiledduration != null) { if (profiledduration != null) {
profiledduration.finish(true); profiledduration.finish(true);
} }
@@ -387,23 +448,217 @@ @@ -383,23 +444,217 @@
protected void forceDifficulty() {} protected void forceDifficulty() {}
@ -305,7 +297,7 @@
+ } + }
+ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) + worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
+ if (options.has("forceUpgrade")) { + if (options.has("forceUpgrade")) {
+ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> { + net.minecraft.server.Main.forceUpgrade(worldSession, worlddata, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> {
+ return true; + return true;
+ }, iregistrycustom_dimension, options.has("recreateRegionFiles")); + }, iregistrycustom_dimension, options.has("recreateRegionFiles"));
+ } + }
@ -375,7 +367,7 @@
if (!iworlddataserver.isInitialized()) { if (!iworlddataserver.isInitialized()) {
try { try {
@@ -427,30 +682,8 @@ @@ -423,28 +678,8 @@
iworlddataserver.setInitialized(true); iworlddataserver.setInitialized(true);
} }
@ -385,16 +377,14 @@
- } - }
- -
- RandomSequences randomsequences = worldserver.getRandomSequences(); - RandomSequences randomsequences = worldserver.getRandomSequences();
- Iterator iterator = iregistry.entrySet().iterator();
- -
- while (iterator.hasNext()) { - for (Map.Entry<ResourceKey<WorldDimension>, WorldDimension> map_entry : iregistry.entrySet()) {
- Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next(); - ResourceKey<WorldDimension> resourcekey = (ResourceKey) map_entry.getKey();
- ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
- -
- if (resourcekey != WorldDimension.OVERWORLD) { - if (resourcekey != WorldDimension.OVERWORLD) {
- ResourceKey<World> resourcekey1 = ResourceKey.create(Registries.DIMENSION, resourcekey.location()); - ResourceKey<World> resourcekey1 = ResourceKey.create(Registries.DIMENSION, resourcekey.location());
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver);
- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false, randomsequences); - WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) map_entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false, randomsequences);
- -
- worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder())); - worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder()));
- this.levels.put(resourcekey1, worldserver1); - this.levels.put(resourcekey1, worldserver1);
@ -407,7 +397,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) { private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) { if (flag1) {
@@ -458,6 +691,21 @@ @@ -452,6 +687,21 @@
} else { } else {
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource(); ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition()); ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
@ -429,7 +419,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver); int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinY()) { if (i < worldserver.getMinY()) {
@@ -516,8 +764,11 @@ @@ -510,8 +760,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR); iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
} }
@ -443,7 +433,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location()); MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos(); BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -527,20 +778,22 @@ @@ -521,18 +774,21 @@
this.nextTickTimeNanos = SystemUtils.getNanos(); this.nextTickTimeNanos = SystemUtils.getNanos();
worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle()); worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle());
@ -461,20 +451,17 @@
- this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; - this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.waitUntilNextTick(); - this.waitUntilNextTick();
- Iterator iterator = this.levels.values().iterator();
+ // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS; + // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
+ this.executeModerately(); + this.executeModerately();
+ // Iterator iterator = this.levels.values().iterator();
- while (iterator.hasNext()) { - for (WorldServer worldserver1 : this.levels.values()) {
- WorldServer worldserver1 = (WorldServer) iterator.next();
+ if (true) { + if (true) {
+ WorldServer worldserver1 = worldserver; + WorldServer worldserver1 = worldserver;
+ // CraftBukkit end + // CraftBukkit end
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks"); TicketStorage ticketstorage = (TicketStorage) worldserver1.getDataStorage().get(TicketStorage.TYPE);
if (forcedchunk != null) { if (ticketstorage != null) {
@@ -555,10 +808,17 @@ @@ -540,10 +796,17 @@
} }
} }
@ -495,8 +482,8 @@
} }
public EnumGamemode getDefaultGameType() { public EnumGamemode getDefaultGameType() {
@@ -588,12 +848,16 @@ @@ -572,12 +835,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2); flag3 = true;
} }
+ // CraftBukkit start - moved to WorldServer.save + // CraftBukkit start - moved to WorldServer.save
@ -510,9 +497,9 @@
+ */ + */
+ // CraftBukkit end + // CraftBukkit end
if (flag1) { if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator(); for (WorldServer worldserver2 : this.getAllLevels()) {
MinecraftServer.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", worldserver2.getChunkSource().chunkMap.getStorageName());
@@ -628,18 +892,40 @@ @@ -608,18 +875,40 @@
this.stopServer(); this.stopServer();
} }
@ -553,7 +540,7 @@
} }
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
@@ -727,7 +1013,7 @@ @@ -699,7 +988,7 @@
} }
this.nextTickTimeNanos = SystemUtils.getNanos(); this.nextTickTimeNanos = SystemUtils.getNanos();
@ -562,7 +549,7 @@
this.status = this.buildServerStatus(); this.status = this.buildServerStatus();
while (this.running) { while (this.running) {
@@ -744,6 +1030,7 @@ @@ -716,6 +1005,7 @@
if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) { if (j > MinecraftServer.OVERLOADED_THRESHOLD_NANOS + 20L * i && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= MinecraftServer.OVERLOADED_WARNING_INTERVAL_NANOS + 100L * i) {
long k = j / i; long k = j / i;
@ -570,7 +557,7 @@
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k); MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", j / TimeRange.NANOSECONDS_PER_MILLISECOND, k);
this.nextTickTimeNanos += k * i; this.nextTickTimeNanos += k * i;
this.lastOverloadWarningNanos = this.nextTickTimeNanos; this.lastOverloadWarningNanos = this.nextTickTimeNanos;
@@ -757,6 +1044,7 @@ @@ -729,6 +1019,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount); this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
} }
@ -578,7 +565,7 @@
this.nextTickTimeNanos += i; this.nextTickTimeNanos += i;
try { try {
@@ -830,6 +1118,12 @@ @@ -802,6 +1093,12 @@
this.services.profileCache().clearExecutor(); this.services.profileCache().clearExecutor();
} }
@ -591,7 +578,7 @@
this.onServerExit(); this.onServerExit();
} }
@@ -889,7 +1183,14 @@ @@ -861,7 +1158,14 @@
} }
private boolean haveTime() { private boolean haveTime() {
@ -607,7 +594,7 @@
} }
public static boolean throwIfFatalException() { public static boolean throwIfFatalException() {
@@ -903,7 +1204,7 @@ @@ -875,7 +1179,7 @@
} }
public static void setFatalException(RuntimeException runtimeexception) { public static void setFatalException(RuntimeException runtimeexception) {
@ -616,7 +603,7 @@
} }
@Override @Override
@@ -977,7 +1278,7 @@ @@ -945,7 +1249,7 @@
} }
} }
@ -625,7 +612,7 @@
Profiler.get().incrementCounter("runTask"); Profiler.get().incrementCounter("runTask");
super.doRunTask(ticktask); super.doRunTask(ticktask);
} }
@@ -1041,6 +1342,7 @@ @@ -1009,6 +1313,7 @@
this.autoSave(); this.autoSave();
} }
@ -633,7 +620,7 @@
this.tickConnection(); this.tickConnection();
return; return;
} }
@@ -1055,7 +1357,7 @@ @@ -1023,7 +1328,7 @@
} }
--this.ticksUntilAutosave; --this.ticksUntilAutosave;
@ -642,7 +629,7 @@
this.autoSave(); this.autoSave();
} }
@@ -1074,7 +1376,7 @@ @@ -1042,7 +1347,7 @@
} }
private void autoSave() { private void autoSave() {
@ -651,7 +638,7 @@
MinecraftServer.LOGGER.debug("Autosave started"); MinecraftServer.LOGGER.debug("Autosave started");
GameProfilerFiller gameprofilerfiller = Profiler.get(); GameProfilerFiller gameprofilerfiller = Profiler.get();
@@ -1154,11 +1456,26 @@ @@ -1122,21 +1427,38 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> { this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing(); entityplayer.connection.suspendFlushing();
}); });
@ -659,7 +646,6 @@
gameprofilerfiller.push("commandFunctions"); gameprofilerfiller.push("commandFunctions");
this.getFunctions().tick(); this.getFunctions().tick();
gameprofilerfiller.popPush("levels"); gameprofilerfiller.popPush("levels");
Iterator iterator = this.getAllLevels().iterator();
+ // CraftBukkit start + // CraftBukkit start
+ // Run tasks that are waiting on processing + // Run tasks that are waiting on processing
@ -675,10 +661,9 @@
+ } + }
+ } + }
+ +
while (iterator.hasNext()) { for (WorldServer worldserver : this.getAllLevels()) {
WorldServer worldserver = (WorldServer) iterator.next(); gameprofilerfiller.push(() -> {
String s = String.valueOf(worldserver);
@@ -1167,11 +1484,13 @@
return s + " " + String.valueOf(worldserver.dimension().location()); return s + " " + String.valueOf(worldserver.dimension().location());
}); });
@ -692,7 +677,7 @@
gameprofilerfiller.push("tick"); gameprofilerfiller.push("tick");
@@ -1267,6 +1586,22 @@ @@ -1226,6 +1548,22 @@
return (WorldServer) this.levels.get(resourcekey); return (WorldServer) this.levels.get(resourcekey);
} }
@ -715,7 +700,7 @@
public Set<ResourceKey<World>> levelKeys() { public Set<ResourceKey<World>> levelKeys() {
return this.levels.keySet(); return this.levels.keySet();
} }
@@ -1296,7 +1631,7 @@ @@ -1255,7 +1593,7 @@
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
@ -724,7 +709,7 @@
} }
public SystemReport fillSystemReport(SystemReport systemreport) { public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1634,11 +1969,11 @@ @@ -1589,11 +1927,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) { public CompletableFuture<Void> reloadResources(Collection<String> collection) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -736,9 +721,9 @@
- return (ImmutableList) stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); - return (ImmutableList) stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList());
+ return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error + return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
}, this).thenCompose((immutablelist) -> { }, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist); IReloadableResourceManager ireloadableresourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
List<IRegistry.a<?>> list = TagDataPack.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess()); List<IRegistry.a<?>> list = TagDataPack.loadTagsForExistingRegistries(ireloadableresourcemanager, this.registries.compositeAccess());
@@ -1654,6 +1989,7 @@ @@ -1609,6 +1947,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> { }).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close(); this.resources.close();
this.resources = minecraftserver_reloadableresources; this.resources = minecraftserver_reloadableresources;
@ -746,26 +731,8 @@
this.packRepository.setSelected(collection); this.packRepository.setSelected(collection);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures()); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
@@ -1952,7 +2288,7 @@ @@ -1938,6 +2277,22 @@
final List<String> list = Lists.newArrayList(); }
final GameRules gamerules = this.getGameRules();
- gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor(this) {
+ gamerules.visitGameRuleTypes(new GameRules.GameRuleVisitor() { // CraftBukkit - decompile error
@Override
public <T extends GameRules.GameRuleValue<T>> void visit(GameRules.GameRuleKey<T> gamerules_gamerulekey, GameRules.GameRuleDefinition<T> gamerules_gameruledefinition) {
list.add(String.format(Locale.ROOT, "%s=%s\n", gamerules_gamerulekey.getId(), gamerules.getRule(gamerules_gamerulekey)));
@@ -2058,7 +2394,7 @@
try {
label51:
{
- ArrayList arraylist;
+ ArrayList<NativeModuleLister.a> arraylist; // CraftBukkit - decompile error
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -2108,6 +2444,22 @@
} }
+ // CraftBukkit start + // CraftBukkit start
@ -787,7 +754,7 @@
private GameProfilerFiller createProfiler() { private GameProfilerFiller createProfiler() {
if (this.willStartRecordingMetrics) { if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -2235,6 +2587,11 @@ @@ -2065,6 +2420,11 @@
} }

View File

@ -1,6 +1,15 @@
--- a/net/minecraft/server/ScoreboardServer.java --- a/net/minecraft/server/ScoreboardServer.java
+++ b/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java
@@ -42,7 +42,7 @@ @@ -32,7 +32,7 @@
return persistentbase_a.levelOrThrow().getScoreboard().createData();
}, (persistentbase_a) -> {
ScoreboardServer scoreboardserver = persistentbase_a.levelOrThrow().getScoreboard();
- Codec codec = PersistentScoreboard.a.CODEC;
+ Codec<PersistentScoreboard.a> codec = PersistentScoreboard.a.CODEC; // CraftBukkit - decompile error
Objects.requireNonNull(scoreboardserver);
return codec.xmap(scoreboardserver::createData, PersistentScoreboard::pack);
@@ -49,7 +49,7 @@
protected void onScoreChanged(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective, ScoreboardScore scoreboardscore) { protected void onScoreChanged(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective, ScoreboardScore scoreboardscore) {
super.onScoreChanged(scoreholder, scoreboardobjective, scoreboardscore); super.onScoreChanged(scoreholder, scoreboardobjective, scoreboardscore);
if (this.trackedObjectives.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -9,7 +18,7 @@
} }
this.setDirty(); this.setDirty();
@@ -57,7 +57,7 @@ @@ -64,7 +64,7 @@
@Override @Override
public void onPlayerRemoved(ScoreHolder scoreholder) { public void onPlayerRemoved(ScoreHolder scoreholder) {
super.onPlayerRemoved(scoreholder); super.onPlayerRemoved(scoreholder);
@ -18,7 +27,7 @@
this.setDirty(); this.setDirty();
} }
@@ -65,7 +65,7 @@ @@ -72,7 +72,7 @@
public void onPlayerScoreRemoved(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective) { public void onPlayerScoreRemoved(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective) {
super.onPlayerScoreRemoved(scoreholder, scoreboardobjective); super.onPlayerScoreRemoved(scoreholder, scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -27,7 +36,7 @@
} }
this.setDirty(); this.setDirty();
@@ -78,7 +78,7 @@ @@ -85,7 +85,7 @@
super.setDisplayObjective(displayslot, scoreboardobjective); super.setDisplayObjective(displayslot, scoreboardobjective);
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) { if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
@ -36,7 +45,7 @@
} else { } else {
this.stopTrackingObjective(scoreboardobjective1); this.stopTrackingObjective(scoreboardobjective1);
} }
@@ -86,7 +86,7 @@ @@ -93,7 +93,7 @@
if (scoreboardobjective != null) { if (scoreboardobjective != null) {
if (this.trackedObjectives.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -45,7 +54,7 @@
} else { } else {
this.startTrackingObjective(scoreboardobjective); this.startTrackingObjective(scoreboardobjective);
} }
@@ -98,7 +98,7 @@ @@ -105,7 +105,7 @@
@Override @Override
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
if (super.addPlayerToTeam(s, scoreboardteam)) { if (super.addPlayerToTeam(s, scoreboardteam)) {
@ -54,7 +63,7 @@
this.setDirty(); this.setDirty();
return true; return true;
} else { } else {
@@ -109,7 +109,7 @@ @@ -116,7 +116,7 @@
@Override @Override
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
super.removePlayerFromTeam(s, scoreboardteam); super.removePlayerFromTeam(s, scoreboardteam);
@ -63,7 +72,7 @@
this.setDirty(); this.setDirty();
} }
@@ -123,7 +123,7 @@ @@ -130,7 +130,7 @@
public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) { public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) {
super.onObjectiveChanged(scoreboardobjective); super.onObjectiveChanged(scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -72,7 +81,7 @@
} }
this.setDirty(); this.setDirty();
@@ -142,21 +142,21 @@ @@ -149,21 +149,21 @@
@Override @Override
public void onTeamAdded(ScoreboardTeam scoreboardteam) { public void onTeamAdded(ScoreboardTeam scoreboardteam) {
super.onTeamAdded(scoreboardteam); super.onTeamAdded(scoreboardteam);
@ -97,24 +106,24 @@
this.setDirty(); this.setDirty();
} }
@@ -207,6 +207,7 @@ @@ -200,6 +200,7 @@
List<Packet<?>> list = this.getStartTrackingPackets(scoreboardobjective);
while (iterator.hasNext()) { for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
Iterator iterator1 = list.iterator(); for (Packet<?> packet : list) {
entityplayer.connection.send(packet);
}
@@ -226,6 +227,7 @@
List<Packet<?>> list = this.getStopTrackingPackets(scoreboardobjective);
while (iterator1.hasNext()) { for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) {
@@ -243,6 +244,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
Iterator iterator1 = list.iterator(); for (Packet<?> packet : list) {
entityplayer.connection.send(packet);
while (iterator1.hasNext()) { }
@@ -287,6 +289,16 @@ @@ -261,6 +263,16 @@
return this.createData().load(nbttagcompound, holderlookup_a); return persistentscoreboard;
} }
+ // CraftBukkit start - Send to players + // CraftBukkit start - Send to players

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/bossevents/BossBattleCustom.java --- a/net/minecraft/server/bossevents/BossBattleCustom.java
+++ b/net/minecraft/server/bossevents/BossBattleCustom.java +++ b/net/minecraft/server/bossevents/BossBattleCustom.java
@@ -19,12 +19,27 @@ @@ -19,6 +19,11 @@
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.BossBattle; import net.minecraft.world.BossBattle;
@ -11,7 +11,8 @@
+ +
public class BossBattleCustom extends BossBattleServer { public class BossBattleCustom extends BossBattleServer {
private final MinecraftKey id; private static final int DEFAULT_MAX = 100;
@@ -26,6 +31,16 @@
private final Set<UUID> players = Sets.newHashSet(); private final Set<UUID> players = Sets.newHashSet();
private int value; private int value;
private int max = 100; private int max = 100;
@ -28,3 +29,12 @@
public BossBattleCustom(MinecraftKey minecraftkey, IChatBaseComponent ichatbasecomponent) { public BossBattleCustom(MinecraftKey minecraftkey, IChatBaseComponent ichatbasecomponent) {
super(ichatbasecomponent, BossBattle.BarColor.WHITE, BossBattle.BarStyle.PROGRESS); super(ichatbasecomponent, BossBattle.BarColor.WHITE, BossBattle.BarStyle.PROGRESS);
@@ -168,7 +183,7 @@
bossbattlecustom.setDarkenScreen(bossbattlecustom_a.darkenScreen);
bossbattlecustom.setPlayBossMusic(bossbattlecustom_a.playBossMusic);
bossbattlecustom.setCreateWorldFog(bossbattlecustom_a.createWorldFog);
- Set set = bossbattlecustom_a.players;
+ Set<UUID> set = bossbattlecustom_a.players; // CraftBukkit - decompile error
Objects.requireNonNull(bossbattlecustom);
set.forEach(bossbattlecustom::addOfflinePlayer);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandDifficulty.java --- a/net/minecraft/server/commands/CommandDifficulty.java
+++ b/net/minecraft/server/commands/CommandDifficulty.java +++ b/net/minecraft/server/commands/CommandDifficulty.java
@@ -44,11 +44,12 @@ @@ -40,11 +40,12 @@
public static int setDifficulty(CommandListenerWrapper commandlistenerwrapper, EnumDifficulty enumdifficulty) throws CommandSyntaxException { public static int setDifficulty(CommandListenerWrapper commandlistenerwrapper, EnumDifficulty enumdifficulty) throws CommandSyntaxException {
MinecraftServer minecraftserver = commandlistenerwrapper.getServer(); MinecraftServer minecraftserver = commandlistenerwrapper.getServer();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandEffect.java --- a/net/minecraft/server/commands/CommandEffect.java
+++ b/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java
@@ -84,7 +84,7 @@ @@ -79,7 +79,7 @@
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
MobEffect mobeffect = new MobEffect(holder, k, i, false, flag); MobEffect mobeffect = new MobEffect(holder, k, i, false, flag);
@ -9,19 +9,19 @@
++j; ++j;
} }
} }
@@ -114,7 +114,7 @@ @@ -106,7 +106,7 @@
while (iterator.hasNext()) { int i = 0;
Entity entity = (Entity) iterator.next();
for (Entity entity : collection) {
- if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects()) { - if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects()) {
+ if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit + if (entity instanceof EntityLiving && ((EntityLiving) entity).removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
++i; ++i;
} }
} }
@@ -144,7 +144,7 @@ @@ -133,7 +133,7 @@
while (iterator.hasNext()) { int i = 0;
Entity entity = (Entity) iterator.next();
for (Entity entity : collection) {
- if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder)) { - if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder)) {
+ if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit + if (entity instanceof EntityLiving && ((EntityLiving) entity).removeEffect(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
++i; ++i;

View File

@ -7,7 +7,7 @@
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey); - T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit + T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
t0.setFromArgument(commandcontext, "value"); ((GameRules.GameRuleValue) t0).setFromArgument(commandcontext, "value");
commandlistenerwrapper.sendSuccess(() -> { commandlistenerwrapper.sendSuccess(() -> {
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
} }

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/server/commands/CommandGive.java --- a/net/minecraft/server/commands/CommandGive.java
+++ b/net/minecraft/server/commands/CommandGive.java +++ b/net/minecraft/server/commands/CommandGive.java
@@ -60,7 +60,7 @@ @@ -55,7 +55,7 @@
EntityItem entityitem; boolean flag = entityplayer.getInventory().add(itemstack1);
if (flag && itemstack1.isEmpty()) { if (flag && itemstack1.isEmpty()) {
- entityitem = entityplayer.drop(itemstack, false); - EntityItem entityitem = entityplayer.drop(itemstack, false);
+ entityitem = entityplayer.drop(itemstack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event + EntityItem entityitem = entityplayer.drop(itemstack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event
if (entityitem != null) { if (entityitem != null) {
entityitem.makeFakeItem(); entityitem.makeFakeItem();
}

View File

@ -1,15 +1,6 @@
--- a/net/minecraft/server/commands/CommandLoot.java --- a/net/minecraft/server/commands/CommandLoot.java
+++ b/net/minecraft/server/commands/CommandLoot.java +++ b/net/minecraft/server/commands/CommandLoot.java
@@ -95,7 +95,7 @@ @@ -237,6 +237,7 @@
}
private static <T extends ArgumentBuilder<CommandListenerWrapper, T>> T addTargets(T t0, CommandLoot.c commandloot_c) {
- return t0.then(((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("replace").then(net.minecraft.commands.CommandDispatcher.literal("entity").then(net.minecraft.commands.CommandDispatcher.argument("entities", ArgumentEntity.entities()).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("slot", ArgumentInventorySlot.slot()), (commandcontext, list, commandloot_a) -> {
+ return (T) t0.then(((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("replace").then(net.minecraft.commands.CommandDispatcher.literal("entity").then(net.minecraft.commands.CommandDispatcher.argument("entities", ArgumentEntity.entities()).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("slot", ArgumentInventorySlot.slot()), (commandcontext, list, commandloot_a) -> { // CraftBukkit - decompile error
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a);
}).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> {
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a);
@@ -250,6 +250,7 @@
private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List<ItemStack> list, CommandLoot.a commandloot_a) throws CommandSyntaxException { private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List<ItemStack> list, CommandLoot.a commandloot_a) throws CommandSyntaxException {
WorldServer worldserver = commandlistenerwrapper.getLevel(); WorldServer worldserver = commandlistenerwrapper.getLevel();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandReload.java --- a/net/minecraft/server/commands/CommandReload.java
+++ b/net/minecraft/server/commands/CommandReload.java +++ b/net/minecraft/server/commands/CommandReload.java
@@ -44,6 +44,16 @@ @@ -40,6 +40,16 @@
return collection1; return collection1;
} }

View File

@ -7,5 +7,5 @@
- CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents(); - CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents();
+ CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer + CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer
Optional<net.minecraft.commands.functions.CommandFunction<CommandListenerWrapper>> optional = ((Either) pair.getSecond()).left(); Optional<net.minecraft.commands.functions.CommandFunction<CommandListenerWrapper>> optional = ((Either) pair.getSecond()).left();
String s;
if (optional.isPresent()) {

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/server/commands/CommandSpawnpoint.java --- a/net/minecraft/server/commands/CommandSpawnpoint.java
+++ b/net/minecraft/server/commands/CommandSpawnpoint.java +++ b/net/minecraft/server/commands/CommandSpawnpoint.java
@@ -41,7 +41,7 @@ @@ -37,7 +37,7 @@
while (iterator.hasNext()) { ResourceKey<World> resourcekey = commandlistenerwrapper.getLevel().dimension();
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- entityplayer.setRespawnPosition(resourcekey, blockposition, f, true, false); for (EntityPlayer entityplayer : collection) {
+ entityplayer.setRespawnPosition(resourcekey, blockposition, f, true, false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit - entityplayer.setRespawnPosition(new EntityPlayer.RespawnConfig(resourcekey, blockposition, f, true), false);
+ entityplayer.setRespawnPosition(new EntityPlayer.RespawnConfig(resourcekey, blockposition, f, true), false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit
} }
String s = resourcekey.location().toString(); String s = resourcekey.location().toString();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandSpreadPlayers.java --- a/net/minecraft/server/commands/CommandSpreadPlayers.java
+++ b/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java
@@ -93,7 +93,7 @@ @@ -88,7 +88,7 @@
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
set.add(entity.getTeam()); set.add(entity.getTeam());
} else { } else {
@ -9,12 +9,12 @@
} }
} }
@@ -203,7 +203,7 @@ @@ -187,7 +187,7 @@
commandspreadplayers_a = acommandspreadplayers_a[j++]; commandspreadplayers_a = acommandspreadplayers_a[j++];
} }
- entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true); - entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true);
+ entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason + entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason
d1 = Double.MAX_VALUE; double d1 = Double.MAX_VALUE;
CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a;
int k = acommandspreadplayers_a.length; for (CommandSpreadPlayers.a commandspreadplayers_a1 : acommandspreadplayers_a) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandTeleport.java --- a/net/minecraft/server/commands/CommandTeleport.java
+++ b/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java
@@ -31,6 +31,14 @@ @@ -30,6 +30,14 @@
import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -15,7 +15,7 @@
public class CommandTeleport { public class CommandTeleport {
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition")); private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
@@ -167,7 +175,30 @@ @@ -160,7 +168,30 @@
float f4 = MathHelper.wrapDegrees(f2); float f4 = MathHelper.wrapDegrees(f2);
float f5 = MathHelper.wrapDegrees(f3); float f5 = MathHelper.wrapDegrees(f3);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandTime.java --- a/net/minecraft/server/commands/CommandTime.java
+++ b/net/minecraft/server/commands/CommandTime.java +++ b/net/minecraft/server/commands/CommandTime.java
@@ -9,6 +9,11 @@ @@ -8,6 +8,11 @@
import net.minecraft.network.chat.IChatBaseComponent; import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.server.level.WorldServer; import net.minecraft.server.level.WorldServer;
@ -12,18 +12,15 @@
public class CommandTime { public class CommandTime {
public CommandTime() {} public CommandTime() {}
@@ -49,12 +54,18 @@ @@ -48,8 +53,15 @@
} }
public static int setTime(CommandListenerWrapper commandlistenerwrapper, int i) { public static int setTime(CommandListenerWrapper commandlistenerwrapper, int i) {
- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator(); - for (WorldServer worldserver : commandlistenerwrapper.getServer().getAllLevels()) {
+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
- worldserver.setDayTime((long) i); - worldserver.setDayTime((long) i);
+ // CraftBukkit start + // CraftBukkit start - SPIGOT-6496: Only set the time for the world the command originates in
+ {
+ WorldServer worldserver = commandlistenerwrapper.getLevel();
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i - worldserver.getDayTime()); + TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i - worldserver.getDayTime());
+ Bukkit.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
@ -33,18 +30,15 @@
} }
commandlistenerwrapper.getServer().forceTimeSynchronization(); commandlistenerwrapper.getServer().forceTimeSynchronization();
@@ -65,12 +76,18 @@ @@ -60,8 +72,15 @@
} }
public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) { public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) {
- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator(); - for (WorldServer worldserver : commandlistenerwrapper.getServer().getAllLevels()) {
+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
- worldserver.setDayTime(worldserver.getDayTime() + (long) i); - worldserver.setDayTime(worldserver.getDayTime() + (long) i);
+ // CraftBukkit start + // CraftBukkit start - SPIGOT-6496: Only set the time for the world the command originates in
+ {
+ WorldServer worldserver = commandlistenerwrapper.getLevel();
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i); + TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i);
+ Bukkit.getPluginManager().callEvent(event); + Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/PlaceCommand.java --- a/net/minecraft/server/commands/PlaceCommand.java
+++ b/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java
@@ -132,6 +132,7 @@ @@ -134,6 +134,7 @@
if (!structurestart.isValid()) { if (!structurestart.isValid()) {
throw PlaceCommand.ERROR_STRUCTURE_FAILED.create(); throw PlaceCommand.ERROR_STRUCTURE_FAILED.create();
} else { } else {

View File

@ -169,7 +169,7 @@
} }
if (dedicatedserverproperties.enableQuery) { if (dedicatedserverproperties.enableQuery) {
@@ -293,6 +367,7 @@ @@ -278,6 +352,7 @@
this.queryThreadGs4.stop(); this.queryThreadGs4.stop();
} }
@ -177,7 +177,7 @@
} }
@Override @Override
@@ -314,7 +389,15 @@ @@ -299,7 +374,15 @@
while (!this.consoleInput.isEmpty()) { while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0); ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
@ -194,7 +194,7 @@
} }
} }
@@ -541,16 +624,52 @@ @@ -524,16 +607,52 @@
@Override @Override
public String getPluginNames() { public String getPluginNames() {
@ -251,7 +251,7 @@
} }
public void storeUsingWhiteList(boolean flag) { public void storeUsingWhiteList(boolean flag) {
@@ -660,4 +779,15 @@ @@ -643,4 +762,15 @@
} }
} }
} }

View File

@ -72,7 +72,7 @@
@@ -269,7 +278,7 @@ @@ -269,7 +278,7 @@
if (holder.is(WorldPresets.FLAT)) { if (holder.is(WorldPresets.FLAT)) {
RegistryOps<JsonElement> registryops = holderlookup_a.createSerializationContext(JsonOps.INSTANCE); RegistryOps<JsonElement> registryops = holderlookup_a.<JsonElement>createSerializationContext(JsonOps.INSTANCE);
- DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); - DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings()));
+ DataResult<GeneratorSettingsFlat> dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error + DataResult<GeneratorSettingsFlat> dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error
Logger logger = DedicatedServerProperties.LOGGER; Logger logger = DedicatedServerProperties.LOGGER;

View File

@ -36,22 +36,22 @@
+ return new Properties(); + return new Properties();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
Properties properties; try (InputStream inputstream = Files.newInputStream(path)) {
Properties properties1; CharsetDecoder charsetdecoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
Properties properties = new Properties();
@@ -97,6 +117,11 @@ @@ -57,6 +77,11 @@
}
public void store(Path path) { public void store(Path path) {
try {
+ // CraftBukkit start - Don't attempt writing to file if it's read only + // CraftBukkit start - Don't attempt writing to file if it's read only
+ if (path.toFile().exists() && !path.toFile().canWrite()) { + if (path.toFile().exists() && !path.toFile().canWrite()) {
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8); try (Writer writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
this.properties.store(writer, "Minecraft server properties");
try { } catch (IOException ioexception) {
@@ -125,7 +150,7 @@ @@ -68,7 +93,7 @@
private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) { private static <V extends Number> Function<String, V> wrapNumberDeserializer(Function<String, V> function) {
return (s) -> { return (s) -> {
try { try {
@ -60,7 +60,7 @@
} catch (NumberFormatException numberformatexception) { } catch (NumberFormatException numberformatexception) {
return null; return null;
} }
@@ -144,7 +169,7 @@ @@ -87,7 +112,7 @@
@Nullable @Nullable
private String getStringRaw(String s) { private String getStringRaw(String s) {
@ -69,7 +69,7 @@
} }
@Nullable @Nullable
@@ -160,6 +185,16 @@ @@ -103,6 +128,16 @@
} }
protected <V> V get(String s, Function<String, V> function, Function<V, String> function1, V v0) { protected <V> V get(String s, Function<String, V> function, Function<V, String> function1, V v0) {
@ -84,18 +84,18 @@
+ private <V> V get0(String s, Function<String, V> function, Function<V, String> function1, V v0) { + private <V> V get0(String s, Function<String, V> function, Function<V, String> function1, V v0) {
+ // CraftBukkit end + // CraftBukkit end
String s1 = this.getStringRaw(s); String s1 = this.getStringRaw(s);
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); V v1 = (V) MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
@@ -172,7 +207,7 @@ @@ -115,7 +150,7 @@
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); V v1 = (V) MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
this.properties.put(s, function1.apply(v1)); this.properties.put(s, function1.apply(v1));
- return new PropertyManager.EditableProperty<>(s, v1, function1); - return new PropertyManager.EditableProperty<V>(s, v1, function1);
+ return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error + return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error
} }
protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) { protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
@@ -236,7 +271,7 @@ @@ -179,7 +214,7 @@
return properties; return properties;
} }
@ -104,7 +104,7 @@
public class EditableProperty<V> implements Supplier<V> { public class EditableProperty<V> implements Supplier<V> {
@@ -244,7 +279,7 @@ @@ -187,7 +222,7 @@
private final V value; private final V value;
private final Function<V, String> serializer; private final Function<V, String> serializer;
@ -113,12 +113,12 @@
this.key = s; this.key = s;
this.value = object; this.value = object;
this.serializer = function; this.serializer = function;
@@ -258,7 +293,7 @@ @@ -201,7 +236,7 @@
Properties properties = PropertyManager.this.cloneProperties(); Properties properties = PropertyManager.this.cloneProperties();
properties.put(this.key, this.serializer.apply(v0)); properties.put(this.key, this.serializer.apply(v0));
- return PropertyManager.this.reload(iregistrycustom, properties); - return (T) PropertyManager.this.reload(iregistrycustom, properties);
+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit + return (T) PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit
} }
} }
} }

View File

@ -9,15 +9,6 @@
Objects.requireNonNull(guistatscomponent); Objects.requireNonNull(guistatscomponent);
collection.add(guistatscomponent::close); collection.add(guistatscomponent::close);
@@ -132,7 +132,7 @@
jtextfield.setText("");
});
- jtextarea.addFocusListener(new FocusAdapter(this) {
+ jtextarea.addFocusListener(new FocusAdapter() { // CraftBukkit - decompile error
public void focusGained(FocusEvent focusevent) {}
});
jpanel.add(jscrollpane, "Center");
@@ -166,6 +166,7 @@ @@ -166,6 +166,7 @@
this.finalizers.forEach(Runnable::run); this.finalizers.forEach(Runnable::run);
} }

View File

@ -1,93 +1,18 @@
--- a/net/minecraft/server/level/ChunkMapDistance.java --- a/net/minecraft/server/level/ChunkMapDistance.java
+++ b/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java
@@ -117,6 +117,15 @@ @@ -77,6 +77,11 @@
}
PlayerChunk playerchunk;
if (!this.chunksToUpdateFutures.isEmpty()) {
+ // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus + // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus
+ while (iterator.hasNext()) { + for (PlayerChunk playerchunk : this.chunksToUpdateFutures) {
+ playerchunk = (PlayerChunk) iterator.next();
+ playerchunk.callEventIfUnloading(playerchunkmap); + playerchunk.callEventIfUnloading(playerchunkmap);
+ } + }
+
+ iterator = this.chunksToUpdateFutures.iterator();
+ // CraftBukkit end + // CraftBukkit end
+ for (PlayerChunk playerchunk : this.chunksToUpdateFutures) {
while (iterator.hasNext()) {
playerchunk = (PlayerChunk) iterator.next();
playerchunk.updateHighestAllowedStatus(playerchunkmap); playerchunk.updateHighestAllowedStatus(playerchunkmap);
@@ -165,7 +174,7 @@
} }
} @@ -137,6 +142,7 @@
- void addTicket(long i, Ticket<?> ticket) {
+ boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
int j = getTicketLevelAt(arraysetsorted);
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
@@ -175,13 +184,15 @@
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
}
+ return ticket == ticket1; // CraftBukkit
}
- void removeTicket(long i, Ticket<?> ticket) {
+ boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
+ boolean removed = false; // CraftBukkit
if (arraysetsorted.remove(ticket)) {
- ;
+ removed = true; // CraftBukkit
}
if (arraysetsorted.isEmpty()) {
@@ -189,6 +200,7 @@
}
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
+ return removed; // CraftBukkit
}
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
@@ -202,19 +214,33 @@
}
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit start
+ addRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0);
+ }
+
+ public <T> boolean addRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit end
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
long j = chunkcoordintpair.toLong();
- this.addTicket(j, ticket);
+ boolean added = this.addTicket(j, ticket); // CraftBukkit
this.tickingTicketsTracker.addTicket(j, ticket);
+ return added; // CraftBukkit
}
public <T> void removeRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit start
+ removeRegionTicketAtDistance(tickettype, chunkcoordintpair, i, t0);
+ }
+
+ public <T> boolean removeRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit end
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
long j = chunkcoordintpair.toLong();
- this.removeTicket(j, ticket);
+ boolean removed = this.removeTicket(j, ticket); // CraftBukkit
this.tickingTicketsTracker.removeTicket(j, ticket);
+ return removed; // CraftBukkit
}
private ArraySetSorted<Ticket<?>> getTickets(long i) {
@@ -253,6 +279,7 @@
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk(); ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
long i = chunkcoordintpair.toLong(); long i = chunkcoordintpair.toLong();
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i); ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
@ -95,30 +20,3 @@
objectset.remove(entityplayer); objectset.remove(entityplayer);
if (objectset.isEmpty()) { if (objectset.isEmpty()) {
@@ -391,6 +418,26 @@
return !this.tickets.isEmpty();
}
+ // CraftBukkit start
+ public <T> void removeAllTicketsFor(TicketType<T> ticketType, int ticketLevel, T ticketIdentifier) {
+ Ticket<T> target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier);
+
+ for (java.util.Iterator<Entry<ArraySetSorted<Ticket<?>>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) {
+ Entry<ArraySetSorted<Ticket<?>>> entry = iterator.next();
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue();
+ if (tickets.remove(target)) {
+ // copied from removeTicket
+ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false);
+
+ // can't use entry after it's removed
+ if (tickets.isEmpty()) {
+ iterator.remove();
+ }
+ }
+ }
+ }
+ // CraftBukkit end
+
private class a extends ChunkMap {
private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ChunkProviderServer.java --- a/net/minecraft/server/level/ChunkProviderServer.java
+++ b/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java
@@ -96,6 +96,16 @@ @@ -100,6 +100,16 @@
this.clearCache(); this.clearCache();
} }
@ -17,7 +17,7 @@
@Override @Override
public LightEngineThreaded getLightEngine() { public LightEngineThreaded getLightEngine() {
return this.lightEngine; return this.lightEngine;
@@ -139,7 +149,7 @@ @@ -143,7 +153,7 @@
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) { if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
IChunkAccess ichunkaccess = this.lastChunk[l]; IChunkAccess ichunkaccess = this.lastChunk[l];
@ -26,16 +26,16 @@
return ichunkaccess; return ichunkaccess;
} }
} }
@@ -152,7 +162,7 @@ @@ -156,7 +166,7 @@
Objects.requireNonNull(completablefuture); Objects.requireNonNull(completablefuture);
chunkproviderserver_b.managedBlock(completablefuture::isDone); chunkproviderserver_a.managedBlock(completablefuture::isDone);
ChunkResult<IChunkAccess> chunkresult = (ChunkResult) completablefuture.join(); ChunkResult<IChunkAccess> chunkresult = (ChunkResult) completablefuture.join();
- IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse((Object) null); - IChunkAccess ichunkaccess1 = chunkresult.orElse((Object) null);
+ IChunkAccess ichunkaccess1 = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error + IChunkAccess ichunkaccess1 = chunkresult.orElse(null); // CraftBukkit - decompile error
if (ichunkaccess1 == null && flag) { if (ichunkaccess1 == null && flag) {
throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError())); throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError()));
@@ -232,7 +242,15 @@ @@ -236,7 +246,15 @@
int l = ChunkLevel.byStatus(chunkstatus); int l = ChunkLevel.byStatus(chunkstatus);
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k); PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
@ -49,10 +49,10 @@
+ } + }
+ if (flag && !currentlyUnloading) { + if (flag && !currentlyUnloading) {
+ // CraftBukkit end + // CraftBukkit end
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); this.addTicket(new Ticket(TicketType.UNKNOWN, l), chunkcoordintpair);
if (this.chunkAbsent(playerchunk, l)) { if (this.chunkAbsent(playerchunk, l)) {
GameProfilerFiller gameprofilerfiller = Profiler.get(); GameProfilerFiller gameprofilerfiller = Profiler.get();
@@ -251,7 +269,7 @@ @@ -255,7 +273,7 @@
} }
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) { private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
@ -61,7 +61,7 @@
} }
@Override @Override
@@ -310,12 +328,34 @@ @@ -314,12 +332,34 @@
@Override @Override
public void close() throws IOException { public void close() throws IOException {
@ -85,7 +85,7 @@
+ GameProfilerFiller gameprofilerfiller = Profiler.get(); + GameProfilerFiller gameprofilerfiller = Profiler.get();
+ +
+ gameprofilerfiller.push("purge"); + gameprofilerfiller.push("purge");
+ this.distanceManager.purgeStaleTickets(); + this.ticketStorage.purgeStaleTickets();
+ this.runDistanceManagerUpdates(); + this.runDistanceManagerUpdates();
+ gameprofilerfiller.popPush("unload"); + gameprofilerfiller.popPush("unload");
+ this.chunkMap.tick(() -> true); + this.chunkMap.tick(() -> true);
@ -97,25 +97,25 @@
@Override @Override
public void tick(BooleanSupplier booleansupplier, boolean flag) { public void tick(BooleanSupplier booleansupplier, boolean flag) {
GameProfilerFiller gameprofilerfiller = Profiler.get(); GameProfilerFiller gameprofilerfiller = Profiler.get();
@@ -402,14 +442,14 @@ @@ -384,14 +424,14 @@
this.lastSpawnState = spawnercreature_d; this.lastSpawnState = spawnercreature_d;
gameprofilerfiller.popPush("spawnAndTick"); gameprofilerfiller.popPush("spawnAndTick");
- boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING); - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
+ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
List list1; List<EnumCreatureType> list;
if (flag && (this.spawnEnemies || this.spawnFriendlies)) { if (flag && (this.spawnEnemies || this.spawnFriendlies)) {
- boolean flag1 = this.level.getLevelData().getGameTime() % 400L == 0L; - boolean flag1 = this.level.getLevelData().getGameTime() % 400L == 0L;
+ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit + boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
- list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); - list = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
+ list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit + list = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit
} else { } else {
list1 = List.of(); list = List.of();
} }
@@ -542,8 +582,14 @@ @@ -554,8 +594,14 @@
@Override @Override
public void setSpawnSettings(boolean flag) { public void setSpawnSettings(boolean flag) {
@ -131,7 +131,7 @@
} }
public String getChunkDebugData(ChunkCoordIntPair chunkcoordintpair) { public String getChunkDebugData(ChunkCoordIntPair chunkcoordintpair) {
@@ -619,13 +665,19 @@ @@ -631,13 +677,19 @@
} }
@Override @Override
@ -151,4 +151,4 @@
+ // CraftBukkit end + // CraftBukkit end
} }
} }
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java --- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java +++ b/net/minecraft/server/level/EntityPlayer.java
@@ -183,6 +183,41 @@ @@ -189,6 +189,41 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria; import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -42,7 +42,7 @@
public class EntityPlayer extends EntityHuman { public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -225,7 +260,7 @@ @@ -234,7 +269,7 @@
private int levitationStartTime; private int levitationStartTime;
private boolean disconnected; private boolean disconnected;
private int requestedViewDistance; private int requestedViewDistance;
@ -51,7 +51,7 @@
@Nullable @Nullable
private Vec3D startingToFallPosition; private Vec3D startingToFallPosition;
@Nullable @Nullable
@@ -259,6 +294,22 @@ @@ -265,6 +300,22 @@
private int containerCounter; private int containerCounter;
public boolean wonGame; public boolean wonGame;
@ -74,7 +74,16 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) { public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile); super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL; this.chatVisibility = EnumChatVisibility.FULL;
@@ -340,6 +391,13 @@ @@ -329,7 +380,7 @@
@Override
public RemoteSlot createSlot() {
- LoadingCache loadingcache = this.cache;
+ LoadingCache<TypedDataComponent<?>,Integer> loadingcache = this.cache; // CraftBukkit - decompile error
Objects.requireNonNull(this.cache);
return new RemoteSlot.a(loadingcache::getUnchecked);
@@ -371,6 +422,13 @@
public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) { public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
EntityPlayer.this.sendSystemMessage(ichatbasecomponent); EntityPlayer.this.sendSystemMessage(ichatbasecomponent);
} }
@ -88,8 +97,8 @@
}; };
this.textFilter = minecraftserver.createTextFilterForPlayer(this); this.textFilter = minecraftserver.createTextFilterForPlayer(this);
this.gameMode = minecraftserver.createGameModeForPlayer(this); this.gameMode = minecraftserver.createGameModeForPlayer(this);
@@ -352,14 +410,67 @@ @@ -383,14 +441,67 @@
this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); this.snapTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
this.updateOptions(clientinformation); this.updateOptions(clientinformation);
this.object = null; this.object = null;
+ +
@ -102,7 +111,7 @@
+ // Use method to resend items in hands in case of client desync, because the item use got cancelled. + // Use method to resend items in hands in case of client desync, because the item use got cancelled.
+ // For example, when cancelling the leash event + // For example, when cancelling the leash event
+ public void resendItemInHands() { + public void resendItemInHands() {
+ containerMenu.findSlot(getInventory(), getInventory().selected).ifPresent(s -> { + containerMenu.findSlot(getInventory(), getInventory().getSelectedSlot()).ifPresent(s -> {
+ containerSynchronizer.sendSlotChange(containerMenu, s, getMainHandItem()); + containerSynchronizer.sendSlotChange(containerMenu, s, getMainHandItem());
+ }); + });
+ containerSynchronizer.sendSlotChange(inventoryMenu, ContainerPlayer.SHIELD_SLOT, getOffhandItem()); + containerSynchronizer.sendSlotChange(inventoryMenu, ContainerPlayer.SHIELD_SLOT, getOffhandItem());
@ -157,7 +166,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver)); int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -395,14 +506,20 @@ @@ -426,14 +537,20 @@
Objects.requireNonNull(blockposition); Objects.requireNonNull(blockposition);
crashreportsystemdetails.setDetail("Origin", blockposition::toString); crashreportsystemdetails.setDetail("Origin", blockposition::toString);
@ -174,76 +183,52 @@
+ // CraftBukkit start - decompile error + // CraftBukkit start - decompile error
+ int finalL1 = l1; + int finalL1 = l1;
crashreportsystemdetails.setDetail("Progress", () -> { crashreportsystemdetails.setDetail("Progress", () -> {
- return "" + l1 + " out of " + i1; - return l1 + " out of " + i1;
+ return "" + finalL1 + " out of " + i1; + return finalL1 + " out of " + i1;
+ // CraftBukkit end + // CraftBukkit end
}); });
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
@@ -440,7 +557,7 @@ @@ -465,18 +582,27 @@
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker"))); public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
logger = EntityPlayer.LOGGER; super.readAdditionalSaveData(nbttagcompound);
Objects.requireNonNull(logger); this.wardenSpawnTracker = (WardenSpawnTracker) nbttagcompound.read("warden_spawn_tracker", WardenSpawnTracker.CODEC).orElseGet(WardenSpawnTracker::new);
- dataresult.resultOrPartial(logger::error).ifPresent((wardenspawntracker) -> { - this.enteredNetherPosition = (Vec3D) nbttagcompound.read("entered_nether_pos", Vec3D.CODEC).orElse((Object) null);
+ ((DataResult<WardenSpawnTracker>) dataresult).resultOrPartial(logger::error).ifPresent((wardenspawntracker) -> { + this.enteredNetherPosition = (Vec3D) nbttagcompound.read("entered_nether_pos", Vec3D.CODEC).orElse(null); // CraftBukkit - decompile error
this.wardenSpawnTracker = wardenspawntracker; this.seenCredits = nbttagcompound.getBooleanOr("seenCredits", false);
}); this.recipeBook.fromNbt(nbttagcompound.getCompoundOrEmpty("recipeBook"), (resourcekey) -> {
}
@@ -457,17 +574,26 @@
return this.server.getRecipeManager().byKey(resourcekey).isPresent(); return this.server.getRecipeManager().byKey(resourcekey).isPresent();
}); });
}
+ this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit + this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
if (this.isSleeping()) { if (this.isSleeping()) {
this.stopSleeping(); this.stopSleeping();
} }
- this.respawnConfig = (EntityPlayer.RespawnConfig) nbttagcompound.read("respawn", EntityPlayer.RespawnConfig.CODEC).orElse((Object) null);
+ this.respawnConfig = (EntityPlayer.RespawnConfig) nbttagcompound.read("respawn", EntityPlayer.RespawnConfig.CODEC).orElse(null); // CraftBukkit - decompile error
+ // CraftBukkit start + // CraftBukkit start
+ String spawnWorld = nbttagcompound.getString("SpawnWorld"); + String spawnWorld = nbttagcompound.getStringOr("SpawnWorld", "");
+ CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld); + CraftWorld oldWorld = (CraftWorld) Bukkit.getWorld(spawnWorld);
+ if (oldWorld != null) { + if (oldWorld != null) {
+ this.respawnDimension = oldWorld.getHandle().dimension(); + EntityPlayer.RespawnConfig respawnConfig = this.respawnConfig;
+ this.respawnConfig = new RespawnConfig(oldWorld.getHandle().dimension(), respawnConfig.pos(), respawnConfig.angle(), respawnConfig.forced());
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ this.spawnExtraParticlesOnFall = nbttagcompound.getBooleanOr("spawn_extra_particles_on_fall", false);
if (nbttagcompound.contains("SpawnX", 99) && nbttagcompound.contains("SpawnY", 99) && nbttagcompound.contains("SpawnZ", 99)) { - this.raidOmenPosition = (BlockPosition) nbttagcompound.read("raid_omen_position", BlockPosition.CODEC).orElse((Object) null);
this.respawnPosition = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ")); + this.raidOmenPosition = (BlockPosition) nbttagcompound.read("raid_omen_position", BlockPosition.CODEC).orElse(null); // CraftBukkit - decompile error
this.respawnForced = nbttagcompound.getBoolean("SpawnForced");
this.respawnAngle = nbttagcompound.getFloat("SpawnAngle");
if (nbttagcompound.contains("SpawnDimension")) {
- DataResult dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension"));
+ DataResult<ResourceKey<World>> dataresult1 = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("SpawnDimension")); // CraftBukkit - decompile error
Logger logger1 = EntityPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -482,7 +608,7 @@
dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
- dataresult.resultOrPartial(logger::error).ifPresent((blockposition) -> {
+ ((DataResult<BlockPosition>) dataresult).resultOrPartial(logger::error).ifPresent((blockposition) -> { // CraftBukkit - decompile error
this.raidOmenPosition = blockposition;
});
} }
@@ -492,7 +618,7 @@
@Override @Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { @@ -490,6 +616,7 @@
super.addAdditionalSaveData(nbttagcompound); nbttagcompound.put("recipeBook", this.recipeBook.toNbt());
- DataResult dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); nbttagcompound.putString("Dimension", this.level().dimension().location().toString());
+ DataResult<NBTBase> dataresult = WardenSpawnTracker.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.wardenSpawnTracker); // CraftBukkit - decompile error nbttagcompound.storeNullable("respawn", EntityPlayer.RespawnConfig.CODEC, this.respawnConfig);
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -526,6 +652,7 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
if (this.raidOmenPosition != null) { nbttagcompound.storeNullable("raid_omen_position", BlockPosition.CODEC, this.raidOmenPosition);
@@ -544,7 +671,20 @@ this.saveEnderPearls(nbttagcompound);
@@ -499,7 +626,20 @@
Entity entity = this.getRootVehicle(); Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle(); Entity entity1 = this.getVehicle();
@ -265,61 +250,41 @@
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound2 = new NBTTagCompound();
@@ -598,12 +738,12 @@ @@ -521,7 +661,7 @@
});
if (entity != null) {
- UUID uuid = (UUID) ((NBTTagCompound) optional.get()).read("Attach", UUIDUtil.CODEC).orElse((Object) null);
+ UUID uuid = (UUID) ((NBTTagCompound) optional.get()).read("Attach", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error
if (entity.getUUID().equals(uuid)) {
this.startRiding(entity, true);
@@ -536,10 +676,10 @@
if (!this.isPassenger()) { if (!this.isPassenger()) {
EntityPlayer.LOGGER.warn("Couldn't reattach entity to player"); EntityPlayer.LOGGER.warn("Couldn't reattach entity to player");
- entity.discard(); - entity.discard();
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause + entity.discard(null); // CraftBukkit - add Bukkit remove cause
iterator = entity.getIndirectPassengers().iterator();
while (iterator.hasNext()) { for (Entity entity2 : entity.getIndirectPassengers()) {
entity1 = (Entity) iterator.next(); - entity2.discard();
- entity1.discard(); + entity2.discard(null); // CraftBukkit - add Bukkit remove cause
+ entity1.discard(null); // CraftBukkit - add Bukkit remove cause
} }
} }
@@ -597,6 +737,20 @@
} }
@@ -625,7 +765,7 @@
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
entityenderpearl.save(nbttagcompound1);
- DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location());
+ DataResult<NBTBase> dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, entityenderpearl.level().dimension().location()); // CraftBukkit - decompile error
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -651,7 +791,7 @@
nbttaglist.forEach((nbtbase1) -> {
if (nbtbase1 instanceof NBTTagCompound nbttagcompound) {
if (nbttagcompound.contains("ender_pearl_dimension")) {
- DataResult dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension"));
+ DataResult<ResourceKey<World>> dataresult = World.RESOURCE_KEY_CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("ender_pearl_dimension")); // CraftBukkit - decompile error
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -686,6 +826,29 @@
} }
+ // CraftBukkit start - World fallback code, either respawn location or global spawn + // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) { + public void spawnIn(World world, boolean flag) {
+ this.setLevel(world); + this.setLevel(world);
+ if (world == null) { + if (world == null) {
+ this.unsetRemoved(); + this.unsetRemoved();
+ Vec3D position = null; + TeleportTransition teleporttransition = this.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, null);
+ if (this.respawnDimension != null) { +
+ world = this.server.getLevel(this.respawnDimension); + this.setLevel(teleporttransition.newLevel());
+ if (world != null && this.getRespawnPosition() != null) { + this.setPos(teleporttransition.position());
+ position = EntityPlayer.findRespawnAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).map(EntityPlayer.RespawnPosAngle::position).orElse(null);
+ }
+ }
+ if (world == null || position == null) {
+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ position = Vec3D.atCenterOf(world.getSharedSpawnPos());
+ }
+ this.setLevel(world);
+ this.setPos(position);
+ } + }
+ this.gameMode.setLevel((WorldServer) world); + this.gameMode.setLevel((WorldServer) world);
+ } + }
@ -328,7 +293,7 @@
public void setExperiencePoints(int i) { public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel(); float f = (float) this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f; float f1 = (f - 1.0F) / f;
@@ -714,6 +877,7 @@ @@ -625,6 +779,7 @@
public void initMenu(Container container) { public void initMenu(Container container) {
container.addSlotListener(this.containerListener); container.addSlotListener(this.containerListener);
container.setSynchronizer(this.containerSynchronizer); container.setSynchronizer(this.containerSynchronizer);
@ -336,7 +301,7 @@
} }
public void initInventoryMenu() { public void initInventoryMenu() {
@@ -744,6 +908,11 @@ @@ -655,6 +810,11 @@
@Override @Override
public void tick() { public void tick() {
@ -348,7 +313,7 @@
this.tickClientLoadTimeout(); this.tickClientLoadTimeout();
this.gameMode.tick(); this.gameMode.tick();
this.wardenSpawnTracker.tick(); this.wardenSpawnTracker.tick();
@@ -820,7 +989,7 @@ @@ -731,7 +891,7 @@
} }
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@ -357,7 +322,7 @@
this.lastSentHealth = this.getHealth(); this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel(); this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -851,6 +1020,12 @@ @@ -762,6 +922,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience)); this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
} }
@ -370,7 +335,7 @@
if (this.experienceLevel != this.lastRecordedLevel) { if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel; this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel)); this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -865,6 +1040,20 @@ @@ -776,6 +942,20 @@
CriterionTriggers.LOCATION.trigger(this); CriterionTriggers.LOCATION.trigger(this);
} }
@ -391,7 +356,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -893,7 +1082,7 @@ @@ -804,7 +984,7 @@
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
if (this.getHealth() < this.getMaxHealth()) { if (this.getHealth() < this.getMaxHealth()) {
@ -400,7 +365,7 @@
} }
float f = this.foodData.getSaturationLevel(); float f = this.foodData.getSaturationLevel();
@@ -946,7 +1135,8 @@ @@ -857,7 +1037,8 @@
} }
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) { private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@ -410,7 +375,7 @@
scoreaccess.set(i); scoreaccess.set(i);
}); });
} }
@@ -955,9 +1145,47 @@ @@ -866,9 +1047,47 @@
public void die(DamageSource damagesource) { public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE); this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@ -424,14 +389,14 @@
- if (flag) { - if (flag) {
- IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage(); - IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage();
+ if (!keepInventory) { + if (!keepInventory) {
+ for (ItemStack item : this.getInventory().getContents()) { + for (ItemStack item : this.getInventory()) {
+ if (!item.isEmpty() && !EnchantmentManager.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { + if (!item.isEmpty() && !EnchantmentManager.has(item, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
+ loot.add(CraftItemStack.asCraftMirror(item).markForInventoryDrop()); + loot.add(CraftItemStack.asCraftMirror(item).markForInventoryDrop());
+ } + }
+ } + }
+ } + }
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
+ this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerTime > 0); + this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerMemoryTime > 0);
+ this.dropCustomDeathLoot(this.serverLevel(), damagesource, flag); + this.dropCustomDeathLoot(this.serverLevel(), damagesource, flag);
+ +
+ loot.addAll(this.drops); + loot.addAll(this.drops);
@ -459,8 +424,8 @@
+ } + }
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> { this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true; int i = 256;
@@ -988,12 +1216,18 @@ @@ -899,12 +1118,18 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied(); this.tellNeutralMobsThatIDied();
} }
@ -483,7 +448,7 @@
EntityLiving entityliving = this.getKillCredit(); EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) { if (entityliving != null) {
@@ -1028,10 +1262,12 @@ @@ -939,10 +1164,12 @@
public void awardKillScore(Entity entity, DamageSource damagesource) { public void awardKillScore(Entity entity, DamageSource damagesource) {
if (entity != this) { if (entity != this) {
super.awardKillScore(entity, damagesource); super.awardKillScore(entity, damagesource);
@ -498,7 +463,7 @@
} else { } else {
this.awardStat(StatisticList.MOB_KILLS); this.awardStat(StatisticList.MOB_KILLS);
} }
@@ -1049,7 +1285,8 @@ @@ -960,7 +1187,8 @@
int i = scoreboardteam.getColor().getId(); int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) { if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -508,7 +473,7 @@
} }
} }
@@ -1093,10 +1330,16 @@ @@ -1004,10 +1232,16 @@
} }
private boolean isPvpAllowed() { private boolean isPvpAllowed() {
@ -524,10 +489,10 @@
+ boolean isBedSpawn = false; + boolean isBedSpawn = false;
+ boolean isAnchorSpawn = false; + boolean isAnchorSpawn = false;
+ // CraftBukkit end + // CraftBukkit end
BlockPosition blockposition = this.getRespawnPosition(); EntityPlayer.RespawnConfig entityplayer_respawnconfig = this.getRespawnConfig();
float f = this.getRespawnAngle(); WorldServer worldserver = this.server.getLevel(EntityPlayer.RespawnConfig.getDimensionOrDefault(entityplayer_respawnconfig));
boolean flag1 = this.isRespawnForced();
@@ -1108,13 +1351,32 @@ @@ -1017,13 +1251,32 @@
if (optional.isPresent()) { if (optional.isPresent()) {
EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get(); EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get();
@ -562,8 +527,8 @@
+ // CraftBukkit end + // CraftBukkit end
} }
public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) { public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag) {
@@ -1129,11 +1391,11 @@ @@ -1041,11 +1294,11 @@
} }
return optional.map((vec3d) -> { return optional.map((vec3d) -> {
@ -575,9 +540,9 @@
- return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition); - return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition);
+ return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, true, false); // CraftBukkit + return EntityPlayer.RespawnPosAngle.of(vec3d, blockposition, true, false); // CraftBukkit
}); });
} else if (!flag) { } else if (!flag1) {
return Optional.empty(); return Optional.empty();
@@ -1142,7 +1404,7 @@ @@ -1054,7 +1307,7 @@
IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above()); IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above());
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1); boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
@ -586,7 +551,7 @@
} }
} }
@@ -1160,6 +1422,7 @@ @@ -1072,6 +1325,7 @@
@Nullable @Nullable
@Override @Override
public EntityPlayer teleport(TeleportTransition teleporttransition) { public EntityPlayer teleport(TeleportTransition teleporttransition) {
@ -594,7 +559,7 @@
if (this.isRemoved()) { if (this.isRemoved()) {
return null; return null;
} else { } else {
@@ -1169,18 +1432,38 @@ @@ -1081,18 +1335,38 @@
WorldServer worldserver = teleporttransition.newLevel(); WorldServer worldserver = teleporttransition.newLevel();
WorldServer worldserver1 = this.serverLevel(); WorldServer worldserver1 = this.serverLevel();
@ -618,7 +583,7 @@
+ // CraftBukkit end + // CraftBukkit end
if (!teleporttransition.asPassenger()) { if (!teleporttransition.asPassenger()) {
this.stopRiding(); this.removeVehicle();
} }
- if (worldserver.dimension() == resourcekey) { - if (worldserver.dimension() == resourcekey) {
@ -636,7 +601,7 @@
this.isChangingDimension = true; this.isChangingDimension = true;
WorldData worlddata = worldserver.getLevelData(); WorldData worlddata = worldserver.getLevelData();
@@ -1191,17 +1474,31 @@ @@ -1103,17 +1377,31 @@
playerlist.sendPlayerPermissionLevel(this); playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved(); this.unsetRemoved();
@ -670,7 +635,7 @@
this.connection.resetPosition(); this.connection.resetPosition();
worldserver.addDuringTeleport(this); worldserver.addDuringTeleport(this);
gameprofilerfiller.pop(); gameprofilerfiller.pop();
@@ -1215,11 +1512,29 @@ @@ -1127,11 +1415,29 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
@ -700,7 +665,7 @@
@Override @Override
public void forceSetRotation(float f, float f1) { public void forceSetRotation(float f, float f1) {
this.connection.send(new ClientboundPlayerRotationPacket(f, f1)); this.connection.send(new ClientboundPlayerRotationPacket(f, f1));
@@ -1228,13 +1543,21 @@ @@ -1140,13 +1446,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) { public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension(); ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level().dimension(); ResourceKey<World> resourcekey1 = this.level().dimension();
@ -725,7 +690,7 @@
this.enteredNetherPosition = null; this.enteredNetherPosition = null;
} }
@@ -1251,19 +1574,17 @@ @@ -1163,19 +1477,17 @@
this.containerMenu.broadcastChanges(); this.containerMenu.broadcastChanges();
} }
@ -744,12 +709,12 @@
} else if (this.bedBlocked(blockposition, enumdirection)) { } else if (this.bedBlocked(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.OBSTRUCTED); return Either.left(EntityHuman.EnumBedResult.OBSTRUCTED);
} else { } else {
- this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true); - this.setRespawnPosition(new EntityPlayer.RespawnConfig(this.level().dimension(), blockposition, this.getYRot(), false), true);
+ this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit + this.setRespawnPosition(new EntityPlayer.RespawnConfig(this.level().dimension(), blockposition, this.getYRot(), false), true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit
if (this.level().isDay()) { if (this.level().isBrightOutside()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW); return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
} else { } else {
@@ -1280,7 +1601,36 @@ @@ -1192,7 +1504,36 @@
} }
} }
@ -787,7 +752,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED); this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this); CriterionTriggers.SLEPT_IN_BED.trigger(this);
}); });
@@ -1293,9 +1643,8 @@ @@ -1205,9 +1546,8 @@
return either; return either;
} }
} }
@ -798,7 +763,7 @@
} }
@Override @Override
@@ -1322,13 +1671,31 @@ @@ -1234,13 +1574,31 @@
@Override @Override
public void stopSleepInBed(boolean flag, boolean flag1) { public void stopSleepInBed(boolean flag, boolean flag1) {
@ -831,7 +796,7 @@
} }
} }
@@ -1387,8 +1754,9 @@ @@ -1293,8 +1651,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag)); this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
} }
@ -842,7 +807,7 @@
} }
@Override @Override
@@ -1396,13 +1764,35 @@ @@ -1302,13 +1661,35 @@
if (itileinventory == null) { if (itileinventory == null) {
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@ -878,7 +843,7 @@
if (container == null) { if (container == null) {
if (this.isSpectator()) { if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1410,9 +1800,11 @@ @@ -1316,9 +1697,11 @@
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@ -892,7 +857,7 @@
return OptionalInt.of(this.containerCounter); return OptionalInt.of(this.containerCounter);
} }
} }
@@ -1425,15 +1817,26 @@ @@ -1331,15 +1714,26 @@
@Override @Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -921,7 +886,7 @@
this.initMenu(this.containerMenu); this.initMenu(this.containerMenu);
} }
@@ -1456,6 +1859,7 @@ @@ -1362,6 +1756,7 @@
@Override @Override
public void closeContainer() { public void closeContainer() {
@ -929,47 +894,49 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer(); this.doCloseContainer();
} }
@@ -1485,19 +1889,19 @@ @@ -1390,21 +1785,21 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) { if (i > 0) {
this.awardStat(StatisticList.SWIM_ONE_CM, i); this.awardStat(StatisticList.SWIM_ONE_CM, i);
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F); - this.causeFoodExhaustion(0.01F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent
} }
} else if (this.isEyeInFluid(TagsFluid.WATER)) { } else if (this.isEyeInFluid(TagsFluid.WATER)) {
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); int j = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, i); if (j > 0) {
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F); this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, j);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent - this.causeFoodExhaustion(0.01F * (float) j * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) j * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent
} }
} else if (this.isInWater()) { } else if (this.isInWater()) {
i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F); int k = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, i); if (k > 0) {
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F); this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, k);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent - this.causeFoodExhaustion(0.01F * (float) k * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) k * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent
} }
} else if (this.onClimbable()) { } else if (this.onClimbable()) {
if (d1 > 0.0D) { if (d1 > 0.0D) {
@@ -1508,13 +1912,13 @@ @@ -1416,13 +1811,13 @@
if (i > 0) { if (l > 0) {
if (this.isSprinting()) { if (this.isSprinting()) {
this.awardStat(StatisticList.SPRINT_ONE_CM, i); this.awardStat(StatisticList.SPRINT_ONE_CM, l);
- this.causeFoodExhaustion(0.1F * (float) i * 0.01F); - this.causeFoodExhaustion(0.1F * (float) l * 0.01F);
+ this.causeFoodExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(0.1F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent
} else if (this.isCrouching()) { } else if (this.isCrouching()) {
this.awardStat(StatisticList.CROUCH_ONE_CM, i); this.awardStat(StatisticList.CROUCH_ONE_CM, l);
- this.causeFoodExhaustion(0.0F * (float) i * 0.01F); - this.causeFoodExhaustion(0.0F * (float) l * 0.01F);
+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(0.0F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent
} else { } else {
this.awardStat(StatisticList.WALK_ONE_CM, i); this.awardStat(StatisticList.WALK_ONE_CM, l);
- this.causeFoodExhaustion(0.0F * (float) i * 0.01F); - this.causeFoodExhaustion(0.0F * (float) l * 0.01F);
+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent + this.causeFoodExhaustion(0.0F * (float) l * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent
} }
} }
} else if (this.isFallFlying()) { } else if (this.isFallFlying()) {
@@ -1557,7 +1961,7 @@ @@ -1467,7 +1862,7 @@
@Override @Override
public void awardStat(Statistic<?> statistic, int i) { public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i); this.stats.increment(this, statistic, i);
@ -978,7 +945,7 @@
scoreaccess.add(i); scoreaccess.add(i);
}); });
} }
@@ -1565,7 +1969,7 @@ @@ -1475,7 +1870,7 @@
@Override @Override
public void resetStat(Statistic<?> statistic) { public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0); this.stats.setValue(this, statistic, 0);
@ -987,7 +954,7 @@
} }
@Override @Override
@@ -1597,9 +2001,9 @@ @@ -1507,9 +1902,9 @@
super.jumpFromGround(); super.jumpFromGround();
this.awardStat(StatisticList.JUMP); this.awardStat(StatisticList.JUMP);
if (this.isSprinting()) { if (this.isSprinting()) {
@ -999,7 +966,7 @@
} }
} }
@@ -1625,6 +2029,7 @@ @@ -1535,6 +1930,7 @@
public void resetSentInfo() { public void resetSentInfo() {
this.lastSentHealth = -1.0E8F; this.lastSentHealth = -1.0E8F;
@ -1007,7 +974,7 @@
} }
@Override @Override
@@ -1661,7 +2066,7 @@ @@ -1571,12 +1967,12 @@
this.onUpdateAbilities(); this.onUpdateAbilities();
if (flag) { if (flag) {
this.getAttributes().assignBaseValues(entityplayer.getAttributes()); this.getAttributes().assignBaseValues(entityplayer.getAttributes());
@ -1015,17 +982,14 @@
+ // this.getAttributes().assignPermanentModifiers(entityplayer.getAttributes()); // CraftBukkit + // this.getAttributes().assignPermanentModifiers(entityplayer.getAttributes()); // CraftBukkit
this.setHealth(entityplayer.getHealth()); this.setHealth(entityplayer.getHealth());
this.foodData = entityplayer.foodData; this.foodData = entityplayer.foodData;
Iterator iterator = entityplayer.getActiveEffects().iterator();
@@ -1669,7 +2074,7 @@
while (iterator.hasNext()) {
MobEffect mobeffect = (MobEffect) iterator.next();
for (MobEffect mobeffect : entityplayer.getActiveEffects()) {
- this.addEffect(new MobEffect(mobeffect)); - this.addEffect(new MobEffect(mobeffect));
+ // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit + // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit
} }
this.getInventory().replaceWith(entityplayer.getInventory()); this.getInventory().replaceWith(entityplayer.getInventory());
@@ -1680,7 +2085,7 @@ @@ -1587,7 +1983,7 @@
this.portalProcess = entityplayer.portalProcess; this.portalProcess = entityplayer.portalProcess;
} else { } else {
this.getAttributes().assignBaseValues(entityplayer.getAttributes()); this.getAttributes().assignBaseValues(entityplayer.getAttributes());
@ -1034,7 +998,7 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) { if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) {
this.getInventory().replaceWith(entityplayer.getInventory()); this.getInventory().replaceWith(entityplayer.getInventory());
this.experienceLevel = entityplayer.experienceLevel; this.experienceLevel = entityplayer.experienceLevel;
@@ -1696,7 +2101,7 @@ @@ -1603,7 +1999,7 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
@ -1043,7 +1007,7 @@
this.seenCredits = entityplayer.seenCredits; this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition; this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.chunkTrackingView = entityplayer.chunkTrackingView; this.chunkTrackingView = entityplayer.chunkTrackingView;
@@ -1752,7 +2157,7 @@ @@ -1656,7 +2052,7 @@
} }
@Override @Override
@ -1052,7 +1016,7 @@
if (this.isSleeping()) { if (this.isSleeping()) {
this.stopSleepInBed(true, true); this.stopSleepInBed(true, true);
} }
@@ -1761,7 +2166,7 @@ @@ -1665,7 +2061,7 @@
this.setCamera(this); this.setCamera(this);
} }
@ -1061,7 +1025,7 @@
if (flag1) { if (flag1) {
this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f); this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f);
@@ -1878,6 +2283,16 @@ @@ -1778,6 +2174,16 @@
} }
public void updateOptions(ClientInformation clientinformation) { public void updateOptions(ClientInformation clientinformation) {
@ -1078,7 +1042,7 @@
this.language = clientinformation.language(); this.language = clientinformation.language();
this.requestedViewDistance = clientinformation.viewDistance(); this.requestedViewDistance = clientinformation.viewDistance();
this.chatVisibility = clientinformation.chatVisibility(); this.chatVisibility = clientinformation.chatVisibility();
@@ -1962,7 +2377,13 @@ @@ -1862,7 +2268,13 @@
if (world instanceof WorldServer) { if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world; WorldServer worldserver = (WorldServer) world;
@ -1093,7 +1057,7 @@
} }
if (entity != null) { if (entity != null) {
@@ -1999,11 +2420,11 @@ @@ -1899,11 +2311,11 @@
@Nullable @Nullable
public IChatBaseComponent getTabListDisplayName() { public IChatBaseComponent getTabListDisplayName() {
@ -1107,80 +1071,62 @@
} }
@Override @Override
@@ -2046,6 +2467,32 @@ @@ -1934,6 +2346,32 @@
} }
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) { public void setRespawnPosition(@Nullable EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag) {
+ // CraftBukkit start + // CraftBukkit start
+ this.setRespawnPosition(resourcekey, blockposition, f, flag, flag1, PlayerSpawnChangeEvent.Cause.UNKNOWN); + this.setRespawnPosition(entityplayer_respawnconfig, flag, PlayerSpawnChangeEvent.Cause.UNKNOWN);
+ } + }
+ +
+ public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) { + public void setRespawnPosition(@Nullable EntityPlayer.RespawnConfig entityplayer_respawnconfig, boolean flag, PlayerSpawnChangeEvent.Cause cause) {
+ WorldServer newWorld = this.server.getLevel(resourcekey); + Location newSpawn = null;
+ Location newSpawn = (blockposition != null) ? CraftLocation.toBukkit(blockposition, newWorld.getWorld(), f, 0) : null; + boolean forced = false;
+ if (entityplayer_respawnconfig != null) {
+ WorldServer newWorld = this.server.getLevel(entityplayer_respawnconfig.dimension());
+ newSpawn = CraftLocation.toBukkit(entityplayer_respawnconfig.pos(), newWorld.getWorld(), entityplayer_respawnconfig.angle(), 0);
+ forced = respawnConfig.forced();
+ }
+ +
+ PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, flag, cause); + PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, forced, cause);
+ Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ newSpawn = event.getNewSpawn(); + newSpawn = event.getNewSpawn();
+ flag = event.isForced();
+ +
+ if (newSpawn != null) { + if (newSpawn != null) {
+ resourcekey = ((CraftWorld) newSpawn.getWorld()).getHandle().dimension(); + entityplayer_respawnconfig = new EntityPlayer.RespawnConfig(((CraftWorld) newSpawn.getWorld()).getHandle().dimension(), BlockPosition.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ()), newSpawn.getYaw(), event.isForced());
+ blockposition = BlockPosition.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ());
+ f = newSpawn.getYaw();
+ } else { + } else {
+ resourcekey = World.OVERWORLD; + entityplayer_respawnconfig = null;
+ blockposition = null;
+ f = 0.0F;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (blockposition != null) { if (flag && entityplayer_respawnconfig != null && !entityplayer_respawnconfig.isSamePosition(this.respawnConfig)) {
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension); this.sendSystemMessage(EntityPlayer.SPAWN_SET_MESSAGE);
}
@@ -2088,12 +2535,38 @@ @@ -1963,8 +2401,10 @@
} }
@Override @Override
- public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { - public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { // CraftBukkit - SPIGOT-2942: Add boolean to call event - EntityItem entityitem = super.drop(itemstack, flag, flag1);
EntityItem entityitem = this.createItemStackToDrop(itemstack, flag, flag1); + // CraftBukkit start - SPIGOT-2942: Add boolean to call event
+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) {
if (entityitem == null) { + EntityItem entityitem = super.drop(itemstack, flag, flag1, callEvent);
return null;
} else {
+ // CraftBukkit start - fire PlayerDropItemEvent
+ if (callEvent) {
+ Player player = (Player) this.getBukkitEntity();
+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
+
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
+ // The complete stack was dropped
+ player.getInventory().setItemInHand(drop.getItemStack());
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
+ // Only one item is dropped
+ cur.setAmount(cur.getAmount() + 1);
+ player.getInventory().setItemInHand(cur);
+ } else {
+ // Fallback
+ player.getInventory().addItem(drop.getItemStack());
+ }
+ return null;
+ }
+ }
+ // CraftBukkit end + // CraftBukkit end
+
this.level().addFreshEntity(entityitem);
ItemStack itemstack1 = entityitem.getItem();
@@ -2375,10 +2848,12 @@ if (flag1) {
ItemStack itemstack1 = entityitem != null ? entityitem.getItem() : ItemStack.EMPTY;
@@ -1989,7 +2429,7 @@
@Nullable
private static EnumGamemode readPlayerMode(@Nullable NBTTagCompound nbttagcompound, String s) {
- return nbttagcompound != null ? (EnumGamemode) nbttagcompound.read(s, EnumGamemode.LEGACY_ID_CODEC).orElse((Object) null) : null;
+ return nbttagcompound != null ? (EnumGamemode) nbttagcompound.read(s, EnumGamemode.LEGACY_ID_CODEC).orElse(null) : null; // CraftBukkit - decompile error
}
private EnumGamemode calculateGameModeForNewPlayer(@Nullable EnumGamemode enumgamemode) {
@@ -2206,10 +2646,12 @@
return TicketType.ENDER_PEARL.timeout(); return TicketType.ENDER_PEARL.timeout();
} }
@ -1196,11 +1142,10 @@
} }
private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) { private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) {
@@ -2387,4 +2862,146 @@ @@ -2219,6 +2661,148 @@
return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
} }
} }
+
+ // CraftBukkit start - Add per-player time and weather. + // CraftBukkit start - Add per-player time and weather.
+ public long timeOffset = 0; + public long timeOffset = 0;
+ public boolean relativeTime = true; + public boolean relativeTime = true;
@ -1287,7 +1232,7 @@
+ +
+ // SPIGOT-1903, MC-98153 + // SPIGOT-1903, MC-98153
+ public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) { + public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) {
+ this.moveTo(x, y, z, yaw, pitch); + this.snapTo(x, y, z, yaw, pitch);
+ this.connection.resetPosition(); + this.connection.resetPosition();
+ } + }
+ +
@ -1342,4 +1287,7 @@
+ return (CraftPlayer) super.getBukkitEntity(); + return (CraftPlayer) super.getBukkitEntity();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} +
public static record RespawnConfig(ResourceKey<World> dimension, BlockPosition pos, float angle, boolean forced) {
public static final Codec<EntityPlayer.RespawnConfig> CODEC = RecordCodecBuilder.create((instance) -> {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityTrackerEntry.java --- a/net/minecraft/server/level/EntityTrackerEntry.java
+++ b/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java
@@ -50,6 +50,12 @@ @@ -52,6 +52,12 @@
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -13,30 +13,29 @@
public class EntityTrackerEntry { public class EntityTrackerEntry {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -74,8 +80,12 @@ @@ -77,8 +83,12 @@
private boolean wasOnGround; private boolean wasOnGround;
@Nullable @Nullable
private List<DataWatcher.c<?>> trackedDataValues; private List<DataWatcher.c<?>> trackedDataValues;
+ // CraftBukkit start + // CraftBukkit start
+ private final Set<ServerPlayerConnection> trackedPlayers; + private final Set<ServerPlayerConnection> trackedPlayers;
- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer) { - public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, BiConsumer<Packet<?>, List<UUID>> biconsumer) {
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) { + public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, BiConsumer<Packet<?>, List<UUID>> biconsumer, Set<ServerPlayerConnection> trackedPlayers) {
+ this.trackedPlayers = trackedPlayers; + this.trackedPlayers = trackedPlayers;
+ // CraftBukkit end + // CraftBukkit end
this.level = worldserver; this.level = worldserver;
this.broadcast = consumer; this.broadcast = consumer;
this.entity = entity; this.entity = entity;
@@ -94,7 +104,7 @@ @@ -100,22 +110,23 @@
List<Entity> list = this.entity.getPassengers();
if (!list.equals(this.lastPassengers)) { if (!list.equals(this.lastPassengers)) {
- this.broadcast.accept(new PacketPlayOutMount(this.entity)); List<UUID> list1 = this.mountedOrDismounted(list).map(Entity::getUUID).toList();
+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit
removedPassengers(list, this.lastPassengers).forEach((entity) -> { - this.broadcastWithIgnore.accept(new PacketPlayOutMount(this.entity), list1);
if (entity instanceof EntityPlayer entityplayer) { + this.broadcastWithIgnoreAndSend(new PacketPlayOutMount(this.entity), list1); // CraftBukkit
entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); this.lastPassengers = list;
@@ -107,18 +117,18 @@ }
Entity entity = this.entity; Entity entity = this.entity;
if (entity instanceof EntityItemFrame entityitemframe) { if (entity instanceof EntityItemFrame entityitemframe) {
@ -50,16 +49,13 @@
WorldMap worldmap = ItemWorldMap.getSavedData(mapid, this.level); WorldMap worldmap = ItemWorldMap.getSavedData(mapid, this.level);
if (worldmap != null) { if (worldmap != null) {
- Iterator iterator = this.level.players().iterator(); - for (EntityPlayer entityplayer : this.level.players()) {
+ Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit + for (ServerPlayerConnection connection : this.trackedPlayers) { // CraftBukkit
+ EntityPlayer entityplayer = connection.getPlayer(); // CraftBukkit
while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit
worldmap.tickCarriedBy(entityplayer, itemstack); worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(mapid, entityplayer); Packet<?> packet = worldmap.getUpdatePacket(mapid, entityplayer);
@@ -248,6 +258,27 @@
@@ -244,6 +255,27 @@
++this.tickCount; ++this.tickCount;
if (this.entity.hurtMarked) { if (this.entity.hurtMarked) {
@ -87,7 +83,7 @@
this.entity.hurtMarked = false; this.entity.hurtMarked = false;
this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity)); this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
} }
@@ -298,7 +329,10 @@ @@ -296,7 +328,10 @@
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) { public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
if (this.entity.isRemoved()) { if (this.entity.isRemoved()) {
@ -99,7 +95,7 @@
} }
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket(this); Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket(this);
@@ -313,6 +347,12 @@ @@ -311,6 +346,12 @@
if (this.entity instanceof EntityLiving) { if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes(); Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
@ -112,7 +108,7 @@
if (!collection.isEmpty()) { if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection)); consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
} }
@@ -344,6 +384,7 @@ @@ -340,6 +381,7 @@
if (!list.isEmpty()) { if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list)); consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
} }
@ -120,7 +116,7 @@
} }
if (!this.entity.getPassengers().isEmpty()) { if (!this.entity.getPassengers().isEmpty()) {
@@ -396,6 +437,11 @@ @@ -392,6 +434,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync(); Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync();
if (!set.isEmpty()) { if (!set.isEmpty()) {
@ -132,3 +128,18 @@
this.broadcastAndSend(new PacketPlayOutUpdateAttributes(this.entity.getId(), set)); this.broadcastAndSend(new PacketPlayOutUpdateAttributes(this.entity.getId(), set));
} }
@@ -407,4 +454,14 @@
}
}
+
+ // CraftBukkit start
+ private void broadcastWithIgnoreAndSend(Packet<?> packet, List<UUID> list) {
+ this.broadcastWithIgnore.accept(packet, list);
+ if (this.entity instanceof EntityPlayer) {
+ ((EntityPlayer) this.entity).connection.send(packet);
+ }
+
+ }
+ // CraftBukkit end
}

View File

@ -60,20 +60,7 @@
if (this.changedBlocksPerSection[i] == null) { if (this.changedBlocksPerSection[i] == null) {
this.hasChangedSections = true; this.hasChangedSections = true;
this.changedBlocksPerSection[i] = new ShortOpenHashSet(); this.changedBlocksPerSection[i] = new ShortOpenHashSet();
@@ -224,8 +241,11 @@ @@ -291,7 +308,7 @@
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
this.broadcast(list, packetplayoutmultiblockchange);
+ // CraftBukkit start
+ List finalList = list;
packetplayoutmultiblockchange.runUpdates((blockposition1, iblockdata1) -> {
- this.broadcastBlockEntityIfNeeded(list, world, blockposition1, iblockdata1);
+ this.broadcastBlockEntityIfNeeded(finalList, world, blockposition1, iblockdata1);
+ // CraftBukkit end
});
}
}
@@ -291,7 +311,7 @@
this.pendingFullStateConfirmation = completablefuture1; this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((chunkresult) -> { completablefuture.thenAccept((chunkresult) -> {
chunkresult.ifSuccess((chunk) -> { chunkresult.ifSuccess((chunk) -> {
@ -82,7 +69,7 @@
}); });
}); });
} }
@@ -301,6 +321,38 @@ @@ -301,6 +318,38 @@
playerchunkmap.onFullChunkStatusChange(this.pos, fullchunkstatus); playerchunkmap.onFullChunkStatusChange(this.pos, fullchunkstatus);
} }
@ -121,7 +108,7 @@
protected void updateFutures(PlayerChunkMap playerchunkmap, Executor executor) { protected void updateFutures(PlayerChunkMap playerchunkmap, Executor executor) {
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel); FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel); FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
@@ -357,6 +409,26 @@ @@ -357,6 +406,26 @@
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel); this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
this.oldTicketLevel = this.ticketLevel; this.oldTicketLevel = this.ticketLevel;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java --- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -104,6 +104,10 @@ @@ -105,6 +105,10 @@
import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableBoolean;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -11,7 +11,7 @@
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap { public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.b, GeneratingChunkMap {
private static final ChunkResult<List<IChunkAccess>> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); private static final ChunkResult<List<IChunkAccess>> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range");
@@ -149,6 +153,27 @@ @@ -151,6 +155,27 @@
public int serverViewDistance; public int serverViewDistance;
private final WorldGenContext worldGenContext; private final WorldGenContext worldGenContext;
@ -36,10 +36,10 @@
+ }; + };
+ // CraftBukkit end + // CraftBukkit end
+ +
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) { public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, TicketStorage ticketstorage, int i, boolean flag) {
super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag); super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone(); this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -170,7 +195,13 @@ @@ -172,7 +197,13 @@
IRegistryCustom iregistrycustom = worldserver.registryAccess(); IRegistryCustom iregistrycustom = worldserver.registryAccess();
long j = worldserver.getSeed(); long j = worldserver.getSeed();
@ -51,29 +51,29 @@
+ } + }
+ if (randomGenerator instanceof ChunkGeneratorAbstract chunkgeneratorabstract) { + if (randomGenerator instanceof ChunkGeneratorAbstract chunkgeneratorabstract) {
+ // CraftBukkit end + // CraftBukkit end
this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), iregistrycustom.lookupOrThrow(Registries.NOISE), j);
} else { } else {
this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j); this.randomState = RandomState.create(GeneratorSettingBase.dummy(), iregistrycustom.lookupOrThrow(Registries.NOISE), j);
@@ -325,7 +356,7 @@ @@ -316,7 +347,7 @@
throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a"); throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a");
} }
- IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse((Object) null); - IChunkAccess ichunkaccess = chunkresult.orElse((Object) null);
+ IChunkAccess ichunkaccess = (IChunkAccess) chunkresult.orElse(null); // CraftBukkit - decompile error + IChunkAccess ichunkaccess = chunkresult.orElse(null); // CraftBukkit - decompile error
if (ichunkaccess == null) { if (ichunkaccess == null) {
return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT; return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT;
@@ -977,7 +1008,8 @@ @@ -961,7 +992,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
}); });
- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { - csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.ticketStorage.getTicketDebugString(i, false), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> { + csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getPersistedStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.ticketStorage.getTicketDebugString(i, false), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
return chunk.getBlockEntities().size(); return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { }).orElse(0), this.ticketStorage.getTicketDebugString(i, true), this.distanceManager.getChunkLevel(i, true), optional1.map((chunk) -> {
return chunk.getBlockTicks().count(); return chunk.getBlockTicks().count();
@@ -990,7 +1022,7 @@ @@ -974,7 +1006,7 @@
private static String printFuture(CompletableFuture<ChunkResult<Chunk>> completablefuture) { private static String printFuture(CompletableFuture<ChunkResult<Chunk>> completablefuture) {
try { try {
@ -82,7 +82,7 @@
return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed"; return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed";
} catch (CompletionException completionexception) { } catch (CompletionException completionexception) {
@@ -1002,12 +1034,14 @@ @@ -986,12 +1018,14 @@
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) { private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> { return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
@ -99,17 +99,17 @@
+ // CraftBukkit end + // CraftBukkit end
} }
void forEachSpawnCandidateChunk(Consumer<PlayerChunk> consumer) { void collectSpawningChunks(List<Chunk> list) {
@@ -1424,7 +1458,7 @@ @@ -1413,7 +1447,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet(); public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) { public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) {
- this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast); - this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, this::broadcastIgnorePlayers);
+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit + this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, this::broadcastIgnorePlayers, seenBy); // CraftBukkit
this.entity = entity; this.entity = entity;
this.range = i; this.range = i;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity); this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1484,6 +1518,11 @@ @@ -1474,6 +1508,11 @@
double d2 = d0 * d0; double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z); boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z);

View File

@ -52,15 +52,15 @@
public void tick() { public void tick() {
- ++this.gameTicks; - ++this.gameTicks;
+ this.gameTicks = MinecraftServer.currentTick; // CraftBukkit; + this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
IBlockData iblockdata;
if (this.hasDelayedDestroy) { if (this.hasDelayedDestroy) {
@@ -146,11 +174,33 @@ IBlockData iblockdata = this.level.getBlockState(this.delayedDestroyPos);
@@ -144,11 +172,33 @@
} else {
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, blockposition)) { if (!this.level.mayInteract(this.player, blockposition)) {
+ // CraftBukkit start - fire PlayerInteractEvent + // CraftBukkit start - fire PlayerInteractEvent
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND);
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition))); this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
this.debugLogging(blockposition, false, j, "may not interact"); this.debugLogging(blockposition, false, j, "may not interact");
+ // Update any tile entity data for this block + // Update any tile entity data for this block
@ -73,7 +73,7 @@
} }
+ // CraftBukkit start + // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // Let the client know the block still exists + // Let the client know the block still exists
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); + this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
@ -86,13 +86,13 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.isCreative()) { if (this.player.getAbilities().instabuild) {
this.destroyAndAck(blockposition, j, "creative destroy"); this.destroyAndAck(blockposition, j, "creative destroy");
return; return;
@@ -166,7 +216,19 @@ @@ -164,7 +214,19 @@
float f = 1.0F; float f = 1.0F;
IBlockData iblockdata = this.level.getBlockState(blockposition);
iblockdata = this.level.getBlockState(blockposition);
- if (!iblockdata.isAir()) { - if (!iblockdata.isAir()) {
+ // CraftBukkit start - Swings at air do *NOT* exist. + // CraftBukkit start - Swings at air do *NOT* exist.
+ if (event.useInteractedBlock() == Event.Result.DENY) { + if (event.useInteractedBlock() == Event.Result.DENY) {
@ -110,7 +110,7 @@
EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> { EnchantmentManager.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EnumItemSlot.MAINHAND, Vec3D.atCenterOf(blockposition), iblockdata, (item) -> {
this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND); this.player.onEquippedItemBroken(item, EnumItemSlot.MAINHAND);
}); });
@@ -174,6 +236,26 @@ @@ -172,6 +234,26 @@
f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition); f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition);
} }
@ -121,7 +121,7 @@
+ } + }
+ return; + return;
+ } + }
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelected(), f >= 1.0f); + org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition, this.player.getInventory().getSelectedItem(), f >= 1.0f);
+ +
+ if (blockEvent.isCancelled()) { + if (blockEvent.isCancelled()) {
+ // Let the client know the block still exists + // Let the client know the block still exists
@ -137,7 +137,7 @@
if (!iblockdata.isAir() && f >= 1.0F) { if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, j, "insta mine"); this.destroyAndAck(blockposition, j, "insta mine");
} else { } else {
@@ -218,13 +300,15 @@ @@ -216,13 +298,15 @@
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false; this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, blockposition)) { if (!Objects.equals(this.destroyPos, blockposition)) {
@ -150,11 +150,11 @@
this.level.destroyBlockProgress(this.player.getId(), blockposition, -1); this.level.destroyBlockProgress(this.player.getId(), blockposition, -1);
this.debugLogging(blockposition, true, j, "aborted destroying"); this.debugLogging(blockposition, true, j, "aborted destroying");
+ +
+ CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelected()); // CraftBukkit + CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelectedItem()); // CraftBukkit
} }
} }
@@ -242,10 +326,65 @@ @@ -240,10 +324,65 @@
public boolean destroyBlock(BlockPosition blockposition) { public boolean destroyBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.level.getBlockState(blockposition); IBlockData iblockdata = this.level.getBlockState(blockposition);
@ -162,10 +162,10 @@
+ org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition); + org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
+ BlockBreakEvent event = null; + BlockBreakEvent event = null;
- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { - if (!this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player)) {
+ if (this.player instanceof EntityPlayer) { + if (this.player instanceof EntityPlayer) {
+ // Sword + Creative mode pre-cancel + // Sword + Creative mode pre-cancel
+ boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player); + boolean isSwordNoBreak = !this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player);
+ +
+ // Tell client the block is gone immediately then process events + // Tell client the block is gone immediately then process events
+ // Don't tell the client if its a creative sword break because its not broken! + // Don't tell the client if its a creative sword break because its not broken!
@ -213,7 +213,7 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false + if (false && !this.player.getMainHandItem().canDestroyBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false
return false; return false;
} else { } else {
+ iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins + iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins
@ -221,7 +221,7 @@
TileEntity tileentity = this.level.getBlockEntity(blockposition); TileEntity tileentity = this.level.getBlockEntity(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
@@ -255,6 +394,10 @@ @@ -253,6 +392,10 @@
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) { } else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
return false; return false;
} else { } else {
@ -232,10 +232,10 @@
IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player); IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
boolean flag = this.level.removeBlock(blockposition, false); boolean flag = this.level.removeBlock(blockposition, false);
@@ -263,19 +406,32 @@ @@ -261,19 +404,32 @@
} }
if (this.isCreative()) { if (this.player.preventsBlockDrops()) {
- return true; - return true;
+ // return true; // CraftBukkit + // return true; // CraftBukkit
} else { } else {
@ -268,7 +268,7 @@
} }
} }
} }
@@ -321,14 +477,53 @@ @@ -319,14 +475,53 @@
} }
} }
@ -322,12 +322,12 @@
if (itileinventory != null) { if (itileinventory != null) {
entityplayer.openMenu(itileinventory); entityplayer.openMenu(itileinventory);
@@ -359,7 +554,7 @@ @@ -357,7 +552,7 @@
} }
} }
- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack)) { - if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack)) {
+ if (!itemstack.isEmpty() && !interactResult) { // add !interactResult SPIGOT-764 + if (!itemstack.isEmpty() && !interactResult) { // add !interactResult SPIGOT-764
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock); ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
EnumInteractionResult enuminteractionresult2;
if (this.isCreative()) {

View File

@ -0,0 +1,18 @@
--- a/net/minecraft/server/level/Ticket.java
+++ b/net/minecraft/server/level/Ticket.java
@@ -17,6 +17,15 @@
private final TicketType type;
private final int ticketLevel;
private long ticksLeft;
+ // CraftBukkit start
+ public Object key;
+
+ public static Ticket of(TicketType tickettype, int i, Object key) {
+ Ticket ticket = new Ticket(tickettype, i);
+ ticket.key = key;
+ return ticket;
+ }
+ // CraftBukkit end
public Ticket(TicketType tickettype, int i) {
this(tickettype, i, tickettype.timeout());

View File

@ -1,11 +1,19 @@
--- a/net/minecraft/server/level/TicketType.java --- a/net/minecraft/server/level/TicketType.java
+++ b/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java
@@ -22,6 +22,8 @@ @@ -14,6 +14,16 @@
public static final TicketType<BlockPosition> PORTAL = create("portal", BaseBlockPosition::compareTo, 300); public static final TicketType PORTAL = register("portal", 300L, true, TicketType.a.LOADING_AND_SIMULATION);
public static final TicketType<ChunkCoordIntPair> ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40); public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, false, TicketType.a.LOADING_AND_SIMULATION);
public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1); public static final TicketType UNKNOWN = register("unknown", 1L, false, TicketType.a.LOADING);
+ public static final TicketType<Unit> PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit + // CraftBukkit start
+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit + public static long pluginTimeout = 0L;
+ public static final TicketType PLUGIN = register("plugin", 0L, false, TicketType.a.LOADING_AND_SIMULATION);
+ public static final TicketType PLUGIN_TICKET = register("plugin_ticket", 0L, false, TicketType.a.LOADING_AND_SIMULATION);
+
+ @Override
+ public long timeout() {
+ return (this != TicketType.PLUGIN) ? this.timeout : TicketType.pluginTimeout;
+ }
+ // CraftBukkit end
public static <T> TicketType<T> create(String s, Comparator<T> comparator) { private static TicketType register(String s, long i, boolean flag, TicketType.a tickettype_a) {
return new TicketType<>(s, comparator, 0L); return (TicketType) IRegistry.register(BuiltInRegistries.TICKET_TYPE, s, new TicketType(i, flag, tickettype_a));

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/server/level/WorldServer.java --- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java
@@ -174,6 +174,23 @@ @@ -169,6 +169,24 @@
import net.minecraft.world.ticks.TickListServer; import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger; import org.slf4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import java.util.UUID;
+import net.minecraft.world.level.biome.WorldChunkManager; +import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.dimension.WorldDimension; +import net.minecraft.world.level.dimension.WorldDimension;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract; +import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
@ -24,7 +25,7 @@
public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed { public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -187,7 +204,7 @@ @@ -182,7 +200,7 @@
final List<EntityPlayer> players = Lists.newArrayList(); final List<EntityPlayer> players = Lists.newArrayList();
private final ChunkProviderServer chunkSource; private final ChunkProviderServer chunkSource;
private final MinecraftServer server; private final MinecraftServer server;
@ -33,7 +34,7 @@
private int lastSpawnChunkRadius; private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList(); final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager; public final PersistentEntitySectionManager<Entity> entityManager;
@@ -214,13 +231,47 @@ @@ -209,13 +227,47 @@
private final boolean tickTime; private final boolean tickTime;
private final RandomSequences randomSequences; private final RandomSequences randomSequences;
@ -83,7 +84,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites(); boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper(); 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); 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);
@@ -248,9 +299,9 @@ @@ -243,9 +295,9 @@
long l = minecraftserver.getWorldData().worldGenOptions().seed(); 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); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -96,24 +97,25 @@
} else { } else {
this.dragonFight = null; this.dragonFight = null;
} }
@@ -260,6 +311,7 @@ @@ -255,6 +307,7 @@
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> { this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences"); return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.TYPE);
}); });
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
} }
/** @deprecated */ /** @deprecated */
@@ -305,12 +357,20 @@ @@ -299,13 +352,22 @@
long j; int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
+ // CraftBukkit start + TimeSkipEvent event = null; // CraftBukkit
+ j = this.levelData.getDayTime() + 24000L;
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime());
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
- j = this.levelData.getDayTime() + 24000L; long j = this.levelData.getDayTime() + 24000L;
- this.setDayTime(j - j % 24000L); - this.setDayTime(j - j % 24000L);
+ // CraftBukkit start
+ event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime());
+ getCraftServer().getPluginManager().callEvent(event); + getCraftServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ this.setDayTime(this.getDayTime() + event.getSkipAmount()); + this.setDayTime(this.getDayTime() + event.getSkipAmount());
@ -121,23 +123,23 @@
} }
- this.wakeUpAllPlayers(); - this.wakeUpAllPlayers();
+ if (!event.isCancelled()) { + if (event == null || !event.isCancelled()) {
+ this.wakeUpAllPlayers(); + this.wakeUpAllPlayers();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle(); this.resetWeatherCycle();
} }
@@ -345,7 +405,7 @@ @@ -341,7 +403,7 @@
this.handlingTick = false; this.handlingTick = false;
gameprofilerfiller.pop(); gameprofilerfiller.pop();
- boolean flag1 = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); - boolean flag1 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty();
+ boolean flag1 = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players + boolean flag1 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
if (flag1) { if (flag1) {
this.resetEmptyTime(); this.resetEmptyTime();
@@ -429,7 +489,7 @@ @@ -421,7 +483,7 @@
private void wakeUpAllPlayers() { private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers(); this.sleepStatus.removeAllSleepers();
@ -146,7 +148,7 @@
entityplayer.stopSleepInBed(false, false); entityplayer.stopSleepInBed(false, false);
}); });
} }
@@ -456,7 +516,7 @@ @@ -498,7 +560,7 @@
entityhorseskeleton.setTrap(true); entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0); entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -155,16 +157,16 @@
} }
} }
@@ -465,7 +525,7 @@ @@ -507,7 +569,7 @@
if (entitylightning != null) { if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition)); entitylightning.snapTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1); entitylightning.setVisualOnly(flag1);
- this.addFreshEntity(entitylightning); - this.addFreshEntity(entitylightning);
+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit + this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit
} }
} }
} }
@@ -521,7 +581,7 @@ @@ -522,7 +584,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value(); BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
if (biomebase.shouldFreeze(this, blockposition2)) { if (biomebase.shouldFreeze(this, blockposition2)) {
@ -173,7 +175,7 @@
} }
if (this.isRaining()) { if (this.isRaining()) {
@@ -537,10 +597,10 @@ @@ -538,10 +600,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
@ -186,7 +188,7 @@
} }
} }
@@ -701,6 +761,7 @@ @@ -698,6 +760,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
} }
@ -194,7 +196,7 @@
if (this.oRainLevel != this.rainLevel) { if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
} }
@@ -719,15 +780,48 @@ @@ -716,15 +779,48 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
@ -245,23 +247,23 @@
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -763,6 +857,7 @@ @@ -760,6 +856,7 @@
}); });
gameprofilerfiller.incrementCounter("tickNonPassenger"); gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick(); entity.tick();
+ entity.postTick(); // CraftBukkit + entity.postTick(); // CraftBukkit
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -786,6 +881,7 @@ for (Entity entity1 : entity.getPassengers()) {
@@ -780,6 +877,7 @@
}); });
gameprofilerfiller.incrementCounter("tickPassenger"); gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick(); entity1.rideTick();
+ entity1.postTick(); // CraftBukkit + entity1.postTick(); // CraftBukkit
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -810,6 +906,7 @@ for (Entity entity2 : entity1.getPassengers()) {
@@ -811,6 +909,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource(); ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) { if (!flag1) {
@ -269,7 +271,7 @@
if (iprogressupdate != null) { if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel")); iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
} }
@@ -827,11 +924,19 @@ @@ -828,11 +927,19 @@
} }
} }
@ -290,7 +292,7 @@
} }
WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage(); WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage();
@@ -903,18 +1008,40 @@ @@ -901,18 +1008,40 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {
@ -334,7 +336,7 @@
} }
} }
@@ -939,24 +1066,37 @@ @@ -937,24 +1066,37 @@
this.entityManager.addNewEntity(entityplayer); this.entityManager.addNewEntity(entityplayer);
} }
@ -376,7 +378,7 @@
return true; return true;
} }
} }
@@ -967,13 +1107,35 @@ @@ -965,17 +1107,45 @@
} }
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) { public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
@ -402,18 +404,15 @@
+ +
@Override @Override
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) { public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
+ // CraftBukkit start + // CraftBukkit start
+ EntityHuman entityhuman = null; + EntityHuman entityhuman = null;
+ Entity entity = this.getEntity(i); + Entity entity = this.getEntity(i);
+ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity; + if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
+ // CraftBukkit end + // CraftBukkit end
+ +
while (iterator.hasNext()) { for (EntityPlayer entityplayer : this.server.getPlayerList().getPlayers()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); if (entityplayer != null && entityplayer.level() == this && entityplayer.getId() != i) {
double d0 = (double) blockposition.getX() - entityplayer.getX();
@@ -982,6 +1144,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY(); double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ(); double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -426,15 +425,18 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
} }
@@ -1060,7 +1228,18 @@ @@ -1078,8 +1248,21 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) { if (VoxelShapes.joinIsNotEmpty(voxelshape, voxelshape1, OperatorBoolean.NOT_SAME)) {
- EntityInsentient entityinsentient = (EntityInsentient) iterator.next(); List<NavigationAbstract> list = new ObjectArrayList();
+ // CraftBukkit start - fix SPIGOT-6362 + // CraftBukkit start - fix SPIGOT-6362
+ java.util.Iterator<EntityInsentient> iterator = this.navigatingMobs.iterator();
- for (EntityInsentient entityinsentient : this.navigatingMobs) {
+ while (iterator.hasNext()) {
+ EntityInsentient entityinsentient; + EntityInsentient entityinsentient;
+ try { + try {
+ entityinsentient = (EntityInsentient) iterator.next(); + entityinsentient = iterator.next();
+ } catch (java.util.ConcurrentModificationException ex) { + } catch (java.util.ConcurrentModificationException ex) {
+ // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register + // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register
+ // In this case we just run the update again across all the iterators as the chunk will then be loaded + // In this case we just run the update again across all the iterators as the chunk will then be loaded
@ -446,7 +448,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation(); NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) { if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1126,6 +1305,12 @@ @@ -1142,6 +1325,12 @@
@Override @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) { 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 +461,7 @@
Explosion.Effect explosion_effect; Explosion.Effect explosion_effect;
switch (world_a) { switch (world_a) {
@@ -1144,6 +1329,11 @@ @@ -1160,6 +1349,11 @@
case TRIGGER: case TRIGGER:
explosion_effect = Explosion.Effect.TRIGGER_BLOCK; explosion_effect = Explosion.Effect.TRIGGER_BLOCK;
break; break;
@ -471,7 +473,7 @@
default: default:
throw new MatchException((String) null, (Throwable) null); throw new MatchException((String) null, (Throwable) null);
} }
@@ -1153,6 +1343,11 @@ @@ -1169,6 +1363,11 @@
ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1); ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
serverexplosion.explode(); serverexplosion.explode();
@ -481,9 +483,9 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1; ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1;
Iterator iterator = this.players.iterator();
@@ -1166,6 +1361,7 @@ for (EntityPlayer entityplayer : this.players) {
@@ -1179,6 +1378,7 @@
} }
} }
@ -491,7 +493,7 @@
} }
private Explosion.Effect getDestroyType(GameRules.GameRuleKey<GameRules.GameRuleBoolean> gamerules_gamerulekey) { private Explosion.Effect getDestroyType(GameRules.GameRuleKey<GameRules.GameRuleBoolean> gamerules_gamerulekey) {
@@ -1226,15 +1422,22 @@ @@ -1239,15 +1439,22 @@
} }
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -515,7 +517,7 @@
if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) { if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) {
++j; ++j;
@@ -1292,7 +1495,7 @@ @@ -1300,7 +1507,7 @@
@Nullable @Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) { public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -524,13 +526,13 @@
return null; return null;
} else { } else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey); Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey);
@@ -1334,11 +1537,22 @@ @@ -1342,10 +1549,21 @@
@Nullable @Nullable
@Override @Override
public WorldMap getMapData(MapId mapid) { public WorldMap getMapData(MapId mapid) {
- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.factory(), mapid.key()); - return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.type(mapid));
+ // CraftBukkit start + // CraftBukkit start
+ WorldMap worldmap = (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.factory(), mapid.key()); + WorldMap worldmap = (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap.type(mapid));
+ if (worldmap != null) { + if (worldmap != null) {
+ worldmap.id = mapid; + worldmap.id = mapid;
+ } + }
@ -538,29 +540,16 @@
+ // CraftBukkit end + // CraftBukkit end
} }
@Override
public void setMapData(MapId mapid, WorldMap worldmap) { public void setMapData(MapId mapid, WorldMap worldmap) {
+ // CraftBukkit start + // CraftBukkit start
+ worldmap.id = mapid; + worldmap.id = mapid;
+ MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView); + MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end + // CraftBukkit end
this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap); this.getServer().overworld().getDataStorage().set(WorldMap.type(mapid), worldmap);
} }
@@ -1649,6 +1863,11 @@ @@ -1557,12 +1775,12 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
+ // CraftBukkit start
+ if (populating) {
+ return;
+ }
+ // CraftBukkit end
this.updateNeighborsAt(blockposition, block);
}
@@ -1668,12 +1887,12 @@
} }
public boolean isFlat() { public boolean isFlat() {
@ -575,16 +564,7 @@
} }
@Nullable @Nullable
@@ -1696,7 +1915,7 @@ @@ -1592,7 +1810,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
- Iterator iterator = iterable.iterator();
+ Iterator<T> iterator = iterable.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1705,7 +1924,7 @@
object2intopenhashmap.addTo(s, 1); object2intopenhashmap.addTo(s, 1);
} }
@ -593,7 +573,7 @@
String s1 = (String) entry.getKey(); String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue(); return s1 + ":" + entry.getIntValue();
@@ -1864,6 +2083,8 @@ @@ -1754,6 +1972,8 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -602,7 +582,7 @@
} }
public void onTrackingEnd(Entity entity) { public void onTrackingEnd(Entity entity) {
@@ -1895,6 +2116,14 @@ @@ -1780,6 +2000,14 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/HandshakeListener.java --- a/net/minecraft/server/network/HandshakeListener.java
+++ b/net/minecraft/server/network/HandshakeListener.java +++ b/net/minecraft/server/network/HandshakeListener.java
@@ -13,8 +13,17 @@ @@ -12,8 +12,17 @@
import net.minecraft.network.protocol.status.StatusProtocols; import net.minecraft.network.protocol.status.StatusProtocols;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@ -18,7 +18,7 @@
private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.translatable("disconnect.ignoring_status_request"); private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.translatable("disconnect.ignoring_status_request");
private final MinecraftServer server; private final MinecraftServer server;
private final NetworkManager connection; private final NetworkManager connection;
@@ -26,6 +35,7 @@ @@ -25,6 +34,7 @@
@Override @Override
public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) { public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) {
@ -26,7 +26,7 @@
switch (packethandshakinginsetprotocol.intention()) { switch (packethandshakinginsetprotocol.intention()) {
case LOGIN: case LOGIN:
this.beginLogin(packethandshakinginsetprotocol, false); this.beginLogin(packethandshakinginsetprotocol, false);
@@ -59,6 +69,40 @@ @@ -58,6 +68,40 @@
private void beginLogin(PacketHandshakingInSetProtocol packethandshakinginsetprotocol, boolean flag) { private void beginLogin(PacketHandshakingInSetProtocol packethandshakinginsetprotocol, boolean flag) {
this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND); this.connection.setupOutboundProtocol(LoginProtocols.CLIENTBOUND);
@ -39,7 +39,7 @@
+ synchronized (throttleTracker) { + synchronized (throttleTracker) {
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
+ throttleTracker.put(address, currentTime); + throttleTracker.put(address, currentTime);
+ IChatMutableComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting."); + IChatBaseComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting.");
+ this.connection.send(new PacketLoginOutDisconnect(chatmessage)); + this.connection.send(new PacketLoginOutDisconnect(chatmessage));
+ this.connection.disconnect(chatmessage); + this.connection.disconnect(chatmessage);
+ return; + return;
@ -65,5 +65,5 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (packethandshakinginsetprotocol.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) { if (packethandshakinginsetprotocol.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
IChatMutableComponent ichatmutablecomponent; IChatBaseComponent ichatbasecomponent;

View File

@ -1,28 +1,28 @@
--- a/net/minecraft/server/network/LegacyPingHandler.java --- a/net/minecraft/server/network/LegacyPingHandler.java
+++ b/net/minecraft/server/network/LegacyPingHandler.java +++ b/net/minecraft/server/network/LegacyPingHandler.java
@@ -35,10 +35,11 @@ @@ -30,10 +30,11 @@
if (bytebuf.readUnsignedByte() == 254) {
SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress(); SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress();
int i = bytebuf.readableBytes(); int i = bytebuf.readableBytes();
String s;
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit + org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit
if (i == 0) { if (i == 0) {
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress); LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
- s = createVersion0Response(this.server); - String s = createVersion0Response(this.server);
+ s = createVersion0Response(this.server, event); // CraftBukkit + String s = createVersion0Response(this.server, event); // CraftBukkit
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s)); sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
} else { } else {
if (bytebuf.readUnsignedByte() != 1) { @@ -51,7 +52,7 @@
@@ -55,7 +56,7 @@
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress); LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
} }
- s = createVersion1Response(this.server); - String s1 = createVersion1Response(this.server);
+ s = createVersion1Response(this.server, event); // CraftBukkit + String s1 = createVersion1Response(this.server, event); // CraftBukkit
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
}
@@ -106,12 +107,16 @@ sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s1));
}
@@ -104,12 +105,16 @@
} }
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PlayerConnection.java --- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java +++ b/net/minecraft/server/network/PlayerConnection.java
@@ -198,6 +198,71 @@ @@ -208,6 +208,71 @@
import net.minecraft.world.phys.shapes.VoxelShapes; import net.minecraft.world.phys.shapes.VoxelShapes;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -69,10 +69,10 @@
+import org.bukkit.util.Vector; +import org.bukkit.util.Vector;
+// CraftBukkit end +// CraftBukkit end
+ +
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener { public class PlayerConnection extends ServerCommonPacketListenerImpl implements GameProtocols.a, PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
static final Logger LOGGER = LogUtils.getLogger(); static final Logger LOGGER = LogUtils.getLogger();
@@ -247,7 +312,7 @@ @@ -258,7 +323,7 @@
private boolean waitingForSwitchToConfig; private boolean waitingForSwitchToConfig;
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) { public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
@ -81,7 +81,7 @@
this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection()); this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection());
this.player = entityplayer; this.player = entityplayer;
entityplayer.connection = this; entityplayer.connection = this;
@@ -256,9 +321,25 @@ @@ -267,9 +332,25 @@
Objects.requireNonNull(minecraftserver); Objects.requireNonNull(minecraftserver);
this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile); this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile);
@ -108,7 +108,7 @@
@Override @Override
public void tick() { public void tick() {
if (this.ackBlockChangesUpTo > -1) { if (this.ackBlockChangesUpTo > -1) {
@@ -313,6 +394,7 @@ @@ -324,6 +405,7 @@
this.chatSpamThrottler.tick(); this.chatSpamThrottler.tick();
this.dropSpamThrottler.tick(); this.dropSpamThrottler.tick();
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) { 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")); this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
} }
@@ -376,6 +458,12 @@ @@ -387,6 +469,12 @@
@Override @Override
public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) { public void handlePlayerInput(PacketPlayInSteerVehicle packetplayinsteervehicle) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinsteervehicle, this, this.player.serverLevel());
@ -129,7 +129,7 @@
this.player.setLastClientInput(packetplayinsteervehicle.input()); this.player.setLastClientInput(packetplayinsteervehicle.input());
} }
@@ -401,6 +489,13 @@ @@ -412,6 +500,13 @@
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) { if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
WorldServer worldserver = this.player.serverLevel(); WorldServer worldserver = this.player.serverLevel();
@ -143,7 +143,7 @@
double d0 = entity.getX(); double d0 = entity.getX();
double d1 = entity.getY(); double d1 = entity.getY();
double d2 = entity.getZ(); double d2 = entity.getZ();
@@ -415,7 +510,33 @@ @@ -426,7 +521,33 @@
double d9 = entity.getDeltaMovement().lengthSqr(); double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8; double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -178,17 +178,18 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8}); PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.send(PacketPlayOutVehicleMove.fromEntity(entity)); this.send(PacketPlayOutVehicleMove.fromEntity(entity));
return; return;
@@ -455,14 +576,67 @@ @@ -466,15 +587,68 @@
} }
entity.absMoveTo(d3, d4, d5, f, f1); entity.absSnapTo(d3, d4, d5, f, f1);
+ player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + player.absSnapTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D)); boolean flag3 = worldserver.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
if (flag && (flag2 || !flag3)) { if (flag && (flag2 || !flag3)) {
entity.absMoveTo(d0, d1, d2, f, f1); entity.absSnapTo(d0, d1, d2, f, f1);
+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + player.absSnapTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.send(PacketPlayOutVehicleMove.fromEntity(entity)); this.send(PacketPlayOutVehicleMove.fromEntity(entity));
entity.removeLatestMovementRecordingBatch();
return; return;
} }
@ -244,9 +245,9 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
this.player.serverLevel().getChunkSource().move(this.player); 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); Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
@@ -499,6 +673,7 @@
@@ -510,6 +684,7 @@
this.lastGoodZ = this.awaitingPositionFromClient.z; this.lastGoodZ = this.awaitingPositionFromClient.z;
this.player.hasChangedDimension(); this.player.hasChangedDimension();
this.awaitingPositionFromClient = null; this.awaitingPositionFromClient = null;
@ -254,7 +255,7 @@
} }
} }
@@ -528,6 +703,7 @@ @@ -540,6 +715,7 @@
@Override @Override
public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) { public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel());
@ -262,7 +263,7 @@
this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering()); this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering());
} }
@@ -548,6 +724,12 @@ @@ -560,6 +736,12 @@
@Override @Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
@ -275,7 +276,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') { if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -557,6 +739,7 @@ @@ -569,6 +751,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -283,7 +284,16 @@
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000)); Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1)); this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1));
@@ -866,6 +1049,13 @@ @@ -891,7 +1074,7 @@
this.player.level().sendBlockUpdated(blockposition, Blocks.AIR.defaultBlockState(), iblockdata, 3);
} else {
IRegistry<GameTestInstance> iregistry = this.player.registryAccess().lookupOrThrow(Registries.TEST_INSTANCE);
- Optional optional = serverboundtestinstanceblockactionpacket.data().test();
+ Optional<ResourceKey<GameTestInstance>> optional = serverboundtestinstanceblockactionpacket.data().test(); // CraftBukkit - decompile error
Objects.requireNonNull(iregistry);
Optional<Holder.c<GameTestInstance>> optional1 = optional.flatMap(iregistry::get);
@@ -970,6 +1153,13 @@
Container container = this.player.containerMenu; Container container = this.player.containerMenu;
if (container instanceof ContainerMerchant containermerchant) { if (container instanceof ContainerMerchant containermerchant) {
@ -297,7 +307,7 @@
if (!containermerchant.stillValid(this.player)) { if (!containermerchant.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant); PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
return; return;
@@ -879,6 +1069,13 @@ @@ -983,6 +1173,13 @@
@Override @Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@ -311,7 +321,7 @@
int i = packetplayinbedit.slot(); int i = packetplayinbedit.slot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) { if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -899,12 +1096,16 @@ @@ -1003,12 +1200,16 @@
} }
private void updateBookContents(List<FilteredText> list, int i) { private void updateBookContents(List<FilteredText> list, int i) {
@ -329,7 +339,7 @@
} }
} }
@@ -915,12 +1116,13 @@ @@ -1019,12 +1220,13 @@
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK); ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT); itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
@ -345,7 +355,7 @@
} }
} }
@@ -982,7 +1184,7 @@ @@ -1086,7 +1288,7 @@
} else { } else {
WorldServer worldserver = this.player.serverLevel(); WorldServer worldserver = this.player.serverLevel();
@ -354,9 +364,9 @@
if (this.tickCount == 0) { if (this.tickCount == 0) {
this.resetPosition(); this.resetPosition();
} }
@@ -997,7 +1199,15 @@ @@ -1105,7 +1307,15 @@
if (this.player.isPassenger()) { if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.absSnapTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.serverLevel().getChunkSource().move(this.player); this.player.serverLevel().getChunkSource().move(this.player);
+ this.allowedPlayerTicks = 20; // CraftBukkit + this.allowedPlayerTicks = 20; // CraftBukkit
} else { } else {
@ -370,7 +380,7 @@
double d3 = this.player.getX(); double d3 = this.player.getX();
double d4 = this.player.getY(); double d4 = this.player.getY();
double d5 = this.player.getZ(); double d5 = this.player.getZ();
@@ -1019,15 +1229,33 @@ @@ -1127,15 +1337,33 @@
++this.receivedMovePacketCount; ++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -406,7 +416,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8}); 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()); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return; return;
@@ -1049,6 +1277,7 @@ @@ -1157,6 +1385,7 @@
boolean flag2 = this.player.verticalCollisionBelow; boolean flag2 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8)); this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
@ -414,17 +424,18 @@
double d11 = d7; double d11 = d7;
d6 = d0 - this.player.getX(); d6 = d0 - this.player.getX();
@@ -1067,9 +1296,75 @@ @@ -1175,10 +1404,76 @@
} }
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) { if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
- this.teleport(d3, d4, d5, f, f1); - this.teleport(d3, d4, d5, f, f1);
+ this.internalTeleport(d3, d4, d5, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. + this.internalTeleport(d3, d4, d5, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet.
this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround()); this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround());
this.player.removeLatestMovementRecordingBatch();
} else { } else {
+ // CraftBukkit start - fire PlayerMoveEvent + // CraftBukkit start - fire PlayerMoveEvent
+ // Reset to old location first + // Reset to old location first
+ this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); + this.player.absSnapTo(prevX, prevY, prevZ, prevYaw, prevPitch);
+ +
+ Player player = this.getCraftPlayer(); + Player player = this.getCraftPlayer();
+ if (!this.hasMoved) { + if (!this.hasMoved) {
@ -488,10 +499,10 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.player.absMoveTo(d0, d1, d2, f, f1); this.player.absSnapTo(d0, d1, d2, f, f1);
boolean flag4 = this.player.isAutoSpinAttack(); boolean flag4 = this.player.isAutoSpinAttack();
@@ -1119,6 +1414,7 @@ @@ -1228,6 +1523,7 @@
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
} }
@ -499,7 +510,7 @@
return true; return true;
} else { } else {
@@ -1147,10 +1443,62 @@ @@ -1251,10 +1547,62 @@
} }
public void teleport(double d0, double d1, double d2, float f, float f1) { public void teleport(double d0, double d1, double d2, float f, float f1) {
@ -563,7 +574,7 @@
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
if (++this.awaitingTeleport == Integer.MAX_VALUE) { if (++this.awaitingTeleport == Integer.MAX_VALUE) {
this.awaitingTeleport = 0; this.awaitingTeleport = 0;
@@ -1158,12 +1506,20 @@ @@ -1262,12 +1610,20 @@
this.player.teleportSetPosition(positionmoverotation, set); this.player.teleportSetPosition(positionmoverotation, set);
this.awaitingPositionFromClient = this.player.position(); this.awaitingPositionFromClient = this.player.position();
@ -584,7 +595,7 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
BlockPosition blockposition = packetplayinblockdig.getPos(); BlockPosition blockposition = packetplayinblockdig.getPos();
@@ -1175,14 +1531,46 @@ @@ -1279,14 +1635,46 @@
if (!this.player.isSpectator()) { if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@ -633,7 +644,7 @@
this.player.drop(false); this.player.drop(false);
} }
@@ -1221,6 +1609,7 @@ @@ -1325,6 +1713,7 @@
@Override @Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
@ -641,7 +652,7 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence()); this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.serverLevel(); WorldServer worldserver = this.player.serverLevel();
@@ -1244,6 +1633,7 @@ @@ -1348,6 +1737,7 @@
if (blockposition.getY() <= i) { if (blockposition.getY() <= i) {
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) { if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
@ -649,7 +660,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enuminteractionresult.consumesAction()) { if (enuminteractionresult.consumesAction()) {
@@ -1281,6 +1671,7 @@ @@ -1385,6 +1775,7 @@
@Override @Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
@ -657,8 +668,8 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence()); this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.serverLevel(); WorldServer worldserver = this.player.serverLevel();
@@ -1296,6 +1687,47 @@ @@ -1400,6 +1791,47 @@
this.player.absRotateTo(f, f1); this.player.absSnapRotationTo(f, f1);
} }
+ // CraftBukkit start + // CraftBukkit start
@ -705,7 +716,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult instanceof EnumInteractionResult.d) { if (enuminteractionresult instanceof EnumInteractionResult.d) {
@@ -1321,7 +1753,7 @@ @@ -1422,7 +1854,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver); Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) { if (entity != null) {
@ -714,7 +725,7 @@
return; return;
} }
} }
@@ -1342,6 +1774,13 @@ @@ -1443,6 +1875,13 @@
@Override @Override
public void onDisconnect(DisconnectionDetails disconnectiondetails) { public void onDisconnect(DisconnectionDetails disconnectiondetails) {
@ -728,7 +739,7 @@
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString()); PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString());
this.removePlayerFromWorld(); this.removePlayerFromWorld();
super.onDisconnect(disconnectiondetails); super.onDisconnect(disconnectiondetails);
@@ -1349,10 +1788,18 @@ @@ -1450,10 +1889,18 @@
private void removePlayerFromWorld() { private void removePlayerFromWorld() {
this.chatMessageChain.close(); this.chatMessageChain.close();
@ -748,24 +759,24 @@
this.player.getTextFilter().leave(); this.player.getTextFilter().leave();
} }
@@ -1367,7 +1814,16 @@ @@ -1468,7 +1915,16 @@
@Override @Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit + if (this.player.isImmobile()) return; // CraftBukkit
if (packetplayinhelditemslot.getSlot() >= 0 && packetplayinhelditemslot.getSlot() < PlayerInventory.getSelectionSize()) { if (packetplayinhelditemslot.getSlot() >= 0 && packetplayinhelditemslot.getSlot() < PlayerInventory.getSelectionSize()) {
+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, packetplayinhelditemslot.getSlot()); + PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().getSelectedSlot(), packetplayinhelditemslot.getSlot());
+ this.cserver.getPluginManager().callEvent(event); + this.cserver.getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ this.send(new PacketPlayOutHeldItemSlot(this.player.getInventory().selected)); + this.send(new PacketPlayOutHeldItemSlot(this.player.getInventory().getSelectedSlot()));
+ this.player.resetLastActionTime(); + this.player.resetLastActionTime();
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { if (this.player.getInventory().getSelectedSlot() != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem(); this.player.stopUsingItem();
} }
@@ -1376,11 +1832,18 @@ @@ -1477,11 +1933,18 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
} else { } else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -784,7 +795,7 @@
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages()); Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages());
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
@@ -1394,7 +1857,7 @@ @@ -1495,7 +1958,7 @@
return; return;
} }
@ -793,7 +804,7 @@
IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent()); IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
this.chatMessageChain.append(completablefuture, (filteredtext) -> { this.chatMessageChain.append(completablefuture, (filteredtext) -> {
@@ -1402,19 +1865,36 @@ @@ -1503,19 +1966,36 @@
this.broadcastChatMessage(playerchatmessage1); this.broadcastChatMessage(playerchatmessage1);
}); });
@ -832,7 +843,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s); ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s);
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) { if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
@@ -1431,19 +1911,37 @@ @@ -1532,19 +2012,37 @@
if (!optional.isEmpty()) { if (!optional.isEmpty()) {
this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> { this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> {
@ -865,7 +876,7 @@
+ ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(command); + ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(command);
+ // CraftBukkit end + // CraftBukkit end
Map map; Map<String, PlayerChatMessage> map;
try { try {
- map = this.collectSignedArguments(serverboundchatcommandsignedpacket, SignableCommand.of(parseresults), lastseenmessages); - map = this.collectSignedArguments(serverboundchatcommandsignedpacket, SignableCommand.of(parseresults), lastseenmessages);
@ -873,21 +884,17 @@
} catch (SignedMessageChain.a signedmessagechain_a) { } catch (SignedMessageChain.a signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a); this.handleMessageDecodeFailure(signedmessagechain_a);
return; return;
@@ -1451,10 +1949,10 @@ @@ -1555,7 +2053,7 @@
parseresults = net.minecraft.commands.CommandDispatcher.<CommandListenerWrapper>mapSource(parseresults, (commandlistenerwrapper) -> {
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map); return commandlistenerwrapper.withSigningContext(commandsigningcontext, this.chatMessageChain);
- parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> {
+ parseresults = CommandDispatcher.<CommandListenerWrapper>mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a, this.chatMessageChain);
}); });
- this.server.getCommands().performCommand(parseresults, serverboundchatcommandsignedpacket.command()); - this.server.getCommands().performCommand(parseresults, serverboundchatcommandsignedpacket.command());
+ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit + this.server.getCommands().performCommand(parseresults, command); // CraftBukkit
} }
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) { private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
@@ -1530,14 +2028,20 @@ @@ -1621,14 +2119,20 @@
return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack()); return commanddispatcher.parse(s, this.player.createCommandSourceStack());
} }
- private void tryHandleChat(String s, Runnable runnable) { - private void tryHandleChat(String s, Runnable runnable) {
@ -910,7 +917,7 @@
} }
} }
@@ -1566,6 +2070,116 @@ @@ -1660,6 +2164,116 @@
return false; return false;
} }
@ -1027,7 +1034,7 @@
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a { private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages); SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
@@ -1573,13 +2187,33 @@ @@ -1667,13 +2281,33 @@
} }
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) { private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
@ -1064,7 +1071,7 @@
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam")); this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam"));
} }
@@ -1601,7 +2235,39 @@ @@ -1695,7 +2329,39 @@
@Override @Override
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) { public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
@ -1086,12 +1093,12 @@
+ return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(player); + return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(player);
+ }); + });
+ if (result == null) { + if (result == null) {
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND); + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), EnumHand.MAIN_HAND);
+ } else if (this.player.gameMode.getGameModeForPlayer() == EnumGamemode.ADVENTURE) { + } else if (this.player.gameMode.getGameModeForPlayer() == EnumGamemode.ADVENTURE) {
+ Block block = result.getHitBlock(); + Block block = result.getHitBlock();
+ if (block != null) { + if (block != null) {
+ Vector hitPosition = result.getHitPosition().subtract(block.getLocation().toVector()); + Vector hitPosition = result.getHitPosition().subtract(block.getLocation().toVector());
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, block, result.getHitBlockFace(), this.player.getInventory().getSelected(), true, EnumHand.MAIN_HAND, hitPosition); + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, block, result.getHitBlockFace(), this.player.getInventory().getSelectedItem(), true, EnumHand.MAIN_HAND, hitPosition);
+ } + }
+ } + }
+ +
@ -1104,7 +1111,7 @@
this.player.swing(packetplayinarmanimation.getHand()); this.player.swing(packetplayinarmanimation.getHand());
} }
@@ -1609,6 +2275,29 @@ @@ -1703,6 +2369,29 @@
public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) { public void handlePlayerCommand(PacketPlayInEntityAction packetplayinentityaction) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinentityaction, this, this.player.serverLevel());
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
@ -1132,9 +1139,9 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.player.resetLastActionTime(); this.player.resetLastActionTime();
Entity entity; switch (packetplayinentityaction.getAction()) {
IJumpable ijumpable; case PRESS_SHIFT_KEY:
@@ -1691,6 +2380,12 @@ @@ -1766,6 +2455,12 @@
} }
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) { public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
@ -1144,10 +1151,10 @@
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a)); this.send(new ClientboundPlayerChatPacket(this.nextChatIndex++, playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a));
this.addPendingMessage(playerchatmessage); MessageSignature messagesignature = playerchatmessage.signature();
}
@@ -1718,6 +2413,7 @@ @@ -1808,6 +2503,7 @@
@Override @Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
@ -1155,7 +1162,7 @@
if (this.player.hasClientLoaded()) { if (this.player.hasClientLoaded()) {
final WorldServer worldserver = this.player.serverLevel(); final WorldServer worldserver = this.player.serverLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver); final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1733,13 +2429,51 @@ @@ -1823,13 +2519,51 @@
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) { if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
@ -1168,22 +1175,22 @@
+ // CraftBukkit start + // CraftBukkit start
+ ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand); + ItemStack itemInHand = PlayerConnection.this.player.getItemInHand(enumhand);
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient; + boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && entity instanceof EntityInsentient;
+ Item origItem = player.getInventory().getSelected() == null ? null : player.getInventory().getSelected().getItem(); + Item origItem = player.getInventory().getSelectedItem() == null ? null : player.getInventory().getSelectedItem().getItem();
+ +
+ cserver.getPluginManager().callEvent(event); + cserver.getPluginManager().callEvent(event);
+ +
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a + // 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)) { + if ((entity instanceof Bucketable && entity instanceof EntityLiving && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem)) {
+ entity.getBukkitEntity().update(player); + entity.getBukkitEntity().update(player);
+ player.containerMenu.sendAllDataToRemote(); + player.containerMenu.sendAllDataToRemote();
+ } + }
+ +
+ if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem)) { + if (triggerLeashUpdate && (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem)) {
+ // Refresh the current leash state + // Refresh the current leash state
+ send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder())); + send(new PacketPlayOutAttachEntity(entity, ((EntityInsentient) entity).getLeashHolder()));
+ } + }
+ +
+ if (event.isCancelled() || player.getInventory().getSelected() == null || player.getInventory().getSelected().getItem() != origItem) { + if (event.isCancelled() || player.getInventory().getSelectedItem() == null || player.getInventory().getSelectedItem().getItem() != origItem) {
+ // Refresh the current entity metadata + // Refresh the current entity metadata
+ entity.refreshEntityData(player); + entity.refreshEntityData(player);
+ // SPIGOT-7136 - Allays + // SPIGOT-7136 - Allays
@ -1208,7 +1215,7 @@
if (enuminteractionresult instanceof EnumInteractionResult.d) { if (enuminteractionresult instanceof EnumInteractionResult.d) {
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult; EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY; ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
@@ -1755,19 +2489,20 @@ @@ -1845,19 +2579,20 @@
@Override @Override
public void onInteraction(EnumHand enumhand) { public void onInteraction(EnumHand enumhand) {
@ -1232,7 +1239,7 @@
label23: label23:
{ {
if (entity instanceof EntityArrow) { if (entity instanceof EntityArrow) {
@@ -1785,6 +2520,11 @@ @@ -1875,6 +2610,11 @@
} }
PlayerConnection.this.player.attack(entity); PlayerConnection.this.player.attack(entity);
@ -1244,7 +1251,7 @@
return; return;
} }
} }
@@ -1809,7 +2549,7 @@ @@ -1899,7 +2639,7 @@
case PERFORM_RESPAWN: case PERFORM_RESPAWN:
if (this.player.wonGame) { if (this.player.wonGame) {
this.player.wonGame = false; this.player.wonGame = false;
@ -1253,7 +1260,7 @@
this.resetPosition(); this.resetPosition();
CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD); CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD);
} else { } else {
@@ -1817,11 +2557,11 @@ @@ -1907,11 +2647,11 @@
return; return;
} }
@ -1267,7 +1274,7 @@
} }
} }
break; break;
@@ -1834,15 +2574,21 @@ @@ -1924,15 +2664,21 @@
@Override @Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
@ -1283,26 +1290,26 @@
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinwindowclick, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinwindowclick, this, this.player.serverLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit + if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime(); this.player.resetLastActionTime();
- if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId()) { - if (this.player.containerMenu.containerId == packetplayinwindowclick.containerId()) {
- if (this.player.isSpectator()) { - if (this.player.isSpectator()) {
+ if (this.player.containerMenu.containerId == packetplayinwindowclick.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit + if (this.player.containerMenu.containerId == packetplayinwindowclick.containerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
+ boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
+ if (false/*this.player.isSpectator()*/) { // CraftBukkit + if (false/*this.player.isSpectator()*/) { // CraftBukkit
this.player.containerMenu.sendAllDataToRemote(); this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) { } else if (!this.player.containerMenu.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1855,7 +2601,284 @@ @@ -1945,7 +2691,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId(); boolean flag = packetplayinwindowclick.stateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates(); this.player.containerMenu.suppressRemoteUpdates();
- this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); - this.player.containerMenu.clicked(i, packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player);
+ // CraftBukkit start - Call InventoryClickEvent + // CraftBukkit start - Call InventoryClickEvent
+ if (packetplayinwindowclick.getSlotNum() < -1 && packetplayinwindowclick.getSlotNum() != -999) { + if (packetplayinwindowclick.slotNum() < -1 && packetplayinwindowclick.slotNum() != -999) {
+ return; + return;
+ } + }
+ +
+ InventoryView inventory = this.player.containerMenu.getBukkitView(); + InventoryView inventory = this.player.containerMenu.getBukkitView();
+ SlotType type = inventory.getSlotType(packetplayinwindowclick.getSlotNum()); + SlotType type = inventory.getSlotType(packetplayinwindowclick.slotNum());
+ +
+ InventoryClickEvent event; + InventoryClickEvent event;
+ ClickType click = ClickType.UNKNOWN; + ClickType click = ClickType.UNKNOWN;
@ -1310,36 +1317,36 @@
+ +
+ ItemStack itemstack = ItemStack.EMPTY; + ItemStack itemstack = ItemStack.EMPTY;
+ +
+ switch (packetplayinwindowclick.getClickType()) { + switch (packetplayinwindowclick.clickType()) {
+ case PICKUP: + case PICKUP:
+ if (packetplayinwindowclick.getButtonNum() == 0) { + if (packetplayinwindowclick.buttonNum()== 0) {
+ click = ClickType.LEFT; + click = ClickType.LEFT;
+ } else if (packetplayinwindowclick.getButtonNum() == 1) { + } else if (packetplayinwindowclick.buttonNum() == 1) {
+ click = ClickType.RIGHT; + click = ClickType.RIGHT;
+ } + }
+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { + if (packetplayinwindowclick.buttonNum() == 0 || packetplayinwindowclick.buttonNum() == 1) {
+ action = InventoryAction.NOTHING; // Don't want to repeat ourselves + action = InventoryAction.NOTHING; // Don't want to repeat ourselves
+ if (packetplayinwindowclick.getSlotNum() == -999) { + if (packetplayinwindowclick.slotNum() == -999) {
+ if (!player.containerMenu.getCarried().isEmpty()) { + if (!player.containerMenu.getCarried().isEmpty()) {
+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
+ } + }
+ } else if (packetplayinwindowclick.getSlotNum() < 0) { + } else if (packetplayinwindowclick.slotNum() < 0) {
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ } else { + } else {
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (slot != null) { + if (slot != null) {
+ ItemStack clickedItem = slot.getItem(); + ItemStack clickedItem = slot.getItem();
+ ItemStack cursor = player.containerMenu.getCarried(); + ItemStack cursor = player.containerMenu.getCarried();
+ if (clickedItem.isEmpty()) { + if (clickedItem.isEmpty()) {
+ if (!cursor.isEmpty()) { + if (!cursor.isEmpty()) {
+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; + action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
+ } + }
+ } else if (slot.mayPickup(player)) { + } else if (slot.mayPickup(player)) {
+ if (cursor.isEmpty()) { + if (cursor.isEmpty()) {
+ action = packetplayinwindowclick.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; + action = packetplayinwindowclick.buttonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
+ } else if (slot.mayPlace(cursor)) { + } else if (slot.mayPlace(cursor)) {
+ if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { + if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) {
+ int toPlace = packetplayinwindowclick.getButtonNum() == 0 ? cursor.getCount() : 1; + int toPlace = packetplayinwindowclick.buttonNum() == 0 ? cursor.getCount() : 1;
+ toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); + toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount());
+ toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); + toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount());
+ if (toPlace == 1) { + if (toPlace == 1) {
@ -1369,16 +1376,16 @@
+ break; + break;
+ // TODO check on updates + // TODO check on updates
+ case QUICK_MOVE: + case QUICK_MOVE:
+ if (packetplayinwindowclick.getButtonNum() == 0) { + if (packetplayinwindowclick.buttonNum() == 0) {
+ click = ClickType.SHIFT_LEFT; + click = ClickType.SHIFT_LEFT;
+ } else if (packetplayinwindowclick.getButtonNum() == 1) { + } else if (packetplayinwindowclick.buttonNum() == 1) {
+ click = ClickType.SHIFT_RIGHT; + click = ClickType.SHIFT_RIGHT;
+ } + }
+ if (packetplayinwindowclick.getButtonNum() == 0 || packetplayinwindowclick.getButtonNum() == 1) { + if (packetplayinwindowclick.buttonNum() == 0 || packetplayinwindowclick.buttonNum() == 1) {
+ if (packetplayinwindowclick.getSlotNum() < 0) { + if (packetplayinwindowclick.slotNum() < 0) {
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ } else { + } else {
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) { + if (slot != null && slot.mayPickup(this.player) && slot.hasItem()) {
+ action = InventoryAction.MOVE_TO_OTHER_INVENTORY; + action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
+ } else { + } else {
@ -1388,11 +1395,11 @@
+ } + }
+ break; + break;
+ case SWAP: + case SWAP:
+ if ((packetplayinwindowclick.getButtonNum() >= 0 && packetplayinwindowclick.getButtonNum() < 9) || packetplayinwindowclick.getButtonNum() == 40) { + if ((packetplayinwindowclick.buttonNum() >= 0 && packetplayinwindowclick.buttonNum() < 9) || packetplayinwindowclick.buttonNum() == 40) {
+ click = (packetplayinwindowclick.getButtonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; + click = (packetplayinwindowclick.buttonNum() == 40) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY;
+ Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot clickedSlot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (clickedSlot.mayPickup(player)) { + if (clickedSlot.mayPickup(player)) {
+ ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.getButtonNum()); + ItemStack hotbar = this.player.getInventory().getItem(packetplayinwindowclick.buttonNum());
+ boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item + boolean canCleanSwap = hotbar.isEmpty() || (clickedSlot.container == player.getInventory() && clickedSlot.mayPlace(hotbar)); // the slot will accept the hotbar item
+ if (clickedSlot.hasItem()) { + if (clickedSlot.hasItem()) {
+ if (canCleanSwap) { + if (canCleanSwap) {
@ -1411,12 +1418,12 @@
+ } + }
+ break; + break;
+ case CLONE: + case CLONE:
+ if (packetplayinwindowclick.getButtonNum() == 2) { + if (packetplayinwindowclick.buttonNum() == 2) {
+ click = ClickType.MIDDLE; + click = ClickType.MIDDLE;
+ if (packetplayinwindowclick.getSlotNum() < 0) { + if (packetplayinwindowclick.slotNum() < 0) {
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ } else { + } else {
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) { + if (slot != null && slot.hasItem() && player.getAbilities().instabuild && player.containerMenu.getCarried().isEmpty()) {
+ action = InventoryAction.CLONE_STACK; + action = InventoryAction.CLONE_STACK;
+ } else { + } else {
@ -1429,18 +1436,18 @@
+ } + }
+ break; + break;
+ case THROW: + case THROW:
+ if (packetplayinwindowclick.getSlotNum() >= 0) { + if (packetplayinwindowclick.slotNum() >= 0) {
+ if (packetplayinwindowclick.getButtonNum() == 0) { + if (packetplayinwindowclick.buttonNum() == 0) {
+ click = ClickType.DROP; + click = ClickType.DROP;
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { + if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) {
+ action = InventoryAction.DROP_ONE_SLOT; + action = InventoryAction.DROP_ONE_SLOT;
+ } else { + } else {
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ } + }
+ } else if (packetplayinwindowclick.getButtonNum() == 1) { + } else if (packetplayinwindowclick.buttonNum() == 1) {
+ click = ClickType.CONTROL_DROP; + click = ClickType.CONTROL_DROP;
+ Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()); + Slot slot = this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum());
+ if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) { + if (slot != null && slot.hasItem() && slot.mayPickup(player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Item.byBlock(Blocks.AIR)) {
+ action = InventoryAction.DROP_ALL_SLOT; + action = InventoryAction.DROP_ALL_SLOT;
+ } else { + } else {
@ -1450,19 +1457,19 @@
+ } else { + } else {
+ // Sane default (because this happens when they are holding nothing. Don't ask why.) + // Sane default (because this happens when they are holding nothing. Don't ask why.)
+ click = ClickType.LEFT; + click = ClickType.LEFT;
+ if (packetplayinwindowclick.getButtonNum() == 1) { + if (packetplayinwindowclick.buttonNum() == 1) {
+ click = ClickType.RIGHT; + click = ClickType.RIGHT;
+ } + }
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ } + }
+ break; + break;
+ case QUICK_CRAFT: + case QUICK_CRAFT:
+ this.player.containerMenu.clicked(packetplayinwindowclick.getSlotNum(), packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + this.player.containerMenu.clicked(packetplayinwindowclick.slotNum(), packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player);
+ break; + break;
+ case PICKUP_ALL: + case PICKUP_ALL:
+ click = ClickType.DOUBLE_CLICK; + click = ClickType.DOUBLE_CLICK;
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ if (packetplayinwindowclick.getSlotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { + if (packetplayinwindowclick.slotNum() >= 0 && !this.player.containerMenu.getCarried().isEmpty()) {
+ ItemStack cursor = this.player.containerMenu.getCarried(); + ItemStack cursor = this.player.containerMenu.getCarried();
+ action = InventoryAction.NOTHING; + action = InventoryAction.NOTHING;
+ // Quick check for if we have any of the item + // Quick check for if we have any of the item
@ -1475,32 +1482,32 @@
+ break; + break;
+ } + }
+ +
+ if (packetplayinwindowclick.getClickType() != InventoryClickType.QUICK_CRAFT) { + if (packetplayinwindowclick.clickType() != InventoryClickType.QUICK_CRAFT) {
+ if (click == ClickType.NUMBER_KEY) { + if (click == ClickType.NUMBER_KEY) {
+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum());
+ } else { + } else {
+ event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action);
+ } + }
+ +
+ org.bukkit.inventory.Inventory top = inventory.getTopInventory(); + org.bukkit.inventory.Inventory top = inventory.getTopInventory();
+ if (packetplayinwindowclick.getSlotNum() == 0 && top instanceof CraftingInventory) { + if (packetplayinwindowclick.slotNum() == 0 && top instanceof CraftingInventory) {
+ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); + org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe();
+ if (recipe != null) { + if (recipe != null) {
+ if (click == ClickType.NUMBER_KEY) { + if (click == ClickType.NUMBER_KEY) {
+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum());
+ } else { + } else {
+ event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + event = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.slotNum(), click, action);
+ } + }
+ } + }
+ } + }
+ +
+ if (packetplayinwindowclick.getSlotNum() == 3 && top instanceof SmithingInventory) { + if (packetplayinwindowclick.slotNum() == 3 && top instanceof SmithingInventory) {
+ org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult(); + org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult();
+ if (result != null) { + if (result != null) {
+ if (click == ClickType.NUMBER_KEY) { + if (click == ClickType.NUMBER_KEY) {
+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action, packetplayinwindowclick.getButtonNum()); + event = new SmithItemEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action, packetplayinwindowclick.buttonNum());
+ } else { + } else {
+ event = new SmithItemEvent(inventory, type, packetplayinwindowclick.getSlotNum(), click, action); + event = new SmithItemEvent(inventory, type, packetplayinwindowclick.slotNum(), click, action);
+ } + }
+ } + }
+ } + }
@ -1515,7 +1522,7 @@
+ switch (event.getResult()) { + switch (event.getResult()) {
+ case ALLOW: + case ALLOW:
+ case DEFAULT: + case DEFAULT:
+ this.player.containerMenu.clicked(i, packetplayinwindowclick.getButtonNum(), packetplayinwindowclick.getClickType(), this.player); + this.player.containerMenu.clicked(i, packetplayinwindowclick.buttonNum(), packetplayinwindowclick.clickType(), this.player);
+ break; + break;
+ case DENY: + case DENY:
+ /* Needs enum constructor in InventoryAction + /* Needs enum constructor in InventoryAction
@ -1548,12 +1555,12 @@
+ case PLACE_ONE: + case PLACE_ONE:
+ case SWAP_WITH_CURSOR: + case SWAP_WITH_CURSOR:
+ this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried())); + this.player.connection.send(new PacketPlayOutSetSlot(-1, -1, this.player.inventoryMenu.incrementStateId(), this.player.containerMenu.getCarried()));
+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); + this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.slotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()).getItem()));
+ break; + break;
+ // Modified clicked only + // Modified clicked only
+ case DROP_ALL_SLOT: + case DROP_ALL_SLOT:
+ case DROP_ONE_SLOT: + case DROP_ONE_SLOT:
+ this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.getSlotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.getSlotNum()).getItem())); + this.player.connection.send(new PacketPlayOutSetSlot(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packetplayinwindowclick.slotNum(), this.player.containerMenu.getSlot(packetplayinwindowclick.slotNum()).getItem()));
+ break; + break;
+ // Modified cursor only + // Modified cursor only
+ case DROP_ALL_CURSOR: + case DROP_ALL_CURSOR:
@ -1574,10 +1581,10 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.changedSlots()).iterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
@@ -1901,7 +2924,21 @@ @@ -1991,7 +3014,21 @@
return; return;
} }
@ -1600,7 +1607,7 @@
if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) { if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) {
this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display())); this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
@@ -1917,6 +2954,7 @@ @@ -2007,6 +3044,7 @@
@Override @Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
@ -1608,7 +1615,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) { if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) { if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1945,6 +2983,42 @@ @@ -2035,6 +3073,42 @@
boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45; boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize(); boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
@ -1651,7 +1658,7 @@
if (flag1 && flag2) { if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack); this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack);
@@ -1972,6 +3046,7 @@ @@ -2062,6 +3136,7 @@
} }
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) { private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
@ -1659,7 +1666,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
WorldServer worldserver = this.player.serverLevel(); WorldServer worldserver = this.player.serverLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos(); BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1993,7 +3068,17 @@ @@ -2083,7 +3158,17 @@
@Override @Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
@ -1678,7 +1685,7 @@
} }
@Override @Override
@@ -2058,7 +3143,7 @@ @@ -2148,7 +3233,7 @@
if (!this.waitingForSwitchToConfig) { if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested"); throw new IllegalStateException("Client acknowledged config, but none was requested");
} else { } else {
@ -1687,7 +1694,7 @@
} }
} }
@@ -2083,8 +3168,10 @@ @@ -2173,8 +3258,10 @@
}); });
} }

View File

@ -1,15 +1,8 @@
--- a/net/minecraft/server/network/ServerConnection.java --- a/net/minecraft/server/network/ServerConnection.java
+++ b/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java
@@ -100,15 +100,25 @@ @@ -103,9 +103,19 @@
networkmanager.configurePacketHandler(channelpipeline);
NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND, false, (BandwidthDebugMonitor) null); networkmanager.setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, networkmanager));
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
- Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
+ NetworkManager object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); // CraftBukkit - decompile error
ServerConnection.this.connections.add(object);
((NetworkManager) object).configurePacketHandler(channelpipeline);
((NetworkManager) object).setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
} }
- }).group(eventloopgroup).localAddress(inetaddress, i)).bind().syncUninterruptibly()); - }).group(eventloopgroup).localAddress(inetaddress, i)).bind().syncUninterruptibly());
+ }).group(eventloopgroup).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit + }).group(eventloopgroup).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
@ -27,4 +20,4 @@
+ // CraftBukkit end + // CraftBukkit end
public SocketAddress startMemoryChannel() { public SocketAddress startMemoryChannel() {
List list = this.channels; ChannelFuture channelfuture;

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/server/players/JsonList.java --- a/net/minecraft/server/players/JsonList.java
+++ b/net/minecraft/server/players/JsonList.java +++ b/net/minecraft/server/players/JsonList.java
@@ -54,7 +54,7 @@ @@ -40,7 +40,7 @@
@Nullable
public V get(K k0) {
this.removeExpired();
- return (JsonListEntry) this.map.get(this.getKeyForUser(k0));
+ return (V) this.map.get(this.getKeyForUser(k0)); // CraftBukkit - fix decompile error
} }
public void remove(K k0) { public void add(V v0) {
@@ -85,6 +85,7 @@ - this.map.put(this.getKeyForUser(((JsonListEntry) v0).getUser()), v0);
+ this.map.put(this.getKeyForUser((v0).getUser()), v0); // CraftBukkit - decompile error
try {
this.save();
@@ -84,6 +84,7 @@
} }
protected boolean contains(K k0) { protected boolean contains(K k0) {
@ -17,25 +17,16 @@
return this.map.containsKey(this.getKeyForUser(k0)); return this.map.containsKey(this.getKeyForUser(k0));
} }
@@ -93,7 +94,7 @@ @@ -92,7 +93,7 @@
Iterator iterator = this.map.values().iterator();
while (iterator.hasNext()) {
- V v0 = (JsonListEntry) iterator.next();
+ V v0 = (V) iterator.next(); // CraftBukkit - decompile error
for (V v0 : this.map.values()) {
if (v0.hasExpired()) { if (v0.hasExpired()) {
list.add(v0.getUser()); - list.add(((JsonListEntry) v0).getUser());
@@ -103,7 +104,7 @@ + list.add((v0).getUser()); // CraftBukkit - decompile error
iterator = list.iterator();
while (iterator.hasNext()) {
- K k0 = iterator.next();
+ K k0 = (K) iterator.next(); // CraftBukkit - decompile error
this.map.remove(this.getKeyForUser(k0));
} }
@@ -118,7 +119,7 @@ }
@@ -110,7 +111,7 @@
public void save() throws IOException { public void save() throws IOException {
JsonArray jsonarray = new JsonArray(); JsonArray jsonarray = new JsonArray();
@ -44,7 +35,7 @@
JsonObject jsonobject = new JsonObject(); JsonObject jsonobject = new JsonObject();
Objects.requireNonNull(jsonlistentry); Objects.requireNonNull(jsonlistentry);
@@ -171,7 +172,7 @@ @@ -141,7 +142,7 @@
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject); JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
if (jsonlistentry.getUser() != null) { if (jsonlistentry.getUser() != null) {
@ -52,4 +43,4 @@
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error + this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
} }
} }
} catch (Throwable throwable) { }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/NameReferencingFileConverter.java --- a/net/minecraft/server/players/NameReferencingFileConverter.java
+++ b/net/minecraft/server/players/NameReferencingFileConverter.java +++ b/net/minecraft/server/players/NameReferencingFileConverter.java
@@ -27,6 +27,12 @@ @@ -26,6 +26,12 @@
import net.minecraft.world.level.storage.SavedFile; import net.minecraft.world.level.storage.SavedFile;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -13,7 +13,7 @@
public class NameReferencingFileConverter { public class NameReferencingFileConverter {
static final Logger LOGGER = LogUtils.getLogger(); static final Logger LOGGER = LogUtils.getLogger();
@@ -85,7 +91,7 @@ @@ -76,7 +82,7 @@
try { try {
gameprofilebanlist.load(); gameprofilebanlist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -22,7 +22,7 @@
} }
} }
@@ -143,7 +149,7 @@ @@ -134,7 +140,7 @@
try { try {
ipbanlist.load(); ipbanlist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -31,7 +31,7 @@
} }
} }
@@ -184,7 +190,7 @@ @@ -173,7 +179,7 @@
try { try {
oplist.load(); oplist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -40,7 +40,7 @@
} }
} }
@@ -228,7 +234,7 @@ @@ -217,7 +223,7 @@
try { try {
whitelist.load(); whitelist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -49,7 +49,7 @@
} }
} }
@@ -347,6 +353,30 @@ @@ -333,6 +339,30 @@
File file5 = new File(file, s2 + ".dat"); File file5 = new File(file, s2 + ".dat");
File file6 = new File(file4, s3 + ".dat"); File file6 = new File(file4, s3 + ".dat");
@ -66,7 +66,7 @@
+ if (!root.contains("bukkit")) { + if (!root.contains("bukkit")) {
+ root.put("bukkit", new NBTTagCompound()); + root.put("bukkit", new NBTTagCompound());
+ } + }
+ NBTTagCompound data = root.getCompound("bukkit"); + NBTTagCompound data = root.getCompoundOrEmpty("bukkit");
+ data.putString("lastKnownName", s2); + data.putString("lastKnownName", s2);
+ +
+ try { + try {

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/server/players/PlayerList.java --- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java
@@ -104,6 +104,27 @@ @@ -103,6 +103,27 @@
import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger; import org.slf4j.Logger;
+// CraftBukkit start +// CraftBukkit start
@ -28,7 +28,7 @@
public abstract class PlayerList { public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json"); public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -116,14 +137,16 @@ @@ -115,14 +136,16 @@
private static final int SEND_PLAYER_INFO_INTERVAL = 600; 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 static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server; private final MinecraftServer server;
@ -48,7 +48,7 @@
public final WorldNBTStorage playerIo; public final WorldNBTStorage playerIo;
private boolean doWhiteList; private boolean doWhiteList;
private final LayeredRegistryAccess<RegistryLayer> registries; private final LayeredRegistryAccess<RegistryLayer> registries;
@@ -134,13 +157,23 @@ @@ -133,13 +156,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false; private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn; private int sendAllPlayerInfoIn;
@ -74,35 +74,20 @@
this.server = minecraftserver; this.server = minecraftserver;
this.registries = layeredregistryaccess; this.registries = layeredregistryaccess;
this.maxPlayers = i; this.maxPlayers = i;
@@ -150,25 +183,34 @@ @@ -161,13 +194,22 @@
public void placeNewPlayer(NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
GameProfile gameprofile = entityplayer.getGameProfile();
UserCache usercache = this.server.getProfileCache();
- Optional optional;
+ // Optional optional; // CraftBukkit - decompile error
String s;
if (usercache != null) {
- optional = usercache.get(gameprofile.getId());
+ Optional<GameProfile> optional = usercache.get(gameprofile.getId()); // CraftBukkit - decompile error
s = (String) optional.map(GameProfile::getName).orElse(gameprofile.getName());
usercache.add(gameprofile);
} else {
s = gameprofile.getName();
} }
- optional = this.load(entityplayer); Optional<NBTTagCompound> optional1 = this.load(entityplayer);
+ Optional<NBTTagCompound> optional = this.load(entityplayer); // CraftBukkit - decompile error
+ // CraftBukkit start - Better rename detection + // CraftBukkit start - Better rename detection
+ if (optional.isPresent()) { + if (optional1.isPresent()) {
+ NBTTagCompound nbttagcompound = optional.get(); + NBTTagCompound nbttagcompound = optional1.get();
+ if (nbttagcompound.contains("bukkit")) { + if (nbttagcompound.contains("bukkit")) {
+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit"); + NBTTagCompound bukkit = nbttagcompound.getCompoundOrEmpty("bukkit");
+ s = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s; + s = bukkit.getStringOr("lastKnownName", s);
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
ResourceKey<World> resourcekey = (ResourceKey) optional.flatMap((nbttagcompound) -> { ResourceKey<World> resourcekey = (ResourceKey) optional1.flatMap((nbttagcompound) -> {
- DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); - DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension")));
+ DataResult<ResourceKey<World>> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); // CraftBukkit - decompile error + DataResult<ResourceKey<World>> dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension"))); // CraftBukkit - decompile error
Logger logger = PlayerList.LOGGER; Logger logger = PlayerList.LOGGER;
@ -114,7 +99,7 @@
WorldServer worldserver = this.server.getLevel(resourcekey); WorldServer worldserver = this.server.getLevel(resourcekey);
WorldServer worldserver1; WorldServer worldserver1;
@@ -182,10 +224,11 @@ @@ -181,10 +223,11 @@
entityplayer.setServerLevel(worldserver1); entityplayer.setServerLevel(worldserver1);
String s1 = networkmanager.getLoggableAddress(this.server.logIPs()); String s1 = networkmanager.getLoggableAddress(this.server.logIPs());
@ -123,20 +108,20 @@
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()}); + // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()});
WorldData worlddata = worldserver1.getLevelData(); WorldData worlddata = worldserver1.getLevelData();
- entityplayer.loadGameTypes((NBTTagCompound) optional.orElse((Object) null)); - entityplayer.loadGameTypes((NBTTagCompound) optional1.orElse((Object) null));
+ entityplayer.loadGameTypes((NBTTagCompound) optional.orElse(null)); // CraftBukkit - decompile error + entityplayer.loadGameTypes((NBTTagCompound) optional1.orElse(null)); // CraftBukkit - decompile error
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie); PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie);
networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection); networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess()), playerconnection), playerconnection);
@@ -195,6 +238,7 @@ @@ -194,6 +237,7 @@
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile()));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities())); playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().getSelectedSlot()));
@@ -213,8 +257,10 @@ @@ -212,8 +256,10 @@
} else { } else {
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s); ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
} }
@ -148,7 +133,7 @@
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot()); playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
ServerPing serverping = this.server.getStatus(); ServerPing serverping = this.server.getStatus();
@@ -222,17 +268,70 @@ @@ -221,19 +267,72 @@
entityplayer.sendServerStatus(serverping); entityplayer.sendServerStatus(serverping);
} }
@ -215,15 +200,17 @@
+ worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it + worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it
+ // CraftBukkit end + // CraftBukkit end
this.sendActivePlayerEffects(entityplayer); this.sendActivePlayerEffects(entityplayer);
entityplayer.loadAndSpawnEnderpearls(optional); optional1.ifPresent((nbttagcompound) -> {
entityplayer.loadAndSpawnParentVehicle(optional); entityplayer.loadAndSpawnEnderPearls(nbttagcompound);
entityplayer.loadAndSpawnParentVehicle(nbttagcompound);
});
entityplayer.initInventoryMenu(); entityplayer.initInventoryMenu();
+ // CraftBukkit - Moved from above, added world + // CraftBukkit - Moved from above, added world
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getLevelName(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()); + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getLevelName(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ());
} }
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -269,30 +368,31 @@ @@ -258,30 +357,31 @@
} }
public void addWorldborderListener(WorldServer worldserver) { public void addWorldborderListener(WorldServer worldserver) {
@ -260,7 +247,7 @@
} }
@Override @Override
@@ -319,14 +419,15 @@ @@ -308,14 +408,15 @@
} }
protected void save(EntityPlayer entityplayer) { protected void save(EntityPlayer entityplayer) {
@ -278,7 +265,7 @@
if (advancementdataplayer != null) { if (advancementdataplayer != null) {
advancementdataplayer.save(); advancementdataplayer.save();
@@ -334,10 +435,24 @@ @@ -323,10 +424,24 @@
} }
@ -304,7 +291,7 @@
this.save(entityplayer); this.save(entityplayer);
if (entityplayer.isPassenger()) { if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle(); Entity entity = entityplayer.getRootVehicle();
@@ -346,7 +461,7 @@ @@ -335,7 +450,7 @@
PlayerList.LOGGER.debug("Removing player mount"); PlayerList.LOGGER.debug("Removing player mount");
entityplayer.stopRiding(); entityplayer.stopRiding();
entity.getPassengersAndSelf().forEach((entity1) -> { entity.getPassengersAndSelf().forEach((entity1) -> {
@ -313,16 +300,16 @@
}); });
} }
} }
@@ -357,7 +472,7 @@ @@ -343,7 +458,7 @@
while (iterator.hasNext()) { entityplayer.unRide();
EntityEnderPearl entityenderpearl = (EntityEnderPearl) iterator.next();
for (EntityEnderPearl entityenderpearl : entityplayer.getEnderPearls()) {
- entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER); - entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER);
+ entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause + entityenderpearl.setRemoved(Entity.RemovalReason.UNLOADED_WITH_PLAYER, EntityRemoveEvent.Cause.PLAYER_QUIT); // CraftBukkit - add Bukkit remove cause
} }
worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER); worldserver.removePlayerImmediately(entityplayer, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
@@ -369,17 +484,66 @@ @@ -355,15 +470,58 @@
if (entityplayer1 == entityplayer) { if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid); this.playersByUUID.remove(uuid);
@ -358,27 +345,19 @@
- public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) { - public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) { + public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) {
IChatMutableComponent ichatmutablecomponent;
+ // Moved from processLogin + // Moved from processLogin
+ UUID uuid = gameprofile.getId(); + UUID uuid = gameprofile.getId();
+ List<EntityPlayer> list = Lists.newArrayList(); + Set<EntityPlayer> set = Sets.newIdentityHashSet();
+ +
+ EntityPlayer entityplayer; + for (EntityPlayer entityplayer : this.players) {
+
+ for (int i = 0; i < this.players.size(); ++i) {
+ entityplayer = (EntityPlayer) this.players.get(i);
+ if (entityplayer.getUUID().equals(uuid)) { + if (entityplayer.getUUID().equals(uuid)) {
+ list.add(entityplayer); + set.add(entityplayer);
+ } + }
+ } + }
+ +
+ Iterator iterator = list.iterator(); + for (EntityPlayer entityplayer2 : set) {
+ + save(entityplayer2); // CraftBukkit - Force the player's inventory to be saved
+ while (iterator.hasNext()) { + entityplayer2.connection.disconnect(PlayerList.DUPLICATE_LOGIN_DISCONNECT_MESSAGE);
+ entityplayer = (EntityPlayer) iterator.next();
+ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
+ entityplayer.connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.duplicate_login"));
+ } + }
+ +
+ // Instead of kicking then returning, we need to store the kick reason + // Instead of kicking then returning, we need to store the kick reason
@ -393,28 +372,28 @@
+ +
if (this.bans.isBanned(gameprofile)) { if (this.bans.isBanned(gameprofile)) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile); GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -388,9 +552,11 @@ @@ -372,9 +530,11 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires()))); ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
} }
- return ichatmutablecomponent; - return ichatmutablecomponent;
+ // return chatmessage; + // return ichatmutablecomponent;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent)); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else if (!this.isWhiteListed(gameprofile)) { } else if (!this.isWhiteListed(gameprofile)) {
- return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted"); - return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted"); + IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent)); + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else if (this.ipBans.isBanned(socketaddress)) { } else if (this.ipBans.isBanned(socketaddress)) {
IpBanEntry ipbanentry = this.ipBans.get(socketaddress); IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
IChatMutableComponent ichatmutablecomponent1 = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -399,17 +565,32 @@ @@ -383,17 +543,32 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires()))); ichatmutablecomponent1.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
} }
- return ichatmutablecomponent; - return ichatmutablecomponent1;
+ // return chatmessage; + // return ichatmutablecomponent1;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent)); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent1));
} else { } else {
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; - return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; + // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
@ -445,8 +424,8 @@
+ /* CraftBukkit startMoved up + /* CraftBukkit startMoved up
UUID uuid = gameprofile.getId(); UUID uuid = gameprofile.getId();
Set<EntityPlayer> set = Sets.newIdentityHashSet(); Set<EntityPlayer> set = Sets.newIdentityHashSet();
Iterator iterator = this.players.iterator();
@@ -437,22 +618,41 @@ @@ -414,32 +589,66 @@
} }
return !set.isEmpty(); return !set.isEmpty();
@ -487,9 +466,7 @@
+ */ + */
+ // CraftBukkit end + // CraftBukkit end
Iterator iterator = entityplayer.getTags().iterator(); for (String s : entityplayer.getTags()) {
@@ -462,11 +662,26 @@
entityplayer1.addTag(s); entityplayer1.addTag(s);
} }
@ -503,24 +480,24 @@
+ teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING);
+ } + }
+ WorldServer worldserver = teleporttransition.newLevel(); + WorldServer worldserver = teleporttransition.newLevel();
+ entityplayer1.spawnIn(worldserver); + entityplayer1.spawnIn(worldserver, flag);
+ entityplayer1.unsetRemoved(); + entityplayer1.unsetRemoved();
+ entityplayer1.setShiftKeyDown(false); + entityplayer1.setShiftKeyDown(false);
Vec3D vec3d = teleporttransition.position(); Vec3D vec3d = teleporttransition.position();
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); - entityplayer1.snapTo(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot());
+ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); + entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot());
+ // CraftBukkit end + // CraftBukkit end
if (teleporttransition.missingRespawnBlock()) { if (teleporttransition.missingRespawnBlock()) {
entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); 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 + entityplayer1.setRespawnPosition(null, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
} }
int i = flag ? 1 : 0; byte b0 = (byte) (flag ? 1 : 0);
@@ -474,17 +689,19 @@ @@ -447,17 +656,19 @@
WorldData worlddata = worldserver1.getLevelData(); WorldData worlddata = worldserver1.getLevelData();
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i)); entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), b0));
- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); - entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit + entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle())); entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()));
@ -540,10 +517,10 @@
+ } + }
+ // entityplayer1.initInventoryMenu(); + // entityplayer1.initInventoryMenu();
entityplayer1.setHealth(entityplayer1.getHealth()); entityplayer1.setHealth(entityplayer1.getHealth());
BlockPosition blockposition = entityplayer1.getRespawnPosition(); EntityPlayer.RespawnConfig entityplayer_respawnconfig = entityplayer1.getRespawnConfig();
WorldServer worldserver2 = this.server.getLevel(entityplayer1.getRespawnDimension());
@@ -496,6 +713,27 @@ @@ -473,6 +684,27 @@
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver.getRandom().nextLong())); }
} }
} }
+ // Added from changeDimension + // Added from changeDimension
@ -570,7 +547,7 @@
return entityplayer1; return entityplayer1;
} }
@@ -524,7 +762,18 @@ @@ -497,7 +729,18 @@
public void tick() { public void tick() {
if (++this.sendAllPlayerInfoIn > 600) { if (++this.sendAllPlayerInfoIn > 600) {
@ -590,7 +567,7 @@
this.sendAllPlayerInfoIn = 0; this.sendAllPlayerInfoIn = 0;
} }
@@ -541,6 +790,25 @@ @@ -510,6 +753,25 @@
} }
@ -614,18 +591,9 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) { public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator(); for (EntityPlayer entityplayer : this.players) {
if (entityplayer.level().dimension() == resourcekey) {
@@ -619,7 +887,7 @@ @@ -604,6 +866,7 @@
}
public void deop(GameProfile gameprofile) {
- this.ops.remove((Object) gameprofile);
+ this.ops.remove(gameprofile); // CraftBukkit - decompile error
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -643,6 +911,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0)); entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
} }
@ -633,7 +601,7 @@
this.server.getCommands().sendCommands(entityplayer); this.server.getCommands().sendCommands(entityplayer);
} }
@@ -673,6 +942,12 @@ @@ -634,6 +897,12 @@
for (int i = 0; i < this.players.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -646,7 +614,7 @@
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) { if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX(); double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY(); double d5 = d1 - entityplayer.getY();
@@ -712,15 +987,19 @@ @@ -673,15 +942,19 @@
public void reloadWhiteList() {} public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) { public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@ -670,7 +638,7 @@
} }
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F)); entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F));
@@ -729,8 +1008,16 @@ @@ -690,8 +963,16 @@
public void sendAllPlayerInfo(EntityPlayer entityplayer) { public void sendAllPlayerInfo(EntityPlayer entityplayer) {
entityplayer.inventoryMenu.sendAllDataToRemote(); entityplayer.inventoryMenu.sendAllDataToRemote();
@ -678,7 +646,7 @@
+ // entityplayer.resetSentInfo(); + // entityplayer.resetSentInfo();
+ entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
+ entityplayer.refreshEntityData(entityplayer); // CraftBukkkit - SPIGOT-7218: sync metadata + entityplayer.refreshEntityData(entityplayer); // CraftBukkkit - SPIGOT-7218: sync metadata
entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected)); entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().getSelectedSlot()));
+ // CraftBukkit start - from GameRules + // CraftBukkit start - from GameRules
+ int i = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; + int i = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23;
+ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); + entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
@ -688,7 +656,7 @@
} }
public int getPlayerCount() { public int getPlayerCount() {
@@ -786,12 +1073,22 @@ @@ -744,12 +1025,22 @@
} }
public void removeAll() { public void removeAll() {
@ -713,7 +681,7 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> { this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent; return ichatbasecomponent;
@@ -849,16 +1146,23 @@ @@ -803,16 +1094,23 @@
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now()); return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
} }
@ -741,7 +709,7 @@
Path path = file2.toPath(); Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -867,7 +1171,7 @@ @@ -821,7 +1119,7 @@
} }
serverstatisticmanager = new ServerStatisticManager(this.server, file1); serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@ -750,7 +718,7 @@
} }
return serverstatisticmanager; return serverstatisticmanager;
@@ -875,13 +1179,13 @@ @@ -829,13 +1127,13 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) { public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID(); UUID uuid = entityplayer.getUUID();
@ -766,23 +734,19 @@
} }
advancementdataplayer.setPlayer(entityplayer); advancementdataplayer.setPlayer(entityplayer);
@@ -932,15 +1236,28 @@ @@ -880,11 +1178,24 @@
} }
public void reloadResources() { public void reloadResources() {
- Iterator iterator = this.advancements.values().iterator(); - for (AdvancementDataPlayer advancementdataplayer : this.advancements.values()) {
+ // CraftBukkit start + // CraftBukkit start
+ /*Iterator iterator = this.advancements.values().iterator(); + /*for (AdvancementDataPlayer advancementdataplayer : this.advancements.values()) {
while (iterator.hasNext()) {
AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next();
advancementdataplayer.reload(this.server.getAdvancements()); advancementdataplayer.reload(this.server.getAdvancements());
+ }*/ + }*/
+ +
+ for (EntityPlayer player : players) { + for (EntityPlayer player : players) {
+ player.getAdvancements().reload(this.server.getAdvancements()); + player.getAdvancements().reload(this.server.getAdvancements());
+ player.getAdvancements().flushDirty(player); // CraftBukkit - trigger immediate flush of advancements + player.getAdvancements().flushDirty(player, false); // CraftBukkit - trigger immediate flush of advancements
} }
+ // CraftBukkit end + // CraftBukkit end
@ -795,4 +759,4 @@
+ // CraftBukkit end + // CraftBukkit end
CraftingManager craftingmanager = this.server.getRecipeManager(); CraftingManager craftingmanager = this.server.getRecipeManager();
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes()); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes());
Iterator iterator1 = this.players.iterator();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/SleepStatus.java --- a/net/minecraft/server/players/SleepStatus.java
+++ b/net/minecraft/server/players/SleepStatus.java +++ b/net/minecraft/server/players/SleepStatus.java
@@ -18,9 +18,12 @@ @@ -17,9 +17,12 @@
} }
public boolean areEnoughDeepSleeping(int i, List<EntityPlayer> list) { public boolean areEnoughDeepSleeping(int i, List<EntityPlayer> list) {
@ -15,15 +15,13 @@
} }
public int sleepersNeeded(int i) { public int sleepersNeeded(int i) {
@@ -42,18 +45,24 @@ @@ -40,16 +43,22 @@
this.activePlayers = 0; this.activePlayers = 0;
this.sleepingPlayers = 0; this.sleepingPlayers = 0;
Iterator iterator = list.iterator();
+ boolean anySleep = false; // CraftBukkit + boolean anySleep = false; // CraftBukkit
while (iterator.hasNext()) { for (EntityPlayer entityplayer : list) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
if (!entityplayer.isSpectator()) { if (!entityplayer.isSpectator()) {
++this.activePlayers; ++this.activePlayers;
- if (entityplayer.isSleeping()) { - if (entityplayer.isSleeping()) {

View File

@ -1,15 +1,6 @@
--- a/net/minecraft/server/players/UserCache.java --- a/net/minecraft/server/players/UserCache.java
+++ b/net/minecraft/server/players/UserCache.java +++ b/net/minecraft/server/players/UserCache.java
@@ -85,7 +85,7 @@ @@ -127,7 +127,7 @@
}
public void onProfileLookupFailed(String s1, Exception exception) {
- atomicreference.set((Object) null);
+ atomicreference.set(null); // CraftBukkit - decompile error
}
};
@@ -142,7 +142,7 @@
usercache_usercacheentry.setLastAccess(this.getNextOperation()); usercache_usercacheentry.setLastAccess(this.getNextOperation());
optional = Optional.of(usercache_usercacheentry.getProfile()); optional = Optional.of(usercache_usercacheentry.getProfile());
} else { } else {
@ -18,16 +9,7 @@
if (optional.isPresent()) { if (optional.isPresent()) {
this.add((GameProfile) optional.get()); this.add((GameProfile) optional.get());
flag = false; flag = false;
@@ -208,7 +208,7 @@ @@ -198,7 +198,7 @@
label54:
{
- ArrayList arraylist;
+ List<UserCache.UserCacheEntry> arraylist; // CraftBukkit - decompile error
try {
JsonArray jsonarray = (JsonArray) this.gson.fromJson(bufferedreader, JsonArray.class);
@@ -217,7 +217,7 @@
DateFormat dateformat = createDateFormat(); DateFormat dateformat = createDateFormat();
jsonarray.forEach((jsonelement) -> { jsonarray.forEach((jsonelement) -> {

View File

@ -28,7 +28,7 @@
this.client = socket; this.client = socket;
try { try {
@@ -38,11 +45,14 @@ @@ -38,6 +45,7 @@
} }
this.rconPassword = s; this.rconPassword = s;
@ -36,16 +36,7 @@
} }
public void run() { public void run() {
- while (true) { @@ -71,7 +79,7 @@
- try {
+ // CraftBukkit start - decompile error: switch try / while statement
+ try {
+ while (true) {
+ // CraftBukkit end
if (!this.running) {
return;
}
@@ -71,7 +81,7 @@
String s = StatusChallengeUtils.stringFromByteArray(this.buf, j, i); String s = StatusChallengeUtils.stringFromByteArray(this.buf, j, i);
try { try {
@ -54,24 +45,3 @@
} catch (Exception exception) { } catch (Exception exception) {
this.sendCmdResponse(l, "Error executing: " + s + " (" + exception.getMessage() + ")"); this.sendCmdResponse(l, "Error executing: " + s + " (" + exception.getMessage() + ")");
} }
@@ -98,6 +108,7 @@
continue;
}
}
+ } // CraftBukkit - decompile error: switch try / while statement
} catch (IOException ioexception) {
return;
} catch (Exception exception1) {
@@ -109,8 +120,10 @@
this.running = false;
}
- return;
- }
+ // CraftBukkit start - decompile error: switch try / while statement
+ // return;
+ // }
+ // CraftBukkit end
}
private void send(int i, int j, String s) throws IOException {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/stats/RecipeBookServer.java --- a/net/minecraft/stats/RecipeBookServer.java
+++ b/net/minecraft/stats/RecipeBookServer.java +++ b/net/minecraft/stats/RecipeBookServer.java
@@ -29,6 +29,8 @@ @@ -26,6 +26,8 @@
import net.minecraft.world.item.crafting.display.RecipeDisplayId; import net.minecraft.world.item.crafting.display.RecipeDisplayId;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -9,8 +9,8 @@
public class RecipeBookServer extends RecipeBook { public class RecipeBookServer extends RecipeBook {
public static final String RECIPE_BOOK_TAG = "recipeBook"; public static final String RECIPE_BOOK_TAG = "recipeBook";
@@ -72,7 +74,7 @@ @@ -68,7 +70,7 @@
RecipeHolder<?> recipeholder = (RecipeHolder) iterator.next(); for (RecipeHolder<?> recipeholder : collection) {
ResourceKey<IRecipe<?>> resourcekey = recipeholder.id(); ResourceKey<IRecipe<?>> resourcekey = recipeholder.id();
- if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial()) { - if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial()) {
@ -18,7 +18,7 @@
this.add(resourcekey); this.add(resourcekey);
this.addHighlight(resourcekey); this.addHighlight(resourcekey);
this.displayResolver.displaysForRecipe(resourcekey, (recipedisplayentry) -> { this.displayResolver.displaysForRecipe(resourcekey, (recipedisplayentry) -> {
@@ -82,7 +84,7 @@ @@ -78,7 +80,7 @@
} }
} }
@ -27,7 +27,7 @@
entityplayer.connection.send(new ClientboundRecipeBookAddPacket(list, false)); entityplayer.connection.send(new ClientboundRecipeBookAddPacket(list, false));
} }
@@ -105,7 +107,7 @@ @@ -99,7 +101,7 @@
} }
} }

View File

@ -4,23 +4,18 @@
+// mc-dev import +// mc-dev import
package net.minecraft.stats; package net.minecraft.stats;
import com.google.common.collect.Maps; import com.google.common.collect.Sets;
@@ -158,13 +159,12 @@ @@ -53,11 +54,11 @@
} private final File file;
private final Set<Statistic<?>> dirty = Sets.newHashSet();
private <T> Optional<Statistic<T>> getStat(StatisticWrapper<T> statisticwrapper, String s) { - private static <T> Codec<Map<Statistic<?>, Integer>> createTypedStatsCodec(StatisticWrapper<T> statisticwrapper) {
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s)); + private static <T> Codec<Map<Statistic<T>, Integer>> createTypedStatsCodec(StatisticWrapper<T> statisticwrapper) { // CraftBukkit - decompile error
- IRegistry iregistry = statisticwrapper.getRegistry(); Codec<T> codec = statisticwrapper.getRegistry().byNameCodec();
+ // CraftBukkit - decompile error start
+ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.tryParse(s));
+ IRegistry<T> iregistry = statisticwrapper.getRegistry();
- Objects.requireNonNull(iregistry); Objects.requireNonNull(statisticwrapper);
- optional = optional.flatMap(iregistry::getOptional); - Codec<Statistic<?>> codec1 = codec.flatComapMap(statisticwrapper::get, (statistic) -> {
- Objects.requireNonNull(statisticwrapper); + Codec<Statistic<T>> codec1 = codec.flatComapMap(statisticwrapper::get, (statistic) -> { // CraftBukkit - decompile error
- return optional.map(statisticwrapper::get); return statistic.getType() == statisticwrapper ? DataResult.success(statistic.getValue()) : DataResult.error(() -> {
+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::get); String s = String.valueOf(statisticwrapper);
+ // CraftBukkit - decompile error end
}
private static NBTTagCompound fromJson(JsonObject jsonobject) {

View File

@ -17,7 +17,7 @@
blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1); blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1);
if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a) && (!flag || worldserver.noCollision(entitytypes.getSpawnAABB((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D)))) { if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a) && (!flag || worldserver.noCollision(entitytypes.getSpawnAABB((double) blockposition_mutableblockposition.getX() + 0.5D, (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + 0.5D)))) {
- T t0 = (EntityInsentient) entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false); - T t0 = entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, entityspawnreason, false, false);
+ T t0 = entitytypes.create(worldserver, (Consumer<T>) null, blockposition_mutableblockposition, entityspawnreason, false, false); // CraftBukkit - decompile error + T t0 = entitytypes.create(worldserver, (Consumer<T>) null, blockposition_mutableblockposition, entityspawnreason, false, false); // CraftBukkit - decompile error
if (t0 != null) { if (t0 != null) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/util/datafix/DataConverterRegistry.java --- a/net/minecraft/util/datafix/DataConverterRegistry.java
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java
@@ -517,6 +517,18 @@ @@ -553,6 +553,20 @@
datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false)); datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false));
Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED); Schema schema45 = datafixerbuilder.addSchema(1458, V1458::new);
+ // CraftBukkit start + // CraftBukkit start
+ datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) { + datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) {
@ -10,73 +10,84 @@
+ protected com.mojang.datafixers.TypeRewriteRule makeRule() { + protected com.mojang.datafixers.TypeRewriteRule makeRule() {
+ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> { + return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> {
+ return typed.update(DSL.remainderFinder(), (dynamic) -> { + return typed.update(DSL.remainderFinder(), (dynamic) -> {
+ return DataConverterCustomNameEntity.fixTagCustomName(dynamic); + String s = dynamic.get("CustomName").asString("");
+
+ return s.isEmpty() ? dynamic.remove("CustomName") : dynamic.set("CustomName", LegacyComponentDataFixUtils.createPlainTextComponent(dynamic.getOps(), s));
+ }); + });
+ }); + });
+ } + }
+ }); + });
+ // CraftBukkit end + // CraftBukkit end
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45));
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45));
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45));
@@ -775,7 +787,8 @@ @@ -617,7 +631,7 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY)); Type<?> type = this.getInputSchema().getType(DataConverterTypes.ENTITY);
Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED); OpticFinder<String> opticfinder = DSL.fieldFinder("id", DataConverterSchemaNamed.namespacedString());
OpticFinder<?> opticfinder1 = type.findField("CustomName");
- OpticFinder<Pair<String, String>> opticfinder2 = DSL.typeFinder(this.getInputSchema().getType(DataConverterTypes.TEXT_COMPONENT));
+ OpticFinder<Pair<String, String>> opticfinder2 = (OpticFinder<Pair<String, String>>) DSL.typeFinder(this.getInputSchema().getType(DataConverterTypes.TEXT_COMPONENT)); // CraftBukkit - decompile error
- datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); return this.fixTypeEverywhereTyped("Command block minecart custom name fix", type, (typed) -> {
String s = (String) typed.getOptional(opticfinder).orElse("");
@@ -826,7 +840,8 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema111, "Added Zoglin", DataConverterTypes.ENTITY));
Schema schema112 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED);
- datafixerbuilder.addFixer(new DataConverterAttributes(schema112, "Attribute renames", createRenamerNoNamespace(ImmutableMap.builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build())));
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ datafixerbuilder.addFixer(new DataConverterAttributes(schema111, "Attribute renames", createRenamerNoNamespace(ImmutableMap.<String, String>builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build()))); + datafixerbuilder.addFixer(new DataConverterAttributes(schema112, "Attribute renames", createRenamerNoNamespace(ImmutableMap.<String, String>builder().put("generic.maxHealth", "minecraft:generic.max_health").put("Max Health", "minecraft:generic.max_health").put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements").put("Spawn Reinforcements Chance", "minecraft:zombie.spawn_reinforcements").put("horse.jumpStrength", "minecraft:horse.jump_strength").put("Jump Strength", "minecraft:horse.jump_strength").put("generic.followRange", "minecraft:generic.follow_range").put("Follow Range", "minecraft:generic.follow_range").put("generic.knockbackResistance", "minecraft:generic.knockback_resistance").put("Knockback Resistance", "minecraft:generic.knockback_resistance").put("generic.movementSpeed", "minecraft:generic.movement_speed").put("Movement Speed", "minecraft:generic.movement_speed").put("generic.flyingSpeed", "minecraft:generic.flying_speed").put("Flying Speed", "minecraft:generic.flying_speed").put("generic.attackDamage", "minecraft:generic.attack_damage").put("generic.attackKnockback", "minecraft:generic.attack_knockback").put("generic.attackSpeed", "minecraft:generic.attack_speed").put("generic.armorToughness", "minecraft:generic.armor_toughness").build())));
Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED); Schema schema113 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED);
datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112)); datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema113));
@@ -838,12 +851,14 @@ @@ -889,12 +904,14 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY));
datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY));
Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED); Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); - ImmutableMap<String, String> immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build();
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap = ImmutableMap.<String, String>builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build(); + ImmutableMap<String, String> immutablemap = ImmutableMap.<String, String>builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build();
datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap))); datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap)));
datafixerbuilder.addFixer(DataConverterBlockRename.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Renamed copper blocks to new oxidized terms", createRenamer(immutablemap)));
Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED); Schema schema133 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); - ImmutableMap<String, String> immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build();
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap1 = ImmutableMap.<String, String>builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build(); + ImmutableMap<String, String> immutablemap1 = ImmutableMap.<String, String>builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build();
datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1))); datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1)));
datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
@@ -851,7 +866,8 @@ @@ -902,7 +919,8 @@
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false)); datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED); Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); - ImmutableMap<String, String> immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build();
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap2 = ImmutableMap.<String, String>builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build(); + ImmutableMap<String, String> immutablemap2 = ImmutableMap.<String, String>builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build();
datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2))); datafixerbuilder.addFixer(DataConverterItemName.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2)));
datafixerbuilder.addFixer(DataConverterBlockRename.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2))); datafixerbuilder.addFixer(DataConverterBlockRename.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2)));
@@ -938,10 +954,11 @@ @@ -989,10 +1007,11 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY)); datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY));
Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED); Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED);
- datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); - datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema161, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())));
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema160, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.<String, String>builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build()))); + datafixerbuilder.addFixer(new NamespacedTypeRenameFix(schema161, "game_event_renames_3084", DataConverterTypes.GAME_EVENT_NAME, createRenamer(ImmutableMap.<String, String>builder().put("minecraft:block_press", "minecraft:block_activate").put("minecraft:block_switch", "minecraft:block_activate").put("minecraft:block_unpress", "minecraft:block_deactivate").put("minecraft:block_unswitch", "minecraft:block_deactivate").put("minecraft:drinking_finish", "minecraft:drink").put("minecraft:elytra_free_fall", "minecraft:elytra_glide").put("minecraft:entity_damaged", "minecraft:entity_damage").put("minecraft:entity_dying", "minecraft:entity_die").put("minecraft:entity_killed", "minecraft:entity_die").put("minecraft:mob_interact", "minecraft:entity_interact").put("minecraft:ravager_roar", "minecraft:entity_roar").put("minecraft:ring_bell", "minecraft:block_change").put("minecraft:shulker_close", "minecraft:container_close").put("minecraft:shulker_open", "minecraft:container_open").put("minecraft:wolf_shaking", "minecraft:entity_shake").build())));
Schema schema161 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED); Schema schema162 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED);
TypeReference typereference = DataConverterTypes.ENTITY; TypeReference typereference = DataConverterTypes.ENTITY;
- Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { - Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> {
+ Int2ObjectOpenHashMap<String> int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error + Int2ObjectOpenHashMap<String> int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error
int2objectopenhashmap1.defaultReturnValue("minecraft:tabby"); int2objectopenhashmap1.defaultReturnValue("minecraft:tabby");
int2objectopenhashmap1.put(0, "minecraft:tabby"); int2objectopenhashmap1.put(0, "minecraft:tabby");
int2objectopenhashmap1.put(1, "minecraft:black"); int2objectopenhashmap1.put(1, "minecraft:black");
@@ -958,7 +975,8 @@ @@ -1009,7 +1028,8 @@
Objects.requireNonNull(int2objectopenhashmap); Objects.requireNonNull(int2objectopenhashmap);
datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get)); datafixerbuilder.addFixer(new EntityVariantFix(schema162, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get));
- ImmutableMap<String, String> immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); - ImmutableMap<String, String> immutablemap3 = ImmutableMap.builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build();
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap3 = ImmutableMap.<String, String>builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build(); + ImmutableMap<String, String> immutablemap3 = ImmutableMap.<String, String>builder().put("textures/entity/cat/tabby.png", "minecraft:tabby").put("textures/entity/cat/black.png", "minecraft:black").put("textures/entity/cat/red.png", "minecraft:red").put("textures/entity/cat/siamese.png", "minecraft:siamese").put("textures/entity/cat/british_shorthair.png", "minecraft:british").put("textures/entity/cat/calico.png", "minecraft:calico").put("textures/entity/cat/persian.png", "minecraft:persian").put("textures/entity/cat/ragdoll.png", "minecraft:ragdoll").put("textures/entity/cat/white.png", "minecraft:white").put("textures/entity/cat/jellie.png", "minecraft:jellie").put("textures/entity/cat/all_black.png", "minecraft:all_black").build();
datafixerbuilder.addFixer(new CriteriaRenameFix(schema161, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> { datafixerbuilder.addFixer(new CriteriaRenameFix(schema162, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> {
return (String) immutablemap3.getOrDefault(s, s); return (String) immutablemap3.getOrDefault(s, s);

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java --- a/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -80,7 +80,7 @@ @@ -82,7 +82,7 @@
public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) { public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, SaveData savedata, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) {
this.dimensions = iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM); this.dimensions = iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM);
- this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); - this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
+ this.levels = (Set) java.util.stream.Stream.of(convertable_conversionsession.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit + this.levels = (Set) java.util.stream.Stream.of(convertable_conversionsession.dimensionType).map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); // CraftBukkit
this.eraseCache = flag; this.eraseCache = flag;
this.dataFixer = datafixer; this.dataFixer = datafixer;
this.levelStorage = convertable_conversionsession; this.levelStorage = convertable_conversionsession;
@@ -197,9 +197,9 @@ @@ -446,9 +446,9 @@
if (nbttagcompound != null) { if (nbttagcompound != null) {
int i = IChunkLoader.getVersion(nbttagcompound); int i = IChunkLoader.getVersion(nbttagcompound);
ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(resourcekey))).generator(); ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(resourcekey))).generator();
@ -18,15 +18,6 @@
return WorldUpgrader.this.overworldDataStorage; return WorldUpgrader.this.overworldDataStorage;
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer()); - }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit + }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos")); ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getIntOr("xPos", 0), nbttagcompound1.getIntOr("zPos", 0));
if (!chunkcoordintpair1.equals(chunkcoordintpair)) { if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
@@ -321,7 +321,7 @@
WorldUpgrader.c<T> worldupgrader_c = (WorldUpgrader.c) iterator.next();
ResourceKey<World> resourcekey = worldupgrader_c.dimensionKey;
ListIterator<WorldUpgrader.e> listiterator = worldupgrader_c.files;
- T t0 = (AutoCloseable) worldupgrader_c.storage;
+ T t0 = (T) worldupgrader_c.storage; // CraftBukkit - decompile error
if (listiterator.hasNext()) {
WorldUpgrader.e worldupgrader_e = (WorldUpgrader.e) listiterator.next();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/IInventory.java --- a/net/minecraft/world/IInventory.java
+++ b/net/minecraft/world/IInventory.java +++ b/net/minecraft/world/IInventory.java
@@ -9,6 +9,11 @@ @@ -11,6 +11,11 @@
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntity;
@ -9,10 +9,10 @@
+import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+// CraftBukkit end +// CraftBukkit end
+ +
public interface IInventory extends Clearable { public interface IInventory extends Clearable, Iterable<ItemStack> {
float DEFAULT_DISTANCE_BUFFER = 4.0F; float DEFAULT_DISTANCE_BUFFER = 4.0F;
@@ -25,9 +30,7 @@ @@ -27,9 +32,7 @@
void setItem(int i, ItemStack itemstack); void setItem(int i, ItemStack itemstack);
@ -23,11 +23,10 @@
default int getMaxStackSize(ItemStack itemstack) { default int getMaxStackSize(ItemStack itemstack) {
return Math.min(this.getMaxStackSize(), itemstack.getMaxStackSize()); return Math.min(this.getMaxStackSize(), itemstack.getMaxStackSize());
@@ -91,4 +94,22 @@ @@ -94,6 +97,24 @@
return new IInventory.a(this);
return world == null ? false : (world.getBlockEntity(blockposition) != tileentity ? false : entityhuman.canInteractWithBlock(blockposition, (double) f));
} }
+
+ // CraftBukkit start + // CraftBukkit start
+ java.util.List<ItemStack> getContents(); + java.util.List<ItemStack> getContents();
+ +
@ -45,4 +44,7 @@
+ +
+ int MAX_STACK = 99; + int MAX_STACK = 99;
+ // CraftBukkit end + // CraftBukkit end
} +
public static class a implements Iterator<ItemStack> {
private final IInventory container;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/InventorySubcontainer.java --- a/net/minecraft/world/InventorySubcontainer.java
+++ b/net/minecraft/world/InventorySubcontainer.java +++ b/net/minecraft/world/InventorySubcontainer.java
@@ -14,6 +14,12 @@ @@ -13,6 +13,12 @@
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -13,7 +13,7 @@
public class InventorySubcontainer implements IInventory, AutoRecipeOutput { public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
private final int size; private final int size;
@@ -21,7 +27,59 @@ @@ -20,7 +26,59 @@
@Nullable @Nullable
private List<IInventoryListener> listeners; private List<IInventoryListener> listeners;
@ -71,5 +71,5 @@
+ this.bukkitOwner = owner; + this.bukkitOwner = owner;
+ // CraftBukkit end + // CraftBukkit end
this.size = i; this.size = i;
this.items = NonNullList.withSize(i, ItemStack.EMPTY); this.items = NonNullList.<ItemStack>withSize(i, ItemStack.EMPTY);
} }

View File

@ -9,12 +9,12 @@
} else { } else {
entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), (float) (6 << i)); entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), (float) (6 << i));
} }
@@ -31,7 +31,7 @@ @@ -30,7 +30,7 @@
if (this.isHarm == entityliving.isInvertedHealAndHarm()) { if (this.isHarm == entityliving.isInvertedHealAndHarm()) {
j = (int) (d0 * (double) (4 << i) + 0.5D); int j = (int) (d0 * (double) (4 << i) + 0.5D);
- entityliving.heal((float) j); - entityliving.heal((float) j);
+ entityliving.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit + entityliving.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
} else { } else {
j = (int) (d0 * (double) (6 << i) + 0.5D); int k = (int) (d0 * (double) (6 << i) + 0.5D);
if (entity == null) {

View File

@ -2,7 +2,7 @@
+++ b/net/minecraft/world/effect/InfestedMobEffect.java +++ b/net/minecraft/world/effect/InfestedMobEffect.java
@@ -48,7 +48,11 @@ @@ -48,7 +48,11 @@
entitysilverfish.moveTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F); entitysilverfish.snapTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F);
entitysilverfish.setDeltaMovement(new Vec3D(vector3f)); entitysilverfish.setDeltaMovement(new Vec3D(vector3f));
- worldserver.addFreshEntity(entitysilverfish); - worldserver.addFreshEntity(entitysilverfish);
+ // CraftBukkit start + // CraftBukkit start

View File

@ -3,7 +3,7 @@
@@ -52,7 +52,7 @@ @@ -52,7 +52,7 @@
if (entityslime != null) { if (entityslime != null) {
entityslime.setSize(2, true); entityslime.setSize(2, true);
entityslime.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F); entityslime.snapTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F);
- world.addFreshEntity(entityslime); - world.addFreshEntity(entityslime);
+ world.addFreshEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit + world.addFreshEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ConversionType.java --- a/net/minecraft/world/entity/ConversionType.java
+++ b/net/minecraft/world/entity/ConversionType.java +++ b/net/minecraft/world/entity/ConversionType.java
@@ -12,6 +12,11 @@ @@ -11,6 +11,11 @@
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.scores.Scoreboard; import net.minecraft.world.scores.Scoreboard;
@ -12,25 +12,25 @@
public enum ConversionType { public enum ConversionType {
SINGLE(true) { SINGLE(true) {
@@ -31,7 +36,7 @@ @@ -26,7 +31,7 @@
while (iterator.hasNext()) {
entity1 = (Entity) iterator.next(); for (Entity entity1 : entityinsentient1.getPassengers()) {
entity1.stopRiding(); entity1.stopRiding();
- entity1.remove(Entity.RemovalReason.DISCARDED); - entity1.remove(Entity.RemovalReason.DISCARDED);
+ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause + entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
} }
entity.startRiding(entityinsentient1); entity.startRiding(entityinsentient1);
@@ -52,7 +57,7 @@ @@ -44,7 +49,7 @@
ItemStack itemstack = entityinsentient.getItemBySlot(enumitemslot); ItemStack itemstack = entityinsentient.getItemBySlot(enumitemslot);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
- entityinsentient1.setItemSlot(enumitemslot, itemstack.copyAndClear()); - entityinsentient1.setItemSlot(enumitemslot, itemstack.copyAndClear());
+ entityinsentient1.setItemSlot(enumitemslot, itemstack.copy()); // CraftBukkit - SPIGOT-7996: don't clear yet + entityinsentient1.setItemSlot(enumitemslot, itemstack.copy()); // CraftBukkit - SPIGOT-7996: don't clear yet
entityinsentient1.setDropChance(enumitemslot, entityinsentient.getEquipmentDropChance(enumitemslot)); entityinsentient1.setDropChance(enumitemslot, entityinsentient.getDropChances().byEquipment(enumitemslot));
} }
} }
@@ -64,7 +69,7 @@ @@ -56,7 +61,7 @@
entityinsentient1.hurtTime = entityinsentient.hurtTime; entityinsentient1.hurtTime = entityinsentient.hurtTime;
entityinsentient1.yBodyRot = entityinsentient.yBodyRot; entityinsentient1.yBodyRot = entityinsentient.yBodyRot;
entityinsentient1.setOnGround(entityinsentient.onGround()); entityinsentient1.setOnGround(entityinsentient.onGround());
@ -39,7 +39,7 @@
Objects.requireNonNull(entityinsentient1); Objects.requireNonNull(entityinsentient1);
optional.ifPresent(entityinsentient1::setSleepingPos); optional.ifPresent(entityinsentient1::setSleepingPos);
@@ -75,6 +80,21 @@ @@ -68,6 +73,21 @@
this.convertCommon(entityinsentient, entityinsentient1, conversionparams); this.convertCommon(entityinsentient, entityinsentient1, conversionparams);
} }
@ -61,7 +61,7 @@
}, },
SPLIT_ON_DEATH(false) { SPLIT_ON_DEATH(false) {
@Override @Override
@@ -107,6 +127,8 @@ @@ -100,6 +120,8 @@
abstract void convert(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams); abstract void convert(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams);
@ -69,8 +69,8 @@
+ +
void convertCommon(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams) { void convertCommon(EntityInsentient entityinsentient, EntityInsentient entityinsentient1, ConversionParams conversionparams) {
entityinsentient1.setAbsorptionAmount(entityinsentient.getAbsorptionAmount()); entityinsentient1.setAbsorptionAmount(entityinsentient.getAbsorptionAmount());
Iterator iterator = entityinsentient.getActiveEffects().iterator();
@@ -156,7 +178,7 @@ @@ -146,7 +168,7 @@
entityinsentient1.setNoGravity(entityinsentient.isNoGravity()); entityinsentient1.setNoGravity(entityinsentient.isNoGravity());
entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown()); entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown());
entityinsentient1.setSilent(entityinsentient.isSilent()); entityinsentient1.setSilent(entityinsentient.isSilent());

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -139,8 +139,68 @@ @@ -144,8 +144,68 @@
import net.minecraft.world.scores.ScoreboardTeamBase; import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger; import org.jetbrains.annotations.Contract;
+// CraftBukkit start +// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity; +import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
@ -43,12 +43,12 @@
+import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.PluginManager;
+// CraftBukkit end +// CraftBukkit end
+ +
public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder { public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder, DataComponentGetter {
+ // CraftBukkit start + // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2; + private static final int CURRENT_LEVEL = 2;
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) { + static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; + return tag.contains("Bukkit.updateLevel") && tag.getIntOr("Bukkit.updateLevel", -1) >= level;
+ } + }
+ +
+ private CraftEntity bukkitEntity; + private CraftEntity bukkitEntity;
@ -66,13 +66,13 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id"; public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers"; public static final String PASSENGERS_TAG = "Passengers";
@@ -253,6 +313,30 @@ private static final String DATA_TAG = "data";
private final List<Entity.b> movementThisTick; @@ -262,6 +322,30 @@
private final Set<IBlockData> blocksInside;
private final LongSet visitedBlocks; private final LongSet visitedBlocks;
private final InsideBlockEffectApplier.a insideEffectCollector;
private CustomData customData;
+ // CraftBukkit start + // CraftBukkit start
+ public boolean forceDrops; + public boolean forceDrops;
+ public boolean persist = true; + public boolean persist = true;
@ -100,7 +100,7 @@
public Entity(EntityTypes<?> entitytypes, World world) { public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -362,12 +446,18 @@ @@ -372,12 +456,18 @@
} }
public void kill(WorldServer worldserver) { public void kill(WorldServer worldserver) {
@ -121,7 +121,7 @@
} }
protected abstract void defineSynchedData(DataWatcher.a datawatcher_a); protected abstract void defineSynchedData(DataWatcher.a datawatcher_a);
@@ -376,6 +466,16 @@ @@ -386,6 +476,16 @@
return this.entityData; return this.entityData;
} }
@ -138,7 +138,7 @@
public boolean equals(Object object) { public boolean equals(Object object) {
return object instanceof Entity ? ((Entity) object).id == this.id : false; return object instanceof Entity ? ((Entity) object).id == this.id : false;
} }
@@ -385,7 +485,13 @@ @@ -395,7 +495,13 @@
} }
public void remove(Entity.RemovalReason entity_removalreason) { public void remove(Entity.RemovalReason entity_removalreason) {
@ -153,7 +153,7 @@
} }
public void onClientRemoval() {} public void onClientRemoval() {}
@@ -393,6 +499,12 @@ @@ -403,6 +509,12 @@
public void onRemoval(Entity.RemovalReason entity_removalreason) {} public void onRemoval(Entity.RemovalReason entity_removalreason) {}
public void setPose(EntityPose entitypose) { public void setPose(EntityPose entitypose) {
@ -166,7 +166,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose); this.entityData.set(Entity.DATA_POSE, entitypose);
} }
@@ -417,6 +529,33 @@ @@ -427,6 +539,33 @@
} }
protected void setRot(float f, float f1) { protected void setRot(float f, float f1) {
@ -200,7 +200,7 @@
this.setYRot(f % 360.0F); this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F); this.setXRot(f1 % 360.0F);
} }
@@ -462,6 +601,15 @@ @@ -472,6 +611,15 @@
this.baseTick(); this.baseTick();
} }
@ -216,7 +216,7 @@
public void baseTick() { public void baseTick() {
GameProfilerFiller gameprofilerfiller = Profiler.get(); GameProfilerFiller gameprofilerfiller = Profiler.get();
@@ -475,7 +623,7 @@ @@ -485,7 +633,7 @@
--this.boardingCooldown; --this.boardingCooldown;
} }
@ -225,10 +225,10 @@
if (this.canSpawnSprintParticle()) { if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle(); this.spawnSprintParticle();
} }
@@ -514,6 +662,10 @@ @@ -518,6 +666,10 @@
if (this.isInLava()) { if (this.isInLava()) {
this.lavaHurt(); this.fallDistance *= 0.5D;
this.fallDistance *= 0.5F;
+ // CraftBukkit start + // CraftBukkit start
+ } else { + } else {
+ this.lastLavaContact = null; + this.lastLavaContact = null;
@ -236,18 +236,18 @@
} }
this.checkBelowWorld(); this.checkBelowWorld();
@@ -525,7 +677,7 @@ @@ -529,7 +681,7 @@
world = this.level(); world = this.level();
if (world instanceof WorldServer worldserver) { if (world instanceof WorldServer worldserver1) {
if (this instanceof Leashable) { if (this instanceof Leashable) {
- Leashable.tickLeash(worldserver, (Entity) ((Leashable) this)); - Leashable.tickLeash(worldserver1, (Entity) ((Leashable) this));
+ Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error + Leashable.tickLeash(worldserver1, (Entity & Leashable) this); // CraftBukkit - decompile error
} }
} }
@@ -568,15 +720,32 @@ @@ -572,7 +724,22 @@
public void lavaHurt() { public void lavaIgnite() {
if (!this.fireImmune()) { if (!this.fireImmune()) {
- this.igniteForSeconds(15.0F); - this.igniteForSeconds(15.0F);
+ // CraftBukkit start - Fallen in lava TODO: this event spams! + // CraftBukkit start - Fallen in lava TODO: this event spams!
@ -266,21 +266,19 @@
+ this.igniteForSeconds(15.0F, false); + this.igniteForSeconds(15.0F, false);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
World world = this.level(); }
}
@@ -583,7 +750,7 @@
if (world instanceof WorldServer) { if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world; WorldServer worldserver = (WorldServer) world;
- if (this.hurtServer(worldserver, this.damageSources().lava(), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { - if (this.hurtServer(worldserver, this.damageSources().lava(), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) {
+ // CraftBukkit start + if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { // CraftBukkit
+ if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) { worldserver.playSound((Entity) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
worldserver.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
} }
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
} }
@@ -596,6 +763,22 @@
}
@@ -587,6 +756,22 @@
} }
public final void igniteForSeconds(float f) { public final void igniteForSeconds(float f) {
@ -303,7 +301,7 @@
this.igniteForTicks(MathHelper.floor(f * 20.0F)); this.igniteForTicks(MathHelper.floor(f * 20.0F));
} }
@@ -610,7 +795,7 @@ @@ -620,7 +803,7 @@
} }
protected void onBelowWorld() { protected void onBelowWorld() {
@ -312,7 +310,7 @@
} }
public boolean isFree(double d0, double d1, double d2) { public boolean isFree(double d0, double d1, double d2) {
@@ -750,6 +935,28 @@ @@ -774,6 +957,28 @@
} }
} }
@ -338,10 +336,19 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission(); Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1133,6 +1340,20 @@ @@ -828,7 +1033,7 @@
protected void applyEffectsFromBlocks() {
this.finalMovementsThisTick.clear();
- List list = this.movementThisTick;
+ List<List<Entity.b>> list = this.movementThisTick; // CraftBukkit - decompile error
List list1 = this.finalMovementsThisTick;
Objects.requireNonNull(this.finalMovementsThisTick);
@@ -1158,6 +1363,20 @@
return SoundEffects.GENERIC_SPLASH; return SoundEffects.GENERIC_SPLASH;
} }
@ -359,18 +366,18 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) { private void checkInsideBlocks(List<Entity.b> list, InsideBlockEffectApplier.a insideblockeffectapplier_a) {
this.movementThisTick.add(new Entity.b(vec3d, vec3d1)); if (this.isAffectedByBlocks()) {
} LongSet longset = this.visitedBlocks;
@@ -1609,6 +1830,7 @@ @@ -1624,6 +1843,7 @@
this.yo = d1; this.yo = d1;
this.zo = d4; this.zo = d4;
this.setPos(d3, d1, d4); this.setPos(d3, d1, d4);
+ if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit + if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit
} }
public void moveTo(Vec3D vec3d) { public void snapTo(Vec3D vec3d) {
@@ -1861,6 +2083,12 @@ @@ -1876,6 +2096,12 @@
return false; return false;
} }
@ -383,7 +390,7 @@
public void awardKillScore(Entity entity, DamageSource damagesource) { public void awardKillScore(Entity entity, DamageSource damagesource) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1889,16 +2117,22 @@ @@ -1904,16 +2130,22 @@
} }
public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { public boolean saveAsPassenger(NBTTagCompound nbttagcompound) {
@ -408,7 +415,7 @@
return true; return true;
} }
} }
@@ -1909,16 +2143,38 @@ @@ -1924,14 +2156,34 @@
} }
public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) {
@ -420,23 +427,20 @@
+ // CraftBukkit end + // CraftBukkit end
try { try {
- if (this.vehicle != null) { - if (this.vehicle != null) {
- nbttagcompound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); - nbttagcompound.store("Pos", Vec3D.CODEC, new Vec3D(this.vehicle.getX(), this.getY(), this.vehicle.getZ()));
- } else { - } else {
- nbttagcompound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); - nbttagcompound.store("Pos", Vec3D.CODEC, this.position());
+ // CraftBukkit start - selectively save position + // CraftBukkit start - selectively save position
+ if (includeAll) { + if (includeAll) {
+ if (this.vehicle != null) { + if (this.vehicle != null) {
+ nbttagcompound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); + nbttagcompound.store("Pos", Vec3D.CODEC, new Vec3D(this.vehicle.getX(), this.getY(), this.vehicle.getZ()));
+ } else { + } else {
+ nbttagcompound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); + nbttagcompound.store("Pos", Vec3D.CODEC, this.position());
+ } + }
} }
+ // CraftBukkit end + // CraftBukkit end
Vec3D vec3d = this.getDeltaMovement(); nbttagcompound.store("Motion", Vec3D.CODEC, this.getDeltaMovement());
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
+
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
+ // TODO: make sure this is the best way to address this. + // TODO: make sure this is the best way to address this.
+ if (Float.isNaN(this.yRot)) { + if (Float.isNaN(this.yRot)) {
@ -447,18 +451,17 @@
+ this.xRot = 0; + this.xRot = 0;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ nbttagcompound.store("Rotation", Vec2F.CODEC, new Vec2F(this.getYRot(), this.getXRot()));
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.putDouble("fall_distance", this.fallDistance);
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1926,7 +2182,28 @@ @@ -1939,7 +2191,28 @@
nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("OnGround", this.onGround());
nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
- nbttagcompound.putUUID("UUID", this.getUUID()); - nbttagcompound.store("UUID", UUIDUtil.CODEC, this.getUUID());
+ // CraftBukkit start - selectively save uuid and world + // CraftBukkit start - selectively save uuid and world
+ if (includeAll) { + if (includeAll) {
+ nbttagcompound.putUUID("UUID", this.getUUID()); + nbttagcompound.store("UUID", UUIDUtil.CODEC, this.getUUID());
+ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
+ nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits()); + nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits());
+ nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits()); + nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits());
@ -481,17 +484,16 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName(); IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) { if (ichatbasecomponent != null) {
@@ -1975,7 +2252,7 @@ @@ -1982,14 +2255,14 @@
nbttagcompound.put("Tags", nbttaglist); nbttagcompound.store("data", CustomData.CODEC, this.customData);
} }
- this.addAdditionalSaveData(nbttagcompound); - this.addAdditionalSaveData(nbttagcompound);
+ this.addAdditionalSaveData(nbttagcompound, includeAll); // CraftBukkit - pass on includeAll + this.addAdditionalSaveData(nbttagcompound, includeAll); // CraftBukkit - pass on includeAll
if (this.isVehicle()) { if (this.isVehicle()) {
nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
iterator = this.getPassengers().iterator();
@@ -1984,7 +2261,7 @@ for (Entity entity : this.getPassengers()) {
Entity entity = (Entity) iterator.next();
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
- if (entity.saveAsPassenger(nbttagcompound1)) { - if (entity.saveAsPassenger(nbttagcompound1)) {
@ -499,7 +501,7 @@
nbttaglist.add(nbttagcompound1); nbttaglist.add(nbttagcompound1);
} }
} }
@@ -1994,6 +2271,11 @@ @@ -1999,6 +2272,11 @@
} }
} }
@ -511,18 +513,34 @@
return nbttagcompound; return nbttagcompound;
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2080,6 +2362,45 @@ @@ -2041,7 +2319,7 @@
this.setRot(this.getYRot(), this.getXRot());
RegistryOps<NBTBase> registryops = this.registryAccess().<NBTBase>createSerializationContext(DynamicOpsNBT.INSTANCE);
- this.setCustomName((IChatBaseComponent) nbttagcompound.read("CustomName", ComponentSerialization.CODEC, registryops).orElse((Object) null));
+ this.setCustomName((IChatBaseComponent) nbttagcompound.read("CustomName", ComponentSerialization.CODEC, registryops).orElse(null)); // CraftBukkit - decompile error
this.setCustomNameVisible(nbttagcompound.getBooleanOr("CustomNameVisible", false));
this.setSilent(nbttagcompound.getBooleanOr("Silent", false));
this.setNoGravity(nbttagcompound.getBooleanOr("NoGravity", false));
@@ -2050,7 +2328,7 @@
this.hasVisualFire = nbttagcompound.getBooleanOr("HasVisualFire", false);
this.customData = (CustomData) nbttagcompound.read("data", CustomData.CODEC).orElse(CustomData.EMPTY);
this.tags.clear();
- Optional optional = nbttagcompound.read("Tags", Entity.TAG_LIST_CODEC);
+ Optional<List<String>> optional = nbttagcompound.read("Tags", Entity.TAG_LIST_CODEC); // CraftBukkit - deocmpile error
Set set = this.tags;
Objects.requireNonNull(this.tags);
@@ -2066,6 +2344,43 @@
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
} }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); + this.persist = nbttagcompound.getBooleanOr("Bukkit.persist", this.persist);
+ this.visibleByDefault = !nbttagcompound.contains("Bukkit.visibleByDefault") || nbttagcompound.getBoolean("Bukkit.visibleByDefault"); + this.visibleByDefault = nbttagcompound.getBooleanOr("Bukkit.visibleByDefault", this.visibleByDefault);
+ // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ if (nbttagcompound.contains("Bukkit.MaxAirSupply")) { + this.maxAirTicks = nbttagcompound.getIntOr("Bukkit.MaxAirSupply", this.maxAirTicks);
+ maxAirTicks = nbttagcompound.getInt("Bukkit.MaxAirSupply");
+ }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ // CraftBukkit start - Reset world + // CraftBukkit start - Reset world
@ -531,10 +549,10 @@
+ org.bukkit.World bworld = null; + org.bukkit.World bworld = null;
+ +
+ // TODO: Remove World related checks, replaced with WorldUID + // TODO: Remove World related checks, replaced with WorldUID
+ String worldName = nbttagcompound.getString("world"); + String worldName = nbttagcompound.getStringOr("world", "");
+ +
+ if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) { + if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) {
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast")); + UUID uid = new UUID(nbttagcompound.getLongOr("WorldUUIDMost", -1), nbttagcompound.getLongOr("WorldUUIDLeast", -1));
+ bworld = server.getWorld(uid); + bworld = server.getWorld(uid);
+ } else { + } else {
+ bworld = server.getWorld(worldName); + bworld = server.getWorld(worldName);
@ -548,7 +566,7 @@
+ } + }
+ this.getBukkitEntity().readBukkitValues(nbttagcompound); + this.getBukkitEntity().readBukkitValues(nbttagcompound);
+ if (nbttagcompound.contains("Bukkit.invisible")) { + if (nbttagcompound.contains("Bukkit.invisible")) {
+ boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible"); + boolean bukkitInvisible = nbttagcompound.getBooleanOr("Bukkit.invisible", false);
+ this.setInvisible(bukkitInvisible); + this.setInvisible(bukkitInvisible);
+ this.persistentInvisibility = bukkitInvisible; + this.persistentInvisibility = bukkitInvisible;
+ } + }
@ -557,7 +575,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -2101,6 +2422,12 @@ @@ -2087,6 +2402,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
} }
@ -570,7 +588,7 @@
protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound);
protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound);
@@ -2153,9 +2480,22 @@ @@ -2111,9 +2432,22 @@
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
return null; return null;
} else { } else {
@ -593,7 +611,7 @@
worldserver.addFreshEntity(entityitem); worldserver.addFreshEntity(entityitem);
return entityitem; return entityitem;
} }
@@ -2184,6 +2524,12 @@ @@ -2142,6 +2476,12 @@
if (this.isAlive() && this instanceof Leashable leashable) { if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == entityhuman) { if (leashable.getLeashHolder() == entityhuman) {
if (!this.level().isClientSide()) { if (!this.level().isClientSide()) {
@ -606,7 +624,7 @@
if (entityhuman.hasInfiniteMaterials()) { if (entityhuman.hasInfiniteMaterials()) {
leashable.removeLeash(); leashable.removeLeash();
} else { } else {
@@ -2200,6 +2546,13 @@ @@ -2158,6 +2498,13 @@
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) { if (!this.level().isClientSide()) {
@ -620,7 +638,7 @@
leashable.setLeashedTo(entityhuman, true); leashable.setLeashedTo(entityhuman, true);
} }
@@ -2273,7 +2626,7 @@ @@ -2231,7 +2578,7 @@
return false; return false;
} else if (!entity.couldAcceptPassenger()) { } else if (!entity.couldAcceptPassenger()) {
return false; return false;
@ -629,7 +647,7 @@
return false; return false;
} else { } else {
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
@@ -2285,6 +2638,27 @@ @@ -2243,6 +2590,27 @@
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false; return false;
} else { } else {
@ -657,7 +675,7 @@
if (this.isPassenger()) { if (this.isPassenger()) {
this.stopRiding(); this.stopRiding();
} }
@@ -2318,7 +2692,7 @@ @@ -2276,7 +2644,7 @@
Entity entity = this.vehicle; Entity entity = this.vehicle;
this.vehicle = null; this.vehicle = null;
@ -666,7 +684,7 @@
} }
} }
@@ -2349,10 +2723,38 @@ @@ -2307,10 +2675,38 @@
} }
} }
@ -706,7 +724,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of(); this.passengers = ImmutableList.of();
} else { } else {
@@ -2364,6 +2766,7 @@ @@ -2322,6 +2718,7 @@
entity.boardingCooldown = 60; entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
} }
@ -714,7 +732,7 @@
} }
protected boolean canAddPassenger(Entity entity) { protected boolean canAddPassenger(Entity entity) {
@@ -2464,7 +2867,7 @@ @@ -2416,7 +2813,7 @@
if (teleporttransition != null) { if (teleporttransition != null) {
WorldServer worldserver1 = teleporttransition.newLevel(); WorldServer worldserver1 = teleporttransition.newLevel();
@ -723,7 +741,7 @@
this.teleport(teleporttransition); this.teleport(teleporttransition);
} }
} }
@@ -2571,6 +2974,13 @@ @@ -2523,6 +2920,13 @@
} }
public void setSwimming(boolean flag) { public void setSwimming(boolean flag) {
@ -737,7 +755,7 @@
this.setSharedFlag(4, flag); this.setSharedFlag(4, flag);
} }
@@ -2624,8 +3034,12 @@ @@ -2576,8 +2980,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
} }
@ -751,7 +769,7 @@
} }
public boolean getSharedFlag(int i) { public boolean getSharedFlag(int i) {
@@ -2644,7 +3058,7 @@ @@ -2596,7 +3004,7 @@
} }
public int getMaxAirSupply() { public int getMaxAirSupply() {
@ -760,7 +778,7 @@
} }
public int getAirSupply() { public int getAirSupply() {
@@ -2652,7 +3066,18 @@ @@ -2604,7 +3012,18 @@
} }
public void setAirSupply(int i) { public void setAirSupply(int i) {
@ -779,8 +797,8 @@
+ // CraftBukkit end + // CraftBukkit end
} }
public int getTicksFrozen() { public void clearFreeze() {
@@ -2679,11 +3104,40 @@ @@ -2635,11 +3054,40 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1); this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -822,11 +840,17 @@
+ // CraftBukkit end + // CraftBukkit end
} }
public void onAboveBubbleCol(boolean flag) { public void onAboveBubbleColumn(boolean flag, BlockPosition blockposition) {
@@ -2852,6 +3306,18 @@ @@ -2816,11 +3264,23 @@
if (world instanceof WorldServer worldserver) { @Nullable
public Entity teleport(TeleportTransition teleporttransition) {
- WorldServer worldserver = this.level();
+ World worldserver = this.level(); // CraftBukkit - decompile error
if (worldserver instanceof WorldServer worldserver1) {
if (!this.isRemoved()) { if (!this.isRemoved()) {
- worldserver = teleporttransition.newLevel();
+ // CraftBukkit start + // CraftBukkit start
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); + PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
+ Location to = CraftLocation.toBukkit(absolutePosition.position(), teleporttransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + Location to = CraftLocation.toBukkit(absolutePosition.position(), teleporttransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
@ -839,24 +863,34 @@
+ teleporttransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause()); + teleporttransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause());
+ } + }
+ // CraftBukkit end + // CraftBukkit end
WorldServer worldserver1 = teleporttransition.newLevel(); + worldserver1 = teleporttransition.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension(); boolean flag = worldserver.dimension() != worldserver1.dimension();
@@ -2920,8 +3386,12 @@ if (!teleporttransition.asPassenger()) {
@@ -2828,7 +3288,7 @@
}
if (flag) {
- return this.teleportCrossDimension(worldserver, teleporttransition);
+ return this.teleportCrossDimension(worldserver1, teleporttransition); // CraftBukkit - decompile error
}
return this.teleportSameDimension(worldserver1, teleporttransition);
@@ -2881,8 +3341,12 @@
} else { } else {
entity.restoreFrom(this); entity2.restoreFrom(this);
this.removeAfterChangingDimensions(); this.removeAfterChangingDimensions();
+ // CraftBukkit start - Forward the CraftEntity to the new entity + // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity); + this.getBukkitEntity().setHandle(entity2);
+ entity.bukkitEntity = this.getBukkitEntity(); + entity2.bukkitEntity = this.getBukkitEntity();
+ // CraftBukkit end + // CraftBukkit end
entity.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); entity2.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
- worldserver.addDuringTeleport(entity); - worldserver.addDuringTeleport(entity2);
+ if (this.inWorld) worldserver.addDuringTeleport(entity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned + if (this.inWorld) worldserver.addDuringTeleport(entity2); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned
Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) { for (Entity entity3 : list1) {
@@ -2995,8 +3465,9 @@ entity3.startRiding(entity2, true);
@@ -2950,8 +3414,9 @@
} }
protected void removeAfterChangingDimensions() { protected void removeAfterChangingDimensions() {
@ -867,7 +901,7 @@
leashable.removeLeash(); leashable.removeLeash();
} }
@@ -3006,6 +3477,20 @@ @@ -2961,6 +3426,20 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
} }
@ -888,25 +922,24 @@
public boolean canUsePortal(boolean flag) { public boolean canUsePortal(boolean flag) {
return (flag || !this.isPassenger()) && this.isAlive(); return (flag || !this.isPassenger()) && this.isAlive();
} }
@@ -3134,9 +3619,15 @@ @@ -3085,8 +3564,14 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
} }
- 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) {
- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, set, TeleportTransition.DO_NOTHING));
+ // CraftBukkit start + // CraftBukkit start
+ public final boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) { + public final boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
+ return teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, PlayerTeleportEvent.TeleportCause.UNKNOWN); + return teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ } + }
+ +
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); + Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, set, TeleportTransition.DO_NOTHING, cause));
- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING));
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
+ // CraftBukkit end + // CraftBukkit end
return entity != null; return entity != null;
} }
@@ -3258,7 +3749,26 @@ @@ -3208,7 +3693,26 @@
} }
public final void setBoundingBox(AxisAlignedBB axisalignedbb) { public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -934,7 +967,7 @@
} }
public final float getEyeHeight(EntityPose entitypose) { public final float getEyeHeight(EntityPose entitypose) {
@@ -3489,8 +3999,37 @@ @@ -3433,8 +3937,37 @@
return 1; return 1;
} }
@ -973,7 +1006,7 @@
} }
public void lookAt(ArgumentAnchor.Anchor argumentanchor_anchor, Vec3D vec3d) { public void lookAt(ArgumentAnchor.Anchor argumentanchor_anchor, Vec3D vec3d) {
@@ -3551,6 +4090,11 @@ @@ -3495,6 +4028,11 @@
vec3d = vec3d.add(vec3d1); vec3d = vec3d.add(vec3d1);
++k1; ++k1;
} }
@ -985,7 +1018,7 @@
} }
} }
} }
@@ -3818,6 +4362,14 @@ @@ -3766,6 +4304,14 @@
@Override @Override
public final void setRemoved(Entity.RemovalReason entity_removalreason) { public final void setRemoved(Entity.RemovalReason entity_removalreason) {

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/world/entity/EntityAgeable.java --- a/net/minecraft/world/entity/EntityAgeable.java
+++ b/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java
@@ -21,6 +21,7 @@ @@ -23,6 +23,7 @@
protected int age; protected int age = 0;
protected int forcedAge; protected int forcedAge = 0;
protected int forcedAgeTimer; protected int forcedAgeTimer;
+ public boolean ageLocked; // CraftBukkit + public boolean ageLocked; // CraftBukkit
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) { protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
@@ -104,6 +105,7 @@ @@ -106,6 +107,7 @@
super.addAdditionalSaveData(nbttagcompound); super.addAdditionalSaveData(nbttagcompound);
nbttagcompound.putInt("Age", this.getAge()); nbttagcompound.putInt("Age", this.getAge());
nbttagcompound.putInt("ForcedAge", this.forcedAge); nbttagcompound.putInt("ForcedAge", this.forcedAge);
@ -16,15 +16,15 @@
} }
@Override @Override
@@ -111,6 +113,7 @@ @@ -113,6 +115,7 @@
super.readAdditionalSaveData(nbttagcompound); super.readAdditionalSaveData(nbttagcompound);
this.setAge(nbttagcompound.getInt("Age")); this.setAge(nbttagcompound.getIntOr("Age", 0));
this.forcedAge = nbttagcompound.getInt("ForcedAge"); this.forcedAge = nbttagcompound.getIntOr("ForcedAge", 0);
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit + this.ageLocked = nbttagcompound.getBooleanOr("AgeLocked", this.ageLocked); // CraftBukkit
} }
@Override @Override
@@ -125,7 +128,7 @@ @@ -127,7 +130,7 @@
@Override @Override
public void aiStep() { public void aiStep() {
super.aiStep(); super.aiStep();

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
@@ -33,6 +33,12 @@ @@ -32,6 +32,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.material.EnumPistonReaction; import net.minecraft.world.level.material.EnumPistonReaction;
import org.slf4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.entity.CraftLivingEntity;
@ -12,17 +12,17 @@
+ +
public class EntityAreaEffectCloud extends Entity implements TraceableEntity { public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
private static final Logger LOGGER = LogUtils.getLogger(); private static final int TIME_BETWEEN_APPLICATIONS = 5;
@@ -200,7 +206,7 @@ @@ -217,7 +223,7 @@
private void serverTick(WorldServer worldserver) { private void serverTick(WorldServer worldserver) {
if (this.tickCount >= this.waitTime + this.duration) { if (this.duration != -1 && this.tickCount >= this.waitTime + this.duration) {
- this.discard(); - this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else { } else {
boolean flag = this.isWaiting(); boolean flag = this.isWaiting();
boolean flag1 = this.tickCount < this.waitTime; boolean flag1 = this.tickCount < this.waitTime;
@@ -215,7 +221,7 @@ @@ -232,7 +238,7 @@
if (this.radiusPerTick != 0.0F) { if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick; f += this.radiusPerTick;
if (f < 0.5F) { if (f < 0.5F) {
@ -31,21 +31,19 @@
return; return;
} }
@@ -249,11 +255,12 @@ @@ -254,9 +260,10 @@
List<EntityLiving> list1 = this.level().<EntityLiving>getEntitiesOfClass(EntityLiving.class, this.getBoundingBox());
if (!list1.isEmpty()) { if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit + List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator1.hasNext()) { for (EntityLiving entityliving : list1) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) { if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
- Stream stream = list.stream(); - Stream stream = list.stream();
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error + Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
Objects.requireNonNull(entityliving); Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) { if (!stream.noneMatch(entityliving::canBeAffected)) {
@@ -262,6 +269,19 @@ @@ -265,20 +272,33 @@
double d2 = d0 * d0 + d1 * d1; double d2 = d0 * d0 + d1 * d1;
if (d2 <= (double) (f * f)) { if (d2 <= (double) (f * f)) {
@ -63,14 +61,13 @@
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end + // CraftBukkit end
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay); this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -271,14 +291,14 @@ for (MobEffect mobeffect : list) {
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) { if (((MobEffectList) mobeffect.getEffect().value()).isInstantenous()) {
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D); ((MobEffectList) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), 0.5D);
} else { } else {
- entityliving.addEffect(new MobEffect(mobeffect1), this); - entityliving.addEffect(new MobEffect(mobeffect), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + entityliving.addEffect(new MobEffect(mobeffect), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
} }
} }
@ -83,7 +80,7 @@
} }
@@ -288,7 +308,7 @@ @@ -288,7 +308,7 @@
if (this.durationOnUse != 0) { if (this.durationOnUse != 0 && this.duration != -1) {
this.duration += this.durationOnUse; this.duration += this.durationOnUse;
if (this.duration <= 0) { if (this.duration <= 0) {
- this.discard(); - this.discard();
@ -91,3 +88,12 @@
return; return;
} }
} }
@@ -381,7 +401,7 @@
this.radiusOnUse = nbttagcompound.getFloatOr("RadiusOnUse", 0.0F);
this.radiusPerTick = nbttagcompound.getFloatOr("RadiusPerTick", 0.0F);
this.setRadius(nbttagcompound.getFloatOr("Radius", 3.0F));
- this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse((Object) null);
+ this.ownerUUID = (UUID) nbttagcompound.read("Owner", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error
RegistryOps<NBTBase> registryops = this.registryAccess().<NBTBase>createSerializationContext(DynamicOpsNBT.INSTANCE);
this.setParticle((ParticleParam) nbttagcompound.read("Particle", Particles.CODEC, registryops).orElse(EntityAreaEffectCloud.DEFAULT_PARTICLE));

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityCreature.java --- a/net/minecraft/world/entity/EntityCreature.java
+++ b/net/minecraft/world/entity/EntityCreature.java +++ b/net/minecraft/world/entity/EntityCreature.java
@@ -11,6 +11,10 @@ @@ -10,6 +10,10 @@
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityExperienceOrb.java --- a/net/minecraft/world/entity/EntityExperienceOrb.java
+++ b/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java
@@ -25,6 +25,14 @@ @@ -24,6 +24,14 @@
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -14,17 +14,25 @@
+ +
public class EntityExperienceOrb extends Entity { public class EntityExperienceOrb extends Entity {
private static final int LIFETIME = 6000; protected static final DataWatcherObject<Integer> DATA_VALUE = DataWatcher.<Integer>defineId(EntityExperienceOrb.class, DataWatcherRegistry.INT);
@@ -68,6 +76,7 @@ @@ -123,13 +131,14 @@
@Override
public void tick() { ++this.age;
super.tick(); if (this.age >= 6000) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
}
private void followNearbyPlayer() {
+ EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target + EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target
this.xo = this.getX(); if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr((Entity) this) > 64.0D) {
this.yo = this.getY(); EntityHuman entityhuman = this.level().getNearestPlayer(this, 8.0D);
this.zo = this.getZ();
@@ -93,7 +102,22 @@ @@ -140,7 +149,22 @@
this.followingPlayer = null; }
} }
- if (this.followingPlayer != null) { - if (this.followingPlayer != null) {
@ -46,17 +54,8 @@
+ // CraftBukkit end + // CraftBukkit end
Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ()); Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ());
double d0 = vec3d.lengthSqr(); double d0 = vec3d.lengthSqr();
double d1 = 1.0D - Math.sqrt(d0) / 8.0D;
@@ -121,7 +145,7 @@ @@ -205,7 +229,7 @@
++this.age;
if (this.age >= 6000) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
}
}
@@ -190,7 +214,7 @@
private void merge(EntityExperienceOrb entityexperienceorb) { private void merge(EntityExperienceOrb entityexperienceorb) {
this.count += entityexperienceorb.count; this.count += entityexperienceorb.count;
this.age = Math.min(this.age, entityexperienceorb.age); this.age = Math.min(this.age, entityexperienceorb.age);
@ -65,7 +64,7 @@
} }
private void setUnderwaterMovement() { private void setUnderwaterMovement() {
@@ -215,7 +239,7 @@ @@ -230,7 +254,7 @@
this.markHurt(); this.markHurt();
this.health = (int) ((float) this.health - f); this.health = (int) ((float) this.health - f);
if (this.health <= 0) { if (this.health <= 0) {
@ -74,14 +73,14 @@
} }
return true; return true;
@@ -242,17 +266,17 @@ @@ -257,17 +281,17 @@
public void playerTouch(EntityHuman entityhuman) { public void playerTouch(EntityHuman entityhuman) {
if (entityhuman instanceof EntityPlayer entityplayer) { if (entityhuman instanceof EntityPlayer entityplayer) {
if (entityhuman.takeXpDelay == 0) { if (entityhuman.takeXpDelay == 0) {
- entityhuman.takeXpDelay = 2; - entityhuman.takeXpDelay = 2;
+ entityhuman.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entityhuman, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; + entityhuman.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entityhuman, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2;
entityhuman.take(this, 1); entityhuman.take(this, 1);
int i = this.repairPlayerItems(entityplayer, this.value); int i = this.repairPlayerItems(entityplayer, this.getValue());
if (i > 0) { if (i > 0) {
- entityhuman.giveExperiencePoints(i); - entityhuman.giveExperiencePoints(i);
@ -95,7 +94,7 @@
} }
} }
@@ -266,12 +290,20 @@ @@ -281,12 +305,20 @@
ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack(); ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack();
int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i); int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i);
int k = Math.min(j, itemstack.getDamageValue()); int k = Math.min(j, itemstack.getDamageValue());
@ -112,11 +111,11 @@
int l = i - k * i / j; int l = i - k * i / j;
if (l > 0) { if (l > 0) {
+ this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls + this.setValue(l); // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls
return this.repairPlayerItems(entityplayer, l); return this.repairPlayerItems(entityplayer, l);
} }
} }
@@ -291,6 +323,24 @@ @@ -312,6 +344,24 @@
} }
public static int getExperienceValue(int i) { public static int getExperienceValue(int i) {

View File

@ -1,12 +1,16 @@
--- a/net/minecraft/world/entity/EntityInsentient.java --- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -85,6 +85,18 @@ @@ -83,6 +83,23 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.ticks.ContainerSingleItem;
+// CraftBukkit start +// CraftBukkit start
+import java.util.Arrays;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
@ -14,12 +18,13 @@
+import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityTransformEvent;
+import org.bukkit.event.entity.EntityUnleashEvent; +import org.bukkit.event.entity.EntityUnleashEvent;
+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end +// CraftBukkit end
+ +
public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting { public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting {
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE); private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.<Byte>defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -132,6 +144,8 @@ @@ -126,6 +143,8 @@
private BlockPosition restrictCenter; private BlockPosition restrictCenter;
private float restrictRadius; private float restrictRadius;
@ -27,8 +32,8 @@
+ +
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) { protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY); this.dropChances = DropChances.DEFAULT;
@@ -160,6 +174,12 @@ @@ -149,6 +168,12 @@
} }
@ -41,7 +46,7 @@
protected void registerGoals() {} protected void registerGoals() {}
public static AttributeProvider.Builder createMobAttributes() { public static AttributeProvider.Builder createMobAttributes() {
@@ -264,11 +284,42 @@ @@ -253,11 +278,42 @@
@Nullable @Nullable
protected final EntityLiving getTargetFromBrain() { protected final EntityLiving getTargetFromBrain() {
@ -85,7 +90,7 @@
} }
@Override @Override
@@ -399,6 +450,12 @@ @@ -379,6 +435,12 @@
return null; return null;
} }
@ -98,7 +103,7 @@
@Override @Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) { public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound); super.addAdditionalSaveData(nbttagcompound);
@@ -473,13 +530,25 @@ @@ -403,13 +465,25 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi()); nbttagcompound.putBoolean("NoAI", this.isNoAi());
} }
@ -108,37 +113,35 @@
@Override @Override
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) { public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound); super.readAdditionalSaveData(nbttagcompound);
- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot")); - this.setCanPickUpLoot(nbttagcompound.getBooleanOr("CanPickUpLoot", false));
- this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired"); - this.persistenceRequired = nbttagcompound.getBooleanOr("PersistenceRequired", false);
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
+ if (nbttagcompound.contains("CanPickUpLoot", 99)) { + if (nbttagcompound.contains("CanPickUpLoot")) {
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot"); + boolean data = nbttagcompound.getBooleanOr("CanPickUpLoot", false);
+ if (isLevelAtLeast(nbttagcompound, 1) || data) { + if (isLevelAtLeast(nbttagcompound, 1) || data) {
+ this.setCanPickUpLoot(data); + this.setCanPickUpLoot(data);
+ } + }
+ } + }
+ +
+ boolean data = nbttagcompound.getBoolean("PersistenceRequired"); + boolean data = nbttagcompound.getBooleanOr("PersistenceRequired", false);
+ if (isLevelAtLeast(nbttagcompound, 1) || data) { + if (isLevelAtLeast(nbttagcompound, 1) || data) {
+ this.persistenceRequired = data; + this.persistenceRequired = data;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
NBTTagList nbttaglist; RegistryOps<NBTBase> registryops = this.registryAccess().<NBTBase>createSerializationContext(DynamicOpsNBT.INSTANCE);
NBTTagCompound nbttagcompound1;
int i;
@@ -547,6 +616,11 @@
this.lootTableSeed = nbttagcompound.getLong("DeathLootTableSeed"); this.dropChances = (DropChances) nbttagcompound.read("drop_chances", DropChances.CODEC, registryops).orElse(DropChances.DEFAULT);
this.setNoAi(nbttagcompound.getBoolean("NoAI")); @@ -418,6 +492,9 @@
this.lootTable = nbttagcompound.read("DeathLootTable", LootTable.KEY_CODEC);
this.lootTableSeed = nbttagcompound.getLongOr("DeathLootTableSeed", 0L);
this.setNoAi(nbttagcompound.getBooleanOr("NoAI", false));
+ // CraftBukkit start + // CraftBukkit start
+ if (nbttagcompound.contains("Bukkit.Aware")) { + this.aware = nbttagcompound.getBooleanOr("Bukkit.Aware", this.aware);
+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware");
+ }
+ // CraftBukkit end + // CraftBukkit end
} }
@Override @Override
@@ -623,20 +697,26 @@ @@ -490,20 +567,26 @@
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) { protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem(); ItemStack itemstack = entityitem.getItem();
@ -165,9 +168,9 @@
+ public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack, EntityItem entityitem) { + public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack, EntityItem entityitem) {
+ // CraftBukkit end + // CraftBukkit end
EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack); EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot); if (!this.isEquippableInSlot(itemstack, enumitemslot)) {
@@ -647,11 +727,19 @@ @@ -518,11 +601,19 @@
flag = itemstack1.isEmpty(); flag = itemstack1.isEmpty();
} }
@ -179,7 +182,7 @@
+ } + }
+ if (canPickup) { + if (canPickup) {
+ // CraftBukkit end + // CraftBukkit end
double d0 = (double) this.getEquipmentDropChance(enumitemslot); double d0 = (double) this.dropChances.byEquipment(enumitemslot);
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
+ this.forceDrops = true; // CraftBukkit + this.forceDrops = true; // CraftBukkit
@ -188,16 +191,16 @@
} }
ItemStack itemstack2 = enumitemslot.limit(itemstack); ItemStack itemstack2 = enumitemslot.limit(itemstack);
@@ -768,7 +856,7 @@ @@ -630,7 +721,7 @@
@Override @Override
public void checkDespawn() { public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
- this.discard(); - this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D); Entity entity = this.level().getNearestPlayer(this, -1.0D);
@@ -778,14 +866,14 @@ @@ -640,14 +731,14 @@
int j = i * i; int j = i * i;
if (d0 > (double) j && this.removeWhenFarAway(d0)) { if (d0 > (double) j && this.removeWhenFarAway(d0)) {
@ -214,7 +217,7 @@
} else if (d0 < (double) l) { } else if (d0 < (double) l) {
this.noActionTime = 0; this.noActionTime = 0;
} }
@@ -799,6 +887,7 @@ @@ -661,6 +752,7 @@
@Override @Override
protected final void serverAiStep() { protected final void serverAiStep() {
++this.noActionTime; ++this.noActionTime;
@ -222,7 +225,59 @@
GameProfilerFiller gameprofilerfiller = Profiler.get(); GameProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("sensing"); gameprofilerfiller.push("sensing");
@@ -1338,7 +1427,7 @@ @@ -841,6 +933,51 @@
public boolean stillValid(EntityHuman entityhuman) {
return entityhuman.getVehicle() == EntityInsentient.this || entityhuman.canInteractWithEntity((Entity) EntityInsentient.this, 4.0D);
}
+
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ @Override
+ public List<ItemStack> getContents() {
+ return Arrays.asList(this.getTheItem());
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ @Override
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ @Override
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+
+ @Override
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+
+ @Override
+ public InventoryHolder getOwner() {
+ return (InventoryHolder) EntityInsentient.this.getBukkitEntity();
+ }
+
+ @Override
+ public Location getLocation() {
+ return EntityInsentient.this.getBukkitEntity().getLocation();
+ }
+ // CraftBukkit end
};
}
@@ -1132,7 +1269,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) { if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level() instanceof WorldServer) { if (this.level() instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
@ -231,13 +286,11 @@
optional.ifPresent((entityinsentient) -> { optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient); this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1389,12 +1478,19 @@ @@ -1185,6 +1322,13 @@
return this.restrictRadius != -1.0F;
}
+ // CraftBukkit start
@Nullable @Nullable
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a) { public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a) {
+ // CraftBukkit start
+ return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ } + }
+ +
@ -247,12 +300,7 @@
if (this.isRemoved()) { if (this.isRemoved()) {
return null; return null;
} else { } else {
- T t0 = (EntityInsentient) entitytypes.create(this.level(), entityspawnreason); @@ -1197,14 +1341,26 @@
+ T t0 = entitytypes.create(this.level(), EntitySpawnReason.CONVERSION); // CraftBukkit - decompile error
if (t0 == null) {
return null;
@@ -1403,14 +1499,26 @@
conversionparams_a.finalizeConversion(t0); conversionparams_a.finalizeConversion(t0);
World world = this.level(); World world = this.level();
@ -281,23 +329,23 @@
} }
return t0; return t0;
@@ -1420,7 +1528,14 @@ @@ -1214,7 +1370,14 @@
@Nullable @Nullable
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a) { public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a) {
- return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a); - return (T) this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a);
+ // CraftBukkit start + // CraftBukkit start
+ return this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + return (T) this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ } + }
+ +
+ @Nullable + @Nullable
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason); + return (T) this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason);
+ // CraftBukkit end + // CraftBukkit end
} }
@Nullable @Nullable
@@ -1458,6 +1573,7 @@ @@ -1252,6 +1415,7 @@
boolean flag1 = super.startRiding(entity, flag); boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) { if (flag1 && this.isLeashed()) {
@ -305,12 +353,12 @@
this.dropLeash(); this.dropLeash();
} }
@@ -1542,7 +1658,7 @@ @@ -1341,7 +1505,7 @@
if (f1 > 0.0F && entity instanceof EntityLiving) { if (f1 > 0.0F && entity instanceof EntityLiving) {
entityliving = (EntityLiving) entity; EntityLiving entityliving = (EntityLiving) entity;
- entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
+ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit - entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * ((float) Math.PI / 180F)), (double) (-MathHelper.cos(this.getYRot() * ((float) Math.PI / 180F))));
+ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * ((float) Math.PI / 180F)), (double) (-MathHelper.cos(this.getYRot() * ((float) Math.PI / 180F))), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLightning.java --- a/net/minecraft/world/entity/EntityLightning.java
+++ b/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java
@@ -31,6 +31,11 @@ @@ -29,6 +29,11 @@
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -12,7 +12,7 @@
public class EntityLightning extends Entity { public class EntityLightning extends Entity {
private static final int START_LIFE = 2; private static final int START_LIFE = 2;
@@ -120,7 +125,7 @@ @@ -112,7 +117,7 @@
} }
} }
@ -21,7 +21,7 @@
} else if (this.life < -this.random.nextInt(10)) { } else if (this.life < -this.random.nextInt(10)) {
--this.flashes; --this.flashes;
this.life = 1; this.life = 1;
@@ -129,7 +134,7 @@ @@ -121,7 +126,7 @@
} }
} }
@ -30,7 +30,7 @@
if (!(this.level() instanceof WorldServer)) { if (!(this.level() instanceof WorldServer)) {
this.level().setSkyFlashTime(2); this.level().setSkyFlashTime(2);
} else if (!this.visualOnly) { } else if (!this.visualOnly) {
@@ -169,8 +174,12 @@ @@ -158,8 +163,12 @@
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition); IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@ -45,7 +45,7 @@
} }
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
@@ -178,8 +187,12 @@ @@ -167,8 +176,12 @@
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1); iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) { if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
@ -60,14 +60,3 @@
} }
} }
@@ -247,8 +260,9 @@
iblockdata = world.getBlockState(blockposition1);
} while (!(iblockdata.getBlock() instanceof WeatheringCopper));
+ BlockPosition blockposition1Final = blockposition1; // CraftBukkit - decompile error
WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
- world.setBlockAndUpdate(blockposition1, iblockdata1);
+ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
});
world.levelEvent(3002, blockposition1, -1);
return Optional.of(blockposition1);

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/EntityLiving.java --- a/net/minecraft/world/entity/EntityLiving.java
+++ b/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java
@@ -136,6 +136,33 @@ @@ -134,6 +134,36 @@
import net.minecraft.world.scores.ScoreboardTeam; import org.jetbrains.annotations.Contract;
import org.slf4j.Logger; import org.slf4j.Logger;
+// CraftBukkit start +// CraftBukkit start
@ -12,6 +12,8 @@
+import java.util.UUID; +import java.util.UUID;
+import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagFloat;
+import net.minecraft.nbt.NBTTagInt; +import net.minecraft.nbt.NBTTagInt;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.world.damagesource.DamageType;
+import net.minecraft.world.item.component.Consumable; +import net.minecraft.world.item.component.Consumable;
+import org.bukkit.Location; +import org.bukkit.Location;
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
@ -28,16 +30,17 @@
+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityResurrectEvent; +import org.bukkit.event.entity.EntityResurrectEvent;
+import org.bukkit.event.entity.EntityTeleportEvent; +import org.bukkit.event.entity.EntityTeleportEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.event.player.PlayerItemConsumeEvent;
+// CraftBukkit end +// CraftBukkit end
+ +
public abstract class EntityLiving extends Entity implements Attackable { public abstract class EntityLiving extends Entity implements Attackable {
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
@@ -260,6 +287,19 @@ @@ -246,6 +276,19 @@
protected boolean skipDropExperience; protected boolean skipDropExperience;
private final EnumMap<EnumItemSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments; private final EnumMap<EnumItemSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments;
protected float appliedScale; protected final EntityEquipment equipment;
+ // CraftBukkit start + // CraftBukkit start
+ public int expToDrop; + public int expToDrop;
+ public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(); + public ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
@ -54,33 +57,42 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) { protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
@@ -276,7 +316,9 @@ @@ -253,7 +296,9 @@
this.lastClimbablePos = Optional.empty();
this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class); this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class);
this.appliedScale = 1.0F;
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes)); this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
- this.setHealth(this.getMaxHealth()); - this.setHealth(this.getMaxHealth());
+ this.craftAttributes = new CraftAttributeMap(attributes); // CraftBukkit + this.craftAttributes = new CraftAttributeMap(attributes); // CraftBukkit
+ // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
+ this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttribute(GenericAttributes.MAX_HEALTH).getValue()); + this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttribute(GenericAttributes.MAX_HEALTH).getValue());
this.equipment = this.createEquipment();
this.blocksBuilding = true; this.blocksBuilding = true;
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.reapplyPosition(); this.reapplyPosition();
@@ -356,7 +398,13 @@ @@ -336,7 +381,13 @@
double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D); double d8 = Math.min((double) 0.2F + d1 / 15.0D, 2.5D);
int i = (int) (150.0D * d8); int i = (int) (150.0D * d8);
- worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); - worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F);
+ // CraftBukkit start - visiblity api + // CraftBukkit start - visiblity api
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ worldserver.sendParticlesSource((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), false, false, d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + worldserver.sendParticlesSource((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), false, false, d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F);
+ } else { + } else {
+ worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, (double) 0.15F);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
} }
} }
@@ -573,7 +621,7 @@ @@ -367,7 +418,7 @@
this.getSleepingPos().ifPresent(this::setPosToBed);
}
- WorldServer worldserver = this.level();
+ WorldServer worldserver = (WorldServer) this.level(); // CraftBukkit - decompile error
if (worldserver instanceof WorldServer worldserver1) {
EnchantmentManager.tickEffects(worldserver1, this);
@@ -541,7 +592,7 @@
++this.deathTime; ++this.deathTime;
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
this.level().broadcastEntityEvent(this, (byte) 60); this.level().broadcastEntityEvent(this, (byte) 60);
@ -89,7 +101,7 @@
} }
} }
@@ -679,13 +727,19 @@ @@ -660,11 +711,17 @@
} }
public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) { public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) {
@ -100,17 +112,15 @@
+ public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) { + public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
+ // CraftBukkit end + // CraftBukkit end
if (!this.level().isClientSide() && !this.isSpectator()) { if (!this.level().isClientSide() && !this.isSpectator()) {
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty(); if (!ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE); Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
- if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot()) { - if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot()) {
+ if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot() && !silent) { // CraftBukkit + if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot() && !silent) { // CraftBukkit
this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong()); this.level().playSeededSound((Entity) null, this.getX(), this.getY(), this.getZ(), this.getEquipSound(enumitemslot, itemstack1, equippable), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
} }
@@ -699,6 +753,13 @@ @@ -682,6 +739,13 @@
@Override @Override
public void remove(Entity.RemovalReason entity_removalreason) { public void remove(Entity.RemovalReason entity_removalreason) {
@ -124,7 +134,7 @@
if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) { if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) {
World world = this.level(); World world = this.level();
@@ -709,7 +770,7 @@ @@ -692,7 +756,7 @@
} }
} }
@ -133,7 +143,7 @@
this.brain.clearMemories(); this.brain.clearMemories();
} }
@@ -722,6 +783,7 @@ @@ -701,6 +765,7 @@
mobeffect.onMobRemoved(worldserver, this, entity_removalreason); mobeffect.onMobRemoved(worldserver, this, entity_removalreason);
} }
@ -141,26 +151,81 @@
this.activeEffects.clear(); this.activeEffects.clear();
} }
@@ -781,6 +843,17 @@ @@ -747,6 +812,13 @@
@Nullable
public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
+ // CraftBukkit start - SPIGOT-2942: Add boolean to call event
+ return drop(itemstack, flag, flag1, true);
+ }
+
+ @Nullable
+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) {
+ // CraftBukkit end
if (itemstack.isEmpty()) {
return null;
} else if (this.level().isClientSide) {
@@ -756,6 +828,31 @@
EntityItem entityitem = this.createItemStackToDrop(itemstack, flag, flag1);
if (entityitem != null) {
+ // CraftBukkit start - fire PlayerDropItemEvent
+ if (callEvent && this instanceof EntityPlayer) {
+ Player player = (Player) this.getBukkitEntity();
+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
+
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
+ // The complete stack was dropped
+ player.getInventory().setItemInHand(drop.getItemStack());
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
+ // Only one item is dropped
+ cur.setAmount(cur.getAmount() + 1);
+ player.getInventory().setItemInHand(cur);
+ } else {
+ // Fallback
+ player.getInventory().addItem(drop.getItemStack());
+ }
+ return null;
+ }
+ }
+ // CraftBukkit end
this.level().addFreshEntity(entityitem);
} }
@@ -767,7 +864,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
this.internalSetAbsorptionAmount(nbttagcompound.getFloatOr("AbsorptionAmount", 0.0F));
if (this.level() != null && !this.level().isClientSide) {
- Optional optional = nbttagcompound.getList("attributes");
+ Optional<NBTTagList> optional = nbttagcompound.getList("attributes"); // CraftBukkit - decompile error
AttributeMapBase attributemapbase = this.getAttributes();
java.util.Objects.requireNonNull(attributemapbase);
@@ -783,6 +880,17 @@
this.activeEffects.put(mobeffect.getEffect(), mobeffect);
} }
+ // CraftBukkit start + // CraftBukkit start
+ if (nbttagcompound.contains("Bukkit.MaxHealth")) { + if (nbttagcompound.contains("Bukkit.MaxHealth")) {
+ NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth"); + NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
+ if (nbtbase.getId() == 5) { + if (nbtbase.getId() == 5) {
+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).getAsDouble()); + this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).doubleValue());
+ } else if (nbtbase.getId() == 3) { + } else if (nbtbase.getId() == 3) {
+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).getAsDouble()); + this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).doubleValue());
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (nbttagcompound.contains("Health", 99)) { this.setHealth(nbttagcompound.getFloatOr("Health", this.getMaxHealth()));
this.setHealth(nbttagcompound.getFloat("Health")); this.hurtTime = nbttagcompound.getShortOr("HurtTime", (short) 0);
} this.deathTime = nbttagcompound.getShortOr("DeathTime", (short) 0);
@@ -819,9 +892,32 @@ @@ -816,12 +924,35 @@
this.equipment.setAll((EntityEquipment) nbttagcompound.read("equipment", EntityEquipment.CODEC, registryops).orElseGet(EntityEquipment::new));
} }
+ // CraftBukkit start + // CraftBukkit start
@ -186,16 +251,19 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
protected void tickEffects() { protected void tickEffects() {
World world = this.level();
if (world instanceof WorldServer worldserver) {
Iterator<Holder<MobEffectList>> iterator = this.activeEffects.keySet().iterator(); Iterator<Holder<MobEffectList>> iterator = this.activeEffects.keySet().iterator();
+ isTickingEffects = true; // CraftBukkit + isTickingEffects = true; // CraftBukkit
try { try {
while (iterator.hasNext()) { while (iterator.hasNext()) {
Holder<MobEffectList> holder = (Holder) iterator.next(); Holder<MobEffectList> holder = (Holder) iterator.next();
@@ -831,6 +927,12 @@ @@ -830,6 +961,12 @@
if (!mobeffect.tickServer(worldserver, this, () -> {
this.onEffectUpdated(mobeffect, true, (Entity) null); this.onEffectUpdated(mobeffect, true, (Entity) null);
})) { })) {
if (!this.level().isClientSide) {
+ // CraftBukkit start + // CraftBukkit start
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -204,8 +272,8 @@
+ // CraftBukkit end + // CraftBukkit end
iterator.remove(); iterator.remove();
this.onEffectsRemoved(List.of(mobeffect)); this.onEffectsRemoved(List.of(mobeffect));
} } else if (mobeffect.getDuration() % 600 == 0) {
@@ -841,6 +943,17 @@ @@ -839,6 +976,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) { } catch (ConcurrentModificationException concurrentmodificationexception) {
; ;
} }
@ -222,8 +290,8 @@
+ // CraftBukkit end + // CraftBukkit end
if (this.effectsDirty) { if (this.effectsDirty) {
if (!this.level().isClientSide) { this.updateInvisibilityStatus();
@@ -952,17 +1065,36 @@ @@ -946,17 +1094,36 @@
this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of()); this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of());
} }
@ -264,7 +332,7 @@
} }
} }
@@ -987,20 +1119,50 @@ @@ -987,20 +1154,50 @@
return this.addEffect(mobeffect, (Entity) null); return this.addEffect(mobeffect, (Entity) null);
} }
@ -316,18 +384,18 @@
flag = true; flag = true;
} }
@@ -1031,13 +1193,39 @@ @@ -1031,13 +1228,39 @@
return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM); return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM);
} }
+ // CraftBukkit start + // CraftBukkit start
@Nullable @Nullable
public MobEffect removeEffectNoUpdate(Holder<MobEffectList> holder) { public final MobEffect removeEffectNoUpdate(Holder<MobEffectList> holder) {
+ return removeEffectNoUpdate(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + return removeEffectNoUpdate(holder, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
+ } + }
+ +
+ @Nullable + @Nullable
+ public MobEffect removeEffectNoUpdate(Holder<MobEffectList> holder, EntityPotionEffectEvent.Cause cause) { + public final MobEffect removeEffectNoUpdate(Holder<MobEffectList> holder, EntityPotionEffectEvent.Cause cause) {
+ if (isTickingEffects) { + if (isTickingEffects) {
+ effectsToProcess.add(new ProcessableEffect(holder, cause)); + effectsToProcess.add(new ProcessableEffect(holder, cause));
+ return null; + return null;
@ -357,7 +425,7 @@
if (mobeffect != null) { if (mobeffect != null) {
this.onEffectsRemoved(List.of(mobeffect)); this.onEffectsRemoved(List.of(mobeffect));
@@ -1142,20 +1330,55 @@ @@ -1129,20 +1352,55 @@
} }
@ -414,7 +482,7 @@
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth())); this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
} }
@@ -1167,7 +1390,7 @@ @@ -1154,7 +1412,7 @@
public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) { public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) {
if (this.isInvulnerableTo(worldserver, damagesource)) { if (this.isInvulnerableTo(worldserver, damagesource)) {
return false; return false;
@ -423,23 +491,16 @@
return false; return false;
} else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { } else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false; return false;
@@ -1182,10 +1405,11 @@ @@ -1169,38 +1427,64 @@
} }
float f1 = f; float f1 = f;
- boolean flag = false; + /* // CraftBukkit start - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage
+ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below float f2 = this.applyItemBlocking(worldserver, damagesource, f);
float f2 = 0.0F;
- if (f > 0.0F && this.isDamageSourceBlocked(damagesource)) { f -= f2;
+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage boolean flag = f2 > 0.0F;
+ if (false && f > 0.0F && this.isDamageSourceBlocked(damagesource)) { + */ // CraftBukkit end
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1202,15 +1426,26 @@
flag = true;
}
- if (damagesource.is(DamageTypeTags.IS_FREEZING) && this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) { - if (damagesource.is(DamageTypeTags.IS_FREEZING) && this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) {
+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f + // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f
@ -458,15 +519,18 @@
+ EntityDamageEvent event = handleEntityDamage(damagesource, f); + EntityDamageEvent event = handleEntityDamage(damagesource, f);
+ f = 0; + f = 0;
+ f += (float) event.getDamage(DamageModifier.BASE); + f += (float) event.getDamage(DamageModifier.BASE);
+ f += (float) event.getDamage(DamageModifier.BLOCKING);
+ f += (float) event.getDamage(DamageModifier.FREEZING); + f += (float) event.getDamage(DamageModifier.FREEZING);
+ f += (float) event.getDamage(DamageModifier.HARD_HAT); + f += (float) event.getDamage(DamageModifier.HARD_HAT);
+
+ float f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
+
+ f -= f2;
+ boolean flag = f2 > 0.0F;
+ // CraftBukkit end + // CraftBukkit end
+ +
this.walkAnimation.setSpeed(1.5F);
if (Float.isNaN(f) || Float.isInfinite(f)) { if (Float.isNaN(f) || Float.isInfinite(f)) {
f = Float.MAX_VALUE; f = Float.MAX_VALUE;
@@ -1218,18 +1453,27 @@ }
boolean flag1 = true; boolean flag1 = true;
@ -498,7 +562,7 @@
this.hurtDuration = 10; this.hurtDuration = 10;
this.hurtTime = this.hurtDuration; this.hurtTime = this.hurtDuration;
} }
@@ -1243,7 +1487,7 @@ @@ -1216,7 +1500,7 @@
worldserver.broadcastDamageEvent(this, damagesource); worldserver.broadcastDamageEvent(this, damagesource);
} }
@ -507,17 +571,17 @@
this.markHurt(); this.markHurt();
} }
@@ -1263,7 +1507,7 @@ @@ -1236,7 +1520,7 @@
d1 = damagesource.getSourcePosition().z() - this.getZ(); d1 = damagesource.getSourcePosition().z() - this.getZ();
} }
- this.knockback(0.4000000059604645D, d0, d1); - this.knockback((double) 0.4F, d0, d1);
+ this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit + this.knockback((double) 0.4F, d0, d1, entity, entity == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
if (!flag) { if (!flag) {
this.indicateDamage(d0, d1); this.indicateDamage(d0, d1);
} }
@@ -1282,12 +1526,12 @@ @@ -1257,13 +1541,13 @@
this.playHurtSound(damagesource); this.playSecondaryHurtSound(damagesource);
} }
- boolean flag2 = !flag || f > 0.0F; - boolean flag2 = !flag || f > 0.0F;
@ -526,29 +590,78 @@
if (flag2) { if (flag2) {
this.lastDamageSource = damagesource; this.lastDamageSource = damagesource;
this.lastDamageStamp = this.level().getGameTime(); this.lastDamageStamp = this.level().getGameTime();
- Iterator iterator = this.getActiveEffects().iterator();
+ Iterator iterator = new LinkedList<>(this.getActiveEffects()).iterator(); // CraftBukkit - SPIGOT-7999: copy to prevent CME in unrelated events
while (iterator.hasNext()) { - for (MobEffect mobeffect : this.getActiveEffects()) {
MobEffect mobeffect = (MobEffect) iterator.next(); + for (MobEffect mobeffect : new LinkedList<>(this.getActiveEffects())) { // CraftBukkit - SPIGOT-7999: copy to prevent CME in unrelated events
@@ -1363,7 +1607,7 @@ mobeffect.onMobHurt(worldserver, this, damagesource, f);
}
}
@@ -1290,6 +1574,12 @@
} }
protected void blockedByShield(EntityLiving entityliving) { public float applyItemBlocking(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start
+ return actuallyDoItemBlocking(worldserver, damagesource, calculateItemBlocking(damagesource, f));
+ }
+
+ private float calculateItemBlocking(DamageSource damagesource, float f) {
+ // CraftBukkit end
if (f <= 0.0F) {
return 0.0F;
} else {
@@ -1301,7 +1591,7 @@
BlocksAttacks blocksattacks = (BlocksAttacks) itemstack.get(DataComponents.BLOCKS_ATTACKS);
if (blocksattacks != null) {
- Optional optional = blocksattacks.bypassedBy();
+ Optional<TagKey<DamageType>> optional = blocksattacks.bypassedBy(); // CraftBukkit - decompile error
java.util.Objects.requireNonNull(damagesource);
if (!(Boolean) optional.map(damagesource::is).orElse(false)) {
@@ -1330,6 +1620,26 @@
float f1 = blocksattacks.resolveBlockedDamage(damagesource, f, d0);
+ // CraftBukkit start
+ return f1;
+ }
+ }
+
+ return 0.0F;
+ }
+ }
+ }
+
+ private float actuallyDoItemBlocking(WorldServer worldserver, DamageSource damagesource, float f1) {
+ {
+ {
+ ItemStack itemstack = this.getItemBlockingWith();
+
+ if (itemstack != null) {
+ BlocksAttacks blocksattacks = (BlocksAttacks) itemstack.get(DataComponents.BLOCKS_ATTACKS);
+
+ if (blocksattacks != null) {
+ // CraftBukkit end
blocksattacks.hurtBlockingItem(this.level(), itemstack, this, this.getUsedItemHand(), f1);
if (!damagesource.is(DamageTypeTags.IS_PROJECTILE)) {
Entity entity1 = damagesource.getDirectEntity();
@@ -1395,7 +1705,7 @@
}
protected void blockedByItem(EntityLiving entityliving) {
- entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ()); - entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ());
+ entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ(), null, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit + entityliving.knockback(0.5D, entityliving.getX() - this.getX(), entityliving.getZ() - this.getZ(), null, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit
} }
private boolean checkTotemDeathProtection(DamageSource damagesource) { private boolean checkTotemDeathProtection(DamageSource damagesource) {
@@ -1375,20 +1619,33 @@ @@ -1405,19 +1715,32 @@
EnumHand[] aenumhand = EnumHand.values(); ItemStack itemstack = null;
int i = aenumhand.length; DeathProtection deathprotection = null;
+ // CraftBukkit start + // CraftBukkit start
+ EnumHand hand = null; + EnumHand hand = null;
+ ItemStack itemstack1 = ItemStack.EMPTY; + ItemStack itemstack1 = ItemStack.EMPTY;
for (int j = 0; j < i; ++j) { for (EnumHand enumhand : EnumHand.values()) {
EnumHand enumhand = aenumhand[j];
- ItemStack itemstack1 = this.getItemInHand(enumhand); - ItemStack itemstack1 = this.getItemInHand(enumhand);
+ itemstack1 = this.getItemInHand(enumhand); + itemstack1 = this.getItemInHand(enumhand);
@ -557,7 +670,7 @@
+ hand = enumhand; // CraftBukkit + hand = enumhand; // CraftBukkit
itemstack = itemstack1.copy(); itemstack = itemstack1.copy();
- itemstack1.shrink(1); - itemstack1.shrink(1);
+ // itemstack1.subtract(1); // CraftBukkit + // itemstack1.shrink(1); // CraftBukkit
break; break;
} }
} }
@ -578,7 +691,7 @@
EntityPlayer entityplayer = (EntityPlayer) this; EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem())); entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
@@ -1512,14 +1769,22 @@ @@ -1516,14 +1839,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@ -603,9 +716,9 @@
this.level().addFreshEntity(entityitem); this.level().addFreshEntity(entityitem);
} }
} }
@@ -1530,22 +1795,37 @@ @@ -1534,22 +1865,37 @@
protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) { protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) {
boolean flag = this.lastHurtByPlayerTime > 0; boolean flag = this.lastHurtByPlayerMemoryTime > 0;
+ this.dropEquipment(worldserver); // CraftBukkit - from below + this.dropEquipment(worldserver); // CraftBukkit - from below
if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
@ -626,9 +739,9 @@
- protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) { - protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) {
+ public int getExpReward(WorldServer worldserver, @Nullable Entity entity) { // CraftBukkit + public int getExpReward(WorldServer worldserver, @Nullable Entity entity) { // CraftBukkit
if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) { if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity)); - EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity));
+ return this.getExperienceReward(worldserver, entity); // CraftBukkit } + return this.getExperienceReward(worldserver, entity); // CraftBukkit
} }
+ return 0; // CraftBukkit + return 0; // CraftBukkit
@ -644,7 +757,7 @@
} }
protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {} protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {}
@@ -1612,9 +1892,14 @@ @@ -1617,9 +1963,14 @@
} }
public void knockback(double d0, double d1, double d2) { public void knockback(double d0, double d1, double d2) {
@ -661,7 +774,7 @@
Vec3D vec3d; Vec3D vec3d;
@@ -1624,7 +1909,14 @@ @@ -1629,7 +1980,14 @@
Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0); Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0);
@ -677,7 +790,7 @@
} }
} }
@@ -1683,6 +1975,20 @@ @@ -1684,6 +2042,20 @@
return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL); return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL);
} }
@ -698,8 +811,8 @@
public Optional<BlockPosition> getLastClimbablePos() { public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos; return this.lastClimbablePos;
} }
@@ -1757,9 +2063,14 @@ @@ -1755,9 +2127,14 @@
int i = this.calculateFallDamage(f, f1); int i = this.calculateFallDamage(d0, f);
if (i > 0) { if (i > 0) {
+ // CraftBukkit start + // CraftBukkit start
@ -714,7 +827,7 @@
return true; return true;
} else { } else {
return flag; return flag;
@@ -1830,7 +2141,7 @@ @@ -1826,7 +2203,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) { protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@ -723,17 +836,17 @@
f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS)); f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
} }
@@ -1841,7 +2152,8 @@ @@ -1837,7 +2214,8 @@
if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) { if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) {
return f; return f;
} else { } else {
- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { - if (this.hasEffect(MobEffects.RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) {
+ // CraftBukkit - Moved to handleEntityDamage(DamageSource, float) + // CraftBukkit - Moved to handleEntityDamage(DamageSource, float)
+ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + if (false && this.hasEffect(MobEffects.RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) {
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i; int j = 25 - i;
float f1 = f * (float) j; float f1 = f * (float) j;
@@ -1884,15 +2196,141 @@ @@ -1880,15 +2258,136 @@
} }
} }
@ -769,7 +882,7 @@
+ com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() { + com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() {
+ @Override + @Override
+ public Double apply(Double f) { + public Double apply(Double f) {
+ return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); + return -((double) EntityLiving.this.calculateItemBlocking(damagesource, f.floatValue()));
+ } + }
+ }; + };
+ float blockingModifier = blocking.apply((double) f).floatValue(); + float blockingModifier = blocking.apply((double) f).floatValue();
@ -787,8 +900,8 @@
+ com.google.common.base.Function<Double, Double> resistance = new com.google.common.base.Function<Double, Double>() { + com.google.common.base.Function<Double, Double> resistance = new com.google.common.base.Function<Double, Double>() {
+ @Override + @Override
+ public Double apply(Double f) { + public Double apply(Double f) {
+ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) {
+ int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; + int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
+ int j = 25 - i; + int j = 25 - i;
+ float f1 = f.floatValue() * (float) j; + float f1 = f.floatValue() * (float) j;
+ +
@ -861,12 +974,7 @@
+ +
+ // Apply blocking code // PAIL: steal from above + // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) { + if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); + actuallyDoItemBlocking(worldserver, damagesource, (float) -event.getDamage(DamageModifier.BLOCKING));
+ Entity entity = damagesource.getDirectEntity();
+
+ if (entity instanceof EntityLiving) {
+ this.blockUsingShield((EntityLiving) entity);
+ }
+ } + }
+ +
+ boolean human = this instanceof EntityHuman; + boolean human = this instanceof EntityHuman;
@ -882,7 +990,7 @@
if (f2 > 0.0F && f2 < 3.4028235E37F) { if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity(); Entity entity = damagesource.getEntity();
@@ -1904,13 +2342,48 @@ @@ -1900,13 +2399,48 @@
} }
} }
@ -933,7 +1041,7 @@
} }
public CombatTracker getCombatTracker() { public CombatTracker getCombatTracker() {
@@ -1935,9 +2408,19 @@ @@ -1931,9 +2465,19 @@
} }
public final void setArrowCount(int i) { public final void setArrowCount(int i) {
@ -954,20 +1062,34 @@
public final int getStingerCount() { public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID); return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
} }
@@ -2182,6 +2665,12 @@ @@ -2191,7 +2735,13 @@
}
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
- this.onEquipItem(enumitemslot, this.equipment.set(enumitemslot, itemstack), itemstack);
+ // CraftBukkit start + // CraftBukkit start
+ this.setItemSlot(enumitemslot, itemstack, false);
+ }
+
+ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) { + public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
+ this.setItemSlot(enumitemslot, itemstack); + this.onEquipItem(enumitemslot, this.equipment.set(enumitemslot, itemstack), itemstack, silent);
+ // CraftBukkit end
}
public float getArmorCoverPercentage() {
@@ -2455,6 +3005,11 @@
}
public void stopFallFlying() {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
+ return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ this.setSharedFlag(7, true);
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack); this.setSharedFlag(7, false);
}
public Iterable<ItemStack> getHandSlots() { @@ -2640,7 +3195,7 @@
@@ -2634,7 +3123,7 @@
} }
} }
@ -976,7 +1098,7 @@
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
this.getCombatTracker().recheckStatus(); this.getCombatTracker().recheckStatus();
} }
@@ -2741,7 +3230,7 @@ @@ -2728,7 +3283,7 @@
this.elytraAnimationState.tick(); this.elytraAnimationState.tick();
} }
@ -985,7 +1107,7 @@
Map<EnumItemSlot, ItemStack> map = this.collectEquipmentChanges(); Map<EnumItemSlot, ItemStack> map = this.collectEquipmentChanges();
if (map != null) { if (map != null) {
@@ -3063,6 +3552,7 @@ @@ -3005,6 +3560,7 @@
this.checkSlowFallDistance(); this.checkSlowFallDistance();
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
if (!this.canGlide()) { if (!this.canGlide()) {
@ -993,7 +1115,7 @@
this.setSharedFlag(7, false); this.setSharedFlag(7, false);
return; return;
} }
@@ -3305,14 +3795,21 @@ @@ -3192,14 +3748,21 @@
@Override @Override
public boolean isPickable() { public boolean isPickable() {
@ -1017,7 +1139,7 @@
@Override @Override
public float getYHeadRot() { public float getYHeadRot() {
return this.yHeadRot; return this.yHeadRot;
@@ -3483,7 +3980,30 @@ @@ -3404,7 +3967,30 @@
this.releaseUsingItem(); this.releaseUsingItem();
} else { } else {
if (!this.useItem.isEmpty() && this.isUsingItem()) { if (!this.useItem.isEmpty() && this.isUsingItem()) {
@ -1049,7 +1171,7 @@
if (itemstack != this.useItem) { if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack); this.setItemInHand(enumhand, itemstack);
@@ -3568,6 +4088,12 @@ @@ -3500,6 +4086,12 @@
} }
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) { public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@ -1062,7 +1184,7 @@
double d3 = this.getX(); double d3 = this.getX();
double d4 = this.getY(); double d4 = this.getY();
double d5 = this.getZ(); double d5 = this.getZ();
@@ -3592,16 +4118,41 @@ @@ -3524,16 +4116,41 @@
} }
if (flag2) { if (flag2) {
@ -1107,7 +1229,7 @@
} else { } else {
if (flag) { if (flag) {
world.broadcastEntityEvent(this, (byte) 46); world.broadcastEntityEvent(this, (byte) 46);
@@ -3613,7 +4164,7 @@ @@ -3545,7 +4162,7 @@
entitycreature.getNavigation().stop(); entitycreature.getNavigation().stop();
} }
@ -1116,7 +1238,7 @@
} }
} }
@@ -3706,7 +4257,7 @@ @@ -3638,7 +4255,7 @@
} }
public void stopSleeping() { public void stopSleeping() {
@ -1125,7 +1247,7 @@
World world = this.level(); World world = this.level();
java.util.Objects.requireNonNull(world); java.util.Objects.requireNonNull(world);
@@ -3740,7 +4291,7 @@ @@ -3672,7 +4289,7 @@
@Nullable @Nullable
public EnumDirection getBedOrientation() { public EnumDirection getBedOrientation() {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityTameableAnimal.java --- a/net/minecraft/world/entity/EntityTameableAnimal.java
+++ b/net/minecraft/world/entity/EntityTameableAnimal.java +++ b/net/minecraft/world/entity/EntityTameableAnimal.java
@@ -28,6 +28,12 @@ @@ -26,6 +26,12 @@
import net.minecraft.world.level.pathfinder.PathfinderNormal; import net.minecraft.world.level.pathfinder.PathfinderNormal;
import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeam;
@ -13,18 +13,18 @@
public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity { public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity {
public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144; public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144;
@@ -295,7 +301,14 @@ @@ -299,7 +305,14 @@
if (!this.canTeleportTo(new BlockPosition(i, j, k))) { if (!this.canTeleportTo(new BlockPosition(i, j, k))) {
return false; return false;
} else { } else {
- this.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.getYRot(), this.getXRot()); - this.snapTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.getYRot(), this.getXRot());
+ // CraftBukkit start + // CraftBukkit start
+ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) i + 0.5D, (double) j, (double) k + 0.5D); + EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this, (double) i + 0.5D, (double) j, (double) k + 0.5D);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return false; + return false;
+ } + }
+ Location to = event.getTo(); + Location to = event.getTo();
+ this.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + this.snapTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ // CraftBukkit end + // CraftBukkit end
this.navigation.stop(); this.navigation.stop();
return true; return true;

View File

@ -8,7 +8,7 @@
import org.slf4j.Logger; import org.slf4j.Logger;
public class EntityTypes<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> { public class EntityTypes<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> {
@@ -191,7 +192,7 @@ @@ -192,7 +193,7 @@
return Items.ACACIA_CHEST_BOAT; return Items.ACACIA_CHEST_BOAT;
}), EnumCreatureType.MISC).noLootTable().sized(1.375F, 0.5625F).eyeHeight(0.5625F).clientTrackingRange(10)); }), EnumCreatureType.MISC).noLootTable().sized(1.375F, 0.5625F).eyeHeight(0.5625F).clientTrackingRange(10));
public static final EntityTypes<Allay> ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).eyeHeight(0.36F).ridingOffset(0.04F).clientTrackingRange(8).updateInterval(2)); public static final EntityTypes<Allay> ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).eyeHeight(0.36F).ridingOffset(0.04F).clientTrackingRange(8).updateInterval(2));
@ -17,7 +17,7 @@
public static final EntityTypes<Armadillo> ARMADILLO = register("armadillo", EntityTypes.Builder.of(Armadillo::new, EnumCreatureType.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10)); public static final EntityTypes<Armadillo> ARMADILLO = register("armadillo", EntityTypes.Builder.of(Armadillo::new, EnumCreatureType.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10));
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).eyeHeight(1.7775F).clientTrackingRange(10)); public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).eyeHeight(1.7775F).clientTrackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).noLootTable().sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20)); public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).noLootTable().sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20));
@@ -399,7 +400,7 @@ @@ -401,7 +402,7 @@
return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s)); return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s));
} }
@ -26,50 +26,48 @@
return register(vanillaEntityId(s), entitytypes_builder); return register(vanillaEntityId(s), entitytypes_builder);
} }
@@ -431,7 +432,14 @@ @@ -433,6 +434,13 @@
@Nullable @Nullable
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) { public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityLiving entityliving, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) {
- Consumer consumer;
+ // CraftBukkit start + // CraftBukkit start
+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); + return this.spawn(worldserver, itemstack, entityliving, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ } + }
+ +
+ @Nullable + @Nullable
+ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityLiving entityliving, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end + // CraftBukkit end
+ Consumer<T> consumer; // CraftBukkit - decompile error Consumer<T> consumer;
if (itemstack != null) { if (itemstack != null) {
consumer = createDefaultStackConfig(worldserver, itemstack, entityhuman); @@ -442,7 +450,7 @@
@@ -440,7 +448,7 @@
}; };
} }
- return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); - return (T) this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1);
+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit + return (T) this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit
} }
public static <T extends Entity> Consumer<T> createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) { public static <T extends Entity> Consumer<T> createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityLiving entityliving) {
@@ -464,21 +472,40 @@ @@ -464,21 +472,40 @@
CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY);
return !customdata.isEmpty() ? consumer.andThen((entity) -> { return !customdata.isEmpty() ? consumer.andThen((entity) -> {
- updateCustomEntityTag(world, entityhuman, entity, customdata); - updateCustomEntityTag(world, entityliving, entity, customdata);
+ try { updateCustomEntityTag(world, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665 + try { updateCustomEntityTag(world, entityliving, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
}) : consumer; }) : consumer;
} }
@Nullable @Nullable
public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) { public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) {
- return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false); - return (T) this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false);
+ // CraftBukkit start + // CraftBukkit start
+ return this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + return (T) this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ } + }
+ +
+ @Nullable + @Nullable
+ public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ return this.spawn(worldserver, (Consumer<T>) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit - decompile error + return (T) this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit
+ // CraftBukkit end + // CraftBukkit end
} }
@ -95,7 +93,7 @@
if (t0 instanceof EntityInsentient) { if (t0 instanceof EntityInsentient) {
EntityInsentient entityinsentient = (EntityInsentient) t0; EntityInsentient entityinsentient = (EntityInsentient) t0;
@@ -657,7 +684,7 @@ @@ -668,7 +695,7 @@
} }
return entity; return entity;
@ -103,22 +101,13 @@
+ }).orElse(null); // CraftBukkit - decompile error + }).orElse(null); // CraftBukkit - decompile error
} }
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world, final EntitySpawnReason entityspawnreason) { public static Stream<Entity> loadEntitiesRecursive(List<? extends NBTBase> list, World world, EntitySpawnReason entityspawnreason) {
@@ -718,7 +745,7 @@ @@ -786,7 +813,7 @@
@Nullable
public T tryCast(Entity entity) {
- return entity.getType() == this ? entity : null;
+ return entity.getType() == this ? (T) entity : null; // CraftBukkit - decompile error
}
@Override
@@ -791,7 +818,7 @@
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC; this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
} }
- public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) { - public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) {
+ public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error + public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error
return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype); return new EntityTypes.Builder<T>(entitytypes_b, enumcreaturetype);
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/IEntityAngerable.java --- a/net/minecraft/world/entity/IEntityAngerable.java
+++ b/net/minecraft/world/entity/IEntityAngerable.java +++ b/net/minecraft/world/entity/IEntityAngerable.java
@@ -9,6 +9,10 @@ @@ -10,6 +10,10 @@
import net.minecraft.world.level.GameRules; import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
@ -11,24 +11,23 @@
public interface IEntityAngerable { public interface IEntityAngerable {
String TAG_ANGER_TIME = "AngerTime"; String TAG_ANGER_TIME = "AngerTime";
@@ -48,14 +52,14 @@ @@ -34,13 +38,13 @@
if (entity instanceof EntityInsentient) { default void readPersistentAngerSaveData(World world, NBTTagCompound nbttagcompound) {
EntityInsentient entityinsentient = (EntityInsentient) entity; this.setRemainingPersistentAngerTime(nbttagcompound.getIntOr("AngerTime", 0));
if (world instanceof WorldServer worldserver) {
- UUID uuid = (UUID) nbttagcompound.read("AngryAt", UUIDUtil.CODEC).orElse((Object) null);
+ UUID uuid = (UUID) nbttagcompound.read("AngryAt", UUIDUtil.CODEC).orElse(null); // CraftBukkit - decompile error
- this.setTarget(entityinsentient); this.setPersistentAngerTarget(uuid);
+ this.setTarget(entityinsentient, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit Entity entity = uuid != null ? worldserver.getEntity(uuid) : null;
this.setLastHurtByMob(entityinsentient);
if (entity instanceof EntityLiving entityliving) {
- this.setTarget(entityliving);
+ this.setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
} }
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
- this.setTarget(entityhuman);
+ this.setTarget(entityhuman, EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit
this.setLastHurtByPlayer(entityhuman);
} }
@@ -96,7 +100,7 @@
@@ -114,7 +118,7 @@
default void stopBeingAngry() { default void stopBeingAngry() {
this.setLastHurtByMob((EntityLiving) null); this.setLastHurtByMob((EntityLiving) null);
this.setPersistentAngerTarget((UUID) null); this.setPersistentAngerTarget((UUID) null);
@ -37,7 +36,7 @@
this.setRemainingPersistentAngerTime(0); this.setRemainingPersistentAngerTime(0);
} }
@@ -127,6 +131,8 @@ @@ -107,6 +111,8 @@
void setTarget(@Nullable EntityLiving entityliving); void setTarget(@Nullable EntityLiving entityliving);

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/IEntitySelector.java --- a/net/minecraft/world/entity/IEntitySelector.java
+++ b/net/minecraft/world/entity/IEntitySelector.java +++ b/net/minecraft/world/entity/IEntitySelector.java
@@ -43,7 +43,7 @@ @@ -52,7 +52,7 @@
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteam == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteam.getCollisionRule(); ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule();
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> { return (Predicate<Entity>) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> {
- if (!entity1.isPushable()) { - if (!entity1.isPushable()) {
+ if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API + if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API
return false; return false;
} else if (entity.level().isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) { } else {
return false; if (entity.level().isClientSide) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/Interaction.java --- a/net/minecraft/world/entity/Interaction.java
+++ b/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java
@@ -27,6 +27,12 @@ @@ -21,6 +21,12 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.damagesource.DamageSource;
@ -12,17 +12,19 @@
+ +
public class Interaction extends Entity implements Attackable, Targeting { public class Interaction extends Entity implements Attackable, Targeting {
private static final Logger LOGGER = LogUtils.getLogger(); private static final DataWatcherObject<Float> DATA_WIDTH_ID = DataWatcher.<Float>defineId(Interaction.class, DataWatcherRegistry.FLOAT);
@@ -65,7 +71,7 @@ @@ -55,8 +61,8 @@
this.setHeight(nbttagcompound.getFloat("height")); protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
this.setWidth(nbttagcompound.getFloatOr("width", 1.0F));
this.setHeight(nbttagcompound.getFloatOr("height", 1.0F));
- this.attack = (Interaction.PlayerAction) nbttagcompound.read("attack", Interaction.PlayerAction.CODEC).orElse((Object) null);
- this.interaction = (Interaction.PlayerAction) nbttagcompound.read("interaction", Interaction.PlayerAction.CODEC).orElse((Object) null);
+ this.attack = (Interaction.PlayerAction) nbttagcompound.read("attack", Interaction.PlayerAction.CODEC).orElse(null); // CraftBukkit - decompile error
+ this.interaction = (Interaction.PlayerAction) nbttagcompound.read("interaction", Interaction.PlayerAction.CODEC).orElse(null); // CraftBukkit - decompile error
this.setResponse(nbttagcompound.getBooleanOr("response", false));
this.setBoundingBox(this.makeBoundingBox());
} }
@@ -102,9 +108,16 @@
- DataResult dataresult;
+ DataResult<com.mojang.datafixers.util.Pair<Interaction.PlayerAction, net.minecraft.nbt.NBTBase>> dataresult; // CraftBukkit - decompile error
Logger logger;
if (nbttagcompound.contains("attack")) {
@@ -145,9 +151,16 @@
@Override @Override
public boolean skipAttackInteraction(Entity entity) { public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof EntityHuman entityhuman) { if (entity instanceof EntityHuman entityhuman) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Leashable.java --- a/net/minecraft/world/entity/Leashable.java
+++ b/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java
@@ -16,6 +16,11 @@ @@ -17,6 +17,11 @@
import net.minecraft.world.level.IMaterial; import net.minecraft.world.level.IMaterial;
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
@ -12,7 +12,7 @@
public interface Leashable { public interface Leashable {
String LEASH_TAG = "leash"; String LEASH_TAG = "leash";
@@ -45,7 +50,7 @@ @@ -46,11 +51,11 @@
default void setDelayedLeashHolderId(int i) { default void setDelayedLeashHolderId(int i) {
this.setLeashData(new Leashable.a(i)); this.setLeashData(new Leashable.a(i));
@ -21,28 +21,27 @@
} }
default void readLeashData(NBTTagCompound nbttagcompound) { default void readLeashData(NBTTagCompound nbttagcompound) {
@@ -64,7 +69,7 @@ - Leashable.a leashable_a = (Leashable.a) nbttagcompound.read("leash", Leashable.a.CODEC).orElse((Object) null);
return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID"))); + Leashable.a leashable_a = (Leashable.a) nbttagcompound.read("leash", Leashable.a.CODEC).orElse(null); // CraftBukkit - decompile error
} else {
if (nbttagcompound.contains("leash", 11)) {
- Either<UUID, BlockPosition> either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse((Object) null);
+ Either<UUID, BlockPosition> either = (Either) GameProfileSerializer.readBlockPos(nbttagcompound, "leash").map(Either::right).orElse(null); // CraftBukkit - decompile error
if (either != null) { if (this.getLeashData() != null && leashable_a == null) {
return new Leashable.a(either); this.removeLeash();
@@ -79,6 +84,11 @@ @@ -60,6 +65,14 @@
if (leashable_a != null) { }
Either<UUID, BlockPosition> either = leashable_a.delayedLeashInfo;
Entity entity = leashable_a.leashHolder; default void writeLeashData(NBTTagCompound nbttagcompound, @Nullable Leashable.a leashable_a) {
+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin + // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
+ if (leashable_a != null) {
+ Entity entity = leashable_a.leashHolder;
+ if (entity != null && entity.pluginRemoved) { + if (entity != null && entity.pluginRemoved) {
+ return; + return;
+ } + }
+ }
+ // CraftBukkit end + // CraftBukkit end
nbttagcompound.storeNullable("leash", Leashable.a.CODEC, leashable_a);
}
if (entity instanceof EntityLeash) { @@ -85,7 +98,9 @@
EntityLeash entityleash = (EntityLeash) entity;
@@ -121,7 +131,9 @@
} }
if (e0.tickCount > 100) { if (e0.tickCount > 100) {
@ -52,7 +51,7 @@
((Leashable) e0).setLeashData((Leashable.a) null); ((Leashable) e0).setLeashData((Leashable.a) null);
} }
} }
@@ -130,11 +142,11 @@ @@ -94,11 +109,11 @@
} }
default void dropLeash() { default void dropLeash() {
@ -66,7 +65,7 @@
} }
default void onLeashRemoved() {} default void onLeashRemoved() {}
@@ -151,7 +163,9 @@ @@ -115,7 +130,9 @@
WorldServer worldserver = (WorldServer) world; WorldServer worldserver = (WorldServer) world;
if (flag1) { if (flag1) {
@ -76,7 +75,7 @@
} }
if (flag) { if (flag) {
@@ -171,7 +185,8 @@ @@ -135,7 +152,8 @@
if (leashable_a != null && leashable_a.leashHolder != null) { if (leashable_a != null && leashable_a.leashHolder != null) {
if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) { if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) {
@ -86,7 +85,7 @@
((Leashable) e0).dropLeash(); ((Leashable) e0).dropLeash();
} else { } else {
((Leashable) e0).removeLeash(); ((Leashable) e0).removeLeash();
@@ -205,13 +220,18 @@ @@ -169,13 +187,18 @@
} }
default void leashTooFarBehaviour() { default void leashTooFarBehaviour() {
@ -106,7 +105,7 @@
} }
private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) { private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) {
@@ -223,7 +243,7 @@ @@ -187,7 +210,7 @@
} }
default void setLeashedTo(Entity entity, boolean flag) { default void setLeashedTo(Entity entity, boolean flag) {
@ -115,7 +114,7 @@
} }
private static <E extends Entity & Leashable> void setLeashedTo(E e0, Entity entity, boolean flag) { private static <E extends Entity & Leashable> void setLeashedTo(E e0, Entity entity, boolean flag) {
@@ -254,7 +274,7 @@ @@ -218,7 +241,7 @@
@Nullable @Nullable
default Entity getLeashHolder() { default Entity getLeashHolder() {

View File

@ -1,9 +1,10 @@
--- a/net/minecraft/world/entity/SaddleStorage.java --- a/net/minecraft/world/entity/SaddleStorage.java
+++ b/net/minecraft/world/entity/SaddleStorage.java +++ b/net/minecraft/world/entity/SaddleStorage.java
@@ -53,6 +53,14 @@ @@ -49,4 +49,12 @@
public int boostTimeTotal() {
return (Integer) this.entityData.get(this.boostTimeAccessor); return (Integer) this.entityData.get(this.boostTimeAccessor);
} }
+
+ // CraftBukkit add setBoostTicks(int) + // CraftBukkit add setBoostTicks(int)
+ public void setBoostTicks(int ticks) { + public void setBoostTicks(int ticks) {
+ this.boosting = true; + this.boosting = true;
@ -11,7 +12,4 @@
+ this.entityData.set(this.boostTimeAccessor, ticks); + this.entityData.set(this.boostTimeAccessor, ticks);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
nbttagcompound.putBoolean("Saddle", this.hasSaddle());
} }

View File

@ -14,17 +14,17 @@
public BehaviorCareer() {} public BehaviorCareer() {}
@@ -37,7 +43,14 @@ @@ -37,7 +43,14 @@
return villagerprofession.heldJobSite().test(holder); return ((VillagerProfession) holder_c.value()).heldJobSite().test(holder);
}).findFirst(); }).findFirst();
}).ifPresent((villagerprofession) -> { }).ifPresent((holder_c) -> {
- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession)); - entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(holder_c));
+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed + // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftToBukkit(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftHolderToBukkit(holder_c), VillagerCareerChangeEvent.ChangeReason.EMPLOYED);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ +
+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession())));
+ // CraftBukkit end + // CraftBukkit end
entityvillager.refreshBrain(worldserver); entityvillager.refreshBrain(worldserver);
}); });

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java --- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -27,6 +27,11 @@ @@ -26,6 +26,11 @@
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.gameevent.GameEvent;
@ -12,18 +12,7 @@
public class BehaviorFarm extends Behavior<EntityVillager> { public class BehaviorFarm extends Behavior<EntityVillager> {
private static final int HARVEST_DURATION = 200; private static final int HARVEST_DURATION = 200;
@@ -82,8 +87,8 @@ @@ -102,7 +107,9 @@
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
- entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos)));
- entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1)));
+ entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error
+ entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error
}
}
@@ -103,7 +108,9 @@
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock(); Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) { if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
@ -33,26 +22,15 @@
} }
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) { if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
@@ -120,9 +127,11 @@ @@ -119,9 +126,11 @@
ItemBlock itemblock = (ItemBlock) item; ItemBlock itemblock = (ItemBlock) item;
IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState(); IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState();
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1)) { // CraftBukkit + if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1)) { // CraftBukkit
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1); worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
worldserver.gameEvent((Holder) GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1)); worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true; flag = true;
+ } // CraftBukkit + } // CraftBukkit
} }
} }
@@ -142,8 +151,8 @@
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
if (this.aboveFarmlandPos != null) {
this.nextOkStartTime = i + 20L;
- entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1)));
- entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.aboveFarmlandPos)));
+ entityvillager.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.aboveFarmlandPos), 0.5F, 1))); // CraftBukkit - decompile error
+ entityvillager.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.aboveFarmlandPos))); // CraftBukkit - decompile error
}
}
}

View File

@ -19,7 +19,7 @@
- entityvillager.setAge(6000); - entityvillager.setAge(6000);
- entityvillager1.setAge(6000); - entityvillager1.setAge(6000);
entityvillager2.setAge(-24000); entityvillager2.setAge(-24000);
entityvillager2.moveTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F); entityvillager2.snapTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F);
- worldserver.addFreshEntityWithPassengers(entityvillager2); - worldserver.addFreshEntityWithPassengers(entityvillager2);
+ // CraftBukkit start - call EntityBreedEvent + // CraftBukkit start - call EntityBreedEvent
+ if (CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) { + if (CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
@ -33,11 +33,3 @@
worldserver.broadcastEntityEvent(entityvillager2, (byte) 12); worldserver.broadcastEntityEvent(entityvillager2, (byte) 12);
return Optional.of(entityvillager2); return Optional.of(entityvillager2);
} }
@@ -127,6 +138,6 @@
private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition);
- entityvillager.getBrain().setMemory(MemoryModuleType.HOME, (Object) globalpos);
+ entityvillager.getBrain().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error
}
}

View File

@ -13,18 +13,18 @@
public class BehaviorProfession { public class BehaviorProfession {
public BehaviorProfession() {} public BehaviorProfession() {}
@@ -17,7 +23,14 @@ @@ -18,7 +24,14 @@
VillagerData villagerdata = entityvillager.getVillagerData(); boolean flag = !villagerdata.profession().is(VillagerProfession.NONE) && !villagerdata.profession().is(VillagerProfession.NITWIT);
if (villagerdata.getProfession() != VillagerProfession.NONE && villagerdata.getProfession() != VillagerProfession.NITWIT && entityvillager.getVillagerXp() == 0 && villagerdata.getLevel() <= 1) { if (flag && entityvillager.getVillagerXp() == 0 && villagerdata.level() <= 1) {
- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(VillagerProfession.NONE)); - entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(worldserver.registryAccess(), VillagerProfession.NONE));
+ // CraftBukkit start + // CraftBukkit start
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftToBukkit(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); + VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.CraftProfession.minecraftHolderToBukkit(worldserver.registryAccess().getOrThrow(VillagerProfession.NONE)), VillagerCareerChangeEvent.ChangeReason.LOSING_JOB);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return false; + return false;
+ } + }
+ +
+ entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); + entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession())));
+ // CraftBukkit end + // CraftBukkit end
entityvillager.refreshBrain(worldserver); entityvillager.refreshBrain(worldserver);
return true; return true;

View File

@ -1,25 +1,5 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java --- a/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java +++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtil.java
@@ -60,7 +60,7 @@
}
public static void lookAtEntity(EntityLiving entityliving, EntityLiving entityliving1) {
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1, true)));
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1, true))); // CraftBukkit - decompile error
}
private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f, int i) {
@@ -79,8 +79,8 @@
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BehaviorPosition behaviorposition, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(behaviorposition, f, i);
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorposition);
- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, behaviorposition); // CraftBukkit - decompile error
+ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
}
public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) {
@@ -90,6 +90,7 @@ @@ -90,6 +90,7 @@
} }

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java --- a/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java
+++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java +++ b/net/minecraft/world/entity/ai/behavior/PrepareRamNearestTarget.java
@@ -31,6 +31,13 @@ @@ -29,6 +29,13 @@
import net.minecraft.world.level.pathfinder.PathfinderNormal; import net.minecraft.world.level.pathfinder.PathfinderNormal;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -14,7 +14,7 @@
public class PrepareRamNearestTarget<E extends EntityCreature> extends Behavior<E> { public class PrepareRamNearestTarget<E extends EntityCreature> extends Behavior<E> {
public static final int TIME_OUT_DURATION = 160; public static final int TIME_OUT_DURATION = 160;
@@ -63,6 +70,13 @@ @@ -61,6 +68,13 @@
return this.ramTargeting.test(worldserver, entitycreature, entityliving); return this.ramTargeting.test(worldserver, entitycreature, entityliving);
}); });
}).ifPresent((entityliving) -> { }).ifPresent((entityliving) -> {
@ -28,36 +28,7 @@
this.chooseRamPosition(entitycreature, entityliving); this.chooseRamPosition(entitycreature, entityliving);
}); });
} }
@@ -72,7 +86,7 @@ @@ -148,7 +162,7 @@
if (!behaviorcontroller.hasMemoryValue(MemoryModuleType.RAM_TARGET)) {
worldserver.broadcastEntityEvent(e0, (byte) 59);
- behaviorcontroller.setMemory(MemoryModuleType.RAM_COOLDOWN_TICKS, (Object) this.getCooldownOnFail.applyAsInt(e0));
+ behaviorcontroller.setMemory(MemoryModuleType.RAM_COOLDOWN_TICKS, this.getCooldownOnFail.applyAsInt(e0)); // CraftBukkit - decompile error
}
}
@@ -83,8 +97,8 @@
protected void tick(WorldServer worldserver, E e0, long i) {
if (!this.ramCandidate.isEmpty()) {
- e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0)));
- e0.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget(), true)));
+ e0.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getStartPosition(), this.walkSpeed, 0))); // CraftBukkit - decompile error
+ e0.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget(), true))); // CraftBukkit - decompile error
boolean flag = !((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTarget().blockPosition().equals(((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition());
if (flag) {
@@ -101,7 +115,7 @@
}
if (i - (Long) this.reachedRamPositionTimestamp.get() >= (long) this.ramPrepareTime) {
- e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, (Object) this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition()));
+ e0.getBrain().setMemory(MemoryModuleType.RAM_TARGET, this.getEdgeOfBlock(blockposition, ((PrepareRamNearestTarget.a) this.ramCandidate.get()).getTargetPosition())); // CraftBukkit - decompile error
worldserver.playSound((EntityHuman) null, (Entity) e0, (SoundEffect) this.getPrepareRamSound.apply(e0), SoundCategory.NEUTRAL, 1.0F, e0.getVoicePitch());
this.ramCandidate = Optional.empty();
}
@@ -153,7 +167,7 @@
} }
NavigationAbstract navigationabstract = entitycreature.getNavigation(); NavigationAbstract navigationabstract = entitycreature.getNavigation();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java --- a/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
+++ b/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java +++ b/net/minecraft/world/entity/ai/behavior/TryLaySpawnOnWaterNearLand.java
@@ -39,6 +39,12 @@ @@ -33,6 +33,12 @@
if (worldserver.getBlockState(blockposition2).isAir()) { if (worldserver.getBlockState(blockposition2).isAir()) {
IBlockData iblockdata = block.defaultBlockState(); IBlockData iblockdata = block.defaultBlockState();
@ -11,5 +11,5 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
worldserver.setBlock(blockposition2, iblockdata, 3); worldserver.setBlock(blockposition2, iblockdata, 3);
worldserver.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition2, GameEvent.a.of(entityliving, iblockdata)); worldserver.gameEvent(GameEvent.BLOCK_PLACE, blockposition2, GameEvent.a.of(entityliving, iblockdata));
worldserver.playSound((EntityHuman) null, (Entity) entityliving, SoundEffects.FROG_LAY_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F); worldserver.playSound((Entity) null, (Entity) entityliving, SoundEffects.FROG_LAY_SPAWN, SoundCategory.BLOCKS, 1.0F, 1.0F);

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java --- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java +++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
@@ -11,6 +11,10 @@ @@ -11,6 +11,10 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
+// CraftBukkit start +// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,16 +11,16 @@
public class PathfinderGoalEatTile extends PathfinderGoal { public class PathfinderGoalEatTile extends PathfinderGoal {
private static final int EAT_ANIMATION_TICKS = 40; private static final int EAT_ANIMATION_TICKS = 40;
@@ -64,7 +68,7 @@ @@ -66,7 +70,7 @@
BlockPosition blockposition = this.mob.blockPosition(); BlockPosition blockposition = this.mob.blockPosition();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) { if (PathfinderGoalEatTile.IS_EDIBLE.test(this.level.getBlockState(blockposition))) {
- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit + if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
this.level.destroyBlock(blockposition, false); this.level.destroyBlock(blockposition, false);
} }
@@ -73,7 +77,7 @@ @@ -75,7 +79,7 @@
BlockPosition blockposition1 = blockposition.below(); BlockPosition blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) { if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {

View File

@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
@@ -22,7 +22,7 @@
@Override
public boolean canUse() {
if (!this.mob.isTame()) {
- return false;
+ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals
} else if (this.mob.isInWaterOrBubble()) {
return false;
} else if (!this.mob.onGround()) {

View File

@ -1,6 +1,15 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
@@ -61,7 +61,7 @@ @@ -30,7 +30,7 @@
public boolean canUse() {
AxisAlignedBB axisalignedbb = this.golem.getBoundingBox().inflate(10.0D, 8.0D, 10.0D);
WorldServer worldserver = getServerLevel((Entity) this.golem);
- List<? extends EntityLiving> list = worldserver.<EntityLiving>getNearbyEntities(EntityVillager.class, this.attackTargeting, this.golem, axisalignedbb);
+ List<? extends EntityLiving> list = worldserver.getNearbyEntities(EntityVillager.class, this.attackTargeting, this.golem, axisalignedbb); // CraftBukkit - decompile error
List<EntityHuman> list1 = worldserver.getNearbyPlayers(this.attackTargeting, this.golem, axisalignedbb);
for (EntityLiving entityliving : list) {
@@ -64,7 +64,7 @@
@Override @Override
public void start() { public void start() {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java --- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java +++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalHurtByTarget.java
@@ -67,7 +67,7 @@ @@ -60,7 +60,7 @@
@Override @Override
public void start() { public void start() {
@ -9,7 +9,7 @@
this.targetMob = this.mob.getTarget(); this.targetMob = this.mob.getTarget();
this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.timestamp = this.mob.getLastHurtByMobTimestamp();
this.unseenMemoryTicks = 300; this.unseenMemoryTicks = 300;
@@ -114,6 +114,6 @@ @@ -99,6 +99,6 @@
} }
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) { protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {

Some files were not shown because too many files have changed in this diff Show More