13
0
geforkt von Mirrors/Paper

Update to Minecraft 1.17

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-06-11 15:00:00 +10:00
Ursprung 75faba7fde
Commit b3a8254758
619 geänderte Dateien mit 10708 neuen und 8451 gelöschten Zeilen

Datei anzeigen

@ -1,10 +1,10 @@
--- a/net/minecraft/CrashReport.java --- a/net/minecraft/CrashReport.java
+++ b/net/minecraft/CrashReport.java +++ b/net/minecraft/CrashReport.java
@@ -68,6 +68,7 @@ @@ -31,6 +31,7 @@
public CrashReport(String s, Throwable throwable) {
return String.format("%d total; %s", list.size(), list.stream().collect(Collectors.joining(" "))); this.title = s;
}); this.exception = throwable;
+ this.d.a("CraftBukkit Information", (CrashReportCallable) new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit + this.systemReport.a("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
} }
public String a() { public String a() {

Datei anzeigen

@ -7,8 +7,8 @@
+ public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit + public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit
public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) { public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) {
this.key = minecraftkey; this.id = minecraftkey;
@@ -222,7 +223,7 @@ @@ -233,7 +234,7 @@
} }
public Advancement b(MinecraftKey minecraftkey) { public Advancement b(MinecraftKey minecraftkey) {

Datei anzeigen

@ -1,6 +1,15 @@
--- a/net/minecraft/advancements/Advancements.java --- a/net/minecraft/advancements/Advancements.java
+++ b/net/minecraft/advancements/Advancements.java +++ b/net/minecraft/advancements/Advancements.java
@@ -73,7 +73,7 @@ @@ -79,7 +79,7 @@
entry = (Entry) iterator.next();
MinecraftKey minecraftkey = (MinecraftKey) entry.getKey();
Advancement.SerializedAdvancement advancement_serializedadvancement = (Advancement.SerializedAdvancement) entry.getValue();
- Map map1 = this.advancements;
+ Map<MinecraftKey, Advancement> map1 = this.advancements; // CraftBukkit - decompile error
Objects.requireNonNull(this.advancements);
if (advancement_serializedadvancement.a(map1::get)) {
@@ -116,7 +116,7 @@
} }
} }
@ -8,4 +17,4 @@
+ // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload + // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload
} }
public Iterable<Advancement> b() { public void a() {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java --- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java +++ b/net/minecraft/commands/CommandDispatcher.java
@@ -102,12 +102,21 @@ @@ -103,6 +103,14 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -15,27 +15,28 @@
public class CommandDispatcher { public class CommandDispatcher {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> b = new com.mojang.brigadier.CommandDispatcher(); @@ -114,6 +122,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) {
+ this(); // CraftBukkit + this(); // CraftBukkit
CommandAdvancement.a(this.b); CommandAdvancement.a(this.dispatcher);
CommandAttribute.a(this.b); CommandAttribute.a(this.dispatcher);
CommandExecute.a(this.b); CommandExecute.a(this.dispatcher);
@@ -188,17 +197,61 @@ @@ -195,17 +204,61 @@
} }
this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); - CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection);
+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit + // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit
}); });
- this.b.setConsumer((commandcontext, flag, i) -> { - this.dispatcher.setConsumer((commandcontext, flag, i) -> {
- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i); - ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
+ } + }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ public CommandDispatcher() { + public CommandDispatcher() {
+ this.b.setConsumer((commandcontext, flag1, i) -> { + this.dispatcher.setConsumer((commandcontext, flag1, i) -> {
+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i); + ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
}); });
} }
@ -88,7 +89,7 @@
stringreader.skip(); stringreader.skip();
} }
@@ -222,7 +275,7 @@ @@ -229,7 +282,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> { IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> {
@ -97,7 +98,7 @@
}); });
if (j > 10) { if (j > 10) {
@@ -272,11 +325,36 @@ @@ -279,11 +332,36 @@
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
@ -114,8 +115,8 @@
+ // Now build the global commands in a second pass + // Now build the global commands in a second pass
RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode(); RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode();
map.put(this.b.getRoot(), rootcommandnode); map.put(this.dispatcher.getRoot(), rootcommandnode);
this.a(this.b.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map); this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
+ +
+ Collection<String> bukkit = new LinkedHashSet<>(); + Collection<String> bukkit = new LinkedHashSet<>();
+ for (CommandNode node : rootcommandnode.getChildren()) { + for (CommandNode node : rootcommandnode.getChildren()) {
@ -132,10 +133,10 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode)); entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
} }
@@ -287,7 +365,7 @@ @@ -294,7 +372,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next(); CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) { if (commandnode2.canUse(commandlistenerwrapper)) {
@ -144,7 +145,7 @@
argumentbuilder.requires((icompletionprovider) -> { argumentbuilder.requires((icompletionprovider) -> {
return true; return true;
@@ -310,7 +388,7 @@ @@ -317,7 +395,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect())); argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
} }

Datei anzeigen

@ -8,16 +8,16 @@
+ +
public class CommandListenerWrapper implements ICompletionProvider { public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
@@ -53,6 +55,7 @@ @@ -53,6 +55,7 @@
private final ResultConsumer<CommandListenerWrapper> l; private final ResultConsumer<CommandListenerWrapper> consumer;
private final ArgumentAnchor.Anchor m; private final ArgumentAnchor.Anchor anchor;
private final Vec2F n; private final Vec2F rotation;
+ public volatile CommandNode currentCommand; // CraftBukkit + 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) { 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) -> { this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -149,9 +152,23 @@ @@ -153,9 +156,23 @@
@Override @Override
public boolean hasPermission(int i) { public boolean hasPermission(int i) {
@ -28,36 +28,36 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
return this.f >= i; return this.permissionLevel >= i;
} }
+ // CraftBukkit start + // CraftBukkit start
+ public boolean hasPermission(int i, String bukkitPermission) { + public boolean hasPermission(int i, String bukkitPermission) {
+ // World is null when loading functions + // World is null when loading functions
+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.f >= i) || getBukkitSender().hasPermission(bukkitPermission); + return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public Vec3D getPosition() { public Vec3D getPosition() {
return this.d; return this.worldPosition;
} }
@@ -213,7 +230,7 @@ @@ -217,7 +234,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer != this.base && this.i.getPlayerList().isOp(entityplayer.getProfile())) { - if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) {
+ if (entityplayer != this.base && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit + if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b); entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID);
} }
} }
@@ -273,4 +290,10 @@ @@ -277,4 +294,10 @@
public IRegistryCustom q() { public IRegistryCustom q() {
return this.i.getCustomRegistry(); return this.server.getCustomRegistry();
} }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ public org.bukkit.command.CommandSender getBukkitSender() { + public org.bukkit.command.CommandSender getBukkitSender() {
+ return base.getBukkitSender(this); + return source.getBukkitSender(this);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -14,10 +14,10 @@
}; };
void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid); void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid);
@@ -32,4 +39,6 @@ @@ -36,4 +43,6 @@
boolean shouldSendFailure(); default boolean c_() {
return false;
boolean shouldBroadcastCommands(); }
+ +
+ org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit + org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit
} }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/arguments/ArgumentEntity.java --- a/net/minecraft/commands/arguments/ArgumentEntity.java
+++ b/net/minecraft/commands/arguments/ArgumentEntity.java +++ b/net/minecraft/commands/arguments/ArgumentEntity.java
@@ -93,9 +93,15 @@ @@ -95,9 +95,15 @@
} }
public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException { public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException {
@ -15,5 +15,5 @@
- EntitySelector entityselector = argumentparserselector.parse(); - EntitySelector entityselector = argumentparserselector.parse();
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit + EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
if (entityselector.a() > 1 && this.h) { if (entityselector.a() > 1 && this.single) {
if (this.i) { if (this.playersOnly) {

Datei anzeigen

@ -1,15 +1,15 @@
--- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java --- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
+++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java +++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
@@ -55,7 +55,7 @@ @@ -61,7 +61,7 @@
}; };
private final StringReader i; private final StringReader reader;
private final boolean j; private final boolean forTesting;
- private final Map<IBlockState<?>, Comparable<?>> k = Maps.newHashMap(); - private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newHashMap();
+ private final Map<IBlockState<?>, Comparable<?>> k = Maps.newLinkedHashMap(); // CraftBukkit - stable + private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable
private final Map<String, String> l = Maps.newHashMap(); private final Map<String, String> vagueProperties = Maps.newHashMap();
private MinecraftKey m = new MinecraftKey(""); private MinecraftKey id = new MinecraftKey("");
private BlockStateList<Block, IBlockData> n; private BlockStateList<Block, IBlockData> definition;
@@ -231,7 +231,7 @@ @@ -237,7 +237,7 @@
Iterator iterator = iblockstate.getValues().iterator(); Iterator iterator = iblockstate.getValues().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -18,16 +18,16 @@
if (t0 instanceof Integer) { if (t0 instanceof Integer) {
suggestionsbuilder.suggest((Integer) t0); suggestionsbuilder.suggest((Integer) t0);
@@ -500,7 +500,7 @@ @@ -506,7 +506,7 @@
Optional<T> optional = iblockstate.b(s); Optional<T> optional = iblockstate.b(s);
if (optional.isPresent()) { if (optional.isPresent()) {
- this.o = (IBlockData) this.o.set(iblockstate, (Comparable) optional.get()); - this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get());
+ this.o = (IBlockData) this.o.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error + this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
this.k.put(iblockstate, optional.get()); this.properties.put(iblockstate, (Comparable) optional.get());
} else { } else {
this.i.setCursor(i); this.reader.setCursor(i);
@@ -534,7 +534,7 @@ @@ -540,7 +540,7 @@
private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) { private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.getName()); stringbuilder.append(iblockstate.getName());
stringbuilder.append('='); stringbuilder.append('=');

Datei anzeigen

@ -1,28 +1,28 @@
--- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java --- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
+++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java +++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
@@ -137,7 +137,7 @@ @@ -149,7 +149,7 @@
axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x); axisalignedbb = this.a(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
} }
- Function function; - Function function;
+ Function<Vec3D, Vec3D> function; // CraftBukkit - decompile error + Function<Vec3D, Vec3D> function; // CraftBukkit - decompile error
if (this.s == null && this.t == null && this.u == null) { if (this.x == null && this.y == null && this.z == null) {
function = (vec3d) -> { function = (vec3d) -> {
@@ -198,8 +198,10 @@ @@ -206,8 +206,10 @@
}; };
} }
- protected void parseSelector() throws CommandSyntaxException { - protected void parseSelector() throws CommandSyntaxException {
- this.checkPermissions = true; - this.usesSelectors = true;
+ // CraftBukkit start + // CraftBukkit start
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException { + protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
+ this.checkPermissions = !overridePermissions; + this.usesSelectors = !overridePermissions;
+ // CraftBukkit end + // CraftBukkit end
this.G = this::d; this.suggestions = this::d;
if (!this.l.canRead()) { if (!this.reader.canRead()) {
throw ArgumentParserSelector.d.createWithContext(this.l); throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
@@ -453,6 +455,12 @@ @@ -465,6 +467,12 @@
} }
public EntitySelector parse() throws CommandSyntaxException { public EntitySelector parse() throws CommandSyntaxException {
@ -32,13 +32,13 @@
+ +
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException { + public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
+ // CraftBukkit end + // CraftBukkit end
this.E = this.l.getCursor(); this.startPosition = this.reader.getCursor();
this.G = this::b; this.suggestions = this::b;
if (this.l.canRead() && this.l.peek() == '@') { if (this.reader.canRead() && this.reader.peek() == '@') {
@@ -461,7 +469,7 @@ @@ -473,7 +481,7 @@
} }
this.l.skip(); this.reader.skip();
- this.parseSelector(); - this.parseSelector();
+ this.parseSelector(overridePermissions); // CraftBukkit + this.parseSelector(overridePermissions); // CraftBukkit
} else { } else {

Datei anzeigen

@ -1,11 +1,11 @@
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java --- a/net/minecraft/commands/arguments/selector/EntitySelector.java
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
@@ -75,7 +75,7 @@ @@ -90,7 +90,7 @@
} }
private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
- if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2)) { - if (this.usesSelector && !commandlistenerwrapper.hasPermission(2)) {
+ if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit + if (this.usesSelector && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
throw ArgumentEntity.f.create(); throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create();
} }
} }

Datei anzeigen

@ -0,0 +1,173 @@
--- a/net/minecraft/core/cauldron/CauldronInteraction.java
+++ b/net/minecraft/core/cauldron/CauldronInteraction.java
@@ -30,6 +30,10 @@
import net.minecraft.world.level.block.state.properties.IBlockState;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import org.bukkit.event.block.CauldronLevelChangeEvent;
+// CraftBukkit end
+
public interface CauldronInteraction {
Map<Item, CauldronInteraction> EMPTY = a();
@@ -52,6 +56,11 @@
return EnumInteractionResult.PASS;
} else {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
ItemStack itemstack1 = new ItemStack(Blocks.SHULKER_BOX);
if (itemstack.hasTag()) {
@@ -60,7 +69,7 @@
entityhuman.a(enumhand, itemstack1);
entityhuman.a(StatisticList.CLEAN_SHULKER_BOX);
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
}
return EnumInteractionResult.a(world.isClientSide);
@@ -71,6 +80,11 @@
return EnumInteractionResult.PASS;
} else {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
ItemStack itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
@@ -88,7 +102,7 @@
}
entityhuman.a(StatisticList.CLEAN_BANNER);
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
}
return EnumInteractionResult.a(world.isClientSide);
@@ -106,9 +120,14 @@
return EnumInteractionResult.PASS;
} else {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
idyeable.e_(itemstack);
entityhuman.a(StatisticList.CLEAN_ARMOR);
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
}
return EnumInteractionResult.a(world.isClientSide);
@@ -117,7 +136,7 @@
};
static Object2ObjectOpenHashMap<Item, CauldronInteraction> a() {
- return (Object2ObjectOpenHashMap) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> {
+ return SystemUtils.a((new Object2ObjectOpenHashMap<>()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
object2objectopenhashmap.defaultReturnValue((iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
return EnumInteractionResult.PASS;
});
@@ -133,12 +152,17 @@
return EnumInteractionResult.PASS;
} else {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.getBlockData(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
Item item = itemstack.getItem();
entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
entityhuman.a(StatisticList.USE_CAULDRON);
entityhuman.b(StatisticList.ITEM_USED.b(item));
- world.setTypeUpdate(blockposition, Blocks.WATER_CAULDRON.getBlockData());
+ // world.setTypeUpdate(blockposition, Blocks.WATER_CAULDRON.getBlockData()); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition);
}
@@ -154,12 +178,17 @@
});
CauldronInteraction.WATER.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
Item item = itemstack.getItem();
entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER)));
entityhuman.a(StatisticList.USE_CAULDRON);
entityhuman.b(StatisticList.ITEM_USED.b(item));
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
}
@@ -169,10 +198,15 @@
CauldronInteraction.WATER.put(Items.POTION, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
if ((Integer) iblockdata.get(LayeredCauldronBlock.LEVEL) != 3 && PotionUtil.d(itemstack) == Potions.WATER) {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.a(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
entityhuman.a(StatisticList.USE_CAULDRON);
entityhuman.b(StatisticList.ITEM_USED.b(itemstack.getItem()));
- world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL));
+ // world.setTypeUpdate(blockposition, (IBlockData) iblockdata.a((IBlockState) LayeredCauldronBlock.LEVEL)); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition);
}
@@ -244,12 +278,17 @@
return EnumInteractionResult.PASS;
} else {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.getBlockData(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
Item item = itemstack.getItem();
entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, itemstack1));
entityhuman.a(StatisticList.USE_CAULDRON);
entityhuman.b(StatisticList.ITEM_USED.b(item));
- world.setTypeUpdate(blockposition, Blocks.CAULDRON.getBlockData());
+ // world.setTypeUpdate(blockposition, Blocks.CAULDRON.getBlockData()); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
}
@@ -260,12 +299,17 @@
static EnumInteractionResult a(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
Item item = itemstack.getItem();
entityhuman.a(enumhand, ItemLiquidUtil.a(itemstack, entityhuman, new ItemStack(Items.BUCKET)));
entityhuman.a(StatisticList.FILL_CAULDRON);
entityhuman.b(StatisticList.ITEM_USED.b(item));
- world.setTypeUpdate(blockposition, iblockdata);
+ // world.setTypeUpdate(blockposition, iblockdata); // CraftBukkit
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition);
}

Datei anzeigen

@ -11,7 +11,7 @@
+ +
public class DispenseBehaviorBoat extends DispenseBehaviorItem { public class DispenseBehaviorBoat extends DispenseBehaviorItem {
private final DispenseBehaviorItem b = new DispenseBehaviorItem(); private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
@@ -39,12 +44,40 @@ @@ -39,12 +44,40 @@
d3 = 0.0D; d3 = 0.0D;
} }
@ -37,8 +37,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -47,8 +47,8 @@
+ EntityBoat entityboat = new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()); + EntityBoat entityboat = new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ // CraftBukkit end + // CraftBukkit end
entityboat.setType(this.c); entityboat.setType(this.type);
entityboat.yaw = enumdirection.o(); entityboat.setYRot(enumdirection.o());
- worldserver.addEntity(entityboat); - worldserver.addEntity(entityboat);
- itemstack.subtract(1); - itemstack.subtract(1);
+ if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit + if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit

Datei anzeigen

@ -59,8 +59,8 @@
+ if (!event.getItem().getType().equals(craftItem.getType())) { + if (!event.getItem().getType().equals(craftItem.getType())) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior.getClass() != DispenseBehaviorItem.class) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ } else { + } else {
+ world.addEntity(entityitem); + world.addEntity(entityitem);

Datei anzeigen

@ -39,8 +39,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }

Datei anzeigen

@ -1,7 +1,7 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java --- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java
@@ -23,6 +23,12 @@ @@ -25,6 +25,12 @@
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start +// CraftBukkit start
@ -13,7 +13,7 @@
public class DispenseBehaviorShears extends DispenseBehaviorMaybe { public class DispenseBehaviorShears extends DispenseBehaviorMaybe {
public DispenseBehaviorShears() {} public DispenseBehaviorShears() {}
@@ -30,11 +36,34 @@ @@ -32,11 +38,34 @@
@Override @Override
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
@ -33,15 +33,15 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (!worldserver.s_()) { if (!worldserver.isClientSide()) {
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
- this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition)); - this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition));
@ -49,16 +49,16 @@
if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) { if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) {
itemstack.setCount(0); itemstack.setCount(0);
} }
@@ -60,7 +89,7 @@ @@ -63,7 +92,7 @@
return false; return false;
} }
- private static boolean b(WorldServer worldserver, BlockPosition blockposition) { - private static boolean b(WorldServer worldserver, BlockPosition blockposition) {
+ private static boolean b(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args + private static boolean b(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
List<EntityLiving> list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.g); List<EntityLiving> list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
Iterator iterator = list.iterator(); Iterator iterator = list.iterator();
@@ -71,6 +100,11 @@ @@ -74,6 +103,11 @@
IShearable ishearable = (IShearable) entityliving; IShearable ishearable = (IShearable) entityliving;
if (ishearable.canShear()) { if (ishearable.canShear()) {
@ -68,5 +68,5 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
ishearable.shear(SoundCategory.BLOCKS); ishearable.shear(SoundCategory.BLOCKS);
worldserver.a((Entity) null, GameEvent.SHEAR, blockposition);
return true; return true;
}

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java --- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java +++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
@@ -10,6 +10,11 @@ @@ -12,6 +12,11 @@
import net.minecraft.world.item.context.BlockActionContextDirectional; import org.apache.logging.log4j.LogManager;
import net.minecraft.world.level.block.BlockDispenser; import org.apache.logging.log4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftItemStack;
@ -11,8 +11,8 @@
+ +
public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe { public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe {
public DispenseBehaviorShulkerBox() {} private static final Logger LOGGER = LogManager.getLogger();
@@ -24,6 +29,30 @@ @@ -28,6 +33,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP; EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
@ -32,14 +32,14 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a()); try {
} this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a());
} catch (Exception exception) {

Datei anzeigen

@ -1,10 +1,11 @@
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java --- a/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java +++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -74,6 +74,19 @@ @@ -79,6 +79,20 @@
import net.minecraft.world.phys.AxisAlignedBB; import org.apache.logging.log4j.LogManager;
import net.minecraft.world.phys.MovingObjectPositionBlock; import org.apache.logging.log4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import net.minecraft.world.item.ItemBucket;
+import net.minecraft.world.level.block.BlockSapling; +import net.minecraft.world.level.block.BlockSapling;
+import net.minecraft.world.level.block.IFluidContainer; +import net.minecraft.world.level.block.IFluidContainer;
+import net.minecraft.world.level.material.Material; +import net.minecraft.world.level.material.Material;
@ -19,8 +20,8 @@
+ +
public interface IDispenseBehavior { public interface IDispenseBehavior {
IDispenseBehavior NONE = (isourceblock, itemstack) -> { Logger LOGGER = LogManager.getLogger();
@@ -114,7 +127,7 @@ @@ -120,7 +134,7 @@
BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() { BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
@Override @Override
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
@ -29,7 +30,7 @@
entityegg.setItem(itemstack); entityegg.setItem(itemstack);
}); });
} }
@@ -122,7 +135,7 @@ @@ -128,7 +142,7 @@
BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() { BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
@Override @Override
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
@ -38,7 +39,7 @@
entitysnowball.setItem(itemstack); entitysnowball.setItem(itemstack);
}); });
} }
@@ -130,7 +143,7 @@ @@ -136,7 +150,7 @@
BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() { BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
@Override @Override
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
@ -47,7 +48,7 @@
entitythrownexpbottle.setItem(itemstack); entitythrownexpbottle.setItem(itemstack);
}); });
} }
@@ -151,7 +164,7 @@ @@ -157,7 +171,7 @@
return (new DispenseBehaviorProjectile() { return (new DispenseBehaviorProjectile() {
@Override @Override
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) {
@ -56,7 +57,7 @@
entitypotion.setItem(itemstack1); entitypotion.setItem(itemstack1);
}); });
} }
@@ -174,7 +187,7 @@ @@ -180,7 +194,7 @@
return (new DispenseBehaviorProjectile() { return (new DispenseBehaviorProjectile() {
@Override @Override
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) {
@ -65,9 +66,9 @@
entitypotion.setItem(itemstack1); entitypotion.setItem(itemstack1);
}); });
} }
@@ -197,8 +210,36 @@ @@ -203,14 +217,42 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag()); EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag());
+ // CraftBukkit start + // CraftBukkit start
+ WorldServer worldserver = isourceblock.getWorld(); + WorldServer worldserver = isourceblock.getWorld();
@ -89,21 +90,28 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
+ } + }
+ +
entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); try {
entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
} catch (Exception exception) {
- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getBlockPosition(), exception);
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getBlockPosition(), exception); // CraftBukkit - decompile error
return ItemStack.EMPTY;
}
- itemstack.subtract(1); - itemstack.subtract(1);
+ // itemstack.subtract(1); // Handled during event processing + // itemstack.subtract(1); // Handled during event processing
+ // CraftBukkit end + // CraftBukkit end
isourceblock.getWorld().a(GameEvent.ENTITY_PLACE, isourceblock.getBlockPosition());
return itemstack; return itemstack;
} }
}; @@ -229,12 +271,40 @@
@@ -216,12 +257,40 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
@ -127,8 +135,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -138,14 +146,14 @@
EntityArmorStand entityarmorstand = new EntityArmorStand(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); EntityArmorStand entityarmorstand = new EntityArmorStand(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
EntityTypes.a((World) worldserver, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); EntityTypes.a((World) worldserver, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag());
entityarmorstand.yaw = enumdirection.o(); entityarmorstand.setYRot(enumdirection.o());
worldserver.addEntity(entityarmorstand); worldserver.addEntity(entityarmorstand);
- itemstack.subtract(1); - itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing + // itemstack.subtract(1); // CraftBukkit - Handled during event processing
return itemstack; return itemstack;
} }
})); }));
@@ -322,12 +391,41 @@ @@ -335,12 +405,41 @@
@Override @Override
public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
@ -169,8 +177,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -188,12 +196,14 @@
return itemstack; return itemstack;
} }
@@ -350,10 +448,39 @@ @@ -362,12 +461,40 @@
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX();
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY(); double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ(); double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
- EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5);
- worldserver.addEntity((Entity) SystemUtils.a((Object) (new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5)), (entitysmallfireball) -> { - worldserver.addEntity((Entity) SystemUtils.a((Object) entitysmallfireball, (entitysmallfireball1) -> {
- entitysmallfireball.setItem(itemstack); - entitysmallfireball1.setItem(itemstack);
- })); - }));
- itemstack.subtract(1); - itemstack.subtract(1);
+ // CraftBukkit start + // CraftBukkit start
@ -215,8 +225,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -232,7 +242,7 @@
return itemstack; return itemstack;
} }
@@ -377,9 +504,52 @@ @@ -391,9 +518,52 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
@ -242,7 +252,7 @@
+ int z = blockposition.getZ(); + int z = blockposition.getZ();
+ IBlockData iblockdata = worldserver.getType(blockposition); + IBlockData iblockdata = worldserver.getType(blockposition);
+ Material material = iblockdata.getMaterial(); + Material material = iblockdata.getMaterial();
+ if (worldserver.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(worldserver, blockposition, iblockdata, itembucket.fluidType))) { + if (worldserver.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlace(worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) {
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ +
@ -258,19 +268,19 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
+ } + }
+ +
+ itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); + dispensiblecontaineritem = (DispensibleContainerItem) CraftItemStack.asNMSCopy(event.getItem()).getItem();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (itembucket.a((EntityHuman) null, (World) worldserver, blockposition, (MovingObjectPositionBlock) null)) { if (dispensiblecontaineritem.a((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) {
itembucket.a((World) worldserver, itemstack, blockposition); dispensiblecontaineritem.a((EntityHuman) null, worldserver, itemstack, blockposition);
- return new ItemStack(Items.BUCKET); - return new ItemStack(Items.BUCKET);
+ // CraftBukkit start - Handle stacked buckets + // CraftBukkit start - Handle stacked buckets
+ Item item = Items.BUCKET; + Item item = Items.BUCKET;
@ -279,24 +289,25 @@
+ itemstack.setItem(Items.BUCKET); + itemstack.setItem(Items.BUCKET);
+ itemstack.setCount(1); + itemstack.setCount(1);
+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { + } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
+ this.b.dispense(isourceblock, new ItemStack(item)); + this.defaultDispenseItemBehavior.dispense(isourceblock, new ItemStack(item));
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ return itemstack; + return itemstack;
} else { } else {
return this.b.dispense(isourceblock, itemstack); return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack);
} }
@@ -403,13 +573,39 @@ @@ -419,7 +589,7 @@
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
if (block instanceof IFluidSource) { if (block instanceof IFluidSource) {
- FluidType fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); - ItemStack itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata);
+ FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit + ItemStack itemstack1 = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
if (!(fluidtype instanceof FluidTypeFlowing)) { if (itemstack1.isEmpty()) {
return super.a(isourceblock, itemstack); return super.a(isourceblock, itemstack);
} else { @@ -427,6 +597,32 @@
Item item = fluidtype.a(); worldserver.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
Item item = itemstack1.getItem();
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); + org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
@ -314,20 +325,20 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
+ } + }
+ +
+ fluidtype = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above + itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above
+ // CraftBukkit end + // CraftBukkit end
+ +
itemstack.subtract(1); itemstack.subtract(1);
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
return new ItemStack(item); return new ItemStack(item);
@@ -431,13 +627,41 @@ @@ -448,14 +644,42 @@
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
@ -347,8 +358,8 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -362,15 +373,17 @@
if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) { if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) {
- worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); - worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition));
- worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
+ // CraftBukkit start - Ignition by dispensing flint and steel + // CraftBukkit start - Ignition by dispensing flint and steel
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getBlockPosition()).isCancelled()) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getBlockPosition()).isCancelled()) {
+ worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition)); + worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition));
+ worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} else if (BlockCampfire.h(iblockdata)) { } else if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) {
worldserver.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true)); if (iblockdata.getBlock() instanceof BlockTNT) {
} else if (iblockdata.getBlock() instanceof BlockTNT) { BlockTNT.a((World) worldserver, blockposition);
@@ -460,12 +684,62 @@ @@ -481,12 +705,62 @@
this.a(true); this.a(true);
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
@ -390,8 +403,8 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -403,7 +416,7 @@
if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) { if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) {
this.a(false); this.a(false);
} else if (!worldserver.isClientSide) { } else if (!worldserver.isClientSide) {
worldserver.triggerEffect(2005, blockposition, 0); worldserver.triggerEffect(1505, blockposition, 0);
} }
+ // CraftBukkit start + // CraftBukkit start
+ worldserver.captureTreeGeneration = false; + worldserver.captureTreeGeneration = false;
@ -433,12 +446,12 @@
return itemstack; return itemstack;
} }
@@ -475,11 +749,40 @@ @@ -496,12 +770,41 @@
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getWorld(); WorldServer worldserver = isourceblock.getWorld();
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); + // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ +
+ // CraftBukkit start + // CraftBukkit start
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1); + ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
@ -459,8 +472,8 @@
+ itemstack.add(1); + itemstack.add(1);
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -470,13 +483,14 @@
+ // CraftBukkit end + // CraftBukkit end
worldserver.addEntity(entitytntprimed); worldserver.addEntity(entitytntprimed);
worldserver.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); worldserver.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
worldserver.a((Entity) null, GameEvent.ENTITY_PLACE, blockposition);
- itemstack.subtract(1); - itemstack.subtract(1);
+ // itemstack.subtract(1); // CraftBukkit - handled above + // itemstack.subtract(1); // CraftBukkit - handled above
return itemstack; return itemstack;
} }
})); }));
@@ -503,6 +806,30 @@ @@ -525,6 +828,30 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
@ -496,8 +510,8 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -505,9 +519,9 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) { if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) {
worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.ROTATION, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3);
TileEntity tileentity = worldserver.getTileEntity(blockposition); worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
@@ -527,6 +854,30 @@ @@ -550,6 +877,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
@ -527,8 +541,8 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -538,7 +552,7 @@
if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) { if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) {
if (!worldserver.isClientSide) { if (!worldserver.isClientSide) {
worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3);
@@ -574,6 +925,30 @@ @@ -599,6 +950,30 @@
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getType(blockposition); IBlockData iblockdata = worldserver.getType(blockposition);
@ -558,8 +572,8 @@
+ if (!event.getItem().equals(craftItem)) { + if (!event.getItem().equals(craftItem)) {
+ // Chain to handler for new item + // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); + ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); + IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { + if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack); + idispensebehavior.dispense(isourceblock, eventStack);
+ return itemstack; + return itemstack;
+ } + }
@ -567,5 +581,5 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> { if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> {
return blockbase_blockdata.b(BlockBeehive.b); return blockbase_blockdata.b(BlockBeehive.HONEY_LEVEL);
}) && (Integer) iblockdata.get(BlockBeehive.b) >= 5) { }) && (Integer) iblockdata.get(BlockBeehive.HONEY_LEVEL) >= 5) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/network/NetworkManager.java --- a/net/minecraft/network/NetworkManager.java
+++ b/net/minecraft/network/NetworkManager.java +++ b/net/minecraft/network/NetworkManager.java
@@ -137,7 +137,7 @@ @@ -156,7 +156,7 @@
} }
private static <T extends PacketListener> void a(Packet<T> packet, PacketListener packetlistener) { private static <T extends PacketListener> void a(Packet<T> packet, PacketListener packetlistener) {
@ -9,12 +9,12 @@
} }
public void setPacketListener(PacketListener packetlistener) { public void setPacketListener(PacketListener packetlistener) {
@@ -247,7 +247,7 @@ @@ -268,7 +268,7 @@
public void close(IChatBaseComponent ichatbasecomponent) { public void close(IChatBaseComponent ichatbasecomponent) {
if (this.channel.isOpen()) { if (this.channel.isOpen()) {
- this.channel.close().awaitUninterruptibly(); - this.channel.close().awaitUninterruptibly();
+ this.channel.close(); // We can't wait as this may be called from an event loop. + this.channel.close(); // We can't wait as this may be called from an event loop.
this.m = ichatbasecomponent; this.disconnectedReason = ichatbasecomponent;
} }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/network/PacketDataSerializer.java --- a/net/minecraft/network/PacketDataSerializer.java
+++ b/net/minecraft/network/PacketDataSerializer.java +++ b/net/minecraft/network/PacketDataSerializer.java
@@ -39,6 +39,8 @@ @@ -54,6 +54,8 @@
import net.minecraft.world.phys.MovingObjectPositionBlock; import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -8,17 +8,59 @@
+ +
public class PacketDataSerializer extends ByteBuf { public class PacketDataSerializer extends ByteBuf {
private final ByteBuf a; private static final int MAX_VARINT_SIZE = 5;
@@ -167,7 +169,7 @@ @@ -112,7 +114,7 @@
public <T, C extends Collection<T>> C a(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) {
int i = this.j();
- 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));
@@ -123,7 +125,7 @@
public <T> void a(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) {
this.d(collection.size());
- Iterator iterator = collection.iterator();
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -134,7 +136,7 @@
}
public <T> List<T> a(Function<PacketDataSerializer, T> function) {
- return (List) this.a(Lists::newArrayListWithCapacity, function);
+ return (List) this.a((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error
}
public IntList a() {
@@ -150,12 +152,12 @@
public void a(IntList intlist) {
this.d(intlist.size());
- intlist.forEach(this::d);
+ intlist.forEach((java.util.function.IntConsumer) this::d); // CraftBukkit - decompile error
}
public <K, V, M extends Map<K, V>> M a(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> function1) {
int i = this.j();
- 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);
@@ -330,7 +332,7 @@
} }
public <T extends Enum<T>> T a(Class<T> oclass) { public <T extends Enum<T>> T a(Class<T> oclass) {
- return ((Enum[]) oclass.getEnumConstants())[this.i()]; - return ((Enum[]) oclass.getEnumConstants())[this.j()];
+ return ((T[]) oclass.getEnumConstants())[this.i()]; // CraftBukkit - fix decompile error + return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error
} }
public PacketDataSerializer a(Enum<?> oenum) { public PacketDataSerializer a(Enum<?> oenum) {
@@ -244,7 +246,7 @@ @@ -407,7 +409,7 @@
} else { } else {
try { try {
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this))); NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
@ -27,7 +69,7 @@
throw new EncoderException(ioexception); throw new EncoderException(ioexception);
} }
} }
@@ -281,7 +283,7 @@ @@ -444,7 +446,7 @@
} }
public PacketDataSerializer a(ItemStack itemstack) { public PacketDataSerializer a(ItemStack itemstack) {
@ -36,10 +78,10 @@
this.writeBoolean(false); this.writeBoolean(false);
} else { } else {
this.writeBoolean(true); this.writeBoolean(true);
@@ -310,6 +312,11 @@ @@ -473,6 +475,11 @@
ItemStack itemstack = new ItemStack(Item.getById(i), b0); ItemStack itemstack = new ItemStack(Item.getById(i), b0);
itemstack.setTag(this.l()); itemstack.setTag(this.m());
+ // CraftBukkit start + // CraftBukkit start
+ if (itemstack.getTag() != null) { + if (itemstack.getTag() != null) {
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); + CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));

Datei anzeigen

@ -1,16 +1,16 @@
--- a/net/minecraft/network/chat/ChatHexColor.java --- a/net/minecraft/network/chat/ChatHexColor.java
+++ b/net/minecraft/network/chat/ChatHexColor.java +++ b/net/minecraft/network/chat/ChatHexColor.java
@@ -11,7 +11,7 @@ @@ -12,7 +12,7 @@
public final class ChatHexColor {
private static final Map<EnumChatFormat, ChatHexColor> a = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::d).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { private static final String CUSTOM_COLOR_PREFIX = "#";
private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::d).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> {
- return new ChatHexColor(enumchatformat.e(), enumchatformat.f()); - return new ChatHexColor(enumchatformat.e(), enumchatformat.f());
+ return new ChatHexColor(enumchatformat.e(), enumchatformat.f(), enumchatformat); // CraftBukkit + return new ChatHexColor(enumchatformat.e(), enumchatformat.f(), enumchatformat); // CraftBukkit
})); }));
private static final Map<String, ChatHexColor> b = (Map) ChatHexColor.a.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { private static final Map<String, ChatHexColor> NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> {
return chathexcolor.name; return chathexcolor.name;
@@ -19,16 +19,22 @@ @@ -20,16 +20,22 @@
private final int rgb; private final int value;
@Nullable @Nullable
public final String name; public final String name;
+ // CraftBukkit start + // CraftBukkit start
@ -19,17 +19,17 @@
- private ChatHexColor(int i, String s) { - private ChatHexColor(int i, String s) {
+ private ChatHexColor(int i, String s, EnumChatFormat format) { + private ChatHexColor(int i, String s, EnumChatFormat format) {
this.rgb = i; this.value = i;
this.name = s; this.name = s;
+ this.format = format; + this.format = format;
} }
private ChatHexColor(int i) { private ChatHexColor(int i) {
this.rgb = i; this.value = i;
this.name = null; this.name = null;
+ this.format = null; + this.format = null;
} }
+ // CraftBukkit end + // CraftBukkit end
public String b() { public int a() {
return this.name != null ? this.name : this.c(); return this.value;

Datei anzeigen

@ -1,23 +0,0 @@
--- a/net/minecraft/network/chat/ChatModifier.java
+++ b/net/minecraft/network/chat/ChatModifier.java
@@ -118,6 +118,20 @@
return new ChatModifier(this.color, this.bold, obool, this.underlined, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font);
}
+ // CraftBukkit start
+ public ChatModifier setStrikethrough(@Nullable Boolean obool) {
+ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, obool, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font);
+ }
+
+ public ChatModifier setUnderline(@Nullable Boolean obool) {
+ return new ChatModifier(this.color, this.bold, this.italic, obool, this.strikethrough, this.obfuscated, this.clickEvent, this.hoverEvent, this.insertion, this.font);
+ }
+
+ public ChatModifier setRandom(@Nullable Boolean obool) {
+ return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, obool, this.clickEvent, this.hoverEvent, this.insertion, this.font);
+ }
+ // CraftBukkit end
+
public ChatModifier setChatClickable(@Nullable ChatClickable chatclickable) {
return new ChatModifier(this.color, this.bold, this.italic, this.underlined, this.strikethrough, this.obfuscated, chatclickable, this.hoverEvent, this.insertion, this.font);
}

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/network/chat/IChatBaseComponent.java --- a/net/minecraft/network/chat/IChatBaseComponent.java
+++ b/net/minecraft/network/chat/IChatBaseComponent.java +++ b/net/minecraft/network/chat/IChatBaseComponent.java
@@ -27,7 +27,23 @@ @@ -29,7 +29,23 @@
import net.minecraft.util.ChatDeserializer;
import net.minecraft.util.ChatTypeAdapterFactory; import net.minecraft.util.ChatTypeAdapterFactory;
import net.minecraft.util.FormattedString;
-public interface IChatBaseComponent extends Message, IChatFormatted { -public interface IChatBaseComponent extends Message, IChatFormatted {
+// CraftBukkit start +// CraftBukkit start

Datei anzeigen

@ -12,7 +12,7 @@
public class PlayerConnectionUtils { public class PlayerConnectionUtils {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -18,6 +23,7 @@ @@ -20,6 +25,7 @@
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException { public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
if (!iasynctaskhandler.isMainThread()) { if (!iasynctaskhandler.isMainThread()) {
iasynctaskhandler.execute(() -> { iasynctaskhandler.execute(() -> {
@ -20,13 +20,13 @@
if (t0.a().isConnected()) { if (t0.a().isConnected()) {
packet.a(t0); packet.a(t0);
} else { } else {
@@ -26,6 +32,10 @@ @@ -28,6 +34,10 @@
}); });
throw CancelledPacketHandleException.INSTANCE; throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
+ // CraftBukkit start - SPIGOT-5477, MC-142590 + // CraftBukkit start - SPIGOT-5477, MC-142590
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) { + } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) {
+ throw CancelledPacketHandleException.INSTANCE; + throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
+ // CraftBukkit end + // CraftBukkit end
} }
} }

Datei anzeigen

@ -0,0 +1,15 @@
--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java
@@ -27,8 +27,10 @@
}
public ClientboundInitializeBorderPacket(WorldBorder worldborder) {
- this.newCenterX = worldborder.getCenterX();
- this.newCenterZ = worldborder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale();
+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale();
+ // CraftBukkit end
this.oldSize = worldborder.getSize();
this.newSize = worldborder.k();
this.lerpTime = worldborder.j();

Datei anzeigen

@ -0,0 +1,15 @@
--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java
@@ -10,8 +10,10 @@
private final double newCenterZ;
public ClientboundSetBorderCenterPacket(WorldBorder worldborder) {
- this.newCenterX = worldborder.getCenterX();
- this.newCenterZ = worldborder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.newCenterX = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale();
+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale();
+ // CraftBukkit end
}
public ClientboundSetBorderCenterPacket(PacketDataSerializer packetdataserializer) {

Datei anzeigen

@ -4,4 +4,4 @@
+// mc-dev import +// mc-dev import
package net.minecraft.network.protocol.game; package net.minecraft.network.protocol.game;
import java.io.IOException; import net.minecraft.network.PacketDataSerializer;

Datei anzeigen

@ -1,11 +1,11 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInChat.java --- a/net/minecraft/network/protocol/game/PacketPlayInChat.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInChat.java +++ b/net/minecraft/network/protocol/game/PacketPlayInChat.java
@@ -20,7 +20,7 @@ @@ -17,7 +17,7 @@
}
@Override public PacketPlayInChat(PacketDataSerializer packetdataserializer) {
public void a(PacketDataSerializer packetdataserializer) throws IOException { - this.message = packetdataserializer.e(256);
- this.a = packetdataserializer.e(256); + this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection
+ this.a = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection
} }
@Override @Override

Datei anzeigen

@ -1,15 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.java
+++ b/net/minecraft/network/protocol/game/PacketPlayInCloseWindow.java
@@ -10,6 +10,12 @@
public PacketPlayInCloseWindow() {}
+ // CraftBukkit start
+ public PacketPlayInCloseWindow(int id) {
+ this.id = id;
+ }
+ // CraftBukkit end
+
public void a(PacketListenerPlayIn packetlistenerplayin) {
packetlistenerplayin.a(this);
}

Datei anzeigen

@ -4,4 +4,4 @@
+// mc-dev import +// mc-dev import
package net.minecraft.network.protocol.game; package net.minecraft.network.protocol.game;
import java.io.IOException; import net.minecraft.network.PacketDataSerializer;

Datei anzeigen

@ -4,4 +4,4 @@
+// mc-dev import +// mc-dev import
package net.minecraft.network.protocol.game; package net.minecraft.network.protocol.game;
import java.io.IOException; import java.util.UUID;

Datei anzeigen

@ -1,11 +1,11 @@
--- a/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java --- a/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
+++ b/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java +++ b/net/minecraft/network/protocol/game/PacketPlayOutMultiBlockChange.java
@@ -31,7 +31,7 @@ @@ -32,7 +32,7 @@
short short0 = (Short) shortiterator.next(); short short0 = (Short) shortiterator.next();
this.b[i] = short0; this.positions[j] = short0;
- this.c[i] = chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)); - this.states[j] = chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0));
+ this.c[i] = (chunksection != null) ? chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)) : net.minecraft.world.level.block.Blocks.AIR.getBlockData(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified + this.states[j] = (chunksection != null) ? chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0)) : net.minecraft.world.level.block.Blocks.AIR.getBlockData(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified
} }
} }

Datei anzeigen

@ -1,15 +0,0 @@
--- a/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.java
+++ b/net/minecraft/network/protocol/game/PacketPlayOutWorldBorder.java
@@ -21,8 +21,10 @@
public PacketPlayOutWorldBorder(WorldBorder worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction packetplayoutworldborder_enumworldborderaction) {
this.a = packetplayoutworldborder_enumworldborderaction;
- this.c = worldborder.getCenterX();
- this.d = worldborder.getCenterZ();
+ // CraftBukkit start - multiply out nether border
+ this.c = worldborder.getCenterX() * worldborder.world.getDimensionManager().getCoordinateScale();
+ this.d = worldborder.getCenterZ() * worldborder.world.getDimensionManager().getCoordinateScale();
+ // CraftBukkit end
this.f = worldborder.getSize();
this.e = worldborder.k();
this.g = worldborder.j();

Datei anzeigen

@ -4,4 +4,4 @@
+// mc-dev import +// mc-dev import
package net.minecraft.network.protocol.handshake; package net.minecraft.network.protocol.handshake;
import java.io.IOException; import net.minecraft.SharedConstants;

Datei anzeigen

@ -1,16 +1,25 @@
--- a/net/minecraft/network/syncher/DataWatcher.java --- a/net/minecraft/network/syncher/DataWatcher.java
+++ b/net/minecraft/network/syncher/DataWatcher.java +++ b/net/minecraft/network/syncher/DataWatcher.java
@@ -134,6 +134,13 @@ @@ -141,6 +141,13 @@
} }
+ // CraftBukkit start - add method from above + // CraftBukkit start - add method from above
+ public <T> void markDirty(DataWatcherObject<T> datawatcherobject) { + public <T> void markDirty(DataWatcherObject<T> datawatcherobject) {
+ this.b(datawatcherobject).a(true); + this.b(datawatcherobject).a(true);
+ this.g = true; + this.isDirty = true;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public boolean a() { public boolean a() {
return this.g; return this.isDirty;
} }
@@ -273,7 +280,7 @@
if (!Objects.equals(datawatcher_item1.accessor.b(), datawatcher_item.accessor.b())) {
throw new IllegalStateException(String.format("Invalid entity data item type for field %d on entity %s: old=%s(%s), new=%s(%s)", datawatcher_item.accessor.a(), this.entity, datawatcher_item.value, datawatcher_item.value.getClass(), datawatcher_item1.value, datawatcher_item1.value.getClass()));
} else {
- datawatcher_item.a(datawatcher_item1.b());
+ datawatcher_item.a((T) datawatcher_item1.b()); // CraftBukkit - decompile error
}
}

Datei anzeigen

@ -4,20 +4,20 @@
Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey()); Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey());
if (advancement == null) { if (advancement == null) {
- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); - AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file);
+ // CraftBukkit start + // CraftBukkit start
+ if (entry.getKey().getNamespace().equals("minecraft")) { + if (entry.getKey().getNamespace().equals("minecraft")) {
+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.f); + AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} else { } else {
this.a(advancement, (AdvancementProgress) entry.getValue()); this.a(advancement, (AdvancementProgress) entry.getValue());
} }
@@ -296,6 +300,7 @@ @@ -276,6 +280,7 @@
this.j.add(advancement); this.progressChanged.add(advancement);
flag = true; flag = true;
if (!flag1 && advancementprogress.isDone()) { if (!flag1 && advancementprogress.isDone()) {
+ this.player.world.getServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit + this.player.level.getServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
advancement.d().a(this.player); advancement.d().a(this.player);
if (advancement.c() != null && advancement.c().i() && this.player.world.getGameRules().getBoolean(GameRules.ANNOUNCE_ADVANCEMENTS)) { if (advancement.c() != null && advancement.c().i() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
this.e.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.b); this.playerList.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);

Datei anzeigen

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

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/DispenserRegistry.java --- a/net/minecraft/server/DispenserRegistry.java
+++ b/net/minecraft/server/DispenserRegistry.java +++ b/net/minecraft/server/DispenserRegistry.java
@@ -26,6 +26,12 @@ @@ -28,6 +28,12 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -12,8 +12,32 @@
+ +
public class DispenserRegistry { public class DispenserRegistry {
public static final PrintStream a = System.out; public static final PrintStream STDOUT = System.out;
@@ -50,6 +56,69 @@ @@ -38,6 +44,23 @@
public static void init() {
if (!DispenserRegistry.isBootstrapped) {
+ // CraftBukkit start
+ String name = DispenserRegistry.class.getSimpleName();
+ switch (name) {
+ case "DispenserRegistry":
+ break;
+ case "Bootstrap":
+ System.err.println("***************************************************************************");
+ System.err.println("*** WARNING: This server jar may only be used for development purposes. ***");
+ System.err.println("***************************************************************************");
+ break;
+ default:
+ System.err.println("**********************************************************************");
+ System.err.println("*** WARNING: This server jar is unsupported, use at your own risk. ***");
+ System.err.println("**********************************************************************");
+ break;
+ }
+ // CraftBukkit end
DispenserRegistry.isBootstrapped = true;
if (IRegistry.REGISTRY.keySet().isEmpty()) {
throw new IllegalStateException("Unable to load registries");
@@ -55,6 +78,69 @@
TagStatic.b(); TagStatic.b();
d(); d();
} }
@ -34,51 +58,51 @@
+ DataConverterFlattenData.map(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); + DataConverterFlattenData.map(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}");
+ DataConverterFlattenData.map(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); + DataConverterFlattenData.map(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}");
+ DataConverterFlattenData.map(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); + DataConverterFlattenData.map(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}");
+ DataConverterMaterialId.ID_MAPPING.put(323, "minecraft:oak_sign"); + DataConverterMaterialId.ITEM_NAMES.put(323, "minecraft:oak_sign");
+ +
+ DataConverterFlattenData.map(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); + DataConverterFlattenData.map(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"});
+ +
+ DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard"); + DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard");
+ DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals"); + DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals");
+ DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit"); + DataConverterMaterialId.ITEM_NAMES.put(411, "minecraft:rabbit");
+ DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit"); + DataConverterMaterialId.ITEM_NAMES.put(412, "minecraft:cooked_rabbit");
+ DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew"); + DataConverterMaterialId.ITEM_NAMES.put(413, "minecraft:rabbit_stew");
+ DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot"); + DataConverterMaterialId.ITEM_NAMES.put(414, "minecraft:rabbit_foot");
+ DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide"); + DataConverterMaterialId.ITEM_NAMES.put(415, "minecraft:rabbit_hide");
+ DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand"); + DataConverterMaterialId.ITEM_NAMES.put(416, "minecraft:armor_stand");
+ +
+ DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton"); + DataConverterMaterialId.ITEM_NAMES.put(423, "minecraft:mutton");
+ DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton"); + DataConverterMaterialId.ITEM_NAMES.put(424, "minecraft:cooked_mutton");
+ DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner"); + DataConverterMaterialId.ITEM_NAMES.put(425, "minecraft:banner");
+ DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal"); + DataConverterMaterialId.ITEM_NAMES.put(426, "minecraft:end_crystal");
+ DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door"); + DataConverterMaterialId.ITEM_NAMES.put(427, "minecraft:spruce_door");
+ DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door"); + DataConverterMaterialId.ITEM_NAMES.put(428, "minecraft:birch_door");
+ DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door"); + DataConverterMaterialId.ITEM_NAMES.put(429, "minecraft:jungle_door");
+ DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door"); + DataConverterMaterialId.ITEM_NAMES.put(430, "minecraft:acacia_door");
+ DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door"); + DataConverterMaterialId.ITEM_NAMES.put(431, "minecraft:dark_oak_door");
+ DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit"); + DataConverterMaterialId.ITEM_NAMES.put(432, "minecraft:chorus_fruit");
+ DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped"); + DataConverterMaterialId.ITEM_NAMES.put(433, "minecraft:chorus_fruit_popped");
+ DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot"); + DataConverterMaterialId.ITEM_NAMES.put(434, "minecraft:beetroot");
+ DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds"); + DataConverterMaterialId.ITEM_NAMES.put(435, "minecraft:beetroot_seeds");
+ DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup"); + DataConverterMaterialId.ITEM_NAMES.put(436, "minecraft:beetroot_soup");
+ DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath"); + DataConverterMaterialId.ITEM_NAMES.put(437, "minecraft:dragon_breath");
+ DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion"); + DataConverterMaterialId.ITEM_NAMES.put(438, "minecraft:splash_potion");
+ DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow"); + DataConverterMaterialId.ITEM_NAMES.put(439, "minecraft:spectral_arrow");
+ DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow"); + DataConverterMaterialId.ITEM_NAMES.put(440, "minecraft:tipped_arrow");
+ DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion"); + DataConverterMaterialId.ITEM_NAMES.put(441, "minecraft:lingering_potion");
+ DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield"); + DataConverterMaterialId.ITEM_NAMES.put(442, "minecraft:shield");
+ DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra"); + DataConverterMaterialId.ITEM_NAMES.put(443, "minecraft:elytra");
+ DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat"); + DataConverterMaterialId.ITEM_NAMES.put(444, "minecraft:spruce_boat");
+ DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat"); + DataConverterMaterialId.ITEM_NAMES.put(445, "minecraft:birch_boat");
+ DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat"); + DataConverterMaterialId.ITEM_NAMES.put(446, "minecraft:jungle_boat");
+ DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat"); + DataConverterMaterialId.ITEM_NAMES.put(447, "minecraft:acacia_boat");
+ DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat"); + DataConverterMaterialId.ITEM_NAMES.put(448, "minecraft:dark_oak_boat");
+ DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying"); + DataConverterMaterialId.ITEM_NAMES.put(449, "minecraft:totem_of_undying");
+ DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell"); + DataConverterMaterialId.ITEM_NAMES.put(450, "minecraft:shulker_shell");
+ DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget"); + DataConverterMaterialId.ITEM_NAMES.put(452, "minecraft:iron_nugget");
+ DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book"); + DataConverterMaterialId.ITEM_NAMES.put(453, "minecraft:knowledge_book");
+ +
+ DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow"; + DataConverterSpawnEgg.ID_TO_ENTITY[23] = "Arrow";
+ // CraftBukkit end + // CraftBukkit end
} }
} }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java --- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java
@@ -54,13 +54,20 @@ @@ -58,6 +58,12 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -13,16 +13,18 @@
public class Main { public class Main {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -65,8 +71,9 @@
public Main() {} public Main() {}
@DontObfuscate
- public static void main(String[] astring) { - public static void main(String[] astring) {
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) + public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
SharedConstants.a();
+ /* CraftBukkit start - Replace everything + /* CraftBukkit start - Replace everything
OptionParser optionparser = new OptionParser(); OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui"); OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits"); OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -84,21 +91,23 @@ @@ -90,20 +97,22 @@
optionparser.printHelpOn(System.err); optionparser.printHelpOn(System.err);
return; return;
} }
@ -33,26 +35,21 @@
DispenserRegistry.init(); DispenserRegistry.init();
DispenserRegistry.c(); DispenserRegistry.c();
SystemUtils.l(); SystemUtils.l();
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.b(); IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.a();
- Path path = Paths.get("server.properties"); Path path = Paths.get("server.properties");
- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, path); - DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path);
+ java.nio.file.Path java_nio_file_path = Paths.get("server.properties"); + DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support
+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(iregistrycustom_dimension, optionset); // CraftBukkit - CLI argument support
dedicatedserversettings.save(); dedicatedserversettings.save();
- Path path1 = Paths.get("eula.txt"); Path path1 = Paths.get("eula.txt");
- EULA eula = new EULA(path1); EULA eula = new EULA(path1);
+ java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt");
+ EULA eula = new EULA(java_nio_file_path1);
- if (optionset.has(optionspec1)) { - if (optionset.has(optionspec1)) {
- Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath());
+ if (optionset.has("initSettings")) { // CraftBukkit + if (optionset.has("initSettings")) { // CraftBukkit
+ Main.LOGGER.info("Initialized '{}' and '{}'", java_nio_file_path.toAbsolutePath(), java_nio_file_path1.toAbsolutePath()); Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath());
return; return;
} }
@@ -113,14 +122,15 @@
@@ -107,24 +116,42 @@
return; return;
} }
@ -61,15 +58,19 @@
YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY); YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY);
MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName())); UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.USERID_CACHE_FILE.getName()));
- String s = (String) Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName); - String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
+ // CraftBukkit start + // CraftBukkit start
+ String s = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); + String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
Convertable convertable = Convertable.a(file.toPath()); Convertable convertable = Convertable.a(file.toPath());
- Convertable.ConversionSession convertable_conversionsession = convertable.c(s); - Convertable.ConversionSession convertable_conversionsession = convertable.c(s);
+ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD); + Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD);
MinecraftServer.convertWorld(convertable_conversionsession); MinecraftServer.convertWorld(convertable_conversionsession);
WorldInfo worldinfo = convertable_conversionsession.d();
@@ -131,13 +141,30 @@
}
DataPackConfiguration datapackconfiguration = convertable_conversionsession.e(); DataPackConfiguration datapackconfiguration = convertable_conversionsession.e();
- boolean flag = optionset.has(optionspec6); - boolean flag = optionset.has(optionspec6);
+ boolean flag = optionset.has("safeMode"); + boolean flag = optionset.has("safeMode");
@ -78,9 +79,9 @@
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded"); Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
} }
ResourcePackRepository resourcepackrepository = new ResourcePackRepository(new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), PackSource.c)}); ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)});
+ // CraftBukkit start + // CraftBukkit start
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACKS).toFile(), "bukkit"); + File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), "bukkit");
+ if (!bukkitDataPackFolder.exists()) { + if (!bukkitDataPackFolder.exists()) {
+ bukkitDataPackFolder.mkdirs(); + bukkitDataPackFolder.mkdirs();
+ } + }
@ -96,18 +97,18 @@
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex); + throw new RuntimeException("Could not initialize Bukkit datapack", ex);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.a : datapackconfiguration, flag); DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag);
CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run); CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run);
@@ -139,6 +166,7 @@ @@ -152,6 +179,7 @@
} }
datapackresources.i(); datapackresources.j();
+ /* + /*
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, datapackresources.h(), iregistrycustom_dimension); RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, datapackresources.i(), (IRegistryCustom) iregistrycustom_dimension);
Object object = convertable_conversionsession.a((DynamicOps) registryreadops, datapackconfiguration1);
@@ -166,21 +194,32 @@ dedicatedserversettings.getProperties().a((IRegistryCustom) iregistrycustom_dimension);
@@ -181,21 +209,32 @@
} }
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object); convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
@ -126,7 +127,7 @@
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui"); + boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
if (flag1 && !GraphicsEnvironment.isHeadless()) { if (flag1 && !GraphicsEnvironment.isHeadless()) {
dedicatedserver1.bd(); dedicatedserver1.bi();
} }
+ if (optionset.has("port")) { + if (optionset.has("port")) {
@ -142,7 +143,7 @@
Thread thread = new Thread("Server Shutdown Thread") { Thread thread = new Thread("Server Shutdown Thread") {
public void run() { public void run() {
dedicatedserver.safeShutdown(true); dedicatedserver.safeShutdown(true);
@@ -189,14 +228,15 @@ @@ -204,14 +243,15 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread); Runtime.getRuntime().addShutdownHook(thread);

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java --- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java
@@ -155,6 +155,25 @@ @@ -166,6 +166,25 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -26,9 +26,9 @@
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable { public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
@@ -224,6 +243,20 @@ @@ -258,6 +277,20 @@
private final DefinedStructureManager ak; private final DefinedStructureManager structureManager;
protected SaveData saveData; protected SaveData worldData;
+ // CraftBukkit start + // CraftBukkit start
+ public DataPackConfiguration datapackconfiguration; + public DataPackConfiguration datapackconfiguration;
@ -47,7 +47,7 @@
public static <S extends MinecraftServer> S a(Function<Thread, S> function) { public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference(); AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
@@ -233,21 +266,21 @@ @@ -267,14 +300,14 @@
thread.setUncaughtExceptionHandler((thread1, throwable) -> { thread.setUncaughtExceptionHandler((thread1, throwable) -> {
MinecraftServer.LOGGER.error(throwable); MinecraftServer.LOGGER.error(throwable);
}); });
@ -59,27 +59,28 @@
return s0; return s0;
} }
- public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { - public MinecraftServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { + public MinecraftServer(OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, SaveData savedata, ResourcePackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, DataPackResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
super("Server"); super("Server");
this.m = new GameProfilerSwitcher(SystemUtils.a, this::ai); this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.methodProfiler = GameProfilerDisabled.a; this.profiler = this.metricsRecorder.e();
this.serverPing = new ServerPing(); @@ -286,7 +319,7 @@
this.r = new Random(); this.status = new ServerPing();
this.serverPort = -1; this.random = new Random();
- this.worldServer = Maps.newLinkedHashMap(); this.port = -1;
+ this.worldServer = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods - this.levels = Maps.newLinkedHashMap();
this.isRunning = true; + this.levels = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods
this.h = new long[100]; this.running = true;
this.K = ""; this.tickTimes = new long[100];
@@ -273,7 +306,34 @@ this.resourcePack = "";
this.ak = new DefinedStructureManager(datapackresources.h(), convertable_conversionsession, datafixer); @@ -316,13 +349,40 @@
this.structureManager = new DefinedStructureManager(datapackresources.i(), convertable_conversionsession, datafixer);
this.serverThread = thread; this.serverThread = thread;
this.executorService = SystemUtils.f(); this.executor = SystemUtils.f();
+ // CraftBukkit start + // CraftBukkit start
+ this.options = options; + this.options = options;
+ this.datapackconfiguration = datapackconfiguration; + this.datapackconfiguration = datapackconfiguration;
+ this.vanillaCommandDispatcher = datapackresources.commandDispatcher; // CraftBukkit + this.vanillaCommandDispatcher = datapackresources.commands; // CraftBukkit
+ // Try to see if we're actually running in a terminal, disable jline if not + // Try to see if we're actually running in a terminal, disable jline if not
+ if (System.console() == null && System.getProperty("jline.terminal") == null) { + if (System.console() == null && System.getProperty("jline.terminal") == null) {
+ System.setProperty("jline.terminal", "jline.UnsupportedTerminal"); + System.setProperty("jline.terminal", "jline.UnsupportedTerminal");
@ -106,42 +107,49 @@
+ // CraftBukkit end + // CraftBukkit end
private void initializeScoreboards(WorldPersistentData worldpersistentdata) { private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
PersistentScoreboard persistentscoreboard = (PersistentScoreboard) worldpersistentdata.a(PersistentScoreboard::new, "scoreboard"); ScoreboardServer scoreboardserver = this.getScoreboard();
@@ -286,7 +346,7 @@
Objects.requireNonNull(scoreboardserver);
- Function function = scoreboardserver::a;
+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::a; // CraftBukkit - decompile error
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -333,7 +393,7 @@
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) { public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
if (convertable_conversionsession.isConvertable()) { if (convertable_conversionsession.isConvertable()) {
- MinecraftServer.LOGGER.info("Converting map!"); - MinecraftServer.LOGGER.info("Converting map!");
+ MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit + MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
convertable_conversionsession.convert(new IProgressUpdate() { convertable_conversionsession.convert(new IProgressUpdate() {
private long a = SystemUtils.getMonotonicMillis(); private long timeStamp = SystemUtils.getMonotonicMillis();
@@ -309,48 +369,197 @@ @@ -362,48 +422,197 @@
} }
- protected void loadWorld() { - protected void loadWorld() {
- this.loadResourcesZip(); - this.loadResourcesZip();
- this.saveData.a(this.getServerModName(), this.getModded().isPresent()); - this.worldData.a(this.getServerModName(), this.getModded().isPresent());
- WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); - WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ protected void loadWorld(String s) { + protected void loadWorld(String s) {
+ // CraftBukkit start + // CraftBukkit start
+ Convertable.ConversionSession worldSession = this.convertable; + Convertable.ConversionSession worldSession = this.storageSource;
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.customRegistry; + IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder;
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, this.dataPackResources.h(), iregistrycustom_dimension); + RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, this.resources.i(), (IRegistryCustom) iregistrycustom_dimension);
+ WorldDataServer overworldData = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration); + WorldDataServer overworldData = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
+ if (overworldData == null) { + if (overworldData == null) {
+ WorldSettings worldsettings; + WorldSettings worldsettings;
+ GeneratorSettings generatorsettings; + GeneratorSettings generatorsettings;
+ +
+ if (this.isDemoMode()) { + if (this.isDemoMode()) {
+ worldsettings = MinecraftServer.c; + worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); + generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension);
+ } else { + } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties();
+ +
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings; + generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.worldGenSettings.j() : dedicatedserverproperties.worldGenSettings;
+ } + }
+ +
+ overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); + overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
@ -156,13 +164,13 @@
+ WorldServer world; + WorldServer world;
+ int dimension = 0; + int dimension = 0;
+ +
+ if (dimensionKey == WorldDimension.THE_NETHER) { + if (dimensionKey == WorldDimension.NETHER) {
+ if (getAllowNether()) { + if (getAllowNether()) {
+ dimension = -1; + dimension = -1;
+ } else { + } else {
+ continue; + continue;
+ } + }
+ } else if (dimensionKey == WorldDimension.THE_END) { + } else if (dimensionKey == WorldDimension.END) {
+ if (server.getAllowEnd()) { + if (server.getAllowEnd()) {
+ dimension = 1; + dimension = 1;
+ } else { + } else {
@ -225,13 +233,13 @@
+ GeneratorSettings generatorsettings; + GeneratorSettings generatorsettings;
+ +
+ if (this.isDemoMode()) { + if (this.isDemoMode()) {
+ worldsettings = MinecraftServer.c; + worldsettings = MinecraftServer.DEMO_SETTINGS;
+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension); + generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension);
+ } else { + } else {
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties(); + DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties();
+ +
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration); + worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.generatorSettings.j() : dedicatedserverproperties.generatorSettings; + generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.worldGenSettings.j() : dedicatedserverproperties.worldGenSettings;
+ } + }
+ +
+ worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable()); + worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
@ -241,7 +249,7 @@
+ net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> { + net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> {
+ return true; + return true;
+ }, worlddata.getGeneratorSettings().d().d().stream().map((entry1) -> { + }, worlddata.getGeneratorSettings().d().d().stream().map((entry1) -> {
+ return ResourceKey.a(IRegistry.K, ((ResourceKey) entry1.getKey()).a()); + return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).a());
+ }).collect(ImmutableSet.toImmutableSet())); + }).collect(ImmutableSet.toImmutableSet()));
+ } + }
+ +
@ -256,35 +264,35 @@
+ ChunkGenerator chunkgenerator; + ChunkGenerator chunkgenerator;
+ +
+ if (worlddimension == null) { + if (worlddimension == null) {
+ dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD); + dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION);
+ chunkgenerator = GeneratorSettings.a(customRegistry.b(IRegistry.ay), customRegistry.b(IRegistry.ar), (new Random()).nextLong()); + chunkgenerator = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong());
+ } else { + } else {
+ dimensionmanager = worlddimension.b(); + dimensionmanager = worlddimension.b();
+ chunkgenerator = worlddimension.c(); + chunkgenerator = worlddimension.c();
+ } + }
+ +
+ ResourceKey<World> worldKey = ResourceKey.a(IRegistry.L, dimensionKey.a()); + ResourceKey<World> worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, dimensionKey.a());
+ +
+ if (dimensionKey == WorldDimension.OVERWORLD) { + if (dimensionKey == WorldDimension.OVERWORLD) {
+ this.saveData = worlddata; + this.worldData = worlddata;
+ this.saveData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init + this.worldData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init
+ +
+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ +
+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen);
+ WorldPersistentData worldpersistentdata = world.getWorldPersistentData(); + WorldPersistentData worldpersistentdata = world.getWorldPersistentData();
+ this.initializeScoreboards(worldpersistentdata); + this.initializeScoreboards(worldpersistentdata);
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard()); + this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
+ this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); + this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ } else { + } else {
+ WorldLoadListener worldloadlistener = this.worldLoadListenerFactory.create(11); + WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
+ world = new WorldServer(this, this.executorService, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen); + world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen);
+ } + }
+ +
+ worlddata.a(this.getServerModName(), this.getModded().isPresent()); + worlddata.a(this.getServerModName(), this.getModded().isPresent());
+ this.initWorld(world, worlddata, saveData, worlddata.getGeneratorSettings()); + this.initWorld(world, worlddata, worldData, worlddata.getGeneratorSettings());
+ +
+ this.worldServer.put(world.getDimensionKey(), world); + this.levels.put(world.getDimensionKey(), world);
+ this.getPlayerList().setPlayerFileData(world); + this.getPlayerList().setPlayerFileData(world);
+ +
+ if (worlddata.getCustomBossEvents() != null) { + if (worlddata.getCustomBossEvents() != null) {
@ -294,21 +302,21 @@
this.updateWorldSettings(); this.updateWorldSettings();
- this.loadSpawn(worldloadlistener); - this.loadSpawn(worldloadlistener);
+ for (WorldServer worldserver : this.getWorlds()) { + for (WorldServer worldserver : this.getWorlds()) {
+ this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver); + this.loadSpawn(worldserver.getChunkProvider().chunkMap.progressListener, worldserver);
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
+ } + }
+ +
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); + this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
+ this.serverConnection.acceptConnections(); + this.connection.acceptConnections();
+ // CraftBukkit end + // CraftBukkit end
} }
protected void updateWorldSettings() {} protected void updateWorldSettings() {}
- protected void a(WorldLoadListener worldloadlistener) { - protected void a(WorldLoadListener worldloadlistener) {
- IWorldDataServer iworlddataserver = this.saveData.H(); - IWorldDataServer iworlddataserver = this.worldData.H();
- GeneratorSettings generatorsettings = this.saveData.getGeneratorSettings(); - GeneratorSettings generatorsettings = this.worldData.getGeneratorSettings();
+ // CraftBukkit start + // CraftBukkit start
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) { + public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) {
boolean flag = generatorsettings.isDebugWorld(); boolean flag = generatorsettings.isDebugWorld();
@ -321,8 +329,8 @@
- Object object; - Object object;
- -
- if (worlddimension == null) { - if (worlddimension == null) {
- dimensionmanager = (DimensionManager) this.customRegistry.a().d(DimensionManager.OVERWORLD); - dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION);
- object = GeneratorSettings.a(this.customRegistry.b(IRegistry.ay), this.customRegistry.b(IRegistry.ar), (new Random()).nextLong()); - object = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong());
- } else { - } else {
- dimensionmanager = worlddimension.b(); - dimensionmanager = worlddimension.b();
- object = worlddimension.c(); - object = worlddimension.c();
@ -331,28 +339,28 @@
+ worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld())); + worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld()));
} }
- -
- WorldServer worldserver = new WorldServer(this, this.executorService, this.convertable, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true); - WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
- -
- this.worldServer.put(World.OVERWORLD, worldserver); - this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData(); - WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData();
- -
- this.initializeScoreboards(worldpersistentdata); - this.initializeScoreboards(worldpersistentdata);
- this.persistentCommandStorage = new PersistentCommandStorage(worldpersistentdata); - this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
WorldBorder worldborder = worldserver.getWorldBorder(); WorldBorder worldborder = worldserver.getWorldBorder();
worldborder.a(iworlddataserver.r()); worldborder.a(iworlddataserver.r());
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569 + this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569
if (!iworlddataserver.p()) { if (!iworlddataserver.p()) {
try { try {
a(worldserver, iworlddataserver, generatorsettings.c(), flag, true); a(worldserver, iworlddataserver, generatorsettings.c(), flag);
@@ -372,31 +581,8 @@ @@ -425,31 +634,8 @@
iworlddataserver.c(true); iworlddataserver.c(true);
} }
- -
- this.getPlayerList().setPlayerFileData(worldserver); - this.getPlayerList().setPlayerFileData(worldserver);
- if (this.saveData.getCustomBossEvents() != null) { - if (this.worldData.getCustomBossEvents() != null) {
- this.getBossBattleCustomData().load(this.saveData.getCustomBossEvents()); - this.getBossBattleCustomData().load(this.worldData.getCustomBossEvents());
- } - }
- -
- Iterator iterator = registrymaterials.d().iterator(); - Iterator iterator = registrymaterials.d().iterator();
@ -362,23 +370,23 @@
- ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey(); - ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
- -
- if (resourcekey != WorldDimension.OVERWORLD) { - if (resourcekey != WorldDimension.OVERWORLD) {
- ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a()); - ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, resourcekey.a());
- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b(); - DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b();
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c(); - ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c();
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.saveData, iworlddataserver); - SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver);
- WorldServer worldserver1 = new WorldServer(this, this.executorService, this.convertable, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false); - WorldServer worldserver1 = new WorldServer(this, this.executor, this.storageSource, secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), false);
- -
- worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder()))); - worldborder.a((IWorldBorderListener) (new IWorldBorderListener.a(worldserver1.getWorldBorder())));
- this.worldServer.put(resourcekey1, worldserver1); - this.levels.put(resourcekey1, worldserver1);
- } - }
- } - }
- -
} }
+ // CraftBukkit end + // CraftBukkit end
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1, boolean flag2) { private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
ChunkGenerator chunkgenerator = worldserver.getChunkProvider().getChunkGenerator(); if (flag1) {
@@ -412,6 +598,21 @@ @@ -462,6 +648,21 @@
return biomebase.b().b(); return biomebase.b().b();
}, random); }, random);
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition); ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
@ -400,60 +408,58 @@
if (blockposition == null) { if (blockposition == null) {
MinecraftServer.LOGGER.warn("Unable to find spawn biome"); MinecraftServer.LOGGER.warn("Unable to find spawn biome");
@@ -478,8 +679,15 @@ @@ -536,8 +737,15 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR); iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
} }
- public void loadSpawn(WorldLoadListener worldloadlistener) { - public void loadSpawn(WorldLoadListener worldloadlistener) {
- WorldServer worldserver = this.E(); - WorldServer worldserver = this.F();
+ // CraftBukkit start + // CraftBukkit start
+ public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) { + public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) {
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) { + if (!worldserver.getWorld().getKeepSpawnInMemory()) {
+ return; + return;
+ } + }
+ +
+ // WorldServer worldserver = this.E(); + // WorldServer worldserver = this.F();
+ this.forceTicks = true; + this.forceTicks = true;
+ // CraftBukkit end + // CraftBukkit end
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a()); MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
BlockPosition blockposition = worldserver.getSpawn(); BlockPosition blockposition = worldserver.getSpawn();
@@ -492,17 +700,21 @@ @@ -550,16 +758,20 @@
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE); chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
while (chunkproviderserver.b() != 441) { while (chunkproviderserver.b() != 441) {
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; - this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
- this.sleepForTick(); - this.sleepForTick();
+ // CraftBukkit start + // CraftBukkit start
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; + // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
+ this.executeModerately(); + this.executeModerately();
+ // CraftBukkit end + // CraftBukkit end
} }
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; - this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
- this.sleepForTick(); - this.sleepForTick();
- Iterator iterator = this.worldServer.values().iterator(); - Iterator iterator = this.levels.values().iterator();
- -
- while (iterator.hasNext()) { - while (iterator.hasNext()) {
- WorldServer worldserver1 = (WorldServer) iterator.next(); - WorldServer worldserver1 = (WorldServer) iterator.next();
- ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().b(ForcedChunk::new, "chunks");
+ // CraftBukkit start + // CraftBukkit start
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; + // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
+ this.executeModerately(); + this.executeModerately();
+ // Iterator iterator = this.worldServer.values().iterator(); + // Iterator iterator = this.worldServer.values().iterator();
+ +
+ if (true) { + if (true) {
+ WorldServer worldserver1 = worldserver; + WorldServer worldserver1 = worldserver;
+ ForcedChunk forcedchunk = (ForcedChunk) worldserver.getWorldPersistentData().b(ForcedChunk::new, "chunks");
+ // CraftBukkit end + // CraftBukkit end
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().a(ForcedChunk::b, "chunks");
if (forcedchunk != null) { if (forcedchunk != null) {
LongIterator longiterator = forcedchunk.a().iterator(); @@ -574,11 +786,18 @@
@@ -516,11 +728,18 @@
} }
} }
- this.nextTick = SystemUtils.getMonotonicMillis() + 10L; - this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
- this.sleepForTick(); - this.sleepForTick();
+ // CraftBukkit start + // CraftBukkit start
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L; + // this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
@ -471,24 +477,24 @@
} }
protected void loadResourcesZip() { protected void loadResourcesZip() {
@@ -565,12 +784,16 @@ @@ -623,12 +842,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.savingDisabled && !flag2); worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
} }
+ // CraftBukkit start - moved to WorldServer.save + // CraftBukkit start - moved to WorldServer.save
+ /* + /*
WorldServer worldserver1 = this.E(); WorldServer worldserver1 = this.F();
IWorldDataServer iworlddataserver = this.saveData.H(); IWorldDataServer iworlddataserver = this.worldData.H();
iworlddataserver.a(worldserver1.getWorldBorder().t()); iworlddataserver.a(worldserver1.getWorldBorder().t());
this.saveData.setCustomBossEvents(this.getBossBattleCustomData().save()); this.worldData.setCustomBossEvents(this.getBossBattleCustomData().save());
this.convertable.a(this.customRegistry, this.saveData, this.getPlayerList().save()); this.storageSource.a(this.registryHolder, this.worldData, this.getPlayerList().save());
+ */ + */
+ // CraftBukkit end + // CraftBukkit end
return flag3; return flag3;
} }
@@ -579,8 +802,29 @@ @@ -637,8 +860,29 @@
this.stop(); this.stop();
} }
@ -502,7 +508,7 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
protected void stop() { public void stop() {
+ // CraftBukkit start - prevent double stopping on multiple threads + // CraftBukkit start - prevent double stopping on multiple threads
+ synchronized(stopLock) { + synchronized(stopLock) {
+ if (hasStopped) return; + if (hasStopped) return;
@ -518,7 +524,7 @@
if (this.getServerConnection() != null) { if (this.getServerConnection() != null) {
this.getServerConnection().b(); this.getServerConnection().b();
} }
@@ -589,6 +833,7 @@ @@ -647,6 +891,7 @@
MinecraftServer.LOGGER.info("Saving players"); MinecraftServer.LOGGER.info("Saving players");
this.playerList.savePlayers(); this.playerList.savePlayers();
this.playerList.shutdown(); this.playerList.shutdown();
@ -526,25 +532,27 @@
} }
MinecraftServer.LOGGER.info("Saving worlds"); MinecraftServer.LOGGER.info("Saving worlds");
@@ -666,14 +911,16 @@ @@ -724,9 +969,10 @@
while (this.isRunning) { while (this.running) {
long i = SystemUtils.getMonotonicMillis() - this.nextTick; long i = SystemUtils.getMonotonicMillis() - this.nextTickTime;
- if (i > 2000L && this.nextTick - this.lastOverloadTime >= 15000L) { - if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) {
+ if (i > 5000L && this.nextTick - this.lastOverloadTime >= 30000L) { // CraftBukkit + if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
long j = i / 50L; long j = i / 50L;
+ if (server.getWarnOnOverload()) // CraftBukkit + if (server.getWarnOnOverload()) // CraftBukkit
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j); MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTick += j * 50L; this.nextTickTime += j * 50L;
this.lastOverloadTime = this.nextTick; this.lastOverloadWarning = this.nextTickTime;
@@ -737,6 +983,7 @@
this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getMonotonicNanos(), this.tickCount);
} }
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit + MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
this.nextTick += 50L; this.nextTickTime += 50L;
GameProfilerTick gameprofilertick = GameProfilerTick.a("Server"); this.bi();
this.profiler.enter("tick");
@@ -719,6 +966,12 @@ @@ -782,6 +1029,12 @@
} catch (Throwable throwable1) { } catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1); MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally { } finally {
@ -557,13 +565,13 @@
this.exit(); this.exit();
} }
@@ -727,8 +980,15 @@ @@ -790,8 +1043,15 @@
} }
private boolean canSleepForTick() { private boolean canSleepForTick() {
- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); - return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
+ // CraftBukkit start + // CraftBukkit start
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick); + return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
+ } + }
+ +
+ private void executeModerately() { + private void executeModerately() {
@ -574,23 +582,23 @@
protected void sleepForTick() { protected void sleepForTick() {
this.executeAll(); this.executeAll();
@@ -834,7 +1094,7 @@ @@ -906,7 +1166,7 @@
this.serverPing.b().a(agameprofile); this.status.b().a(agameprofile);
} }
- if (this.ticks % 6000 == 0) { - if (this.tickCount % 6000 == 0) {
+ if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit + if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit
MinecraftServer.LOGGER.debug("Autosave started"); MinecraftServer.LOGGER.debug("Autosave started");
this.methodProfiler.enter("save"); this.profiler.enter("save");
this.playerList.savePlayers(); this.playerList.savePlayers();
@@ -864,22 +1124,39 @@ @@ -936,22 +1196,39 @@
} }
protected void b(BooleanSupplier booleansupplier) { public void b(BooleanSupplier booleansupplier) {
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks); // CraftBukkit + this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit
this.methodProfiler.enter("commandFunctions"); this.profiler.enter("commandFunctions");
this.getFunctionData().tick(); this.getFunctionData().tick();
this.methodProfiler.exitEnter("levels"); this.profiler.exitEnter("levels");
Iterator iterator = this.getWorlds().iterator(); Iterator iterator = this.getWorlds().iterator();
+ // CraftBukkit start + // CraftBukkit start
@ -600,59 +608,59 @@
+ } + }
+ +
+ // Send time updates to everyone, it will get the right time from the world the player is in. + // Send time updates to everyone, it will get the right time from the world the player is in.
+ if (this.ticks % 20 == 0) { + if (this.tickCount % 20 == 0) {
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) { + for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
+ EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i); + EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); // Add support for per player time + entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.level.getTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
+ } + }
+ } + }
+ +
while (iterator.hasNext()) { while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next(); WorldServer worldserver = (WorldServer) iterator.next();
this.methodProfiler.a(() -> { this.profiler.a(() -> {
return worldserver + " " + worldserver.getDimensionKey().a(); return worldserver + " " + worldserver.getDimensionKey().a();
}); });
+ /* Drop global time updates + /* Drop global time updates
if (this.ticks % 20 == 0) { if (this.tickCount % 20 == 0) {
this.methodProfiler.enter("timeSync"); this.profiler.enter("timeSync");
this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))), worldserver.getDimensionKey()); this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))), worldserver.getDimensionKey());
this.methodProfiler.exit(); this.profiler.exit();
} }
+ // CraftBukkit end */ + // CraftBukkit end */
this.methodProfiler.enter("tick"); this.profiler.enter("tick");
@@ -963,7 +1240,7 @@ @@ -1040,7 +1317,7 @@
}
@DontObfuscate
public String getServerModName() { public String getServerModName() {
- return "vanilla"; - return "vanilla";
+ return server.getName(); // CraftBukkit - cb > vanilla! + return server.getName(); // CraftBukkit - cb > vanilla!
} }
public CrashReport b(CrashReport crashreport) { public SystemReport b(SystemReport systemreport) {
@@ -1320,16 +1597,17 @@ @@ -1412,16 +1689,17 @@
public CompletableFuture<Void> a(Collection<String> collection) { public CompletableFuture<Void> a(Collection<String> collection) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
- Stream stream = collection.stream(); - Stream stream = collection.stream();
+ Stream<String> stream = collection.stream(); // CraftBukkit - decompile error + Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
ResourcePackRepository resourcepackrepository = this.resourcePackRepository; ResourcePackRepository resourcepackrepository = this.packRepository;
this.resourcePackRepository.getClass(); Objects.requireNonNull(this.packRepository);
- return (ImmutableList) stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); - return (ImmutableList) stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList());
+ return stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error + return stream.map(resourcepackrepository::a).filter(Objects::nonNull).map(ResourcePackLoader::d).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
}, this).thenCompose((immutablelist) -> { }, this).thenCompose((immutablelist) -> {
return DataPackResources.a(immutablelist, this.j() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.h(), this.executorService, this); return DataPackResources.a(immutablelist, this.registryHolder, this.k() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.i(), this.executor, this);
}).thenAcceptAsync((datapackresources) -> { }).thenAcceptAsync((datapackresources) -> {
this.dataPackResources.close(); this.resources.close();
this.dataPackResources = datapackresources; this.resources = datapackresources;
+ this.server.syncCommands(); // SPIGOT-5884: Lost on reload + this.server.syncCommands(); // SPIGOT-5884: Lost on reload
this.resourcePackRepository.a(collection); this.packRepository.a(collection);
this.saveData.a(a(this.resourcePackRepository)); this.worldData.a(a(this.packRepository));
datapackresources.i(); datapackresources.j();
@@ -1695,6 +1973,22 @@ @@ -1766,6 +2044,22 @@
} }
@ -672,6 +680,6 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
private void a(@Nullable GameProfilerTick gameprofilertick) { private void bi() {
if (this.O) { if (this.willStartRecordingMetrics) {
this.O = false; this.metricsRecorder = ActiveMetricsRecorder.a(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.k()), SystemUtils.timeSource, SystemUtils.g(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {

Datei anzeigen

@ -1,100 +1,100 @@
--- a/net/minecraft/server/ScoreboardServer.java --- a/net/minecraft/server/ScoreboardServer.java
+++ b/net/minecraft/server/ScoreboardServer.java +++ b/net/minecraft/server/ScoreboardServer.java
@@ -32,7 +32,7 @@ @@ -34,7 +34,7 @@
public void handleScoreChanged(ScoreboardScore scoreboardscore) { public void handleScoreChanged(ScoreboardScore scoreboardscore) {
super.handleScoreChanged(scoreboardscore); super.handleScoreChanged(scoreboardscore);
if (this.b.contains(scoreboardscore.getObjective())) { if (this.trackedObjectives.contains(scoreboardscore.getObjective())) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore())); + this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getPlayerName(), scoreboardscore.getScore()));
} }
this.b(); this.a();
@@ -41,7 +41,7 @@ @@ -43,7 +43,7 @@
@Override @Override
public void handlePlayerRemoved(String s) { public void handlePlayerRemoved(String s) {
super.handlePlayerRemoved(s); super.handlePlayerRemoved(s);
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0)); + this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
this.b(); this.a();
} }
@@ -49,7 +49,7 @@ @@ -51,7 +51,7 @@
public void a(String s, ScoreboardObjective scoreboardobjective) { public void a(String s, ScoreboardObjective scoreboardobjective) {
super.a(s, scoreboardobjective); super.a(s, scoreboardobjective);
if (this.b.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
+ this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0)); + this.sendAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
} }
this.b(); this.a();
@@ -62,7 +62,7 @@ @@ -64,7 +64,7 @@
super.setDisplaySlot(i, scoreboardobjective); super.setDisplaySlot(i, scoreboardobjective);
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
if (this.h(scoreboardobjective1) > 0) { if (this.h(scoreboardobjective1) > 0) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
} else { } else {
this.g(scoreboardobjective1); this.g(scoreboardobjective1);
} }
@@ -70,7 +70,7 @@ @@ -72,7 +72,7 @@
if (scoreboardobjective != null) { if (scoreboardobjective != null) {
if (this.b.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective)); + this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
} else { } else {
this.e(scoreboardobjective); this.e(scoreboardobjective);
} }
@@ -82,7 +82,7 @@ @@ -84,7 +84,7 @@
@Override @Override
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) { public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
if (super.addPlayerToTeam(s, scoreboardteam)) { if (super.addPlayerToTeam(s, scoreboardteam)) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3)); - this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 3)); + this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
this.b(); this.a();
return true; return true;
} else { } else {
@@ -93,7 +93,7 @@ @@ -95,7 +95,7 @@
@Override @Override
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) { public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
super.removePlayerFromTeam(s, scoreboardteam); super.removePlayerFromTeam(s, scoreboardteam);
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4)); - this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, Arrays.asList(s), 4)); + this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
this.b(); this.a();
} }
@@ -107,7 +107,7 @@ @@ -109,7 +109,7 @@
public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) { public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) {
super.handleObjectiveChanged(scoreboardobjective); super.handleObjectiveChanged(scoreboardobjective);
if (this.b.contains(scoreboardobjective)) { if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); - this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
+ this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); + this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
} }
this.b(); this.a();
@@ -126,21 +126,21 @@ @@ -128,21 +128,21 @@
@Override @Override
public void handleTeamAdded(ScoreboardTeam scoreboardteam) { public void handleTeamAdded(ScoreboardTeam scoreboardteam) {
super.handleTeamAdded(scoreboardteam); super.handleTeamAdded(scoreboardteam);
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); - this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 0)); + this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true));
this.b(); this.a();
} }
@Override @Override
public void handleTeamChanged(ScoreboardTeam scoreboardteam) { public void handleTeamChanged(ScoreboardTeam scoreboardteam) {
super.handleTeamChanged(scoreboardteam); super.handleTeamChanged(scoreboardteam);
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); - this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 2)); + this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false));
this.b(); this.a();
} }
@Override @Override
public void handleTeamRemoved(ScoreboardTeam scoreboardteam) { public void handleTeamRemoved(ScoreboardTeam scoreboardteam) {
super.handleTeamRemoved(scoreboardteam); super.handleTeamRemoved(scoreboardteam);
- this.a.getPlayerList().sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); - this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam));
+ this.sendAll(new PacketPlayOutScoreboardTeam(scoreboardteam, 1)); + this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam));
this.b(); this.a();
} }
@@ -189,6 +189,7 @@ @@ -189,6 +189,7 @@
@ -113,15 +113,15 @@
Iterator iterator1 = list.iterator(); Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -245,6 +247,16 @@ @@ -257,6 +259,16 @@
return i; return this.b().b(nbttagcompound);
} }
+ // CraftBukkit start - Send to players + // CraftBukkit start - Send to players
+ private void sendAll(Packet packet) { + private void sendAll(Packet packet) {
+ for (EntityPlayer entityplayer : (List<EntityPlayer>) this.a.getPlayerList().players) { + for (EntityPlayer entityplayer : (List<EntityPlayer>) this.server.getPlayerList().players) {
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { + if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) {
+ entityplayer.playerConnection.sendPacket(packet); + entityplayer.connection.sendPacket(packet);
+ } + }
+ } + }
+ } + }

Datei anzeigen

@ -11,10 +11,10 @@
+ +
public class BossBattleCustom extends BossBattleServer { public class BossBattleCustom extends BossBattleServer {
private final MinecraftKey h; private final MinecraftKey id;
private final Set<UUID> i = Sets.newHashSet(); private final Set<UUID> players = Sets.newHashSet();
private int j; private int value;
private int k = 100; private int max = 100;
+ // CraftBukkit start + // CraftBukkit start
+ private KeyedBossBar bossBar; + private KeyedBossBar bossBar;
+ +

Datei anzeigen

@ -1,15 +1,15 @@
--- a/net/minecraft/server/commands/CommandEffect.java --- a/net/minecraft/server/commands/CommandEffect.java
+++ b/net/minecraft/server/commands/CommandEffect.java +++ b/net/minecraft/server/commands/CommandEffect.java
@@ -71,7 +71,7 @@ @@ -73,7 +73,7 @@
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag); MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag);
- if (((EntityLiving) entity).addEffect(mobeffect)) { - if (((EntityLiving) entity).addEffect(mobeffect, commandlistenerwrapper.getEntity())) {
+ if (((EntityLiving) entity).addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit + if (((EntityLiving) entity).addEffect(mobeffect, commandlistenerwrapper.getEntity(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.COMMAND)) { // CraftBukkit
++j; ++j;
} }
} }
@@ -97,7 +97,7 @@ @@ -99,7 +99,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -18,7 +18,7 @@
++i; ++i;
} }
} }
@@ -122,7 +122,7 @@ @@ -124,7 +124,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();

Datei anzeigen

@ -1,15 +0,0 @@
--- a/net/minecraft/server/commands/CommandGamemode.java
+++ b/net/minecraft/server/commands/CommandGamemode.java
@@ -63,6 +63,12 @@
if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
entityplayer.a(enumgamemode);
+ // CraftBukkit start - handle event cancelling the change
+ if (entityplayer.playerInteractManager.getGameMode() != enumgamemode) {
+ commandcontext.getSource().sendFailureMessage(new net.minecraft.network.chat.ChatComponentText("Failed to set the gamemode of '" + entityplayer.getName() + "'"));
+ continue;
+ }
+ // CraftBukkit end
a((CommandListenerWrapper) commandcontext.getSource(), entityplayer, enumgamemode);
++i;
}

Datei anzeigen

@ -1,18 +1,18 @@
--- a/net/minecraft/server/commands/CommandGamerule.java --- a/net/minecraft/server/commands/CommandGamerule.java
+++ b/net/minecraft/server/commands/CommandGamerule.java +++ b/net/minecraft/server/commands/CommandGamerule.java
@@ -29,7 +29,7 @@ @@ -31,7 +31,7 @@
private static <T extends GameRules.GameRuleValue<T>> int b(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) { static <T extends GameRules.GameRuleValue<T>> int a(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource(); CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource();
- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); - T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit + T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit
t0.b(commandcontext, "value"); t0.b(commandcontext, "value");
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true); commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true);
@@ -37,7 +37,7 @@ @@ -39,7 +39,7 @@
} }
private static <T extends GameRules.GameRuleValue<T>> int b(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) { static <T extends GameRules.GameRuleValue<T>> int a(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey); - T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey);
+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit + T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandList.java --- a/net/minecraft/server/commands/CommandList.java
+++ b/net/minecraft/server/commands/CommandList.java +++ b/net/minecraft/server/commands/CommandList.java
@@ -36,6 +36,12 @@ @@ -37,6 +37,12 @@
private static int a(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) { private static int a(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList(); PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
List<EntityPlayer> list = playerlist.getPlayers(); List<EntityPlayer> list = playerlist.getPlayers();
@ -10,6 +10,6 @@
+ list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList()); + list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList());
+ } + }
+ // CraftBukkit end + // CraftBukkit end
IChatMutableComponent ichatmutablecomponent = ChatComponentUtils.b(list, function); IChatBaseComponent ichatbasecomponent = ChatComponentUtils.b(list, function);
commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatmutablecomponent}), false); commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false);

Datei anzeigen

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

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandSpreadPlayers.java --- a/net/minecraft/server/commands/CommandSpreadPlayers.java
+++ b/net/minecraft/server/commands/CommandSpreadPlayers.java +++ b/net/minecraft/server/commands/CommandSpreadPlayers.java
@@ -77,7 +77,7 @@ @@ -80,7 +80,7 @@
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
set.add(entity.getScoreboardTeam()); set.add(entity.getScoreboardTeam());
} else { } else {
@ -9,27 +9,27 @@
} }
} }
@@ -286,7 +286,7 @@ @@ -289,7 +289,7 @@
for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > 0; flag2 = flag1) { for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
blockposition_mutableblockposition.c(EnumDirection.DOWN); blockposition_mutableblockposition.c(EnumDirection.DOWN);
- flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); - flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir();
+ flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit + flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
if (!flag1 && flag2 && flag) { if (!flag1 && flag2 && flag) {
return blockposition_mutableblockposition.getY() + 1; return blockposition_mutableblockposition.getY() + 1;
} }
@@ -299,7 +299,7 @@ @@ -302,7 +302,7 @@
public boolean b(IBlockAccess iblockaccess, int i) { public boolean b(IBlockAccess iblockaccess, int i) {
BlockPosition blockposition = new BlockPosition(this.a, (double) (this.a(iblockaccess, i) - 1), this.b); BlockPosition blockposition = new BlockPosition(this.x, (double) (this.a(iblockaccess, i) - 1), this.z);
- IBlockData iblockdata = iblockaccess.getType(blockposition); - IBlockData iblockdata = iblockaccess.getType(blockposition);
+ IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit + IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
Material material = iblockdata.getMaterial(); Material material = iblockdata.getMaterial();
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE; return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
@@ -309,5 +309,12 @@ @@ -312,5 +312,12 @@
this.a = MathHelper.a(random, d0, d2); this.x = MathHelper.a(random, d0, d2);
this.b = MathHelper.a(random, d1, d3); this.z = MathHelper.a(random, d1, d3);
} }
+ +
+ // CraftBukkit start - add a version of getType which force loads chunks + // CraftBukkit start - add a version of getType which force loads chunks

Datei anzeigen

@ -1,11 +1,11 @@
--- a/net/minecraft/server/commands/CommandSummon.java --- a/net/minecraft/server/commands/CommandSummon.java
+++ b/net/minecraft/server/commands/CommandSummon.java +++ b/net/minecraft/server/commands/CommandSummon.java
@@ -64,7 +64,7 @@ @@ -66,7 +66,7 @@
((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null); ((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null);
} }
- if (!worldserver.addAllEntitiesSafely(entity)) { - if (!worldserver.addAllEntitiesSafely(entity)) {
+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND" + if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
throw CommandSummon.b.create(); throw CommandSummon.ERROR_DUPLICATE_UUID.create();
} else { } else {
commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true); commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true);

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/commands/CommandTeleport.java --- a/net/minecraft/server/commands/CommandTeleport.java
+++ b/net/minecraft/server/commands/CommandTeleport.java +++ b/net/minecraft/server/commands/CommandTeleport.java
@@ -35,6 +35,12 @@ @@ -36,6 +36,12 @@
import net.minecraft.world.phys.Vec2F; import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
@ -12,25 +12,23 @@
+ +
public class CommandTeleport { public class CommandTeleport {
private static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition")); private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
@@ -150,9 +156,9 @@ @@ -160,14 +166,29 @@
} }
if (worldserver == entity.world) { if (worldserver == entity.level) {
- ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set); - ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set);
+ ((EntityPlayer) entity).playerConnection.a(d0, d1, d2, f, f1, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
} else { } else {
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1); - ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3);
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit + ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
} }
entity.setHeadRotation(f); entity.setHeadRotation(f2);
@@ -161,6 +167,21 @@ } else {
float f3 = MathHelper.g(f1); float f4 = MathHelper.a(f3, -90.0F, 90.0F);
f3 = MathHelper.a(f3, -90.0F, 90.0F);
+ // CraftBukkit start - Teleport event + // CraftBukkit start - Teleport event
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3); + Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4);
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to); + EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
+ worldserver.getServer().getPluginManager().callEvent(event); + worldserver.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -41,9 +39,9 @@
+ d1 = to.getY(); + d1 = to.getY();
+ d2 = to.getZ(); + d2 = to.getZ();
+ f2 = to.getYaw(); + f2 = to.getYaw();
+ f3 = to.getPitch(); + f4 = to.getPitch();
+ worldserver = ((CraftWorld) to.getWorld()).getHandle(); + worldserver = ((CraftWorld) to.getWorld()).getHandle();
+ // CraftBukkit end + // CraftBukkit end
if (worldserver == entity.world) {
entity.setPositionRotation(d0, d1, d2, f2, f3); if (worldserver == entity.level) {
entity.setHeadRotation(f2); entity.setPositionRotation(d0, d1, d2, f2, f4);

Datei anzeigen

@ -11,8 +11,8 @@
+ +
public class CommandTime { public class CommandTime {
public static void a(CommandDispatcher<CommandListenerWrapper> commanddispatcher) { public CommandTime() {}
@@ -51,7 +56,13 @@ @@ -53,7 +58,13 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next(); WorldServer worldserver = (WorldServer) iterator.next();
@ -27,7 +27,7 @@
} }
commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true); commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true);
@@ -64,7 +75,13 @@ @@ -66,7 +77,13 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next(); WorldServer worldserver = (WorldServer) iterator.next();

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java --- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -60,6 +60,15 @@ @@ -64,6 +64,15 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -15,10 +15,10 @@
+ +
public class DedicatedServer extends MinecraftServer implements IMinecraftServer { public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
private static final Logger LOGGER = LogManager.getLogger(); static final Logger LOGGER = LogManager.getLogger();
@@ -74,8 +83,10 @@ @@ -82,8 +91,10 @@
@Nullable @Nullable
private final TextFilter r; private final IChatBaseComponent resourcePackPrompt;
- public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { - public DedicatedServer(Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
- super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); - super(thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
@ -26,10 +26,10 @@
+ public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) { + public DedicatedServer(joptsimple.OptionSet options, DataPackConfiguration datapackconfiguration, Thread thread, IRegistryCustom.Dimension iregistrycustom_dimension, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, DataPackResources datapackresources, SaveData savedata, DedicatedServerSettings dedicatedserversettings, DataFixer datafixer, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory) {
+ super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory); + super(options, datapackconfiguration, thread, iregistrycustom_dimension, convertable_conversionsession, savedata, resourcepackrepository, Proxy.NO_PROXY, datafixer, datapackresources, minecraftsessionservice, gameprofilerepository, usercache, worldloadlistenerfactory);
+ // CraftBukkit end + // CraftBukkit end
this.propertyManager = dedicatedserversettings; this.settings = dedicatedserversettings;
this.remoteControlCommandListener = new RemoteControlCommandListener(this); this.rconConsoleSource = new RemoteControlCommandListener(this);
this.r = null; this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig);
@@ -85,13 +96,44 @@ @@ -94,13 +105,44 @@
public boolean init() throws IOException { public boolean init() throws IOException {
Thread thread = new Thread("Server console handler") { Thread thread = new Thread("Server console handler") {
public void run() { public void run() {
@ -77,7 +77,7 @@
} }
} catch (IOException ioexception) { } catch (IOException ioexception) {
DedicatedServer.LOGGER.error("Exception handling console input", ioexception); DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
@@ -100,6 +142,27 @@ @@ -109,6 +151,27 @@
} }
}; };
@ -105,21 +105,21 @@
thread.setDaemon(true); thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
thread.start(); thread.start();
@@ -126,7 +189,7 @@ @@ -134,7 +197,7 @@
this.setForceGamemode(dedicatedserverproperties.forceGamemode); this.setMotd(dedicatedserverproperties.motd);
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get()); super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
this.i(dedicatedserverproperties.enforceWhitelist); this.h(dedicatedserverproperties.enforceWhitelist);
- this.saveData.setGameType(dedicatedserverproperties.gamemode); - this.worldData.setGameType(dedicatedserverproperties.gamemode);
+ // this.saveData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading + // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode); DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
InetAddress inetaddress = null; InetAddress inetaddress = null;
@@ -150,6 +213,12 @@ @@ -158,6 +221,12 @@
return false; return false;
} }
+ // CraftBukkit start + // CraftBukkit start
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); + this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
+ server.loadPlugins(); + server.loadPlugins();
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
+ // CraftBukkit end + // CraftBukkit end
@ -127,47 +127,46 @@
if (!this.getOnlineMode()) { if (!this.getOnlineMode()) {
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware."); DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
@@ -164,7 +233,7 @@ @@ -172,14 +241,14 @@
if (!NameReferencingFileConverter.e(this)) { if (!NameReferencingFileConverter.e(this)) {
return false; return false;
} else { } else {
- this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); - this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
+ // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up + // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up
long i = SystemUtils.getMonotonicNanos(); long i = SystemUtils.getMonotonicNanos();
this.c(dedicatedserverproperties.maxBuildHeight); TileEntitySkull.a(this.getUserCache());
@@ -172,7 +241,7 @@
TileEntitySkull.a(this.getMinecraftSessionService()); TileEntitySkull.a(this.getMinecraftSessionService());
UserCache.a(this.getOnlineMode()); UserCache.a(this.getOnlineMode());
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld()); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
- this.loadWorld(); - this.loadWorld();
+ this.loadWorld(convertable.getLevelName()); // CraftBukkit + this.loadWorld(storageSource.getLevelName()); // CraftBukkit
long j = SystemUtils.getMonotonicNanos() - i; long j = SystemUtils.getMonotonicNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D); String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
@@ -189,6 +258,7 @@ @@ -196,6 +265,7 @@
if (dedicatedserverproperties.enableRcon) { if (dedicatedserverproperties.enableRcon) {
DedicatedServer.LOGGER.info("Starting remote control listener"); DedicatedServer.LOGGER.info("Starting remote control listener");
this.remoteControlListener = RemoteControlListener.a((IMinecraftServer) this); this.rconThread = RemoteControlListener.a((IMinecraftServer) this);
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.remoteControlCommandListener); // CraftBukkit + this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
} }
if (this.getMaxTickTime() > 0L) { if (this.getMaxTickTime() > 0L) {
@@ -303,6 +373,7 @@ @@ -345,6 +415,7 @@
this.remoteStatusListener.b(); this.queryThreadGs4.b();
} }
+ System.exit(0); // CraftBukkit + System.exit(0); // CraftBukkit
} }
@Override @Override
@@ -331,7 +402,15 @@ @@ -378,7 +449,15 @@
while (!this.serverCommandQueue.isEmpty()) { while (!this.consoleInput.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
- this.getCommandDispatcher().a(servercommand.source, servercommand.command); - this.getCommandDispatcher().a(servercommand.source, servercommand.msg);
+ // CraftBukkit start - ServerCommand for preprocessing + // CraftBukkit start - ServerCommand for preprocessing
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command); + ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
+ server.getPluginManager().callEvent(event); + server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) continue; + if (event.isCancelled()) continue;
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source); + servercommand = new ServerCommand(event.getCommand(), servercommand.source);
@ -178,7 +177,7 @@
} }
} }
@@ -541,14 +620,45 @@ @@ -583,14 +662,45 @@
@Override @Override
public String getPlugins() { public String getPlugins() {
@ -211,24 +210,24 @@
@Override @Override
public String executeRemoteCommand(String s) { public String executeRemoteCommand(String s) {
this.remoteControlCommandListener.clearMessages(); this.rconConsoleSource.clearMessages();
this.executeSync(() -> { this.executeSync(() -> {
- this.getCommandDispatcher().a(this.remoteControlCommandListener.getWrapper(), s); - this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), s);
+ // CraftBukkit start - fire RemoteServerCommandEvent + // CraftBukkit start - fire RemoteServerCommandEvent
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s); + RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
+ server.getPluginManager().callEvent(event); + server.getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), remoteControlCommandListener.getWrapper()); + ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.getWrapper());
+ server.dispatchServerCommand(remoteConsole, serverCommand); + server.dispatchServerCommand(remoteConsole, serverCommand);
+ // CraftBukkit end + // CraftBukkit end
}); });
return this.remoteControlCommandListener.getMessages(); return this.rconConsoleSource.getMessages();
} }
@@ -590,4 +700,15 @@ @@ -663,4 +773,15 @@
public ITextFilter a(EntityPlayer entityplayer) { public IChatBaseComponent bb() {
return this.r != null ? this.r.a(entityplayer.getProfile()) : null; return this.resourcePackPrompt;
} }
+ +
+ // CraftBukkit start + // CraftBukkit start

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java --- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -9,8 +9,14 @@ @@ -10,8 +10,14 @@
import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.levelgen.GeneratorSettings; import net.minecraft.world.level.levelgen.GeneratorSettings;
@ -15,35 +15,36 @@
public final boolean onlineMode = this.getBoolean("online-mode", true); public final boolean onlineMode = this.getBoolean("online-mode", true);
public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false); public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false);
public final String serverIp = this.getString("server-ip", ""); public final String serverIp = this.getString("server-ip", "");
@@ -61,8 +67,10 @@ @@ -64,8 +70,10 @@
public final PropertyManager<DedicatedServerProperties>.EditableProperty<Boolean> whiteList; @Nullable
public final GeneratorSettings generatorSettings; public GeneratorSettings worldGenSettings;
- public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom) { - public DedicatedServerProperties(Properties properties) {
- super(properties); - super(properties);
+ // CraftBukkit start + // CraftBukkit start
+ public DedicatedServerProperties(Properties properties, IRegistryCustom iregistrycustom, OptionSet optionset) { + public DedicatedServerProperties(Properties properties, OptionSet optionset) {
+ super(properties, optionset); + super(properties, optionset);
+ // CraftBukkit end + // CraftBukkit end
this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY); this.difficulty = (EnumDifficulty) this.a("difficulty", a(EnumDifficulty::getById, EnumDifficulty::a), EnumDifficulty::c, EnumDifficulty.EASY);
this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL); this.gamemode = (EnumGamemode) this.a("gamemode", a(EnumGamemode::getById, EnumGamemode::a), EnumGamemode::b, EnumGamemode.SURVIVAL);
this.levelName = this.getString("level-name", "world"); this.levelName = this.getString("level-name", "world");
@@ -113,12 +121,14 @@ @@ -112,13 +120,15 @@
this.generatorSettings = GeneratorSettings.a(iregistrycustom, properties); this.whiteList = this.b("white-list", false);
} }
- public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path) { - public static DedicatedServerProperties load(Path path) {
- return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom); - return new DedicatedServerProperties(loadPropertiesFile(path));
+ // CraftBukkit start + // CraftBukkit start
+ public static DedicatedServerProperties load(IRegistryCustom iregistrycustom, Path path, OptionSet optionset) { + public static DedicatedServerProperties load(Path path, OptionSet optionset) {
+ return new DedicatedServerProperties(loadPropertiesFile(path), iregistrycustom, optionset); + return new DedicatedServerProperties(loadPropertiesFile(path), optionset);
} }
@Override @Override
- protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) { - protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties) {
- return new DedicatedServerProperties(properties, iregistrycustom); - DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties);
+ protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) { + protected DedicatedServerProperties reload(IRegistryCustom iregistrycustom, Properties properties, OptionSet optionset) {
+ return new DedicatedServerProperties(properties, iregistrycustom, optionset); + DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset);
+ // CraftBukkit end + // CraftBukkit end
}
} dedicatedserverproperties.a(iregistrycustom);
return dedicatedserverproperties;

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/server/dedicated/DedicatedServerSettings.java --- a/net/minecraft/server/dedicated/DedicatedServerSettings.java
+++ b/net/minecraft/server/dedicated/DedicatedServerSettings.java +++ b/net/minecraft/server/dedicated/DedicatedServerSettings.java
@@ -4,14 +4,21 @@ @@ -3,14 +3,21 @@
import java.nio.file.Path;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import net.minecraft.core.IRegistryCustom;
+// CraftBukkit start +// CraftBukkit start
+import java.io.File; +import java.io.File;
@ -11,16 +11,16 @@
+ +
public class DedicatedServerSettings { public class DedicatedServerSettings {
private final Path path; private final Path source;
private DedicatedServerProperties properties; private DedicatedServerProperties properties;
- public DedicatedServerSettings(IRegistryCustom iregistrycustom, Path path) { - public DedicatedServerSettings(Path path) {
- this.path = path; - this.source = path;
- this.properties = DedicatedServerProperties.load(iregistrycustom, path); - this.properties = DedicatedServerProperties.load(path);
+ // CraftBukkit start + // CraftBukkit start
+ public DedicatedServerSettings(IRegistryCustom iregistrycustom, OptionSet optionset) { + public DedicatedServerSettings(OptionSet optionset) {
+ this.path = ((File) optionset.valueOf("config")).toPath(); + this.source = ((File) optionset.valueOf("config")).toPath();
+ this.properties = DedicatedServerProperties.load(iregistrycustom, path, optionset); + this.properties = DedicatedServerProperties.load(source, optionset);
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -32,7 +32,7 @@
public static Properties loadPropertiesFile(Path path) { public static Properties loadPropertiesFile(Path path) {
Properties properties = new Properties(); Properties properties = new Properties();
@@ -61,6 +76,11 @@ @@ -58,6 +73,11 @@
public void savePropertiesFile(Path path) { public void savePropertiesFile(Path path) {
try { try {
@ -42,9 +42,9 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
OutputStream outputstream = Files.newOutputStream(path); OutputStream outputstream = Files.newOutputStream(path);
Throwable throwable = null;
@@ -92,7 +112,7 @@ try {
@@ -86,7 +106,7 @@
private static <V extends Number> Function<String, V> a(Function<String, V> function) { private static <V extends Number> Function<String, V> a(Function<String, V> function) {
return (s) -> { return (s) -> {
try { try {
@ -53,7 +53,7 @@
} catch (NumberFormatException numberformatexception) { } catch (NumberFormatException numberformatexception) {
return null; return null;
} }
@@ -111,7 +131,7 @@ @@ -105,7 +125,7 @@
@Nullable @Nullable
private String c(String s) { private String c(String s) {
@ -62,7 +62,7 @@
} }
@Nullable @Nullable
@@ -139,7 +159,7 @@ @@ -133,7 +153,7 @@
V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0); V v1 = MoreObjects.firstNonNull(s1 != null ? function.apply(s1) : null, v0);
this.properties.put(s, function1.apply(v1)); this.properties.put(s, function1.apply(v1));
@ -71,7 +71,7 @@
} }
protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) { protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
@@ -168,7 +188,7 @@ @@ -162,7 +182,7 @@
} }
protected int getInt(String s, int i) { protected int getInt(String s, int i) {
@ -80,7 +80,7 @@
} }
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) { protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
@@ -180,7 +200,7 @@ @@ -174,7 +194,7 @@
} }
protected long getLong(String s, long i) { protected long getLong(String s, long i) {
@ -89,7 +89,7 @@
} }
protected boolean getBoolean(String s, boolean flag) { protected boolean getBoolean(String s, boolean flag) {
@@ -203,7 +223,7 @@ @@ -197,7 +217,7 @@
return properties; return properties;
} }
@ -98,19 +98,19 @@
public class EditableProperty<V> implements Supplier<V> { public class EditableProperty<V> implements Supplier<V> {
@@ -211,7 +231,7 @@ @@ -205,7 +225,7 @@
private final V c; private final V value;
private final Function<V, String> d; private final Function<V, String> serializer;
- private EditableProperty(String s, Object object, Function function) { - EditableProperty(String s, Object object, Function function) {
+ private EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error + EditableProperty(String s, V object, Function function) { // CraftBukkit - decompile error
this.b = s; this.key = s;
this.c = object; this.value = object;
this.d = function; this.serializer = function;
@@ -225,7 +245,7 @@ @@ -219,7 +239,7 @@
Properties properties = PropertyManager.this.a(); Properties properties = PropertyManager.this.a();
properties.put(this.b, this.d.apply(v0)); properties.put(this.key, this.serializer.apply(v0));
- return PropertyManager.this.reload(iregistrycustom, properties); - return PropertyManager.this.reload(iregistrycustom, properties);
+ return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit + return PropertyManager.this.reload(iregistrycustom, properties, PropertyManager.this.options); // CraftBukkit
} }

Datei anzeigen

@ -1,14 +1,23 @@
--- a/net/minecraft/server/gui/ServerGUI.java --- a/net/minecraft/server/gui/ServerGUI.java
+++ b/net/minecraft/server/gui/ServerGUI.java +++ b/net/minecraft/server/gui/ServerGUI.java
@@ -160,6 +160,7 @@ @@ -96,7 +96,7 @@
this.e.forEach(Runnable::run); private JComponent c() {
JPanel jpanel = new JPanel(new BorderLayout());
GuiStatsComponent guistatscomponent = new GuiStatsComponent(this.server);
- Collection collection = this.finalizers;
+ Collection<Runnable> collection = this.finalizers; // CraftBukkit - decompile error
Objects.requireNonNull(guistatscomponent);
collection.add(guistatscomponent::a);
@@ -166,6 +166,7 @@
this.finalizers.forEach(Runnable::run);
} }
+ private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit + private static final java.util.regex.Pattern ANSI = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})*)?[m|K]"); // CraftBukkit
public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) { public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
if (!SwingUtilities.isEventDispatchThread()) { if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
@@ -175,7 +176,7 @@ @@ -181,7 +182,7 @@
} }
try { try {

Datei anzeigen

@ -1,64 +1,64 @@
--- a/net/minecraft/server/level/ChunkMapDistance.java --- a/net/minecraft/server/level/ChunkMapDistance.java
+++ b/net/minecraft/server/level/ChunkMapDistance.java +++ b/net/minecraft/server/level/ChunkMapDistance.java
@@ -65,7 +65,7 @@ @@ -73,7 +73,7 @@
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next(); Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next();
- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> { - if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> {
+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error + if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
return ticket.b(this.currentTick); return ticket.b(this.ticketTickCounter);
})) { })) {
this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false); this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
@@ -101,10 +101,25 @@ @@ -109,10 +109,25 @@
} }
if (!this.pendingChunkUpdates.isEmpty()) { if (!this.chunksToUpdateFutures.isEmpty()) {
- this.pendingChunkUpdates.forEach((playerchunk) -> { - this.chunksToUpdateFutures.forEach((playerchunk) -> {
+ // CraftBukkit start + // CraftBukkit start
+ // Iterate pending chunk updates with protection against concurrent modification exceptions + // Iterate pending chunk updates with protection against concurrent modification exceptions
+ java.util.Iterator<PlayerChunk> iter = this.pendingChunkUpdates.iterator(); + java.util.Iterator<PlayerChunk> iter = this.chunksToUpdateFutures.iterator();
+ int expectedSize = this.pendingChunkUpdates.size(); + int expectedSize = this.chunksToUpdateFutures.size();
+ do { + do {
+ PlayerChunk playerchunk = iter.next(); + PlayerChunk playerchunk = iter.next();
+ iter.remove(); + iter.remove();
+ expectedSize--; + expectedSize--;
+ +
playerchunk.a(playerchunkmap); playerchunk.a(playerchunkmap, this.mainThreadExecutor);
- }); - });
- this.pendingChunkUpdates.clear(); - this.chunksToUpdateFutures.clear();
+ +
+ // Reset iterator if set was modified using add() + // Reset iterator if set was modified using add()
+ if (this.pendingChunkUpdates.size() != expectedSize) { + if (this.chunksToUpdateFutures.size() != expectedSize) {
+ expectedSize = this.pendingChunkUpdates.size(); + expectedSize = this.chunksToUpdateFutures.size();
+ iter = this.pendingChunkUpdates.iterator(); + iter = this.chunksToUpdateFutures.iterator();
+ } + }
+ } while (iter.hasNext()); + } while (iter.hasNext());
+ // CraftBukkit end + // CraftBukkit end
+ +
return true; return true;
} else { } else {
if (!this.l.isEmpty()) { if (!this.ticketsToRelease.isEmpty()) {
@@ -140,23 +155,25 @@ @@ -148,23 +163,25 @@
} }
} }
- private void addTicket(long i, Ticket<?> ticket) { - void addTicket(long i, Ticket<?> ticket) {
+ private boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean + boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i); ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
int j = getLowestTicketLevel(arraysetsorted); int j = getLowestTicketLevel(arraysetsorted);
- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket); - Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket);
+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error + Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
ticket1.a(this.currentTick); ticket1.a(this.ticketTickCounter);
if (ticket.b() < j) { if (ticket.b() < j) {
this.ticketLevelTracker.update(i, ticket.b(), true); this.ticketTracker.update(i, ticket.b(), true);
} }
+ return ticket == ticket1; // CraftBukkit + return ticket == ticket1; // CraftBukkit
} }
- private void removeTicket(long i, Ticket<?> ticket) { - void removeTicket(long i, Ticket<?> ticket) {
+ private boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean + boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i); ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
+ boolean removed = false; // CraftBukkit + boolean removed = false; // CraftBukkit
@ -68,10 +68,10 @@
} }
if (arraysetsorted.isEmpty()) { if (arraysetsorted.isEmpty()) {
@@ -164,16 +181,29 @@ @@ -172,16 +189,29 @@
} }
this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false); this.ticketTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
+ return removed; // CraftBukkit + return removed; // CraftBukkit
} }
@ -101,16 +101,16 @@
} }
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) { public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
@@ -216,6 +246,7 @@ @@ -224,6 +254,7 @@
public void b(SectionPosition sectionposition, EntityPlayer entityplayer) { public void b(SectionPosition sectionposition, EntityPlayer entityplayer) {
long i = sectionposition.r().pair(); long i = sectionposition.r().pair();
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.c.get(i); ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208 + if (objectset == null) return; // CraftBukkit - SPIGOT-6208
objectset.remove(entityplayer); objectset.remove(entityplayer);
if (objectset.isEmpty()) { if (objectset.isEmpty()) {
@@ -257,6 +288,26 @@ @@ -300,6 +331,26 @@
return this.i.a();
} }
+ // CraftBukkit start + // CraftBukkit start
@ -122,7 +122,7 @@
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue(); + ArraySetSorted<Ticket<?>> tickets = entry.getValue();
+ if (tickets.remove(target)) { + if (tickets.remove(target)) {
+ // copied from removeTicket + // copied from removeTicket
+ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false); + this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false);
+ +
+ // can't use entry after it's removed + // can't use entry after it's removed
+ if (tickets.isEmpty()) { + if (tickets.isEmpty()) {
@ -133,6 +133,6 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
class a extends ChunkMap { private class a extends ChunkMap {
public a() { public a() {

Datei anzeigen

@ -1,12 +1,12 @@
--- a/net/minecraft/server/level/ChunkProviderServer.java --- a/net/minecraft/server/level/ChunkProviderServer.java
+++ b/net/minecraft/server/level/ChunkProviderServer.java +++ b/net/minecraft/server/level/ChunkProviderServer.java
@@ -79,6 +79,24 @@ @@ -83,6 +83,24 @@
this.clearCache(); this.clearCache();
} }
+ // CraftBukkit start - properly implement isChunkLoaded + // CraftBukkit start - properly implement isChunkLoaded
+ public boolean isChunkLoaded(int chunkX, int chunkZ) { + public boolean isChunkLoaded(int chunkX, int chunkZ) {
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); + PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
+ if (chunk == null) { + if (chunk == null) {
+ return false; + return false;
+ } + }
@ -14,7 +14,7 @@
+ } + }
+ +
+ public Chunk getChunkUnchecked(int chunkX, int chunkZ) { + public Chunk getChunkUnchecked(int chunkX, int chunkZ) {
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ)); + PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
+ if (chunk == null) { + if (chunk == null) {
+ return null; + return null;
+ } + }
@ -25,16 +25,16 @@
@Override @Override
public LightEngineThreaded getLightEngine() { public LightEngineThreaded getLightEngine() {
return this.lightEngine; return this.lightEngine;
@@ -123,7 +141,7 @@ @@ -127,7 +145,7 @@
for (int l = 0; l < 4; ++l) { for (int l = 0; l < 4; ++l) {
if (k == this.cachePos[l] && chunkstatus == this.cacheStatus[l]) { if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
ichunkaccess = this.cacheChunk[l]; ichunkaccess = this.lastChunk[l];
- if (ichunkaccess != null || !flag) { - if (ichunkaccess != null || !flag) {
+ if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime + if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
return ichunkaccess; return ichunkaccess;
} }
} }
@@ -169,12 +187,12 @@ @@ -175,12 +193,12 @@
if (playerchunk == null) { if (playerchunk == null) {
return null; return null;
} else { } else {
@ -49,7 +49,7 @@
if (ichunkaccess1 != null) { if (ichunkaccess1 != null) {
this.a(k, ichunkaccess1, ChunkStatus.FULL); this.a(k, ichunkaccess1, ChunkStatus.FULL);
@@ -201,7 +219,15 @@ @@ -228,7 +246,15 @@
int l = 33 + ChunkStatus.a(chunkstatus); int l = 33 + ChunkStatus.a(chunkstatus);
PlayerChunk playerchunk = this.getChunk(k); PlayerChunk playerchunk = this.getChunk(k);
@ -63,10 +63,10 @@
+ } + }
+ if (flag && !currentlyUnloading) { + if (flag && !currentlyUnloading) {
+ // CraftBukkit end + // CraftBukkit end
this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair); this.distanceManager.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
if (this.a(playerchunk, l)) { if (this.a(playerchunk, l)) {
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
@@ -220,7 +246,7 @@ @@ -247,7 +273,7 @@
} }
private boolean a(@Nullable PlayerChunk playerchunk, int i) { private boolean a(@Nullable PlayerChunk playerchunk, int i) {
@ -74,31 +74,17 @@
+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks + return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks
} }
public boolean isLoaded(int i, int j) { @Override
@@ -282,19 +308,19 @@ @@ -307,7 +333,7 @@
public boolean a(Entity entity) {
long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
- return this.a(i, PlayerChunk::b);
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
} }
@Override public boolean a(long i) {
public boolean a(ChunkCoordIntPair chunkcoordintpair) {
- return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
+ return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
}
@Override
public boolean a(BlockPosition blockposition) {
long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
- return this.a(i, PlayerChunk::a); - return this.a(i, PlayerChunk::a);
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error + return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
} }
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) { private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {
@@ -316,11 +342,31 @@ @@ -329,11 +355,31 @@
@Override @Override
public void close() throws IOException { public void close() throws IOException {
@ -113,44 +99,46 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.lightEngine.close(); this.lightEngine.close();
this.playerChunkMap.close(); this.chunkMap.close();
} }
+ // CraftBukkit start - modelled on below + // CraftBukkit start - modelled on below
+ public void purgeUnload() { + public void purgeUnload() {
+ this.world.getMethodProfiler().enter("purge"); + this.level.getMethodProfiler().enter("purge");
+ this.chunkMapDistance.purgeTickets(); + this.distanceManager.purgeTickets();
+ this.tickDistanceManager(); + this.tickDistanceManager();
+ this.world.getMethodProfiler().exitEnter("unload"); + this.level.getMethodProfiler().exitEnter("unload");
+ this.playerChunkMap.unloadChunks(() -> true); + this.chunkMap.unloadChunks(() -> true);
+ this.world.getMethodProfiler().exit(); + this.level.getMethodProfiler().exit();
+ this.clearCache(); + this.clearCache();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
@Override
public void tick(BooleanSupplier booleansupplier) { public void tick(BooleanSupplier booleansupplier) {
this.world.getMethodProfiler().enter("purge"); this.level.getMethodProfiler().enter("purge");
this.chunkMapDistance.purgeTickets(); @@ -354,12 +400,12 @@
@@ -340,12 +386,12 @@ this.lastInhabitedUpdate = i;
this.lastTickTime = i; WorldData worlddata = this.level.getWorldData();
WorldData worlddata = this.world.getWorldData(); boolean flag = this.level.isDebugWorld();
boolean flag = this.world.isDebugWorld(); - boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
- boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING); + boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.getPlayers().isEmpty(); // CraftBukkit
+ boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit
if (!flag) { if (!flag) {
this.world.getMethodProfiler().enter("pollingChunks"); this.level.getMethodProfiler().enter("pollingChunks");
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED); int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
- boolean flag2 = worlddata.getTime() % 400L == 0L; - boolean flag2 = worlddata.getTime() % 400L == 0L;
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit + boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
this.world.getMethodProfiler().enter("naturalSpawnCount"); this.level.getMethodProfiler().enter("naturalSpawnCount");
int l = this.chunkMapDistance.b(); int l = this.distanceManager.b();
@@ -532,12 +578,18 @@ @@ -548,13 +594,19 @@
}
@Override @Override
protected boolean executeNext() { - protected boolean executeNext() {
+ // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task + // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
+ public boolean executeNext() {
+ try { + try {
if (ChunkProviderServer.this.tickDistanceManager()) { if (ChunkProviderServer.this.tickDistanceManager()) {
return true; return true;
@ -159,7 +147,7 @@
return super.executeNext(); return super.executeNext();
} }
+ } finally { + } finally {
+ playerChunkMap.callbackExecutor.run(); + chunkMap.callbackExecutor.run();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -1,10 +1,11 @@
--- a/net/minecraft/server/level/EntityTrackerEntry.java --- a/net/minecraft/server/level/EntityTrackerEntry.java
+++ b/net/minecraft/server/level/EntityTrackerEntry.java +++ b/net/minecraft/server/level/EntityTrackerEntry.java
@@ -40,6 +40,11 @@ @@ -42,6 +42,12 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import net.minecraft.server.network.ServerPlayerConnection;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.event.player.PlayerVelocityEvent;
+// CraftBukkit end +// CraftBukkit end
@ -12,44 +13,51 @@
public class EntityTrackerEntry { public class EntityTrackerEntry {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -60,8 +65,12 @@ @@ -63,8 +69,12 @@
private List<Entity> p; private List<Entity> lastPassengers;
private boolean q; private boolean wasRiding;
private boolean r; private boolean wasOnGround;
+ // CraftBukkit start + // CraftBukkit start
+ private final Set<EntityPlayer> trackedPlayers; + private final Set<ServerPlayerConnection> trackedPlayers;
- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer) { - public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer) {
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<EntityPlayer> trackedPlayers) { + public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
+ this.trackedPlayers = trackedPlayers; + this.trackedPlayers = trackedPlayers;
+ // CraftBukkit end + // CraftBukkit end
this.m = Vec3D.ORIGIN; this.ap = Vec3D.ZERO;
this.p = Collections.emptyList(); this.lastPassengers = Collections.emptyList();
this.b = worldserver; this.level = worldserver;
@@ -81,16 +90,16 @@ @@ -84,22 +94,22 @@
if (!list.equals(this.p)) { if (!list.equals(this.lastPassengers)) {
this.p = list; this.lastPassengers = list;
- this.f.accept(new PacketPlayOutMount(this.tracker)); - this.broadcast.accept(new PacketPlayOutMount(this.entity));
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit + this.broadcastIncludingSelf(new PacketPlayOutMount(this.entity)); // CraftBukkit
} }
- if (this.tracker instanceof EntityItemFrame && this.tickCounter % 10 == 0) { - if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) {
+ if (this.tracker instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block + if (this.entity instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker; EntityItemFrame entityitemframe = (EntityItemFrame) this.entity;
ItemStack itemstack = entityitemframe.getItem(); ItemStack itemstack = entityitemframe.getItem();
- if (itemstack.getItem() instanceof ItemWorldMap) { - if (itemstack.getItem() instanceof ItemWorldMap) {
+ if (this.tickCounter % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks + if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.b); Integer integer = ItemWorldMap.d(itemstack);
- Iterator iterator = this.b.getPlayers().iterator(); WorldMap worldmap = ItemWorldMap.a(integer, (World) this.level);
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
while (iterator.hasNext()) { if (worldmap != null) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); - Iterator iterator = this.level.getPlayers().iterator();
@@ -135,6 +144,17 @@ + Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit
boolean flag2 = flag1 || this.tickCounter % 60 == 0;
boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1; while (iterator.hasNext()) {
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ EntityPlayer entityplayer = iterator.next().d(); // CraftBukkit
worldmap.a((EntityHuman) entityplayer, itemstack);
Packet<?> packet = worldmap.a(integer, entityplayer);
@@ -142,6 +152,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 + // CraftBukkit start - Code moved from below
+ if (flag2) { + if (flag2) {
@ -57,15 +65,15 @@
+ } + }
+ +
+ if (flag3) { + if (flag3) {
+ this.yRot = i; + this.yRotp = i;
+ this.xRot = j; + this.xRotp = j;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) { if (this.tickCount > 0 || this.entity instanceof EntityArrow) {
long k = PacketPlayOutEntity.a(vec3d.x); long k = PacketPlayOutEntity.a(vec3d.x);
long l = PacketPlayOutEntity.a(vec3d.y); long l = PacketPlayOutEntity.a(vec3d.y);
@@ -173,6 +193,7 @@ @@ -180,6 +201,7 @@
} }
this.c(); this.c();
@ -73,28 +81,28 @@
if (flag2) { if (flag2) {
this.d(); this.d();
} }
@@ -181,6 +202,7 @@ @@ -188,6 +210,7 @@
this.yRot = i; this.yRotp = i;
this.xRot = j; this.xRotp = j;
} }
+ // CraftBukkit end */ + // CraftBukkit end */
this.q = false; this.wasRiding = false;
} }
@@ -196,7 +218,27 @@ @@ -203,7 +226,27 @@
++this.tickCounter; ++this.tickCount;
if (this.tracker.velocityChanged) { if (this.entity.hurtMarked) {
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); - this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
+ // CraftBukkit start - Create PlayerVelocity event + // CraftBukkit start - Create PlayerVelocity event
+ boolean cancelled = false; + boolean cancelled = false;
+ +
+ if (this.tracker instanceof EntityPlayer) { + if (this.entity instanceof EntityPlayer) {
+ Player player = (Player) this.tracker.getBukkitEntity(); + Player player = (Player) this.entity.getBukkitEntity();
+ org.bukkit.util.Vector velocity = player.getVelocity(); + org.bukkit.util.Vector velocity = player.getVelocity();
+ +
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone()); + PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
+ this.tracker.world.getServer().getPluginManager().callEvent(event); + this.entity.level.getServer().getPluginManager().callEvent(event);
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ cancelled = true; + cancelled = true;
@ -104,70 +112,69 @@
+ } + }
+ +
+ if (!cancelled) { + if (!cancelled) {
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); + this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.tracker.velocityChanged = false; this.entity.hurtMarked = false;
} }
@@ -211,14 +253,17 @@ @@ -218,13 +261,16 @@
PlayerConnection playerconnection = entityplayer.playerConnection; PlayerConnection playerconnection = entityplayer.connection;
entityplayer.playerConnection.getClass(); Objects.requireNonNull(entityplayer.connection);
- this.a(playerconnection::sendPacket); - this.a(playerconnection::sendPacket);
+ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player + this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player
this.tracker.b(entityplayer); this.entity.c(entityplayer);
entityplayer.d(this.tracker);
} }
- public void a(Consumer<Packet<?>> consumer) { - public void a(Consumer<Packet<?>> consumer) {
+ public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player + public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
if (this.tracker.dead) { if (this.entity.isRemoved()) {
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker); - EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
+ // CraftBukkit start - Remove useless error spam, just return + // CraftBukkit start - Remove useless error spam, just return
+ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker); + // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
+ return; + return;
+ // CraftBukkit end + // CraftBukkit end
} }
Packet<?> packet = this.tracker.P(); Packet<?> packet = this.entity.getPacket();
@@ -234,6 +279,12 @@ @@ -240,6 +286,12 @@
if (this.tracker instanceof EntityLiving) { if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.tracker).getAttributeMap().b(); Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributeMap().b();
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health + // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
+ if (this.tracker.getId() == entityplayer.getId()) { + if (this.entity.getId() == entityplayer.getId()) {
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false); + ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(collection, false);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (!collection.isEmpty()) { if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection)); consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
} }
@@ -265,8 +316,14 @@ @@ -271,8 +323,14 @@
if (!list.isEmpty()) { if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.tracker.getId(), list)); consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
} }
+ ((EntityLiving) this.tracker).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending + ((EntityLiving) this.entity).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
} }
+ // CraftBukkit start - Fix for nonsensical head yaw + // CraftBukkit start - Fix for nonsensical head yaw
+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); + this.yHeadRotp = MathHelper.d(this.entity.getHeadRotation() * 256.0F / 360.0F);
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw)); + consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.tracker instanceof EntityLiving) { if (this.entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.tracker; EntityLiving entityliving = (EntityLiving) this.entity;
Iterator iterator = entityliving.getEffects().iterator(); Iterator iterator = entityliving.getEffects().iterator();
@@ -307,6 +364,11 @@ @@ -313,6 +371,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.tracker).getAttributeMap().getAttributes(); Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributeMap().getAttributes();
if (!set.isEmpty()) { if (!set.isEmpty()) {
+ // CraftBukkit start - Send scaled max health + // CraftBukkit start - Send scaled max health
+ if (this.tracker instanceof EntityPlayer) { + if (this.entity instanceof EntityPlayer) {
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false); + ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set)); this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.entity.getId(), set));
} }

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerChunk.java --- a/net/minecraft/server/level/PlayerChunk.java
+++ b/net/minecraft/server/level/PlayerChunk.java +++ b/net/minecraft/server/level/PlayerChunk.java
@@ -33,6 +33,10 @@ @@ -38,6 +38,10 @@
import net.minecraft.world.level.chunk.ProtoChunkExtension; import net.minecraft.world.level.chunk.ProtoChunkExtension;
import net.minecraft.world.level.lighting.LightEngine; import net.minecraft.world.level.lighting.LightEngine;
@ -10,18 +10,23 @@
+ +
public class PlayerChunk { public class PlayerChunk {
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK_ACCESS = Either.right(PlayerChunk.Failure.b); public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
@@ -65,7 +69,7 @@ @@ -75,11 +79,11 @@
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
- this.chunkSave = CompletableFuture.completedFuture((Object) null); - this.chunkToSave = CompletableFuture.completedFuture((Object) null);
+ this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error + this.chunkToSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
this.dirtyBlocks = new ShortSet[16]; this.chunkToSaveHistory = null;
this.location = chunkcoordintpair; this.blockChangedLightSectionFilter = new BitSet();
this.skyChangedLightSectionFilter = new BitSet();
- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null);
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
this.pos = chunkcoordintpair;
this.levelHeightAccessor = levelheightaccessor;
this.lightEngine = lightengine; this.lightEngine = lightengine;
@@ -77,6 +81,19 @@ @@ -92,6 +96,19 @@
this.a(i); this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
} }
+ // CraftBukkit start + // CraftBukkit start
@ -38,9 +43,9 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) { public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c()); CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.c());
@@ -102,9 +119,9 @@ @@ -117,9 +134,9 @@
@Nullable @Nullable
public Chunk getChunk() { public Chunk getChunk() {
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a(); CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a();
@ -52,25 +57,34 @@
} }
@Nullable @Nullable
@@ -135,6 +152,7 @@ @@ -164,6 +181,7 @@
if (chunk != null) { if (chunk != null) {
byte b0 = (byte) SectionPosition.a(blockposition.getY()); int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
+ if (b0 < 0 || b0 >= this.dirtyBlocks.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296 + if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
if (this.dirtyBlocks[b0] == null) { if (this.changedBlocksPerSection[i] == null) {
this.p = true; this.hasChangedSections = true;
this.dirtyBlocks[b0] = new ShortArraySet(); this.changedBlocksPerSection[i] = new ShortArraySet();
@@ -237,7 +255,7 @@ @@ -274,7 +292,7 @@
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(i); CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(i);
if (completablefuture != null) { if (completablefuture != null) {
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null); - Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error + Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
boolean flag = either != null && either.right().isPresent();
if (either == null || either.left().isPresent()) { if (!flag) {
return completablefuture; @@ -341,7 +359,7 @@
@@ -292,6 +310,30 @@ this.pendingFullStateConfirmation = completablefuture1;
boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET; completablefuture.thenAccept((either) -> {
either.ifLeft((chunk) -> {
- completablefuture1.complete((Object) null);
+ completablefuture1.complete(null); // CraftBukkit - decompile error
});
});
}
@@ -358,6 +376,30 @@
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel); PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel);
PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel); PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel);
+ // CraftBukkit start + // CraftBukkit start
@ -89,7 +103,7 @@
+ } + }
+ }).exceptionally((throwable) -> { + }).exceptionally((throwable) -> {
+ // ensure exceptions are printed, by default this is not the case + // ensure exceptions are printed, by default this is not the case
+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.location, throwable); + MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.pos, throwable);
+ return null; + return null;
+ }); + });
+ +
@ -100,18 +114,18 @@
CompletableFuture completablefuture; CompletableFuture completablefuture;
if (flag) { if (flag) {
@@ -323,7 +365,7 @@ @@ -388,7 +430,7 @@
if (flag2 && !flag3) { if (flag2 && !flag3) {
completablefuture = this.fullChunkFuture; completablefuture = this.fullChunkFuture;
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE; this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
- this.a(completablefuture.thenApply((either1) -> { - this.a(completablefuture.thenApply((either1) -> {
+ this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error + this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error
playerchunkmap.getClass(); Objects.requireNonNull(playerchunkmap);
return either1.ifLeft(playerchunkmap::a); return either1.ifLeft(playerchunkmap::a);
})); }), "unfull");
@@ -361,6 +403,26 @@ @@ -432,6 +474,26 @@
this.u.a(this.location, this::k, this.ticketLevel, this::d); this.onLevelChange.a(this.pos, this::k, this.ticketLevel, this::d);
this.oldTicketLevel = this.ticketLevel; this.oldTicketLevel = this.ticketLevel;
+ // CraftBukkit start + // CraftBukkit start
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins. + // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
@ -125,7 +139,7 @@
+ } + }
+ }).exceptionally((throwable) -> { + }).exceptionally((throwable) -> {
+ // ensure exceptions are printed, by default this is not the case + // ensure exceptions are printed, by default this is not the case
+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.location, throwable); + MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.pos, throwable);
+ return null; + return null;
+ }); + });
+ +

Datei anzeigen

@ -1,47 +1,43 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java --- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java +++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -89,6 +89,8 @@ @@ -91,6 +91,8 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
+import org.bukkit.entity.Player; // CraftBukkit +import org.bukkit.entity.Player; // CraftBukkit
+ +
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d { public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
private static final Logger LOGGER = LogManager.getLogger(); private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -119,6 +121,31 @@ @@ -129,6 +131,27 @@
private final Queue<Runnable> A; private final Queue<Runnable> unloadQueue;
private int viewDistance; int viewDistance;
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor(); + public final CallbackExecutor callbackExecutor = new CallbackExecutor();
+ public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable { + public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
+ +
+ private Runnable queued; + private final java.util.Queue<Runnable> queue = new java.util.ArrayDeque<>();
+ +
+ @Override + @Override
+ public void execute(Runnable runnable) { + public void execute(Runnable runnable) {
+ if (queued != null) { + queue.add(runnable);
+ throw new IllegalStateException("Already queued");
+ }
+ queued = runnable;
+ } + }
+ +
+ @Override + @Override
+ public void run() { + public void run() {
+ Runnable task = queued; + Runnable task;
+ queued = null; + while ((task = queue.poll()) != null) {
+ if (task != null) {
+ task.run(); + task.run();
+ } + }
+ } + }
+ }; + };
+ // CraftBukkit end + // 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, Supplier<WorldPersistentData> supplier, int i, boolean flag) { 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) {
super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag); super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
this.visibleChunks = this.updatingChunks.clone(); this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -239,9 +266,12 @@ @@ -279,9 +302,12 @@
return completablefuture1.thenApply((list1) -> { return completablefuture1.thenApply((list1) -> {
List<IChunkAccess> list2 = Lists.newArrayList(); List<IChunkAccess> list2 = Lists.newArrayList();
@ -56,24 +52,24 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next(); final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
Optional<IChunkAccess> optional = either.left(); Optional<IChunkAccess> optional = either.left();
@@ -344,7 +374,7 @@ @@ -389,7 +415,7 @@
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName()); PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.storageFolder.getName());
} else { } else {
this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> { this.visibleChunkMap.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null); - IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error + IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) { if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
this.saveChunk(ichunkaccess); this.saveChunk(ichunkaccess);
@@ -355,7 +385,6 @@ @@ -400,7 +426,6 @@
} }
} }
- -
protected void unloadChunks(BooleanSupplier booleansupplier) { protected void unloadChunks(BooleanSupplier booleansupplier) {
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler(); GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
@@ -394,7 +423,7 @@ @@ -439,7 +464,7 @@
private void a(long i, PlayerChunk playerchunk) { private void a(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave(); CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave();
@ -82,42 +78,40 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave(); CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave();
if (completablefuture1 != completablefuture) { if (completablefuture1 != completablefuture) {
@@ -616,8 +645,23 @@ @@ -615,7 +640,21 @@
while (iterator.hasNext()) { private static void a(WorldServer worldserver, List<NBTTagCompound> list) {
Entity entity = (Entity) iterator.next(); if (!list.isEmpty()) {
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities - worldserver.b(EntityTypes.a(list, (World) worldserver));
+ boolean needsRemoval = false; + // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
+ if (chunk.needsDecoration) { + worldserver.b(EntityTypes.a(list, (World) worldserver).filter((entity) -> {
+ net.minecraft.server.dedicated.DedicatedServer server = this.world.getServer().getServer(); + boolean needsRemoval = false;
+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) { + net.minecraft.server.dedicated.DedicatedServer server = worldserver.getServer().getServer();
+ entity.die(); + if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) {
+ needsRemoval = true; + entity.die();
+ } + needsRemoval = true;
+ + }
+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) { + if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
+ entity.die(); + entity.die();
+ needsRemoval = true; + needsRemoval = true;
+ } + }
+ } + return !needsRemoval;
+ }));
+ // CraftBukkit end
}
- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) { }
+ if (!(entity instanceof EntityHuman) && (needsRemoval || !this.world.addEntityChunk(entity))) { @@ -843,7 +882,8 @@
+ // CraftBukkit end
if (list == null) {
list = Lists.newArrayList(new Entity[]{entity});
} else {
@@ -828,7 +872,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
}); });
- csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { - csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
+ // CraftBukkit - decompile error + // CraftBukkit - decompile error
+ csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> { + csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
return Stream.of(chunk.getEntitySlices()).mapToInt(EntitySlice::size).sum();
}).orElse(0), optional1.map((chunk) -> {
return chunk.getTileEntities().size(); return chunk.getTileEntities().size();
@@ -839,7 +884,7 @@ }).orElse(0));
}
@@ -852,7 +892,7 @@
private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) { private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try { try {
@ -126,48 +120,41 @@
return either != null ? (String) either.map((chunk) -> { return either != null ? (String) either.map((chunk) -> {
return "done"; return "done";
@@ -857,7 +902,7 @@ @@ -870,7 +910,7 @@
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException { private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound); - return nbttagcompound == null ? null : this.getChunkData(this.level.getDimensionKey(), this.overworldDataStorage, nbttagcompound);
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getTypeKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit + return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, chunkcoordintpair, level); // CraftBukkit
} }
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) { boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
@@ -1189,7 +1234,7 @@ @@ -1233,7 +1273,7 @@
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet(); public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) { public EntityTracker(Entity entity, int i, int j, boolean flag) {
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast); - this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast);
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit + this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit
this.tracker = entity; this.entity = entity;
this.trackingDistance = i; this.range = i;
this.e = SectionPosition.a(entity); this.lastSectionPos = SectionPosition.a(entity);
@@ -1242,7 +1287,7 @@ @@ -1286,10 +1326,18 @@
public void updatePlayer(EntityPlayer entityplayer) { public void updatePlayer(EntityPlayer entityplayer) {
if (entityplayer != this.tracker) { if (entityplayer != this.entity) {
- Vec3D vec3d = entityplayer.getPositionVector().d(this.trackerEntry.b()); - Vec3D vec3d = entityplayer.getPositionVector().d(this.serverEntity.b());
+ Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113 + Vec3D vec3d = entityplayer.getPositionVector().d(this.entity.getPositionVector()); // MC-155077, SPIGOT-5113
int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16); int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16);
boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer); boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.entity.a(entityplayer);
@@ -1258,6 +1303,17 @@ + // CraftBukkit start - respect vanish API
} + if (this.entity instanceof EntityPlayer) {
} + Player player = ((EntityPlayer) this.entity).getBukkitEntity();
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
+ // CraftBukkit start - respect vanish API + flag = false;
+ if (this.tracker instanceof EntityPlayer) {
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
+ flag1 = false;
+ }
+ } + }
+ + }
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); + // CraftBukkit end
+ // CraftBukkit end if (flag) {
+ if (this.seenBy.add(entityplayer.connection)) {
if (flag1 && this.trackedPlayers.add(entityplayer)) { this.serverEntity.b(entityplayer);
this.trackerEntry.b(entityplayer);
}

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/PlayerInteractManager.java --- a/net/minecraft/server/level/PlayerInteractManager.java
+++ b/net/minecraft/server/level/PlayerInteractManager.java +++ b/net/minecraft/server/level/PlayerInteractManager.java
@@ -26,6 +26,25 @@ @@ -25,6 +25,25 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -26,49 +26,49 @@
public class PlayerInteractManager { public class PlayerInteractManager {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -60,7 +79,7 @@ @@ -65,7 +84,7 @@
this.gamemode = enumgamemode; this.gameModeForPlayer = enumgamemode;
enumgamemode.a(this.player.abilities); enumgamemode.a(this.player.getAbilities());
this.player.updateAbilities(); this.player.updateAbilities();
- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player})); - this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}));
+ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit + this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit
this.world.everyoneSleeping(); this.level.everyoneSleeping();
} }
@@ -89,7 +108,7 @@ @@ -87,7 +106,7 @@
} }
public void a() { public void a() {
- ++this.currentTick; - ++this.gameTicks;
+ this.currentTick = MinecraftServer.currentTick; // CraftBukkit; + this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
IBlockData iblockdata; IBlockData iblockdata;
if (this.j) { if (this.hasDelayedDestroy) {
@@ -145,9 +164,31 @@ @@ -143,9 +162,31 @@
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) { if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
if (!this.world.a((EntityHuman) this.player, blockposition)) { if (!this.level.a((EntityHuman) this.player, blockposition)) {
+ // CraftBukkit start - fire PlayerInteractEvent + // CraftBukkit start - fire PlayerInteractEvent
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); + CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact")); this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ TileEntity tileentity = world.getTileEntity(blockposition); + TileEntity tileentity = level.getTileEntity(blockposition);
+ if (tileentity != null) { + if (tileentity != null) {
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); + this.player.connection.sendPacket(tileentity.getUpdatePacket());
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ return; + return;
+ } + }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND); + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // Let the client know the block still exists + // Let the client know the block still exists
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ TileEntity tileentity = this.world.getTileEntity(blockposition); + TileEntity tileentity = this.level.getTileEntity(blockposition);
+ if (tileentity != null) { + if (tileentity != null) {
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); + this.player.connection.sendPacket(tileentity.getUpdatePacket());
+ } + }
return; return;
} }
@ -76,40 +76,40 @@
if (this.isCreative()) { if (this.isCreative()) {
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy"); this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
@@ -163,11 +204,43 @@ @@ -161,11 +202,43 @@
float f = 1.0F; float f = 1.0F;
iblockdata = this.world.getType(blockposition); iblockdata = this.level.getType(blockposition);
- if (!iblockdata.isAir()) { - if (!iblockdata.isAir()) {
+ // CraftBukkit start - Swings at air do *NOT* exist. + // CraftBukkit start - Swings at air do *NOT* exist.
+ if (event.useInteractedBlock() == Event.Result.DENY) { + if (event.useInteractedBlock() == Event.Result.DENY) {
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
+ IBlockData data = this.world.getType(blockposition); + IBlockData data = this.level.getType(blockposition);
+ if (data.getBlock() instanceof BlockDoor) { + if (data.getBlock() instanceof BlockDoor) {
+ // For some reason *BOTH* the bottom/top part have to be marked updated. + // For some reason *BOTH* the bottom/top part have to be marked updated.
+ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; + boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down())); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.up() : blockposition.down()));
+ } else if (data.getBlock() instanceof BlockTrapdoor) { + } else if (data.getBlock() instanceof BlockTrapdoor) {
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ } + }
+ } else if (!iblockdata.isAir()) { + } else if (!iblockdata.isAir()) {
iblockdata.attack(this.world, blockposition, this.player); iblockdata.attack(this.level, blockposition, this.player);
f = iblockdata.getDamage(this.player, this.player.world, blockposition); f = iblockdata.getDamage(this.player, this.player.level, blockposition);
} }
+ if (event.useItemInHand() == Event.Result.DENY) { + if (event.useItemInHand() == Event.Result.DENY) {
+ // If we 'insta destroyed' then the client needs to be informed. + // If we 'insta destroyed' then the client needs to be informed.
+ if (f > 1.0f) { + if (f > 1.0f) {
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ } + }
+ return; + return;
+ } + }
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.inventory.getItemInHand(), f >= 1.0f); + org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getItemInHand(), f >= 1.0f);
+ +
+ if (blockEvent.isCancelled()) { + if (blockEvent.isCancelled()) {
+ // Let the client know the block still exists + // Let the client know the block still exists
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ return; + return;
+ } + }
+ +
@ -121,41 +121,40 @@
if (!iblockdata.isAir() && f >= 1.0F) { if (!iblockdata.isAir() && f >= 1.0F) {
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine"); this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
} else { } else {
@@ -211,7 +284,7 @@ @@ -209,7 +282,7 @@
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) { } else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
this.f = false; this.isDestroyingBlock = false;
if (!Objects.equals(this.h, blockposition)) { if (!Objects.equals(this.destroyPos, blockposition)) {
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.h + " " + blockposition); - PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled + PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
this.world.a(this.player.getId(), this.h, -1); this.level.a(this.player.getId(), this.destroyPos, -1);
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); this.player.connection.sendPacket(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getType(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
} }
@@ -227,17 +300,73 @@ @@ -225,17 +298,72 @@
if (this.breakBlock(blockposition)) { if (this.breakBlock(blockposition)) {
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s)); this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
} else { } else {
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s)); - this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); // CraftBukkit - SPIGOT-5196 + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
} }
} }
public boolean breakBlock(BlockPosition blockposition) { public boolean breakBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.world.getType(blockposition); IBlockData iblockdata = this.level.getType(blockposition);
+ // CraftBukkit start - fire BlockBreakEvent + // CraftBukkit start - fire BlockBreakEvent
+ org.bukkit.block.Block bblock = CraftBlock.at(world, blockposition); + org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
+ BlockBreakEvent event = null; + BlockBreakEvent event = null;
+ +
+ if (this.player instanceof EntityPlayer) { + if (this.player instanceof EntityPlayer) {
+ // Sword + Creative mode pre-cancel + // Sword + Creative mode pre-cancel
+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player); + boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.level, blockposition, (EntityHuman) this.player);
+ +
+ // Tell client the block is gone immediately then process events + // Tell client the block is gone immediately then process events
+ // Don't tell the client if its a creative sword break because its not broken! + // Don't tell the client if its a creative sword break because its not broken!
+ if (world.getTileEntity(blockposition) == null && !isSwordNoBreak) { + if (level.getTileEntity(blockposition) == null && !isSwordNoBreak) {
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition); + PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.getBlockData());
+ packet.block = Blocks.AIR.getBlockData(); + this.player.connection.sendPacket(packet);
+ this.player.playerConnection.sendPacket(packet);
+ } + }
+ +
+ event = new BlockBreakEvent(bblock, this.player.getBukkitEntity()); + event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
@ -164,60 +163,60 @@
+ event.setCancelled(isSwordNoBreak); + event.setCancelled(isSwordNoBreak);
+ +
+ // Calculate default block experience + // Calculate default block experience
+ IBlockData nmsData = this.world.getType(blockposition); + IBlockData nmsData = this.level.getType(blockposition);
+ Block nmsBlock = nmsData.getBlock(); + Block nmsBlock = nmsData.getBlock();
+ +
+ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND); + ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
+ +
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) { + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack)); + event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack));
+ } + }
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { - if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) {
+ this.world.getServer().getPluginManager().callEvent(event); + this.level.getServer().getPluginManager().callEvent(event);
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ if (isSwordNoBreak) { + if (isSwordNoBreak) {
+ return false; + return false;
+ } + }
+ // Let the client know the block still exists + // Let the client know the block still exists
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
+ +
+ // Brute force all possible updates + // Brute force all possible updates
+ for (EnumDirection dir : EnumDirection.values()) { + for (EnumDirection dir : EnumDirection.values()) {
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir))); + this.player.connection.sendPacket(new PacketPlayOutBlockChange(level, blockposition.shift(dir)));
+ } + }
+ +
+ // Update any tile entity data for this block + // Update any tile entity data for this block
+ TileEntity tileentity = this.world.getTileEntity(blockposition); + TileEntity tileentity = this.level.getTileEntity(blockposition);
+ if (tileentity != null) { + if (tileentity != null) {
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket()); + this.player.connection.sendPacket(tileentity.getUpdatePacket());
+ } + }
+ return false; + return false;
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false + if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
return false; return false;
} else { } else {
+ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins + iblockdata = this.level.getType(blockposition); // CraftBukkit - update state from plugins
+ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling + if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
TileEntity tileentity = this.world.getTileEntity(blockposition); TileEntity tileentity = this.level.getTileEntity(blockposition);
Block block = iblockdata.getBlock(); Block block = iblockdata.getBlock();
@@ -247,6 +376,10 @@ @@ -245,6 +373,10 @@
} else if (this.player.a((World) this.world, blockposition, this.gamemode)) { } else if (this.player.a((World) this.level, blockposition, this.gameModeForPlayer)) {
return false; return false;
} else { } else {
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.block.BlockState state = bblock.getState(); + org.bukkit.block.BlockState state = bblock.getState();
+ world.captureDrops = new ArrayList<>(); + level.captureDrops = new ArrayList<>();
+ // CraftBukkit end + // CraftBukkit end
block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player); block.a((World) this.level, blockposition, iblockdata, (EntityHuman) this.player);
boolean flag = this.world.a(blockposition, false); boolean flag = this.level.a(blockposition, false);
@@ -255,19 +388,32 @@ @@ -253,19 +385,32 @@
} }
if (this.isCreative()) { if (this.isCreative()) {
@ -228,10 +227,10 @@
ItemStack itemstack1 = itemstack.cloneItemStack(); ItemStack itemstack1 = itemstack.cloneItemStack();
boolean flag1 = this.player.hasBlock(iblockdata); boolean flag1 = this.player.hasBlock(iblockdata);
itemstack.a(this.world, iblockdata, blockposition, this.player); itemstack.a(this.level, iblockdata, blockposition, this.player);
- if (flag && flag1) { - if (flag && flag1) {
+ if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items + if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
block.a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack1); block.a(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1);
} }
- return true; - return true;
@ -239,13 +238,13 @@
+ } + }
+ // CraftBukkit start + // CraftBukkit start
+ if (event.isDropItems()) { + if (event.isDropItems()) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops);
} }
+ world.captureDrops = null; + level.captureDrops = null;
+ +
+ // Drop event experience + // Drop event experience
+ if (flag && event != null) { + if (flag && event != null) {
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop()); + iblockdata.getBlock().dropExperience(this.level, blockposition, event.getExpToDrop());
+ } + }
+ +
+ return true; + return true;
@ -253,7 +252,7 @@
} }
} }
} }
@@ -309,12 +455,52 @@ @@ -307,12 +452,52 @@
} }
} }
@ -269,7 +268,7 @@
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS; + EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS;
+ boolean cancelledBlock = false; + boolean cancelledBlock = false;
if (this.gamemode == EnumGamemode.SPECTATOR) { if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
ITileInventory itileinventory = iblockdata.b(world, blockposition); ITileInventory itileinventory = iblockdata.b(world, blockposition);
+ cancelledBlock = !(itileinventory instanceof ITileInventory); + cancelledBlock = !(itileinventory instanceof ITileInventory);
+ } + }
@ -289,24 +288,24 @@
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. + // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
+ if (iblockdata.getBlock() instanceof BlockDoor) { + if (iblockdata.getBlock() instanceof BlockDoor) {
+ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; + boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); + entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
+ } else if (iblockdata.getBlock() instanceof BlockCake) { + } else if (iblockdata.getBlock() instanceof BlockCake) {
+ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake + entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
+ } else if (interactItemStack.getItem() instanceof ItemBisected) { + } else if (interactItemStack.getItem() instanceof ItemBisected) {
+ // send a correcting update to the client, as it already placed the upper half of the bisected item + // send a correcting update to the client, as it already placed the upper half of the bisected item
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up())); + entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up()));
+ +
+ // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) + // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up())); + entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up()));
+ } + }
+ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867 + entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS; + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
+ } else if (this.gamemode == EnumGamemode.SPECTATOR) { + } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
+ ITileInventory itileinventory = iblockdata.b(world, blockposition); + ITileInventory itileinventory = iblockdata.b(world, blockposition);
if (itileinventory != null) { if (itileinventory != null) {
entityplayer.openContainer(itileinventory); entityplayer.openContainer(itileinventory);
@@ -328,7 +514,7 @@ @@ -326,7 +511,7 @@
ItemStack itemstack1 = itemstack.cloneItemStack(); ItemStack itemstack1 = itemstack.cloneItemStack();
if (!flag1) { if (!flag1) {
@ -314,8 +313,8 @@
+ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock); + enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
if (enuminteractionresult.a()) { if (enuminteractionresult.a()) {
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1); CriterionTriggers.ITEM_USED_ON_BLOCK.a(entityplayer, blockposition, itemstack1);
@@ -336,17 +522,17 @@ @@ -334,17 +519,17 @@
} }
} }
@ -336,7 +335,7 @@
} }
if (enuminteractionresult1.a()) { if (enuminteractionresult1.a()) {
@@ -354,10 +540,10 @@ @@ -352,10 +537,10 @@
} }
return enuminteractionresult1; return enuminteractionresult1;

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java --- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java +++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
@@ -273,6 +273,13 @@ @@ -308,6 +308,13 @@
@Override @Override
public boolean addEntity(Entity entity) { public boolean addEntity(Entity entity) {
@ -11,6 +11,6 @@
+ @Override + @Override
+ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ // CraftBukkit end + // CraftBukkit end
int i = MathHelper.floor(entity.locX() / 16.0D); int i = SectionPosition.a(entity.cW());
int j = MathHelper.floor(entity.locZ() / 16.0D); int j = SectionPosition.a(entity.dc());

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java --- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java
@@ -145,6 +145,21 @@ @@ -152,6 +152,22 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -8,6 +8,7 @@
+import java.util.logging.Level; +import java.util.logging.Level;
+import net.minecraft.world.entity.monster.EntityDrowned; +import net.minecraft.world.entity.monster.EntityDrowned;
+import net.minecraft.world.level.block.ITileEntity; +import net.minecraft.world.level.block.ITileEntity;
+import net.minecraft.world.level.block.entity.TileEntity;
+import net.minecraft.world.level.storage.WorldDataServer; +import net.minecraft.world.level.storage.WorldDataServer;
+import org.bukkit.Bukkit; +import org.bukkit.Bukkit;
+import org.bukkit.WeatherType; +import org.bukkit.WeatherType;
@ -21,21 +22,22 @@
+ +
public class WorldServer extends World implements GeneratorAccessSeed { public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition a = new BlockPosition(100, 50, 0); public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -156,7 +171,7 @@ @@ -160,7 +176,7 @@
private final ChunkProviderServer chunkProvider; final List<EntityPlayer> players;
boolean tickingEntities; private final ChunkProviderServer chunkSource;
private final MinecraftServer server; private final MinecraftServer server;
- public final IWorldDataServer worldDataServer; - public final IWorldDataServer serverLevelData;
+ public final WorldDataServer worldDataServer; // CraftBukkit - type + public final WorldDataServer serverLevelData; // CraftBukkit - type
public boolean savingDisabled; final EntityTickList entityTickList;
private boolean everyoneSleeping; private final PersistentEntitySectionManager<Entity> entityManager;
private int emptyTime; public boolean noSave;
@@ -173,8 +188,23 @@ @@ -180,31 +196,52 @@
private final StructureManager structureManager; private final StructureManager structureFeatureManager;
private final boolean Q; private final boolean tickTime;
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) { - public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i); - super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i);
+ +
+ // CraftBukkit start + // CraftBukkit start
@ -44,50 +46,67 @@
+ public final UUID uuid; + public final UUID uuid;
+ +
+ public Chunk getChunkIfLoaded(int x, int z) { + public Chunk getChunkIfLoaded(int x, int z) {
+ return this.chunkProvider.getChunkAt(x, z, false); + return this.chunkSource.getChunkAt(x, z, false);
+ } + }
+ +
+ // Add env and gen to constructor, WorldData -> WorldDataServer + // Add env and gen to constructor, WorldData -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { + public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env); + super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env);
+ this.pvpMode = minecraftserver.getPVP(); + this.pvpMode = minecraftserver.getPVP();
+ convertable = convertable_conversionsession; + convertable = convertable_conversionsession;
+ uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile()); + uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
+ // CraftBukkit end + // CraftBukkit end
this.nextTickListBlock = new TickListServer<>(this, (block) -> { this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
- Predicate predicate = (block) -> {
+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror
return block == null || block.getBlockData().isAir(); return block == null || block.getBlockData().isAir();
}, IRegistry.BLOCK::getKey, this::b); };
@@ -186,10 +216,17 @@ RegistryBlocks registryblocks = IRegistry.BLOCK;
this.Q = flag1;
Objects.requireNonNull(registryblocks);
- this.blockTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::b);
- predicate = (fluidtype) -> {
+ this.blockTicks = new TickListServer<>(this, predicate, IRegistry.BLOCK::getKey, this::b); // CraftBukkit - decompile error
+ Predicate<FluidType> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
};
registryblocks = IRegistry.FLUID;
Objects.requireNonNull(registryblocks);
- this.liquidTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::a);
+ this.liquidTicks = new TickListServer<>(this, predicate2, IRegistry.FLUID::getKey, this::a); // CraftBukkit - decompile error
this.navigatingMobs = new ObjectOpenHashSet();
this.blockEvents = new ObjectLinkedOpenHashSet();
this.dragonParts = new Int2ObjectOpenHashMap();
this.tickTime = flag1;
this.server = minecraftserver; this.server = minecraftserver;
this.mobSpawners = list; this.customSpawners = list;
- this.worldDataServer = iworlddataserver; - this.serverLevelData = iworlddataserver;
+ // CraftBukkit start + // CraftBukkit start
+ this.worldDataServer = (WorldDataServer) iworlddataserver; + this.serverLevelData = (WorldDataServer) iworlddataserver;
+ worldDataServer.world = this; + serverLevelData.world = this;
+ if (gen != null) { + if (gen != null) {
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen); + chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
+ } + }
+
this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> {
return minecraftserver.E().getWorldPersistentData();
});
+ // CraftBukkit end + // CraftBukkit end
this.portalTravelAgent = new PortalTravelAgent(this); boolean flag2 = minecraftserver.isSyncChunkWrites();
this.Q(); DataFixer datafixer = minecraftserver.getDataFixer();
this.R(); EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, new File(convertable_conversionsession.a(resourcekey), "entities"), datafixer, flag2, minecraftserver);
@@ -201,14 +238,50 @@ @@ -231,15 +268,51 @@
iworlddataserver.setGameType(minecraftserver.getGamemode()); iworlddataserver.setGameType(minecraftserver.getGamemode());
} }
- this.structureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings()); - this.structureFeatureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings());
+ this.structureManager = new StructureManager(this, this.worldDataServer.getGeneratorSettings()); // CraftBukkit + this.structureFeatureManager = new StructureManager(this, this.serverLevelData.getGeneratorSettings()); // CraftBukkit
if (this.getDimensionManager().isCreateDragonBattle()) { if (this.getDimensionManager().isCreateDragonBattle()) {
- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C()); - this.dragonFight = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C());
+ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.C()); // CraftBukkit + this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.getGeneratorSettings().getSeed(), this.serverLevelData.C()); // CraftBukkit
} else { } else {
this.dragonBattle = null; this.dragonFight = null;
} }
this.sleepStatus = new SleepStatus();
+ this.getServer().addWorld(this.getWorld()); // CraftBukkit + this.getServer().addWorld(this.getWorld()); // CraftBukkit
+ } + }
+ +
@ -95,13 +114,13 @@
+ @Override + @Override
+ public TileEntity getTileEntity(BlockPosition pos, boolean validate) { + public TileEntity getTileEntity(BlockPosition pos, boolean validate) {
+ TileEntity result = super.getTileEntity(pos, validate); + TileEntity result = super.getTileEntity(pos, validate);
+ if (!validate || Thread.currentThread() != this.serverThread) { + if (!validate || Thread.currentThread() != this.thread) {
+ // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load + // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load
+ return result; + return result;
+ } + }
+ Block type = getType(pos).getBlock(); + IBlockData type = getType(pos);
+
+ if (result != null && type != Blocks.AIR) { + if (result != null && !type.a(Blocks.AIR)) {
+ if (!result.getTileType().isValidBlock(type)) { + if (!result.getTileType().isValidBlock(type)) {
+ result = fixTileEntity(pos, type, result); + result = fixTileEntity(pos, type, result);
+ } + }
@ -110,15 +129,14 @@
+ return result; + return result;
+ } + }
+ +
+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) { + private TileEntity fixTileEntity(BlockPosition pos, IBlockData type, TileEntity found) {
+ this.getServer().getLogger().log(Level.SEVERE, "Block at {0}, {1}, {2} is {3} but has {4}" + ". " + this.getServer().getLogger().log(Level.SEVERE, "Block at {0}, {1}, {2} is {3} but has {4}" + ". "
+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found}); + + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found});
+ +
+ if (type instanceof ITileEntity) { + if (type instanceof ITileEntity) {
+ TileEntity replacement = ((ITileEntity) type).createTile(this); + TileEntity replacement = ((ITileEntity) type).createTile(pos, type);
+ if (replacement != null) { + if (replacement != null) {
+ replacement.setLocation(this, pos); + this.setTileEntity(replacement);
+ this.setTileEntity(pos, replacement);
+ } + }
+ return replacement; + return replacement;
+ } else { + } else {
@ -128,22 +146,22 @@
+ // CraftBukkit end + // CraftBukkit end
public void a(int i, int j, boolean flag, boolean flag1) { public void a(int i, int j, boolean flag, boolean flag1) {
this.worldDataServer.setClearWeatherTime(i); this.serverLevelData.setClearWeatherTime(i);
@@ -299,6 +372,7 @@ @@ -331,6 +404,7 @@
this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F); this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F);
} }
+ /* CraftBukkit start + /* CraftBukkit start
if (this.lastRainLevel != this.rainLevel) { if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)), this.getDimensionKey()); this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)), this.getDimensionKey());
} }
@@ -317,18 +391,47 @@ @@ -349,16 +423,45 @@
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
+ // */ + // */
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) { + if (((EntityPlayer) this.players.get(idx)).level == this) {
+ ((EntityPlayer) this.players.get(idx)).tickWeather(); + ((EntityPlayer) this.players.get(idx)).tickWeather();
+ } + }
+ } + }
@ -151,28 +169,25 @@
+ if (flag != this.isRaining()) { + if (flag != this.isRaining()) {
+ // Only send weather packets to those affected + // Only send weather packets to those affected
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) { + if (((EntityPlayer) this.players.get(idx)).level == this) {
+ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); + ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
+ } + }
+ } + }
+ } + }
+ for (int idx = 0; idx < this.players.size(); ++idx) { + for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).world == this) { + if (((EntityPlayer) this.players.get(idx)).level == this) {
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel); + ((EntityPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel);
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> { i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping(); if (this.sleepStatus.a(i) && this.sleepStatus.a(i, this.players)) {
+ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit
})) {
- this.everyoneSleeping = false;
+ // CraftBukkit start + // CraftBukkit start
+ long l = this.worldData.getDayTime() + 24000L; + long l = this.levelData.getDayTime() + 24000L;
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime()); + TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) { if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
- long l = this.worldData.getDayTime() + 24000L; - long l = this.levelData.getDayTime() + 24000L;
+ getServer().getPluginManager().callEvent(event); + getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ this.setDayTime(this.getDayTime() + event.getSkipAmount()); + this.setDayTime(this.getDayTime() + event.getSkipAmount());
@ -183,49 +198,41 @@
- this.wakeupPlayers(); - this.wakeupPlayers();
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ this.everyoneSleeping = false;
+ this.wakeupPlayers(); + this.wakeupPlayers();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (this.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE)) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) {
this.clearWeather(); this.clearWeather();
} }
@@ -350,7 +453,7 @@ @@ -380,7 +483,7 @@
this.ak(); this.aq();
this.ticking = false; this.handlingTick = false;
gameprofilerfiller.exitEnter("entities"); gameprofilerfiller.exit();
- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); - boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty();
+ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players + boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
if (flag3) { if (flag3) {
this.resetEmptyTime(); this.resetEmptyTime();
@@ -369,6 +472,7 @@ @@ -396,7 +499,7 @@
Entity entity = (Entity) entry.getValue();
Entity entity1 = entity.getVehicle();
+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed this.entityTickList.a((entity) -> {
if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { if (!entity.isRemoved()) {
entity.die(); - if (this.i(entity)) {
} + if (false && this.i(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
@@ -376,6 +480,7 @@ entity.die();
if (!this.server.getSpawnNPCs() && entity instanceof NPC) { } else {
entity.die(); gameprofilerfiller.enter("checkDespawn");
} @@ -461,7 +564,7 @@
+ // CraftBukkit end */
gameprofilerfiller.enter("checkDespawn");
if (!entity.dead) {
@@ -450,7 +555,7 @@
}
private void wakeupPlayers() { private void wakeupPlayers() {
this.sleepStatus.a();
- ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { - ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> {
+ (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error + (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error
entityplayer.wakeup(false, false); entityplayer.wakeup(false, false);
}); });
} }
@@ -477,14 +582,14 @@ @@ -488,14 +591,14 @@
entityhorseskeleton.t(true); entityhorseskeleton.v(true);
entityhorseskeleton.setAgeRaw(0); entityhorseskeleton.setAgeRaw(0);
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
- this.addEntity(entityhorseskeleton); - this.addEntity(entityhorseskeleton);
@ -241,80 +248,63 @@
} }
} }
@@ -495,11 +600,11 @@ @@ -506,12 +609,12 @@
BiomeBase biomebase = this.getBiome(blockposition); BiomeBase biomebase = this.getBiome(blockposition);
if (biomebase.a(this, blockposition1)) { if (biomebase.a((IWorldReader) this, blockposition1)) {
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData()); - this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
} }
if (flag && biomebase.b(this, blockposition)) { if (flag) {
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData()); if (biomebase.b(this, blockposition)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit - this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
} + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
}
if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) { IBlockData iblockdata = this.getType(blockposition1);
@@ -546,7 +651,7 @@ @@ -642,10 +745,22 @@
protected BlockPosition a(BlockPosition blockposition) {
BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D);
- List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> {
+ List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates());
});
@@ -575,7 +680,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer.isSpectator()) {
+ if (entityplayer.isSpectator() || (entityplayer.fauxSleeping && !entityplayer.isSleeping())) { // CraftBukkit
++i;
} else if (entityplayer.isSleeping()) {
++j;
@@ -593,10 +698,22 @@
} }
private void clearWeather() { private void clearWeather() {
- this.worldDataServer.setWeatherDuration(0); - this.serverLevelData.setWeatherDuration(0);
+ // CraftBukkit start + // CraftBukkit start
this.worldDataServer.setStorm(false); this.serverLevelData.setStorm(false);
- this.worldDataServer.setThunderDuration(0); - this.serverLevelData.setThunderDuration(0);
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
+ // Not that everyone ever manages to get the whole server to sleep at the same time.... + // Not that everyone ever manages to get the whole server to sleep at the same time....
+ if (!this.worldDataServer.hasStorm()) { + if (!this.serverLevelData.hasStorm()) {
+ this.worldDataServer.setWeatherDuration(0); + this.serverLevelData.setWeatherDuration(0);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.worldDataServer.setThundering(false); this.serverLevelData.setThundering(false);
+ // CraftBukkit start + // CraftBukkit start
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value. + // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
+ // Not that everyone ever manages to get the whole server to sleep at the same time.... + // Not that everyone ever manages to get the whole server to sleep at the same time....
+ if (!this.worldDataServer.isThundering()) { + if (!this.serverLevelData.isThundering()) {
+ this.worldDataServer.setThunderDuration(0); + this.serverLevelData.setThunderDuration(0);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -637,6 +754,7 @@ @@ -680,6 +795,7 @@
});
gameprofilerfiller.c("tickNonPassenger");
entity.tick();
+ entity.postTick(); // CraftBukkit
this.getMethodProfiler().exit();
Iterator iterator = entity.getPassengers().iterator();
@@ -703,6 +819,7 @@
}); });
gameprofilerfiller.c("tickNonPassenger"); gameprofilerfiller.c("tickPassenger");
entity.tick(); entity1.passengerTick();
+ entity.postTick(); // CraftBukkit + entity1.postTick(); // CraftBukkit
gameprofilerfiller.exit(); gameprofilerfiller.exit();
} Iterator iterator = entity1.getPassengers().iterator();
@@ -669,6 +787,7 @@ @@ -727,6 +844,7 @@
});
gameprofilerfiller.c("tickPassenger");
entity1.passengerTick();
+ entity1.postTick(); // CraftBukkit
gameprofilerfiller.exit();
}
@@ -725,6 +844,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkProvider(); ChunkProviderServer chunkproviderserver = this.getChunkProvider();
if (!flag1) { if (!flag1) {
@ -322,28 +312,28 @@
if (iprogressupdate != null) { if (iprogressupdate != null) {
iprogressupdate.a(new ChatMessage("menu.savingLevel")); iprogressupdate.a(new ChatMessage("menu.savingLevel"));
} }
@@ -736,11 +856,19 @@ @@ -744,11 +862,19 @@
}
chunkproviderserver.save(flag);
} }
+ +
+ // CraftBukkit start - moved from MinecraftServer.saveChunks + // CraftBukkit start - moved from MinecraftServer.saveChunks
+ WorldServer worldserver1 = this; + WorldServer worldserver1 = this;
+ +
+ worldDataServer.a(worldserver1.getWorldBorder().t()); + serverLevelData.a(worldserver1.getWorldBorder().t());
+ worldDataServer.setCustomBossEvents(this.server.getBossBattleCustomData().save()); + serverLevelData.setCustomBossEvents(this.server.getBossBattleCustomData().save());
+ convertable.a(this.server.customRegistry, this.worldDataServer, this.server.getPlayerList().save()); + convertable.a(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().save());
+ // CraftBukkit end + // CraftBukkit end
} }
private void aj() { private void ap() {
if (this.dragonBattle != null) { if (this.dragonFight != null) {
- this.server.getSaveData().a(this.dragonBattle.a()); - this.server.getSaveData().a(this.dragonFight.a());
+ this.worldDataServer.a(this.dragonBattle.a()); // CraftBukkit + this.serverLevelData.a(this.dragonFight.a()); // CraftBukkit
} }
this.getChunkProvider().getWorldPersistentData().a(); this.getChunkProvider().getWorldPersistentData().a();
@@ -801,11 +929,24 @@ @@ -794,15 +920,34 @@
@Override @Override
public boolean addEntity(Entity entity) { public boolean addEntity(Entity entity) {
@ -370,47 +360,56 @@
} }
public void addEntityTeleport(Entity entity) { public void addEntityTeleport(Entity entity) {
@@ -855,13 +996,18 @@ - this.addEntity0(entity);
this.registerEntity(entityplayer); + // CraftBukkit start
+ this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
+ this.addEntity0(entity, reason);
+ // CraftBukkit end
}
public void addPlayerCommand(EntityPlayer entityplayer) {
@@ -830,27 +975,39 @@
this.a((EntityPlayer) entity, Entity.RemovalReason.DISCARDED);
}
- this.entityManager.a((EntityAccess) entityplayer);
+ this.entityManager.a(entityplayer); // CraftBukkit - decompile error
} }
- private boolean addEntity0(Entity entity) { - private boolean addEntity0(Entity entity) {
+ // CraftBukkit start + // CraftBukkit start
+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { + private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
if (entity.dead) { if (entity.isRemoved()) {
- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); - WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType()));
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit + // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit
return false; return false;
} else if (this.isUUIDTaken(entity)) {
return false;
} else { } else {
- return this.entityManager.a((EntityAccess) entity);
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { + if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
+ return false; + return false;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer); +
+ return this.entityManager.a(entity); // CraftBukkit - decompile error
if (!(ichunkaccess instanceof Chunk)) {
@@ -890,7 +1036,7 @@
if (entity1 == null) {
return false;
} else {
- WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId());
+ // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit
return true;
} }
} }
@@ -919,10 +1065,16 @@
}
public boolean addAllEntitiesSafely(Entity entity) { public boolean addAllEntitiesSafely(Entity entity) {
- Stream stream = entity.recursiveStream().map(Entity::getUniqueID);
+ // CraftBukkit start + // CraftBukkit start
+ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ } + }
+ +
+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ // CraftBukkit end + // CraftBukkit end
if (entity.recursiveStream().anyMatch(this::isUUIDTaken)) { + Stream<UUID> stream = entity.recursiveStream().map(Entity::getUniqueID); // CraftBukkit - decompile error
PersistentEntitySectionManager persistententitysectionmanager = this.entityManager;
Objects.requireNonNull(this.entityManager);
if (stream.anyMatch(persistententitysectionmanager::a)) {
return false; return false;
} else { } else {
- this.addAllEntities(entity); - this.addAllEntities(entity);
@ -418,52 +417,8 @@
return true; return true;
} }
} }
@@ -973,10 +1125,17 @@ @@ -863,10 +1020,32 @@
} entityplayer.a(entity_removalreason);
this.getScoreboard().a(entity);
+ // CraftBukkit start - SPIGOT-5278
+ if (entity instanceof EntityDrowned) {
+ this.navigators.remove(((EntityDrowned) entity).navigationWater);
+ this.navigators.remove(((EntityDrowned) entity).navigationLand);
+ } else
+ // CraftBukkit end
if (entity instanceof EntityInsentient) {
this.navigators.remove(((EntityInsentient) entity).getNavigation());
}
+ entity.valid = false; // CraftBukkit
}
private void registerEntity(Entity entity) {
@@ -997,9 +1156,16 @@
this.entitiesByUUID.put(entity.getUniqueID(), entity);
this.getChunkProvider().addEntity(entity);
+ // CraftBukkit start - SPIGOT-5278
+ if (entity instanceof EntityDrowned) {
+ this.navigators.add(((EntityDrowned) entity).navigationWater);
+ this.navigators.add(((EntityDrowned) entity).navigationLand);
+ } else
+ // CraftBukkit end
if (entity instanceof EntityInsentient) {
this.navigators.add(((EntityInsentient) entity).getNavigation());
}
+ entity.valid = true; // CraftBukkit
}
}
@@ -1015,7 +1181,7 @@
}
private void removeEntityFromChunk(Entity entity) {
- IChunkAccess ichunkaccess = this.getChunkAt(entity.chunkX, entity.chunkZ, ChunkStatus.FULL, false);
+ IChunkAccess ichunkaccess = chunkProvider.getChunkUnchecked(entity.chunkX, entity.chunkZ); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE).
if (ichunkaccess instanceof Chunk) {
((Chunk) ichunkaccess).b(entity);
@@ -1029,10 +1195,32 @@
this.everyoneSleeping();
} }
+ // CraftBukkit start + // CraftBukkit start
@ -495,7 +450,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -1041,6 +1229,12 @@ @@ -875,6 +1054,12 @@
double d1 = (double) blockposition.getY() - entityplayer.locY(); double d1 = (double) blockposition.getY() - entityplayer.locY();
double d2 = (double) blockposition.getZ() - entityplayer.locZ(); double d2 = (double) blockposition.getZ() - entityplayer.locZ();
@ -506,17 +461,17 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); entityplayer.connection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
} }
@@ -1079,7 +1273,18 @@ @@ -923,7 +1108,18 @@
Iterator iterator = this.navigators.iterator(); Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
- NavigationAbstract navigationabstract = (NavigationAbstract) iterator.next(); - EntityInsentient entityinsentient = (EntityInsentient) iterator.next();
+ // CraftBukkit start - fix SPIGOT-6362 + // CraftBukkit start - fix SPIGOT-6362
+ NavigationAbstract navigationabstract; + EntityInsentient entityinsentient;
+ try { + try {
+ navigationabstract = (NavigationAbstract) iterator.next(); + entityinsentient = (EntityInsentient) iterator.next();
+ } catch (java.util.ConcurrentModificationException ex) { + } catch (java.util.ConcurrentModificationException ex) {
+ // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register + // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register
+ // In this case we just run the update again across all the iterators as the chunk will then be loaded + // In this case we just run the update again across all the iterators as the chunk will then be loaded
@ -525,10 +480,10 @@
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (!navigationabstract.i()) { if (!navigationabstract.i()) {
navigationabstract.b(blockposition); @@ -946,10 +1142,20 @@
@@ -1101,10 +1306,20 @@
@Override @Override
public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -549,7 +504,7 @@
if (explosion_effect == Explosion.Effect.NONE) { if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearBlocks(); explosion.clearBlocks();
} }
@@ -1169,13 +1384,20 @@ @@ -1023,13 +1229,20 @@
} }
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) { public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -572,85 +527,39 @@
++j; ++j;
} }
} }
@@ -1217,7 +1439,7 @@ @@ -1079,7 +1292,7 @@
@Nullable @Nullable
public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) { public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
- return !this.server.getSaveData().getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); - return !this.server.getSaveData().getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag);
+ return !this.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit + return !this.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
} }
@Nullable @Nullable
@@ -1255,7 +1477,13 @@ @@ -1116,11 +1329,21 @@
@Nullable
@Override @Override
public WorldMap a(String s) { public WorldMap a(String s) {
return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> { - return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a(WorldMap::b, s);
- return new WorldMap(s); + return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a((nbttagcompound) -> {
+ // CraftBukkit start + // CraftBukkit start
+ // We only get here when the data file exists, but is not a valid map + // We only get here when the data file exists, but is not a valid map
+ WorldMap newMap = new WorldMap(s); + WorldMap newMap = WorldMap.b(nbttagcompound);
+ newMap.id = s;
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView); + MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event);
+ return newMap; + return newMap;
+ // CraftBukkit end + // CraftBukkit end
}, s); + }, s);
} }
@@ -1386,9 +1614,9 @@ @Override
reputationhandler.a(reputationevent, entity); public void a(String s, WorldMap worldmap) {
+ worldmap.id = s; // CraftBukkit
this.getMinecraftServer().F().getWorldPersistentData().a(s, (PersistentBase) worldmap);
} }
- public void a(Path path) throws IOException { @@ -1432,6 +1655,11 @@
+ public void a(java.nio.file.Path java_nio_file_path) throws IOException {
PlayerChunkMap playerchunkmap = this.getChunkProvider().playerChunkMap;
- BufferedWriter bufferedwriter = Files.newBufferedWriter(path.resolve("stats.txt"));
+ BufferedWriter bufferedwriter = Files.newBufferedWriter(java_nio_file_path.resolve("stats.txt"));
Throwable throwable = null;
try {
@@ -1432,7 +1660,7 @@
CrashReport crashreport = new CrashReport("Level dump", new Exception("dummy"));
this.a(crashreport);
- BufferedWriter bufferedwriter1 = Files.newBufferedWriter(path.resolve("example_crash.txt"));
+ BufferedWriter bufferedwriter1 = Files.newBufferedWriter(java_nio_file_path.resolve("example_crash.txt"));
Throwable throwable3 = null;
try {
@@ -1455,8 +1683,8 @@
}
- Path path1 = path.resolve("chunks.csv");
- BufferedWriter bufferedwriter2 = Files.newBufferedWriter(path1);
+ java.nio.file.Path java_nio_file_path1 = java_nio_file_path.resolve("chunks.csv");
+ BufferedWriter bufferedwriter2 = Files.newBufferedWriter(java_nio_file_path1);
Throwable throwable6 = null;
try {
@@ -1479,8 +1707,8 @@
}
- Path path2 = path.resolve("entities.csv");
- BufferedWriter bufferedwriter3 = Files.newBufferedWriter(path2);
+ java.nio.file.Path java_nio_file_path2 = java_nio_file_path.resolve("entities.csv");
+ BufferedWriter bufferedwriter3 = Files.newBufferedWriter(java_nio_file_path2);
Throwable throwable9 = null;
try {
@@ -1503,8 +1731,8 @@
}
- Path path3 = path.resolve("block_entities.csv");
- BufferedWriter bufferedwriter4 = Files.newBufferedWriter(path3);
+ java.nio.file.Path java_nio_file_path3 = java_nio_file_path.resolve("block_entities.csv");
+ BufferedWriter bufferedwriter4 = Files.newBufferedWriter(java_nio_file_path3);
Throwable throwable12 = null;
try {
@@ -1566,6 +1794,11 @@
@Override @Override
public void update(BlockPosition blockposition, Block block) { public void update(BlockPosition blockposition, Block block) {
if (!this.isDebugWorld()) { if (!this.isDebugWorld()) {
@ -662,53 +571,40 @@
this.applyPhysics(blockposition, block); this.applyPhysics(blockposition, block);
} }
@@ -1580,12 +1813,12 @@ @@ -1451,12 +1679,12 @@
} }
public boolean isFlatWorld() { public boolean isFlatWorld() {
- return this.server.getSaveData().getGeneratorSettings().isFlatWorld(); - return this.server.getSaveData().getGeneratorSettings().isFlatWorld();
+ return this.worldDataServer.getGeneratorSettings().isFlatWorld(); // CraftBukkit + return this.serverLevelData.getGeneratorSettings().isFlatWorld(); // CraftBukkit
} }
@Override @Override
public long getSeed() { public long getSeed() {
- return this.server.getSaveData().getGeneratorSettings().getSeed(); - return this.server.getSaveData().getGeneratorSettings().getSeed();
+ return this.worldDataServer.getGeneratorSettings().getSeed(); // CraftBukkit + return this.serverLevelData.getGeneratorSettings().getSeed(); // CraftBukkit
} }
@Nullable @Nullable
@@ -1605,9 +1838,9 @@ @@ -1484,7 +1712,7 @@
private static <T> String a(Iterable<T> iterable, Function<T, String> function) {
@VisibleForTesting
public String F() {
- return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a((Collection) this.entitiesById.values(), (entity) -> {
+ return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a(this.entitiesById.values(), (entity) -> { // CraftBukkit - decompile error
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType());
- }), this.tileEntityListTick.size(), a((Collection) this.tileEntityListTick, (tileentity) -> {
+ }), this.tileEntityListTick.size(), a(this.tileEntityListTick, (tileentity) -> { // CraftBukkit - decompile error
return IRegistry.BLOCK_ENTITY_TYPE.getKey(tileentity.getTileType());
}), this.getBlockTickList().a(), this.getFluidTickList().a(), this.P());
}
@@ -1615,7 +1848,7 @@
private static <T> String a(Collection<T> collection, Function<T, MinecraftKey> function) {
try { try {
Object2IntOpenHashMap<MinecraftKey> object2intopenhashmap = new Object2IntOpenHashMap(); Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
- Iterator iterator = collection.iterator(); - Iterator iterator = iterable.iterator();
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error + Iterator<T> iterator = iterable.iterator(); // CraftBukkit - decompile error
while (iterator.hasNext()) { while (iterator.hasNext()) {
T t0 = iterator.next(); T t0 = iterator.next();
@@ -1624,7 +1857,8 @@ @@ -1493,7 +1721,7 @@
object2intopenhashmap.addTo(minecraftkey, 1); object2intopenhashmap.addTo(s, 1);
} }
- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> { - return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry::getIntValue).reversed()).limit(5L).map((entry) -> {
+ // CraftBukkit - decompile error + return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry<String>::getIntValue).reversed()).limit(5L).map((entry) -> { // CraftBukkit - decompile error
+ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<MinecraftKey>::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> { String s1 = (String) entry.getKey();
return it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey() + ":" + it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue();
}).collect(Collectors.joining(",")); return s1 + ":" + entry.getIntValue();
} catch (Exception exception) { @@ -1504,17 +1732,33 @@
@@ -1633,16 +1867,32 @@
} }
public static void a(WorldServer worldserver) { public static void a(WorldServer worldserver) {
@ -718,7 +614,7 @@
+ +
+ public static void a(WorldServer worldserver, Entity entity) { + public static void a(WorldServer worldserver, Entity entity) {
+ // CraftBukkit end + // CraftBukkit end
BlockPosition blockposition = WorldServer.a; BlockPosition blockposition = WorldServer.END_SPAWN_POINT;
int i = blockposition.getX(); int i = blockposition.getX();
int j = blockposition.getY() - 2; int j = blockposition.getY() - 2;
int k = blockposition.getZ(); int k = blockposition.getZ();
@ -742,4 +638,21 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
@Override
@@ -1601,6 +1845,7 @@
}
}
+ entity.valid = true; // CraftBukkit
}
public void a(Entity entity) {
@@ -1633,6 +1878,7 @@
gameeventlistenerregistrar.a(entity.level);
}
+ entity.valid = false; // CraftBukkit
}
}
} }

Datei anzeigen

@ -15,25 +15,25 @@
+ private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>(); + private static final HashMap<InetAddress, Long> throttleTracker = new HashMap<InetAddress, Long>();
+ private static int throttleCounter = 0; + private static int throttleCounter = 0;
+ // CraftBukkit end + // CraftBukkit end
private static final IChatBaseComponent a = new ChatComponentText("Ignoring status request"); private static final IChatBaseComponent IGNORE_STATUS_REASON = new ChatComponentText("Ignoring status request");
private final MinecraftServer b; private final MinecraftServer server;
private final NetworkManager c; private final NetworkManager connection;
@@ -27,6 +36,40 @@ @@ -27,6 +36,40 @@
switch (packethandshakinginsetprotocol.b()) { switch (packethandshakinginsetprotocol.b()) {
case LOGIN: case LOGIN:
this.c.setProtocol(EnumProtocol.LOGIN); this.connection.setProtocol(EnumProtocol.LOGIN);
+ // CraftBukkit start - Connection throttle + // CraftBukkit start - Connection throttle
+ try { + try {
+ long currentTime = System.currentTimeMillis(); + long currentTime = System.currentTimeMillis();
+ long connectionThrottle = this.b.server.getConnectionThrottle(); + long connectionThrottle = this.server.server.getConnectionThrottle();
+ InetAddress address = ((java.net.InetSocketAddress) this.c.getSocketAddress()).getAddress(); + InetAddress address = ((java.net.InetSocketAddress) this.connection.getSocketAddress()).getAddress();
+ +
+ synchronized (throttleTracker) { + synchronized (throttleTracker) {
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { + if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
+ throttleTracker.put(address, currentTime); + throttleTracker.put(address, currentTime);
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting."); + ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
+ this.c.sendPacket(new PacketLoginOutDisconnect(chatmessage)); + this.connection.sendPacket(new PacketLoginOutDisconnect(chatmessage));
+ this.c.close(chatmessage); + this.connection.close(chatmessage);
+ return; + return;
+ } + }
+ +
@ -60,10 +60,10 @@
ChatMessage chatmessage; ChatMessage chatmessage;
@@ -40,6 +83,7 @@ @@ -40,6 +83,7 @@
this.c.close(chatmessage); this.connection.close(chatmessage);
} else { } else {
this.c.setPacketListener(new LoginListener(this.b, this.c)); this.connection.setPacketListener(new LoginListener(this.server, this.connection));
+ ((LoginListener) this.c.j()).hostname = packethandshakinginsetprotocol.hostname + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname + ((LoginListener) this.connection.j()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
} }
break; break;
case STATUS: case STATUS:

Datei anzeigen

@ -1,7 +1,7 @@
--- a/net/minecraft/server/network/LegacyPingHandler.java --- a/net/minecraft/server/network/LegacyPingHandler.java
+++ b/net/minecraft/server/network/LegacyPingHandler.java +++ b/net/minecraft/server/network/LegacyPingHandler.java
@@ -35,11 +35,12 @@ @@ -36,11 +36,12 @@
MinecraftServer minecraftserver = this.b.d(); MinecraftServer minecraftserver = this.serverConnectionListener.d();
int i = bytebuf.readableBytes(); int i = bytebuf.readableBytes();
String s; String s;
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit + org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
@ -14,7 +14,7 @@
this.a(channelhandlercontext, this.a(s)); this.a(channelhandlercontext, this.a(s));
break; break;
case 1: case 1:
@@ -48,7 +49,7 @@ @@ -49,7 +50,7 @@
} }
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
@ -23,7 +23,7 @@
this.a(channelhandlercontext, this.a(s)); this.a(channelhandlercontext, this.a(s));
break; break;
default: default:
@@ -67,7 +68,7 @@ @@ -68,7 +69,7 @@
} }
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort()); LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/LoginListener.java --- a/net/minecraft/server/network/LoginListener.java
+++ b/net/minecraft/server/network/LoginListener.java +++ b/net/minecraft/server/network/LoginListener.java
@@ -35,6 +35,13 @@ @@ -36,6 +36,13 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -13,16 +13,16 @@
+ +
public class LoginListener implements PacketLoginInListener { public class LoginListener implements PacketLoginInListener {
private static final AtomicInteger b = new AtomicInteger(0); private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
@@ -49,6 +56,7 @@ @@ -52,6 +59,7 @@
private final String j; private final String serverId;
private SecretKey loginKey; @Nullable
private EntityPlayer l; private EntityPlayer delayedAcceptPlayer;
+ public String hostname = ""; // CraftBukkit - add field + public String hostname = ""; // CraftBukkit - add field
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) { public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.g = LoginListener.EnumProtocolState.HELLO; this.state = LoginListener.EnumProtocolState.HELLO;
@@ -77,6 +85,20 @@ @@ -80,6 +88,20 @@
} }
@ -32,8 +32,8 @@
+ try { + try {
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s); + IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s); + LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s);
+ this.networkManager.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent)); + this.connection.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
+ this.networkManager.close(ichatbasecomponent); + this.connection.close(ichatbasecomponent);
+ } catch (Exception exception) { + } catch (Exception exception) {
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception); + LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
+ } + }
@ -42,14 +42,14 @@
+ +
@Override @Override
public NetworkManager a() { public NetworkManager a() {
return this.networkManager; return this.connection;
@@ -98,10 +120,12 @@ @@ -101,10 +123,12 @@
this.i = this.a(this.i); this.gameProfile = this.a(this.gameProfile);
} }
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.networkManager.getSocketAddress(), this.i); - IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.connection.getSocketAddress(), this.gameProfile);
+ // CraftBukkit start - fire PlayerLoginEvent + // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname); + EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.gameProfile, hostname);
- if (ichatbasecomponent != null) { - if (ichatbasecomponent != null) {
- this.disconnect(ichatbasecomponent); - this.disconnect(ichatbasecomponent);
@ -57,32 +57,29 @@
+ // this.disconnect(ichatbasecomponent); + // this.disconnect(ichatbasecomponent);
+ // CraftBukkit end + // CraftBukkit end
} else { } else {
this.g = LoginListener.EnumProtocolState.ACCEPTED; this.state = LoginListener.EnumProtocolState.ACCEPTED;
if (this.server.ax() >= 0 && !this.networkManager.isLocal()) { if (this.server.aw() >= 0 && !this.connection.isLocal()) {
@@ -115,9 +139,9 @@ @@ -117,7 +141,7 @@
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
if (entityplayer != null) { try {
this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; - EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile);
- this.l = this.server.getPlayerList().processLogin(this.i); + EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile, s); // CraftBukkit - add player reference
+ this.l = this.server.getPlayerList().processLogin(this.i, s); // CraftBukkit - add player reference
} else {
- this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i));
+ this.server.getPlayerList().a(this.networkManager, this.server.getPlayerList().processLogin(this.i, s)); // CraftBukkit - add player reference
}
}
@@ -175,6 +199,43 @@ if (entityplayer != null) {
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -191,6 +215,43 @@
try { try {
LoginListener.this.i = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a()); LoginListener.this.gameProfile = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
if (LoginListener.this.i != null) { if (LoginListener.this.gameProfile != null) {
+ // CraftBukkit start - fire PlayerPreLoginEvent + // CraftBukkit start - fire PlayerPreLoginEvent
+ if (!networkManager.isConnected()) { + if (!connection.isConnected()) {
+ return; + return;
+ } + }
+ +
+ String playerName = i.getName(); + String playerName = gameProfile.getName();
+ java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress(); + java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getSocketAddress()).getAddress();
+ java.util.UUID uniqueId = i.getId(); + java.util.UUID uniqueId = gameProfile.getId();
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server; + final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
+ +
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
@ -112,10 +109,10 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.i.getName(), LoginListener.this.i.getId()); LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT; LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
} else if (LoginListener.this.server.isEmbeddedServer()) { } else if (LoginListener.this.server.isEmbeddedServer()) {
@@ -194,6 +255,11 @@ @@ -210,6 +271,11 @@
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down")); LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable"); LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
} }

Datei anzeigen

@ -18,21 +18,21 @@
+ +
public class PacketStatusListener implements PacketStatusInListener { public class PacketStatusListener implements PacketStatusInListener {
private static final IChatBaseComponent a = new ChatMessage("multiplayer.status.request_handled"); private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled");
@@ -36,8 +48,96 @@ @@ -36,8 +48,96 @@
this.networkManager.close(PacketStatusListener.a); this.connection.close(PacketStatusListener.DISCONNECT_REASON);
} else { } else {
this.d = true; this.hasRequestedStatus = true;
- this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); - this.connection.sendPacket(new PacketStatusOutServerInfo(this.server.getServerPing()));
+ // CraftBukkit start + // CraftBukkit start
+ // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); + // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
+ final Object[] players = minecraftServer.getPlayerList().players.toArray(); + final Object[] players = server.getPlayerList().players.toArray();
+ class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { + class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent {
+ +
+ CraftIconCache icon = minecraftServer.server.getServerIcon(); + CraftIconCache icon = server.server.getServerIcon();
+ +
+ ServerListPingEvent() { + ServerListPingEvent() {
+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.getMotd(), minecraftServer.getPlayerList().getMaxPlayers()); + super(((InetSocketAddress) connection.getSocketAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers());
+ } + }
+ +
+ @Override + @Override
@ -92,7 +92,7 @@
+ } + }
+ +
+ ServerListPingEvent event = new ServerListPingEvent(); + ServerListPingEvent event = new ServerListPingEvent();
+ this.minecraftServer.server.getPluginManager().callEvent(event); + this.server.server.getPluginManager().callEvent(event);
+ +
+ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length); + java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
+ for (Object player : players) { + for (Object player : players) {
@ -109,9 +109,9 @@
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); + ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]);
+ ping.setPlayerSample(playerSample); + ping.setPlayerSample(playerSample);
+ int version = SharedConstants.getGameVersion().getProtocolVersion(); + int version = SharedConstants.getGameVersion().getProtocolVersion();
+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); + ping.setServerInfo(new ServerPing.ServerData(server.getServerModName() + " " + server.getVersion(), version));
+ +
+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); + this.connection.sendPacket(new PacketStatusOutServerInfo(ping));
} }
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -1,13 +1,13 @@
--- a/net/minecraft/server/network/ServerConnection.java --- a/net/minecraft/server/network/ServerConnection.java
+++ b/net/minecraft/server/network/ServerConnection.java +++ b/net/minecraft/server/network/ServerConnection.java
@@ -87,14 +87,24 @@ @@ -96,14 +96,24 @@
int j = ServerConnection.this.e.k(); int j = ServerConnection.this.server.l();
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
- ServerConnection.this.connectedChannels.add(object); - ServerConnection.this.connections.add(object);
+ ServerConnection.this.connectedChannels.add((NetworkManager) object); // CraftBukkit - decompile error + ServerConnection.this.connections.add((NetworkManager) object); // CraftBukkit - decompile error
channel.pipeline().addLast("packet_handler", (ChannelHandler) object); channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object)); ((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
} }
- }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly()); - }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
+ }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit + }).group((EventLoopGroup) lazyinitvar.a()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
@ -16,14 +16,14 @@
+ // CraftBukkit start + // CraftBukkit start
+ public void acceptConnections() { + public void acceptConnections() {
+ synchronized (this.listeningChannels) { + synchronized (this.channels) {
+ for (ChannelFuture future : this.listeningChannels) { + for (ChannelFuture future : this.channels) {
+ future.channel().config().setAutoRead(true); + future.channel().config().setAutoRead(true);
+ } + }
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public void b() { public SocketAddress a() {
this.c = false; List list = this.channels;
Iterator iterator = this.listeningChannels.iterator(); ChannelFuture channelfuture;

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/ExpirableListEntry.java --- a/net/minecraft/server/players/ExpirableListEntry.java
+++ b/net/minecraft/server/players/ExpirableListEntry.java +++ b/net/minecraft/server/players/ExpirableListEntry.java
@@ -24,7 +24,7 @@ @@ -25,7 +25,7 @@
} }
protected ExpirableListEntry(T t0, JsonObject jsonobject) { protected ExpirableListEntry(T t0, JsonObject jsonobject) {
@ -9,21 +9,17 @@
Date date; Date date;
@@ -75,4 +75,26 @@ @@ -80,4 +80,22 @@
jsonobject.addProperty("expires", this.d == null ? "forever" : ExpirableListEntry.a.format(this.d)); jsonobject.addProperty("expires", this.expires == null ? "forever" : ExpirableListEntry.DATE_FORMAT.format(this.expires));
jsonobject.addProperty("reason", this.e); jsonobject.addProperty("reason", this.reason);
} }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ public Date getCreated() {
+ return this.b;
+ }
+
+ private static <T> T checkExpiry(T object, JsonObject jsonobject) { + private static <T> T checkExpiry(T object, JsonObject jsonobject) {
+ Date expires = null; + Date expires = null;
+ +
+ try { + try {
+ expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null; + expires = jsonobject.has("expires") ? DATE_FORMAT.parse(jsonobject.get("expires").getAsString()) : null;
+ } catch (ParseException ex) { + } catch (ParseException ex) {
+ // Guess we don't have a date + // Guess we don't have a date
+ } + }

Datei anzeigen

@ -1,29 +1,29 @@
--- a/net/minecraft/server/players/JsonList.java --- a/net/minecraft/server/players/JsonList.java
+++ b/net/minecraft/server/players/JsonList.java +++ b/net/minecraft/server/players/JsonList.java
@@ -52,7 +52,7 @@ @@ -54,7 +54,7 @@
@Nullable @Nullable
public V get(K k0) { public V get(K k0) {
this.g(); this.g();
- return (JsonListEntry) this.d.get(this.a(k0)); - return (JsonListEntry) this.map.get(this.a(k0));
+ return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error + return (V) this.map.get(this.a(k0)); // CraftBukkit - fix decompile error
} }
public void remove(K k0) { public void remove(K k0) {
@@ -74,6 +74,12 @@ @@ -76,6 +76,12 @@
return (String[]) this.d.keySet().toArray(new String[this.d.size()]); return (String[]) this.map.keySet().toArray(new String[0]);
} }
+ // CraftBukkit start + // CraftBukkit start
+ public Collection<V> getValues() { + public Collection<V> getValues() {
+ return this.d.values(); + return this.map.values();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public boolean isEmpty() { public boolean isEmpty() {
return this.d.size() < 1; return this.map.size() < 1;
} }
@@ -91,7 +97,7 @@ @@ -93,7 +99,7 @@
Iterator iterator = this.d.values().iterator(); Iterator iterator = this.map.values().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
- V v0 = (JsonListEntry) iterator.next(); - V v0 = (JsonListEntry) iterator.next();
@ -31,30 +31,35 @@
if (v0.hasExpired()) { if (v0.hasExpired()) {
list.add(v0.getKey()); list.add(v0.getKey());
@@ -101,7 +107,7 @@ @@ -103,7 +109,7 @@
iterator = list.iterator(); iterator = list.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
- K k0 = iterator.next(); - K k0 = iterator.next();
+ K k0 = (K) iterator.next(); // CraftBukkit - decompile error + K k0 = (K) iterator.next(); // CraftBukkit - decompile error
this.d.remove(this.a(k0)); this.map.remove(this.a(k0));
} }
@@ -121,7 +127,7 @@ @@ -118,11 +124,11 @@
public void save() throws IOException {
JsonArray jsonarray = new JsonArray();
- Stream stream = this.map.values().stream().map((jsonlistentry) -> {
+ Stream<JsonObject> stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error
JsonObject jsonobject = new JsonObject(); JsonObject jsonobject = new JsonObject();
jsonlistentry.getClass(); Objects.requireNonNull(jsonlistentry);
- return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a); - return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a);
+ return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error + return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error
}).forEach(jsonarray::add); });
BufferedWriter bufferedwriter = Files.newWriter(this.c, StandardCharsets.UTF_8);
Throwable throwable = null; Objects.requireNonNull(jsonarray);
@@ -165,7 +171,7 @@ @@ -165,7 +171,7 @@
JsonListEntry<K> jsonlistentry = this.a(jsonobject); JsonListEntry<K> jsonlistentry = this.a(jsonobject);
if (jsonlistentry.getKey() != null) { if (jsonlistentry.getKey() != null) {
- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); - this.map.put(this.a(jsonlistentry.getKey()), jsonlistentry);
+ this.d.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error + this.map.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error
} }
} }
} catch (Throwable throwable1) { } catch (Throwable throwable) {

Datei anzeigen

@ -11,8 +11,8 @@
+ +
public class NameReferencingFileConverter { public class NameReferencingFileConverter {
private static final Logger LOGGER = LogManager.getLogger(); static final Logger LOGGER = LogManager.getLogger();
@@ -85,7 +90,7 @@ @@ -87,7 +92,7 @@
try { try {
gameprofilebanlist.load(); gameprofilebanlist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -21,7 +21,7 @@
} }
} }
@@ -143,7 +148,7 @@ @@ -145,7 +150,7 @@
try { try {
ipbanlist.load(); ipbanlist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -30,7 +30,7 @@
} }
} }
@@ -184,7 +189,7 @@ @@ -186,7 +191,7 @@
try { try {
oplist.load(); oplist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -39,7 +39,7 @@
} }
} }
@@ -228,7 +233,7 @@ @@ -230,7 +235,7 @@
try { try {
whitelist.load(); whitelist.load();
} catch (IOException ioexception) { } catch (IOException ioexception) {
@ -48,7 +48,7 @@
} }
} }
@@ -351,6 +356,30 @@ @@ -353,6 +358,30 @@
File file5 = new File(file, s2 + ".dat"); File file5 = new File(file, s2 + ".dat");
File file6 = new File(file4, s3 + ".dat"); File file6 = new File(file4, s3 + ".dat");
@ -76,6 +76,6 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
NameReferencingFileConverter.b(file4); NameReferencingFileConverter.a(file4);
if (!file5.renameTo(file6)) { if (!file5.renameTo(file6)) {
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2); throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);

Datei anzeigen

@ -1,21 +1,19 @@
--- a/net/minecraft/server/players/PlayerList.java --- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java
@@ -90,6 +90,27 @@ @@ -93,6 +93,25 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
+// CraftBukkit start +// CraftBukkit start
+import com.google.common.base.Predicate; +import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables; +import java.util.stream.Collectors;
+ +import net.minecraft.network.protocol.game.PacketPlayOutChat;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; +import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.dedicated.DedicatedServer;
+import net.minecraft.server.network.LoginListener; +import net.minecraft.server.network.LoginListener;
+ +import org.bukkit.Location;
+import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.CraftWorld;
+
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftChatMessage; +import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.entity.Player; +import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent;
@ -27,30 +25,30 @@
+ +
public abstract class PlayerList { public abstract class PlayerList {
public static final File b = new File("banned-players.json"); public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -99,14 +120,16 @@ @@ -103,14 +122,16 @@
private static final Logger LOGGER = LogManager.getLogger(); private static final int SEND_PLAYER_INFO_INTERVAL = 600;
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z"); private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server; private final MinecraftServer server;
- public final List<EntityPlayer> players = Lists.newArrayList(); - public final List<EntityPlayer> players = Lists.newArrayList();
+ public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety + public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
private final Map<UUID, EntityPlayer> j = Maps.newHashMap(); private final Map<UUID, EntityPlayer> playersByUUID = Maps.newHashMap();
private final GameProfileBanList k; private final GameProfileBanList bans;
private final IpBanList l; private final IpBanList ipBans;
private final OpList operators; private final OpList ops;
private final WhiteList whitelist; private final WhiteList whitelist;
- private final Map<UUID, ServerStatisticManager> o; - private final Map<UUID, ServerStatisticManager> stats;
- private final Map<UUID, AdvancementDataPlayer> p; - private final Map<UUID, AdvancementDataPlayer> advancements;
+ // CraftBukkit start + // CraftBukkit start
+ // private final Map<UUID, ServerStatisticManager> o; + // private final Map<UUID, ServerStatisticManager> o;
+ // private final Map<UUID, AdvancementDataPlayer> p; + // private final Map<UUID, AdvancementDataPlayer> p;
+ // CraftBukkit end + // CraftBukkit end
public final WorldNBTStorage playerFileData; public final WorldNBTStorage playerIo;
private boolean hasWhitelist; private boolean doWhiteList;
private final IRegistryCustom.Dimension s; private final IRegistryCustom.Dimension registryHolder;
@@ -116,13 +139,23 @@ @@ -120,13 +141,23 @@
private boolean v; private static final boolean ALLOW_LOGOUTIVATOR = false;
private int w; private int sendAllPlayerInfoIn;
+ // CraftBukkit start + // CraftBukkit start
+ private CraftServer cserver; + private CraftServer cserver;
@ -61,20 +59,20 @@
+ minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server)); + minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server));
+ // CraftBukkit end + // CraftBukkit end
+ +
this.k = new GameProfileBanList(PlayerList.b); this.bans = new GameProfileBanList(PlayerList.USERBANLIST_FILE);
this.l = new IpBanList(PlayerList.c); this.ipBans = new IpBanList(PlayerList.IPBANLIST_FILE);
this.operators = new OpList(PlayerList.d); this.ops = new OpList(PlayerList.OPLIST_FILE);
this.whitelist = new WhiteList(PlayerList.e); this.whitelist = new WhiteList(PlayerList.WHITELIST_FILE);
- this.o = Maps.newHashMap(); - this.stats = Maps.newHashMap();
- this.p = Maps.newHashMap(); - this.advancements = Maps.newHashMap();
+ // CraftBukkit start + // CraftBukkit start
+ // this.o = Maps.newHashMap(); + // this.o = Maps.newHashMap();
+ // this.p = Maps.newHashMap(); + // this.p = Maps.newHashMap();
+ // CraftBukkit end + // CraftBukkit end
this.server = minecraftserver; this.server = minecraftserver;
this.s = iregistrycustom_dimension; this.registryHolder = iregistrycustom_dimension;
this.maxPlayers = i; this.maxPlayers = i;
@@ -138,6 +171,12 @@ @@ -142,6 +173,12 @@
usercache.a(gameprofile); usercache.a(gameprofile);
NBTTagCompound nbttagcompound = this.a(entityplayer); NBTTagCompound nbttagcompound = this.a(entityplayer);
ResourceKey resourcekey; ResourceKey resourcekey;
@ -86,8 +84,8 @@
+ // CraftBukkit end + // CraftBukkit end
if (nbttagcompound != null) { if (nbttagcompound != null) {
DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("Dimension"))); DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension")));
@@ -168,7 +207,8 @@ @@ -171,7 +208,8 @@
s1 = networkmanager.getSocketAddress().toString(); s1 = networkmanager.getSocketAddress().toString();
} }
@ -96,16 +94,16 @@
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); + // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
WorldData worlddata = worldserver1.getWorldData(); WorldData worlddata = worldserver1.getWorldData();
this.a(entityplayer, (EntityPlayer) null, worldserver1); entityplayer.c(nbttagcompound);
@@ -178,6 +218,7 @@ @@ -181,6 +219,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO); boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.s, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.gameMode.getGameMode(), entityplayer.gameMode.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.G(), this.registryHolder, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld()));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit + entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName()))); playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.getAbilities()));
@@ -196,19 +237,61 @@ @@ -199,19 +238,61 @@
} else { } else {
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s}); chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s});
} }
@ -113,10 +111,10 @@
+ chatmessage.a(EnumChatFormat.YELLOW); + chatmessage.a(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage); + String joinMessage = CraftChatMessage.fromComponent(chatmessage);
- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b); - this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch); playerconnection.b(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.getYRot(), entityplayer.getXRot());
this.players.add(entityplayer); this.players.add(entityplayer);
this.j.put(entityplayer.getUniqueID(), entityplayer); this.playersByUUID.put(entityplayer.getUniqueID(), entityplayer);
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); - this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer}));
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below + // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below
+ +
@ -124,7 +122,7 @@
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage); + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
+ cserver.getPluginManager().callEvent(playerJoinEvent); + cserver.getPluginManager().callEvent(playerJoinEvent);
+ +
+ if (!entityplayer.playerConnection.networkManager.isConnected()) { + if (!entityplayer.connection.connection.isConnected()) {
+ return; + return;
+ } + }
+ +
@ -132,7 +130,7 @@
+ +
+ if (joinMessage != null && joinMessage.length() > 0) { + if (joinMessage != null && joinMessage.length() > 0) {
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { + for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
+ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b)); + server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -141,26 +139,26 @@
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer);
for (int i = 0; i < this.players.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)})); - entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)}));
+ EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i); + EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
+ +
+ if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer1.playerConnection.sendPacket(packet); + entityplayer1.connection.sendPacket(packet);
+ } + }
+ +
+ if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) { + if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
+ continue; + continue;
+ } + }
+ +
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1})); + entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
+ } + }
+ entityplayer.sentListPacket = true; + entityplayer.sentListPacket = true;
+ // CraftBukkit end + // CraftBukkit end
+ +
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn + entityplayer.connection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
+ +
+ // CraftBukkit start - Only add if the player wasn't moved in the event + // CraftBukkit start - Only add if the player wasn't moved in the event
+ if (entityplayer.world == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) { + if (entityplayer.level == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) {
+ worldserver1.addPlayerJoin(entityplayer); + worldserver1.addPlayerJoin(entityplayer);
+ this.server.getBossBattleCustomData().a(entityplayer); + this.server.getBossBattleCustomData().a(entityplayer);
} }
@ -171,8 +169,8 @@
+ // CraftBukkit end + // CraftBukkit end
this.a(entityplayer, worldserver1); this.a(entityplayer, worldserver1);
if (!this.server.getResourcePack().isEmpty()) { if (!this.server.getResourcePack().isEmpty()) {
entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash()); entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.aY(), this.server.bb());
@@ -224,8 +307,11 @@ @@ -227,8 +308,11 @@
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) { if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle"); NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@ -186,71 +184,71 @@
}); });
if (entity != null) { if (entity != null) {
@@ -268,6 +354,8 @@ @@ -271,6 +355,8 @@
} }
entityplayer.syncInventory(); entityplayer.syncInventory();
+ // CraftBukkit - Moved from above, added world + // CraftBukkit - Moved from above, added world
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.worldDataServer.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ()); + PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
} }
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -300,30 +388,31 @@ @@ -303,30 +389,31 @@
} }
public void setPlayerFileData(WorldServer worldserver) { public void setPlayerFileData(WorldServer worldserver) {
+ if (playerFileData != null) return; // CraftBukkit + if (playerIo != null) return; // CraftBukkit
worldserver.getWorldBorder().a(new IWorldBorderListener() { worldserver.getWorldBorder().a(new IWorldBorderListener() {
@Override @Override
public void a(WorldBorder worldborder, double d0) { public void a(WorldBorder worldborder, double d0) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE)); - PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world); + PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit
} }
@Override @Override
public void a(WorldBorder worldborder, double d0, double d1, long i) { public void a(WorldBorder worldborder, double d0, double d1, long i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE)); - PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world); + PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit
} }
@Override @Override
public void a(WorldBorder worldborder, double d0, double d1) { public void a(WorldBorder worldborder, double d0, double d1) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER)); - PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world); + PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit
} }
@Override @Override
public void a(WorldBorder worldborder, int i) { public void a(WorldBorder worldborder, int i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME)); - PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world); + PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit
} }
@Override @Override
public void b(WorldBorder worldborder, int i) { public void b(WorldBorder worldborder, int i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS)); - PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world); + PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit
} }
@Override @Override
@@ -351,14 +440,15 @@ @@ -354,14 +441,15 @@
} }
protected void savePlayerFile(EntityPlayer entityplayer) { protected void savePlayerFile(EntityPlayer entityplayer) {
+ if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit + if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
this.playerFileData.save(entityplayer); this.playerIo.save(entityplayer);
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.o.get(entityplayer.getUniqueID()); - ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUniqueID());
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit + ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
if (serverstatisticmanager != null) { if (serverstatisticmanager != null) {
serverstatisticmanager.save(); serverstatisticmanager.save();
} }
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID()); - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUniqueID());
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
if (advancementdataplayer != null) { if (advancementdataplayer != null) {
advancementdataplayer.b(); advancementdataplayer.b();
@@ -366,10 +456,24 @@ @@ -369,10 +457,24 @@
} }
@ -262,7 +260,7 @@
+ +
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it + // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
+ // See SPIGOT-5799, SPIGOT-6145 + // See SPIGOT-5799, SPIGOT-6145
+ if (entityplayer.activeContainer != entityplayer.defaultContainer) { + if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
+ entityplayer.closeInventory(); + entityplayer.closeInventory();
+ } + }
+ +
@ -276,19 +274,18 @@
this.savePlayerFile(entityplayer); this.savePlayerFile(entityplayer);
if (entityplayer.isPassenger()) { if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle(); Entity entity = entityplayer.getRootVehicle();
@@ -401,18 +505,66 @@ @@ -396,18 +498,66 @@
if (entityplayer1 == entityplayer) { if (entityplayer1 == entityplayer) {
this.j.remove(uuid); this.playersByUUID.remove(uuid);
- this.o.remove(uuid); - this.stats.remove(uuid);
- this.p.remove(uuid); - this.advancements.remove(uuid);
+ // CraftBukkit start + // CraftBukkit start
+ // this.o.remove(uuid); + // this.o.remove(uuid);
+ // this.p.remove(uuid); + // this.p.remove(uuid);
+ // CraftBukkit end + // CraftBukkit end
} + }
+
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
+ // CraftBukkit start + // CraftBukkit start
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer})); + // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer); + PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer);
@ -296,15 +293,16 @@
+ EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i); + EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i);
+ +
+ if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer2.playerConnection.sendPacket(packet); + entityplayer2.connection.sendPacket(packet);
+ } else { + } else {
+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity());
+ } + }
+ } }
+ // This removes the scoreboard (and player reference) for the specific player in the manager + // This removes the scoreboard (and player reference) for the specific player in the manager
+ cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
+ // CraftBukkit end + // CraftBukkit end
+
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit + return playerQuitEvent.getQuitMessage(); // CraftBukkit
} }
@ -314,7 +312,7 @@
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { + public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
ChatMessage chatmessage; ChatMessage chatmessage;
- if (this.k.isBanned(gameprofile)) { - if (this.bans.isBanned(gameprofile)) {
+ // Moved from processLogin + // Moved from processLogin
+ UUID uuid = EntityHuman.a(gameprofile); + UUID uuid = EntityHuman.a(gameprofile);
+ List<EntityPlayer> list = Lists.newArrayList(); + List<EntityPlayer> list = Lists.newArrayList();
@ -333,24 +331,24 @@
+ while (iterator.hasNext()) { + while (iterator.hasNext()) {
+ entityplayer = (EntityPlayer) iterator.next(); + entityplayer = (EntityPlayer) iterator.next();
+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved + savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
+ entityplayer.playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0])); + entityplayer.connection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
+ } + }
+ +
+ // Instead of kicking then returning, we need to store the kick reason + // Instead of kicking then returning, we need to store the kick reason
+ // in the event, check with plugins to see if it's ok, and THEN kick + // in the event, check with plugins to see if it's ok, and THEN kick
+ // depending on the outcome. + // depending on the outcome.
+ SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress(); + SocketAddress socketaddress = loginlistener.connection.getSocketAddress();
+ +
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD))); + EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile);
+ Player player = entity.getBukkitEntity(); + Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress()); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+ +
+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) { + if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile); GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()}); chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
@@ -420,10 +572,12 @@ @@ -415,10 +565,12 @@
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())})); chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())}));
} }
- return chatmessage; - return chatmessage;
@ -358,33 +356,33 @@
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else if (!this.isWhitelisted(gameprofile)) { } else if (!this.isWhitelisted(gameprofile)) {
- return new ChatMessage("multiplayer.disconnect.not_whitelisted"); - return new ChatMessage("multiplayer.disconnect.not_whitelisted");
- } else if (this.l.isBanned(socketaddress)) { - } else if (this.ipBans.isBanned(socketaddress)) {
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); + chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage)); + event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
+ } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) { + } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.l.get(socketaddress); IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()}); chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
@@ -431,13 +585,25 @@ @@ -426,13 +578,25 @@
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.g.format(ipbanentry.getExpires())})); chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())}));
} }
- return chatmessage; - return chatmessage;
+ // return chatmessage; + // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else { } else {
- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; - return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null; + // return this.players.size() >= this.maxPlayers && !this.d(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) { + if (this.players.size() >= this.maxPlayers && !this.d(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full"); + event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ } + }
+ } }
+ +
+ cserver.getPluginManager().callEvent(event); + cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) { + if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(event.getKickMessage()); + loginlistener.disconnect(event.getKickMessage());
+ return null; + return null;
} + }
+ return entity; + return entity;
} }
@ -394,10 +392,10 @@
UUID uuid = EntityHuman.a(gameprofile); UUID uuid = EntityHuman.a(gameprofile);
List<EntityPlayer> list = Lists.newArrayList(); List<EntityPlayer> list = Lists.newArrayList();
@@ -473,14 +639,24 @@ @@ -459,14 +623,24 @@
} }
return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object); return new EntityPlayer(this.server, this.server.F(), gameprofile);
+ */ + */
+ return player; + return player;
+ // CraftBukkit end + // CraftBukkit end
@ -411,7 +409,7 @@
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) { + public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) {
+ entityplayer.stopRiding(); // CraftBukkit + entityplayer.stopRiding(); // CraftBukkit
this.players.remove(entityplayer); this.players.remove(entityplayer);
entityplayer.getWorldServer().removePlayer(entityplayer); entityplayer.getWorldServer().a(entityplayer, Entity.RemovalReason.DISCARDED);
BlockPosition blockposition = entityplayer.getSpawn(); BlockPosition blockposition = entityplayer.getSpawn();
float f = entityplayer.getSpawnAngle(); float f = entityplayer.getSpawnAngle();
boolean flag1 = entityplayer.isSpawnForced(); boolean flag1 = entityplayer.isSpawnForced();
@ -419,24 +417,20 @@
WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension()); WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension());
Optional optional; Optional optional;
@@ -500,6 +676,11 @@ @@ -478,6 +652,11 @@
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile(), (PlayerInteractManager) object); WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.F();
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile());
+ // */ + // */
+ EntityPlayer entityplayer1 = entityplayer; + EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld(); + org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
+ entityplayer.viewingCredits = false; + entityplayer.wonGame = false;
+ // CraftBukkit end + // CraftBukkit end
entityplayer1.playerConnection = entityplayer.playerConnection; entityplayer1.connection = entityplayer.connection;
entityplayer1.copyFrom(entityplayer, flag); entityplayer1.copyFrom(entityplayer, flag);
@@ -513,52 +694,113 @@ @@ -493,49 +672,110 @@
entityplayer1.addScoreboardTag(s);
}
- this.a(entityplayer1, entityplayer, worldserver1);
+ // this.a(entityplayer1, entityplayer, worldserver1); // CraftBukkit - removed
boolean flag2 = false; boolean flag2 = false;
- if (optional.isPresent()) { - if (optional.isPresent()) {
@ -472,30 +466,30 @@
+ } else { + } else {
+ Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d(); + Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d();
+ +
+ f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); + f1 = (float) MathHelper.f(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
+ } + }
+
- f1 = (float) MathHelper.g(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); + entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
+ flag2 = !flag && flag3; + flag2 = !flag && flag3;
+ isBedSpawn = true; + isBedSpawn = true;
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); + location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
+ } else if (blockposition != null) { + } else if (blockposition != null) {
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); + entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
+ } + }
+ }
- f1 = (float) MathHelper.f(MathHelper.d(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
+ if (location == null) {
+ worldserver1 = this.server.getWorldServer(World.OVERWORLD);
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
} }
- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F); - entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false); - entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
- flag2 = !flag && flag3; - flag2 = !flag && flag3;
- } else if (blockposition != null) { - } else if (blockposition != null) {
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F)); - entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
+ if (location == null) {
+ worldserver1 = this.server.getWorldServer(World.OVERWORLD);
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
+ }
+
+ Player respawnPlayer = cserver.getPlayer(entityplayer1); + Player respawnPlayer = cserver.getPlayer(entityplayer1);
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2);
+ cserver.getPluginManager().callEvent(respawnEvent); + cserver.getPluginManager().callEvent(respawnEvent);
@ -509,48 +503,48 @@
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ // CraftBukkit end + // CraftBukkit end
- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { - while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) {
+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) { + while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) {
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ()); entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
} }
+ // CraftBukkit start + // CraftBukkit start
+ WorldData worlddata = worldserver1.getWorldData(); + WorldData worlddata = worldserver1.getWorldData();
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag)); + entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag));
+ entityplayer1.spawnIn(worldserver1); + entityplayer1.spawnIn(worldserver1);
+ entityplayer1.dead = false; + entityplayer1.unsetRemoved();
+ entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch)); + entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
+ entityplayer1.setSneaking(false); + entityplayer1.setSneaking(false);
- WorldData worlddata = entityplayer1.world.getWorldData(); - WorldData worlddata = entityplayer1.level.getWorldData();
- -
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getDimensionManager(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag)); - entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(entityplayer1.level.getDimensionManager(), entityplayer1.level.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag));
- entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); - entityplayer1.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
+ // entityplayer1.playerConnection.a(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch); + // entityplayer1.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.v())); entityplayer1.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.x()));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); entityplayer1.connection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); entityplayer1.connection.sendPacket(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
this.a(entityplayer1, worldserver1); this.a(entityplayer1, worldserver1);
this.d(entityplayer1); this.d(entityplayer1);
- worldserver1.addPlayerRespawn(entityplayer1); - worldserver1.addPlayerRespawn(entityplayer1);
- this.players.add(entityplayer1); - this.players.add(entityplayer1);
- this.j.put(entityplayer1.getUniqueID(), entityplayer1); - this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1);
- entityplayer1.syncInventory(); - entityplayer1.syncInventory();
+ if (!entityplayer.playerConnection.isDisconnected()) { + if (!entityplayer.connection.isDisconnected()) {
+ worldserver1.addPlayerRespawn(entityplayer1); + worldserver1.addPlayerRespawn(entityplayer1);
+ this.players.add(entityplayer1); + this.players.add(entityplayer1);
+ this.j.put(entityplayer1.getUniqueID(), entityplayer1); + this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1);
+ } + }
+ // entityplayer1.syncInventory(); + // entityplayer1.syncInventory();
entityplayer1.setHealth(entityplayer1.getHealth()); entityplayer1.setHealth(entityplayer1.getHealth());
if (flag2) { if (flag2) {
entityplayer1.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F)); entityplayer1.connection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
} }
+ // Added from changeDimension + // Added from changeDimension
+ updateClient(entityplayer); // Update health, etc... + updateClient(entityplayer); // Update health, etc...
+ entityplayer.updateAbilities(); + entityplayer.updateAbilities();
+ for (Object o1 : entityplayer.getEffects()) { + for (Object o1 : entityplayer.getEffects()) {
+ MobEffect mobEffect = (MobEffect) o1; + MobEffect mobEffect = (MobEffect) o1;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect)); + entityplayer.connection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
+ } + }
+ +
+ // Fire advancement trigger + // Fire advancement trigger
@ -563,34 +557,34 @@
+ } + }
+ // Save player file again if they were disconnected + // Save player file again if they were disconnected
+ if (entityplayer.playerConnection.isDisconnected()) { + if (entityplayer.connection.isDisconnected()) {
+ this.savePlayerFile(entityplayer); + this.savePlayerFile(entityplayer);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
return entityplayer1; return entityplayer1;
} }
@@ -571,7 +813,18 @@ @@ -548,7 +788,18 @@
public void tick() { public void tick() {
if (++this.w > 600) { if (++this.sendAllPlayerInfoIn > 600) {
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players)); - this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players));
+ // CraftBukkit start + // CraftBukkit start
+ for (int i = 0; i < this.players.size(); ++i) { + for (int i = 0; i < this.players.size(); ++i) {
+ final EntityPlayer target = (EntityPlayer) this.players.get(i); + final EntityPlayer target = (EntityPlayer) this.players.get(i);
+ +
+ target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() { + target.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() {
+ @Override + @Override
+ public boolean apply(EntityPlayer input) { + public boolean apply(EntityPlayer input) {
+ return target.getBukkitEntity().canSee(input.getBukkitEntity()); + return target.getBukkitEntity().canSee(input.getBukkitEntity());
+ } + }
+ }))); + }).collect(Collectors.toList())));
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.w = 0; this.sendAllPlayerInfoIn = 0;
} }
@@ -584,6 +837,25 @@ @@ -565,6 +816,25 @@
} }
@ -601,30 +595,30 @@
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) { + if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
+ continue; + continue;
+ } + }
+ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet); + ((EntityPlayer) this.players.get(i)).connection.sendPacket(packet);
+ } + }
+ } + }
+ +
+ public void sendAll(Packet packet, World world) { + public void sendAll(Packet packet, World world) {
+ for (int i = 0; i < world.getPlayers().size(); ++i) { + for (int i = 0; i < world.getPlayers().size(); ++i) {
+ ((EntityPlayer) world.getPlayers().get(i)).playerConnection.sendPacket(packet); + ((EntityPlayer) world.getPlayers().get(i)).connection.sendPacket(packet);
+ } + }
+ +
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public void a(Packet<?> packet, ResourceKey<World> resourcekey) { public void a(Packet<?> packet, ResourceKey<World> resourcekey) {
for (int i = 0; i < this.players.size(); ++i) { Iterator iterator = this.players.iterator();
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@@ -684,6 +956,7 @@ @@ -667,6 +937,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0)); entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
} }
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit + entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommandDispatcher().a(entityplayer); this.server.getCommandDispatcher().a(entityplayer);
} }
@@ -716,6 +989,12 @@ @@ -699,6 +970,12 @@
for (int i = 0; i < this.players.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i); EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -634,23 +628,23 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) { if (entityplayer != entityhuman && entityplayer.level.getDimensionKey() == resourcekey) {
double d4 = d0 - entityplayer.locX(); double d4 = d0 - entityplayer.locX();
double d5 = d1 - entityplayer.locY(); double d5 = d1 - entityplayer.locY();
@@ -755,23 +1034,34 @@ @@ -738,23 +1015,34 @@
public void reloadWhitelist() {} public void reloadWhitelist() {}
public void a(EntityPlayer entityplayer, WorldServer worldserver) { public void a(EntityPlayer entityplayer, WorldServer worldserver) {
- WorldBorder worldborder = this.server.E().getWorldBorder(); - WorldBorder worldborder = this.server.F().getWorldBorder();
+ WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit + WorldBorder worldborder = entityplayer.level.getWorldBorder(); // CraftBukkit
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE)); entityplayer.connection.sendPacket(new ClientboundInitializeBorderPacket(worldborder));
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE))); entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.v())); entityplayer.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.x()));
if (worldserver.isRaining()) { if (worldserver.isRaining()) {
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); - entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); - entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.d(1.0F)));
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F))); - entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.b(1.0F)));
+ // CraftBukkit start - handle player weather + // CraftBukkit start - handle player weather
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F)); + // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F));
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F))); + // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F)));
@ -663,62 +657,52 @@
} }
public void updateClient(EntityPlayer entityplayer) { public void updateClient(EntityPlayer entityplayer) {
entityplayer.updateInventory(entityplayer.defaultContainer); entityplayer.inventoryMenu.updateInventory();
- entityplayer.triggerHealthUpdate(); - entityplayer.triggerHealthUpdate();
+ // entityplayer.triggerHealthUpdate(); + // entityplayer.triggerHealthUpdate();
+ entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange + entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); entityplayer.connection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
+ // CraftBukkit start - from GameRules + // CraftBukkit start - from GameRules
+ int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23; + int i = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i)); + entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
+ float immediateRespawn = entityplayer.world.getGameRules().getBoolean(GameRules.DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F; + float immediateRespawn = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.l, immediateRespawn)); + entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn));
+ // CraftBukkit end + // CraftBukkit end
} }
public int getPlayerCount() { public int getPlayerCount() {
@@ -824,31 +1114,54 @@ @@ -805,12 +1093,22 @@
entityplayer.playerInteractManager.a(this.u, EnumGamemode.NOT_SET);
}
- entityplayer.playerInteractManager.b(worldserver.getMinecraftServer().getSaveData().getGameType());
+ entityplayer.playerInteractManager.b(worldserver.worldDataServer.getGameType()); // CraftBukkit
} }
public void shutdown() { public void shutdown() {
- for (int i = 0; i < this.players.size(); ++i) { - for (int i = 0; i < this.players.size(); ++i) {
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown")); - ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
+ // CraftBukkit start - disconnect safely + // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) { + for (EntityPlayer player : this.players) {
+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message + player.connection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
} }
+ // CraftBukkit end + // CraftBukkit end
+
+ } }
+ // CraftBukkit start + // CraftBukkit start
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) { + public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) { + for (IChatBaseComponent component : iChatBaseComponents) {
+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.b); + sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) { public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
this.server.sendMessage(ichatbasecomponent, uuid); this.server.sendMessage(ichatbasecomponent, uuid);
- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype, uuid)); Iterator iterator = this.players.iterator();
+ // CraftBukkit start - we run this through our processor first so we can get web links etc @@ -838,16 +1136,23 @@
+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype, uuid));
+ // CraftBukkit end
+ }
+
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
+ this.sendMessage(ichatbasecomponent, ChatMessageType.SYSTEM, SystemUtils.b);
} }
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) { - public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
- UUID uuid = entityhuman.getUniqueID(); - UUID uuid = entityhuman.getUniqueID();
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid); - ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.stats.get(uuid);
+ // CraftBukkit start + // CraftBukkit start
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) { + public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager(); + ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager();
@ -731,7 +715,7 @@
+ // CraftBukkit end + // CraftBukkit end
if (serverstatisticmanager == null) { if (serverstatisticmanager == null) {
File file = this.server.a(SavedFile.STATS).toFile(); File file = this.server.a(SavedFile.PLAYER_STATS_DIR).toFile();
File file1 = new File(file, uuid + ".json"); File file1 = new File(file, uuid + ".json");
if (!file1.exists()) { if (!file1.exists()) {
@ -740,37 +724,37 @@
if (file2.exists() && file2.isFile()) { if (file2.exists() && file2.isFile()) {
file2.renameTo(file1); file2.renameTo(file1);
@@ -856,7 +1169,7 @@ @@ -855,7 +1160,7 @@
} }
serverstatisticmanager = new ServerStatisticManager(this.server, file1); serverstatisticmanager = new ServerStatisticManager(this.server, file1);
- this.o.put(uuid, serverstatisticmanager); - this.stats.put(uuid, serverstatisticmanager);
+ // this.o.put(uuid, serverstatisticmanager); // CraftBukkit + // this.o.put(uuid, serverstatisticmanager); // CraftBukkit
} }
return serverstatisticmanager; return serverstatisticmanager;
@@ -864,14 +1177,14 @@ @@ -863,14 +1168,14 @@
public AdvancementDataPlayer f(EntityPlayer entityplayer) { public AdvancementDataPlayer f(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUniqueID(); UUID uuid = entityplayer.getUniqueID();
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(uuid); - AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(uuid);
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit + AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
if (advancementdataplayer == null) { if (advancementdataplayer == null) {
File file = this.server.a(SavedFile.ADVANCEMENTS).toFile(); File file = this.server.a(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile();
File file1 = new File(file, uuid + ".json"); File file1 = new File(file, uuid + ".json");
advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer); advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer);
- this.p.put(uuid, advancementdataplayer); - this.advancements.put(uuid, advancementdataplayer);
+ // this.p.put(uuid, advancementdataplayer); // CraftBukkit + // this.p.put(uuid, advancementdataplayer); // CraftBukkit
} }
advancementdataplayer.a(entityplayer); advancementdataplayer.a(entityplayer);
@@ -907,13 +1220,20 @@ @@ -906,13 +1211,20 @@
} }
public void reload() { public void reload() {
- Iterator iterator = this.p.values().iterator(); - Iterator iterator = this.advancements.values().iterator();
+ // CraftBukkit start + // CraftBukkit start
+ /*Iterator iterator = this.p.values().iterator(); + /*Iterator iterator = this.p.values().iterator();
@ -786,5 +770,5 @@
} }
+ // CraftBukkit end + // CraftBukkit end
this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry())); this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry().a((IRegistryCustom) this.registryHolder)));
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b()); PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b());

Datei anzeigen

@ -0,0 +1,20 @@
--- a/net/minecraft/server/players/SleepStatus.java
+++ b/net/minecraft/server/players/SleepStatus.java
@@ -18,7 +18,7 @@
}
public boolean a(int i, List<EntityPlayer> list) {
- int j = (int) list.stream().filter(EntityHuman::isDeeplySleeping).count();
+ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count(); // CraftBukkit
return j >= this.b(i);
}
@@ -46,7 +46,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (!entityplayer.isSpectator()) {
+ if (!entityplayer.isSpectator() && !entityplayer.fauxSleeping) { // CraftBukkit
++this.activePlayers;
if (entityplayer.isSleeping()) {
++this.sleepingPlayers;

Datei anzeigen

@ -5,7 +5,7 @@
package net.minecraft.server.players; package net.minecraft.server.players;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -83,7 +84,7 @@ @@ -92,7 +93,7 @@
} }
public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) { public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {

Datei anzeigen

@ -1,7 +1,7 @@
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java --- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java +++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
@@ -36,6 +36,17 @@ @@ -37,6 +37,17 @@
return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.a, worldserver, 4, "Rcon", RemoteControlCommandListener.b, this.server, (Entity) null); return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
} }
+ // CraftBukkit start - Send a String + // CraftBukkit start - Send a String

Datei anzeigen

@ -8,21 +8,21 @@
+ +
public class RecipeBookServer extends RecipeBook { public class RecipeBookServer extends RecipeBook {
private static final Logger LOGGER = LogManager.getLogger(); public static final String RECIPE_BOOK_TAG = "recipeBook";
@@ -35,7 +37,7 @@ @@ -36,7 +38,7 @@
IRecipe<?> irecipe = (IRecipe) iterator.next(); IRecipe<?> irecipe = (IRecipe) iterator.next();
MinecraftKey minecraftkey = irecipe.getKey(); MinecraftKey minecraftkey = irecipe.getKey();
- if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex()) { - if (!this.known.contains(minecraftkey) && !irecipe.isComplex()) {
+ if (!this.recipes.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit + if (!this.known.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit
this.a(minecraftkey); this.a(minecraftkey);
this.d(minecraftkey); this.d(minecraftkey);
list.add(minecraftkey); list.add(minecraftkey);
@@ -69,6 +71,7 @@ @@ -70,6 +72,7 @@
} }
private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) { private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) {
+ if (entityplayer.playerConnection == null) return; // SPIGOT-4478 during PlayerLoginEvent + if (entityplayer.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent
entityplayer.playerConnection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a())); entityplayer.connection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a()));
} }

Datei anzeigen

@ -5,7 +5,7 @@
package net.minecraft.stats; package net.minecraft.stats;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@@ -158,13 +159,12 @@ @@ -161,13 +162,12 @@
} }
private <T> Optional<Statistic<T>> a(StatisticWrapper<T> statisticwrapper, String s) { private <T> Optional<Statistic<T>> a(StatisticWrapper<T> statisticwrapper, String s) {
@ -15,9 +15,9 @@
+ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.a(s)); + Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.a(s));
+ IRegistry<T> iregistry = statisticwrapper.getRegistry(); + IRegistry<T> iregistry = statisticwrapper.getRegistry();
- iregistry.getClass(); - Objects.requireNonNull(iregistry);
- optional = optional.flatMap(iregistry::getOptional); - optional = optional.flatMap(iregistry::getOptional);
- statisticwrapper.getClass(); - Objects.requireNonNull(statisticwrapper);
- return optional.map(statisticwrapper::b); - return optional.map(statisticwrapper::b);
+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::b); + return optional.flatMap(iregistry::getOptional).map(statisticwrapper::b);
+ // CraftBukkit - decompile error end + // CraftBukkit - decompile error end

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/util/datafix/DataConverterRegistry.java --- a/net/minecraft/util/datafix/DataConverterRegistry.java
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java +++ b/net/minecraft/util/datafix/DataConverterRegistry.java
@@ -367,6 +367,18 @@ @@ -380,6 +380,18 @@
datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false)); datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false));
Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.b); Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED);
+ // CraftBukkit start + // CraftBukkit start
+ datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema47, false) { + datafixerbuilder.addFixer(new com.mojang.datafixers.DataFix(schema47, false) {
@ -19,3 +19,27 @@
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false));
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false)); datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false));
@@ -693,17 +705,20 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Squid", DataConverterTypes.ENTITY));
datafixerbuilder.addFixer(new DataConverterAddChoices(schema130, "Added Glow Item Frame", DataConverterTypes.ENTITY));
Schema schema131 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap = ImmutableMap.builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build();
+ // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap = ImmutableMap.<String, String>builder().put("minecraft:weathered_copper_block", "minecraft:oxidized_copper_block").put("minecraft:semi_weathered_copper_block", "minecraft:weathered_copper_block").put("minecraft:lightly_weathered_copper_block", "minecraft:exposed_copper_block").put("minecraft:weathered_cut_copper", "minecraft:oxidized_cut_copper").put("minecraft:semi_weathered_cut_copper", "minecraft:weathered_cut_copper").put("minecraft:lightly_weathered_cut_copper", "minecraft:exposed_cut_copper").put("minecraft:weathered_cut_copper_stairs", "minecraft:oxidized_cut_copper_stairs").put("minecraft:semi_weathered_cut_copper_stairs", "minecraft:weathered_cut_copper_stairs").put("minecraft:lightly_weathered_cut_copper_stairs", "minecraft:exposed_cut_copper_stairs").put("minecraft:weathered_cut_copper_slab", "minecraft:oxidized_cut_copper_slab").put("minecraft:semi_weathered_cut_copper_slab", "minecraft:weathered_cut_copper_slab").put("minecraft:lightly_weathered_cut_copper_slab", "minecraft:exposed_cut_copper_slab").put("minecraft:waxed_semi_weathered_copper", "minecraft:waxed_weathered_copper").put("minecraft:waxed_lightly_weathered_copper", "minecraft:waxed_exposed_copper").put("minecraft:waxed_semi_weathered_cut_copper", "minecraft:waxed_weathered_cut_copper").put("minecraft:waxed_lightly_weathered_cut_copper", "minecraft:waxed_exposed_cut_copper").put("minecraft:waxed_semi_weathered_cut_copper_stairs", "minecraft:waxed_weathered_cut_copper_stairs").put("minecraft:waxed_lightly_weathered_cut_copper_stairs", "minecraft:waxed_exposed_cut_copper_stairs").put("minecraft:waxed_semi_weathered_cut_copper_slab", "minecraft:waxed_weathered_cut_copper_slab").put("minecraft:waxed_lightly_weathered_cut_copper_slab", "minecraft:waxed_exposed_cut_copper_slab").build();
datafixerbuilder.addFixer(DataConverterItemName.a(schema131, "Renamed copper block items to new oxidized terms", a((Map) immutablemap)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema131, "Renamed copper blocks to new oxidized terms", a((Map) immutablemap)));
Schema schema132 = datafixerbuilder.addSchema(2691, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap1 = ImmutableMap.builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build();
+ // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap1 = ImmutableMap.<String, String>builder().put("minecraft:waxed_copper", "minecraft:waxed_copper_block").put("minecraft:oxidized_copper_block", "minecraft:oxidized_copper").put("minecraft:weathered_copper_block", "minecraft:weathered_copper").put("minecraft:exposed_copper_block", "minecraft:exposed_copper").build();
datafixerbuilder.addFixer(DataConverterItemName.a(schema132, "Rename copper item suffixes", a((Map) immutablemap1)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema132, "Rename copper blocks suffixes", a((Map) immutablemap1)));
Schema schema133 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
- ImmutableMap<String, String> immutablemap2 = ImmutableMap.builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build();
+ // CraftBukkit - decompile error
+ ImmutableMap<String, String> immutablemap2 = ImmutableMap.<String, String>builder().put("minecraft:grimstone", "minecraft:deepslate").put("minecraft:grimstone_slab", "minecraft:cobbled_deepslate_slab").put("minecraft:grimstone_stairs", "minecraft:cobbled_deepslate_stairs").put("minecraft:grimstone_wall", "minecraft:cobbled_deepslate_wall").put("minecraft:polished_grimstone", "minecraft:polished_deepslate").put("minecraft:polished_grimstone_slab", "minecraft:polished_deepslate_slab").put("minecraft:polished_grimstone_stairs", "minecraft:polished_deepslate_stairs").put("minecraft:polished_grimstone_wall", "minecraft:polished_deepslate_wall").put("minecraft:grimstone_tiles", "minecraft:deepslate_tiles").put("minecraft:grimstone_tile_slab", "minecraft:deepslate_tile_slab").put("minecraft:grimstone_tile_stairs", "minecraft:deepslate_tile_stairs").put("minecraft:grimstone_tile_wall", "minecraft:deepslate_tile_wall").put("minecraft:grimstone_bricks", "minecraft:deepslate_bricks").put("minecraft:grimstone_brick_slab", "minecraft:deepslate_brick_slab").put("minecraft:grimstone_brick_stairs", "minecraft:deepslate_brick_stairs").put("minecraft:grimstone_brick_wall", "minecraft:deepslate_brick_wall").put("minecraft:chiseled_grimstone", "minecraft:chiseled_deepslate").build();
datafixerbuilder.addFixer(DataConverterItemName.a(schema133, "Renamed grimstone block items to deepslate", a((Map) immutablemap2)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.b(schema133, "Renamed grimstone blocks to deepslate", a((Map) immutablemap2)));

Datei anzeigen

@ -11,70 +11,70 @@
public class WorldUpgrader { public class WorldUpgrader {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
private static final ThreadFactory b = (new ThreadFactoryBuilder()).setDaemon(true).build(); private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build();
- private final ImmutableSet<ResourceKey<World>> c; - private final ImmutableSet<ResourceKey<World>> levels;
+ private final ImmutableSet<ResourceKey<DimensionManager>> c; // CraftBukkit + private final ImmutableSet<ResourceKey<DimensionManager>> levels; // CraftBukkit
private final boolean d; private final boolean eraseCache;
private final Convertable.ConversionSession e; private final Convertable.ConversionSession levelStorage;
private final Thread f; private final Thread thread;
@@ -49,12 +53,12 @@ @@ -49,12 +53,12 @@
private volatile int k; private volatile int totalChunks;
private volatile int l; private volatile int converted;
private volatile int m; private volatile int skipped;
- private final Object2FloatMap<ResourceKey<World>> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); - private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k()));
+ private final Object2FloatMap<ResourceKey<DimensionManager>> n = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit + private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit
private volatile IChatBaseComponent o = new ChatMessage("optimizeWorld.stage.counting"); private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting");
private static final Pattern p = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
private final WorldPersistentData q; private final WorldPersistentData overworldDataStorage;
- public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<World>> immutableset, boolean flag) { - public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<World>> immutableset, boolean flag) {
+ public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<DimensionManager>> immutableset, boolean flag) { // CraftBukkit + public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, ImmutableSet<ResourceKey<DimensionManager>> immutableset, boolean flag) { // CraftBukkit
this.c = immutableset; this.levels = immutableset;
this.d = flag; this.eraseCache = flag;
this.g = datafixer; this.dataFixer = datafixer;
@@ -82,12 +86,12 @@ @@ -82,12 +86,12 @@
private void i() { private void i() {
this.k = 0; this.totalChunks = 0;
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); - Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit + Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
List list; List list;
for (UnmodifiableIterator unmodifiableiterator = this.c.iterator(); unmodifiableiterator.hasNext(); this.k += list.size()) { for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) {
- ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next(); - ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next();
+ ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit + ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
list = this.b(resourcekey); list = this.b(resourcekey);
builder.put(resourcekey, list.listIterator()); builder.put(resourcekey, list.listIterator());
@@ -97,18 +101,18 @@ @@ -97,18 +101,18 @@
this.i = true; this.finished = true;
} else { } else {
float f = (float) this.k; float f = (float) this.totalChunks;
- ImmutableMap<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); - ImmutableMap<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build();
- Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder(); - Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder();
+ ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit + ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
+ Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit + Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit
UnmodifiableIterator unmodifiableiterator1 = this.c.iterator(); UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator();
while (unmodifiableiterator1.hasNext()) { while (unmodifiableiterator1.hasNext()) {
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); - ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
- File file = this.e.a(resourcekey1); - File file = this.levelStorage.a(resourcekey1);
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit + ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
+ File file = this.e.a(null); // CraftBukkit + File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.g, true)); builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true));
} }
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build(); - ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
+ ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit + ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
long i = SystemUtils.getMonotonicMillis(); long i = SystemUtils.getMonotonicMillis();
this.o = new ChatMessage("optimizeWorld.stage.upgrading"); this.status = new ChatMessage("optimizeWorld.stage.upgrading");
@@ -120,7 +124,7 @@ @@ -120,7 +124,7 @@
float f2; float f2;
for (UnmodifiableIterator unmodifiableiterator2 = this.c.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) { for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
- ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); - ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next();
+ ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit + ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2); ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
@ -83,7 +83,7 @@
@@ -135,7 +139,7 @@ @@ -135,7 +139,7 @@
int j = IChunkLoader.a(nbttagcompound); int j = IChunkLoader.a(nbttagcompound);
NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> { NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> {
return this.q; return this.overworldDataStorage;
- }, nbttagcompound); - }, nbttagcompound);
+ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit + }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level"); NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level");
@ -94,9 +94,18 @@
} }
- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) { - private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) {
- File file = this.e.a(resourcekey); - File file = this.levelStorage.a(resourcekey);
+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit + private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
+ File file = this.e.a(null); // CraftBukkit + File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
File file1 = new File(file, "region"); File file1 = new File(file, "region");
File[] afile = file1.listFiles((file2, s) -> { File[] afile = file1.listFiles((file2, s) -> {
return s.endsWith(".mca"); return s.endsWith(".mca");
@@ -269,7 +273,7 @@
}
public ImmutableSet<ResourceKey<World>> c() {
- return this.levels;
+ throw new AssertionError("Unsupported"); // CraftBukkit
}
public float a(ResourceKey<World> resourcekey) {

Datei anzeigen

@ -12,7 +12,7 @@
@Immutable @Immutable
public class ChestLock { public class ChestLock {
@@ -15,7 +20,19 @@ @@ -16,7 +21,19 @@
} }
public boolean a(ItemStack itemstack) { public boolean a(ItemStack itemstack) {

Datei anzeigen

@ -11,8 +11,8 @@
+ +
public interface IInventory extends Clearable { public interface IInventory extends Clearable {
int getSize(); int LARGE_MAX_STACK_SIZE = 64;
@@ -19,9 +24,7 @@ @@ -21,9 +26,7 @@
void setItem(int i, ItemStack itemstack); void setItem(int i, ItemStack itemstack);
@ -23,7 +23,7 @@
void update(); void update();
@@ -60,4 +63,29 @@ @@ -62,4 +65,29 @@
return false; return false;
} }

Datei anzeigen

@ -15,8 +15,8 @@
+ +
public class InventoryLargeChest implements IInventory { public class InventoryLargeChest implements IInventory {
public final IInventory left; public final IInventory container1;
public final IInventory right; public final IInventory container2;
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@ -30,14 +30,14 @@
+ } + }
+ +
+ public void onOpen(CraftHumanEntity who) { + public void onOpen(CraftHumanEntity who) {
+ this.left.onOpen(who); + this.container1.onOpen(who);
+ this.right.onOpen(who); + this.container2.onOpen(who);
+ transaction.add(who); + transaction.add(who);
+ } + }
+ +
+ public void onClose(CraftHumanEntity who) { + public void onClose(CraftHumanEntity who) {
+ this.left.onClose(who); + this.container1.onClose(who);
+ this.right.onClose(who); + this.container2.onClose(who);
+ transaction.remove(who); + transaction.remove(who);
+ } + }
+ +
@ -50,13 +50,13 @@
+ } + }
+ +
+ public void setMaxStackSize(int size) { + public void setMaxStackSize(int size) {
+ this.left.setMaxStackSize(size); + this.container1.setMaxStackSize(size);
+ this.right.setMaxStackSize(size); + this.container2.setMaxStackSize(size);
+ } + }
+ +
+ @Override + @Override
+ public Location getLocation() { + public Location getLocation() {
+ return left.getLocation(); // TODO: right? + return container1.getLocation(); // TODO: right?
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
@ -67,8 +67,8 @@
@Override @Override
public int getMaxStackSize() { public int getMaxStackSize() {
- return this.left.getMaxStackSize(); - return this.container1.getMaxStackSize();
+ return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides + return Math.min(this.container1.getMaxStackSize(), this.container2.getMaxStackSize()); // CraftBukkit - check both sides
} }
@Override @Override

Datei anzeigen

@ -12,9 +12,9 @@
+ +
public class InventorySubcontainer implements IInventory, AutoRecipeOutput { public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
private final int a; private final int size;
public final NonNullList<ItemStack> items; public final NonNullList<ItemStack> items;
private List<IInventoryListener> c; private List<IInventoryListener> listeners;
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@ -56,8 +56,8 @@
+ } + }
+ +
+ public InventorySubcontainer(InventorySubcontainer original) { + public InventorySubcontainer(InventorySubcontainer original) {
+ this(original.a); + this(original.size);
+ for (int slot = 0; slot < original.a; slot++) { + for (int slot = 0; slot < original.size; slot++) {
+ this.items.set(slot, original.items.get(slot).cloneItemStack()); + this.items.set(slot, original.items.get(slot).cloneItemStack());
+ } + }
+ } + }
@ -69,6 +69,6 @@
+ public InventorySubcontainer(int i, org.bukkit.inventory.InventoryHolder owner) { + public InventorySubcontainer(int i, org.bukkit.inventory.InventoryHolder owner) {
+ this.bukkitOwner = owner; + this.bukkitOwner = owner;
+ // CraftBukkit end + // CraftBukkit end
this.a = i; this.size = i;
this.items = NonNullList.a(i, ItemStack.b); this.items = NonNullList.a(i, ItemStack.EMPTY);
} }

Datei anzeigen

@ -1,9 +1,9 @@
--- a/net/minecraft/world/damagesource/DamageSource.java --- a/net/minecraft/world/damagesource/DamageSource.java
+++ b/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java
@@ -46,6 +46,18 @@ @@ -52,6 +52,18 @@
private boolean D; private boolean isFall;
private boolean E; private boolean noAggro;
public final String translationIndex; public final String msgId;
+ // CraftBukkit start + // CraftBukkit start
+ private boolean sweep; + private boolean sweep;
+ +

Datei anzeigen

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

Datei anzeigen

@ -13,16 +13,7 @@
+ +
public class MobEffectList { public class MobEffectList {
private final Map<AttributeBase, AttributeModifier> a = Maps.newHashMap(); private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap();
@@ -33,7 +40,7 @@
}
public static int getId(MobEffectList mobeffectlist) {
- return IRegistry.MOB_EFFECT.a((Object) mobeffectlist);
+ return IRegistry.MOB_EFFECT.a(mobeffectlist); // CraftBukkit - decompile error
}
protected MobEffectList(MobEffectInfo mobeffectinfo, int i) {
@@ -44,26 +51,37 @@ @@ -44,26 +51,37 @@
public void tick(EntityLiving entityliving, int i) { public void tick(EntityLiving entityliving, int i) {
if (this == MobEffects.REGENERATION) { if (this == MobEffects.REGENERATION) {
@ -41,7 +32,7 @@
- ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1)); - ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1));
+ ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent + ((EntityHuman) entityliving).applyExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
} else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) { } else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
if (!entityliving.world.isClientSide) { if (!entityliving.level.isClientSide) {
- ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F); - ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
+ // CraftBukkit start + // CraftBukkit start
+ EntityHuman entityhuman = (EntityHuman) entityliving; + EntityHuman entityhuman = (EntityHuman) entityliving;
@ -53,11 +44,11 @@
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F); + entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
+ } + }
+ +
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); + ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+ // CraftBukkit end + // CraftBukkit end
} }
} else if ((this != MobEffects.HEAL || entityliving.dj()) && (this != MobEffects.HARM || !entityliving.dj())) { } else if ((this != MobEffects.HEAL || entityliving.dT()) && (this != MobEffects.HARM || !entityliving.dT())) {
if (this == MobEffects.HARM && !entityliving.dj() || this == MobEffects.HEAL && entityliving.dj()) { if (this == MobEffects.HARM && !entityliving.dT() || this == MobEffects.HEAL && entityliving.dT()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i)); entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
} }
} else { } else {

Datei anzeigen

@ -12,6 +12,6 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public MobEffects() {}
private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) { private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) {
return (MobEffectList) IRegistry.a(IRegistry.MOB_EFFECT, i, s, mobeffectlist);
}

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -106,8 +106,58 @@ @@ -116,8 +116,58 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -33,7 +33,7 @@
+import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.PluginManager;
+// CraftBukkit end +// CraftBukkit end
+ +
public abstract class Entity implements INamableTileEntity, ICommandListener { public abstract class Entity implements INamableTileEntity, EntityAccess, ICommandListener {
+ // CraftBukkit start + // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2; + private static final int CURRENT_LEVEL = 2;
@ -45,7 +45,7 @@
+ +
+ public CraftEntity getBukkitEntity() { + public CraftEntity getBukkitEntity() {
+ if (bukkitEntity == null) { + if (bukkitEntity == null) {
+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this); + bukkitEntity = CraftEntity.getEntity(level.getServer(), this);
+ } + }
+ return bukkitEntity; + return bukkitEntity;
+ } + }
@ -57,12 +57,12 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
protected static final Logger LOGGER = LogManager.getLogger(); protected static final Logger LOGGER = LogManager.getLogger();
private static final AtomicInteger entityCount = new AtomicInteger(); public static final String ID_TAG = "id";
private static final List<ItemStack> c = Collections.emptyList(); public static final String PASSENGERS_TAG = "Passengers";
@@ -191,6 +241,21 @@ @@ -224,6 +274,21 @@
private long aB; private float crystalSoundIntensity;
private EntitySize size; private int lastCrystalSoundPlayTick;
private float headHeight; public boolean hasVisualFire;
+ // CraftBukkit start + // CraftBukkit start
+ public boolean persist = true; + public boolean persist = true;
+ public boolean valid; + public boolean valid;
@ -71,30 +71,30 @@
+ public boolean persistentInvisibility = false; + public boolean persistentInvisibility = false;
+ +
+ public float getBukkitYaw() { + public float getBukkitYaw() {
+ return this.yaw; + return this.yRot;
+ } + }
+ +
+ public boolean isChunkLoaded() { + public boolean isChunkLoaded() {
+ return world.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); + return level.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
public Entity(EntityTypes<?> entitytypes, World world) { public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.entityCount.incrementAndGet(); this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -297,6 +362,12 @@ @@ -359,6 +424,12 @@
} public void ae() {}
public void setPose(EntityPose entitypose) { public void setPose(EntityPose entitypose) {
+ // CraftBukkit start + // CraftBukkit start
+ if (entitypose == this.getPose()) { + if (entitypose == this.getPose()) {
+ return; + return;
+ } + }
+ this.world.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()])); + this.level.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()]));
+ // CraftBukkit end + // CraftBukkit end
this.datawatcher.set(Entity.POSE, entitypose); this.entityData.set(Entity.DATA_POSE, entitypose);
} }
@@ -313,6 +384,33 @@ @@ -375,6 +446,33 @@
} }
protected void setYawPitch(float f, float f1) { protected void setYawPitch(float f, float f1) {
@ -105,7 +105,7 @@
+ +
+ if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) { + if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw"); + this.level.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)");
+ } + }
+ f = 0; + f = 0;
@ -118,25 +118,17 @@
+ +
+ if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) { + if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch"); + this.level.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)"); + ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)");
+ } + }
+ f1 = 0; + f1 = 0;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
this.yaw = f % 360.0F; this.setYRot(f % 360.0F);
this.pitch = f1 % 360.0F; this.setXRot(f1 % 360.0F);
} }
@@ -320,6 +418,7 @@ @@ -416,6 +514,15 @@
public void setPosition(double d0, double d1, double d2) {
this.setPositionRaw(d0, d1, d2);
this.a(this.size.a(d0, d1, d2));
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
}
protected void af() {
@@ -334,6 +433,15 @@
this.entityBaseTick(); this.entityBaseTick();
} }
@ -150,30 +142,30 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
public void entityBaseTick() { public void entityBaseTick() {
this.world.getMethodProfiler().enter("entityBaseTick"); this.level.getMethodProfiler().enter("entityBaseTick");
if (this.isPassenger() && this.getVehicle().dead) { if (this.isPassenger() && this.getVehicle().isRemoved()) {
@@ -347,7 +455,7 @@ @@ -429,7 +536,7 @@
this.z = this.A; this.walkDistO = this.walkDist;
this.lastPitch = this.pitch; this.xRotO = this.getXRot();
this.lastYaw = this.yaw; this.yRotO = this.getYRot();
- this.doPortalTick(); - this.doPortalTick();
+ if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick + if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick
if (this.aO()) { if (this.aV()) {
this.aP(); this.aW();
} }
@@ -410,12 +518,44 @@ @@ -507,7 +614,23 @@
protected void burnFromLava() { public void burnFromLava() {
if (!this.isFireProof()) { if (!this.isFireProof()) {
- this.setOnFire(15); - this.setOnFire(15);
+ // CraftBukkit start - Fallen in lava TODO: this event spams! + // CraftBukkit start - Fallen in lava TODO: this event spams!
+ if (this instanceof EntityLiving && fireTicks <= 0) { + if (this instanceof EntityLiving && remainingFireTicks <= 0) {
+ // not on fire yet + // not on fire yet
+ // TODO: shouldn't be sending null for the block + // TODO: shouldn't be sending null for the block
+ org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k); + org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity();
+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); + EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
+ this.world.getServer().getPluginManager().callEvent(combustEvent); + this.level.getServer().getPluginManager().callEvent(combustEvent);
+ +
+ if (!combustEvent.isCancelled()) { + if (!combustEvent.isCancelled()) {
+ this.setOnFire(combustEvent.getDuration(), false); + this.setOnFire(combustEvent.getDuration(), false);
@ -183,8 +175,10 @@
+ this.setOnFire(15, false); + this.setOnFire(15, false);
+ } + }
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls + // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.damageEntity(DamageSource.LAVA, 4.0F); if (this.damageEntity(DamageSource.LAVA, 4.0F)) {
} this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
}
@@ -516,6 +639,22 @@
} }
public void setOnFire(int i) { public void setOnFire(int i) {
@ -195,7 +189,7 @@
+ public void setOnFire(int i, boolean callEvent) { + public void setOnFire(int i, boolean callEvent) {
+ if (callEvent) { + if (callEvent) {
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i); + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i);
+ this.world.getServer().getPluginManager().callEvent(event); + this.level.getServer().getPluginManager().callEvent(event);
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
@ -207,114 +201,92 @@
int j = i * 20; int j = i * 20;
if (this instanceof EntityLiving) { if (this instanceof EntityLiving) {
@@ -512,6 +652,28 @@ @@ -614,6 +753,28 @@
block.a((IBlockAccess) this.world, this); block.a((IBlockAccess) this.level, this);
} }
+ // CraftBukkit start + // CraftBukkit start
+ if (positionChanged && getBukkitEntity() instanceof Vehicle) { + if (horizontalCollision && getBukkitEntity() instanceof Vehicle) {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ())); + org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ()));
+ +
+ if (vec3d.x > vec3d1.x) { + if (vec3d.x > vec3d1.x) {
+ bl = bl.getRelative(BlockFace.EAST); + bl = bl.getRelative(BlockFace.EAST);
+ } else if (vec3d.x < vec3d1.x) { + } else if (vec3d.x < vec3d1.x) {
+ bl = bl.getRelative(BlockFace.WEST); + bl = bl.getRelative(BlockFace.WEST);
+ } else if (vec3d.z > vec3d1.z) { + } else if (vec3d.z > vec3d1.z) {
+ bl = bl.getRelative(BlockFace.SOUTH); + bl = bl.getRelative(BlockFace.SOUTH);
+ } else if (vec3d.z < vec3d1.z) { + } else if (vec3d.z < vec3d1.z) {
+ bl = bl.getRelative(BlockFace.NORTH); + bl = bl.getRelative(BlockFace.NORTH);
+ }
+
+ if (!bl.getType().isAir()) {
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
+ level.getServer().getPluginManager().callEvent(event);
+ }
+ } + }
+ // CraftBukkit end
+ +
+ if (!bl.getType().isAir()) { if (this.onGround && !this.bE()) {
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl); block.stepOn(this.level, blockposition, iblockdata, this);
+ world.getServer().getPluginManager().callEvent(event); }
+ } @@ -1276,6 +1437,7 @@
+ } this.yo = d1;
+ // CraftBukkit end this.zo = d4;
+
if (this.onGround && !this.bv()) {
block.stepOn(this.world, blockposition, this);
}
@@ -785,6 +947,7 @@
AxisAlignedBB axisalignedbb = this.getBoundingBox();
this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D);
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
}
protected SoundEffect getSoundSwim() {
@@ -1110,6 +1273,13 @@
}
public void spawnIn(World world) {
+ // CraftBukkit start
+ if (world == null) {
+ die();
+ this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ return;
+ }
+ // CraftBukkit end
this.world = world;
}
@@ -1129,6 +1299,7 @@
this.lastY = d1;
this.lastZ = d4;
this.setPosition(d3, d1, d4); this.setPosition(d3, d1, d4);
+ world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit + level.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit
} }
public void d(Vec3D vec3d) { public void d(Vec3D vec3d) {
@@ -1303,6 +1474,12 @@ @@ -1466,6 +1628,12 @@
return false; return false;
} }
+ // CraftBukkit start - collidable API + // CraftBukkit start - collidable API
+ public boolean canCollideWith(Entity entity) { + public boolean canCollideWithBukkit(Entity entity) {
+ return isCollidable(); + return isCollidable();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
public void a(Entity entity, int i, DamageSource damagesource) { public void a(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource); CriterionTriggers.ENTITY_KILLED_PLAYER.a((EntityPlayer) entity, this, damagesource);
@@ -1313,7 +1490,7 @@ @@ -1499,7 +1667,7 @@
public boolean a_(NBTTagCompound nbttagcompound) { } else {
String s = this.getSaveID(); String s = this.getSaveID();
- if (!this.dead && s != null) { - if (s == null) {
+ if (this.persist && !this.dead && s != null) { // CraftBukkit - persist flag + if (!this.persist || s == null) { // CraftBukkit - persist flag
nbttagcompound.setString("id", s); return false;
this.save(nbttagcompound); } else {
return true; nbttagcompound.setString("id", s);
@@ -1337,6 +1514,18 @@ @@ -1524,6 +1692,18 @@
Vec3D vec3d = this.getMot(); Vec3D vec3d = this.getMot();
nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z)); nbttagcompound.set("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
+ +
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
+ // TODO: make sure this is the best way to address this. + // TODO: make sure this is the best way to address this.
+ if (Float.isNaN(this.yaw)) { + if (Float.isNaN(this.yRot)) {
+ this.yaw = 0; + this.yRot = 0;
+ } + }
+ +
+ if (Float.isNaN(this.pitch)) { + if (Float.isNaN(this.xRot)) {
+ this.pitch = 0; + this.xRot = 0;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch)); nbttagcompound.set("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.setFloat("FallDistance", this.fallDistance); nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks); nbttagcompound.setShort("Fire", (short) this.remainingFireTicks);
@@ -1345,6 +1534,18 @@ @@ -1532,6 +1712,18 @@
nbttagcompound.setBoolean("Invulnerable", this.invulnerable); nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown); nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
nbttagcompound.a("UUID", this.getUniqueID()); nbttagcompound.a("UUID", this.getUniqueID());
+ // CraftBukkit start + // CraftBukkit start
+ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.world).getWorld().getUID().getLeastSignificantBits()); + nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits());
+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getWorld().getUID().getMostSignificantBits()); + nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits());
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL); + nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
+ if (!this.persist) { + if (!this.persist) {
+ nbttagcompound.setBoolean("Bukkit.persist", this.persist); + nbttagcompound.setBoolean("Bukkit.persist", this.persist);
@ -326,7 +298,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName(); IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) { if (ichatbasecomponent != null) {
@@ -1402,6 +1603,11 @@ @@ -1599,6 +1791,11 @@
} }
} }
@ -338,7 +310,7 @@
return nbttagcompound; return nbttagcompound;
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
@@ -1479,6 +1685,49 @@ @@ -1680,6 +1877,49 @@
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
} }
@ -350,7 +322,7 @@
+ // Reset the persistence for tamed animals + // Reset the persistence for tamed animals
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) { + if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
+ EntityInsentient entityinsentient = (EntityInsentient) entity; + EntityInsentient entityinsentient = (EntityInsentient) entity;
+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(0); + entityinsentient.persistenceRequired = !entityinsentient.isTypeNotPersistent(0);
+ } + }
+ } + }
+ this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist"); + this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
@ -375,7 +347,7 @@
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld(); + bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld();
+ } + }
+ +
+ spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle()); + ((EntityPlayer) this).spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle());
+ } + }
+ this.getBukkitEntity().readBukkitValues(nbttagcompound); + this.getBukkitEntity().readBukkitValues(nbttagcompound);
+ if (nbttagcompound.hasKey("Bukkit.invisible")) { + if (nbttagcompound.hasKey("Bukkit.invisible")) {
@ -388,8 +360,8 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT"); CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
@@ -1554,9 +1803,22 @@ @@ -1755,9 +1995,22 @@
} else if (this.world.isClientSide) { } else if (this.level.isClientSide) {
return null; return null;
} else { } else {
+ // CraftBukkit start - Capture drops for death event + // CraftBukkit start - Capture drops for death event
@ -398,7 +370,7 @@
+ return null; + return null;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY() + (double) f, this.locZ(), itemstack); EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY() + (double) f, this.locZ(), itemstack);
entityitem.defaultPickupDelay(); entityitem.defaultPickupDelay();
+ // CraftBukkit start + // CraftBukkit start
@ -408,19 +380,19 @@
+ return null; + return null;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.world.addEntity(entityitem); this.level.addEntity(entityitem);
return entityitem; return entityitem;
} }
@@ -1640,7 +1902,7 @@ @@ -1849,7 +2102,7 @@
this.setPose(EntityPose.STANDING); this.setPose(EntityPose.STANDING);
this.vehicle = entity; this.vehicle = entity;
- this.vehicle.addPassenger(this); - this.vehicle.addPassenger(this);
+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit + if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
return true; entity.n().filter((entity2) -> {
} return entity2 instanceof EntityPlayer;
} }).forEach((entity2) -> {
@@ -1665,7 +1927,7 @@ @@ -1880,7 +2133,7 @@
Entity entity = this.vehicle; Entity entity = this.vehicle;
this.vehicle = null; this.vehicle = null;
@ -429,8 +401,8 @@
} }
} }
@@ -1674,10 +1936,31 @@ @@ -1889,10 +2142,31 @@
this.bf(); this.bo();
} }
- protected void addPassenger(Entity entity) { - protected void addPassenger(Entity entity) {
@ -459,10 +431,10 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) { if (this.passengers.isEmpty()) {
this.passengers.add(0, entity); this.passengers = ImmutableList.of(entity);
} else { } else {
@@ -1685,15 +1968,36 @@ @@ -1908,12 +2182,32 @@
} }
} }
@ -493,25 +465,29 @@
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.passengers.remove(entity); if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
entity.j = 60; this.passengers = ImmutableList.of();
} else {
@@ -1924,6 +2218,7 @@
entity.boardingCooldown = 60;
} }
+ return true; // CraftBukkit + return true; // CraftBukkit
} }
protected boolean q(Entity entity) { protected boolean o(Entity entity) {
@@ -1731,14 +2035,20 @@ @@ -1974,14 +2269,20 @@
if (this.inPortal) { if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getMinecraftServer(); MinecraftServer minecraftserver = worldserver.getMinecraftServer();
- ResourceKey<World> resourcekey = this.world.getDimensionKey() == World.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; - ResourceKey<World> resourcekey = this.level.getDimensionKey() == World.NETHER ? World.OVERWORLD : World.NETHER;
+ ResourceKey<World> resourcekey = this.world.getTypeKey() == DimensionManager.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; // CraftBukkit + ResourceKey<World> resourcekey = this.level.getTypeKey() == DimensionManager.NETHER_LOCATION ? World.OVERWORLD : World.NETHER; // CraftBukkit
WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey); WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey);
- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTicks++ >= i) { - if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTime++ >= i) {
+ if (true && !this.isPassenger() && this.portalTicks++ >= i) { // CraftBukkit + if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
this.world.getMethodProfiler().enter("portal"); this.level.getMethodProfiler().enter("portal");
this.portalTicks = i; this.portalTime = i;
this.resetPortalCooldown(); this.resetPortalCooldown();
- this.b(worldserver1); - this.b(worldserver1);
+ // CraftBukkit start + // CraftBukkit start
@ -521,10 +497,10 @@
+ this.b(worldserver1); + this.b(worldserver1);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.world.getMethodProfiler().exit(); this.level.getMethodProfiler().exit();
} }
@@ -1838,6 +2148,13 @@ @@ -2099,6 +2400,13 @@
} }
public void setSwimming(boolean flag) { public void setSwimming(boolean flag) {
@ -538,7 +514,7 @@
this.setFlag(4, flag); this.setFlag(4, flag);
} }
@@ -1870,8 +2187,12 @@ @@ -2147,8 +2455,12 @@
return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false;
} }
@ -552,11 +528,11 @@
} }
public boolean getFlag(int i) { public boolean getFlag(int i) {
@@ -1898,16 +2219,56 @@ @@ -2175,7 +2487,17 @@
} }
public void setAirTicks(int i) { public void setAirTicks(int i) {
- this.datawatcher.set(Entity.AIR_TICKS, i); - this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i);
+ // CraftBukkit start + // CraftBukkit start
+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
+ // Suppress during worldgen + // Suppress during worldgen
@ -566,19 +542,22 @@
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ this.datawatcher.set(Entity.AIR_TICKS, event.getAmount()); + this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount());
+ // CraftBukkit end + // CraftBukkit end
} }
public int getTicksFrozen() {
@@ -2202,11 +2524,41 @@
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) { public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
this.setFireTicks(this.fireTicks + 1); this.setFireTicks(this.remainingFireTicks + 1);
+ // CraftBukkit start + // CraftBukkit start
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
+ final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
+ final PluginManager pluginManager = Bukkit.getPluginManager(); + final PluginManager pluginManager = Bukkit.getPluginManager();
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.fireTicks == 0) { if (this.remainingFireTicks == 0) {
- this.setOnFire(8); - this.setOnFire(8);
+ // CraftBukkit start - Call a combust event when lightning strikes + // CraftBukkit start - Call a combust event when lightning strikes
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8); + EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
@ -599,12 +578,12 @@
+ } + }
} }
- this.damageEntity(DamageSource.LIGHTNING, 5.0F); - this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F);
+ if (this.isFireProof()) { + if (this.isFireProof()) {
+ return; + return;
+ } + }
+ CraftEventFactory.entityDamage = entitylightning; + CraftEventFactory.entityDamage = entitylightning;
+ if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) { + if (!this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F)) {
+ CraftEventFactory.entityDamage = null; + CraftEventFactory.entityDamage = null;
+ return; + return;
+ } + }
@ -612,7 +591,7 @@
} }
public void k(boolean flag) { public void k(boolean flag) {
@@ -2057,15 +2418,32 @@ @@ -2356,15 +2708,32 @@
@Nullable @Nullable
public Entity b(WorldServer worldserver) { public Entity b(WorldServer worldserver) {
@ -623,8 +602,8 @@
+ @Nullable + @Nullable
+ public Entity teleportTo(WorldServer worldserver, BlockPosition location) { + public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
+ // CraftBukkit end + // CraftBukkit end
if (this.world instanceof WorldServer && !this.dead) { if (this.level instanceof WorldServer && !this.isRemoved()) {
this.world.getMethodProfiler().enter("changeDimension"); this.level.getMethodProfiler().enter("changeDimension");
- this.decouple(); - this.decouple();
+ // CraftBukkit start + // CraftBukkit start
+ // this.decouple(); + // this.decouple();
@ -632,9 +611,9 @@
+ return null; + return null;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.world.getMethodProfiler().enter("reposition"); this.level.getMethodProfiler().enter("reposition");
- ShapeDetectorShape shapedetectorshape = this.a(worldserver); - ShapeDetectorShape shapedetectorshape = this.a(worldserver);
+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.a(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ORIGIN, this.yaw, this.pitch, worldserver, null); // CraftBukkit + ShapeDetectorShape shapedetectorshape = (location == null) ? this.a(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit
if (shapedetectorshape == null) { if (shapedetectorshape == null) {
return null; return null;
@ -644,55 +623,55 @@
+ this.decouple(); + this.decouple();
+ // CraftBukkit end + // CraftBukkit end
+ +
this.world.getMethodProfiler().exitEnter("reloading"); this.level.getMethodProfiler().exitEnter("reloading");
Entity entity = this.getEntityType().a((World) worldserver); Entity entity = this.getEntityType().a((World) worldserver);
@@ -2074,9 +2452,17 @@ @@ -2373,9 +2742,17 @@
entity.setPositionRotation(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, entity.pitch); entity.setPositionRotation(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setMot(shapedetectorshape.velocity); entity.setMot(shapedetectorshape.speed);
worldserver.addEntityTeleport(entity); worldserver.addEntityTeleport(entity);
- if (worldserver.getDimensionKey() == World.THE_END) { - if (worldserver.getDimensionKey() == World.END) {
- WorldServer.a(worldserver); - WorldServer.a(worldserver);
+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit + if (worldserver.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit
+ WorldServer.a(worldserver, this); // CraftBukkit + WorldServer.a(worldserver, this); // CraftBukkit
} + }
+ // CraftBukkit start - Forward the CraftEntity to the new entity + // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity); + this.getBukkitEntity().setHandle(entity);
+ entity.bukkitEntity = this.getBukkitEntity(); + entity.bukkitEntity = this.getBukkitEntity();
+ +
+ if (this instanceof EntityInsentient) { + if (this instanceof EntityInsentient) {
+ ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads. + ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads.
+ } }
+ // CraftBukkit end + // CraftBukkit end
} }
this.bN(); this.cc();
@@ -2097,13 +2483,18 @@ @@ -2396,13 +2773,18 @@
@Nullable @Nullable
protected ShapeDetectorShape a(WorldServer worldserver) { protected ShapeDetectorShape a(WorldServer worldserver) {
- boolean flag = this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD; - boolean flag = this.level.getDimensionKey() == World.END && worldserver.getDimensionKey() == World.OVERWORLD;
- boolean flag1 = worldserver.getDimensionKey() == World.THE_END; - boolean flag1 = worldserver.getDimensionKey() == World.END;
+ // CraftBukkit start + // CraftBukkit start
+ if (worldserver == null) { + if (worldserver == null) {
+ return null; + return null;
+ } + }
+ boolean flag = this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD; // fromEndToOverworld + boolean flag = this.level.getTypeKey() == DimensionManager.END_LOCATION && worldserver.getTypeKey() == DimensionManager.OVERWORLD_LOCATION; // fromEndToOverworld
+ boolean flag1 = worldserver.getTypeKey() == DimensionManager.THE_END; // targetIsEnd + boolean flag1 = worldserver.getTypeKey() == DimensionManager.END_LOCATION; // targetIsEnd
+ // CraftBukkit end + // CraftBukkit end
if (!flag && !flag1) { if (!flag && !flag1) {
- boolean flag2 = worldserver.getDimensionKey() == World.THE_NETHER; - boolean flag2 = worldserver.getDimensionKey() == World.NETHER;
+ boolean flag2 = worldserver.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit + boolean flag2 = worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION; // CraftBukkit
- if (this.world.getDimensionKey() != World.THE_NETHER && !flag2) { - if (this.level.getDimensionKey() != World.NETHER && !flag2) {
+ if (this.world.getTypeKey() != DimensionManager.THE_NETHER && !flag2) { + if (this.level.getTypeKey() != DimensionManager.NETHER_LOCATION && !flag2) {
return null; return null;
} else { } else {
WorldBorder worldborder = worldserver.getWorldBorder(); WorldBorder worldborder = worldserver.getWorldBorder();
@@ -2113,8 +2504,16 @@ @@ -2412,8 +2794,16 @@
double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D); double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D);
double d4 = DimensionManager.a(this.world.getDimensionManager(), worldserver.getDimensionManager()); double d4 = DimensionManager.a(this.level.getDimensionManager(), worldserver.getDimensionManager());
BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3)); BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3));
+ // CraftBukkit start + // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
@ -705,21 +684,21 @@
- return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2).map((blockutil_rectangle) -> { - return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2).map((blockutil_rectangle) -> {
+ return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { + return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> {
+ // CraftBukkit end + // CraftBukkit end
IBlockData iblockdata = this.world.getType(this.ac); IBlockData iblockdata = this.level.getType(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis; EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d; Vec3D vec3d;
@@ -2131,8 +2530,8 @@ @@ -2430,8 +2820,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D); vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
} }
- return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch); - return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot());
- }).orElse((Object) null); - }).orElse((Object) null);
+ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch, event); // CraftBukkit + return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot(), event); // CraftBukkit
+ }).orElse(null); // CraftBuukkit - decompile error + }).orElse(null); // CraftBuukkit - decompile error
} }
} else { } else {
BlockPosition blockposition1; BlockPosition blockposition1;
@@ -2142,8 +2541,15 @@ @@ -2441,8 +2831,15 @@
} else { } else {
blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
} }
@ -730,13 +709,13 @@
+ } + }
+ blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); + blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch); - return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.getYRot(), this.getXRot());
+ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch, ((CraftWorld) event.getTo().getWorld()).getHandle(), event); + return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event);
+ // CraftBukkit end + // CraftBukkit end
} }
} }
@@ -2151,8 +2557,23 @@ @@ -2450,8 +2847,23 @@
return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose())); return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose()));
} }
@ -762,11 +741,11 @@
} }
public boolean canPortal() { public boolean canPortal() {
@@ -2338,7 +2759,26 @@ @@ -2660,7 +3072,26 @@
} }
public void a(AxisAlignedBB axisalignedbb) { public final void a(AxisAlignedBB axisalignedbb) {
- this.boundingBox = axisalignedbb; - this.bb = axisalignedbb;
+ // CraftBukkit start - block invalid bounding boxes + // CraftBukkit start - block invalid bounding boxes
+ double minX = axisalignedbb.minX, + double minX = axisalignedbb.minX,
+ minY = axisalignedbb.minY, + minY = axisalignedbb.minY,
@ -785,7 +764,7 @@
+ len = axisalignedbb.maxZ - axisalignedbb.minZ; + len = axisalignedbb.maxZ - axisalignedbb.minZ;
+ if (len < 0) maxZ = minZ; + if (len < 0) maxZ = minZ;
+ if (len > 64) maxZ = minZ + 64.0; + if (len > 64) maxZ = minZ + 64.0;
+ this.boundingBox = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); + this.bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -1,35 +1,35 @@
--- a/net/minecraft/world/entity/EntityAgeable.java --- a/net/minecraft/world/entity/EntityAgeable.java
+++ b/net/minecraft/world/entity/EntityAgeable.java +++ b/net/minecraft/world/entity/EntityAgeable.java
@@ -17,6 +17,7 @@ @@ -19,6 +19,7 @@
protected int b; protected int age;
protected int c; protected int forcedAge;
protected int d; protected int forcedAgeTimer;
+ public boolean ageLocked; // CraftBukkit + public boolean ageLocked; // CraftBukkit
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) { protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
@@ -100,6 +101,7 @@ @@ -102,6 +103,7 @@
super.saveData(nbttagcompound); super.saveData(nbttagcompound);
nbttagcompound.setInt("Age", this.getAge()); nbttagcompound.setInt("Age", this.getAge());
nbttagcompound.setInt("ForcedAge", this.c); nbttagcompound.setInt("ForcedAge", this.forcedAge);
+ nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit + nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
} }
@Override @Override
@@ -107,6 +109,7 @@ @@ -109,6 +111,7 @@
super.loadData(nbttagcompound); super.loadData(nbttagcompound);
this.setAgeRaw(nbttagcompound.getInt("Age")); this.setAgeRaw(nbttagcompound.getInt("Age"));
this.c = nbttagcompound.getInt("ForcedAge"); this.forcedAge = nbttagcompound.getInt("ForcedAge");
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit + this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
} }
@Override @Override
@@ -121,7 +124,7 @@ @@ -123,7 +126,7 @@
@Override @Override
public void movementTick() { public void movementTick() {
super.movementTick(); super.movementTick();
- if (this.world.isClientSide) { - if (this.level.isClientSide) {
+ if (this.world.isClientSide || ageLocked) { // CraftBukkit + if (this.level.isClientSide || ageLocked) { // CraftBukkit
if (this.d > 0) { if (this.forcedAgeTimer > 0) {
if (this.d % 4 == 0) { if (this.forcedAgeTimer % 4 == 0) {
this.world.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.cF() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D); this.level.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.da() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D);

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java --- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java +++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
@@ -33,6 +33,12 @@ @@ -32,6 +32,12 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -13,19 +13,19 @@
public class EntityAreaEffectCloud extends Entity { public class EntityAreaEffectCloud extends Entity {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -124,6 +130,22 @@ @@ -127,6 +133,22 @@
} }
+ // CraftBukkit start accessor methods + // CraftBukkit start accessor methods
+ public void refreshEffects() { + public void refreshEffects() {
+ if (!this.hasColor) { + if (!this.fixedColor) {
+ this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename + this.getDataWatcher().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); // PAIL: rename
+ } + }
+ } + }
+ +
+ public String getType() { + public String getType() {
+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potionRegistry)).toString(); + return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString();
+ } + }
+ +
+ public void setType(String string) { + public void setType(String string) {
@ -34,20 +34,20 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
public int getColor() { public int getColor() {
return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR); return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.DATA_COLOR);
} }
@@ -268,6 +290,7 @@ @@ -259,6 +281,7 @@
if (!list1.isEmpty()) { if (!list1.isEmpty()) {
Iterator iterator2 = list1.iterator(); Iterator iterator1 = list1.iterator();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit + List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator2.hasNext()) { while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator2.next(); EntityLiving entityliving = (EntityLiving) iterator1.next();
@@ -277,6 +300,17 @@ @@ -268,6 +291,17 @@
double d2 = d0 * d0 + d1 * d1; double d8 = d6 * d6 + d7 * d7;
if (d2 <= (double) (f * f)) { if (d8 <= (double) (f * f)) {
+ // CraftBukkit start + // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity()); + entities.add((LivingEntity) entityliving.getBukkitEntity());
+ } + }
@ -59,15 +59,15 @@
+ if (entity instanceof CraftLivingEntity) { + if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle(); + EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end + // CraftBukkit end
this.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay); this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator3 = list.iterator(); Iterator iterator2 = list.iterator();
@@ -286,7 +320,7 @@ @@ -277,7 +311,7 @@
if (mobeffect1.getMobEffect().isInstant()) { if (mobeffect1.getMobEffect().isInstant()) {
mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D); mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else { } else {
- entityliving.addEffect(new MobEffect(mobeffect1)); - entityliving.addEffect(new MobEffect(mobeffect1), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit + entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
} }
} }

Datei anzeigen

@ -15,15 +15,15 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) { if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
if (f > 10.0F) { if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true); this.unleash(true, true);
} }
@@ -49,6 +54,7 @@ @@ -49,6 +54,7 @@
this.x(f); this.y(f);
if (f > 10.0F) { if (f > 10.0F) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit + this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.unleash(true, true); this.unleash(true, true);
this.goalSelector.a(PathfinderGoal.Type.MOVE); this.goalSelector.a(PathfinderGoal.Type.MOVE);
} else if (f > 6.0F) { } else if (f > 6.0F) {

Datei anzeigen

@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/EntityExperienceOrb.java --- a/net/minecraft/world/entity/EntityExperienceOrb.java
+++ b/net/minecraft/world/entity/EntityExperienceOrb.java +++ b/net/minecraft/world/entity/EntityExperienceOrb.java
@@ -16,6 +16,12 @@ @@ -21,6 +21,12 @@
import net.minecraft.world.level.World; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D; import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start +// CraftBukkit start
@ -12,63 +12,63 @@
+ +
public class EntityExperienceOrb extends Entity { public class EntityExperienceOrb extends Entity {
public int b; private static final int LIFETIME = 6000;
@@ -50,6 +56,7 @@ @@ -59,6 +65,7 @@
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();
+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target + EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target
if (this.d > 0) { this.xo = this.locX();
--this.d; this.yo = this.locY();
} this.zo = this.locZ();
@@ -86,7 +93,22 @@ @@ -84,7 +91,22 @@
this.targetPlayer = null; this.followingPlayer = null;
} }
- if (this.targetPlayer != null) { - if (this.followingPlayer != null) {
+ // CraftBukkit start + // CraftBukkit start
+ boolean cancelled = false; + boolean cancelled = false;
+ if (this.targetPlayer != prevTarget) { + if (this.followingPlayer != prevTarget) {
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, targetPlayer, (targetPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET); + EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, followingPlayer, (followingPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET);
+ EntityLiving target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); + EntityLiving target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
+ cancelled = event.isCancelled(); + cancelled = event.isCancelled();
+ +
+ if (cancelled) { + if (cancelled) {
+ targetPlayer = prevTarget; + followingPlayer = prevTarget;
+ } else { + } else {
+ targetPlayer = (target instanceof EntityHuman) ? (EntityHuman) target : null; + followingPlayer = (target instanceof EntityHuman) ? (EntityHuman) target : null;
+ } + }
+ } + }
+ +
+ if (this.targetPlayer != null && !cancelled) { + if (this.followingPlayer != null && !cancelled) {
+ // CraftBukkit end + // CraftBukkit end
Vec3D vec3d = new Vec3D(this.targetPlayer.locX() - this.locX(), this.targetPlayer.locY() + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY(), this.targetPlayer.locZ() - this.locZ()); Vec3D vec3d = new Vec3D(this.followingPlayer.locX() - this.locX(), this.followingPlayer.locY() + (double) this.followingPlayer.getHeadHeight() / 2.0D - this.locY(), this.followingPlayer.locZ() - this.locZ());
double d1 = vec3d.g(); double d0 = vec3d.g();
@@ -169,13 +191,19 @@ @@ -225,7 +247,7 @@
if (!itemstack.isEmpty() && itemstack.f()) { int i = this.a(entityhuman, this.value);
int i = Math.min(this.c(this.value), itemstack.getDamage());
- this.value -= this.b(i); if (i > 0) {
- itemstack.setDamage(itemstack.getDamage() - i); - entityhuman.giveExp(i);
+ // CraftBukkit start + entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i);
+ i = event.getRepairAmount();
+ if (!event.isCancelled()) {
+ this.value -= this.b(i);
+ itemstack.setDamage(itemstack.getDamage() - i);
+ }
+ // CraftBukkit end
}
} }
if (this.value > 0) { --this.count;
- entityhuman.giveExp(this.value); @@ -243,6 +265,13 @@
+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount() if (entry != null) {
} ItemStack itemstack = (ItemStack) entry.getValue();
int j = Math.min(this.c(this.value), itemstack.getDamage());
+ // CraftBukkit start
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j);
+ j = event.getRepairAmount();
+ if (event.isCancelled()) {
+ return i;
+ }
+ // CraftBukkit end
this.die(); itemstack.setDamage(itemstack.getDamage() - j);
@@ -197,6 +225,24 @@ int k = i - this.b(j);
@@ -270,6 +299,24 @@
} }
public static int getOrbValue(int i) { public static int getOrbValue(int i) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityInsentient.java --- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java +++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -74,6 +74,19 @@ @@ -72,6 +72,19 @@
import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.level.storage.loot.LootTableInfo; import net.minecraft.world.level.storage.loot.LootTableInfo;
@ -19,36 +19,27 @@
+ +
public abstract class EntityInsentient extends EntityLiving { public abstract class EntityInsentient extends EntityLiving {
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a); private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -92,7 +105,7 @@ @@ -112,6 +125,8 @@
public final float[] dropChanceHand; private BlockPosition restrictCenter;
private final NonNullList<ItemStack> bq; private float restrictRadius;
public final float[] dropChanceArmor;
- private boolean canPickUpLoot;
+ // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
public boolean persistent;
private final Map<PathType, Float> bt;
public MinecraftKey lootTableKey;
@@ -105,6 +118,8 @@
private BlockPosition bz;
private float bA;
+ public boolean aware = true; // CraftBukkit + public boolean aware = true; // CraftBukkit
+ +
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) { protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
this.bp = NonNullList.a(2, ItemStack.b); this.handItems = NonNullList.a(2, ItemStack.EMPTY);
@@ -128,6 +143,9 @@ @@ -135,6 +150,9 @@
this.initPathfinder(); this.initPathfinder();
} }
+ // CraftBukkit start - default persistance to type's persistance value + // CraftBukkit start - default persistance to type's persistance value
+ this.persistent = !isTypeNotPersistent(0); + this.persistenceRequired = !isTypeNotPersistent(0);
+ // CraftBukkit end + // CraftBukkit end
} }
protected void initPathfinder() {} protected void initPathfinder() {}
@@ -208,7 +226,38 @@ @@ -215,7 +233,38 @@
} }
public void setGoalTarget(@Nullable EntityLiving entityliving) { public void setGoalTarget(@Nullable EntityLiving entityliving) {
@ -63,14 +54,14 @@
+ reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; + reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
+ } + }
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) { + if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
+ world.getServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception()); + level.getServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
+ } + }
+ CraftLivingEntity ctarget = null; + CraftLivingEntity ctarget = null;
+ if (entityliving != null) { + if (entityliving != null) {
+ ctarget = (CraftLivingEntity) entityliving.getBukkitEntity(); + ctarget = (CraftLivingEntity) entityliving.getBukkitEntity();
+ } + }
+ EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason); + EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason);
+ world.getServer().getPluginManager().callEvent(event); + level.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return false; + return false;
+ } + }
@ -81,13 +72,13 @@
+ entityliving = null; + entityliving = null;
+ } + }
+ } + }
this.goalTarget = entityliving; this.target = entityliving;
+ return true; + return true;
+ // CraftBukkit end + // CraftBukkit end
} }
@Override @Override
@@ -425,16 +474,26 @@ @@ -442,16 +491,26 @@
nbttagcompound.setBoolean("NoAI", this.isNoAI()); nbttagcompound.setBoolean("NoAI", this.isNoAI());
} }
@ -107,16 +98,16 @@
+ } + }
} }
- this.persistent = nbttagcompound.getBoolean("PersistenceRequired"); - this.persistenceRequired = nbttagcompound.getBoolean("PersistenceRequired");
+ boolean data = nbttagcompound.getBoolean("PersistenceRequired"); + boolean data = nbttagcompound.getBoolean("PersistenceRequired");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) { + if (isLevelAtLeast(nbttagcompound, 1) || data) {
+ this.persistent = data; + this.persistenceRequired = data;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
NBTTagList nbttaglist; NBTTagList nbttaglist;
int i; int i;
@@ -481,6 +540,11 @@ @@ -498,6 +557,11 @@
} }
this.setNoAI(nbttagcompound.getBoolean("NoAI")); this.setNoAI(nbttagcompound.getBoolean("NoAI"));
@ -128,38 +119,26 @@
} }
@Override @Override
@@ -488,6 +552,11 @@ @@ -561,7 +625,7 @@
super.a(damagesource, flag);
this.lootTableKey = null;
}
+ // CraftBukkit - start
+ public MinecraftKey getLootTable() {
+ return getDefaultLootTable();
+ }
+ // CraftBukkit - end
@Override
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
@@ -544,7 +613,7 @@
protected void b(EntityItem entityitem) { protected void b(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItemStack(); ItemStack itemstack = entityitem.getItemStack();
- if (this.g(itemstack)) { - if (this.j(itemstack)) {
+ if (this.g(itemstack, entityitem)) { // CraftBukkit - add item + if (this.j(itemstack, entityitem)) { // CraftBukkit - add item
this.a(entityitem); this.a(entityitem);
this.receive(entityitem, itemstack.getCount()); this.receive(entityitem, itemstack.getCount());
entityitem.die(); entityitem.die();
@@ -553,15 +622,29 @@ @@ -570,15 +634,29 @@
} }
public boolean g(ItemStack itemstack) { public boolean j(ItemStack itemstack) {
+ // CraftBukkit start - add item + // CraftBukkit start - add item
+ return this.g(itemstack, null); + return this.j(itemstack, null);
+ } + }
+ +
+ public boolean g(ItemStack itemstack, EntityItem entityitem) { + public boolean j(ItemStack itemstack, EntityItem entityitem) {
+ // CraftBukkit end + // CraftBukkit end
EnumItemSlot enumitemslot = j(itemstack); EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = this.getEquipment(enumitemslot); ItemStack itemstack1 = this.getEquipment(enumitemslot);
boolean flag = this.a(itemstack, itemstack1); boolean flag = this.a(itemstack, itemstack1);
@ -175,18 +154,18 @@
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) { if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
+ this.forceDrops = true; // CraftBukkit + this.forceDrops = true; // CraftBukkit
this.a(itemstack1); this.b(itemstack1);
+ this.forceDrops = false; // CraftBukkit + this.forceDrops = false; // CraftBukkit
} }
this.b(enumitemslot, itemstack); this.b(enumitemslot, itemstack);
@@ -674,18 +757,18 @@ @@ -691,18 +769,18 @@
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D); EntityHuman entityhuman = this.level.findNearbyPlayer(this, -1.0D);
if (entityhuman != null) { if (entityhuman != null) {
- double d0 = entityhuman.h(this); - double d0 = entityhuman.f(this);
+ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error + double d0 = entityhuman.f((Entity) this); // CraftBukkit - decompile error
int i = this.getEntityType().e().f(); int i = this.getEntityType().f().f();
int j = i * i; int j = i * i;
- if (d0 > (double) j && this.isTypeNotPersistent(d0)) { - if (d0 > (double) j && this.isTypeNotPersistent(d0)) {
@ -194,59 +173,59 @@
this.die(); this.die();
} }
int k = this.getEntityType().e().g(); int k = this.getEntityType().f().g();
int l = k * k; int l = k * k;
- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) { - if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) {
+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check + if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
this.die(); this.die();
} else if (d0 < (double) l) { } else if (d0 < (double) l) {
this.ticksFarFromPlayer = 0; this.noActionTime = 0;
@@ -700,6 +783,7 @@ @@ -717,6 +795,7 @@
@Override @Override
protected final void doTick() { protected final void doTick() {
++this.ticksFarFromPlayer; ++this.noActionTime;
+ if (!this.aware) return; // CraftBukkit + if (!this.aware) return; // CraftBukkit
this.world.getMethodProfiler().enter("sensing"); this.level.getMethodProfiler().enter("sensing");
this.bo.a(); this.sensing.a();
this.world.getMethodProfiler().exit(); this.level.getMethodProfiler().exit();
@@ -1088,6 +1172,12 @@ @@ -1100,6 +1179,12 @@
if (!this.isAlive()) { if (!this.isAlive()) {
return EnumInteractionResult.PASS; return EnumInteractionResult.PASS;
} else if (this.getLeashHolder() == entityhuman) { } else if (this.getLeashHolder() == entityhuman) {
+ // CraftBukkit start - fire PlayerUnleashEntityEvent + // CraftBukkit start - fire PlayerUnleashEntityEvent
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) { + if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
+ return EnumInteractionResult.PASS; + return EnumInteractionResult.PASS;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.unleash(true, !entityhuman.abilities.canInstantlyBuild); this.unleash(true, !entityhuman.getAbilities().instabuild);
return EnumInteractionResult.a(this.world.isClientSide); return EnumInteractionResult.a(this.level.isClientSide);
} else { } else {
@@ -1106,6 +1196,12 @@ @@ -1118,6 +1203,12 @@
ItemStack itemstack = entityhuman.b(enumhand); ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) { if (itemstack.a(Items.LEAD) && this.a(entityhuman)) {
+ // CraftBukkit start - fire PlayerLeashEntityEvent + // CraftBukkit start - fire PlayerLeashEntityEvent
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) { + if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder())); + ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
+ return EnumInteractionResult.PASS; + return EnumInteractionResult.PASS;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.setLeashHolder(entityhuman, true); this.setLeashHolder(entityhuman, true);
itemstack.subtract(1); itemstack.subtract(1);
return EnumInteractionResult.a(this.world.isClientSide); return EnumInteractionResult.a(this.level.isClientSide);
@@ -1121,7 +1217,7 @@ @@ -1133,7 +1224,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) { if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.world instanceof WorldServer) { if (this.level instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem(); ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
- Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); - Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack);
+ Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error + Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getEntityType(), (WorldServer) this.level, this.getPositionVector(), itemstack); // CraftBukkit - decompile error
optional.ifPresent((entityinsentient) -> { optional.ifPresent((entityinsentient) -> {
this.a(entityhuman, entityinsentient); this.a(entityhuman, entityinsentient);
@@ -1167,12 +1263,19 @@ @@ -1183,12 +1274,19 @@
return this.bA != -1.0F; return this.restrictRadius != -1.0F;
} }
+ // CraftBukkit start + // CraftBukkit start
@ -258,55 +237,55 @@
+ @Nullable + @Nullable
+ public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) { + public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end + // CraftBukkit end
if (this.dead) { if (this.isRemoved()) {
return null; return null;
} else { } else {
- T t0 = (EntityInsentient) entitytypes.a(this.world); - T t0 = (EntityInsentient) entitytypes.a(this.level);
+ T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error + T t0 = entitytypes.a(this.level); // CraftBukkit - decompile error
t0.u(this); t0.s(this);
t0.setBaby(this.isBaby()); t0.setBaby(this.isBaby());
@@ -1204,7 +1307,12 @@ @@ -1220,7 +1318,12 @@
} }
} }
- this.world.addEntity(t0); - this.level.addEntity(t0);
+ // CraftBukkit start + // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) { + if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
+ return null; + return null;
+ } + }
+ this.world.addEntity(t0, spawnReason); + this.level.addEntity(t0, spawnReason);
+ // CraftBukkit end + // CraftBukkit end
if (this.isPassenger()) { if (this.isPassenger()) {
Entity entity = this.getVehicle(); Entity entity = this.getVehicle();
@@ -1224,6 +1332,7 @@ @@ -1240,6 +1343,7 @@
if (this.leashHolder != null) { if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) { if (!this.isAlive() || !this.leashHolder.isAlive()) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit + this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
this.unleash(true, true); this.unleash(true, true);
} }
@@ -1240,7 +1349,9 @@ @@ -1251,7 +1355,9 @@
this.leashHolder = null; this.leashHolder = null;
this.by = null; this.leashInfoTag = null;
if (!this.world.isClientSide && flag1) { if (!this.level.isClientSide && flag1) {
+ this.forceDrops = true; // CraftBukkit + this.forceDrops = true; // CraftBukkit
this.a((IMaterial) Items.LEAD); this.a((IMaterial) Items.LEAD);
+ this.forceDrops = false; // CraftBukkit + this.forceDrops = false; // CraftBukkit
} }
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) { if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
@@ -1290,6 +1401,7 @@ @@ -1301,6 +1407,7 @@
boolean flag1 = super.a(entity, flag); boolean flag1 = super.a(entity, flag);
if (flag1 && this.isLeashed()) { if (flag1 && this.isLeashed()) {
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.unleash(true, true); this.unleash(true, true);
} }
@@ -1422,7 +1534,14 @@ @@ -1396,7 +1503,14 @@
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this); int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
if (i > 0) { if (i > 0) {
@ -322,11 +301,15 @@
} }
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f); boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
@@ -1484,6 +1603,7 @@ @@ -1464,9 +1578,10 @@
@Override @Override
protected void bN() { protected void cc() {
super.bN(); super.cc();
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit + this.level.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.unleash(true, false); this.unleash(true, false);
this.by().forEach((itemstack) -> {
- itemstack.setCount(0);
+ if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit
});
} }
}

Datei anzeigen

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/EntityLightning.java --- a/net/minecraft/world/entity/EntityLightning.java
+++ b/net/minecraft/world/entity/EntityLightning.java +++ b/net/minecraft/world/entity/EntityLightning.java
@@ -22,6 +22,11 @@ @@ -32,6 +32,11 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.AxisAlignedBB; import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start +// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; +import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect;
@ -11,65 +11,54 @@
+ +
public class EntityLightning extends Entity { public class EntityLightning extends Entity {
private int lifeTicks; private static final int START_LIFE = 2;
@@ -62,7 +67,24 @@ @@ -132,7 +137,7 @@
this.a(4);
}
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ // CraftBukkit start - Use relative location for far away sounds
+ // this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ float pitch = 0.8F + this.random.nextFloat() * 0.2F;
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) (List) this.world.getPlayers()) {
+ double deltaX = this.locX() - player.locX();
+ double deltaZ = this.locZ() - player.locZ();
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
+ if (distanceSquared > viewDistance * viewDistance) {
+ double deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance;
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, relativeX, this.locY(), relativeZ, 10000.0F, pitch));
+ } else {
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, this.locX(), this.locY(), this.locZ(), 10000.0F, pitch));
+ }
+ }
+ // CraftBukkit end
this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
@@ -78,7 +100,7 @@
} }
} }
- if (this.lifeTicks >= 0) { - if (this.life >= 0) {
+ if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect + if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.isEffect
if (!(this.world instanceof WorldServer)) { if (!(this.level instanceof WorldServer)) {
this.world.c(2); this.level.c(2);
} else if (!this.isEffect) { } else if (!this.visualOnly) {
@@ -106,7 +128,11 @@ @@ -166,8 +171,12 @@
IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition); IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition);
if (this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) { if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) {
- this.world.setTypeUpdate(blockposition, iblockdata); - this.level.setTypeUpdate(blockposition, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!isEffect" + // CraftBukkit start - add "!isEffect"
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) { + if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) {
+ this.world.setTypeUpdate(blockposition, iblockdata); + this.level.setTypeUpdate(blockposition, iblockdata);
+ ++this.blocksSetOnFire;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
@@ -114,7 +140,11 @@ @@ -175,8 +184,12 @@
iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition1); iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition1);
if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) { if (this.level.getType(blockposition1).isAir() && iblockdata.canPlace(this.level, blockposition1)) {
- this.world.setTypeUpdate(blockposition1, iblockdata); - this.level.setTypeUpdate(blockposition1, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!isEffect" + // CraftBukkit start - add "!isEffect"
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition1, this).isCancelled()) { + if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition1, this).isCancelled()) {
+ this.world.setTypeUpdate(blockposition1, iblockdata); + this.level.setTypeUpdate(blockposition1, iblockdata);
+ ++this.blocksSetOnFire;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
} }
@@ -240,8 +253,9 @@
iblockdata = world.getType(blockposition1);
} while (!(iblockdata.getBlock() instanceof WeatheringCopper));
+ BlockPosition blockposition1Final = blockposition1; // CraftBukkit - decompile error
WeatheringCopper.b(iblockdata).ifPresent((iblockdata1) -> {
- world.setTypeUpdate(blockposition1, iblockdata1);
+ world.setTypeUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
});
world.triggerEffect(3002, blockposition1, -1);
return Optional.of(blockposition1);

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLiving.java --- a/net/minecraft/world/entity/EntityLiving.java
+++ b/net/minecraft/world/entity/EntityLiving.java +++ b/net/minecraft/world/entity/EntityLiving.java
@@ -111,6 +111,30 @@ @@ -119,6 +119,30 @@
import net.minecraft.world.scores.ScoreboardTeam; import net.minecraft.world.scores.ScoreboardTeam;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -30,11 +30,11 @@
+ +
public abstract class EntityLiving extends Entity { public abstract class EntityLiving extends Entity {
private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -196,6 +220,21 @@ @@ -227,6 +251,21 @@
private float bB; private float swimAmount;
private float bC; private float swimAmountO;
protected BehaviorController<?> bg; protected BehaviorController<?> brain;
+ // CraftBukkit start + // CraftBukkit start
+ public int expToDrop; + public int expToDrop;
+ public int maxAirTicks = 300; + public int maxAirTicks = 300;
@ -43,7 +43,7 @@
+ public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ public boolean collides = true; + public boolean collides = true;
+ public Set<UUID> collidableExemptions = new HashSet<>(); + public Set<UUID> collidableExemptions = new HashSet<>();
+ public boolean canPickUpLoot; + public boolean bukkitPickUpLoot;
+ +
+ @Override + @Override
+ public float getBukkitYaw() { + public float getBukkitYaw() {
@ -53,57 +53,59 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) { protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
@@ -207,7 +246,9 @@ @@ -239,7 +278,9 @@
this.activeItem = ItemStack.b; this.useItem = ItemStack.EMPTY;
this.by = Optional.empty(); this.lastClimbablePos = Optional.empty();
this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes)); this.attributes = new AttributeMapBase(AttributeDefaults.a(entitytypes));
- this.setHealth(this.getMaxHealth()); - this.setHealth(this.getMaxHealth());
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit + this.craftAttributes = new CraftAttributeMap(attributes); // CraftBukkit
+ // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor + // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
+ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue()); + this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue());
this.i = true; this.blocksBuilding = true;
this.az = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.af(); this.ah();
@@ -274,7 +315,13 @@ @@ -306,7 +347,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1); int i = (int) (150.0D * d1);
- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); - ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ // CraftBukkit start - visiblity api + // CraftBukkit start - visiblity api
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false); + ((WorldServer) this.level).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
+ } else { + } else {
+ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); + ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
} }
@@ -496,7 +543,7 @@ @@ -566,7 +613,7 @@
protected void cU() { protected void dB() {
++this.deathTicks; ++this.deathTime;
- if (this.deathTicks == 20) { - if (this.deathTime == 20 && !this.level.isClientSide()) {
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead) + if (this.deathTime >= 20 && !this.isRemoved() && !this.level.isClientSide()) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
this.die(); this.level.broadcastEntityEffect(this, (byte) 60);
this.a(Entity.RemovalReason.KILLED);
for (int i = 0; i < 20; ++i) { }
@@ -587,7 +634,13 @@ @@ -658,9 +705,15 @@
} }
protected void playEquipSound(ItemStack itemstack) { protected void playEquipSound(ItemStack itemstack) {
- if (!itemstack.isEmpty()) {
+ // CraftBukkit start + // CraftBukkit start
+ this.playEquipSound(itemstack, false); + this.playEquipSound(itemstack, false);
+ } + }
+ +
+ protected void playEquipSound(ItemStack itemstack, boolean silent) { + protected void playEquipSound(ItemStack itemstack, boolean silent) {
+ if (!itemstack.isEmpty() && !silent) { SoundEffect soundeffect = itemstack.M();
+ // CraftBukkit end
SoundEffect soundeffect = SoundEffects.ITEM_ARMOR_EQUIP_GENERIC;
Item item = itemstack.getItem();
@@ -657,6 +710,17 @@ - if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator()) {
+ if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator() && !silent) {
+ // CraftBukkit end
this.a(GameEvent.EQUIP);
this.playSound(soundeffect, 1.0F, 1.0F);
}
@@ -722,6 +775,17 @@
} }
} }
@ -121,7 +123,7 @@
if (nbttagcompound.hasKeyOfType("Health", 99)) { if (nbttagcompound.hasKeyOfType("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health")); this.setHealth(nbttagcompound.getFloat("Health"));
} }
@@ -694,9 +758,32 @@ @@ -759,9 +823,32 @@
} }
@ -148,16 +150,16 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
protected void tickPotionEffects() { protected void tickPotionEffects() {
Iterator iterator = this.effects.keySet().iterator(); Iterator iterator = this.activeEffects.keySet().iterator();
+ isTickingEffects = true; // CraftBukkit + isTickingEffects = true; // CraftBukkit
try { try {
while (iterator.hasNext()) { while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next(); MobEffectList mobeffectlist = (MobEffectList) iterator.next();
@@ -706,6 +793,12 @@ @@ -771,6 +858,12 @@
this.a(mobeffect, true); this.a(mobeffect, true, (Entity) null);
})) { })) {
if (!this.world.isClientSide) { if (!this.level.isClientSide) {
+ // CraftBukkit start + // CraftBukkit start
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
@ -165,9 +167,9 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
iterator.remove(); iterator.remove();
this.b(mobeffect); this.a(mobeffect);
} }
@@ -716,6 +809,17 @@ @@ -781,6 +874,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) { } catch (ConcurrentModificationException concurrentmodificationexception) {
; ;
} }
@ -183,10 +185,10 @@
+ effectsToProcess.clear(); + effectsToProcess.clear();
+ // CraftBukkit end + // CraftBukkit end
if (this.updateEffects) { if (this.effectsDirty) {
if (!this.world.isClientSide) { if (!this.level.isClientSide) {
@@ -825,7 +929,13 @@ @@ -907,7 +1011,13 @@
this.datawatcher.set(EntityLiving.f, 0); this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0);
} }
+ // CraftBukkit start + // CraftBukkit start
@ -196,45 +198,49 @@
+ +
+ public boolean removeAllEffects(EntityPotionEffectEvent.Cause cause) { + public boolean removeAllEffects(EntityPotionEffectEvent.Cause cause) {
+ // CraftBukkit end + // CraftBukkit end
if (this.world.isClientSide) { if (this.level.isClientSide) {
return false; return false;
} else { } else {
@@ -834,7 +944,14 @@ @@ -916,7 +1026,14 @@
boolean flag; boolean flag;
for (flag = false; iterator.hasNext(); flag = true) { for (flag = false; iterator.hasNext(); flag = true) {
- this.b((MobEffect) iterator.next()); - this.a((MobEffect) iterator.next());
+ // CraftBukkit start + // CraftBukkit start
+ MobEffect effect = (MobEffect) iterator.next(); + MobEffect effect = (MobEffect) iterator.next();
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED); + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ continue; + continue;
+ } + }
+ this.b(effect); + this.a(effect);
+ // CraftBukkit end + // CraftBukkit end
iterator.remove(); iterator.remove();
} }
@@ -859,18 +976,44 @@ @@ -945,18 +1062,48 @@
return (MobEffect) this.effects.get(mobeffectlist); return this.addEffect(mobeffect, (Entity) null);
} }
+ // CraftBukkit start + // CraftBukkit start
public boolean addEffect(MobEffect mobeffect) { + public boolean addEffect(MobEffect mobeffect, EntityPotionEffectEvent.Cause cause) {
+ return addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + return this.addEffect(mobeffect, (Entity) null, cause);
+ } + }
+ +
+ public boolean addEffect(MobEffect mobeffect, EntityPotionEffectEvent.Cause cause) { public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity) {
+ return this.addEffect(mobeffect, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
+ }
+
+ public boolean addEffect(MobEffect mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause) {
+ if (isTickingEffects) { + if (isTickingEffects) {
+ effectsToProcess.add(new ProcessableEffect(mobeffect, cause)); + effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
+ return true; + return true;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
if (!this.d(mobeffect)) { if (!this.c(mobeffect)) {
return false; return false;
} else { } else {
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getMobEffect());
+ // CraftBukkit start + // CraftBukkit start
+ boolean override = false; + boolean override = false;
@ -249,19 +255,19 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
if (mobeffect1 == null) { if (mobeffect1 == null) {
this.effects.put(mobeffect.getMobEffect(), mobeffect); this.activeEffects.put(mobeffect.getMobEffect(), mobeffect);
this.a(mobeffect); this.a(mobeffect, entity);
return true; return true;
- } else if (mobeffect1.b(mobeffect)) { - } else if (mobeffect1.b(mobeffect)) {
+ // CraftBukkit start + // CraftBukkit start
+ } else if (event.isOverride()) { + } else if (event.isOverride()) {
+ mobeffect1.b(mobeffect); + mobeffect1.b(mobeffect);
this.a(mobeffect1, true); this.a(mobeffect1, true, entity);
+ // CraftBukkit end + // CraftBukkit end
return true; return true;
} else { } else {
return false; return false;
@@ -894,13 +1037,39 @@ @@ -993,13 +1140,39 @@
return this.getMonsterType() == EnumMonsterType.UNDEAD; return this.getMonsterType() == EnumMonsterType.UNDEAD;
} }
@ -278,7 +284,7 @@
+ return null; + return null;
+ } + }
+ +
+ MobEffect effect = this.effects.get(mobeffectlist); + MobEffect effect = this.activeEffects.get(mobeffectlist);
+ if (effect == null) { + if (effect == null) {
+ return null; + return null;
+ } + }
@ -288,7 +294,7 @@
+ return null; + return null;
+ } + }
+ +
return (MobEffect) this.effects.remove(mobeffectlist); return (MobEffect) this.activeEffects.remove(mobeffectlist);
} }
public boolean removeEffect(MobEffectList mobeffectlist) { public boolean removeEffect(MobEffectList mobeffectlist) {
@ -301,8 +307,8 @@
+ // CraftBukkit end + // CraftBukkit end
if (mobeffect != null) { if (mobeffect != null) {
this.b(mobeffect); this.a(mobeffect);
@@ -937,20 +1106,55 @@ @@ -1036,20 +1209,55 @@
} }
@ -319,7 +325,7 @@
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason); + EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
+ // Suppress during worldgen + // Suppress during worldgen
+ if (this.valid) { + if (this.valid) {
+ this.world.getServer().getPluginManager().callEvent(event); + this.level.getServer().getPluginManager().callEvent(event);
+ } + }
+ +
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
@ -336,7 +342,7 @@
+ return (float) ((EntityPlayer) this).getBukkitEntity().getHealth(); + return (float) ((EntityPlayer) this).getBukkitEntity().getHealth();
+ } + }
+ // CraftBukkit end + // CraftBukkit end
return (Float) this.datawatcher.get(EntityLiving.HEALTH); return (Float) this.entityData.get(EntityLiving.DATA_HEALTH_ID);
} }
public void setHealth(float f) { public void setHealth(float f) {
@ -356,31 +362,22 @@
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth())); this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.a(f, 0.0F, this.getMaxHealth()));
} }
@@ -964,7 +1168,7 @@ @@ -1063,7 +1271,7 @@
return false; return false;
} else if (this.world.isClientSide) { } else if (this.level.isClientSide) {
return false; return false;
- } else if (this.dl()) { - } else if (this.dV()) {
+ } else if (this.dead || this.killed || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die + } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die
return false; return false;
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { } else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false; return false;
@@ -976,17 +1180,19 @@ @@ -1074,10 +1282,11 @@
this.ticksFarFromPlayer = 0;
this.noActionTime = 0;
float f1 = f; float f1 = f;
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this, (entityliving) -> {
entityliving.broadcastItemBreak(EnumItemSlot.HEAD);
});
f *= 0.75F;
}
- boolean flag = false; - boolean flag = false;
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below + boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
float f2 = 0.0F; float f2 = 0.0F;
@ -391,38 +388,45 @@
this.damageShield(f); this.damageShield(f);
f2 = f; f2 = f;
f = 0.0F; f = 0.0F;
@@ -1004,22 +1210,41 @@ @@ -1095,27 +1304,47 @@
this.av = 1.5F; this.animationSpeed = 1.5F;
boolean flag1 = true; boolean flag1 = true;
- if ((float) this.noDamageTicks > 10.0F) { - if ((float) this.invulnerableTime > 10.0F) {
+ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks + if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks
if (f <= this.lastDamage) { if (f <= this.lastHurt) {
+ this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback + this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback
return false; return false;
} }
- this.damageEntity0(damagesource, f - this.lastDamage); - this.damageEntity0(damagesource, f - this.lastHurt);
+ // CraftBukkit start + // CraftBukkit start
+ if (!this.damageEntity0(damagesource, f - this.lastDamage)) { + if (!this.damageEntity0(damagesource, f - this.lastHurt)) {
+ return false; + return false;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.lastDamage = f; this.lastHurt = f;
flag1 = false; flag1 = false;
} else { } else {
+ // CraftBukkit start + // CraftBukkit start
+ if (!this.damageEntity0(damagesource, f)) { + if (!this.damageEntity0(damagesource, f)) {
+ return false; + return false;
+ } + }
this.lastDamage = f; this.lastHurt = f;
- this.noDamageTicks = 20; - this.invulnerableTime = 20;
- this.damageEntity0(damagesource, f); - this.damageEntity0(damagesource, f);
+ this.noDamageTicks = this.maxNoDamageTicks; // CraftBukkit - restore use of maxNoDamageTicks + this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks
+ // this.damageEntity0(damagesource, f); + // this.damageEntity0(damagesource, f);
+ // CraftBukkit end + // CraftBukkit end
this.hurtDuration = 10; this.hurtDuration = 10;
this.hurtTicks = this.hurtDuration; this.hurtTime = this.hurtDuration;
}
- if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
+ if (false && damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
this.damageHelmet(damagesource, f);
f *= 0.75F;
} }
+ // CraftBukkit start + // CraftBukkit start
@ -434,21 +438,21 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ +
this.ap = 0.0F; this.hurtDir = 0.0F;
Entity entity1 = damagesource.getEntity(); Entity entity1 = damagesource.getEntity();
@@ -1140,19 +1365,29 @@ @@ -1238,19 +1467,29 @@
EnumHand[] aenumhand = EnumHand.values(); EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length; int i = aenumhand.length;
+ // CraftBukkit start + // CraftBukkit start
+ ItemStack itemstack1 = ItemStack.b; + ItemStack itemstack1 = ItemStack.EMPTY;
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
EnumHand enumhand = aenumhand[j]; EnumHand enumhand = aenumhand[j];
- ItemStack itemstack1 = this.b(enumhand); - ItemStack itemstack1 = this.b(enumhand);
+ itemstack1 = this.b(enumhand); + itemstack1 = this.b(enumhand);
if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) { if (itemstack1.a(Items.TOTEM_OF_UNDYING)) {
itemstack = itemstack1.cloneItemStack(); itemstack = itemstack1.cloneItemStack();
- itemstack1.subtract(1); - itemstack1.subtract(1);
+ // itemstack1.subtract(1); // CraftBukkit + // itemstack1.subtract(1); // CraftBukkit
@ -460,7 +464,7 @@
- if (this instanceof EntityPlayer) { - if (this instanceof EntityPlayer) {
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity()); + EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
+ event.setCancelled(itemstack == null); + event.setCancelled(itemstack == null);
+ this.world.getServer().getPluginManager().callEvent(event); + this.level.getServer().getPluginManager().callEvent(event);
+ +
+ if (!event.isCancelled()) { + if (!event.isCancelled()) {
+ if (!itemstack1.isEmpty()) { + if (!itemstack1.isEmpty()) {
@ -471,21 +475,21 @@
EntityPlayer entityplayer = (EntityPlayer) this; EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING)); entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
@@ -1160,14 +1395,16 @@ @@ -1258,14 +1497,16 @@
} }
this.setHealth(1.0F); this.setHealth(1.0F);
- this.removeAllEffects(); - this.removeAllEffects();
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1)); - this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1));
- this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1)); - this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1));
- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0)); - this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0));
+ // CraftBukkit start + // CraftBukkit start
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); + this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ // CraftBukkit end + // CraftBukkit end
this.world.broadcastEntityEffect(this, (byte) 35); this.level.broadcastEntityEffect(this, (byte) 35);
} }
- return itemstack != null; - return itemstack != null;
@ -493,9 +497,9 @@
} }
} }
@@ -1265,6 +1502,13 @@ @@ -1374,6 +1615,13 @@
if (!flag) { if (!flag) {
EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.bt)); EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.WITHER_ROSE));
+ // CraftBukkit start + // CraftBukkit start
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
@ -504,15 +508,15 @@
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.world.addEntity(entityitem); this.level.addEntity(entityitem);
} }
} }
@@ -1284,28 +1528,46 @@ @@ -1393,21 +1641,40 @@
boolean flag = this.lastDamageByPlayerTime > 0; boolean flag = this.lastHurtByPlayerTime > 0;
+ this.dropInventory(); // CraftBukkit - from below + this.dropInventory(); // CraftBukkit - from below
if (this.cW() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { if (this.dD() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.a(damagesource, flag); this.a(damagesource, flag);
this.dropDeathLoot(damagesource, i, flag); this.dropDeathLoot(damagesource, i, flag);
} }
@ -531,48 +535,43 @@
- protected void dropExperience() { - protected void dropExperience() {
+ // CraftBukkit start + // CraftBukkit start
+ public int getExpReward() { + public int getExpReward() {
if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) { if (this.level instanceof WorldServer && (this.alwaysGivesExp() || this.lastHurtByPlayerTime > 0 && this.isDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
int i = this.getExpValue(this.killer); - EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.getExpValue(this.lastHurtByPlayer));
+ int i = this.getExpValue(this.lastHurtByPlayer);
+ return i; + return i;
+ } else { + } else {
+ return 0; + return 0;
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
+ protected void dropExperience() { + protected void dropExperience() {
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes! + // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ if (true) { + if (true) {
+ int i = this.expToDrop; + EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.expToDrop);
while (i > 0) {
int j = EntityExperienceOrb.getOrbValue(i);
i -= j;
this.world.addEntity(new EntityExperienceOrb(this.world, this.locX(), this.locY(), this.locZ(), j));
}
+ this.expToDrop = 0; + this.expToDrop = 0;
} }
+ // CraftBukkit end + // CraftBukkit end
} }
@@ -1426,9 +1688,14 @@ @@ -1523,9 +1790,14 @@
int i = this.e(f, f1); int i = this.d(f, f1);
if (i > 0) { if (i > 0) {
+ // CraftBukkit start + // CraftBukkit start
+ if (!this.damageEntity(DamageSource.FALL, (float) i)) { + if (!this.damageEntity(damagesource, (float) i)) {
+ return true; + return true;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.playSound(this.getSoundFall(i), 1.0F, 1.0F); this.playSound(this.getSoundFall(i), 1.0F, 1.0F);
this.playBlockStepSound(); this.playBlockStepSound();
- this.damageEntity(DamageSource.FALL, (float) i); - this.damageEntity(damagesource, (float) i);
+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up + // this.damageEntity(damagesource, (float) i); // CraftBukkit - moved up
return true; return true;
} else { } else {
return flag; return flag;
@@ -1468,7 +1735,7 @@ @@ -1574,7 +1846,7 @@
protected float applyArmorModifier(DamageSource damagesource, float f) { protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) { if (!damagesource.ignoresArmor()) {
@ -581,17 +580,17 @@
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS));
} }
@@ -1481,7 +1748,8 @@ @@ -1587,7 +1859,8 @@
} else { } else {
int i; int i;
- if (this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { - if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
+ // CraftBukkit - Moved to damageEntity0(DamageSource, float) + // CraftBukkit - Moved to damageEntity0(DamageSource, float)
+ if (false && this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { + if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i; int j = 25 - i;
float f1 = f * (float) j; float f1 = f * (float) j;
@@ -1512,28 +1780,173 @@ @@ -1618,29 +1891,172 @@
} }
} }
@ -608,7 +607,7 @@
+ Function<Double, Double> hardHat = new Function<Double, Double>() { + Function<Double, Double> hardHat = new Function<Double, Double>() {
+ @Override + @Override
+ public Double apply(Double f) { + public Double apply(Double f) {
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { + if (damagesource.g() && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ return -(f - (f * 0.75F)); + return -(f - (f * 0.75F));
+ +
+ } + }
@ -639,8 +638,8 @@
+ Function<Double, Double> resistance = new Function<Double, Double>() { + Function<Double, Double> resistance = new Function<Double, Double>() {
+ @Override + @Override
+ public Double apply(Double f) { + public Double apply(Double f) {
+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { + if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
+ int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; + int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
+ int j = 25 - i; + int j = 25 - i;
+ float f1 = f.floatValue() * (float) j; + float f1 = f.floatValue() * (float) j;
+ return -(f - (f1 / 25.0F)); + return -(f - (f1 / 25.0F));
@ -675,9 +674,12 @@
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return false; + return false;
+ } + }
+
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- float f2 = f1 - f;
+ f = (float) event.getFinalDamage(); + f = (float) event.getFinalDamage();
+
+ // Resistance + // Resistance
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) { + if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE); + float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
@ -689,15 +691,10 @@
+ } + }
+ } + }
+ } + }
+
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
- float f2 = f1 - f;
+ // Apply damage to helmet + // Apply damage to helmet
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) { + if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
+ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this, (entityliving) -> { + this.damageHelmet(damagesource, f);
+ entityliving.broadcastItemBreak(EnumItemSlot.HEAD);
+ });
+ } + }
+ +
+ // Apply damage to armor + // Apply damage to armor
@ -705,12 +702,12 @@
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
+ this.damageArmor(damagesource, armorDamage); + this.damageArmor(damagesource, armorDamage);
+ } + }
+
+ // Apply blocking code // PAIL: steal from above + // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) { + if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound + this.level.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING)); + this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
+ Entity entity = damagesource.j(); + Entity entity = damagesource.k();
+ +
+ if (entity instanceof EntityLiving) { + if (entity instanceof EntityLiving) {
+ this.shieldBlock((EntityLiving) entity); + this.shieldBlock((EntityLiving) entity);
@ -747,13 +744,14 @@
+ if (!human) { + if (!human) {
+ this.setAbsorptionHearts(this.getAbsorptionHearts() - f); + this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
+ } + }
this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
+ +
+ return true; + return true;
+ } else { + } else {
+ // Duplicate triggers if blocking + // Duplicate triggers if blocking
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) { + if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ CriterionTriggers.h.a((EntityPlayer) this, damagesource, f, originalDamage, true); + CriterionTriggers.ENTITY_HURT_PLAYER.a((EntityPlayer) this, damagesource, f, originalDamage, true);
+ f2 = (float) -event.getDamage(DamageModifier.BLOCKING); + f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
+ if (f2 > 0.0F && f2 < 3.4028235E37F) { + if (f2 > 0.0F && f2 < 3.4028235E37F) {
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F)); + ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
@ -761,7 +759,7 @@
+ } + }
+ +
+ if (damagesource.getEntity() instanceof EntityPlayer) { + if (damagesource.getEntity() instanceof EntityPlayer) {
+ CriterionTriggers.g.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true); + CriterionTriggers.PLAYER_HURT_ENTITY.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true);
+ } + }
+ +
+ return false; + return false;
@ -775,28 +773,27 @@
} }
public CombatTracker getCombatTracker() { public CombatTracker getCombatTracker() {
@@ -1554,9 +1967,19 @@ @@ -1661,8 +2077,18 @@
} }
public final void setArrowCount(int i) { public final void setArrowCount(int i) {
- this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, i); - this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, i);
+ // CraftBukkit start + // CraftBukkit start
+ setArrowCount(i, false); + setArrowCount(i, false);
} + }
+
+ public final void setArrowCount(int i, boolean flag) { + public final void setArrowCount(int i, boolean flag) {
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, getArrowCount(), i, flag); + ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, getArrowCount(), i, flag);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, event.getNewAmount()); + this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, event.getNewAmount());
+ }
+ // CraftBukkit end
+
public final int dz() {
return (Integer) this.datawatcher.get(EntityLiving.bi);
} }
@@ -1684,6 +2107,12 @@ + // CraftBukkit end
public final int eh() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
@@ -1958,6 +2384,12 @@
public abstract ItemStack getEquipment(EnumItemSlot enumitemslot); public abstract ItemStack getEquipment(EnumItemSlot enumitemslot);
@ -809,64 +806,57 @@
@Override @Override
public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack); public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -1906,6 +2335,7 @@ @@ -2202,6 +2634,7 @@
} }
if (this.onGround && !this.world.isClientSide) { if (this.onGround && !this.level.isClientSide) {
+ if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit + if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
this.setFlag(7, false); this.setFlag(7, false);
} }
} else { } else {
@@ -2411,6 +2841,7 @@ @@ -2732,6 +3165,7 @@
} }
if (!this.world.isClientSide) { if (!this.level.isClientSide) {
+ if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit + if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
this.setFlag(7, flag); this.setFlag(7, flag);
} }
@@ -2531,6 +2962,7 @@ @@ -2899,14 +3333,21 @@
}
public boolean hasLineOfSight(Entity entity) {
+ if (this.world != entity.world) return false; // CraftBukkit - SPIGOT-5675, SPIGOT-5798, MC-149563
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
@@ -2548,13 +2980,20 @@
@Override @Override
public boolean isInteractable() { public boolean isInteractable() {
- return !this.dead; - return !this.isRemoved();
+ return !this.dead && this.collides; // CraftBukkit + return !this.isRemoved() && this.collides; // CraftBukkit
} }
@Override @Override
public boolean isCollidable() { public boolean isCollidable() {
- return this.isAlive() && !this.isSpectator() && !this.isClimbing(); - return this.isAlive() && !this.isSpectator() && !this.isClimbing();
+ return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit + return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit
+ } }
+
+ // CraftBukkit start - collidable API + // CraftBukkit start - collidable API
+ @Override + @Override
+ public boolean canCollideWith(Entity entity) { + public boolean canCollideWithBukkit(Entity entity) {
+ return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID()); + return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID());
} + }
+ // CraftBukkit end + // CraftBukkit end
+
@Override @Override
protected void velocityChanged() { protected void velocityChanged() {
@@ -2748,7 +3187,25 @@ this.hurtMarked = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE);
@@ -3104,7 +3545,25 @@
} else { } else {
if (!this.activeItem.isEmpty() && this.isHandRaised()) { if (!this.useItem.isEmpty() && this.isHandRaised()) {
this.b(this.activeItem, 16); this.b(this.useItem, 16);
- ItemStack itemstack = this.activeItem.a(this.world, this); - ItemStack itemstack = this.useItem.a(this.level, this);
+ // CraftBukkit start - fire PlayerItemConsumeEvent + // CraftBukkit start - fire PlayerItemConsumeEvent
+ ItemStack itemstack; + ItemStack itemstack;
+ if (this instanceof EntityPlayer) { + if (this instanceof EntityPlayer) {
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem); + org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); + PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
+ world.getServer().getPluginManager().callEvent(event); + level.getServer().getPluginManager().callEvent(event);
+ +
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ // Update client + // Update client
@ -875,15 +865,15 @@
+ return; + return;
+ } + }
+ +
+ itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this); + itemstack = (craftItem.equals(event.getItem())) ? this.useItem.a(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).a(level, this);
+ } else { + } else {
+ itemstack = this.activeItem.a(this.world, this); + itemstack = this.useItem.a(this.level, this);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
if (itemstack != this.activeItem) { if (itemstack != this.useItem) {
this.a(enumhand, itemstack); this.a(enumhand, itemstack);
@@ -2816,6 +3273,12 @@ @@ -3176,6 +3635,12 @@
} }
public boolean a(double d0, double d1, double d2, boolean flag) { public boolean a(double d0, double d1, double d2, boolean flag) {
@ -896,7 +886,7 @@
double d3 = this.locX(); double d3 = this.locX();
double d4 = this.locY(); double d4 = this.locY();
double d5 = this.locZ(); double d5 = this.locZ();
@@ -2840,16 +3303,41 @@ @@ -3200,16 +3665,41 @@
} }
if (flag2) { if (flag2) {
@ -914,8 +904,8 @@
+ +
+ if (flag1) { + if (flag1) {
+ if (!(this instanceof EntityPlayer)) { + if (!(this instanceof EntityPlayer)) {
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), d0, d6, d2)); + EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level.getWorld(), d3, d4, d5), new Location(this.level.getWorld(), d0, d6, d2));
+ this.world.getServer().getPluginManager().callEvent(teleport); + this.level.getServer().getPluginManager().callEvent(teleport);
+ if (!teleport.isCancelled()) { + if (!teleport.isCancelled()) {
+ Location to = teleport.getTo(); + Location to = teleport.getTo();
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); + this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
@ -924,7 +914,7 @@
+ } + }
+ } else { + } else {
+ // player teleport event is called in the underlining code + // player teleport event is called in the underlining code
+ if (((EntityPlayer) this).playerConnection.a(d0, d6, d2, this.yaw, this.pitch, java.util.Collections.emptySet(), cause)) { + if (((EntityPlayer) this).connection.a(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) {
+ return Optional.empty(); + return Optional.empty();
+ } + }
+ } + }
@ -941,7 +931,7 @@
} else { } else {
if (flag) { if (flag) {
world.broadcastEntityEffect(this, (byte) 46); world.broadcastEntityEffect(this, (byte) 46);
@@ -2859,7 +3347,7 @@ @@ -3219,7 +3709,7 @@
((EntityCreature) this).getNavigation().o(); ((EntityCreature) this).getNavigation().o();
} }
@ -950,16 +940,25 @@
} }
} }
@@ -2940,7 +3428,7 @@ @@ -3302,7 +3792,7 @@
} }
public void entityWakeup() { public void entityWakeup() {
- Optional optional = this.getBedPosition(); - Optional optional = this.getBedPosition();
+ Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error + Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error
World world = this.world; World world = this.level;
this.world.getClass(); java.util.Objects.requireNonNull(this.level);
@@ -3011,7 +3499,7 @@ @@ -3334,7 +3824,7 @@
@Nullable
public EnumDirection eW() {
- BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse((Object) null);
+ BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse(null); // CraftBukkit - decompile error
return blockposition != null ? BlockBed.a((IBlockAccess) this.level, blockposition) : null;
}
@@ -3383,7 +3873,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next(); Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {

Datei anzeigen

@ -1,24 +1,24 @@
--- a/net/minecraft/world/entity/EntityTypes.java --- a/net/minecraft/world/entity/EntityTypes.java
+++ b/net/minecraft/world/entity/EntityTypes.java +++ b/net/minecraft/world/entity/EntityTypes.java
@@ -142,7 +142,7 @@ @@ -152,7 +152,7 @@
public class EntityTypes<T extends Entity> {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
public static final String ENTITY_TAG = "EntityTag";
private static final float MAGIC_HORSE_WIDTH = 1.3964844F;
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE)); - public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE));
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds + public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10)); public static final EntityTypes<EntityArmorStand> ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20)); public static final EntityTypes<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20));
public static final EntityTypes<EntityBat> BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5)); public static final EntityTypes<Axolotl> AXOLOTL = a("axolotl", EntityTypes.Builder.a(Axolotl::new, EnumCreatureType.UNDERGROUND_WATER_CREATURE).a(0.75F, 0.42F).trackingRange(10));
@@ -267,7 +267,7 @@ @@ -282,7 +282,7 @@
private MinecraftKey bq; private MinecraftKey lootTable;
private final EntitySize br; private final EntitySize dimensions;
- private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder<T> entitytypes_builder) { - private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder<T> entitytypes_builder) {
+ private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error + private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s)); return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
} }
@@ -299,10 +299,18 @@ @@ -314,10 +314,18 @@
@Nullable @Nullable
public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) { public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
@ -33,12 +33,12 @@
if (t0 != null) { if (t0 != null) {
- worldserver.addAllEntities(t0); - worldserver.addAllEntities(t0);
+ worldserver.addAllEntities(t0, spawnReason); + worldserver.addAllEntities(t0, spawnReason);
+ return !t0.dead ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled + return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
+ // CraftBukkit end + // CraftBukkit end
} }
return t0; return t0;
@@ -338,7 +346,7 @@ @@ -353,7 +361,7 @@
t0.setCustomName(ichatbasecomponent); t0.setCustomName(ichatbasecomponent);
} }
@ -47,7 +47,7 @@
return t0; return t0;
} }
} }
@@ -481,7 +489,7 @@ @@ -512,7 +520,7 @@
} }
return entity; return entity;
@ -55,9 +55,18 @@
+ }).orElse(null); // CraftBukkit - decompile error + }).orElse(null); // CraftBukkit - decompile error
} }
private static Optional<Entity> b(NBTTagCompound nbttagcompound, World world) { public static Stream<Entity> a(final List<? extends NBTBase> list, final World world) {
@@ -533,7 +541,7 @@ @@ -569,7 +577,7 @@
this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
@Nullable
public T a(Entity entity) {
- return entity.getEntityType() == this ? entity : null;
+ return entity.getEntityType() == this ? (T) entity : null; // CraftBukkit - decompile error
}
@Override
@@ -596,7 +604,7 @@
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
} }
- public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) { - public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) {

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/IEntityAngerable.java --- a/net/minecraft/world/entity/IEntityAngerable.java
+++ b/net/minecraft/world/entity/IEntityAngerable.java +++ b/net/minecraft/world/entity/IEntityAngerable.java
@@ -103,7 +103,7 @@ @@ -108,7 +108,7 @@
default void pacify() { default void pacify() {
this.setLastDamager((EntityLiving) null); this.setLastDamager((EntityLiving) null);
this.setAngerTarget((UUID) null); this.setAngerTarget((UUID) null);
@ -9,12 +9,12 @@
this.setAnger(0); this.setAnger(0);
} }
@@ -113,6 +113,8 @@ @@ -121,6 +121,8 @@
void setGoalTarget(@Nullable EntityLiving entityliving); void setGoalTarget(@Nullable EntityLiving entityliving);
+ boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit + boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit
+ +
boolean c(EntityLiving entityliving);
@Nullable @Nullable
EntityLiving getGoalTarget();
}

Datei anzeigen

@ -3,9 +3,9 @@
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule(); ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule();
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.g.and((entity1) -> { return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> {
- if (!entity1.isCollidable()) { - if (!entity1.isCollidable()) {
+ if (!entity1.canCollideWith(entity) || !entity.canCollideWith(entity1)) { // CraftBukkit - collidable API + if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API
return false; return false;
} else if (entity.world.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).ez())) { } else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).fh())) {
return false; return false;

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen