Update to Minecraft 1.19

This commit is contained in:
md_5 2022-06-08 02:00:00 +10:00
parent 10ba1beb64
commit 64c15270e7
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
332 changed files with 3628 additions and 2559 deletions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java
@@ -41,6 +41,7 @@
@@ -40,6 +40,7 @@
private final String[][] requirements;
private final Set<Advancement> children = Sets.newLinkedHashSet();
private final IChatBaseComponent chatComponent;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -107,6 +107,14 @@
@@ -106,6 +106,14 @@
import net.minecraft.util.profiling.jfr.JvmProfiler;
import org.slf4j.Logger;
@ -15,21 +15,18 @@
public class CommandDispatcher {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -118,6 +126,7 @@
@@ -117,6 +125,7 @@
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) {
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype, CommandBuildContext commandbuildcontext) {
+ this(); // CraftBukkit
CommandAdvancement.register(this.dispatcher);
CommandAttribute.register(this.dispatcher);
CommandExecute.register(this.dispatcher);
@@ -204,17 +213,63 @@
CommandExecute.register(this.dispatcher, commandbuildcontext);
@@ -201,16 +210,68 @@
CommandPublish.register(this.dispatcher);
}
this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection});
+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection}); // CraftBukkit
});
+ // CraftBukkit start
+ }
+
@ -73,32 +70,39 @@
+ }
+
+ String newCommand = joiner.join(args);
+ return this.performCommand(sender, newCommand, newCommand, false);
+ return this.performCommand(sender, newCommand, newCommand);
+ }
+
public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.performCommand(commandlistenerwrapper, s, s, true);
+ }
+
+ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
StringReader stringreader = new StringReader(s);
- if (stringreader.canRead() && stringreader.peek() == '/') {
+ if (stripSlash && stringreader.canRead() && stringreader.peek() == '/') {
+ // CraftBukkit end
stringreader.skip();
+
public int performPrefixedCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
- return this.performCommand(commandlistenerwrapper, s.startsWith("/") ? s.substring(1) : s);
+ // CraftBukkit start
+ return this.performPrefixedCommand(commandlistenerwrapper, s, s);
+ }
+
+ public int performPrefixedCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label) {
+ return this.performCommand(commandlistenerwrapper, s.startsWith("/") ? s.substring(1) : s, label);
+ // CraftBukkit end
}
@@ -238,7 +293,7 @@
public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.performCommand(commandlistenerwrapper, s, s);
+ }
+
+ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label) { // CraftBukkit
StringReader stringreader = new StringReader(s);
commandlistenerwrapper.getServer().getProfiler().push(() -> {
@@ -235,7 +296,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, "/" + s));
+ return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
});
if (j > 10) {
@@ -288,11 +343,36 @@
@@ -285,11 +346,36 @@
}
public void sendCommands(EntityPlayer entityplayer) {
@ -136,7 +140,7 @@
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
}
@@ -303,7 +383,7 @@
@@ -300,7 +386,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@ -145,7 +149,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -326,7 +406,7 @@
@@ -323,7 +409,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandListenerWrapper.java
+++ b/net/minecraft/commands/CommandListenerWrapper.java
@@ -37,6 +37,8 @@
@@ -35,6 +35,8 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@ -8,16 +8,16 @@
+
public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
@@ -55,6 +57,7 @@
private final ResultConsumer<CommandListenerWrapper> consumer;
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(IChatBaseComponent.translatable("permissions.requires.player"));
@@ -54,6 +56,7 @@
private final ArgumentAnchor.Anchor anchor;
private final Vec2F rotation;
private final CommandSigningContext signingContext;
+ public volatile CommandNode currentCommand; // CraftBukkit
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, (commandcontext, flag, j) -> {
@@ -155,9 +158,23 @@
@@ -163,9 +166,23 @@
@Override
public boolean hasPermission(int i) {
@ -41,16 +41,16 @@
public Vec3D getPosition() {
return this.worldPosition;
}
@@ -219,7 +236,7 @@
@@ -255,7 +272,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) {
+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID);
entityplayer.sendSystemMessage(ichatmutablecomponent);
}
}
@@ -287,4 +304,10 @@
@@ -323,4 +340,10 @@
public IRegistryCustom registryAccess() {
return this.server.registryAccess();
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/ICommandListener.java
+++ b/net/minecraft/commands/ICommandListener.java
@@ -23,6 +23,13 @@
@@ -22,6 +22,13 @@
public boolean shouldInformAdmins() {
return false;
}
@ -13,8 +13,8 @@
+ // CraftBukkit end
};
void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid);
@@ -36,4 +43,6 @@
void sendSystemMessage(IChatBaseComponent ichatbasecomponent);
@@ -35,4 +42,6 @@
default boolean alwaysAccepts() {
return false;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/arguments/ArgumentEntity.java
+++ b/net/minecraft/commands/arguments/ArgumentEntity.java
@@ -95,9 +95,15 @@
@@ -94,9 +94,15 @@
}
public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
+++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
@@ -61,7 +61,7 @@
};
@@ -68,7 +68,7 @@
private final StringReader reader;
private final boolean forTesting;
private final boolean allowNbt;
- private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newHashMap();
+ private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable
private final Map<String, String> vagueProperties = Maps.newHashMap();
private MinecraftKey id = new MinecraftKey("");
private BlockStateList<Block, IBlockData> definition;
@@ -230,7 +230,7 @@
@Nullable
@@ -284,7 +284,7 @@
Iterator iterator = iblockstate.getPossibleValues().iterator();
while (iterator.hasNext()) {
@ -17,8 +17,8 @@
+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error
if (t0 instanceof Integer) {
suggestionsbuilder.suggest((Integer) t0);
@@ -493,7 +493,7 @@
Integer integer = (Integer) t0;
@@ -556,7 +556,7 @@
Optional<T> optional = iblockstate.getValue(s);
if (optional.isPresent()) {
@ -27,7 +27,7 @@
this.properties.put(iblockstate, (Comparable) optional.get());
} else {
this.reader.setCursor(i);
@@ -527,7 +527,7 @@
@@ -592,7 +592,7 @@
private static <T extends Comparable<T>> void appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.getName());
stringbuilder.append('=');
@ -35,4 +35,4 @@
+ stringbuilder.append(iblockstate.getName((T) comparable)); // CraftBukkit - decompile error
}
public CompletableFuture<Suggestions> fillSuggestions(SuggestionsBuilder suggestionsbuilder, IRegistry<Block> iregistry) {
public static record a(IBlockData blockState, Map<IBlockState<?>, Comparable<?>> properties, @Nullable NBTTagCompound nbt) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
@@ -9,6 +9,11 @@
@@ -11,6 +11,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.BlockDispenser;
@ -11,12 +11,12 @@
+
public class DispenseBehaviorBoat extends DispenseBehaviorItem {
private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
@@ -38,12 +43,40 @@
private final DispenseBehaviorItem defaultDispenseItemBehavior;
@@ -47,12 +52,40 @@
d3 = 0.0D;
}
- EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2);
- Object object = this.isChestBoat ? new ChestBoat(worldserver, d0, d1 + d3, d2) : new EntityBoat(worldserver, d0, d1 + d3, d2);
+ // EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2);
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
@ -44,14 +44,14 @@
+ }
+ }
+
+ EntityBoat entityboat = new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ Object object = this.isChestBoat ? new ChestBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()) : new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ // CraftBukkit end
entityboat.setType(this.type);
entityboat.setYRot(enumdirection.toYRot());
- worldserver.addFreshEntity(entityboat);
((EntityBoat) object).setType(this.type);
((EntityBoat) object).setYRot(enumdirection.toYRot());
- worldserver.addFreshEntity((Entity) object);
- itemstack.shrink(1);
+ if (!worldserver.addFreshEntity(entityboat)) itemstack.grow(1); // CraftBukkit
+ if (!worldserver.addFreshEntity((Entity) object)) itemstack.grow(1); // CraftBukkit
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
return itemstack;
}

View File

@ -48,7 +48,7 @@
@@ -45,7 +67,39 @@
double d3 = world.random.nextDouble() * 0.1D + 0.2D;
entityitem.setDeltaMovement(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepZ() * d3);
entityitem.setDeltaMovement(world.random.triangle((double) enumdirection.getStepX() * d3, 0.0172275D * (double) i), world.random.triangle(0.2D, 0.0172275D * (double) i), world.random.triangle((double) enumdirection.getStepZ() * d3, 0.0172275D * (double) i));
+
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -75,6 +75,21 @@
@@ -76,6 +76,21 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import org.slf4j.Logger;
@ -22,7 +22,7 @@
public interface IDispenseBehavior {
Logger LOGGER = LogUtils.getLogger();
@@ -199,14 +214,42 @@
@@ -200,14 +215,42 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag());
@ -64,10 +64,10 @@
- itemstack.shrink(1);
+ // itemstack.shrink(1); // Handled during event processing
+ // CraftBukkit end
isourceblock.getLevel().gameEvent(GameEvent.ENTITY_PLACE, isourceblock.getPos());
isourceblock.getLevel().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, isourceblock.getPos());
return itemstack;
}
@@ -225,12 +268,40 @@
@@ -226,12 +269,40 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
WorldServer worldserver = isourceblock.getLevel();
@ -109,7 +109,7 @@
return itemstack;
}
});
@@ -249,8 +320,35 @@
@@ -250,8 +321,35 @@
});
if (!list.isEmpty()) {
@ -146,7 +146,7 @@
this.setSuccess(true);
return itemstack;
} else {
@@ -277,7 +375,35 @@
@@ -278,7 +376,35 @@
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
} while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed());
@ -183,7 +183,7 @@
this.setSuccess(true);
return itemstack;
}
@@ -320,9 +446,35 @@
@@ -321,9 +447,35 @@
}
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
@ -221,7 +221,7 @@
this.setSuccess(true);
return itemstack;
}
@@ -331,12 +483,41 @@
@@ -332,12 +484,41 @@
@Override
public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
@ -264,10 +264,10 @@
return itemstack;
}
@@ -358,12 +539,40 @@
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX();
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ();
@@ -359,12 +540,40 @@
double d3 = randomsource.triangle((double) enumdirection.getStepX(), 0.11485000000000001D);
double d4 = randomsource.triangle((double) enumdirection.getStepY(), 0.11485000000000001D);
double d5 = randomsource.triangle((double) enumdirection.getStepZ(), 0.11485000000000001D);
- EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5);
- worldserver.addFreshEntity((Entity) SystemUtils.make(entitysmallfireball, (entitysmallfireball1) -> {
@ -310,7 +310,7 @@
return itemstack;
}
@@ -387,9 +596,52 @@
@@ -396,9 +605,52 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
WorldServer worldserver = isourceblock.getLevel();
@ -364,7 +364,7 @@
} else {
return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack);
}
@@ -415,7 +667,7 @@
@@ -425,7 +677,7 @@
Block block = iblockdata.getBlock();
if (block instanceof IFluidSource) {
@ -373,7 +373,7 @@
if (itemstack1.isEmpty()) {
return super.execute(isourceblock, itemstack);
@@ -423,6 +675,32 @@
@@ -433,6 +685,32 @@
worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
Item item = itemstack1.getItem();
@ -406,7 +406,7 @@
itemstack.shrink(1);
if (itemstack.isEmpty()) {
return new ItemStack(item);
@@ -444,14 +722,42 @@
@@ -454,14 +732,42 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
@ -451,7 +451,7 @@
} else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
if (iblockdata.getBlock() instanceof BlockTNT) {
BlockTNT.explode(worldserver, blockposition);
@@ -477,12 +783,62 @@
@@ -487,12 +793,62 @@
this.setSuccess(true);
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@ -514,7 +514,7 @@
return itemstack;
}
@@ -492,12 +848,41 @@
@@ -502,12 +858,41 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@ -558,7 +558,7 @@
return itemstack;
}
});
@@ -521,6 +906,30 @@
@@ -531,6 +916,30 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
@ -589,7 +589,7 @@
if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) {
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, enumdirection.getAxis() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.getOpposite().get2DDataValue() * 4), 3);
worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
@@ -546,6 +955,30 @@
@@ -556,6 +965,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
@ -620,7 +620,7 @@
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
if (!worldserver.isClientSide) {
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
@@ -595,6 +1028,30 @@
@@ -605,6 +1038,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getBlockState(blockposition);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/network/PacketDataSerializer.java
+++ b/net/minecraft/network/PacketDataSerializer.java
@@ -54,6 +54,8 @@
@@ -68,6 +68,8 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
@ -9,34 +9,25 @@
public class PacketDataSerializer extends ByteBuf {
private static final int MAX_VARINT_SIZE = 5;
@@ -122,7 +124,7 @@
@@ -158,7 +160,7 @@
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) {
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, PacketDataSerializer.a<T> packetdataserializer_a) {
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(function.apply(this));
@@ -133,7 +135,7 @@
c0.add(packetdataserializer_a.apply(this));
@@ -169,7 +171,7 @@
public <T> void writeCollection(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) {
public <T> void writeCollection(Collection<T> collection, PacketDataSerializer.b<T> packetdataserializer_b) {
this.writeVarInt(collection.size());
- Iterator iterator = collection.iterator();
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -144,7 +146,7 @@
}
public <T> List<T> readList(Function<PacketDataSerializer, T> function) {
- return (List) this.readCollection(Lists::newArrayListWithCapacity, function);
+ return (List) this.readCollection((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error
}
public IntList readIntIdList() {
@@ -160,12 +162,12 @@
@@ -196,12 +198,12 @@
public void writeIntIdList(IntList intlist) {
this.writeVarInt(intlist.size());
@ -44,14 +35,14 @@
+ intlist.forEach((java.util.function.IntConsumer) this::writeVarInt); // CraftBukkit - decompile error
}
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> function1) {
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, PacketDataSerializer.a<K> packetdataserializer_a, PacketDataSerializer.a<V> packetdataserializer_a1) {
int i = this.readVarInt();
- M m0 = (Map) intfunction.apply(i);
+ M m0 = intfunction.apply(i); // CraftBukkit - decompile error
for (int j = 0; j < i; ++j) {
K k0 = function.apply(this);
@@ -354,7 +356,7 @@
K k0 = packetdataserializer_a.apply(this);
@@ -437,7 +439,7 @@
}
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
@ -60,7 +51,7 @@
}
public PacketDataSerializer writeEnum(Enum<?> oenum) {
@@ -431,7 +433,7 @@
@@ -514,7 +516,7 @@
} else {
try {
NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
@ -69,7 +60,7 @@
throw new EncoderException(ioexception);
}
}
@@ -468,7 +470,7 @@
@@ -551,7 +553,7 @@
}
public PacketDataSerializer writeItem(ItemStack itemstack) {
@ -78,8 +69,8 @@
this.writeBoolean(false);
} else {
this.writeBoolean(true);
@@ -497,6 +499,11 @@
ItemStack itemstack = new ItemStack(Item.byId(i), b0);
@@ -580,6 +582,11 @@
ItemStack itemstack = new ItemStack(item, b0);
itemstack.setTag(this.readNbt());
+ // CraftBukkit start

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/network/chat/ChatHexColor.java
+++ b/net/minecraft/network/chat/ChatHexColor.java
@@ -12,7 +12,7 @@
private static final String CUSTOM_COLOR_PREFIX = "#";
@@ -19,7 +19,7 @@
return chathexcolor != null ? DataResult.success(chathexcolor) : DataResult.error("String is not a valid color name or hex color code");
}, ChatHexColor::serialize);
private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> {
- return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName());
+ return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit
}));
private static final Map<String, ChatHexColor> NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> {
return chathexcolor.name;
@@ -20,16 +20,22 @@
@@ -27,16 +27,22 @@
private final int value;
@Nullable
public final String name;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/network/chat/IChatBaseComponent.java
+++ b/net/minecraft/network/chat/IChatBaseComponent.java
@@ -29,7 +29,23 @@
@@ -40,7 +40,23 @@
import net.minecraft.util.ChatTypeAdapterFactory;
import net.minecraft.util.FormattedString;

View File

@ -0,0 +1,7 @@
--- a/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import java.util.Objects;

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInChat.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInChat.java
@@ -17,7 +17,7 @@
@@ -25,7 +25,7 @@
}
public PacketPlayInChat(PacketDataSerializer packetdataserializer) {
- this.message = packetdataserializer.readUtf(256);
+ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.readUtf(256)); // CraftBukkit - see PlayerConnection
}
@Override
this.timeStamp = packetdataserializer.readInstant();
this.saltSignature = new MinecraftEncryption.b(packetdataserializer);
this.signedPreview = packetdataserializer.readBoolean();

View File

@ -1,7 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayOutChat.java
+++ b/net/minecraft/network/protocol/game/PacketPlayOutChat.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.network.protocol.game;
import java.util.UUID;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/resources/ResourceKey.java
+++ b/net/minecraft/resources/ResourceKey.java
@@ -10,7 +10,7 @@
@@ -9,7 +9,7 @@
public class ResourceKey<T> {
@ -9,7 +9,7 @@
private final MinecraftKey registryName;
private final MinecraftKey location;
@@ -29,7 +29,7 @@
@@ -28,7 +28,7 @@
}
private static <T> ResourceKey<T> create(MinecraftKey minecraftkey, MinecraftKey minecraftkey1) {
@ -18,7 +18,7 @@
return (ResourceKey) ResourceKey.VALUES.computeIfAbsent(s, (s1) -> {
return new ResourceKey<>(minecraftkey, minecraftkey1);
@@ -50,7 +50,7 @@
@@ -49,7 +49,7 @@
}
public <E> Optional<ResourceKey<E>> cast(ResourceKey<? extends IRegistry<E>> resourcekey) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -181,7 +181,11 @@
@@ -180,7 +180,11 @@
Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey());
if (advancement == null) {
@ -13,11 +13,11 @@
} else {
this.startProgress(advancement, (AdvancementProgress) entry.getValue());
}
@@ -276,6 +280,7 @@
@@ -275,6 +279,7 @@
this.progressChanged.add(advancement);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
+ this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
advancement.getRewards().grant(this.player);
if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
this.playerList.broadcastMessage(new ChatMessage("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
this.playerList.broadcastSystemMessage(IChatBaseComponent.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), ChatMessageType.SYSTEM);

View File

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

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java
@@ -33,6 +33,12 @@
@@ -32,6 +32,12 @@
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import org.slf4j.Logger;
@ -13,7 +13,7 @@
public class DispenserRegistry {
public static final PrintStream STDOUT = System.out;
@@ -43,6 +49,23 @@
@@ -42,6 +48,23 @@
public static void bootStrap() {
if (!DispenserRegistry.isBootstrapped) {
@ -37,7 +37,7 @@
DispenserRegistry.isBootstrapped = true;
if (IRegistry.REGISTRY.keySet().isEmpty()) {
throw new IllegalStateException("Unable to load registries");
@@ -60,6 +83,69 @@
@@ -58,6 +81,69 @@
IRegistry.freezeBuiltins();
wrapStreams();
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -57,6 +57,12 @@
@@ -58,6 +58,12 @@
import net.minecraft.world.level.storage.WorldInfo;
import org.slf4j.Logger;
@ -13,7 +13,7 @@
public class Main {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -64,8 +70,9 @@
@@ -65,8 +71,9 @@
public Main() {}
@DontObfuscate
@ -24,7 +24,7 @@
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -90,9 +97,12 @@
@@ -91,9 +98,12 @@
optionparser.printHelpOn(System.err);
return;
}
@ -38,7 +38,7 @@
JvmProfiler.INSTANCE.start(Environment.SERVER);
}
@@ -100,13 +110,13 @@
@@ -101,13 +111,13 @@
DispenserRegistry.validate();
SystemUtils.startTimerHackThread();
Path path = Paths.get("server.properties");
@ -54,16 +54,13 @@
Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath());
return;
}
@@ -116,14 +126,15 @@
@@ -117,11 +127,12 @@
return;
}
- File file = new File((String) optionset.valueOf(optionspec9));
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY);
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.USERID_CACHE_FILE.getName()));
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
+ // CraftBukkit start
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
@ -73,7 +70,7 @@
WorldInfo worldinfo = convertable_conversionsession.getSummary();
if (worldinfo != null) {
@@ -138,13 +149,32 @@
@@ -136,13 +147,32 @@
}
}
@ -107,46 +104,46 @@
WorldStem worldstem;
@@ -158,6 +188,12 @@
}, (iresourcemanager, datapackconfiguration) -> {
@@ -155,6 +185,12 @@
return WorldStem.load(worldloader_a, (iresourcemanager, datapackconfiguration1) -> {
IRegistryCustom.e iregistrycustom_e = IRegistryCustom.builtinCopy();
DynamicOps<NBTBase> dynamicops = RegistryOps.createAndLoad(DynamicOpsNBT.INSTANCE, iregistrycustom_e, iresourcemanager);
+ // CraftBukkit start
+ config.set(datapackconfiguration);
+ config.set(datapackconfiguration1);
+ ops.set(dynamicops);
+ return Pair.of(null, iregistrycustom_e.freeze());
+ // CraftBukkit end
+ /*
SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration, iregistrycustom_e.allElementsLifecycle());
SaveData savedata = convertable_conversionsession.getDataTag(dynamicops, datapackconfiguration1, iregistrycustom_e.allElementsLifecycle());
if (savedata != null) {
@@ -180,6 +216,7 @@
@@ -177,6 +213,7 @@
return Pair.of(worlddataserver, iregistrycustom_e.freeze());
}
+ */
}, SystemUtils.backgroundExecutor(), Runnable::run).get();
}, SystemUtils.backgroundExecutor(), executor);
}).get();
} catch (Exception exception) {
Main.LOGGER.warn("Failed to load datapacks, can't proceed with server load. You can either fix your datapacks or reset to vanilla with --safeMode", exception);
@@ -188,6 +225,7 @@
@@ -184,6 +221,7 @@
return;
}
worldstem.updateGlobals();
+ /*
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registryAccess();
dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension);
@@ -200,21 +238,32 @@
@@ -196,21 +234,32 @@
}
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
+ */
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> {
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, config.get(), ops.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ /*
dedicatedserver1.setSingleplayerName((String) optionset.valueOf(optionspec8));
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
dedicatedserver1.setDemo(optionset.has(optionspec2));
dedicatedserver1.setId((String) optionset.valueOf(optionspec12));
@ -171,7 +168,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.halt(true);
@@ -223,6 +272,7 @@
@@ -219,6 +268,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -179,7 +176,7 @@
} catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
}
@@ -230,7 +280,7 @@
@@ -226,7 +276,7 @@
}
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) {

View File

@ -1,12 +1,13 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -163,6 +163,26 @@
@@ -158,6 +158,28 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.mojang.serialization.DynamicOps;
+import com.mojang.serialization.Lifecycle;
+import java.util.Random;
+import jline.console.ConsoleReader;
+import joptsimple.OptionSet;
+import net.minecraft.nbt.DynamicOpsNBT;
@ -16,6 +17,7 @@
+import net.minecraft.util.datafix.DataConverterRegistry;
+import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
+import net.minecraft.world.level.levelgen.presets.WorldPresets;
+import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
@ -27,7 +29,7 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger();
@@ -255,6 +275,21 @@
@@ -240,6 +262,21 @@
protected SaveData worldData;
private volatile boolean isSaving;
@ -49,7 +51,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -268,14 +303,14 @@
@@ -253,14 +290,14 @@
thread.setPriority(8);
}
@ -61,24 +63,33 @@
return s0;
}
- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- public MinecraftServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -287,7 +322,7 @@
@@ -272,7 +309,7 @@
this.status = new ServerPing();
this.random = new Random();
this.random = RandomSource.create();
this.port = -1;
- this.levels = Maps.newLinkedHashMap();
+ this.levels = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods
this.running = true;
this.tickTimes = new long[100];
this.resourcePack = "";
@@ -317,13 +352,41 @@
this.structureManager = new DefinedStructureManager(worldstem.resourceManager(), convertable_conversionsession, datafixer);
this.nextTickTime = SystemUtils.getMillis();
@@ -281,7 +318,7 @@
this.frameTimer = new CircularTimer();
this.registryHolder = worldstem.registryAccess();
this.worldData = worldstem.worldData();
- if (!this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) {
+ if (false && !this.worldData.worldGenSettings().dimensions().containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later
throw new IllegalStateException("Missing Overworld dimension data");
} else {
this.proxy = proxy;
@@ -302,13 +339,41 @@
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
}
+ // CraftBukkit start
+ this.options = options;
+ this.datapackconfiguration = datapackconfiguration;
@ -118,7 +129,7 @@
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -332,7 +395,7 @@
@@ -317,7 +382,7 @@
protected abstract boolean initServer() throws IOException;
@ -127,11 +138,10 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -340,13 +403,8 @@
@@ -325,12 +390,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
- this.detectBundledResources();
- this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ loadWorld0(s); // CraftBukkit
@ -142,7 +152,7 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -361,36 +419,206 @@
@@ -345,25 +406,189 @@
}
@ -158,7 +168,7 @@
+
+ if (this.isDemo()) {
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension);
+ } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
@ -171,23 +181,14 @@
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
- IRegistry<WorldDimension> iregistry = generatorsettings.dimensions();
- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD);
- Holder holder;
- Object object;
-
- if (worlddimension == null) {
- holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
- object = GeneratorSettings.makeDefaultOverworld(this.registryAccess(), (new Random()).nextLong());
- } else {
- holder = worlddimension.typeHolder();
- object = worlddimension.generator();
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true);
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension);
+ }
+
+ overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
}
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, holder, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
+ }
+
+ GeneratorSettings overworldSettings = overworldData.worldGenSettings();
+ IRegistry<WorldDimension> iregistry = overworldSettings.dimensions();
+ for (WorldDimension worldDimension : iregistry) {
@ -248,9 +249,7 @@
+ MinecraftServer.LOGGER.info("---- Migration of old " + worldType + " folder failed ----");
+ }
+ }
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+
+ try {
+ worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey);
+ } catch (IOException ex) {
@ -268,7 +267,7 @@
+
+ if (this.isDemo()) {
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
+ generatorsettings = WorldPresets.demoSettings(iregistrycustom_dimension);
+ } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
+
@ -285,36 +284,19 @@
+ }, worlddata.worldGenSettings());
+ }
+
+ IWorldDataServer iworlddataserver = worlddata;
+ WorldDataServer iworlddataserver = worlddata;
+ GeneratorSettings generatorsettings = worlddata.worldGenSettings();
+ boolean flag = generatorsettings.isDebug();
+ long i = generatorsettings.seed();
+ long j = BiomeManager.obfuscateSeed(i);
+ List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
+ WorldDimension worlddimension = (WorldDimension) iregistry.get(dimensionKey);
+ Holder<DimensionManager> holder;
+ ChunkGenerator chunkgenerator;
+
+ if (worlddimension == null) {
+ holder = this.registryAccess().registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionManager.OVERWORLD_LOCATION);
+ chunkgenerator = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong());
+ } else {
+ holder = worlddimension.typeHolder();
+ chunkgenerator = worlddimension.generator();
+ }
+
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), holder.value());
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.typeHolder().value());
+ if (biomeProvider == null && gen != null) {
+ biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
+ }
+
+ if (biomeProvider != null) {
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, chunkgenerator.ringPlacementSeed, cga.settings);
+ }
+ }
+
+ ResourceKey<World> worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, dimensionKey.location());
+
+ if (dimensionKey == WorldDimension.OVERWORLD) {
@ -323,24 +305,26 @@
+
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ WorldPersistentData worldpersistentdata = world.getDataStorage();
+ this.readScoreboard(worldpersistentdata);
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
+ this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ } else {
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, holder, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ }
+
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+ this.levels.put(world.dimension(), world);
+ this.getPlayerList().addWorldborderListener(world);
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
+
+ this.levels.put(world.dimension(), world);
+ this.getPlayerList().addWorldborderListener(world);
+
+ if (worlddata.getCustomBossEvents() != null) {
+ this.getCustomBossEvents().load(worlddata.getCustomBossEvents());
+ }
@ -373,7 +357,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -414,31 +642,8 @@
@@ -387,29 +612,8 @@
iworlddataserver.setInitialized(true);
}
@ -390,10 +374,8 @@
-
- if (resourcekey != WorldDimension.OVERWORLD) {
- ResourceKey<World> resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location());
- Holder<DimensionManager> holder1 = ((WorldDimension) entry.getValue()).typeHolder();
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).generator();
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver);
- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, holder1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false);
- WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, (WorldDimension) entry.getValue(), worldloadlistener, flag, j, ImmutableList.of(), false);
-
- worldborder.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder()));
- this.levels.put(resourcekey1, worldserver1);
@ -406,10 +388,10 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -446,6 +651,21 @@
@@ -417,6 +621,21 @@
} else {
ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition());
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
+ // CraftBukkit start
+ if (worldserver.generator != null) {
+ Random rand = new Random(worldserver.getSeed());
@ -425,10 +407,10 @@
+ }
+ }
+ // CraftBukkit end
int i = chunkgenerator.getSpawnHeight(worldserver);
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -503,8 +723,11 @@
@@ -474,8 +693,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@ -442,7 +424,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -514,19 +737,23 @@
@@ -485,19 +707,23 @@
chunkproviderserver.getLightEngine().setTaskPerBatch(500);
this.nextTickTime = SystemUtils.getMillis();
@ -475,7 +457,7 @@
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
if (forcedchunk != null) {
@@ -541,11 +768,18 @@
@@ -512,11 +738,18 @@
}
}
@ -496,8 +478,8 @@
+ // CraftBukkit end
}
protected void detectBundledResources() {
@@ -590,12 +824,16 @@
public EnumGamemode getDefaultGameType() {
@@ -546,12 +779,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@ -514,7 +496,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -630,8 +868,29 @@
@@ -586,12 +823,33 @@
this.stopServer();
}
@ -535,6 +517,10 @@
+ hasStopped = true;
+ }
+ // CraftBukkit end
if (this.metricsRecorder.isRecording()) {
this.cancelRecordingMetrics();
}
MinecraftServer.LOGGER.info("Stopping server");
+ // CraftBukkit start
+ if (this.server != null) {
@ -544,7 +530,7 @@
if (this.getConnection() != null) {
this.getConnection().stop();
}
@@ -641,6 +900,7 @@
@@ -601,6 +859,7 @@
MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll();
this.playerList.removeAll();
@ -552,7 +538,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -732,9 +992,10 @@
@@ -696,9 +955,10 @@
while (this.running) {
long i = SystemUtils.getMillis() - this.nextTickTime;
@ -564,16 +550,16 @@
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime;
@@ -745,6 +1006,7 @@
this.debugCommandProfiler = new MinecraftServer.b(SystemUtils.getNanos(), this.tickCount);
@@ -709,6 +969,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
}
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -789,6 +1051,12 @@
this.profileCache.clearExecutor();
@@ -750,6 +1011,12 @@
this.services.profileCache().clearExecutor();
}
+ // CraftBukkit start - Restore terminal to original settings
@ -585,7 +571,7 @@
this.onServerExit();
}
@@ -822,8 +1090,15 @@
@@ -783,8 +1050,15 @@
}
private boolean haveTime() {
@ -602,7 +588,7 @@
protected void waitUntilNextTick() {
this.runAllTasks();
@@ -869,7 +1144,7 @@
@@ -830,7 +1104,7 @@
}
}
@ -611,7 +597,7 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -940,7 +1215,7 @@
@@ -901,7 +1175,7 @@
}
}
@ -620,7 +606,7 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -959,22 +1234,39 @@
@@ -920,22 +1194,39 @@
}
public void tickChildren(BooleanSupplier booleansupplier) {
@ -660,7 +646,7 @@
this.profiler.push("tick");
@@ -1063,7 +1355,7 @@
@@ -1024,7 +1315,7 @@
@DontObfuscate
public String getServerModName() {
@ -669,7 +655,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1406,11 +1698,11 @@
@@ -1375,11 +1666,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registryAccess();
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -683,15 +669,15 @@
}, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1425,6 +1717,7 @@
}).thenAcceptAsync((minecraftserver_a) -> {
@@ -1394,6 +1685,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_a;
this.resources = minecraftserver_reloadableresources;
+ this.server.syncCommands(); // SPIGOT-5884: Lost on reload
this.packRepository.setSelected(collection);
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
@@ -1774,7 +2067,7 @@
@@ -1743,7 +2035,7 @@
try {
label51:
{
@ -700,7 +686,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1824,6 +2117,22 @@
@@ -1793,6 +2085,22 @@
}
@ -723,24 +709,3 @@
private void startMetricsRecordingTick() {
if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -1935,8 +2244,10 @@
}
}
- private static record a(IReloadableResourceManager a, DataPackResources b) implements AutoCloseable {
+ // CraftBukkit start - decompile error
+ public static record a(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable {
+ /*
final IReloadableResourceManager resourceManager;
final DataPackResources managers;
@@ -1944,6 +2255,8 @@
this.resourceManager = ireloadableresourcemanager;
this.managers = datapackresources;
}
+ */
+ // CraftBukkit end
public void close() {
this.resourceManager.close();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/bossevents/BossBattleCustom.java
+++ b/net/minecraft/server/bossevents/BossBattleCustom.java
@@ -18,12 +18,27 @@
@@ -17,12 +17,27 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.BossBattle;

View File

@ -12,6 +12,6 @@
} else {
- minecraftserver.setDifficulty(enumdifficulty, true);
+ worldServer.serverLevelData.setDifficulty(enumdifficulty); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.difficulty.success", new Object[]{enumdifficulty.getDisplayName()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.difficulty.success", enumdifficulty.getDisplayName()), true);
return 0;
}

View File

@ -8,7 +8,7 @@
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
t0.setFromArgument(commandcontext, "value");
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.set", gamerules_gamerulekey.getId(), t0.toString()), true);
@@ -39,7 +39,7 @@
}
@ -16,5 +16,5 @@
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.gamerule.query", gamerules_gamerulekey.getId(), t0.toString()), false);
return t0.getCommandResult();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandGive.java
+++ b/net/minecraft/server/commands/CommandGive.java
@@ -59,7 +59,7 @@
@@ -60,7 +60,7 @@
if (flag && itemstack.isEmpty()) {
itemstack.setCount(1);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandList.java
+++ b/net/minecraft/server/commands/CommandList.java
@@ -37,6 +37,12 @@
@@ -36,6 +36,12 @@
private static int format(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
List<EntityPlayer> list = playerlist.getPlayers();
@ -12,4 +12,4 @@
+ // CraftBukkit end
IChatBaseComponent ichatbasecomponent = ChatComponentUtils.formatList(list, function);
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent), false);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandLoot.java
+++ b/net/minecraft/server/commands/CommandLoot.java
@@ -90,7 +90,7 @@
@@ -91,7 +91,7 @@
}
private static <T extends ArgumentBuilder<CommandListenerWrapper, T>> T addTargets(T t0, CommandLoot.c commandloot_c) {
@ -9,7 +9,7 @@
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);
@@ -247,6 +247,7 @@
@@ -248,6 +248,7 @@
private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List<ItemStack> list, CommandLoot.a commandloot_a) throws CommandSyntaxException {
WorldServer worldserver = commandlistenerwrapper.getLevel();

View File

@ -28,8 +28,8 @@
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
@@ -322,5 +322,12 @@
this.x = MathHelper.nextDouble(random, d0, d2);
this.z = MathHelper.nextDouble(random, d1, d3);
this.x = MathHelper.nextDouble(randomsource, d0, d2);
this.z = MathHelper.nextDouble(randomsource, d1, d3);
}
+
+ // CraftBukkit start - add a version of getBlockState which force loads chunks

View File

@ -8,4 +8,4 @@
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
throw CommandSummon.ERROR_DUPLICATE_UUID.create();
} else {
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.summon.success", new Object[]{entity.getDisplayName()}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.summon.success", entity.getDisplayName()), true);

View File

@ -12,7 +12,7 @@
+
public class CommandTeleport {
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
@@ -159,14 +165,29 @@
}

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/server/commands/CommandTime.java
+++ b/net/minecraft/server/commands/CommandTime.java
@@ -9,6 +9,11 @@
import net.minecraft.network.chat.ChatMessage;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.server.level.WorldServer;
+// CraftBukkit start
@ -32,7 +32,7 @@
+ // CraftBukkit end
}
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.time.set", new Object[]{i}), true);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.time.set", i), true);
@@ -60,12 +71,18 @@
}

View File

@ -43,7 +43,7 @@
- double d0 = commandlistenerwrapper.getServer().overworld().getWorldBorder().getSize();
+ double d0 = commandlistenerwrapper.getLevel().getWorldBorder().getSize(); // CraftBukkit
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.worldborder.get", new Object[]{String.format(Locale.ROOT, "%.0f", d0)}), false);
commandlistenerwrapper.sendSuccess(IChatBaseComponent.translatable("commands.worldborder.get", String.format(Locale.ROOT, "%.0f", d0)), false);
return MathHelper.floor(d0 + 0.5D);
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -59,6 +59,18 @@
@@ -56,6 +56,18 @@
import net.minecraft.world.level.storage.Convertable;
import org.slf4j.Logger;
@ -19,20 +19,20 @@
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
static final Logger LOGGER = LogUtils.getLogger();
@@ -79,8 +91,10 @@
@@ -73,8 +85,10 @@
@Nullable
private final IChatBaseComponent resourcePackPrompt;
private final TextFilter textFilterClient;
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
- public DedicatedServer(Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit start - Signature changed
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, DynamicOps<NBTBase> registryreadops, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, registryreadops, thread, convertable_conversionsession, resourcepackrepository, worldstem, Proxy.NO_PROXY, datafixer, services, worldloadlistenerfactory);
+ // CraftBukkit end
this.settings = dedicatedserversettings;
this.rconConsoleSource = new RemoteControlCommandListener(this);
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -91,13 +105,44 @@
@@ -84,13 +98,44 @@
public boolean initServer() throws IOException {
Thread thread = new Thread("Server console handler") {
public void run() {
@ -80,7 +80,7 @@
}
} catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -106,6 +151,27 @@
@@ -99,6 +144,27 @@
}
};
@ -108,7 +108,7 @@
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start();
@@ -131,7 +197,7 @@
@@ -123,7 +189,7 @@
this.setMotd(dedicatedserverproperties.motd);
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
@ -117,7 +117,7 @@
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null;
@@ -155,6 +221,12 @@
@@ -147,6 +213,12 @@
return false;
}
@ -130,7 +130,7 @@
if (!this.usesAuthentication()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -169,13 +241,13 @@
@@ -161,13 +233,13 @@
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
return false;
} else {
@ -138,7 +138,7 @@
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryAccess(), this.playerDataStorage)); // CraftBukkit - moved up
long i = SystemUtils.getNanos();
TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this);
TileEntitySkull.setup(this.services, this);
UserCache.setUsesAuthentication(this.usesAuthentication());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
- this.loadLevel();
@ -146,7 +146,7 @@
long j = SystemUtils.getNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -192,6 +264,7 @@
@@ -184,6 +256,7 @@
if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener");
this.rconThread = RemoteControlListener.create(this);
@ -154,7 +154,7 @@
}
if (this.getMaxTickLength() > 0L) {
@@ -335,6 +408,7 @@
@@ -300,6 +373,7 @@
this.queryThreadGs4.stop();
}
@ -162,24 +162,24 @@
}
@Override
@@ -356,7 +430,15 @@
@@ -321,7 +395,15 @@
while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
- this.getCommands().performCommand(servercommand.source, servercommand.msg);
- this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg);
+ // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
+ server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
+
+ // this.getCommands().performCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
+ // this.getCommands().performPrefixedCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
+ server.dispatchServerCommand(console, servercommand);
+ // CraftBukkit end
}
}
@@ -566,14 +648,45 @@
@@ -546,14 +628,45 @@
@Override
public String getPluginNames() {
@ -214,7 +214,7 @@
public String runCommand(String s) {
this.rconConsoleSource.prepareForCommand();
this.executeBlocking(() -> {
- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), s);
- this.getCommands().performPrefixedCommand(this.rconConsoleSource.createCommandSourceStack(), s);
+ // CraftBukkit start - fire RemoteServerCommandEvent
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
+ server.getPluginManager().callEvent(event);
@ -227,9 +227,9 @@
});
return this.rconConsoleSource.getCommandResponse();
}
@@ -647,4 +760,15 @@
public IChatBaseComponent getResourcePackPrompt() {
return this.resourcePackPrompt;
@@ -606,4 +719,15 @@
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
return this.settings.getProperties().serverResourcePackInfo;
}
+
+ // CraftBukkit start

View File

@ -1,21 +1,22 @@
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -13,8 +13,14 @@
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.levelgen.GeneratorSettings;
@@ -37,10 +37,15 @@
import net.minecraft.world.level.levelgen.structure.StructureSet;
import org.slf4j.Logger;
+// CraftBukkit start
+import joptsimple.OptionSet;
+import net.minecraft.server.dedicated.PropertyManager.EditableProperty;
+// CraftBukkit end
+
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
static final Logger LOGGER = LogUtils.getLogger();
private static final Pattern SHA1 = Pattern.compile("^[a-fA-F0-9]{40}$");
+ public final boolean debug = this.get("debug", false); // CraftBukkit
public final boolean onlineMode = this.get("online-mode", true);
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
@@ -71,8 +77,10 @@
@@ -95,8 +100,10 @@
@Nullable
private GeneratorSettings worldGenSettings;
@ -28,8 +29,8 @@
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
this.levelName = this.get("level-name", "world");
@@ -121,13 +129,15 @@
}, "default"));
@@ -147,13 +154,15 @@
this.serverResourcePackInfo = getServerPackInfo(this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", ""));
}
- public static DedicatedServerProperties fromFile(Path path) {
@ -48,24 +49,25 @@
dedicatedserverproperties.getWorldGenSettings(iregistrycustom);
return dedicatedserverproperties;
@@ -141,8 +151,10 @@
return this.worldGenSettings;
}
@@ -222,10 +231,10 @@
}).orElseThrow(() -> {
return new IllegalStateException("Invalid datapack contents: can't find default preset");
});
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> {
+ Optional<ResourceKey<WorldPreset>> optional = Optional.ofNullable(MinecraftKey.tryParse(this.levelType)).map((minecraftkey) -> { // CraftBukkit - decompile error
return ResourceKey.create(IRegistry.WORLD_PRESET_REGISTRY, minecraftkey);
}).or(() -> {
- return Optional.ofNullable((ResourceKey) DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType));
+ return Optional.ofNullable(DedicatedServerProperties.a.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error
});
- public static record a(String a, JsonObject b, boolean c, String d) {
+ // CraftBukkit start - decompile error
+ public static record a(String levelSeed, JsonObject generatorSettings, boolean generateStructures, String levelType) {
Objects.requireNonNull(iregistry);
@@ -239,7 +248,7 @@
+ /*
private final String levelSeed;
private final JsonObject generatorSettings;
private final boolean generateStructures;
@@ -154,6 +166,8 @@
this.generateStructures = flag;
this.levelType = s1;
}
+ */
+ // CraftBukkit end
if (holder1.is(WorldPresets.FLAT)) {
RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, iregistrycustom);
- DataResult dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings()));
+ DataResult<GeneratorSettingsFlat> dataresult = GeneratorSettingsFlat.CODEC.parse(new Dynamic(registryops, this.generatorSettings())); // CraftBukkit - decompile error
Logger logger = DedicatedServerProperties.LOGGER;
public String levelSeed() {
return this.levelSeed;
Objects.requireNonNull(logger);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ChunkProviderServer.java
+++ b/net/minecraft/server/level/ChunkProviderServer.java
@@ -83,6 +83,16 @@
@@ -84,6 +84,16 @@
this.clearCache();
}
@ -17,7 +17,7 @@
@Override
public LightEngineThreaded getLightEngine() {
return this.lightEngine;
@@ -127,7 +137,7 @@
@@ -128,7 +138,7 @@
for (int l = 0; l < 4; ++l) {
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
ichunkaccess = this.lastChunk[l];
@ -26,7 +26,7 @@
return ichunkaccess;
}
}
@@ -175,12 +185,12 @@
@@ -176,12 +186,12 @@
if (playerchunk == null) {
return null;
} else {
@ -41,7 +41,7 @@
if (ichunkaccess1 != null) {
this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL);
@@ -228,7 +238,15 @@
@@ -229,7 +239,15 @@
int l = 33 + ChunkStatus.getDistance(chunkstatus);
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
@ -58,7 +58,7 @@
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
if (this.chunkAbsent(playerchunk, l)) {
GameProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -247,7 +265,7 @@
@@ -248,7 +266,7 @@
}
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
@ -67,7 +67,7 @@
}
@Override
@@ -314,7 +332,7 @@
@@ -315,7 +333,7 @@
} else if (!this.level.shouldTickBlocksAt(i)) {
return false;
} else {
@ -76,7 +76,7 @@
return either != null && either.left().isPresent();
}
@@ -327,11 +345,31 @@
@@ -328,11 +346,31 @@
@Override
public void close() throws IOException {
@ -109,7 +109,7 @@
@Override
public void tick(BooleanSupplier booleansupplier, boolean flag) {
this.level.getProfiler().push("purge");
@@ -363,7 +401,7 @@
@@ -364,7 +402,7 @@
gameprofilerfiller.push("pollingChunks");
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
@ -118,7 +118,7 @@
gameprofilerfiller.push("naturalSpawnCount");
int l = this.distanceManager.getNaturalSpawnChunkCount();
@@ -384,7 +422,7 @@
@@ -385,7 +423,7 @@
}
gameprofilerfiller.popPush("spawnAndTick");
@ -127,7 +127,7 @@
Collections.shuffle(list);
Iterator iterator1 = list.iterator();
@@ -581,18 +619,26 @@
@@ -586,13 +624,19 @@
}
@Override
@ -148,19 +148,3 @@
}
}
- private static record a(Chunk a, PlayerChunk b) {
+ // CraftBukkit start - decompile error
+ private static record a(Chunk chunk, PlayerChunk holder) {
+ /*
final Chunk chunk;
final PlayerChunk holder;
@@ -608,5 +654,7 @@
public PlayerChunk holder() {
return this.holder;
}
+ */
+ // CraftBukkit end
}
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -140,6 +140,34 @@
@@ -147,6 +147,34 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
@ -35,7 +35,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -194,6 +222,21 @@
@@ -201,6 +229,21 @@
public int latency;
public boolean wonGame;
@ -54,10 +54,10 @@
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile, profilepublickey);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -256,12 +299,56 @@
@@ -263,12 +306,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.maxUpStep = 1.0F;
this.fudgeSpawnLocation(worldserver);
@ -66,8 +66,8 @@
+ this.displayName = this.getScoreboardName();
+ this.bukkitPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth();
+ }
+
}
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
+ // If this is an issue, PRs are welcome
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
@ -89,7 +89,7 @@
+ long l = k * k;
+ int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
+ int j1 = this.getCoprime(i1);
+ int k1 = (new Random()).nextInt(i1);
+ int k1 = RandomSource.create().nextInt(i1);
+
+ for (int l1 = 0; l1 < i1; ++l1) {
+ int i2 = (k1 + j1 * l1) % i1;
@ -104,9 +104,9 @@
+ }
+
+ return blockposition;
}
+ }
+ // CraftBukkit end
+
private void fudgeSpawnLocation(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@ -115,7 +115,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -319,17 +406,26 @@
@@ -326,17 +413,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@ -143,7 +143,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -356,7 +452,20 @@
@@ -363,7 +459,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@ -165,7 +165,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -374,7 +483,7 @@
@@ -381,7 +490,7 @@
nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ());
nbttagcompound.putBoolean("SpawnForced", this.respawnForced);
nbttagcompound.putFloat("SpawnAngle", this.respawnAngle);
@ -174,13 +174,13 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -382,9 +491,33 @@
@@ -389,8 +498,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
}
+
+ }
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) {
@ -202,13 +202,12 @@
+ this.setPos(position.x(), position.y(), position.z());
+ }
+ this.gameMode.setLevel((WorldServer) world);
+ }
}
+ // CraftBukkit end
+
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
float f1 = (f - 1.0F) / f;
@@ -443,6 +576,11 @@
@@ -450,6 +583,11 @@
@Override
public void tick() {
@ -220,7 +219,7 @@
this.gameMode.tick();
--this.spawnInvulnerableTime;
if (this.invulnerableTime > 0) {
@@ -498,7 +636,7 @@
@@ -505,7 +643,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@ -229,7 +228,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -529,6 +667,12 @@
@@ -536,6 +674,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@ -242,7 +241,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -543,6 +687,20 @@
@@ -550,6 +694,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@ -263,7 +262,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -585,7 +743,8 @@
@@ -592,7 +750,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@ -273,9 +272,9 @@
scoreboardscore.setScore(i);
});
}
@@ -593,9 +752,47 @@
@Override
@@ -601,9 +760,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
+ // CraftBukkit start - fire PlayerDeathEvent
+ if (this.isRemoved()) {
@ -323,7 +322,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), (future) -> {
if (!future.isSuccess()) {
@@ -629,12 +826,18 @@
@@ -637,12 +834,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@ -346,7 +345,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -671,10 +874,12 @@
@@ -680,10 +883,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@ -361,7 +360,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -692,7 +897,8 @@
@@ -701,7 +906,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -371,7 +370,7 @@
}
}
@@ -736,18 +942,20 @@
@@ -745,18 +951,20 @@
}
private boolean isPvpAllowed() {
@ -395,7 +394,7 @@
} else {
return shapedetectorshape;
}
@@ -756,11 +964,20 @@
@@ -765,11 +973,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@ -419,7 +418,7 @@
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -771,6 +988,8 @@
@@ -780,6 +997,8 @@
return this;
} else {
@ -427,8 +426,8 @@
+ /*
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true));
@@ -780,22 +999,52 @@
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
@@ -789,22 +1008,52 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@ -467,7 +466,7 @@
+ if (true) { // CraftBukkit
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeRegistration(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true));
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getLastDeathLocation()));
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked()));
+ PlayerList playerlist = this.server.getPlayerList();
+
@ -487,7 +486,7 @@
worldserver1.getProfiler().pop();
this.triggerDimensionChangeTriggers(worldserver1);
this.connection.send(new PacketPlayOutAbilities(this.getAbilities()));
@@ -813,12 +1062,31 @@
@@ -822,12 +1071,31 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -519,7 +518,7 @@
private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
@@ -835,17 +1103,17 @@
@@ -844,17 +1112,17 @@
}
@Override
@ -542,21 +541,21 @@
}
return optional1;
@@ -855,13 +1123,21 @@
@@ -864,13 +1132,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
+ // CraftBukkit start
+ ResourceKey<World> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver);
+ ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level);
+
- CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
- if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+ CriterionTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1);
+ if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) {
+ CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
+ }
- CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1);
- if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+
+ if (maindimensionkey == World.NETHER && maindimensionkey1 == World.OVERWORLD && this.enteredNetherPosition != null) {
+ // CraftBukkit end
CriterionTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition);
@ -567,7 +566,7 @@
this.enteredNetherPosition = null;
}
@@ -878,12 +1154,10 @@
@@ -887,12 +1163,10 @@
this.containerMenu.broadcastChanges();
}
@ -583,7 +582,7 @@
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
@@ -907,7 +1181,36 @@
@@ -916,7 +1190,36 @@
}
}
@ -621,7 +620,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -920,9 +1223,8 @@
@@ -929,9 +1232,8 @@
return either;
}
}
@ -632,7 +631,7 @@
}
@Override
@@ -949,6 +1251,24 @@
@@ -958,6 +1260,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@ -657,7 +656,7 @@
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1030,8 +1350,9 @@
@@ -1039,8 +1359,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
}
@ -668,7 +667,7 @@
}
@Override
@@ -1039,13 +1360,35 @@
@@ -1048,13 +1369,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@ -703,8 +702,8 @@
+ // CraftBukkit end
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage((new ChatMessage("container.spectatorCantOpen")).withStyle(EnumChatFormat.RED), true);
@@ -1053,9 +1396,11 @@
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1062,9 +1405,11 @@
return OptionalInt.empty();
} else {
@ -718,7 +717,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1068,13 +1413,24 @@
@@ -1077,13 +1422,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -745,7 +744,7 @@
this.initMenu(this.containerMenu);
}
@@ -1097,6 +1453,7 @@
@@ -1106,6 +1462,7 @@
@Override
public void closeContainer() {
@ -753,7 +752,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1126,7 +1483,7 @@
@@ -1135,7 +1492,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@ -762,7 +761,7 @@
scoreboardscore.add(i);
});
}
@@ -1134,7 +1491,7 @@
@@ -1143,7 +1500,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@ -771,7 +770,7 @@
}
@Override
@@ -1150,7 +1507,7 @@
@@ -1159,7 +1516,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@ -780,24 +779,15 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1185,7 +1542,16 @@
@@ -1194,6 +1551,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
+ }
+
+ // CraftBukkit start - Support multi-line messages
+ public void sendMessage(UUID uuid, IChatBaseComponent[] ichatbasecomponent) {
+ for (IChatBaseComponent component : ichatbasecomponent) {
+ this.sendMessage(component, (uuid == null) ? SystemUtils.NIL_UUID : uuid);
+ }
}
+ // CraftBukkit end
@Override
public void displayClientMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -1240,7 +1606,7 @@
@@ -1249,7 +1607,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -806,7 +796,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1367,7 +1733,20 @@
@@ -1397,7 +1755,20 @@
return s;
}
@ -827,7 +817,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1438,7 +1817,7 @@
@@ -1472,7 +1843,7 @@
this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) {
this.connection.send(new PacketPlayOutCamera(this.camera));
@ -836,7 +826,7 @@
}
}
@@ -1467,7 +1846,7 @@
@@ -1501,7 +1872,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@ -845,7 +835,7 @@
}
@Override
@@ -1488,9 +1867,16 @@
@@ -1522,9 +1893,16 @@
return this.advancements;
}
@ -862,7 +852,7 @@
if (worldserver == this.level) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1510,6 +1896,9 @@
@@ -1544,6 +1922,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@ -872,9 +862,9 @@
}
@@ -1668,4 +2057,146 @@
public boolean allowsListing() {
return this.allowsListing;
@@ -1713,4 +2094,146 @@
}
}
+
+ // CraftBukkit start - Add per-player time and weather.

View File

@ -13,7 +13,7 @@
public class EntityTrackerEntry {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -61,8 +67,12 @@
@@ -59,8 +65,12 @@
private List<Entity> lastPassengers;
private boolean wasRiding;
private boolean wasOnGround;
@ -27,17 +27,12 @@
this.ap = Vec3D.ZERO;
this.lastPassengers = Collections.emptyList();
this.level = worldserver;
@@ -82,22 +92,22 @@
@@ -88,18 +98,18 @@
if (entity instanceof EntityItemFrame) {
EntityItemFrame entityitemframe = (EntityItemFrame) entity;
if (!list.equals(this.lastPassengers)) {
this.lastPassengers = list;
- this.broadcast.accept(new PacketPlayOutMount(this.entity));
+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit
}
- if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) {
+ if (this.entity instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
EntityItemFrame entityitemframe = (EntityItemFrame) this.entity;
- if (this.tickCount % 10 == 0) {
+ if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
ItemStack itemstack = entityitemframe.getItem();
- if (itemstack.getItem() instanceof ItemWorldMap) {
@ -55,41 +50,7 @@
worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
@@ -140,6 +150,17 @@
boolean flag2 = flag1 || this.tickCount % 60 == 0;
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
+ // CraftBukkit start - Code moved from below
+ if (flag2) {
+ this.updateSentPos();
+ }
+
+ if (flag3) {
+ this.yRotp = i;
+ this.xRotp = j;
+ }
+ // CraftBukkit end
+
if (this.tickCount > 0 || this.entity instanceof EntityArrow) {
long k = PacketPlayOutEntity.entityToPacket(vec3d.x);
long l = PacketPlayOutEntity.entityToPacket(vec3d.y);
@@ -178,6 +199,7 @@
}
this.sendDirtyEntityData();
+ /* CraftBukkit start - Code moved up
if (flag2) {
this.updateSentPos();
}
@@ -186,6 +208,7 @@
this.yRotp = i;
this.xRotp = j;
}
+ // CraftBukkit end */
this.wasRiding = false;
}
@@ -201,7 +224,27 @@
@@ -204,7 +214,27 @@
++this.tickCount;
if (this.entity.hurtMarked) {
@ -118,7 +79,7 @@
this.entity.hurtMarked = false;
}
@@ -216,13 +259,16 @@
@@ -219,13 +249,16 @@
PlayerConnection playerconnection = entityplayer.connection;
Objects.requireNonNull(entityplayer.connection);
@ -138,7 +99,7 @@
}
Packet<?> packet = this.entity.getAddEntityPacket();
@@ -238,6 +284,12 @@
@@ -241,6 +274,12 @@
if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
@ -151,7 +112,7 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -269,8 +321,14 @@
@@ -272,8 +311,14 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
@ -166,7 +127,7 @@
if (this.entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.entity;
Iterator iterator = entityliving.getActiveEffects().iterator();
@@ -311,6 +369,11 @@
@@ -314,6 +359,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@ -76,7 +76,20 @@
if (this.changedBlocksPerSection[i] == null) {
this.hasChangedSections = true;
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
@@ -368,7 +387,7 @@
@@ -182,10 +201,10 @@
}
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow((Object) null);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow(null); // CraftBukkit - decompile error
if (either != null) {
- IChunkAccess ichunkaccess = (IChunkAccess) either.left().orElse((Object) null);
+ IChunkAccess ichunkaccess = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
if (ichunkaccess != null) {
ichunkaccess.setUnsaved(true);
@@ -372,7 +391,7 @@
this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((either) -> {
either.ifLeft((chunk) -> {
@ -85,7 +98,7 @@
});
});
}
@@ -385,6 +404,30 @@
@@ -389,6 +408,30 @@
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel);
PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel);
@ -116,7 +129,7 @@
if (flag) {
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
@@ -455,6 +498,26 @@
@@ -459,6 +502,26 @@
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
this.oldTicketLevel = this.ticketLevel;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -98,6 +98,11 @@
@@ -102,6 +102,11 @@
import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger;
@ -12,7 +12,7 @@
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -139,6 +144,27 @@
@@ -144,6 +149,27 @@
private final Queue<Runnable> unloadQueue;
int viewDistance;
@ -37,10 +37,10 @@
+ };
+ // CraftBukkit end
+
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, 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, int i, boolean flag) {
super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -296,9 +322,12 @@
@@ -313,9 +339,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList();
@ -55,7 +55,7 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
if (either == null) {
@@ -503,7 +532,7 @@
@@ -520,7 +549,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@ -64,7 +64,19 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) {
@@ -683,7 +712,21 @@
@@ -609,9 +638,9 @@
ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get());
this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType());
- return Either.left(protochunk);
+ return Either.<IChunkAccess, PlayerChunk.Failure>left(protochunk); // CraftBukkit - decompile error
} else {
- return Either.left(this.createEmptyChunk(chunkcoordintpair));
+ return Either.<IChunkAccess, PlayerChunk.Failure>left(this.createEmptyChunk(chunkcoordintpair)); // CraftBukkit - decompile error
}
}, this.mainThreadExecutor).exceptionallyAsync((throwable) -> {
return this.handleChunkLoadFailure(throwable, chunkcoordintpair);
@@ -717,7 +746,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
@ -87,7 +99,7 @@
}
}
@@ -782,7 +825,7 @@
@@ -816,7 +859,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) {
return false;
} else {
@ -96,7 +108,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false;
@@ -944,7 +987,8 @@
@@ -978,7 +1021,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
});
@ -106,7 +118,7 @@
return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count();
@@ -957,7 +1001,7 @@
@@ -991,7 +1035,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try {
@ -115,16 +127,25 @@
return either != null ? (String) either.map((chunk) -> {
return "done";
@@ -975,7 +1019,7 @@
private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException {
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
@@ -1007,12 +1051,14 @@
- return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
+ return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
- return optional.map(this::upgradeChunkTag);
+ return optional.map((nbttagcompound) -> upgradeChunkTag(nbttagcompound, chunkcoordintpair)); // CraftBukkit
}, SystemUtils.backgroundExecutor());
}
- private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) {
- return this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
+ // CraftBukkit start
+ private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound, ChunkCoordIntPair chunkcoordintpair) {
+ return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level);
+ // CraftBukkit end
}
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1396,7 +1440,7 @@
@@ -1433,7 +1479,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) {
@ -132,15 +153,8 @@
+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPosition.of(entity);
@@ -1449,12 +1493,17 @@
public void updatePlayer(EntityPlayer entityplayer) {
if (entityplayer != this.entity) {
- Vec3D vec3d = entityplayer.position().subtract(this.serverEntity.sentPos());
+ Vec3D vec3d = entityplayer.position().subtract(this.entity.position()); // MC-155077, SPIGOT-5113
double d0 = (double) Math.min(this.getEffectiveRange(), (PlayerChunkMap.this.viewDistance - 1) * 16);
double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1492,6 +1538,11 @@
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/server/level/PlayerInteractManager.java
+++ b/net/minecraft/server/level/PlayerInteractManager.java
@@ -26,6 +26,27 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
@ -60,13 +60,14 @@
IBlockData iblockdata;
if (this.hasDelayedDestroy) {
@@ -152,10 +180,32 @@
@@ -142,11 +170,33 @@
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, blockposition)) {
+ // CraftBukkit start - fire PlayerInteractEvent
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
this.player.connection.send(new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
this.debugLogging(blockposition, false, j, "may not interact");
+ // Update any tile entity data for this block
+ TileEntity tileentity = level.getBlockEntity(blockposition);
+ if (tileentity != null) {
@ -91,13 +92,13 @@
+ // CraftBukkit end
+
if (this.isCreative()) {
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
this.destroyAndAck(blockposition, j, "creative destroy");
return;
@@ -170,11 +220,43 @@
@@ -162,11 +212,43 @@
float f = 1.0F;
iblockdata1 = this.level.getBlockState(blockposition);
- if (!iblockdata1.isAir()) {
iblockdata = this.level.getBlockState(blockposition);
- if (!iblockdata.isAir()) {
+ // CraftBukkit start - Swings at air do *NOT* exist.
+ if (event.useInteractedBlock() == Event.Result.DENY) {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
@ -110,9 +111,9 @@
+ } else if (data.getBlock() instanceof BlockTrapdoor) {
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
+ }
+ } else if (!iblockdata1.isAir()) {
iblockdata1.attack(this.level, blockposition, this.player);
f = iblockdata1.getDestroyProgress(this.player, this.player.level, blockposition);
+ } else if (!iblockdata.isAir()) {
iblockdata.attack(this.level, blockposition, this.player);
f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition);
}
+ if (event.useItemInHand() == Event.Result.DENY) {
@ -135,35 +136,27 @@
+ }
+ // CraftBukkit end
+
if (!iblockdata1.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(blockposition, j, "insta mine");
} else {
@@ -218,13 +300,15 @@
@@ -211,13 +293,15 @@
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, blockposition)) {
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
this.player.connection.send(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getBlockState(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
this.debugLogging(blockposition, true, j, "aborted mismatched destroying");
}
this.level.destroyBlockProgress(this.player.getId(), blockposition, -1);
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, "aborted destroying"));
this.debugLogging(blockposition, true, j, "aborted destroying");
+
+ CraftEventFactory.callBlockDamageAbortEvent(this.player, blockposition, this.player.getInventory().getSelected()); // CraftBukkit
}
}
@@ -234,17 +318,72 @@
if (this.destroyBlock(blockposition)) {
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
} else {
- this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
}
}
@@ -235,10 +319,65 @@
public boolean destroyBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.level.getBlockState(blockposition);
@ -195,7 +188,7 @@
+ ItemStack itemstack = this.player.getItemBySlot(EnumItemSlot.MAINHAND);
+
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) {
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack));
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack, true));
+ }
+
+ this.level.getCraftServer().getPluginManager().callEvent(event);
@ -230,7 +223,7 @@
TileEntity tileentity = this.level.getBlockEntity(blockposition);
Block block = iblockdata.getBlock();
@@ -254,6 +393,10 @@
@@ -248,6 +387,10 @@
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
return false;
} else {
@ -241,7 +234,7 @@
block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
boolean flag = this.level.removeBlock(blockposition, false);
@@ -262,19 +405,32 @@
@@ -256,19 +399,32 @@
}
if (this.isCreative()) {
@ -277,7 +270,7 @@
}
}
}
@@ -316,12 +472,52 @@
@@ -313,12 +469,52 @@
}
}
@ -330,7 +323,7 @@
if (itileinventory != null) {
entityplayer.openMenu(itileinventory);
@@ -335,7 +531,7 @@
@@ -332,7 +528,7 @@
ItemStack itemstack1 = itemstack.copy();
if (!flag1) {
@ -339,7 +332,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
@@ -343,17 +539,17 @@
@@ -340,17 +536,17 @@
}
}
@ -360,7 +353,7 @@
}
if (enuminteractionresult1.consumesAction()) {
@@ -361,10 +557,10 @@
@@ -358,10 +554,10 @@
}
return enuminteractionresult1;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
@@ -199,7 +199,7 @@
@@ -206,7 +206,7 @@
if (iblockdata.isAir()) {
return false;
} else {
@ -9,7 +9,7 @@
TileEntity tileentity = iblockdata.hasBlockEntity() ? this.getBlockEntity(blockposition) : null;
Block.dropResources(iblockdata, this.level, blockposition, tileentity, entity, ItemStack.EMPTY);
@@ -318,6 +318,13 @@
@@ -325,6 +325,13 @@
@Override
public boolean addFreshEntity(Entity entity) {

View File

@ -1,27 +1,32 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -150,6 +150,20 @@
@@ -152,6 +152,25 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.entity.monster.EntityDrowned;
+import net.minecraft.world.level.biome.WorldChunkManager;
+import net.minecraft.world.level.dimension.WorldDimension;
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
+import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.WeatherType;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.craftbukkit.util.WorldUUID;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.server.MapInitializeEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+import org.bukkit.event.world.GenericGameEvent;
+import org.bukkit.event.world.TimeSkipEvent;
+// CraftBukkit end
+
public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -167,7 +181,7 @@
@@ -169,7 +188,7 @@
final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@ -30,16 +35,13 @@
final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager;
public boolean noSave;
@@ -190,9 +204,29 @@
@@ -193,11 +212,28 @@
private final StructureCheck structureCheck;
private final boolean tickTime;
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, Holder<DimensionManager> holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i);
+
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Holder holder = worlddimension.typeHolder();
+ // CraftBukkit start
+ private int tickPosition;
+ public final Convertable.ConversionSession convertable;
+ public final UUID uuid;
+
@ -51,40 +53,49 @@
+ public ResourceKey<WorldDimension> getTypeKey() {
+ return convertable.dimensionType;
+ }
+
+ // Add env and gen to constructor, WorldData -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, Holder<DimensionManager> holder, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ // Holder holder = worlddimension.typeHolder(); // CraftBukkit - decompile error
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
+ super(iworlddataserver, resourcekey, holder, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env);
+ super(iworlddataserver, resourcekey, worlddimension.typeHolder(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
+ this.pvpMode = minecraftserver.isPvpAllowed();
+ convertable = convertable_conversionsession;
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
+ // CraftBukkit end
this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -204,7 +238,13 @@
this.tickTime = flag1;
this.server = minecraftserver;
@@ -212,6 +248,20 @@
this.customSpawners = list;
- this.serverLevelData = iworlddataserver;
this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator();
+ // CraftBukkit start
+ this.serverLevelData = (WorldDataServer) iworlddataserver;
+ serverLevelData.setWorld(this);
+
+ if (biomeProvider != null) {
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryHolder.registryOrThrow(IRegistry.BIOME_REGISTRY));
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
+ chunkgenerator = new ChunkGeneratorAbstract(cga.structureSets, cga.noises, worldChunkManager, cga.settings);
+ }
+ }
+
+ if (gen != null) {
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
+ }
+ // CraftBukkit end
chunkgenerator.ensureStructuresGenerated();
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
@@ -236,14 +276,15 @@
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -243,14 +293,15 @@
long l = minecraftserver.getWorldData().worldGenSettings().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer);
- this.structureFeatureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck);
+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit
if (this.dimensionType().createDragonFight()) {
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
- this.structureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck);
+ this.structureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit
if (this.dimension() == World.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) {
- this.dragonFight = new EnderDragonBattle(this, l, minecraftserver.getWorldData().endDragonFightData());
+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit
} else {
@ -96,7 +107,7 @@
}
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -275,12 +316,20 @@
@@ -282,12 +333,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -120,7 +131,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -306,7 +355,7 @@
@@ -313,7 +372,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@ -129,7 +140,7 @@
if (flag) {
this.resetEmptyTime();
@@ -322,7 +371,7 @@
@@ -329,7 +388,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@ -138,7 +149,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -394,7 +443,7 @@
@@ -403,7 +462,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -147,7 +158,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -421,14 +470,14 @@
@@ -430,14 +489,14 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -164,7 +175,7 @@
}
}
@@ -439,12 +488,12 @@
@@ -448,12 +507,12 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
@ -179,7 +190,7 @@
}
IBlockData iblockdata = this.getBlockState(blockposition1);
@@ -640,6 +689,7 @@
@@ -649,6 +708,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -187,7 +198,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -658,14 +708,47 @@
@@ -667,14 +727,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
@ -237,7 +248,7 @@
}
public void resetEmptyTime() {
@@ -700,6 +783,7 @@
@@ -709,6 +802,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -245,7 +256,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -723,6 +807,7 @@
@@ -732,6 +826,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@ -253,15 +264,15 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -747,6 +832,7 @@
@@ -756,6 +851,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel"));
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -764,11 +850,19 @@
@@ -773,11 +869,19 @@
}
}
@ -282,7 +293,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -814,15 +908,37 @@
@@ -823,15 +927,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -323,7 +334,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -853,24 +969,37 @@
@@ -862,24 +988,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@ -365,7 +376,7 @@
return true;
}
}
@@ -884,10 +1013,32 @@
@@ -893,10 +1032,32 @@
entityplayer.remove(entity_removalreason);
}
@ -398,7 +409,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -896,6 +1047,12 @@
@@ -905,6 +1066,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -411,7 +422,22 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -950,7 +1107,18 @@
@@ -941,6 +1108,14 @@
public void gameEvent(GameEvent gameevent, Vec3D vec3d, GameEvent.a gameevent_a) {
int i = gameevent.getNotificationRadius();
BlockPosition blockposition = new BlockPosition(vec3d);
+ // CraftBukkit start
+ GenericGameEvent event = new GenericGameEvent(org.bukkit.GameEvent.getByKey(CraftNamespacedKey.fromMinecraft(IRegistry.GAME_EVENT.getKey(gameevent))), new Location(this.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()), (gameevent_a.sourceEntity() == null) ? null : gameevent_a.sourceEntity().getBukkitEntity(), i, !Bukkit.isPrimaryThread());
+ getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ i = event.getRadius();
+ // CraftBukkit end
int j = SectionPosition.blockToSectionCoord(blockposition.getX() - i);
int k = SectionPosition.blockToSectionCoord(blockposition.getY() - i);
int l = SectionPosition.blockToSectionCoord(blockposition.getZ() - i);
@@ -1013,7 +1188,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@ -431,7 +457,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -986,10 +1154,20 @@
@@ -1069,10 +1255,20 @@
@Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -452,7 +478,7 @@
if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearToBlow();
}
@@ -1070,13 +1248,20 @@
@@ -1144,13 +1340,20 @@
}
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -475,16 +501,16 @@
++j;
}
}
@@ -1127,7 +1312,7 @@
@@ -1201,7 +1404,7 @@
@Nullable
public BlockPosition findNearestMapFeature(TagKey<StructureFeature<?, ?>> tagkey, BlockPosition blockposition, int i, boolean flag) {
- if (!this.server.getWorldData().worldGenSettings().generateFeatures()) {
+ if (!this.serverLevelData.worldGenSettings().generateFeatures()) { // CraftBukkit
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
- if (!this.server.getWorldData().worldGenSettings().generateStructures()) {
+ if (!this.serverLevelData.worldGenSettings().generateStructures()) { // CraftBukkit
return null;
} else {
Optional<HolderSet.Named<StructureFeature<?, ?>>> optional = this.registryAccess().registryOrThrow(IRegistry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY).getTag(tagkey);
@@ -1169,11 +1354,21 @@
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(IRegistry.STRUCTURE_REGISTRY).getTag(tagkey);
@@ -1243,11 +1446,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
@ -507,7 +533,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1485,6 +1680,11 @@
@@ -1545,6 +1758,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@ -519,7 +545,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1504,12 +1704,12 @@
@@ -1564,12 +1782,12 @@
}
public boolean isFlat() {
@ -534,7 +560,7 @@
}
@Nullable
@@ -1532,7 +1732,7 @@
@@ -1592,7 +1810,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -543,7 +569,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1541,7 +1741,7 @@
@@ -1601,7 +1819,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -552,7 +578,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1552,17 +1752,33 @@
@@ -1612,17 +1830,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@ -588,18 +614,18 @@
}
@Override
@@ -1672,6 +1888,7 @@
}
@@ -1733,6 +1967,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
+ entity.valid = true; // CraftBukkit
}
public void onTrackingEnd(Entity entity) {
@@ -1713,6 +1930,14 @@
gameeventlistenerregistrar.onListenerRemoved(entity.level);
@@ -1769,6 +2004,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
+ // CraftBukkit start
+ entity.valid = false;
+ if (!(entity instanceof EntityPlayer)) {
@ -609,5 +635,5 @@
+ }
+ // CraftBukkit end
}
}
}
public void onSectionChange(Entity entity) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/HandshakeListener.java
+++ b/net/minecraft/server/network/HandshakeListener.java
@@ -11,8 +11,17 @@
@@ -10,8 +10,17 @@
import net.minecraft.network.protocol.login.PacketLoginOutDisconnect;
import net.minecraft.server.MinecraftServer;
@ -15,10 +15,10 @@
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
+ private static int throttleCounter = 0;
+ // CraftBukkit end
private static final IChatBaseComponent IGNORE_STATUS_REASON = new ChatComponentText("Ignoring status request");
private static final IChatBaseComponent IGNORE_STATUS_REASON = IChatBaseComponent.literal("Ignoring status request");
private final MinecraftServer server;
private final NetworkManager connection;
@@ -27,6 +36,40 @@
@@ -26,6 +35,40 @@
switch (packethandshakinginsetprotocol.getIntention()) {
case LOGIN:
this.connection.setProtocol(EnumProtocol.LOGIN);
@ -31,7 +31,7 @@
+ synchronized (throttleTracker) {
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
+ throttleTracker.put(address, currentTime);
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
+ IChatMutableComponent chatmessage = IChatBaseComponent.literal("Connection throttled! Please wait before reconnecting.");
+ this.connection.send(new PacketLoginOutDisconnect(chatmessage));
+ this.connection.disconnect(chatmessage);
+ return;
@ -57,10 +57,10 @@
+ }
+ // CraftBukkit end
if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
ChatMessage chatmessage;
IChatMutableComponent ichatmutablecomponent;
@@ -40,6 +83,7 @@
this.connection.disconnect(chatmessage);
@@ -39,6 +82,7 @@
this.connection.disconnect(ichatmutablecomponent);
} else {
this.connection.setListener(new LoginListener(this.server, this.connection));
+ ((LoginListener) this.connection.getPacketListener()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/server/network/LoginListener.java
+++ b/net/minecraft/server/network/LoginListener.java
@@ -36,6 +36,13 @@
@@ -41,6 +41,12 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.network.chat.ChatComponentText;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerPreLoginEvent;
@ -14,42 +13,35 @@
public class LoginListener implements PacketLoginInListener {
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
@@ -52,6 +59,7 @@
private final String serverId;
@Nullable
@@ -62,6 +68,7 @@
private EntityPlayer delayedAcceptPlayer;
@Nullable
private ProfilePublicKey playerProfilePublicKey;
+ public String hostname = ""; // CraftBukkit - add field
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.state = LoginListener.EnumProtocolState.HELLO;
@@ -80,6 +88,20 @@
@@ -90,6 +97,13 @@
}
+ // CraftBukkit start
+ @Deprecated
+ public void disconnect(String s) {
+ try {
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s);
+ this.connection.send(new PacketLoginOutDisconnect(ichatbasecomponent));
+ this.connection.disconnect(ichatbasecomponent);
+ } catch (Exception exception) {
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
+ }
+ disconnect(IChatBaseComponent.literal(s));
+ }
+ // CraftBukkit end
+
@Override
public NetworkManager getConnection() {
return this.connection;
@@ -101,10 +123,12 @@
@@ -111,10 +125,12 @@
this.gameProfile = this.createFakeProfile(this.gameProfile);
}
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, hostname);
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, this.playerProfilePublicKey, hostname);
- if (ichatbasecomponent != null) {
- this.disconnect(ichatbasecomponent);
@ -59,16 +51,16 @@
} else {
this.state = LoginListener.EnumProtocolState.ACCEPTED;
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
@@ -117,7 +141,7 @@
@@ -127,7 +143,7 @@
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
try {
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile);
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, this.playerProfilePublicKey);
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
if (entityplayer != null) {
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -199,6 +223,43 @@
@@ -259,6 +275,43 @@
try {
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
if (LoginListener.this.gameProfile != null) {
@ -112,8 +104,8 @@
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} else if (LoginListener.this.server.isSingleplayer()) {
@@ -218,6 +279,11 @@
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
@@ -278,6 +331,11 @@
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
}
+ // CraftBukkit start - catch all exceptions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PacketStatusListener.java
+++ b/net/minecraft/server/network/PacketStatusListener.java
@@ -10,6 +10,18 @@
@@ -9,6 +9,18 @@
import net.minecraft.network.protocol.status.PacketStatusOutServerInfo;
import net.minecraft.server.MinecraftServer;
@ -18,8 +18,8 @@
+
public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled");
@@ -36,7 +48,102 @@
private static final IChatBaseComponent DISCONNECT_REASON = IChatBaseComponent.translatable("multiplayer.status.request_handled");
@@ -35,7 +47,102 @@
this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON);
} else {
this.hasRequestedStatus = true;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java
@@ -157,6 +157,62 @@
@@ -173,6 +173,62 @@
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -9,7 +9,7 @@
+import java.util.concurrent.atomic.AtomicInteger;
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.entity.EntityInsentient;
@ -63,7 +63,7 @@
public class PlayerConnection implements ServerPlayerConnection, PacketListenerPlayIn {
static final Logger LOGGER = LogUtils.getLogger();
@@ -168,7 +224,9 @@
@@ -187,7 +243,9 @@
private long keepAliveTime;
private boolean keepAlivePending;
private long keepAliveChallenge;
@ -74,7 +74,7 @@
private int dropSpamTickCount;
private double firstGoodX;
private double firstGoodY;
@@ -203,7 +261,31 @@
@@ -225,7 +283,31 @@
entityplayer.connection = this;
this.keepAliveTime = SystemUtils.getMillis();
entityplayer.getTextFilter().join();
@ -105,17 +105,17 @@
+ // CraftBukkit end
public void tick() {
this.resetPosition();
@@ -252,7 +334,7 @@
if (this.ackBlockChangesUpTo > -1) {
@@ -279,7 +361,7 @@
this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis();
- if (i - this.keepAliveTime >= 15000L) {
+ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
if (this.keepAlivePending) {
this.disconnect(new ChatMessage("disconnect.timeout"));
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
} else {
@@ -264,15 +346,21 @@
@@ -291,15 +373,21 @@
}
this.server.getProfiler().pop();
@ -134,10 +134,10 @@
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) (this.server.getPlayerIdleTimeout() * 1000 * 60)) {
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
}
@@ -296,16 +384,47 @@
@@ -324,16 +412,47 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile());
}
@ -186,7 +186,7 @@
}
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -376,7 +495,34 @@
@@ -404,7 +523,34 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -222,7 +222,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new PacketPlayOutVehicleMove(entity));
return;
@@ -408,14 +554,72 @@
@@ -436,14 +582,72 @@
}
entity.absMoveTo(d3, d4, d5, f, f1);
@ -295,16 +295,7 @@
this.player.getLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
@@ -434,7 +638,7 @@
@Override
public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel());
- if (packetplayinteleportaccept.getId() == this.awaitingTeleport) {
+ if (packetplayinteleportaccept.getId() == this.awaitingTeleport && this.awaitingPositionFromClient != null) { // CraftBukkit
this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
this.lastGoodX = this.awaitingPositionFromClient.x;
this.lastGoodY = this.awaitingPositionFromClient.y;
@@ -444,6 +648,7 @@
@@ -477,6 +681,7 @@
}
this.awaitingPositionFromClient = null;
@ -312,7 +303,7 @@
}
}
@@ -451,7 +656,7 @@
@@ -484,7 +689,7 @@
@Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
@ -321,20 +312,20 @@
RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver);
@@ -481,6 +686,12 @@
@@ -514,6 +719,12 @@
@Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
+ // CraftBukkit start
+ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ this.disconnect(new ChatMessage("disconnect.spam", new Object[0]));
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ return;
+ }
+ // CraftBukkit end
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -490,6 +701,7 @@
@@ -523,6 +734,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -342,7 +333,7 @@
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
});
}
@@ -722,6 +934,13 @@
@@ -755,6 +967,13 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@ -356,7 +347,7 @@
containermerchant.setSelectionHint(i);
containermerchant.tryMoveItems(i);
@@ -731,6 +950,13 @@
@@ -764,6 +983,13 @@
@Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@ -370,7 +361,7 @@
int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -739,7 +965,7 @@
@@ -772,7 +998,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@ -379,7 +370,7 @@
Objects.requireNonNull(list);
stream.forEach(list::add);
@@ -755,7 +981,7 @@
@@ -788,7 +1014,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) {
@ -388,10 +379,10 @@
}
}
@@ -780,16 +1006,16 @@
@@ -813,16 +1039,16 @@
this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s));
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
- }, itemstack1);
- this.player.getInventory().setItem(i, itemstack1);
+ }, itemstack1, i, itemstack); // CraftBukkit
@ -399,17 +390,17 @@
}
}
- private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
- private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
+ private void updateBookPages(List<FilteredText<String>> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
NBTTagList nbttaglist = new NBTTagList();
if (this.player.isTextFilteringEnabled()) {
- Stream stream = list.stream().map((itextfilter_a) -> {
+ Stream<NBTTagString> stream = list.stream().map((itextfilter_a) -> { // CraftBukkit - decompile error
return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered()));
- Stream stream = list.stream().map((filteredtext) -> {
+ Stream<NBTTagString> stream = list.stream().map((filteredtext) -> { // CraftBukkit - decompile error
return NBTTagString.valueOf((String) unaryoperator.apply((String) filteredtext.filteredOrElse("")));
});
@@ -817,6 +1043,7 @@
@@ -848,6 +1074,7 @@
}
itemstack.addTagElement("pages", nbttaglist);
@ -417,7 +408,7 @@
}
@Override
@@ -853,7 +1080,7 @@
@@ -884,7 +1111,7 @@
} else {
WorldServer worldserver = this.player.getLevel();
@ -426,7 +417,7 @@
if (this.tickCount == 0) {
this.resetPosition();
}
@@ -863,7 +1090,7 @@
@@ -894,7 +1121,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@ -435,7 +426,7 @@
} else {
this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -875,7 +1102,15 @@
@@ -906,7 +1133,15 @@
if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.getLevel().getChunkSource().move(this.player);
@ -451,7 +442,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -895,15 +1130,33 @@
@@ -926,15 +1161,33 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -487,7 +478,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d7, d8, d9});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -924,6 +1177,7 @@
@@ -955,6 +1208,7 @@
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@ -495,7 +486,7 @@
double d12 = d8;
d7 = d0 - this.player.getX();
@@ -943,8 +1197,71 @@
@@ -974,8 +1228,71 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
@ -568,7 +559,7 @@
this.clientIsFloating = d12 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
this.player.getLevel().getChunkSource().move(this.player);
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
@@ -983,19 +1300,80 @@
@@ -1014,19 +1331,80 @@
return true;
}
@ -598,8 +589,9 @@
+
+ public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, PlayerTeleportEvent.TeleportCause cause) {
+ this.teleport(d0, d1, d2, f, f1, set, false, cause);
+ }
+
}
- public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status
+ Player player = this.getCraftPlayer();
+ Location from = player.getLocation();
@ -636,9 +628,8 @@
+
+ public void teleport(Location dest) {
+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.<PacketPlayOutPosition.EnumPlayerTeleportFlags>emptySet(), true);
}
- public void teleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ }
+
+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, boolean flag) {
+ // CraftBukkit start
+ if (Float.isNaN(f)) {
@ -653,7 +644,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
@@ -1007,6 +1385,14 @@
@@ -1038,6 +1416,14 @@
this.awaitingTeleport = 0;
}
@ -668,7 +659,7 @@
this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
@@ -1015,6 +1401,7 @@
@@ -1046,6 +1432,7 @@
@Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
@ -676,7 +667,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime();
@@ -1025,14 +1412,46 @@
@@ -1056,14 +1443,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@ -725,15 +716,15 @@
this.player.drop(false);
}
@@ -1069,6 +1488,7 @@
@@ -1101,6 +1520,7 @@
@Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinuseitem.getHand();
ItemStack itemstack = this.player.getItemInHand(enumhand);
@@ -1088,6 +1508,7 @@
@@ -1122,6 +1542,7 @@
if (blockposition.getY() < i) {
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
@ -741,14 +732,15 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
@@ -1117,12 +1538,51 @@
@@ -1149,6 +1570,7 @@
@Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
+ if (this.player.isImmobile()) return; // CraftBukkit
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinblockplace.getHand();
ItemStack itemstack = this.player.getItemInHand(enumhand);
@@ -1156,6 +1578,44 @@
this.player.resetLastActionTime();
if (!itemstack.isEmpty()) {
@ -793,7 +785,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) {
@@ -1143,7 +1603,7 @@
@@ -1176,7 +1636,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) {
@ -802,15 +794,15 @@
return;
}
}
@@ -1158,6 +1618,7 @@
@@ -1191,6 +1651,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit
}
@@ -1177,11 +1638,26 @@
@@ -1210,11 +1671,26 @@
@Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@ -825,7 +817,7 @@
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
this.server.invalidateStatus();
this.server.getPlayerList().broadcastMessage((new ChatMessage("multiplayer.player.left", new Object[]{this.player.getDisplayName()})).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
this.server.getPlayerList().broadcastSystemMessage(IChatBaseComponent.translatable("multiplayer.player.left", this.player.getDisplayName()).withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
+ */
+
this.player.disconnect();
@ -838,7 +830,7 @@
this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1196,6 +1672,15 @@
@@ -1237,6 +1713,15 @@
}
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
@ -854,7 +846,7 @@
try {
this.connection.send(packet, genericfuturelistener);
} catch (Throwable throwable) {
@@ -1212,7 +1697,16 @@
@@ -1253,7 +1738,16 @@
@Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
@ -871,7 +863,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1221,11 +1715,18 @@
@@ -1262,18 +1756,27 @@
this.player.resetLastActionTime();
} else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -887,39 +879,72 @@
+ return;
+ }
+ // CraftBukkit end
String s = StringUtils.normalizeSpace(packetplayinchat.getMessage());
for (int i = 0; i < s.length(); ++i) {
@@ -1239,20 +1740,42 @@
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel());
this.handleChat(ITextFilter.a.passThrough(s));
if (isChatMessageIllegal(packetplayinchat.getMessage())) {
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.illegal_characters"));
} else {
- this.filterTextPacket(s, this::handleChat);
+ this.handleChat(ITextFilter.a.passThrough(s)); // CraftBukkit - filter NYI
}
}
private void handleChat(ITextFilter.a itextfilter_a) {
- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new PacketPlayOutChat((new ChatMessage("chat.disabled.options")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
} else {
this.player.resetLastActionTime();
String s = itextfilter_a.getRaw();
- if (s.startsWith("/")) {
- this.handleCommand(s);
if (this.tryHandleChat(packetplayinchat.getMessage(), packetplayinchat.getTimeStamp())) {
- this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
- this.handleChat(packetplayinchat, filteredtext);
- });
+ // CraftBukkit start
+ boolean isSync = s.startsWith("/");
+ if (isSync) {
+ // this.filterTextPacket(packetplayinchat.getMessage(), (filteredtext) -> {
+ this.handleChat(packetplayinchat, FilteredText.passThrough(packetplayinchat.getMessage())); // CraftBukkit - filter NYI
+ // });
+ // CraftBukkit end
}
}
@@ -1286,10 +1789,18 @@
} else {
PlayerConnectionUtils.ensureRunningOnSameThread(serverboundchatcommandpacket, this, this.player.getLevel());
if (this.tryHandleChat(serverboundchatcommandpacket.command(), serverboundchatcommandpacket.timeStamp())) {
- CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
+ // CraftBukkit start
+ // CommandListenerWrapper commandlistenerwrapper = this.player.createCommandSourceStack().withSigningContext(serverboundchatcommandpacket.signingContext(this.player.getUUID()));
- this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
- this.detectRateSpam();
+ // this.server.getCommands().performCommand(commandlistenerwrapper, serverboundchatcommandpacket.command());
+ try {
+ this.server.server.playerCommandState = true;
+ this.handleCommand(s);
+ this.handleCommand("/" + serverboundchatcommandpacket.command());
+ } finally {
+ this.server.server.playerCommandState = false;
+ }
+ } else if (s.isEmpty()) {
+ this.detectRateSpam(true);
+ // CraftBukkit end
}
}
@@ -1339,7 +1850,7 @@
}
private boolean resetLastActionTime() {
- if (this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
+ if (this.player.isRemoved() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) { // CraftBukkit - dead men tell no tales
IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
@@ -1357,31 +1868,171 @@
boolean flag = packetplayinchat.signedPreview();
ChatDecorator chatdecorator = this.server.getChatDecorator();
- chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAcceptAsync(this::broadcastChatMessage, this.server);
+ chatdecorator.decorateChat(this.player, filteredtext.map(IChatBaseComponent::literal), messagesignature, flag).thenAccept((playerchatmessage) -> broadcastChatMessage(packetplayinchat, playerchatmessage)); // CraftBukkit
}
}
- private void broadcastChatMessage(FilteredText<PlayerChatMessage> filteredtext) {
+ private void broadcastChatMessage(PacketPlayInChat packetplayinchat, FilteredText<PlayerChatMessage> filteredtext) {
if (!((PlayerChatMessage) filteredtext.raw()).verify(this.player)) {
PlayerConnection.LOGGER.warn("{} sent message with invalid signature: '{}'", this.player.getName().getString(), ((PlayerChatMessage) filteredtext.raw()).signedContent().getString());
} else {
- this.server.getPlayerList().broadcastChatMessage(filteredtext, this.player, ChatMessageType.CHAT);
- this.detectRateSpam();
+ // CraftBukkit start
+ String s = packetplayinchat.getMessage();
+ if (s.isEmpty()) {
+ LOGGER.warn(this.player.getScoreboardName() + " tried to send an empty message");
+ } else if (getCraftPlayer().isConversing()) {
+ final String conversationInput = s;
@ -930,50 +955,23 @@
+ }
+ });
+ } else if (this.player.getChatVisibility() == EnumChatVisibility.SYSTEM) { // Re-add "Command Only" flag check
+ this.send(new PacketPlayOutChat((new ChatMessage("chat.cannotSend")).withStyle(EnumChatFormat.RED), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
+ } else if (true) {
+ this.chat(s, true);
+ // CraftBukkit end - the below is for reference. :)
} else {
String s1 = itextfilter_a.getFiltered();
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1});
@@ -1263,28 +1786,198 @@
}, ChatMessageType.CHAT, this.player.getUUID());
}
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(new ChatMessage("disconnect.spam"));
+ // CraftBukkit start - replaced with thread safe throttle
+ // this.chatSpamTickCount += 20;
+ if (chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ if (!isSync) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(new ChatMessage("disconnect.spam"));
+ return null;
+ }
+ };
+ IRegistry<ChatMessageType> iregistry = this.player.level.registryAccess().registryOrThrow(IRegistry.CHAT_TYPE_REGISTRY);
+ int i = iregistry.getId((ChatMessageType) iregistry.get(ChatMessageType.SYSTEM));
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.cannotSend").withStyle(EnumChatFormat.RED), i));
+ } else {
+ this.disconnect(new ChatMessage("disconnect.spam"));
+ this.chat(s, true);
+ }
+ // this.server.getPlayerList().broadcastChatMessage(playerchatmessage, filteredtext, this.player, ChatMessageType.CHAT);
+ this.detectRateSpam(false);
+ // CraftBukkit end
}
}
}
- private void detectRateSpam() {
- this.chatSpamTickCount += 20;
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
- this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ // CraftBukkit start - add method
+ public void chat(String s, boolean async) {
+ if (s.isEmpty() || this.player.getChatVisibility() == EnumChatVisibility.HIDDEN) {
@ -1046,11 +1044,8 @@
+ }
+ }
+ }
+ // CraftBukkit end
+
private void handleCommand(String s) {
- this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s);
+ // CraftBukkit start - whole method
+ private void handleCommand(String s) {
+ this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
+
+ CraftPlayer player = this.getCraftPlayer();
@ -1071,8 +1066,68 @@
+ java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ return;
+ }
+ // this.server.getCommands().performCommand(this.player.createCommandSourceStack(), s);
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - replaced with thread safe throttle
+ private void detectRateSpam(boolean isSync) {
+ // this.chatSpamTickCount += 20;
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
+ if (!isSync) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
+ }
+ // CraftBukkit end
}
}
@Override
public void handleChatPreview(ServerboundChatPreviewPacket serverboundchatpreviewpacket) {
- if (this.server.previewsChat()) {
+ if (false && this.server.previewsChat()) { // CraftBukkit - preview NYI
this.chatPreviewThrottler.schedule(() -> {
int i = serverboundchatpreviewpacket.queryId();
String s = serverboundchatpreviewpacket.query();
@@ -1428,7 +2079,7 @@
CommandContextBuilder<CommandListenerWrapper> commandcontextbuilder1 = commandcontextbuilder.getLastChild();
if (commandcontextbuilder1.getArguments().isEmpty()) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
} else {
List<? extends ParsedCommandNode<?>> list = commandcontextbuilder1.getNodes();
@@ -1445,25 +2096,77 @@
return completablefuture;
}
} catch (CommandSyntaxException commandsyntaxexception) {
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
}
}
}
- return CompletableFuture.completedFuture((Object) null);
+ return CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
}
}
@Override
@ -1140,7 +1195,7 @@
this.player.resetLastActionTime();
IJumpable ijumpable;
@@ -1342,6 +2035,7 @@
@@ -1525,6 +2228,7 @@
@Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
@ -1148,9 +1203,9 @@
WorldServer worldserver = this.player.getLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1356,10 +2050,44 @@
@@ -1537,10 +2241,44 @@
if (this.player.distanceToSqr(entity) < 36.0D) {
if (entity.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
@ -1164,7 +1219,7 @@
+
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859
+ 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)) {
+ send(new PacketPlayOutSpawnEntityLiving((EntityLiving) entity));
+ send(new PacketPlayOutSpawnEntity(entity));
+ player.containerMenu.sendAllDataToRemote();
+ }
+
@ -1194,7 +1249,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
if (enuminteractionresult.shouldSwing()) {
@@ -1371,20 +2099,27 @@
@@ -1552,20 +2290,27 @@
@Override
public void onInteraction(EnumHand enumhand) {
@ -1223,9 +1278,9 @@
+ }
+ // CraftBukkit end
} else {
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
@@ -1429,15 +2164,21 @@
@@ -1610,15 +2355,21 @@
@Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
@ -1249,7 +1304,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else {
int i = packetplayinwindowclick.getSlotNum();
@@ -1448,7 +2189,284 @@
@@ -1629,7 +2380,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -1535,7 +1590,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1484,6 +2502,7 @@
@@ -1665,6 +2693,7 @@
@Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
@ -1543,7 +1598,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
boolean flag = this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
@@ -1514,6 +2533,43 @@
@@ -1695,6 +2724,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1587,15 +1642,15 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
@@ -1536,6 +2592,7 @@
@@ -1717,6 +2783,7 @@
}
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText<String>> list) {
+ if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime();
WorldServer worldserver = this.player.getLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1552,18 +2609,37 @@
@@ -1733,18 +2800,37 @@
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
@ -1611,14 +1666,15 @@
+ String[] lines = new String[4];
+
for (int i = 0; i < list.size(); ++i) {
ITextFilter.a itextfilter_a = (ITextFilter.a) list.get(i);
- FilteredText<IChatBaseComponent> filteredtext = ((FilteredText) list.get(i)).map(IChatBaseComponent::literal);
+ FilteredText<IChatBaseComponent> filteredtext = (list.get(i)).map(IChatBaseComponent::literal); // CraftBukkit - decompile error
if (this.player.isTextFilteringEnabled()) {
- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getFiltered()));
+ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getFiltered())).getString());
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.filteredOrElse(CommonComponents.EMPTY).getString());
} else {
- tileentitysign.setMessage(i, new ChatComponentText(itextfilter_a.getRaw()), new ChatComponentText(itextfilter_a.getFiltered()));
+ lines[i] = EnumChatFormat.stripFormatting(new ChatComponentText(EnumChatFormat.stripFormatting(itextfilter_a.getRaw())).getString());
- tileentitysign.setMessage(i, (IChatBaseComponent) filteredtext.raw(), (IChatBaseComponent) filteredtext.filteredOrElse(CommonComponents.EMPTY));
+ lines[i] = EnumChatFormat.stripFormatting(filteredtext.raw().getString());
}
}
+ SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.player.getBukkitEntity(), lines);
@ -1635,7 +1691,7 @@
tileentitysign.setChanged();
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -1573,6 +2649,7 @@
@@ -1754,6 +2840,7 @@
@Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1643,7 +1699,7 @@
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1587,7 +2664,17 @@
@@ -1768,7 +2855,17 @@
@Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
@ -1662,7 +1718,7 @@
}
@Override
@@ -1596,8 +2683,50 @@
@@ -1777,8 +2874,50 @@
this.player.updateOptions(packetplayinsettings);
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/ServerConnection.java
+++ b/net/minecraft/server/network/ServerConnection.java
@@ -96,14 +96,24 @@
@@ -97,14 +97,24 @@
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);

View File

@ -1,13 +1,12 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -95,6 +95,26 @@
@@ -100,6 +100,25 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
+// CraftBukkit start
+import com.google.common.base.Predicate;
+import java.util.stream.Collectors;
+import net.minecraft.network.protocol.game.PacketPlayOutChat;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.network.LoginListener;
@ -27,7 +26,7 @@
public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -105,14 +125,16 @@
@@ -110,14 +129,16 @@
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server;
@ -47,7 +46,7 @@
public final WorldNBTStorage playerIo;
private boolean doWhiteList;
private final IRegistryCustom.Dimension registryHolder;
@@ -123,13 +145,23 @@
@@ -128,13 +149,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@ -73,7 +72,7 @@
this.server = minecraftserver;
this.registryHolder = iregistrycustom_dimension;
this.maxPlayers = i;
@@ -145,9 +177,15 @@
@@ -150,9 +181,15 @@
usercache.add(gameprofile);
NBTTagCompound nbttagcompound = this.load(entityplayer);
ResourceKey resourcekey;
@ -90,7 +89,7 @@
Logger logger = PlayerList.LOGGER;
Objects.requireNonNull(logger);
@@ -174,7 +212,8 @@
@@ -179,7 +216,8 @@
s1 = networkmanager.getRemoteAddress().toString();
}
@ -100,23 +99,23 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer.loadGameTypes(nbttagcompound);
@@ -184,6 +223,7 @@
@@ -189,6 +227,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat()));
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation()));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
@@ -202,19 +242,66 @@
@@ -207,19 +246,66 @@
} else {
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getDisplayName(), s});
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
}
+ // CraftBukkit start
+ chatmessage.withStyle(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
+ ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(ichatmutablecomponent);
- this.broadcastMessage(chatmessage.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
- this.broadcastSystemMessage(ichatmutablecomponent.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM);
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
this.players.add(entityplayer);
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
@ -140,7 +139,7 @@
+
+ if (joinMessage != null && joinMessage.length() > 0) {
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
+ server.getPlayerList().broadcastAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
+ server.getPlayerList().broadcastSystemMessage(line, ChatMessageType.SYSTEM);
+ }
+ }
+ // CraftBukkit end
@ -178,9 +177,9 @@
+ worldserver1 = entityplayer.getLevel(); // CraftBukkit - Update in case join event changed it
+ // CraftBukkit end
this.sendLevelInfo(entityplayer, worldserver1);
if (!this.server.getResourcePack().isEmpty()) {
entityplayer.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt());
@@ -230,8 +317,11 @@
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
@@ -235,8 +321,11 @@
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@ -194,7 +193,7 @@
});
if (entity != null) {
@@ -274,6 +364,8 @@
@@ -279,6 +368,8 @@
}
entityplayer.initInventoryMenu();
@ -203,7 +202,7 @@
}
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -306,30 +398,31 @@
@@ -311,30 +402,31 @@
}
public void addWorldborderListener(WorldServer worldserver) {
@ -240,7 +239,7 @@
}
@Override
@@ -357,14 +450,15 @@
@@ -362,14 +454,15 @@
}
protected void save(EntityPlayer entityplayer) {
@ -258,7 +257,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -372,10 +466,24 @@
@@ -377,10 +470,24 @@
}
@ -284,7 +283,7 @@
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -399,18 +507,66 @@
@@ -404,18 +511,66 @@
if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid);
@ -319,12 +318,12 @@
- @Nullable
- public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
ChatMessage chatmessage;
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, ProfilePublicKey profilepublickey, String hostname) {
IChatMutableComponent ichatmutablecomponent;
- if (this.bans.isBanned(gameprofile)) {
+ // Moved from processLogin
+ UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
+ UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
+ List<EntityPlayer> list = Lists.newArrayList();
+
+ EntityPlayer entityplayer;
@ -341,7 +340,7 @@
+ while (iterator.hasNext()) {
+ entityplayer = (EntityPlayer) iterator.next();
+ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
+ entityplayer.connection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
+ entityplayer.connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.duplicate_login"));
+ }
+
+ // Instead of kicking then returning, we need to store the kick reason
@ -349,40 +348,40 @@
+ // depending on the outcome.
+ SocketAddress socketaddress = loginlistener.connection.getRemoteAddress();
+
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile);
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile, profilepublickey);
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+
+ if (getBans().isBanned(gameprofile) && !getBans().get(gameprofile).hasExpired()) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
@@ -418,10 +574,12 @@
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})));
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -423,10 +578,12 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
}
- return chatmessage;
- return ichatmutablecomponent;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else if (!this.isWhiteListed(gameprofile)) {
- return new ChatMessage("multiplayer.disconnect.not_whitelisted");
- return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
- } else if (this.ipBans.isBanned(socketaddress)) {
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent));
+ } else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
@@ -429,13 +587,25 @@
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())})));
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -434,13 +591,25 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
}
- return chatmessage;
- return ichatmutablecomponent;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
} else {
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("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;
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
@ -396,16 +395,16 @@
+ return entity;
}
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) {
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile, @Nullable ProfilePublicKey profilepublickey) {
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
+ /* CraftBukkit startMoved up
UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
List<EntityPlayer> list = Lists.newArrayList();
@@ -462,14 +632,24 @@
@@ -467,14 +636,24 @@
}
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
return new EntityPlayer(this.server, this.server.overworld(), gameprofile, profilepublickey);
+ */
+ return player;
+ // CraftBukkit end
@ -427,10 +426,10 @@
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
Optional optional;
@@ -481,6 +661,11 @@
@@ -486,6 +665,11 @@
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.getProfilePublicKey());
+ // */
+ EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
@ -439,7 +438,7 @@
entityplayer1.connection = entityplayer.connection;
entityplayer1.restoreFrom(entityplayer, flag);
@@ -496,49 +681,110 @@
@@ -501,49 +685,110 @@
boolean flag2 = false;
@ -520,7 +519,7 @@
}
+ // CraftBukkit start
+ WorldData worlddata = worldserver1.getLevelData();
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeRegistration(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag));
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag, entityplayer1.getLastDeathLocation()));
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.unsetRemoved();
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
@ -528,7 +527,7 @@
- WorldData worlddata = entityplayer1.level.getLevelData();
-
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeRegistration(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag));
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionTypeId(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag, entityplayer1.getLastDeathLocation()));
- 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.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
@ -548,7 +547,7 @@
+ // entityplayer1.initInventoryMenu();
entityplayer1.setHealth(entityplayer1.getHealth());
if (flag2) {
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F, worldserver1.getRandom().nextLong()));
}
+ // Added from changeDimension
+ sendAllPlayerInfo(entityplayer); // Update health, etc...
@ -574,7 +573,7 @@
return entityplayer1;
}
@@ -551,7 +797,18 @@
@@ -556,7 +801,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@ -594,7 +593,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -568,6 +825,25 @@
@@ -573,6 +829,25 @@
}
@ -620,7 +619,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -646,7 +922,7 @@
@@ -651,7 +926,7 @@
}
public void deop(GameProfile gameprofile) {
@ -629,7 +628,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -670,6 +946,7 @@
@@ -675,6 +950,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@ -637,7 +636,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -702,6 +979,12 @@
@@ -707,6 +983,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -650,7 +649,7 @@
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -741,23 +1024,34 @@
@@ -746,23 +1028,34 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@ -690,12 +689,12 @@
}
public int getPlayerCount() {
@@ -813,12 +1107,22 @@
@@ -818,12 +1111,22 @@
}
public void removeAll() {
- for (int i = 0; i < this.players.size(); ++i) {
- ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
- ((EntityPlayer) this.players.get(i)).connection.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.server_shutdown"));
+ // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) {
+ player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
@ -707,15 +706,15 @@
+ // CraftBukkit start
+ public void broadcastMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) {
+ broadcastMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
+ broadcastSystemMessage(component, ChatMessageType.SYSTEM);
+ }
+ }
+ // CraftBukkit end
+
public void broadcastMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
this.server.sendMessage(ichatbasecomponent, uuid);
Iterator iterator = this.players.iterator();
@@ -846,16 +1150,23 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, ResourceKey<ChatMessageType> resourcekey) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -883,16 +1186,23 @@
}
@ -743,7 +742,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -864,7 +1175,7 @@
@@ -901,7 +1211,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@ -752,7 +751,7 @@
}
return serverstatisticmanager;
@@ -872,14 +1183,14 @@
@@ -909,14 +1219,14 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@ -769,7 +768,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -930,13 +1241,20 @@
@@ -967,13 +1277,20 @@
}
public void reloadResources() {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
@@ -36,6 +36,17 @@
@@ -34,6 +34,17 @@
return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
}
@ -16,5 +16,5 @@
+ // CraftBukkit end
+
@Override
public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
this.buffer.append(ichatbasecomponent.getString());

View File

@ -0,0 +1,29 @@
--- a/net/minecraft/util/SpawnUtil.java
+++ b/net/minecraft/util/SpawnUtil.java
@@ -18,6 +18,12 @@
public SpawnUtil() {}
public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EnumMobSpawn enummobspawn, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) {
+ // CraftBukkit start
+ return trySpawnMob(entitytypes, enummobspawn, worldserver, blockposition, i, j, k, spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EnumMobSpawn enummobspawn, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ // CraftBukkit end
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
for (int l = 0; l < i; ++l) {
@@ -26,11 +32,11 @@
blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1);
if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) {
- T t0 = (EntityInsentient) entitytypes.create(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition_mutableblockposition, enummobspawn, false, false);
+ T t0 = entitytypes.create(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition_mutableblockposition, enummobspawn, false, false); // CraftBukkit - decompile error
if (t0 != null) {
if (t0.checkSpawnRules(worldserver, enummobspawn) && t0.checkSpawnObstruction(worldserver)) {
- worldserver.addFreshEntityWithPassengers(t0);
+ worldserver.addFreshEntityWithPassengers(t0, reason); // CraftBukkit
return Optional.of(t0);
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/util/datafix/DataConverterRegistry.java
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java
@@ -395,6 +395,18 @@
@@ -436,6 +436,18 @@
datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false));
Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED);
@ -19,7 +19,7 @@
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false));
@@ -711,12 +723,14 @@
@@ -753,12 +765,14 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Squid", DataConverterTypes.ENTITY));
datafixerbuilder.addFixer(new DataConverterAddChoices(schema131, "Added Glow Item Frame", DataConverterTypes.ENTITY));
Schema schema132 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED);
@ -36,7 +36,7 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Rename copper item suffixes", createRenamer(immutablemap1)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
@@ -724,7 +738,8 @@
@@ -766,7 +780,8 @@
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema134, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
Schema schema135 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
@ -46,3 +46,27 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema135, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema135, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2)));
@@ -853,10 +868,11 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema160, "Added Allay", DataConverterTypes.ENTITY));
Schema schema161 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED);
- datafixerbuilder.addFixer(new SimpleRenameFix(schema161, DataConverterTypes.GAME_EVENT_NAME, 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
+ datafixerbuilder.addFixer(new SimpleRenameFix(schema161, DataConverterTypes.GAME_EVENT_NAME, 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 schema162 = datafixerbuilder.addSchema(3086, DataConverterRegistry.SAME_NAMESPACED);
TypeReference typereference = DataConverterTypes.ENTITY;
- Int2ObjectOpenHashMap int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> {
+ Int2ObjectOpenHashMap<String> int2objectopenhashmap = (Int2ObjectOpenHashMap) SystemUtils.make(new Int2ObjectOpenHashMap(), (int2objectopenhashmap1) -> { // CraftBukkit - decompile error
int2objectopenhashmap1.defaultReturnValue("minecraft:tabby");
int2objectopenhashmap1.put(0, "minecraft:tabby");
int2objectopenhashmap1.put(1, "minecraft:black");
@@ -873,7 +889,8 @@
Objects.requireNonNull(int2objectopenhashmap);
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();
+ // 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();
datafixerbuilder.addFixer(new CriteriaRenameFix(schema162, "Migrate cat variant advancement", "minecraft:husbandry/complete_catalogue", (s) -> {
return (String) immutablemap3.getOrDefault(s, s);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -38,6 +38,10 @@
@@ -40,6 +40,10 @@
import net.minecraft.world.level.storage.WorldPersistentData;
import org.slf4j.Logger;
@ -11,16 +11,16 @@
public class WorldUpgrader {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -53,7 +57,7 @@
@@ -55,7 +59,7 @@
private volatile int totalChunks;
private volatile int converted;
private volatile int skipped;
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy()));
+ private final Object2FloatMap<ResourceKey<WorldDimension>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit
private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting");
private volatile IChatBaseComponent status = IChatBaseComponent.translatable("optimizeWorld.stage.counting");
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
private final WorldPersistentData overworldDataStorage;
@@ -86,13 +90,13 @@
@@ -88,13 +92,13 @@
private void work() {
this.totalChunks = 0;
@ -37,7 +37,7 @@
list = this.getAllChunkPos(resourcekey);
builder.put(resourcekey, list.listIterator());
@@ -102,18 +106,18 @@
@@ -104,18 +108,18 @@
this.finished = true;
} else {
float f = (float) this.totalChunks;
@ -60,8 +60,8 @@
+ ImmutableMap<ResourceKey<WorldDimension>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
long i = SystemUtils.getMillis();
this.status = new ChatMessage("optimizeWorld.stage.upgrading");
@@ -125,7 +129,7 @@
this.status = IChatBaseComponent.translatable("optimizeWorld.stage.upgrading");
@@ -127,7 +131,7 @@
float f2;
for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
@ -70,7 +70,7 @@
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
@@ -138,10 +142,10 @@
@@ -140,10 +144,10 @@
if (nbttagcompound != null) {
int j = IChunkLoader.getVersion(nbttagcompound);
@ -83,7 +83,7 @@
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
@@ -213,8 +217,8 @@
@@ -223,8 +227,8 @@
}
}
@ -94,7 +94,7 @@
File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> {
return s.endsWith(".mca");
@@ -274,7 +278,7 @@
@@ -284,7 +288,7 @@
}
public ImmutableSet<ResourceKey<World>> levels() {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/IInventory.java
+++ b/net/minecraft/world/IInventory.java
@@ -5,6 +5,11 @@
@@ -6,6 +6,11 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -12,7 +12,7 @@
public interface IInventory extends Clearable {
int LARGE_MAX_STACK_SIZE = 64;
@@ -21,9 +26,7 @@
@@ -22,9 +27,7 @@
void setItem(int i, ItemStack itemstack);
@ -23,7 +23,7 @@
void setChanged();
@@ -62,4 +65,29 @@
@@ -69,4 +72,29 @@
return false;
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java
+++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java
@@ -38,4 +38,10 @@
@@ -37,4 +37,10 @@
return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? new ChatMessage(s1, new Object[]{entityliving.getDisplayName(), ichatbasecomponent, itemstack.getDisplayName()}) : new ChatMessage(s, new Object[]{entityliving.getDisplayName(), ichatbasecomponent});
return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? IChatBaseComponent.translatable(s1, entityliving.getDisplayName(), ichatbasecomponent, itemstack.getDisplayName()) : IChatBaseComponent.translatable(s, entityliving.getDisplayName(), ichatbasecomponent);
}
+
+ // CraftBukkit start

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/effect/MobEffectList.java
+++ b/net/minecraft/world/effect/MobEffectList.java
@@ -19,6 +19,13 @@
@@ -20,6 +20,13 @@
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.EntityHuman;
@ -14,7 +14,7 @@
public class MobEffectList {
private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap();
@@ -44,26 +51,37 @@
@@ -56,26 +63,37 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
@ -57,7 +57,7 @@
}
}
@@ -84,7 +102,7 @@
@@ -96,7 +114,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);

View File

@ -0,0 +1,23 @@
--- a/net/minecraft/world/effect/MobEffectUtil.java
+++ b/net/minecraft/world/effect/MobEffectUtil.java
@@ -48,13 +48,19 @@
}
public static List<EntityPlayer> addEffectToPlayersAround(WorldServer worldserver, @Nullable Entity entity, Vec3D vec3d, double d0, MobEffect mobeffect, int i) {
+ // CraftBukkit start
+ return addEffectToPlayersAround(worldserver, entity, vec3d, d0, mobeffect, i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
+ }
+
+ public static List<EntityPlayer> addEffectToPlayersAround(WorldServer worldserver, @Nullable Entity entity, Vec3D vec3d, double d0, MobEffect mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
+ // CraftBukkit end
MobEffectList mobeffectlist = mobeffect.getEffect();
List<EntityPlayer> list = worldserver.getPlayers((entityplayer) -> {
return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).getDuration() < i);
});
list.forEach((entityplayer) -> {
- entityplayer.addEffect(new MobEffect(mobeffect), entity);
+ entityplayer.addEffect(new MobEffect(mobeffect), entity, cause); // CraftBukkit
});
return list;
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/effect/MobEffects.java
+++ b/net/minecraft/world/effect/MobEffects.java
@@ -65,6 +65,14 @@
});
public static final MobEffectList HERO_OF_THE_VILLAGE = register(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796));
@@ -69,6 +69,14 @@
return new MobEffect.a(22);
}));
+ // CraftBukkit start
+ static {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -119,8 +119,64 @@
@@ -122,8 +122,64 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@ -65,7 +65,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -231,6 +287,24 @@
@@ -234,6 +290,24 @@
public boolean hasVisualFire;
@Nullable
private IBlockData feetBlockState;
@ -90,7 +90,7 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -369,6 +443,12 @@
@@ -365,6 +439,12 @@
public void onClientRemoval() {}
public void setPose(EntityPose entitypose) {
@ -103,7 +103,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -385,6 +465,33 @@
@@ -389,6 +469,33 @@
}
protected void setRot(float f, float f1) {
@ -137,7 +137,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -426,6 +533,15 @@
@@ -430,6 +537,15 @@
this.baseTick();
}
@ -153,7 +153,7 @@
public void baseTick() {
this.level.getProfiler().push("entityBaseTick");
this.feetBlockState = null;
@@ -440,7 +556,7 @@
@@ -444,7 +560,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@ -162,7 +162,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -475,6 +591,10 @@
@@ -479,6 +595,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@ -173,7 +173,7 @@
}
this.checkOutOfWorld();
@@ -518,15 +638,48 @@
@@ -522,15 +642,48 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@ -223,7 +223,7 @@
int j = i * 20;
if (this instanceof EntityLiving) {
@@ -640,6 +793,28 @@
@@ -644,6 +797,28 @@
block.updateEntityAfterFallOn(this.level, this);
}
@ -249,10 +249,10 @@
+ }
+ // CraftBukkit end
+
if (this.onGround && !this.isSteppingCarefully()) {
if (this.onGround) {
block.stepOn(this.level, blockposition, iblockdata, this);
}
@@ -1265,6 +1440,7 @@
@@ -1295,6 +1470,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@ -260,7 +260,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1455,6 +1631,12 @@
@@ -1485,6 +1661,12 @@
return false;
}
@ -273,7 +273,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1488,7 +1670,7 @@
@@ -1518,7 +1700,7 @@
} else {
String s = this.getEncodeId();
@ -282,7 +282,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1513,6 +1695,18 @@
@@ -1543,6 +1725,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@ -301,7 +301,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1521,6 +1715,22 @@
@@ -1551,6 +1745,22 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@ -324,7 +324,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1588,6 +1798,11 @@
@@ -1618,6 +1828,11 @@
}
}
@ -336,7 +336,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1669,6 +1884,44 @@
@@ -1699,6 +1914,44 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@ -381,7 +381,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1744,9 +1997,22 @@
@@ -1774,9 +2027,22 @@
} else if (this.level.isClientSide) {
return null;
} else {
@ -404,7 +404,7 @@
this.level.addFreshEntity(entityitem);
return entityitem;
}
@@ -1840,7 +2106,7 @@
@@ -1870,7 +2136,7 @@
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@ -413,7 +413,7 @@
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -1871,7 +2137,7 @@
@@ -1901,7 +2167,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -422,7 +422,7 @@
}
}
@@ -1880,10 +2146,31 @@
@@ -1910,10 +2176,31 @@
this.removeVehicle();
}
@ -455,7 +455,7 @@
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -1899,12 +2186,32 @@
@@ -1929,12 +2216,32 @@
}
}
@ -489,7 +489,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -1915,6 +2222,7 @@
@@ -1945,6 +2252,7 @@
entity.boardingCooldown = 60;
}
@ -497,7 +497,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -1977,14 +2285,20 @@
@@ -2007,14 +2315,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@ -521,7 +521,7 @@
this.level.getProfiler().pop();
}
@@ -2102,6 +2416,13 @@
@@ -2132,6 +2446,13 @@
}
public void setSwimming(boolean flag) {
@ -535,7 +535,7 @@
this.setSharedFlag(4, flag);
}
@@ -2150,8 +2471,12 @@
@@ -2177,8 +2498,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@ -549,7 +549,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2170,7 +2495,7 @@
@@ -2197,7 +2522,7 @@
}
public int getMaxAirSupply() {
@ -558,7 +558,7 @@
}
public int getAirSupply() {
@@ -2178,7 +2503,18 @@
@@ -2205,7 +2530,18 @@
}
public void setAirSupply(int i) {
@ -578,7 +578,7 @@
}
public int getTicksFrozen() {
@@ -2205,11 +2541,41 @@
@@ -2232,11 +2568,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -622,7 +622,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2365,15 +2731,38 @@
@@ -2394,15 +2760,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@ -663,7 +663,7 @@
this.level.getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2382,9 +2771,17 @@
@@ -2411,9 +2800,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@ -683,7 +683,7 @@
}
this.removeAfterChangingDimensions();
@@ -2405,20 +2802,34 @@
@@ -2434,20 +2831,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -723,7 +723,7 @@
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2435,8 +2846,8 @@
@@ -2464,8 +2875,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@ -734,7 +734,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2446,8 +2857,15 @@
@@ -2475,8 +2886,15 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@ -751,7 +751,7 @@
}
}
@@ -2455,8 +2873,23 @@
@@ -2484,8 +2902,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@ -777,7 +777,7 @@
}
public boolean canChangeDimensions() {
@@ -2665,7 +3098,26 @@
@@ -2694,7 +3127,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -805,7 +805,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -2949,6 +3401,11 @@
@@ -2982,6 +3434,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -72,6 +72,19 @@
@@ -75,6 +75,19 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.level.storage.loot.LootTableInfo;
@ -20,7 +20,7 @@
public abstract class EntityInsentient extends EntityLiving {
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -116,6 +129,8 @@
@@ -121,6 +134,8 @@
private BlockPosition restrictCenter;
private float restrictRadius;
@ -29,7 +29,7 @@
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -141,6 +156,12 @@
@@ -146,6 +161,12 @@
}
@ -42,7 +42,7 @@
protected void registerGoals() {}
public static AttributeProvider.Builder createMobAttributes() {
@@ -219,7 +240,38 @@
@@ -224,7 +245,38 @@
}
public void setTarget(@Nullable EntityLiving entityliving) {
@ -81,7 +81,7 @@
}
@Override
@@ -446,16 +498,26 @@
@@ -453,16 +505,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@ -110,7 +110,7 @@
NBTTagList nbttaglist;
int i;
@@ -502,6 +564,11 @@
@@ -509,6 +571,11 @@
}
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
@ -122,7 +122,7 @@
}
@Override
@@ -565,7 +632,7 @@
@@ -577,7 +644,7 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@ -131,7 +131,7 @@
this.onItemPickup(entityitem);
this.take(entityitem, itemstack.getCount());
entityitem.discard();
@@ -574,15 +641,29 @@
@@ -586,15 +653,29 @@
}
public boolean equipItemIfPossible(ItemStack itemstack) {
@ -162,7 +162,7 @@
}
this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack);
@@ -721,6 +802,7 @@
@@ -732,6 +813,7 @@
@Override
protected final void serverAiStep() {
++this.noActionTime;
@ -170,7 +170,7 @@
this.level.getProfiler().push("sensing");
this.sensing.tick();
this.level.getProfiler().pop();
@@ -1116,6 +1198,12 @@
@@ -1125,6 +1207,12 @@
if (!this.isAlive()) {
return EnumInteractionResult.PASS;
} else if (this.getLeashHolder() == entityhuman) {
@ -183,7 +183,7 @@
this.dropLeash(true, !entityhuman.getAbilities().instabuild);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
} else {
@@ -1134,6 +1222,12 @@
@@ -1148,6 +1236,12 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
@ -196,7 +196,7 @@
this.setLeashedTo(entityhuman, true);
itemstack.shrink(1);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
@@ -1149,7 +1243,7 @@
@@ -1163,7 +1257,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
@ -205,7 +205,7 @@
optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1199,12 +1293,19 @@
@@ -1213,12 +1307,19 @@
return this.restrictRadius != -1.0F;
}
@ -226,7 +226,7 @@
t0.copyPosition(this);
t0.setBaby(this.isBaby());
@@ -1236,7 +1337,12 @@
@@ -1250,7 +1351,12 @@
}
}
@ -240,7 +240,7 @@
if (this.isPassenger()) {
Entity entity = this.getVehicle();
@@ -1256,6 +1362,7 @@
@@ -1270,6 +1376,7 @@
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
@ -248,7 +248,7 @@
this.dropLeash(true, true);
}
@@ -1267,7 +1374,9 @@
@@ -1281,7 +1388,9 @@
this.leashHolder = null;
this.leashInfoTag = null;
if (!this.level.isClientSide && flag1) {
@ -258,7 +258,7 @@
}
if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
@@ -1317,6 +1426,7 @@
@@ -1331,6 +1440,7 @@
boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) {
@ -266,7 +266,7 @@
this.dropLeash(true, true);
}
@@ -1341,7 +1451,9 @@
@@ -1355,7 +1465,9 @@
}
if (this.tickCount > 100) {
@ -276,7 +276,7 @@
this.leashInfoTag = null;
}
}
@@ -1412,7 +1524,14 @@
@@ -1432,7 +1544,14 @@
int i = EnchantmentManager.getFireAspect(this);
if (i > 0) {
@ -292,7 +292,7 @@
}
boolean flag = entity.hurt(DamageSource.mobAttack(this), f);
@@ -1480,9 +1599,10 @@
@@ -1500,9 +1619,10 @@
@Override
protected void removeAfterChangingDimensions() {
super.removeAfterChangingDimensions();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLiving.java
+++ b/net/minecraft/world/entity/EntityLiving.java
@@ -117,6 +117,30 @@
@@ -118,6 +118,30 @@
import net.minecraft.world.scores.ScoreboardTeam;
import org.slf4j.Logger;
@ -31,10 +31,10 @@
public abstract class EntityLiving extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -226,6 +250,20 @@
private float swimAmount;
@@ -228,6 +252,20 @@
private float swimAmountO;
protected BehaviorController<?> brain;
private boolean skipDropExperience;
+ // CraftBukkit start
+ public int expToDrop;
+ public boolean forceDrops;
@ -52,7 +52,7 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world);
@@ -238,7 +276,9 @@
@@ -240,7 +278,9 @@
this.useItem = ItemStack.EMPTY;
this.lastClimbablePos = Optional.empty();
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
@ -63,7 +63,7 @@
this.blocksBuilding = true;
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.reapplyPosition();
@@ -305,7 +345,13 @@
@@ -307,7 +347,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1);
@ -78,24 +78,25 @@
}
}
@@ -655,9 +701,15 @@
@@ -661,10 +707,16 @@
}
protected void equipEventAndSound(ItemStack itemstack) {
public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) {
+ // CraftBukkit start
+ this.equipEventAndSound(itemstack, false);
+ onEquipItem(enumitemslot, itemstack, itemstack1, false);
+ }
+
+ protected void equipEventAndSound(ItemStack itemstack, boolean silent) {
SoundEffect soundeffect = itemstack.getEquipSound();
- if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator()) {
+ if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator() && !silent) {
+ public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
+ // CraftBukkit end
this.gameEvent(GameEvent.EQUIP);
this.playSound(soundeffect, 1.0F, 1.0F);
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
if (!flag && !ItemStack.isSameIgnoreDurability(itemstack, itemstack1)) {
- if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
+ if (enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !silent) { // CraftBukkit
this.playEquipSound(itemstack1);
}
@@ -719,6 +771,17 @@
@@ -742,6 +794,17 @@
}
}
@ -113,7 +114,7 @@
if (nbttagcompound.contains("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
@@ -756,9 +819,32 @@
@@ -779,9 +842,32 @@
}
@ -146,7 +147,7 @@
try {
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
@@ -768,6 +854,12 @@
@@ -791,6 +877,12 @@
this.onEffectUpdated(mobeffect, true, (Entity) null);
})) {
if (!this.level.isClientSide) {
@ -159,7 +160,7 @@
iterator.remove();
this.onEffectRemoved(mobeffect);
}
@@ -778,6 +870,17 @@
@@ -801,6 +893,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@ -177,7 +178,7 @@
if (this.effectsDirty) {
if (!this.level.isClientSide) {
@@ -904,7 +1007,13 @@
@@ -927,7 +1030,13 @@
this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0);
}
@ -191,7 +192,7 @@
if (this.level.isClientSide) {
return false;
} else {
@@ -913,7 +1022,14 @@
@@ -936,7 +1045,14 @@
boolean flag;
for (flag = false; iterator.hasNext(); flag = true) {
@ -207,7 +208,7 @@
iterator.remove();
}
@@ -942,18 +1058,48 @@
@@ -965,18 +1081,48 @@
return this.addEffect(mobeffect, (Entity) null);
}
@ -257,7 +258,7 @@
return true;
} else {
return false;
@@ -990,13 +1136,39 @@
@@ -1013,13 +1159,39 @@
return this.getMobType() == EnumMonsterType.UNDEAD;
}
@ -298,7 +299,7 @@
if (mobeffect != null) {
this.onEffectRemoved(mobeffect);
@@ -1033,20 +1205,55 @@
@@ -1056,20 +1228,55 @@
}
@ -355,7 +356,7 @@
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
}
@@ -1060,7 +1267,7 @@
@@ -1083,7 +1290,7 @@
return false;
} else if (this.level.isClientSide) {
return false;
@ -364,7 +365,7 @@
return false;
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
@@ -1071,10 +1278,11 @@
@@ -1094,10 +1301,11 @@
this.noActionTime = 0;
float f1 = f;
@ -378,7 +379,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1092,27 +1300,46 @@
@@ -1115,27 +1323,46 @@
this.animationSpeed = 1.5F;
boolean flag1 = true;
@ -430,7 +431,7 @@
this.hurtDir = 0.0F;
Entity entity1 = damagesource.getEntity();
@@ -1235,19 +1462,29 @@
@@ -1258,19 +1485,29 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@ -464,7 +465,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1255,14 +1492,16 @@
@@ -1278,14 +1515,16 @@
}
this.setHealth(1.0F);
@ -486,7 +487,7 @@
}
}
@@ -1367,14 +1606,22 @@
@@ -1390,14 +1629,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
@ -511,7 +512,7 @@
this.level.addFreshEntity(entityitem);
}
}
@@ -1394,21 +1641,40 @@
@@ -1417,21 +1664,40 @@
boolean flag = this.lastHurtByPlayerTime > 0;
@ -535,9 +536,9 @@
- protected void dropExperience() {
+ // CraftBukkit start
+ public int getExpReward() {
if (this.level instanceof WorldServer && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.getExperienceReward(this.lastHurtByPlayer));
+ int i = this.getExperienceReward(this.lastHurtByPlayer);
if (this.level instanceof WorldServer && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.getExperienceReward());
+ int i = this.getExperienceReward();
+ return i;
+ } else {
+ return 0;
@ -555,7 +556,7 @@
}
@@ -1528,9 +1794,14 @@
@@ -1559,9 +1825,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
@ -571,7 +572,7 @@
return true;
} else {
return flag;
@@ -1579,7 +1850,7 @@
@@ -1610,7 +1881,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.isBypassArmor()) {
@ -580,7 +581,7 @@
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1592,7 +1863,8 @@
@@ -1623,7 +1894,8 @@
} else {
int i;
@ -590,7 +591,7 @@
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1623,29 +1895,172 @@
@@ -1656,29 +1928,172 @@
}
}
@ -744,7 +745,7 @@
+ if (!human) {
+ this.setAbsorptionAmount(this.getAbsorptionAmount() - f);
+ }
this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
this.gameEvent(GameEvent.ENTITY_DAMAGE);
+
+ return true;
+ } else {
@ -773,7 +774,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1666,8 +2081,18 @@
@@ -1699,8 +2114,18 @@
}
public final void setArrowCount(int i) {
@ -793,7 +794,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
@@ -1963,6 +2388,12 @@
@@ -1996,6 +2421,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@ -806,7 +807,7 @@
@Override
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -2206,6 +2637,7 @@
@@ -2239,6 +2670,7 @@
}
if (this.onGround && !this.level.isClientSide) {
@ -814,7 +815,7 @@
this.setSharedFlag(7, false);
}
} else {
@@ -2736,6 +3168,7 @@
@@ -2769,6 +3201,7 @@
}
if (!this.level.isClientSide) {
@ -822,7 +823,7 @@
this.setSharedFlag(7, flag);
}
@@ -2895,14 +3328,21 @@
@@ -2928,14 +3361,21 @@
@Override
public boolean isPickable() {
@ -846,7 +847,7 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3096,7 +3536,25 @@
@@ -3130,7 +3570,25 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
@ -873,7 +874,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3169,6 +3627,12 @@
@@ -3208,6 +3666,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@ -886,7 +887,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3193,16 +3657,41 @@
@@ -3232,16 +3696,41 @@
}
if (flag2) {
@ -931,7 +932,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3212,7 +3701,7 @@
@@ -3251,7 +3740,7 @@
((EntityCreature) this).getNavigation().stop();
}
@ -940,7 +941,7 @@
}
}
@@ -3295,7 +3784,7 @@
@@ -3334,7 +3823,7 @@
}
public void stopSleeping() {
@ -949,7 +950,7 @@
World world = this.level;
java.util.Objects.requireNonNull(this.level);
@@ -3327,7 +3816,7 @@
@@ -3366,7 +3855,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@ -958,7 +959,7 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
}
@@ -3376,7 +3865,7 @@
@@ -3414,7 +3903,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
@ -967,23 +968,3 @@
}
}
}
@@ -3479,8 +3968,10 @@
this.setDeltaMovement((double) ((float) packetplayoutspawnentityliving.getXd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getYd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getZd() / 8000.0F));
}
- public static record a(SoundEffect a, SoundEffect b) {
+ // CraftBukkit start - decompile error
+ public static record a(SoundEffect small, SoundEffect big) {
+ /*
private final SoundEffect small;
private final SoundEffect big;
@@ -3496,5 +3987,7 @@
public SoundEffect big() {
return this.big;
}
+ */
+ // CraftBukkit end
}
}

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/EntityTypes.java
+++ b/net/minecraft/world/entity/EntityTypes.java
@@ -154,7 +154,7 @@
public static final String ENTITY_TAG = "EntityTag";
@@ -159,7 +159,7 @@
private final Holder.c<EntityTypes<?>> builtInRegistryHolder;
private static final float MAGIC_HORSE_WIDTH = 1.3964844F;
public static final EntityTypes<Allay> ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).clientTrackingRange(8).updateInterval(2));
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20));
public static final EntityTypes<Axolotl> AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10));
@@ -284,8 +284,8 @@
@@ -293,8 +293,8 @@
private MinecraftKey lootTable;
private final EntitySize dimensions;
@ -20,7 +20,7 @@
}
public static MinecraftKey getKey(EntityTypes<?> entitytypes) {
@@ -317,10 +317,18 @@
@@ -326,10 +326,18 @@
@Nullable
public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
@ -40,7 +40,7 @@
}
return t0;
@@ -356,7 +364,7 @@
@@ -365,7 +373,7 @@
t0.setCustomName(ichatbasecomponent);
}
@ -49,7 +49,7 @@
return t0;
}
}
@@ -513,7 +521,7 @@
@@ -512,7 +520,7 @@
}
return entity;
@ -58,7 +58,7 @@
}
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) {
@@ -570,7 +578,7 @@
@@ -569,7 +577,7 @@
@Nullable
public T tryCast(Entity entity) {
@ -67,7 +67,7 @@
}
@Override
@@ -603,7 +611,7 @@
@@ -602,7 +610,7 @@
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
}

View File

@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/ai/attributes/AttributeRanged.java
+++ b/net/minecraft/world/entity/ai/attributes/AttributeRanged.java
@@ -30,6 +30,8 @@
@Override
public double sanitizeValue(double d0) {
+ if (d0 != d0) return getDefaultValue(); // CraftBukkit
+
d0 = MathHelper.clamp(d0, this.minValue, this.maxValue);
return d0;
}

View File

@ -13,7 +13,7 @@
public class BehaviorAttackTargetForget<E extends EntityInsentient> extends Behavior<E> {
private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200;
@@ -77,6 +83,17 @@
@@ -83,6 +89,17 @@
}
protected void clearAttackTarget(E e0) {
@ -28,6 +28,6 @@
+ return;
+ }
+ // CraftBukkit end
this.onTargetErased.accept(e0);
this.onTargetErased.accept(e0, this.getAttackTarget(e0));
e0.getBrain().eraseMemory(MemoryModuleType.ATTACK_TARGET);
}

View File

@ -14,17 +14,17 @@
public class BehaviorAttackTargetSet<E extends EntityInsentient> extends Behavior<E> {
private final Predicate<E> canAttackPredicate;
@@ -38,13 +45,21 @@
@@ -42,13 +49,21 @@
}
protected void start(WorldServer worldserver, E e0, long i) {
- ((Optional) this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> {
+ (this.targetFinderFunction.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error
this.setAttackTarget(e0, entityliving);
setAttackTarget(e0, entityliving);
});
}
private void setAttackTarget(E e0, EntityLiving entityliving) {
public static <E extends EntityInsentient> void setAttackTarget(E e0, EntityLiving entityliving) {
- e0.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving);
+ // CraftBukkit start
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY);

View File

@ -23,7 +23,7 @@
if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) {
MinecraftServer minecraftserver = worldserver.getServer();
@@ -40,7 +46,14 @@
return villagerprofession.getJobPoiType() == villageplacetype;
return villagerprofession.heldJobSite().test(holder);
}).findFirst();
}).ifPresent((villagerprofession) -> {
- entityvillager.setVillagerData(entityvillager.getVillagerData().setProfession(villagerprofession));

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -79,8 +79,8 @@
@@ -80,8 +80,8 @@
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
@ -11,7 +11,7 @@
}
}
@@ -100,7 +100,11 @@
@@ -101,7 +101,11 @@
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
@ -24,40 +24,45 @@
}
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
@@ -111,19 +115,28 @@
boolean flag = false;
@@ -114,27 +118,30 @@
if (!itemstack.isEmpty()) {
IBlockData iblockdata1;
+ // CraftBukkit start
+ Block planted = null;
if (itemstack.is(Items.WHEAT_SEEDS)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.WHEAT.defaultBlockState(), 3);
+ planted = Blocks.WHEAT;
iblockdata1 = Blocks.WHEAT.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.POTATO)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.POTATOES.defaultBlockState(), 3);
+ planted = Blocks.POTATOES;
iblockdata1 = Blocks.POTATOES.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.CARROT)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.CARROTS.defaultBlockState(), 3);
+ planted = Blocks.CARROTS;
iblockdata1 = Blocks.CARROTS.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.BEETROOT_SEEDS)) {
- worldserver.setBlock(this.aboveFarmlandPos, Blocks.BEETROOTS.defaultBlockState(), 3);
+ planted = Blocks.BEETROOTS;
flag = true;
}
iblockdata1 = Blocks.BEETROOTS.defaultBlockState();
+ flag = true;
+ } else {
+ iblockdata1 = null;
+ }
+
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, planted.defaultBlockState()).isCancelled()) {
+ worldserver.setBlock(this.aboveFarmlandPos, planted.defaultBlockState(), 3);
+ if (iblockdata1 != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
- flag = true;
+ } else {
+ flag = false;
+ }
}
+ // CraftBukkit end
}
if (flag) {
@@ -142,8 +155,8 @@
@@ -153,8 +160,8 @@
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
if (this.aboveFarmlandPos != null) {
this.nextOkStartTime = i + 20L;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
@@ -112,11 +112,16 @@
@@ -116,11 +116,16 @@
if (entityvillager2 == null) {
return Optional.empty();
} else {
@ -20,7 +20,7 @@
worldserver.broadcastEntityEvent(entityvillager2, (byte) 12);
return Optional.of(entityvillager2);
}
@@ -125,6 +130,6 @@
@@ -129,6 +134,6 @@
private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition);

View File

@ -9,33 +9,28 @@
}
private static void setWalkAndLookTargetMemoriesToEachOther(EntityLiving entityliving, EntityLiving entityliving1, float f) {
@@ -74,18 +74,19 @@
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, Entity entity, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i);
@@ -82,8 +82,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) (new BehaviorPositionEntity(entity, true)));
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) behaviorposition);
- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error
+ entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
}
public static void setWalkAndLookTargetMemories(EntityLiving entityliving, BlockPosition blockposition, float f, int i) {
MemoryTarget memorytarget = new MemoryTarget(new BehaviorTarget(blockposition), f, i);
- entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition)));
- entityliving.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
+ entityliving.getBrain().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error
+ 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) {
@@ -93,6 +93,7 @@
}
public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d, Vec3D vec3d1, float f) {
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot
double d0 = entityliving.getEyeY() - 0.30000001192092896D;
double d0 = entityliving.getEyeY() - (double) f;
EntityItem entityitem = new EntityItem(entityliving.level, entityliving.getX(), d0, entityliving.getZ(), itemstack);
float f = 0.3F;
@@ -94,12 +95,19 @@
vec3d1 = vec3d1.normalize().scale(0.30000001192092896D);
entityitem.setDeltaMovement(vec3d1);
@@ -102,12 +103,19 @@
vec3d2 = vec3d2.normalize().multiply(vec3d1.x, vec3d1.y, vec3d1.z);
entityitem.setDeltaMovement(vec3d2);
entityitem.setDefaultPickUpDelay();
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalEatTile.java
@@ -12,6 +12,10 @@
@@ -11,6 +11,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.predicate.BlockStatePredicate;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,7 +11,7 @@
public class PathfinderGoalEatTile extends PathfinderGoal {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -65,7 +69,8 @@
@@ -64,7 +68,8 @@
BlockPosition blockposition = this.mob.blockPosition();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
@ -21,7 +21,7 @@
this.level.destroyBlock(blockposition, false);
}
@@ -75,7 +80,8 @@
@@ -73,7 +78,8 @@
BlockPosition blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {

View File

@ -6,7 +6,7 @@
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketEntityEvent;
@ -30,7 +30,7 @@
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
+ if (playerBucketFishEvent.isCancelled()) {
+ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntityLiving(t0)); // We need to play out these packets as the client assumes the fish is gone
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutSpawnEntity(t0)); // We need to play out these packets as the client assumes the fish is gone
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutEntityMetadata(t0.getId(), t0.getEntityData(), true)); // Need to send data such as the display name to client
+ return Optional.of(EnumInteractionResult.FAIL);
+ }

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
@@ -30,12 +30,19 @@
import net.minecraft.world.level.gameevent.GameEvent;
@@ -29,12 +29,19 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.pathfinder.PathType;
+// CraftBukkit start
@ -12,7 +12,7 @@
+
public abstract class EntityAnimal extends EntityAgeable {
static final int PARENT_AGE_AFTER_BREEDING = 6000;
protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
public int inLove;
@Nullable
public UUID loveCause;
@ -20,7 +20,7 @@
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -72,6 +79,9 @@
@@ -71,6 +78,9 @@
}
@ -30,7 +30,7 @@
@Override
public boolean hurt(DamageSource damagesource, float f) {
if (this.isInvulnerableTo(damagesource)) {
@@ -81,6 +91,7 @@
@@ -80,6 +90,7 @@
return super.hurt(damagesource, f);
}
}
@ -38,7 +38,7 @@
@Override
public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -177,10 +188,17 @@
@@ -174,10 +185,17 @@
}
public void setInLove(@Nullable EntityHuman entityhuman) {
@ -57,7 +57,7 @@
this.level.broadcastEntityEvent(this, (byte) 18);
}
@@ -225,6 +243,16 @@
@@ -222,6 +240,16 @@
if (entityplayer == null && entityanimal.getLoveCause() != null) {
entityplayer = entityanimal.getLoveCause();
}
@ -74,7 +74,7 @@
if (entityplayer != null) {
entityplayer.awardStat(StatisticList.ANIMALS_BRED);
@@ -235,12 +263,14 @@
@@ -232,12 +260,14 @@
entityanimal.setAge(6000);
this.resetLove();
entityanimal.resetLove();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -242,7 +242,7 @@
@@ -243,7 +243,7 @@
}
if (b0 > 0) {
@ -9,7 +9,7 @@
}
}
@@ -642,11 +642,15 @@
@@ -643,11 +643,15 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
@ -27,7 +27,7 @@
}
}
@@ -1222,7 +1226,7 @@
@@ -1223,7 +1227,7 @@
}
}
@ -36,7 +36,7 @@
EntityBee.this.level.levelEvent(2005, blockposition, 0);
EntityBee.this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1));
EntityBee.this.incrementNumCropsGrownSincePollination();
@@ -1295,7 +1299,7 @@
@@ -1296,7 +1300,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
@ -45,7 +45,7 @@
}
}
@@ -1304,7 +1308,7 @@
@@ -1305,7 +1309,7 @@
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityCat.java
+++ b/net/minecraft/world/entity/animal/EntityCat.java
@@ -443,7 +443,7 @@
@@ -410,7 +410,7 @@
}
} else if (this.isFood(itemstack)) {
this.usePlayerItem(entityhuman, enumhand, itemstack);
@ -9,7 +9,7 @@
this.tame(entityhuman);
this.setOrderedToSit(true);
this.level.broadcastEntityEvent(this, (byte) 7);
@@ -500,7 +500,7 @@
@@ -467,7 +467,7 @@
private static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
@Nullable
@ -18,7 +18,7 @@
private final EntityCat cat;
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) {
@@ -641,7 +641,15 @@
@@ -608,7 +608,15 @@
while (iterator.hasNext()) {
ItemStack itemstack = (ItemStack) iterator.next();
@ -35,7 +35,7 @@
}
}
@@ -673,10 +681,10 @@
@@ -640,10 +648,10 @@
private final EntityCat cat;
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {

View File

@ -1,12 +1,12 @@
--- a/net/minecraft/world/entity/animal/EntityChicken.java
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -94,7 +94,9 @@
@@ -95,7 +95,9 @@
this.flap += this.flapping * 2.0F;
if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation((IMaterial) Items.EGG);
+ this.forceDrops = false; // CraftBukkit
this.gameEvent(GameEvent.ENTITY_PLACE);
this.eggTime = this.random.nextInt(6000) + 6000;
}

View File

@ -34,7 +34,7 @@
+ // CraftBukkit end
this.onItemPickup(entityitem);
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
this.handDropChances[EnumItemSlot.MAINHAND.getIndex()] = 2.0F;
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
@@ -389,7 +401,7 @@
@Override

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityFox.java
+++ b/net/minecraft/world/entity/animal/EntityFox.java
@@ -509,7 +509,8 @@
@@ -511,7 +511,8 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@ -10,7 +10,7 @@
int i = itemstack.getCount();
if (i > 1) {
@@ -864,6 +865,16 @@
@@ -866,6 +867,16 @@
if (entityplayer1 != null && entityplayer != entityplayer1) {
entityfox.addTrustedUUID(entityplayer1.getUUID());
}
@ -27,7 +27,7 @@
if (entityplayer2 != null) {
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
@@ -874,12 +885,14 @@
@@ -876,12 +887,14 @@
this.partner.setAge(6000);
this.animal.resetLove();
this.partner.resetLove();
@ -46,7 +46,7 @@
}
}
@@ -1270,13 +1283,18 @@
@@ -1272,13 +1285,18 @@
}
private void pickGlowBerry(IBlockData iblockdata) {
@ -66,7 +66,7 @@
int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
@@ -1433,7 +1451,7 @@
@@ -1435,7 +1453,7 @@
private EntityLiving trustedLastHurt;
private int timestamp;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityIronGolem.java
+++ b/net/minecraft/world/entity/animal/EntityIronGolem.java
@@ -106,7 +106,7 @@
@@ -105,7 +105,7 @@
@Override
protected void doPush(Entity entity) {
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {

View File

@ -24,7 +24,7 @@
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level.isClientSide) {
@@ -163,7 +175,7 @@
this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityParrot.java
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
@@ -256,7 +256,7 @@
@@ -257,7 +257,7 @@
}
if (!this.level.isClientSide) {
@ -9,7 +9,7 @@
this.tame(entityhuman);
this.level.broadcastEntityEvent(this, (byte) 7);
} else {
@@ -270,7 +270,7 @@
@@ -271,7 +271,7 @@
itemstack.shrink(1);
}
@ -18,7 +18,7 @@
if (entityhuman.isCreative() || !this.isInvulnerable()) {
this.hurt(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE);
}
@@ -382,7 +382,7 @@
@@ -383,7 +383,7 @@
@Override
public boolean isPushable() {
@ -27,7 +27,7 @@
}
@Override
@@ -398,7 +398,7 @@
@@ -399,7 +399,7 @@
return false;
} else {
if (!this.level.isClientSide) {

View File

@ -11,7 +11,7 @@
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN);
@@ -250,7 +254,13 @@
@@ -249,7 +253,13 @@
}
entitypigzombie.setPersistenceRequired();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
@@ -89,8 +89,14 @@
@@ -90,8 +90,14 @@
super(entitytypes, world);
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
@ -15,7 +15,7 @@
@Override
public void registerGoals() {
@@ -558,9 +564,23 @@
@@ -559,9 +565,23 @@
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
if (i == 0) {

View File

@ -25,7 +25,7 @@
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
@@ -243,7 +256,9 @@
int i = 1 + this.random.nextInt(3);
@ -47,10 +47,10 @@
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
super.ate();
this.setSheared(false);
if (this.isBaby()) {
this.ageUp(60);
@@ -351,7 +372,7 @@
@@ -352,7 +373,7 @@
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1);
@ -59,7 +59,7 @@
return recipecrafting.assemble(inventorycrafting);
}).map(ItemStack::getItem);
@@ -369,10 +390,18 @@
@@ -375,10 +396,18 @@
public boolean stillValid(EntityHuman entityhuman) {
return false;
}

View File

@ -20,16 +20,20 @@
}
if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -119,7 +123,7 @@
@@ -119,7 +123,11 @@
BlockPosition blockposition1 = new BlockPosition(i, j, k);
if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) {
- this.level.setBlockAndUpdate(blockposition1, iblockdata);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition1, iblockdata, this); // CraftBukkit
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition1, iblockdata, this)) {
+ continue;
+ }
+ // CraftBukkit end
this.level.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this, iblockdata));
}
}
}
@@ -150,6 +154,11 @@
@@ -151,6 +159,11 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
@ -39,9 +43,9 @@
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, (Entity) entityhuman);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level.isClientSide) {
@@ -169,7 +178,9 @@
@@ -170,7 +183,9 @@
this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.level.isClientSide()) {
this.setPumpkin(false);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
@@ -309,7 +309,9 @@
@@ -307,7 +307,9 @@
protected void ageBoundaryReached() {
super.ageBoundaryReached();
if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
@ -10,7 +10,7 @@
}
}
@@ -336,7 +338,9 @@
@@ -334,7 +336,9 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
@ -20,7 +20,7 @@
}
private static class e extends ControllerMove {
@@ -482,8 +486,12 @@
@@ -480,8 +484,12 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level;

View File

@ -61,10 +61,10 @@
- this.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
this.gameEvent(GameEvent.MOB_INTERACT, this.eyeBlockPosition());
return EnumInteractionResult.SUCCESS;
}
@@ -361,7 +384,7 @@
@@ -360,7 +383,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
@ -73,7 +73,7 @@
return EnumInteractionResult.SUCCESS;
}
@@ -383,7 +406,8 @@
@@ -382,7 +405,8 @@
itemstack.shrink(1);
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -68,10 +68,17 @@
@@ -66,10 +66,17 @@
public class Axolotl extends EntityAnimal implements LerpingModel, Bucketable {
@ -13,9 +13,9 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final int TOTAL_PLAYDEAD_TIME = 200;
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Axolotl>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS);
- protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN});
- protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
+ // CraftBukkit - decompile error
+ protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.<MemoryModuleType<?>>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN});
+ protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.<MemoryModuleType<?>>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT);
private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
@ -28,7 +28,7 @@
}
public Axolotl.Variant getVariant() {
@@ -428,7 +435,7 @@
@@ -423,7 +430,7 @@
if (i < 2400) {
i = Math.min(2400, 100 + i);
@ -37,7 +37,7 @@
}
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
@@ -478,7 +485,7 @@
@@ -473,7 +480,7 @@
@Override
public BehaviorController<Axolotl> getBrain() {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -45,6 +45,11 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -54,6 +54,11 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -12,7 +12,7 @@
public class Goat extends EntityAnimal {
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F);
@@ -134,7 +139,7 @@
@@ -156,7 +161,7 @@
@Override
public BehaviorController<Goat> getBrain() {
@ -21,7 +21,7 @@
}
@Override
@@ -172,8 +177,15 @@
@@ -194,8 +199,15 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {

View File

@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
@@ -70,6 +70,8 @@
@@ -72,6 +72,8 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable {
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, IJumpable, ISaddleable {
public static final int EQUIPMENT_SLOT_OFFSET = 400;
@@ -109,6 +111,7 @@
@@ -111,6 +113,7 @@
private float mouthAnimO;
protected boolean canGallop = true;
protected int gallopSoundCounter;
@ -17,7 +17,7 @@
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -294,7 +297,7 @@
@@ -296,7 +299,7 @@
public void createInventory() {
InventorySubcontainer inventorysubcontainer = this.inventory;
@ -26,7 +26,7 @@
if (inventorysubcontainer != null) {
inventorysubcontainer.removeListener(this);
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
@@ -410,7 +413,7 @@
@@ -412,7 +415,7 @@
}
public int getMaxTemper() {
@ -35,7 +35,7 @@
}
@Override
@@ -480,7 +483,7 @@
@@ -483,7 +486,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@ -44,7 +44,7 @@
flag = true;
}
@@ -557,7 +560,7 @@
@@ -560,7 +563,7 @@
super.aiStep();
if (!this.level.isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
@ -53,7 +53,7 @@
}
if (this.canEatGrass()) {
@@ -788,6 +791,7 @@
@@ -791,6 +794,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
}
@ -61,7 +61,7 @@
if (!this.inventory.getItem(0).isEmpty()) {
nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound()));
@@ -815,6 +819,11 @@
@@ -818,6 +822,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
@ -73,7 +73,7 @@
if (nbttagcompound.contains("SaddleItem", 10)) {
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem"));
@@ -897,6 +906,18 @@
@@ -895,6 +904,18 @@
@Override
public void handleStartJump(int i) {

View File

@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.java
@@ -24,7 +24,7 @@
private final PathfinderGoalHorseTrap skeletonTrapGoal = new PathfinderGoalHorseTrap(this);
private static final int TRAP_MAX_LIFE = 18000;
private boolean isTrap;
- private int trapTime;
+ public int trapTime; // PAIL
public EntityHorseSkeleton(EntityTypes<? extends EntityHorseSkeleton> entitytypes, World world) {
super(entitytypes, world);

View File

@ -20,7 +20,7 @@
- entityskeleton1.startRiding(entityhorseabstract);
+ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit
entityhorseabstract.push(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D);
entityhorseabstract.push(this.horse.getRandom().triangle(0.0D, 1.1485D), 0.0D, this.horse.getRandom().triangle(0.0D, 1.1485D));
- worldserver.addFreshEntityWithPassengers(entityhorseabstract);
+ worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
@@ -51,6 +51,18 @@
@@ -50,6 +50,18 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@ -19,7 +19,7 @@
public class EntityEnderDragon extends EntityInsentient implements IMonster {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -87,6 +99,7 @@
@@ -86,6 +98,7 @@
private final PathPoint[] nodes = new PathPoint[24];
private final int[] nodeAdjacency = new int[24];
private final Path openSet = new Path();
@ -27,7 +27,7 @@
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
super(EntityTypes.ENDER_DRAGON, world);
@@ -234,7 +247,7 @@
@@ -233,7 +246,7 @@
Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation();
@ -36,7 +36,7 @@
d0 = vec3d1.x - this.getX();
d1 = vec3d1.y - this.getY();
d2 = vec3d1.z - this.getZ();
@@ -375,7 +388,14 @@
@@ -374,7 +387,14 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
} else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
@ -52,7 +52,7 @@
}
}
@@ -450,6 +470,9 @@
@@ -449,6 +469,9 @@
int j1 = MathHelper.floor(axisalignedbb.maxZ);
boolean flag = false;
boolean flag1 = false;
@ -62,9 +62,9 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
@@ -459,7 +482,11 @@
@@ -458,7 +481,11 @@
if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) {
if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) {
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) {
- flag1 = this.level.removeBlock(blockposition, false) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
@ -75,7 +75,7 @@
} else {
flag = true;
}
@@ -468,6 +495,51 @@
@@ -467,6 +494,51 @@
}
}
@ -115,7 +115,7 @@
+ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> {
+ Block.popResource(level, blockposition, itemstack);
+ });
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) level, blockposition, ItemStack.EMPTY);
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) level, blockposition, ItemStack.EMPTY, false);
+ }
+ nmsBlock.wasExploded(level, blockposition, explosionSource);
+

View File

@ -30,7 +30,7 @@
@Override
public void refreshDimensions() {
double d0 = this.getX();
@@ -160,14 +176,21 @@
@@ -160,13 +176,20 @@
@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@ -44,17 +44,16 @@
this.verifyEquippedItem(itemstack);
switch (enumitemslot.getType()) {
case HAND:
- this.equipEventAndSound(itemstack);
+ this.equipEventAndSound(itemstack, silent); // CraftBukkit
this.handItems.set(enumitemslot.getIndex(), itemstack);
- this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack);
+ this.onEquipItem(enumitemslot, (ItemStack) this.handItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit
break;
case ARMOR:
- this.equipEventAndSound(itemstack);
+ this.equipEventAndSound(itemstack, silent); // CraftBukkit
this.armorItems.set(enumitemslot.getIndex(), itemstack);
- this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack);
+ this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit
}
@@ -404,6 +427,21 @@
}
@@ -402,6 +425,21 @@
return false;
} else {
ItemStack itemstack2;
@ -76,7 +75,7 @@
if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.copy();
@@ -432,9 +470,19 @@
@@ -430,9 +468,19 @@
public boolean hurt(DamageSource damagesource, float f) {
if (!this.level.isClientSide && !this.isRemoved()) {
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
@ -97,7 +96,7 @@
if (damagesource.isExplosion()) {
this.brokenByAnything(damagesource);
this.kill();
@@ -474,7 +522,7 @@
@@ -472,7 +520,7 @@
} else {
this.brokenByPlayer(damagesource);
this.showBreakingParticles();
@ -106,7 +105,7 @@
}
return true;
@@ -535,13 +583,13 @@
@@ -533,13 +581,13 @@
}
private void brokenByPlayer(DamageSource damagesource) {
@ -122,7 +121,7 @@
ItemStack itemstack;
int i;
@@ -549,7 +597,7 @@
@@ -547,7 +595,7 @@
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
@ -131,7 +130,7 @@
this.handItems.set(i, ItemStack.EMPTY);
}
}
@@ -557,10 +605,11 @@
@@ -555,10 +603,11 @@
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {
@ -144,13 +143,13 @@
}
@@ -661,8 +710,16 @@
@@ -659,8 +708,16 @@
return this.isSmall();
}
+ // CraftBukkit start
+ @Override
+ protected boolean shouldDropExperience() {
+ public boolean shouldDropExperience() {
+ return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop
+ }
+ // CraftBukkit end
@ -159,5 +158,5 @@
public void kill() {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
this.remove(Entity.RemovalReason.KILLED);
this.gameEvent(GameEvent.ENTITY_DIE);
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/decoration/EntityHanging.java
+++ b/net/minecraft/world/entity/decoration/EntityHanging.java
@@ -24,6 +24,14 @@
import net.minecraft.world.phys.Vec3D;
@@ -26,6 +26,14 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.damagesource.EntityDamageSourceIndirect;
@ -14,8 +14,8 @@
+
public abstract class EntityHanging extends Entity {
protected static final Predicate<Entity> HANGING_ENTITY = (entity) -> {
@@ -57,26 +65,37 @@
private static final Logger LOGGER = LogUtils.getLogger();
@@ -60,26 +68,37 @@
protected void recalculateBoundingBox() {
if (this.direction != null) {
@ -66,7 +66,7 @@
d8 = 1.0D;
} else {
d6 = 1.0D;
@@ -85,11 +104,12 @@
@@ -88,11 +107,12 @@
d6 /= 32.0D;
d7 /= 32.0D;
d8 /= 32.0D;
@ -81,7 +81,7 @@
return i % 32 == 0 ? 0.5D : 0.0D;
}
@@ -100,6 +120,24 @@
@@ -103,6 +123,24 @@
if (this.checkInterval++ == 100) {
this.checkInterval = 0;
if (!this.isRemoved() && !this.survives()) {
@ -106,7 +106,7 @@
this.discard();
this.dropItem((Entity) null);
}
@@ -163,6 +201,22 @@
@@ -166,6 +204,22 @@
return false;
} else {
if (!this.isRemoved() && !this.level.isClientSide) {
@ -129,7 +129,7 @@
this.kill();
this.markHurt();
this.dropItem(damagesource.getEntity());
@@ -175,6 +229,18 @@
@@ -178,6 +232,18 @@
@Override
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
if (!this.level.isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) {
@ -148,7 +148,7 @@
this.kill();
this.dropItem((Entity) null);
}
@@ -183,7 +249,7 @@
@@ -186,7 +252,7 @@
@Override
public void push(double d0, double d1, double d2) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/decoration/EntityItemFrame.java
+++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java
@@ -91,16 +91,27 @@
@@ -93,16 +93,27 @@
@Override
protected void recalculateBoundingBox() {
if (this.direction != null) {
@ -37,7 +37,7 @@
switch (enumdirection_enumaxis) {
case X:
@@ -116,9 +127,10 @@
@@ -118,9 +129,10 @@
d4 /= 32.0D;
d5 /= 32.0D;
d6 /= 32.0D;
@ -49,7 +49,7 @@
@Override
public boolean survives() {
@@ -168,6 +180,11 @@
@@ -170,6 +182,11 @@
return false;
} else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
if (!this.level.isClientSide) {
@ -61,7 +61,7 @@
this.dropItem(damagesource.getEntity(), false);
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
}
@@ -277,6 +294,12 @@
@@ -297,6 +314,12 @@
}
public void setItem(ItemStack itemstack, boolean flag) {
@ -74,9 +74,9 @@
if (!itemstack.isEmpty()) {
itemstack = itemstack.copy();
itemstack.setCount(1);
@@ -284,7 +307,7 @@
}
@@ -304,7 +327,7 @@
this.onItemChanged(itemstack);
this.getEntityData().set(EntityItemFrame.DATA_ITEM, itemstack);
- if (!itemstack.isEmpty()) {
+ if (!itemstack.isEmpty() && playSound) { // CraftBukkit

View File

@ -21,7 +21,7 @@
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
super(entitytypes, world);
@@ -95,9 +102,12 @@
@@ -105,9 +112,12 @@
this.discard();
} else {
super.tick();
@ -37,7 +37,7 @@
this.xo = this.getX();
this.yo = this.getY();
@@ -147,9 +157,11 @@
@@ -157,9 +167,11 @@
this.mergeWithNeighbours();
}
@ -49,7 +49,7 @@
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
if (!this.level.isClientSide) {
@@ -161,6 +173,12 @@
@@ -171,6 +183,12 @@
}
if (!this.level.isClientSide && this.age >= 6000) {
@ -62,7 +62,7 @@
this.discard();
}
@@ -236,10 +254,11 @@
@@ -246,10 +264,11 @@
private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
ItemStack itemstack2 = merge(itemstack, itemstack1, 64);
@ -75,7 +75,7 @@
merge(entityitem, itemstack, itemstack1);
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
entityitem.age = Math.min(entityitem.age, entityitem1.age);
@@ -265,6 +284,11 @@
@@ -275,6 +294,11 @@
} else if (this.level.isClientSide) {
return true;
} else {
@ -86,8 +86,8 @@
+ // CraftBukkit end
this.markHurt();
this.health = (int) ((float) this.health - f);
this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
@@ -328,6 +352,46 @@
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
@@ -338,6 +362,46 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@ -134,7 +134,7 @@
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
entityhuman.take(this, i);
if (itemstack.isEmpty()) {
@@ -371,7 +435,9 @@
@@ -381,7 +445,9 @@
}
public void setItem(ItemStack itemstack) {

View File

@ -27,31 +27,31 @@
}
@@ -470,9 +481,13 @@
@@ -474,9 +485,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
world.setBlock(blockposition, iblockdata2, 3);
world.gameEvent(this.enderman, GameEvent.BLOCK_PLACE, blockposition);
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this.enderman, iblockdata2));
this.enderman.setCarriedBlock((IBlockData) null);
+ }
+ // CraftBukkit end
}
}
@@ -511,9 +526,13 @@
@@ -515,9 +530,13 @@
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {
- world.removeBlock(blockposition, false);
- world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
- world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
- this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
+ // CraftBukkit start - Pickup event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ world.removeBlock(blockposition, false);
+ world.gameEvent(this.enderman, GameEvent.BLOCK_DESTROY, blockposition);
+ world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
+ this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
+ }
+ // CraftBukkit end

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityGhast.java
+++ b/net/minecraft/world/entity/monster/EntityGhast.java
@@ -330,6 +330,8 @@
@@ -337,6 +337,8 @@
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getExplosionPower());

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityGuardianElder.java
+++ b/net/minecraft/world/entity/monster/EntityGuardianElder.java
@@ -79,7 +79,7 @@
@@ -67,7 +67,7 @@
super.customServerAiStep();
if ((this.tickCount + this.getId()) % 1200 == 0) {
MobEffect mobeffect = new MobEffect(MobEffects.DIG_SLOWDOWN, 6000, 2);
- List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level, this, this.position(), 50.0D, mobeffect, 1200);
+ List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) {
list.forEach((entityplayer) -> {
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
- entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this);
+ entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
}

View File

@ -41,4 +41,4 @@
+ // CraftBukkit end
}
public static boolean checkZombifiedPiglinSpawnRules(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) {
public static boolean checkZombifiedPiglinSpawnRules(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, RandomSource randomsource) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityRavager.java
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
@@ -170,7 +170,7 @@
@@ -171,7 +171,7 @@
IBlockData iblockdata = this.level.getBlockState(blockposition);
Block block = iblockdata.getBlock();

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