geforkt von Mirrors/Paper
Update to Minecraft 1.18-pre5
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
a852b81a69
Commit
43702a9e10
@ -4,7 +4,7 @@
|
||||
public CrashReport(String s, Throwable throwable) {
|
||||
this.title = s;
|
||||
this.exception = throwable;
|
||||
+ this.systemReport.a("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
|
||||
+ this.systemReport.setDetail("CraftBukkit Information", new org.bukkit.craftbukkit.CraftCrashReport()); // CraftBukkit
|
||||
}
|
||||
|
||||
public String a() {
|
||||
public String getTitle() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/advancements/Advancement.java
|
||||
+++ b/net/minecraft/advancements/Advancement.java
|
||||
@@ -39,6 +39,7 @@
|
||||
@@ -41,6 +41,7 @@
|
||||
private final String[][] requirements;
|
||||
private final Set<Advancement> children = Sets.newLinkedHashSet();
|
||||
private final IChatBaseComponent chatComponent;
|
||||
@ -8,12 +8,3 @@
|
||||
|
||||
public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring) {
|
||||
this.id = minecraftkey;
|
||||
@@ -233,7 +234,7 @@
|
||||
}
|
||||
|
||||
public Advancement b(MinecraftKey minecraftkey) {
|
||||
- if (!this.a((minecraftkey1) -> {
|
||||
+ if (!this.a((Function<MinecraftKey, Advancement>) (minecraftkey1) -> { // CraftBukkit - decompile error
|
||||
return null;
|
||||
})) {
|
||||
throw new IllegalStateException("Tried to build incomplete advancement!");
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/advancements/Advancements.java
|
||||
+++ b/net/minecraft/advancements/Advancements.java
|
||||
@@ -79,7 +79,7 @@
|
||||
@@ -80,7 +80,7 @@
|
||||
entry = (Entry) iterator.next();
|
||||
MinecraftKey minecraftkey = (MinecraftKey) entry.getKey();
|
||||
Advancement.SerializedAdvancement advancement_serializedadvancement = (Advancement.SerializedAdvancement) entry.getValue();
|
||||
@ -8,8 +8,8 @@
|
||||
+ Map<MinecraftKey, Advancement> map1 = this.advancements; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(this.advancements);
|
||||
if (advancement_serializedadvancement.a(map1::get)) {
|
||||
@@ -116,7 +116,7 @@
|
||||
if (advancement_serializedadvancement.canBuild(map1::get)) {
|
||||
@@ -117,7 +117,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,4 +17,4 @@
|
||||
+ // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload
|
||||
}
|
||||
|
||||
public void a() {
|
||||
public void clear() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/commands/CommandDispatcher.java
|
||||
+++ b/net/minecraft/commands/CommandDispatcher.java
|
||||
@@ -103,6 +103,14 @@
|
||||
@@ -106,6 +106,14 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -15,32 +15,32 @@
|
||||
public class CommandDispatcher {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -114,6 +122,7 @@
|
||||
@@ -117,6 +125,7 @@
|
||||
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
|
||||
|
||||
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) {
|
||||
+ this(); // CraftBukkit
|
||||
CommandAdvancement.a(this.dispatcher);
|
||||
CommandAttribute.a(this.dispatcher);
|
||||
CommandExecute.a(this.dispatcher);
|
||||
@@ -195,17 +204,61 @@
|
||||
CommandAdvancement.register(this.dispatcher);
|
||||
CommandAttribute.register(this.dispatcher);
|
||||
CommandExecute.register(this.dispatcher);
|
||||
@@ -202,17 +211,63 @@
|
||||
}
|
||||
|
||||
this.dispatcher.findAmbiguities((commandnode, commandnode1, 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.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); // CraftBukkit
|
||||
});
|
||||
- this.dispatcher.setConsumer((commandcontext, flag, i) -> {
|
||||
- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
|
||||
+ // CraftBukkit start
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public CommandDispatcher() {
|
||||
+ this.dispatcher.setConsumer((commandcontext, flag1, i) -> {
|
||||
+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
|
||||
+ // CraftBukkkit end
|
||||
this.dispatcher.setConsumer((commandcontext, flag, i) -> {
|
||||
((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i);
|
||||
});
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public int dispatchServerCommand(CommandListenerWrapper sender, String command) {
|
||||
+ Joiner joiner = Joiner.on(" ");
|
||||
+ if (command.startsWith("/")) {
|
||||
@ -68,19 +68,19 @@
|
||||
+ }
|
||||
+
|
||||
+ // Handle vanilla commands;
|
||||
+ if (sender.getWorld().getCraftServer().getCommandBlockOverride(args[0])) {
|
||||
+ if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) {
|
||||
+ args[0] = "minecraft:" + args[0];
|
||||
+ }
|
||||
+
|
||||
+ String newCommand = joiner.join(args);
|
||||
+ return this.a(sender, newCommand, newCommand, false);
|
||||
+ return this.performCommand(sender, newCommand, newCommand, false);
|
||||
+ }
|
||||
+
|
||||
public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
|
||||
+ return this.a(commandlistenerwrapper, s, s, true);
|
||||
public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
|
||||
+ return this.performCommand(commandlistenerwrapper, s, s, true);
|
||||
+ }
|
||||
+
|
||||
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
|
||||
+ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
|
||||
StringReader stringreader = new StringReader(s);
|
||||
|
||||
- if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@ -89,34 +89,34 @@
|
||||
stringreader.skip();
|
||||
}
|
||||
|
||||
@@ -229,7 +282,7 @@
|
||||
@@ -236,7 +291,7 @@
|
||||
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
|
||||
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
|
||||
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> {
|
||||
- return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
|
||||
+ return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
|
||||
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
|
||||
- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
|
||||
+ return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
|
||||
});
|
||||
|
||||
if (j > 10) {
|
||||
@@ -279,11 +332,36 @@
|
||||
@@ -286,11 +341,36 @@
|
||||
}
|
||||
|
||||
public void a(EntityPlayer entityplayer) {
|
||||
public void sendCommands(EntityPlayer entityplayer) {
|
||||
- Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newHashMap();
|
||||
+ // CraftBukkit start
|
||||
+ // Register Vanilla commands into builtRoot as before
|
||||
+ Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
|
||||
+ RootCommandNode vanillaRoot = new RootCommandNode();
|
||||
+
|
||||
+ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot();
|
||||
+ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.getDispatcher().getRoot();
|
||||
+ map.put(vanilla, vanillaRoot);
|
||||
+ this.a(vanilla, vanillaRoot, entityplayer.getCommandListener(), (Map) map);
|
||||
+ this.fillUsableCommands(vanilla, vanillaRoot, entityplayer.createCommandSourceStack(), (Map) map);
|
||||
+
|
||||
+ // Now build the global commands in a second pass
|
||||
RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode();
|
||||
|
||||
map.put(this.dispatcher.getRoot(), rootcommandnode);
|
||||
this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
|
||||
this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, entityplayer.createCommandSourceStack(), map);
|
||||
+
|
||||
+ Collection<String> bukkit = new LinkedHashSet<>();
|
||||
+ for (CommandNode node : rootcommandnode.getChildren()) {
|
||||
@ -133,10 +133,10 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
|
||||
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
|
||||
}
|
||||
|
||||
@@ -294,7 +372,7 @@
|
||||
@@ -301,7 +381,7 @@
|
||||
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
|
||||
|
||||
if (commandnode2.canUse(commandlistenerwrapper)) {
|
||||
@ -145,7 +145,7 @@
|
||||
|
||||
argumentbuilder.requires((icompletionprovider) -> {
|
||||
return true;
|
||||
@@ -317,7 +395,7 @@
|
||||
@@ -324,7 +404,7 @@
|
||||
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/commands/CommandListenerWrapper.java
|
||||
+++ b/net/minecraft/commands/CommandListenerWrapper.java
|
||||
@@ -36,6 +36,8 @@
|
||||
@@ -37,6 +37,8 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
public class CommandListenerWrapper implements ICompletionProvider {
|
||||
|
||||
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
|
||||
@@ -53,6 +55,7 @@
|
||||
@@ -55,6 +57,7 @@
|
||||
private final ResultConsumer<CommandListenerWrapper> consumer;
|
||||
private final ArgumentAnchor.Anchor anchor;
|
||||
private final Vec2F rotation;
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
|
||||
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
|
||||
@@ -153,9 +156,23 @@
|
||||
@@ -155,9 +158,23 @@
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(int i) {
|
||||
@ -34,25 +34,25 @@
|
||||
+ // CraftBukkit start
|
||||
+ public boolean hasPermission(int i, String bukkitPermission) {
|
||||
+ // World is null when loading functions
|
||||
+ return ((getWorld() == null || !getWorld().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
|
||||
+ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public Vec3D getPosition() {
|
||||
return this.worldPosition;
|
||||
}
|
||||
@@ -217,7 +234,7 @@
|
||||
@@ -219,7 +236,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) {
|
||||
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) {
|
||||
+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
|
||||
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID);
|
||||
}
|
||||
}
|
||||
@@ -277,4 +294,10 @@
|
||||
public IRegistryCustom q() {
|
||||
return this.server.getCustomRegistry();
|
||||
@@ -279,4 +296,10 @@
|
||||
public IRegistryCustom registryAccess() {
|
||||
return this.server.registryAccess();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/commands/ICommandListener.java
|
||||
+++ b/net/minecraft/commands/ICommandListener.java
|
||||
@@ -23,6 +23,13 @@
|
||||
public boolean shouldBroadcastCommands() {
|
||||
public boolean shouldInformAdmins() {
|
||||
return false;
|
||||
}
|
||||
+
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid);
|
||||
@@ -36,4 +43,6 @@
|
||||
default boolean c_() {
|
||||
default boolean alwaysAccepts() {
|
||||
return false;
|
||||
}
|
||||
+
|
||||
|
@ -15,5 +15,5 @@
|
||||
- EntitySelector entityselector = argumentparserselector.parse();
|
||||
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
|
||||
|
||||
if (entityselector.a() > 1 && this.single) {
|
||||
if (entityselector.getMaxResults() > 1 && this.single) {
|
||||
if (this.playersOnly) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
private MinecraftKey id = new MinecraftKey("");
|
||||
private BlockStateList<Block, IBlockData> definition;
|
||||
@@ -237,7 +237,7 @@
|
||||
Iterator iterator = iblockstate.getValues().iterator();
|
||||
Iterator iterator = iblockstate.getPossibleValues().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- T t0 = (Comparable) iterator.next();
|
||||
@ -19,20 +19,20 @@
|
||||
if (t0 instanceof Integer) {
|
||||
suggestionsbuilder.suggest((Integer) t0);
|
||||
@@ -506,7 +506,7 @@
|
||||
Optional<T> optional = iblockstate.b(s);
|
||||
Optional<T> optional = iblockstate.getValue(s);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
- this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get());
|
||||
+ this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
|
||||
- this.state = (IBlockData) this.state.setValue(iblockstate, (Comparable) optional.get());
|
||||
+ this.state = (IBlockData) this.state.setValue(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
|
||||
this.properties.put(iblockstate, (Comparable) optional.get());
|
||||
} else {
|
||||
this.reader.setCursor(i);
|
||||
@@ -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 appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
|
||||
stringbuilder.append(iblockstate.getName());
|
||||
stringbuilder.append('=');
|
||||
- stringbuilder.append(iblockstate.a(comparable));
|
||||
+ stringbuilder.append(iblockstate.a((T) comparable)); // CraftBukkit - decompile error
|
||||
- stringbuilder.append(iblockstate.getName(comparable));
|
||||
+ stringbuilder.append(iblockstate.getName((T) comparable)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public CompletableFuture<Suggestions> a(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) {
|
||||
public CompletableFuture<Suggestions> fillSuggestions(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
|
||||
@@ -149,7 +149,7 @@
|
||||
axisalignedbb = this.a(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
|
||||
axisalignedbb = this.createAabb(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
|
||||
}
|
||||
|
||||
- Function function;
|
||||
@ -19,7 +19,7 @@
|
||||
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ this.usesSelectors = !overridePermissions;
|
||||
+ // CraftBukkit end
|
||||
this.suggestions = this::d;
|
||||
this.suggestions = this::suggestSelector;
|
||||
if (!this.reader.canRead()) {
|
||||
throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
|
||||
@@ -465,6 +467,12 @@
|
||||
@ -33,7 +33,7 @@
|
||||
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ // CraftBukkit end
|
||||
this.startPosition = this.reader.getCursor();
|
||||
this.suggestions = this::b;
|
||||
this.suggestions = this::suggestNameOrSelector;
|
||||
if (this.reader.canRead() && this.reader.peek() == '@') {
|
||||
@@ -473,7 +481,7 @@
|
||||
}
|
||||
@ -42,5 +42,5 @@
|
||||
- this.parseSelector();
|
||||
+ this.parseSelector(overridePermissions); // CraftBukkit
|
||||
} else {
|
||||
this.c();
|
||||
this.parseNameOrUUID();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
@@ -90,7 +90,7 @@
|
||||
}
|
||||
|
||||
private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
|
||||
private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
|
||||
- if (this.usesSelector && !commandlistenerwrapper.hasPermission(2)) {
|
||||
+ if (this.usesSelector && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
|
||||
throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create();
|
||||
|
75
paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch
Normale Datei
75
paper-server/nms-patches/net/minecraft/core/IRegistryCustom.patch
Normale Datei
@ -0,0 +1,75 @@
|
||||
--- a/net/minecraft/core/IRegistryCustom.java
|
||||
+++ b/net/minecraft/core/IRegistryCustom.java
|
||||
@@ -80,7 +80,7 @@
|
||||
public <E> Optional<? extends IRegistry<E>> registry(ResourceKey<? extends IRegistry<? extends E>> resourcekey) {
|
||||
Optional<? extends IRegistry<E>> optional = this.ownedRegistry(resourcekey);
|
||||
|
||||
- return optional.isPresent() ? optional : IRegistry.REGISTRY.getOptional(resourcekey.location());
|
||||
+ return optional.isPresent() ? optional : (Optional<? extends IRegistry<E>>) IRegistry.REGISTRY.getOptional(resourcekey.location()); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <E> IRegistry<E> registryOrThrow(ResourceKey<? extends IRegistry<? extends E>> resourcekey) {
|
||||
@@ -138,7 +138,7 @@
|
||||
}
|
||||
|
||||
private static <R extends IRegistry<?>> void copyBuiltin(IRegistryCustom.Dimension iregistrycustom_dimension, ResourceKey<R> resourcekey) {
|
||||
- IRegistry<R> iregistry = RegistryGeneration.REGISTRY;
|
||||
+ IRegistry<R> iregistry = (IRegistry<R>) RegistryGeneration.REGISTRY; // CraftBukkit - decompile error
|
||||
IRegistry<?> iregistry1 = (IRegistry) iregistry.getOrThrow(resourcekey);
|
||||
|
||||
copy(iregistrycustom_dimension, iregistry1);
|
||||
@@ -178,8 +178,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
- public static final class RegistryData extends Record {
|
||||
+ // CraftBukkit start
|
||||
+ public static final record RegistryData<E>(ResourceKey<? extends IRegistry<E>> key, Codec<E> codec, @Nullable Codec<E> networkCodec) {
|
||||
|
||||
+ /*
|
||||
private final ResourceKey<? extends IRegistry<E>> key;
|
||||
private final Codec<E> codec;
|
||||
@Nullable
|
||||
@@ -190,11 +192,15 @@
|
||||
this.codec = codec;
|
||||
this.networkCodec = codec1;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public boolean sendToClient() {
|
||||
return this.networkCodec != null;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ /*
|
||||
public final String toString() {
|
||||
return this.toString < invokedynamic > (this);
|
||||
}
|
||||
@@ -219,6 +225,8 @@
|
||||
public Codec<E> networkCodec() {
|
||||
return this.networkCodec;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static final class Dimension extends IRegistryCustom {
|
||||
@@ -267,7 +275,7 @@
|
||||
}
|
||||
|
||||
private static <E> RegistryMaterials<?> parseRegistry(ResourceKey<? extends IRegistry<?>> resourcekey, Dynamic<?> dynamic) {
|
||||
- DataResult dataresult = RegistryLookupCodec.create(resourcekey).codec().parse(dynamic);
|
||||
+ DataResult<?> dataresult = RegistryLookupCodec.create((ResourceKey) resourcekey).codec().parse(dynamic); // CraftBukkit - decompile error
|
||||
String s = resourcekey + " registry: ";
|
||||
Logger logger = IRegistryCustom.LOGGER;
|
||||
|
||||
@@ -282,7 +290,7 @@
|
||||
}
|
||||
|
||||
private static <E> RegistryMaterials<?> createRegistry(ResourceKey<? extends IRegistry<?>> resourcekey) {
|
||||
- return new RegistryMaterials<>(resourcekey, Lifecycle.stable());
|
||||
+ return new RegistryMaterials(resourcekey, Lifecycle.stable()); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
40
paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch
Normale Datei
40
paper-server/nms-patches/net/minecraft/core/RegistryMaterials.patch
Normale Datei
@ -0,0 +1,40 @@
|
||||
--- a/net/minecraft/core/RegistryMaterials.java
|
||||
+++ b/net/minecraft/core/RegistryMaterials.java
|
||||
@@ -201,7 +201,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
- return SystemUtils.getRandom(this.randomCache, random);
|
||||
+ return (T) SystemUtils.getRandom(this.randomCache, random); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,7 +228,7 @@
|
||||
return registrymaterials;
|
||||
}, (registrymaterials) -> {
|
||||
Builder<RegistryMaterials.a<T>> builder = ImmutableList.builder();
|
||||
- Iterator iterator = registrymaterials.iterator();
|
||||
+ Iterator<T> iterator = registrymaterials.iterator(); // CraftBukkit - decompile error
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -257,8 +257,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
- private static final class a extends Record {
|
||||
+ // CraftBukkit start
|
||||
+ private static final record a<T>(ResourceKey<T> key, int id, T value) {
|
||||
|
||||
+ /*
|
||||
private final ResourceKey<T> key;
|
||||
private final int id;
|
||||
private final T value;
|
||||
@@ -292,5 +294,7 @@
|
||||
public T value() {
|
||||
return this.value;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
--- 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;
|
||||
@@ -29,6 +29,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -10,151 +10,151 @@
|
||||
+
|
||||
public interface CauldronInteraction {
|
||||
|
||||
Map<Item, CauldronInteraction> EMPTY = a();
|
||||
@@ -52,6 +56,11 @@
|
||||
Map<Item, CauldronInteraction> EMPTY = newInteractionMap();
|
||||
@@ -51,6 +55,11 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(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 @@
|
||||
@@ -59,7 +68,7 @@
|
||||
|
||||
entityhuman.a(enumhand, itemstack1);
|
||||
entityhuman.a(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
|
||||
entityhuman.setItemInHand(enumhand, itemstack1);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -71,6 +80,11 @@
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -70,6 +79,11 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
|
||||
itemstack1.setCount(1);
|
||||
@@ -88,7 +102,7 @@
|
||||
@@ -87,7 +101,7 @@
|
||||
}
|
||||
|
||||
entityhuman.a(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.e(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.e(iblockdata, world, blockposition); // CraftBukkit
|
||||
entityhuman.awardStat(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -106,9 +120,14 @@
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -105,9 +119,14 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.decreaseLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(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
|
||||
idyeable.clearColor(itemstack);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_ARMOR);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -117,7 +136,7 @@
|
||||
return EnumInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -116,7 +135,7 @@
|
||||
};
|
||||
|
||||
static Object2ObjectOpenHashMap<Item, CauldronInteraction> a() {
|
||||
- return (Object2ObjectOpenHashMap) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> {
|
||||
+ return SystemUtils.a((new Object2ObjectOpenHashMap<>()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
|
||||
static Object2ObjectOpenHashMap<Item, CauldronInteraction> newInteractionMap() {
|
||||
- return (Object2ObjectOpenHashMap) SystemUtils.make(new Object2ObjectOpenHashMap(), (object2objectopenhashmap) -> {
|
||||
+ return SystemUtils.make(new Object2ObjectOpenHashMap<>(), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
|
||||
object2objectopenhashmap.defaultReturnValue((iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return EnumInteractionResult.PASS;
|
||||
});
|
||||
@@ -133,12 +152,17 @@
|
||||
@@ -132,12 +151,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)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), 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
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
entityhuman.awardStat(StatisticList.USE_CAULDRON);
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
- world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState());
|
||||
+ // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
||||
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -154,12 +178,17 @@
|
||||
@@ -153,12 +177,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)) {
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(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
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)));
|
||||
entityhuman.awardStat(StatisticList.USE_CAULDRON);
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(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);
|
||||
world.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -169,10 +198,15 @@
|
||||
@@ -168,10 +197,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 ((Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtil.getPotion(itemstack) == Potions.WATER) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.a(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(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
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
entityhuman.awardStat(StatisticList.USE_CAULDRON);
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
|
||||
- world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL));
|
||||
+ // world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(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);
|
||||
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -244,12 +278,17 @@
|
||||
@@ -243,12 +277,17 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.getBlockData(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.defaultBlockState(), 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
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1));
|
||||
entityhuman.awardStat(StatisticList.USE_CAULDRON);
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
- world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState());
|
||||
+ // world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
||||
world.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -260,12 +299,17 @@
|
||||
@@ -259,12 +298,17 @@
|
||||
|
||||
static EnumInteractionResult a(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
|
||||
static EnumInteractionResult emptyBucket(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)) {
|
||||
@ -163,11 +163,11 @@
|
||||
+ // 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
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.BUCKET)));
|
||||
entityhuman.awardStat(StatisticList.FILL_CAULDRON);
|
||||
entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
|
||||
- world.setBlockAndUpdate(blockposition, iblockdata);
|
||||
+ // world.setBlockAndUpdate(blockposition, iblockdata); // CraftBukkit
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.a((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
||||
world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
- EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2);
|
||||
+ // EntityBoat entityboat = new EntityBoat(worldserver, d0, d1 + d3, d2);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2));
|
||||
@ -29,12 +29,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -48,11 +48,11 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityboat.setType(this.type);
|
||||
entityboat.setYRot(enumdirection.o());
|
||||
- worldserver.addEntity(entityboat);
|
||||
- itemstack.subtract(1);
|
||||
+ if (!worldserver.addEntity(entityboat)) itemstack.add(1); // CraftBukkit
|
||||
+ // itemstack.subtract(1); // CraftBukkit - handled during event processing
|
||||
entityboat.setYRot(enumdirection.toYRot());
|
||||
- worldserver.addFreshEntity(entityboat);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity(entityboat)) itemstack.grow(1); // CraftBukkit
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
@ -14,37 +14,37 @@
|
||||
|
||||
public DispenseBehaviorItem() {}
|
||||
@@ -26,11 +32,19 @@
|
||||
IPosition iposition = BlockDispenser.a(isourceblock);
|
||||
ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
|
||||
- a(isourceblock.getWorld(), itemstack1, 6, enumdirection, iposition);
|
||||
- spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, iposition);
|
||||
+ // CraftBukkit start
|
||||
+ if (!a(isourceblock.getWorld(), itemstack1, 6, enumdirection, isourceblock)) {
|
||||
+ itemstack.add(1);
|
||||
+ if (!spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, isourceblock)) {
|
||||
+ itemstack.grow(1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
- public static void a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
|
||||
- public static void spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
|
||||
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument
|
||||
+ public static boolean a(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) {
|
||||
+ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock) {
|
||||
+ if (itemstack.isEmpty()) return true;
|
||||
+ IPosition iposition = BlockDispenser.a(isourceblock);
|
||||
+ IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
|
||||
+ // CraftBukkit end
|
||||
double d0 = iposition.getX();
|
||||
double d1 = iposition.getY();
|
||||
double d2 = iposition.getZ();
|
||||
double d0 = iposition.x();
|
||||
double d1 = iposition.y();
|
||||
double d2 = iposition.z();
|
||||
@@ -45,7 +59,39 @@
|
||||
double d3 = world.random.nextDouble() * 0.1D + 0.2D;
|
||||
|
||||
entityitem.setMot(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getAdjacentZ() * d3);
|
||||
entityitem.setDeltaMovement(world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepX() * d3, world.random.nextGaussian() * 0.007499999832361937D * (double) i + 0.20000000298023224D, world.random.nextGaussian() * 0.007499999832361937D * (double) i + (double) enumdirection.getStepZ() * d3);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getMot()));
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getDeltaMovement()));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
@ -53,8 +53,8 @@
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ entityitem.setItemStack(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ entityitem.setMot(CraftVector.toNMS(event.getVelocity()));
|
||||
+ entityitem.setItem(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ entityitem.setDeltaMovement(CraftVector.toNMS(event.getVelocity()));
|
||||
+
|
||||
+ if (!event.getItem().getType().equals(craftItem.getType())) {
|
||||
+ // Chain to handler for new item
|
||||
@ -63,15 +63,15 @@
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
|
||||
+ idispensebehavior.dispense(isourceblock, eventStack);
|
||||
+ } else {
|
||||
+ world.addEntity(entityitem);
|
||||
+ world.addFreshEntity(entityitem);
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
world.addEntity(entityitem);
|
||||
world.addFreshEntity(entityitem);
|
||||
+
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void a(ISourceBlock isourceblock) {
|
||||
protected void playSound(ISourceBlock isourceblock) {
|
||||
|
@ -15,28 +15,28 @@
|
||||
|
||||
public DispenseBehaviorProjectile() {}
|
||||
@@ -20,9 +27,38 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
IProjectile iprojectile = this.a((World) worldserver, iposition, itemstack);
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
IProjectile iprojectile = this.getProjectile(worldserver, iposition, itemstack);
|
||||
|
||||
- iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a());
|
||||
+ // iprojectile.shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), this.getPower(), this.a());
|
||||
- iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty());
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ // iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ()));
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ()));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -46,12 +46,12 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.a());
|
||||
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
|
||||
+ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.getUncertainty());
|
||||
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity());
|
||||
+ // CraftBukkit end
|
||||
worldserver.addEntity(iprojectile);
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing
|
||||
worldserver.addFreshEntity(iprojectile);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java
|
||||
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java
|
||||
@@ -25,6 +25,12 @@
|
||||
@@ -24,6 +24,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
public class DispenseBehaviorShears extends DispenseBehaviorMaybe {
|
||||
|
||||
public DispenseBehaviorShears() {}
|
||||
@@ -32,11 +38,34 @@
|
||||
@@ -31,11 +37,34 @@
|
||||
@Override
|
||||
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||
@ -42,31 +42,31 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!worldserver.isClientSide()) {
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
|
||||
- this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition));
|
||||
+ this.a(a((WorldServer) worldserver, blockposition) || b((WorldServer) worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit
|
||||
if (this.a() && itemstack.isDamaged(1, worldserver.getRandom(), (EntityPlayer) null)) {
|
||||
- this.setSuccess(tryShearBeehive((WorldServer) worldserver, blockposition) || tryShearLivingEntity((WorldServer) worldserver, blockposition));
|
||||
+ this.setSuccess(tryShearBeehive((WorldServer) worldserver, blockposition) || tryShearLivingEntity((WorldServer) worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit
|
||||
if (this.isSuccess() && itemstack.hurt(1, worldserver.getRandom(), (EntityPlayer) null)) {
|
||||
itemstack.setCount(0);
|
||||
}
|
||||
@@ -63,7 +92,7 @@
|
||||
@@ -62,7 +91,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- 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
|
||||
List<EntityLiving> list = worldserver.a(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
|
||||
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition) {
|
||||
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
|
||||
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
@@ -74,6 +103,11 @@
|
||||
@@ -73,6 +102,11 @@
|
||||
IShearable ishearable = (IShearable) entityliving;
|
||||
|
||||
if (ishearable.canShear()) {
|
||||
if (ishearable.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ishearable.shear(SoundCategory.BLOCKS);
|
||||
worldserver.a((Entity) null, GameEvent.SHEAR, blockposition);
|
||||
worldserver.gameEvent((Entity) null, GameEvent.SHEAR, blockposition);
|
||||
return true;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
|
||||
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
|
||||
@@ -12,6 +12,11 @@
|
||||
@@ -11,6 +11,11 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -12,17 +12,17 @@
|
||||
public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -28,6 +33,30 @@
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
|
||||
EnumDirection enumdirection1 = isourceblock.getWorld().isEmpty(blockposition.down()) ? enumdirection : EnumDirection.UP;
|
||||
@@ -27,6 +32,30 @@
|
||||
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
|
||||
EnumDirection enumdirection1 = isourceblock.getLevel().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block bukkitBlock = isourceblock.getWorld().getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ org.bukkit.block.Block bukkitBlock = isourceblock.getLevel().getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ isourceblock.getWorld().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ isourceblock.getLevel().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
@ -41,5 +41,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
try {
|
||||
this.a(((ItemBlock) item).a((BlockActionContext) (new BlockActionContextDirectional(isourceblock.getWorld(), blockposition, enumdirection, itemstack, enumdirection1))).a());
|
||||
this.setSuccess(((ItemBlock) item).place(new BlockActionContextDirectional(isourceblock.getLevel(), blockposition, enumdirection, itemstack, enumdirection1)).consumesAction());
|
||||
} catch (Exception exception) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
@@ -79,6 +79,21 @@
|
||||
@@ -76,6 +76,21 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -22,59 +22,14 @@
|
||||
public interface IDispenseBehavior {
|
||||
|
||||
Logger LOGGER = LogManager.getLogger();
|
||||
@@ -120,7 +135,7 @@
|
||||
BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
|
||||
@Override
|
||||
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
|
||||
- return (IProjectile) SystemUtils.a((Object) (new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> {
|
||||
+ return (IProjectile) SystemUtils.a((new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { // CraftBukkit - decompile error
|
||||
entityegg.setItem(itemstack);
|
||||
});
|
||||
}
|
||||
@@ -128,7 +143,7 @@
|
||||
BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
|
||||
@Override
|
||||
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
|
||||
- return (IProjectile) SystemUtils.a((Object) (new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> {
|
||||
+ return (IProjectile) SystemUtils.a((new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { // CraftBukkit - decompile error
|
||||
entitysnowball.setItem(itemstack);
|
||||
});
|
||||
}
|
||||
@@ -136,7 +151,7 @@
|
||||
BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() {
|
||||
@Override
|
||||
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) {
|
||||
- return (IProjectile) SystemUtils.a((Object) (new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> {
|
||||
+ return (IProjectile) SystemUtils.a((new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { // CraftBukkit - decompile error
|
||||
entitythrownexpbottle.setItem(itemstack);
|
||||
});
|
||||
}
|
||||
@@ -157,7 +172,7 @@
|
||||
return (new DispenseBehaviorProjectile() {
|
||||
@Override
|
||||
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) {
|
||||
- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> {
|
||||
+ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error
|
||||
entitypotion.setItem(itemstack1);
|
||||
});
|
||||
}
|
||||
@@ -180,7 +195,7 @@
|
||||
return (new DispenseBehaviorProjectile() {
|
||||
@Override
|
||||
protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) {
|
||||
- return (IProjectile) SystemUtils.a((Object) (new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> {
|
||||
+ return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error
|
||||
entitypotion.setItem(itemstack1);
|
||||
});
|
||||
}
|
||||
@@ -203,14 +218,42 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).a(itemstack.getTag());
|
||||
@@ -200,14 +215,42 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag());
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer worldserver = isourceblock.getWorld();
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ WorldServer worldserver = isourceblock.getLevel();
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||
@ -83,12 +38,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -99,27 +54,27 @@
|
||||
+ }
|
||||
+
|
||||
try {
|
||||
entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
|
||||
entitytypes.spawn(isourceblock.getLevel(), itemstack, (EntityHuman) null, isourceblock.getPos().relative(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
|
||||
- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception);
|
||||
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception); // CraftBukkit - decompile error
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1); // Handled during event processing
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
isourceblock.getWorld().a(GameEvent.ENTITY_PLACE, isourceblock.getBlockPosition());
|
||||
isourceblock.getLevel().gameEvent(GameEvent.ENTITY_PLACE, isourceblock.getPos());
|
||||
return itemstack;
|
||||
}
|
||||
@@ -229,12 +272,40 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
@@ -226,12 +269,40 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||
@ -128,12 +83,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -146,22 +101,22 @@
|
||||
+
|
||||
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());
|
||||
entityarmorstand.setYRot(enumdirection.o());
|
||||
worldserver.addEntity(entityarmorstand);
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1); // CraftBukkit - Handled during event processing
|
||||
EntityTypes.updateCustomEntityTag(worldserver, (EntityHuman) null, entityarmorstand, itemstack.getTag());
|
||||
entityarmorstand.setYRot(enumdirection.toYRot());
|
||||
worldserver.addFreshEntity(entityarmorstand);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
}));
|
||||
@@ -253,8 +324,35 @@
|
||||
});
|
||||
@@ -250,8 +321,35 @@
|
||||
});
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ World world = isourceblock.getWorld();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ World world = isourceblock.getLevel();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity());
|
||||
@ -170,12 +125,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -185,21 +140,21 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
((ISaddleable) list.get(0)).saddle(SoundCategory.BLOCKS);
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1); // CraftBukkit - handled above
|
||||
this.a(true);
|
||||
((ISaddleable) list.get(0)).equipSaddle(SoundCategory.BLOCKS);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled above
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
} else {
|
||||
@@ -281,7 +379,35 @@
|
||||
@@ -278,7 +376,35 @@
|
||||
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
|
||||
} while (!entityhorseabstract.m(itemstack) || entityhorseabstract.gd() || !entityhorseabstract.isTamed());
|
||||
} while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed());
|
||||
|
||||
- entityhorseabstract.k(401).a(itemstack.cloneAndSubtract(1));
|
||||
- entityhorseabstract.getSlot(401).set(itemstack.split(1));
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ World world = isourceblock.getWorld();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ World world = isourceblock.getLevel();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity());
|
||||
@ -208,12 +163,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -223,21 +178,21 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityhorseabstract.k(401).a(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ entityhorseabstract.getSlot(401).set(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
this.a(true);
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -324,9 +450,35 @@
|
||||
@@ -321,9 +447,35 @@
|
||||
}
|
||||
|
||||
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
|
||||
- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.k(499).a(itemstack));
|
||||
- } while (!entityhorsechestedabstract.isTamed() || !entityhorsechestedabstract.getSlot(499).set(itemstack));
|
||||
+ // CraftBukkit start
|
||||
+ } while (!entityhorsechestedabstract.isTamed());
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ World world = isourceblock.getWorld();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ World world = isourceblock.getLevel();
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity());
|
||||
@ -245,7 +200,7 @@
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
|
||||
- itemstack.subtract(1);
|
||||
- itemstack.shrink(1);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return itemstack;
|
||||
+ }
|
||||
@ -259,35 +214,35 @@
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+ entityhorsechestedabstract.k(499).a(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ entityhorsechestedabstract.getSlot(499).set(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // itemstack.subtract(1); // CraftBukkit - handled above
|
||||
this.a(true);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled above
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -335,12 +487,41 @@
|
||||
@@ -332,12 +484,41 @@
|
||||
@Override
|
||||
public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer worldserver = isourceblock.getWorld();
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ WorldServer worldserver = isourceblock.getLevel();
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ()));
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getStepX(), enumdirection.getStepY(), enumdirection.getStepZ()));
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -298,30 +253,30 @@
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getWorld(), itemstack, isourceblock.getX(), isourceblock.getY(), isourceblock.getX(), true);
|
||||
EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getLevel(), itemstack, isourceblock.x(), isourceblock.y(), isourceblock.x(), true);
|
||||
|
||||
IDispenseBehavior.a(isourceblock, entityfireworks, enumdirection);
|
||||
entityfireworks.shoot((double) enumdirection.getAdjacentX(), (double) enumdirection.getAdjacentY(), (double) enumdirection.getAdjacentZ(), 0.5F, 1.0F);
|
||||
isourceblock.getWorld().addEntity(entityfireworks);
|
||||
- itemstack.subtract(1);
|
||||
+ // itemstack.subtract(1); // Handled during event processing
|
||||
IDispenseBehavior.setEntityPokingOutOfBlock(isourceblock, entityfireworks, enumdirection);
|
||||
entityfireworks.shoot((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), 0.5F, 1.0F);
|
||||
isourceblock.getLevel().addFreshEntity(entityfireworks);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -362,12 +543,40 @@
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
|
||||
@@ -359,12 +540,40 @@
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getStepZ();
|
||||
- EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, d3, d4, d5);
|
||||
|
||||
- worldserver.addEntity((Entity) SystemUtils.a((Object) entitysmallfireball, (entitysmallfireball1) -> {
|
||||
- worldserver.addFreshEntity((Entity) SystemUtils.make(entitysmallfireball, (entitysmallfireball1) -> {
|
||||
- entitysmallfireball1.setItem(itemstack);
|
||||
- }));
|
||||
- itemstack.subtract(1);
|
||||
- itemstack.shrink(1);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
|
||||
@ -330,12 +285,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -347,26 +302,26 @@
|
||||
+
|
||||
+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ entitysmallfireball.setItem(itemstack1);
|
||||
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
|
||||
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity());
|
||||
+
|
||||
+ worldserver.addEntity(entitysmallfireball);
|
||||
+ // itemstack.subtract(1); // Handled during event processing
|
||||
+ worldserver.addFreshEntity(entitysmallfireball);
|
||||
+ // itemstack.shrink(1); // Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@@ -391,9 +600,52 @@
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
@@ -388,9 +597,52 @@
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ int x = blockposition.getX();
|
||||
+ int y = blockposition.getY();
|
||||
+ int z = blockposition.getZ();
|
||||
+ IBlockData iblockdata = worldserver.getType(blockposition);
|
||||
+ IBlockData iblockdata = worldserver.getBlockState(blockposition);
|
||||
+ Material material = iblockdata.getMaterial();
|
||||
+ 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());
|
||||
+ if (worldserver.isEmptyBlock(blockposition) || !material.isSolid() || material.isReplaceable() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlaceLiquid(worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) {
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
|
||||
@ -392,38 +347,38 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (dispensiblecontaineritem.a((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) {
|
||||
dispensiblecontaineritem.a((EntityHuman) null, worldserver, itemstack, blockposition);
|
||||
if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) {
|
||||
dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition);
|
||||
- return new ItemStack(Items.BUCKET);
|
||||
+ // CraftBukkit start - Handle stacked buckets
|
||||
+ Item item = Items.BUCKET;
|
||||
+ itemstack.subtract(1);
|
||||
+ itemstack.shrink(1);
|
||||
+ if (itemstack.isEmpty()) {
|
||||
+ itemstack.setItem(Items.BUCKET);
|
||||
+ itemstack.setCount(1);
|
||||
+ } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) {
|
||||
+ } else if (((TileEntityDispenser) isourceblock.getEntity()).addItem(new ItemStack(item)) < 0) {
|
||||
+ this.defaultDispenseItemBehavior.dispense(isourceblock, new ItemStack(item));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ return itemstack;
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack);
|
||||
}
|
||||
@@ -419,7 +671,7 @@
|
||||
@@ -416,7 +668,7 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof IFluidSource) {
|
||||
- ItemStack itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata);
|
||||
+ ItemStack itemstack1 = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
|
||||
- ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata);
|
||||
+ ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
return super.a(isourceblock, itemstack);
|
||||
@@ -427,6 +679,32 @@
|
||||
worldserver.a((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
||||
return super.execute(isourceblock, itemstack);
|
||||
@@ -424,6 +676,32 @@
|
||||
worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
||||
Item item = itemstack1.getItem();
|
||||
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
@ -445,18 +400,18 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = ((IFluidSource) block).removeFluid(worldserver, blockposition, iblockdata); // From above
|
||||
+ itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata); // From above
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
itemstack.subtract(1);
|
||||
itemstack.shrink(1);
|
||||
if (itemstack.isEmpty()) {
|
||||
return new ItemStack(item);
|
||||
@@ -448,14 +726,42 @@
|
||||
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
@@ -445,14 +723,42 @@
|
||||
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||
@ -479,29 +434,29 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.a(true);
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
|
||||
IBlockData iblockdata = worldserver.getType(blockposition);
|
||||
this.setSuccess(true);
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
|
||||
IBlockData iblockdata = worldserver.getBlockState(blockposition);
|
||||
|
||||
if (BlockFireAbstract.a((World) worldserver, blockposition, enumdirection)) {
|
||||
- worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition));
|
||||
- worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
if (BlockFireAbstract.canBePlacedAt(worldserver, blockposition, enumdirection)) {
|
||||
- worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition));
|
||||
- worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
+ // CraftBukkit start - Ignition by dispensing flint and steel
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getBlockPosition()).isCancelled()) {
|
||||
+ worldserver.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) worldserver, blockposition));
|
||||
+ worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getPos()).isCancelled()) {
|
||||
+ worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition));
|
||||
+ worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else if (!BlockCampfire.h(iblockdata) && !CandleBlock.g(iblockdata) && !CandleCakeBlock.g(iblockdata)) {
|
||||
} else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
|
||||
if (iblockdata.getBlock() instanceof BlockTNT) {
|
||||
BlockTNT.a((World) worldserver, blockposition);
|
||||
@@ -481,12 +787,62 @@
|
||||
this.a(true);
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
BlockTNT.explode(worldserver, blockposition);
|
||||
@@ -478,12 +784,62 @@
|
||||
this.setSuccess(true);
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
+ // CraftBukkit start
|
||||
+ 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
|
||||
@ -526,10 +481,10 @@
|
||||
+ worldserver.captureTreeGeneration = true;
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!ItemBoneMeal.a(itemstack, (World) worldserver, blockposition) && !ItemBoneMeal.a(itemstack, (World) worldserver, blockposition, (EnumDirection) null)) {
|
||||
this.a(false);
|
||||
if (!ItemBoneMeal.growCrop(itemstack, worldserver, blockposition) && !ItemBoneMeal.growWaterPlant(itemstack, worldserver, blockposition, (EnumDirection) null)) {
|
||||
this.setSuccess(false);
|
||||
} else if (!worldserver.isClientSide) {
|
||||
worldserver.triggerEffect(1505, blockposition, 0);
|
||||
worldserver.levelEvent(1505, blockposition, 0);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ worldserver.captureTreeGeneration = false;
|
||||
@ -559,16 +514,16 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -496,12 +852,41 @@
|
||||
protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getWorld();
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
@@ -493,12 +849,41 @@
|
||||
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = isourceblock.getLevel();
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.cloneAndSubtract(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D));
|
||||
@ -577,12 +532,12 @@
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.add(1);
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
@ -595,20 +550,20 @@
|
||||
+ EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null);
|
||||
+ // CraftBukkit end
|
||||
|
||||
worldserver.addEntity(entitytntprimed);
|
||||
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); // CraftBukkit - handled above
|
||||
worldserver.addFreshEntity(entitytntprimed);
|
||||
worldserver.playSound((EntityHuman) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEffects.TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
worldserver.gameEvent((Entity) null, GameEvent.ENTITY_PLACE, blockposition);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled above
|
||||
return itemstack;
|
||||
}
|
||||
}));
|
||||
@@ -525,6 +910,30 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection);
|
||||
});
|
||||
@@ -522,6 +907,30 @@
|
||||
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
|
||||
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
@ -631,15 +586,15 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (worldserver.isEmpty(blockposition) && BlockWitherSkull.b((World) worldserver, blockposition, itemstack)) {
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.ROTATION, enumdirection.n() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3);
|
||||
worldserver.a((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
@@ -550,6 +959,30 @@
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
if (worldserver.isEmptyBlock(blockposition) && BlockWitherSkull.canSpawnMob(worldserver, blockposition, itemstack)) {
|
||||
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, enumdirection.getAxis() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.getOpposite().get2DDataValue() * 4), 3);
|
||||
worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
|
||||
@@ -547,6 +956,30 @@
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
|
||||
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
@ -662,15 +617,15 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (worldserver.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) worldserver, blockposition)) {
|
||||
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
|
||||
if (!worldserver.isClientSide) {
|
||||
worldserver.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3);
|
||||
@@ -599,6 +1032,30 @@
|
||||
BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING));
|
||||
IBlockData iblockdata = worldserver.getType(blockposition);
|
||||
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
|
||||
@@ -596,6 +1029,30 @@
|
||||
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
|
||||
IBlockData iblockdata = worldserver.getBlockState(blockposition);
|
||||
|
||||
+ // 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.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
@ -693,6 +648,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (iblockdata.a((Tag) TagsBlock.BEEHIVES, (blockbase_blockdata) -> {
|
||||
return blockbase_blockdata.b(BlockBeehive.HONEY_LEVEL);
|
||||
}) && (Integer) iblockdata.get(BlockBeehive.HONEY_LEVEL) >= 5) {
|
||||
if (iblockdata.is(TagsBlock.BEEHIVES, (blockbase_blockdata) -> {
|
||||
return blockbase_blockdata.hasProperty(BlockBeehive.HONEY_LEVEL);
|
||||
}) && (Integer) iblockdata.getValue(BlockBeehive.HONEY_LEVEL) >= 5) {
|
||||
|
@ -3,15 +3,15 @@
|
||||
@@ -156,7 +156,7 @@
|
||||
}
|
||||
|
||||
private static <T extends PacketListener> void a(Packet<T> packet, PacketListener packetlistener) {
|
||||
- packet.a(packetlistener);
|
||||
+ packet.a((T) packetlistener); // CraftBukkit - decompile error
|
||||
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
|
||||
- packet.handle(packetlistener);
|
||||
+ packet.handle((T) packetlistener); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public void setPacketListener(PacketListener packetlistener) {
|
||||
public void setListener(PacketListener packetlistener) {
|
||||
@@ -268,7 +268,7 @@
|
||||
|
||||
public void close(IChatBaseComponent ichatbasecomponent) {
|
||||
public void disconnect(IChatBaseComponent ichatbasecomponent) {
|
||||
if (this.channel.isOpen()) {
|
||||
- this.channel.close().awaitUninterruptibly();
|
||||
+ this.channel.close(); // We can't wait as this may be called from an event loop.
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/PacketDataSerializer.java
|
||||
+++ b/net/minecraft/network/PacketDataSerializer.java
|
||||
@@ -55,6 +55,8 @@
|
||||
@@ -54,6 +54,8 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -9,79 +9,79 @@
|
||||
public class PacketDataSerializer extends ByteBuf {
|
||||
|
||||
private static final int MAX_VARINT_SIZE = 5;
|
||||
@@ -123,7 +125,7 @@
|
||||
@@ -122,7 +124,7 @@
|
||||
|
||||
public <T, C extends Collection<T>> C a(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) {
|
||||
int i = this.j();
|
||||
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, Function<PacketDataSerializer, T> function) {
|
||||
int i = this.readVarInt();
|
||||
- C c0 = (Collection) intfunction.apply(i);
|
||||
+ C c0 = intfunction.apply(i); // CraftBukkit - decompile error
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
c0.add(function.apply(this));
|
||||
@@ -134,7 +136,7 @@
|
||||
@@ -133,7 +135,7 @@
|
||||
|
||||
public <T> void a(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) {
|
||||
this.d(collection.size());
|
||||
public <T> void writeCollection(Collection<T> collection, BiConsumer<PacketDataSerializer, T> biconsumer) {
|
||||
this.writeVarInt(collection.size());
|
||||
- Iterator iterator = collection.iterator();
|
||||
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -145,7 +147,7 @@
|
||||
@@ -144,7 +146,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 <T> List<T> readList(Function<PacketDataSerializer, T> function) {
|
||||
- return (List) this.readCollection(Lists::newArrayListWithCapacity, function);
|
||||
+ return (List) this.readCollection((java.util.function.IntFunction) Lists::newArrayListWithCapacity, function); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public IntList a() {
|
||||
@@ -161,12 +163,12 @@
|
||||
public IntList readIntIdList() {
|
||||
@@ -160,12 +162,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 void writeIntIdList(IntList intlist) {
|
||||
this.writeVarInt(intlist.size());
|
||||
- intlist.forEach(this::writeVarInt);
|
||||
+ intlist.forEach((java.util.function.IntConsumer) this::writeVarInt); // 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();
|
||||
public <K, V, M extends Map<K, V>> M readMap(IntFunction<M> intfunction, Function<PacketDataSerializer, K> function, Function<PacketDataSerializer, V> function1) {
|
||||
int i = this.readVarInt();
|
||||
- M m0 = (Map) intfunction.apply(i);
|
||||
+ M m0 = intfunction.apply(i); // CraftBukkit - decompile error
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
K k0 = function.apply(this);
|
||||
@@ -355,7 +357,7 @@
|
||||
@@ -354,7 +356,7 @@
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T a(Class<T> oclass) {
|
||||
- return ((Enum[]) oclass.getEnumConstants())[this.j()];
|
||||
+ return ((T[]) oclass.getEnumConstants())[this.j()]; // CraftBukkit - fix decompile error
|
||||
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
|
||||
- return ((Enum[]) oclass.getEnumConstants())[this.readVarInt()];
|
||||
+ return ((T[]) oclass.getEnumConstants())[this.readVarInt()]; // CraftBukkit - fix decompile error
|
||||
}
|
||||
|
||||
public PacketDataSerializer a(Enum<?> oenum) {
|
||||
@@ -432,7 +434,7 @@
|
||||
public PacketDataSerializer writeEnum(Enum<?> oenum) {
|
||||
@@ -431,7 +433,7 @@
|
||||
} else {
|
||||
try {
|
||||
NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
||||
NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
|
||||
- } catch (IOException ioexception) {
|
||||
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
|
||||
throw new EncoderException(ioexception);
|
||||
}
|
||||
}
|
||||
@@ -469,7 +471,7 @@
|
||||
@@ -468,7 +470,7 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer a(ItemStack itemstack) {
|
||||
public PacketDataSerializer writeItem(ItemStack itemstack) {
|
||||
- if (itemstack.isEmpty()) {
|
||||
+ if (itemstack.isEmpty() || itemstack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
||||
this.writeBoolean(false);
|
||||
} else {
|
||||
this.writeBoolean(true);
|
||||
@@ -498,6 +500,11 @@
|
||||
ItemStack itemstack = new ItemStack(Item.getById(i), b0);
|
||||
@@ -497,6 +499,11 @@
|
||||
ItemStack itemstack = new ItemStack(Item.byId(i), b0);
|
||||
|
||||
itemstack.setTag(this.m());
|
||||
itemstack.setTag(this.readNbt());
|
||||
+ // CraftBukkit start
|
||||
+ if (itemstack.getTag() != null) {
|
||||
+ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack));
|
||||
|
@ -3,9 +3,9 @@
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
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(), enumchatformat); // CraftBukkit
|
||||
private static final Map<EnumChatFormat, ChatHexColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(EnumChatFormat.values()).filter(EnumChatFormat::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> {
|
||||
- return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName());
|
||||
+ return new ChatHexColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit
|
||||
}));
|
||||
private static final Map<String, ChatHexColor> NAMED_COLORS = (Map) ChatHexColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> {
|
||||
return chathexcolor.name;
|
||||
@ -31,5 +31,5 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public int a() {
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
|
@ -23,5 +23,5 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
ChatModifier getChatModifier();
|
||||
ChatModifier getStyle();
|
||||
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -20,6 +25,7 @@
|
||||
public static <T extends PacketListener> void ensureMainThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
|
||||
if (!iasynctaskhandler.isMainThread()) {
|
||||
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
|
||||
if (!iasynctaskhandler.isSameThread()) {
|
||||
iasynctaskhandler.execute(() -> {
|
||||
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
|
||||
if (t0.a().isConnected()) {
|
||||
packet.a(t0);
|
||||
if (t0.getConnection().isConnected()) {
|
||||
packet.handle(t0);
|
||||
} else {
|
||||
@@ -28,6 +34,10 @@
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
- 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();
|
||||
+ this.newCenterX = worldborder.getCenterX() * worldborder.world.dimensionType().coordinateScale();
|
||||
+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.dimensionType().coordinateScale();
|
||||
+ // CraftBukkit end
|
||||
this.oldSize = worldborder.getSize();
|
||||
this.newSize = worldborder.k();
|
||||
this.lerpTime = worldborder.j();
|
||||
this.newSize = worldborder.getLerpTarget();
|
||||
this.lerpTime = worldborder.getLerpRemainingTime();
|
||||
|
@ -7,8 +7,8 @@
|
||||
- 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();
|
||||
+ this.newCenterX = worldborder.getCenterX() * worldborder.world.dimensionType().coordinateScale();
|
||||
+ this.newCenterZ = worldborder.getCenterZ() * worldborder.world.dimensionType().coordinateScale();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
}
|
||||
|
||||
public PacketPlayInChat(PacketDataSerializer packetdataserializer) {
|
||||
- this.message = packetdataserializer.e(256);
|
||||
+ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.e(256)); // CraftBukkit - see PlayerConnection
|
||||
- this.message = packetdataserializer.readUtf(256);
|
||||
+ this.message = org.apache.commons.lang3.StringUtils.normalizeSpace(packetdataserializer.readUtf(256)); // CraftBukkit - see PlayerConnection
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,8 +4,8 @@
|
||||
short short0 = (Short) shortiterator.next();
|
||||
|
||||
this.positions[j] = short0;
|
||||
- this.states[j] = chunksection.getType(SectionPosition.a(short0), SectionPosition.b(short0), SectionPosition.c(short0));
|
||||
+ 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
|
||||
- this.states[j] = chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0));
|
||||
+ this.states[j] = (chunksection != null) ? chunksection.getBlockState(SectionPosition.sectionRelativeX(short0), SectionPosition.sectionRelativeY(short0), SectionPosition.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,20 +6,20 @@
|
||||
|
||||
+ // CraftBukkit start - add method from above
|
||||
+ public <T> void markDirty(DataWatcherObject<T> datawatcherobject) {
|
||||
+ this.b(datawatcherobject).a(true);
|
||||
+ this.getItem(datawatcherobject).setDirty(true);
|
||||
+ this.isDirty = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean a() {
|
||||
public boolean isDirty() {
|
||||
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()));
|
||||
if (!Objects.equals(datawatcher_item1.accessor.getSerializer(), datawatcher_item.accessor.getSerializer())) {
|
||||
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.getId(), 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
|
||||
- datawatcher_item.setValue(datawatcher_item1.getValue());
|
||||
+ datawatcher_item.setValue((T) datawatcher_item1.getValue()); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
--- a/net/minecraft/resources/RegistryResourceAccess.java
|
||||
+++ b/net/minecraft/resources/RegistryResourceAccess.java
|
||||
@@ -160,8 +160,10 @@
|
||||
}));
|
||||
}
|
||||
|
||||
- private static final class Entry extends Record {
|
||||
+ // CraftBukkit start
|
||||
+ private static final record Entry(JsonElement data, int id, Lifecycle lifecycle) {
|
||||
|
||||
+ /*
|
||||
final JsonElement data;
|
||||
final int id;
|
||||
final Lifecycle lifecycle;
|
||||
@@ -183,6 +185,8 @@
|
||||
public final boolean equals(Object object) {
|
||||
return this.equals<invokedynamic>(this, object);
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public JsonElement data() {
|
||||
return this.data;
|
||||
@@ -198,8 +202,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static final class ParsedEntry extends Record {
|
||||
+ // CraftBukkit start
|
||||
+ public static final record ParsedEntry<E>(E value, OptionalInt fixedId) {
|
||||
|
||||
+ /*
|
||||
private final E value;
|
||||
private final OptionalInt fixedId;
|
||||
|
||||
@@ -207,6 +213,8 @@
|
||||
this.value = e0;
|
||||
this.fixedId = optionalint;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static <E> RegistryResourceAccess.ParsedEntry<E> createWithoutId(E e0) {
|
||||
return new RegistryResourceAccess.ParsedEntry(e0, OptionalInt.empty());
|
||||
@@ -216,6 +224,8 @@
|
||||
return new RegistryResourceAccess.ParsedEntry(e0, OptionalInt.of(i));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ /*
|
||||
public final String toString() {
|
||||
return this.toString < invokedynamic > (this);
|
||||
}
|
||||
@@ -235,5 +245,7 @@
|
||||
public OptionalInt fixedId() {
|
||||
return this.fixedId;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/AdvancementDataPlayer.java
|
||||
+++ b/net/minecraft/server/AdvancementDataPlayer.java
|
||||
@@ -181,7 +181,11 @@
|
||||
Advancement advancement = advancementdataworld.a((MinecraftKey) entry.getKey());
|
||||
Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey());
|
||||
|
||||
if (advancement == null) {
|
||||
- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file);
|
||||
@ -11,13 +11,13 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.a(advancement, (AdvancementProgress) entry.getValue());
|
||||
this.startProgress(advancement, (AdvancementProgress) entry.getValue());
|
||||
}
|
||||
@@ -276,6 +280,7 @@
|
||||
this.progressChanged.add(advancement);
|
||||
flag = true;
|
||||
if (!flag1 && advancementprogress.isDone()) {
|
||||
+ this.player.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
|
||||
advancement.d().a(this.player);
|
||||
if (advancement.c() != null && advancement.c().i() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
|
||||
this.playerList.sendMessage(new ChatMessage("chat.type.advancement." + advancement.c().e().a(), new Object[]{this.player.getScoreboardDisplayName(), advancement.j()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
advancement.getRewards().grant(this.player);
|
||||
if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level.getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
|
||||
this.playerList.broadcastMessage(new ChatMessage("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), new Object[]{this.player.getDisplayName(), advancement.getChatComponent()}), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
|
@ -3,9 +3,9 @@
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
|
||||
public CommandDispatcher<CommandListenerWrapper> getCommandDispatcher() {
|
||||
- return this.server.getCommandDispatcher().a();
|
||||
+ return this.server.vanillaCommandDispatcher.a(); // CraftBukkit
|
||||
public CommandDispatcher<CommandListenerWrapper> getDispatcher() {
|
||||
- return this.server.getCommands().getDispatcher();
|
||||
+ return this.server.vanillaCommandDispatcher.getDispatcher(); // CraftBukkit
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/DispenserRegistry.java
|
||||
+++ b/net/minecraft/server/DispenserRegistry.java
|
||||
@@ -28,6 +28,12 @@
|
||||
@@ -34,6 +34,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
public class DispenserRegistry {
|
||||
|
||||
public static final PrintStream STDOUT = System.out;
|
||||
@@ -38,6 +44,23 @@
|
||||
@@ -44,6 +50,23 @@
|
||||
|
||||
public static void init() {
|
||||
public static void bootStrap() {
|
||||
if (!DispenserRegistry.isBootstrapped) {
|
||||
+ // CraftBukkit start
|
||||
+ String name = DispenserRegistry.class.getSimpleName();
|
||||
@ -37,30 +37,30 @@
|
||||
DispenserRegistry.isBootstrapped = true;
|
||||
if (IRegistry.REGISTRY.keySet().isEmpty()) {
|
||||
throw new IllegalStateException("Unable to load registries");
|
||||
@@ -55,6 +78,69 @@
|
||||
TagStatic.b();
|
||||
d();
|
||||
@@ -61,6 +84,69 @@
|
||||
TagStatic.bootStrap();
|
||||
wrapStreams();
|
||||
}
|
||||
+ // CraftBukkit start - easier than fixing the decompile
|
||||
+ DataConverterFlattenData.map(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}");
|
||||
+ DataConverterFlattenData.map(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}");
|
||||
+ DataConverterFlattenData.map(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}");
|
||||
+ DataConverterFlattenData.map(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}");
|
||||
+ DataConverterFlattenData.map(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}");
|
||||
+ DataConverterFlattenData.map(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}");
|
||||
+ DataConverterFlattenData.map(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}");
|
||||
+ DataConverterFlattenData.map(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}");
|
||||
+ DataConverterFlattenData.map(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}");
|
||||
+ DataConverterFlattenData.map(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}");
|
||||
+ DataConverterFlattenData.map(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}");
|
||||
+ DataConverterFlattenData.map(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}");
|
||||
+ DataConverterFlattenData.map(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}");
|
||||
+ 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(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}");
|
||||
+ DataConverterFlattenData.register(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}");
|
||||
+ DataConverterFlattenData.register(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}");
|
||||
+ DataConverterFlattenData.register(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}");
|
||||
+ DataConverterFlattenData.register(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}");
|
||||
+ DataConverterFlattenData.register(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}");
|
||||
+ DataConverterFlattenData.register(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}");
|
||||
+ DataConverterFlattenData.register(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}");
|
||||
+ DataConverterFlattenData.register(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}");
|
||||
+ DataConverterFlattenData.register(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}");
|
||||
+ DataConverterFlattenData.register(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}");
|
||||
+ DataConverterFlattenData.register(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}");
|
||||
+ DataConverterFlattenData.register(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}");
|
||||
+ DataConverterFlattenData.register(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}");
|
||||
+ DataConverterFlattenData.register(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}");
|
||||
+ DataConverterFlattenData.register(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}");
|
||||
+ DataConverterFlattenData.register(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}");
|
||||
+ 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.register(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"});
|
||||
+
|
||||
+ DataConverterMaterialId.ITEM_NAMES.put(409, "minecraft:prismarine_shard");
|
||||
+ DataConverterMaterialId.ITEM_NAMES.put(410, "minecraft:prismarine_crystals");
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -58,6 +58,12 @@
|
||||
@@ -56,6 +56,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -13,34 +13,39 @@
|
||||
public class Main {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -65,8 +71,9 @@
|
||||
@@ -63,8 +69,9 @@
|
||||
public Main() {}
|
||||
|
||||
@DontObfuscate
|
||||
- public static void main(String[] astring) {
|
||||
+ public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring)
|
||||
SharedConstants.a();
|
||||
SharedConstants.tryDetectVersion();
|
||||
+ /* CraftBukkit start - Replace everything
|
||||
OptionParser optionparser = new OptionParser();
|
||||
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
|
||||
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
|
||||
@@ -90,20 +97,22 @@
|
||||
@@ -89,9 +96,12 @@
|
||||
optionparser.printHelpOn(System.err);
|
||||
return;
|
||||
}
|
||||
+ */ // CraftBukkit end
|
||||
|
||||
+
|
||||
+ try {
|
||||
CrashReport.h();
|
||||
DispenserRegistry.init();
|
||||
DispenserRegistry.c();
|
||||
SystemUtils.l();
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.a();
|
||||
|
||||
CrashReport.preload();
|
||||
- if (optionset.has(optionspec13)) {
|
||||
+ if (optionset.has("jfrProfile")) { // CraftBukkit
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
@@ -100,13 +110,13 @@
|
||||
SystemUtils.startTimerHackThread();
|
||||
IRegistryCustom.Dimension iregistrycustom_dimension = IRegistryCustom.builtin();
|
||||
Path path = Paths.get("server.properties");
|
||||
- DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path);
|
||||
+ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support
|
||||
|
||||
dedicatedserversettings.save();
|
||||
dedicatedserversettings.forceSave();
|
||||
Path path1 = Paths.get("eula.txt");
|
||||
EULA eula = new EULA(path1);
|
||||
|
||||
@ -49,7 +54,7 @@
|
||||
Main.LOGGER.info("Initialized '{}' and '{}'", path.toAbsolutePath(), path1.toAbsolutePath());
|
||||
return;
|
||||
}
|
||||
@@ -113,14 +122,15 @@
|
||||
@@ -116,14 +126,15 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,16 +67,16 @@
|
||||
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
+ // CraftBukkit start
|
||||
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
Convertable convertable = Convertable.a(file.toPath());
|
||||
- Convertable.ConversionSession convertable_conversionsession = convertable.c(s);
|
||||
+ Convertable.ConversionSession convertable_conversionsession = convertable.c(s, WorldDimension.OVERWORLD);
|
||||
Convertable convertable = Convertable.createDefault(file.toPath());
|
||||
- Convertable.ConversionSession convertable_conversionsession = convertable.createAccess(s);
|
||||
+ Convertable.ConversionSession convertable_conversionsession = convertable.createAccess(s, WorldDimension.OVERWORLD);
|
||||
WorldInfo worldinfo = convertable_conversionsession.getSummary();
|
||||
|
||||
MinecraftServer.convertWorld(convertable_conversionsession);
|
||||
WorldInfo worldinfo = convertable_conversionsession.d();
|
||||
@@ -131,13 +141,30 @@
|
||||
if (worldinfo != null) {
|
||||
@@ -139,13 +150,30 @@
|
||||
}
|
||||
|
||||
DataPackConfiguration datapackconfiguration = convertable_conversionsession.e();
|
||||
DataPackConfiguration datapackconfiguration = convertable_conversionsession.getDataPacks();
|
||||
- boolean flag = optionset.has(optionspec6);
|
||||
+ boolean flag = optionset.has("safeMode");
|
||||
|
||||
@ -79,9 +84,9 @@
|
||||
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
|
||||
}
|
||||
|
||||
ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)});
|
||||
ResourcePackRepository resourcepackrepository = new ResourcePackRepository(EnumResourcePackType.SERVER_DATA, new ResourcePackSource[]{new ResourcePackSourceVanilla(), new ResourcePackSourceFolder(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), PackSource.WORLD)});
|
||||
+ // CraftBukkit start
|
||||
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getWorldFolder(SavedFile.DATAPACK_DIR).toFile(), "bukkit");
|
||||
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit");
|
||||
+ if (!bukkitDataPackFolder.exists()) {
|
||||
+ bukkitDataPackFolder.mkdirs();
|
||||
+ }
|
||||
@ -90,44 +95,44 @@
|
||||
+ com.google.common.io.Files.write("{\n"
|
||||
+ + " \"pack\": {\n"
|
||||
+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n"
|
||||
+ + " \"pack_format\": " + SharedConstants.getGameVersion().getPackVersion() + "\n"
|
||||
+ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion() + "\n"
|
||||
+ + " }\n"
|
||||
+ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8);
|
||||
+ } catch (java.io.IOException ex) {
|
||||
+ throw new RuntimeException("Could not initialize Bukkit datapack", ex);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataPackConfiguration datapackconfiguration1 = MinecraftServer.a(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag);
|
||||
CompletableFuture completablefuture = DataPackResources.a(resourcepackrepository.f(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.f(), Runnable::run);
|
||||
DataPackConfiguration datapackconfiguration1 = MinecraftServer.configurePackRepository(resourcepackrepository, datapackconfiguration == null ? DataPackConfiguration.DEFAULT : datapackconfiguration, flag);
|
||||
CompletableFuture completablefuture = DataPackResources.loadResources(resourcepackrepository.openAllSelected(), iregistrycustom_dimension, CommandDispatcher.ServerType.DEDICATED, dedicatedserversettings.getProperties().functionPermissionLevel, SystemUtils.backgroundExecutor(), Runnable::run);
|
||||
|
||||
@@ -152,6 +179,7 @@
|
||||
@@ -160,6 +188,7 @@
|
||||
}
|
||||
|
||||
datapackresources.j();
|
||||
datapackresources.updateGlobals();
|
||||
+ /*
|
||||
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, datapackresources.i(), (IRegistryCustom) iregistrycustom_dimension);
|
||||
RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, datapackresources.getResourceManager(), iregistrycustom_dimension);
|
||||
|
||||
dedicatedserversettings.getProperties().a((IRegistryCustom) iregistrycustom_dimension);
|
||||
@@ -181,21 +209,32 @@
|
||||
dedicatedserversettings.getProperties().getWorldGenSettings(iregistrycustom_dimension);
|
||||
@@ -189,21 +218,32 @@
|
||||
}
|
||||
|
||||
convertable_conversionsession.a((IRegistryCustom) iregistrycustom_dimension, (SaveData) object);
|
||||
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, (SaveData) object);
|
||||
+ */
|
||||
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.a((thread) -> {
|
||||
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.a(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
final DedicatedServer dedicatedserver = (DedicatedServer) MinecraftServer.spin((thread) -> {
|
||||
- DedicatedServer dedicatedserver1 = new DedicatedServer(thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, object, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, datapackconfiguration1, thread, iregistrycustom_dimension, convertable_conversionsession, resourcepackrepository, datapackresources, null, dedicatedserversettings, DataConverterRegistry.getDataFixer(), minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new);
|
||||
|
||||
+ /*
|
||||
dedicatedserver1.d((String) optionset.valueOf(optionspec8));
|
||||
dedicatedserver1.setSingleplayerName((String) optionset.valueOf(optionspec8));
|
||||
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
|
||||
dedicatedserver1.c(optionset.has(optionspec2));
|
||||
dedicatedserver1.b((String) optionset.valueOf(optionspec12));
|
||||
dedicatedserver1.setDemo(optionset.has(optionspec2));
|
||||
dedicatedserver1.setId((String) optionset.valueOf(optionspec12));
|
||||
- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui");
|
||||
+ */
|
||||
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
|
||||
|
||||
if (flag1 && !GraphicsEnvironment.isHeadless()) {
|
||||
dedicatedserver1.bh();
|
||||
dedicatedserver1.showGui();
|
||||
}
|
||||
|
||||
+ if (optionset.has("port")) {
|
||||
@ -142,8 +147,8 @@
|
||||
+ /* CraftBukkit start
|
||||
Thread thread = new Thread("Server Shutdown Thread") {
|
||||
public void run() {
|
||||
dedicatedserver.safeShutdown(true);
|
||||
@@ -204,14 +243,15 @@
|
||||
dedicatedserver.halt(true);
|
||||
@@ -212,6 +252,7 @@
|
||||
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
|
||||
Runtime.getRuntime().addShutdownHook(thread);
|
||||
@ -151,13 +156,12 @@
|
||||
} catch (Exception exception1) {
|
||||
Main.LOGGER.fatal("Failed to start the minecraft server", exception1);
|
||||
}
|
||||
|
||||
@@ -219,7 +260,7 @@
|
||||
}
|
||||
|
||||
- public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<World>> immutableset) {
|
||||
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, GeneratorSettings generatorsettings) {
|
||||
- Main.LOGGER.info("Forcing world upgrade!");
|
||||
+ public static void convertWorld(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, ImmutableSet<ResourceKey<DimensionManager>> immutableset) { // CraftBukkit
|
||||
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
|
||||
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, immutableset, flag);
|
||||
+ Main.LOGGER.info("Forcing world upgrade! {}", convertable_conversionsession.getLevelId()); // CraftBukkit
|
||||
WorldUpgrader worldupgrader = new WorldUpgrader(convertable_conversionsession, datafixer, generatorsettings, flag);
|
||||
IChatBaseComponent ichatbasecomponent = null;
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -163,6 +163,27 @@
|
||||
@@ -160,6 +160,27 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.mojang.serialization.DynamicOps;
|
||||
+import com.mojang.serialization.Lifecycle;
|
||||
+import com.google.common.collect.ImmutableSet;
|
||||
+import jline.console.ConsoleReader;
|
||||
+import joptsimple.OptionSet;
|
||||
+import net.minecraft.nbt.DynamicOpsNBT;
|
||||
@ -16,6 +15,7 @@
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
+import net.minecraft.util.datafix.DataConverterRegistry;
|
||||
+import net.minecraft.world.level.biome.WorldChunkManager;
|
||||
+import net.minecraft.world.level.levelgen.ChunkGeneratorAbstract;
|
||||
+import net.minecraft.world.level.storage.WorldDataServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
@ -25,12 +25,12 @@
|
||||
+import org.bukkit.event.server.ServerLoadEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -254,6 +275,20 @@
|
||||
private final DefinedStructureManager structureManager;
|
||||
@@ -252,6 +273,20 @@
|
||||
protected SaveData worldData;
|
||||
private volatile boolean isSaving;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public DataPackConfiguration datapackconfiguration;
|
||||
@ -46,13 +46,13 @@
|
||||
+ private boolean forceTicks;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -263,14 +298,14 @@
|
||||
thread.setUncaughtExceptionHandler((thread1, throwable) -> {
|
||||
MinecraftServer.LOGGER.error(throwable);
|
||||
});
|
||||
@@ -265,14 +300,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
- S s0 = (MinecraftServer) function.apply(thread);
|
||||
+ S s0 = function.apply(thread); // CraftBukkit - decompile error
|
||||
|
||||
@ -65,8 +65,8 @@
|
||||
+ 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");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.e();
|
||||
@@ -282,7 +317,7 @@
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -284,7 +319,7 @@
|
||||
this.status = new ServerPing();
|
||||
this.random = new Random();
|
||||
this.port = -1;
|
||||
@ -75,10 +75,10 @@
|
||||
this.running = true;
|
||||
this.tickTimes = new long[100];
|
||||
this.resourcePack = "";
|
||||
@@ -312,13 +347,40 @@
|
||||
this.structureManager = new DefinedStructureManager(datapackresources.i(), convertable_conversionsession, datafixer);
|
||||
@@ -314,13 +349,40 @@
|
||||
this.structureManager = new DefinedStructureManager(datapackresources.getResourceManager(), convertable_conversionsession, datafixer);
|
||||
this.serverThread = thread;
|
||||
this.executor = SystemUtils.f();
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
+ // CraftBukkit start
|
||||
+ this.options = options;
|
||||
+ this.datapackconfiguration = datapackconfiguration;
|
||||
@ -108,66 +108,95 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private void initializeScoreboards(WorldPersistentData worldpersistentdata) {
|
||||
private void readScoreboard(WorldPersistentData worldpersistentdata) {
|
||||
ScoreboardServer scoreboardserver = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver);
|
||||
- Function function = scoreboardserver::a;
|
||||
+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::a; // CraftBukkit - decompile error
|
||||
- Function function = scoreboardserver::createData;
|
||||
+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::createData; // CraftBukkit - decompile error
|
||||
ScoreboardServer scoreboardserver1 = this.getScoreboard();
|
||||
|
||||
Objects.requireNonNull(scoreboardserver1);
|
||||
@@ -329,7 +391,7 @@
|
||||
|
||||
public static void convertWorld(Convertable.ConversionSession convertable_conversionsession) {
|
||||
if (convertable_conversionsession.isConvertable()) {
|
||||
- MinecraftServer.LOGGER.info("Converting map!");
|
||||
+ MinecraftServer.LOGGER.info("Converting map! {}", convertable_conversionsession.getLevelName()); // CraftBukkit
|
||||
convertable_conversionsession.convert(new IProgressUpdate() {
|
||||
private long timeStamp = SystemUtils.getMonotonicMillis();
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@@ -358,48 +420,211 @@
|
||||
- protected void loadLevel() {
|
||||
+ protected void loadLevel(String s) { // CraftBukkit
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -337,13 +399,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
- this.detectBundledResources();
|
||||
- this.worldData.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
|
||||
- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
|
||||
+ loadWorld0(s); // CraftBukkit
|
||||
|
||||
- this.createLevels(worldloadlistener);
|
||||
- this.forceDifficulty();
|
||||
- this.prepareLevels(worldloadlistener);
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -358,35 +415,204 @@
|
||||
|
||||
}
|
||||
|
||||
- protected void loadWorld() {
|
||||
- this.loadResourcesZip();
|
||||
- this.worldData.a(this.getServerModName(), this.getModded().isPresent());
|
||||
- WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
|
||||
+ protected void loadWorld(String s) {
|
||||
+ // CraftBukkit start
|
||||
- protected void forceDifficulty() {}
|
||||
+ // CraftBukkit start
|
||||
+ private void loadWorld0(String s) {
|
||||
+ Convertable.ConversionSession worldSession = this.storageSource;
|
||||
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.registryHolder;
|
||||
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.a((DynamicOps) DynamicOpsNBT.INSTANCE, this.resources.i(), (IRegistryCustom) iregistrycustom_dimension);
|
||||
+ WorldDataServer overworldData = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
|
||||
+ RegistryReadOps<NBTBase> registryreadops = RegistryReadOps.createAndLoad(DynamicOpsNBT.INSTANCE, this.resources.getResourceManager(), iregistrycustom_dimension);
|
||||
+ WorldDataServer overworldData = (WorldDataServer) worldSession.getDataTag(registryreadops, datapackconfiguration);
|
||||
+ if (overworldData == null) {
|
||||
+ WorldSettings worldsettings;
|
||||
+ GeneratorSettings generatorsettings;
|
||||
+
|
||||
+ if (this.isDemoMode()) {
|
||||
+ if (this.isDemo()) {
|
||||
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension);
|
||||
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
|
||||
+ } else {
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties();
|
||||
+
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
|
||||
|
||||
- protected void createLevels(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.worldData.overworldData();
|
||||
- GeneratorSettings generatorsettings = this.worldData.worldGenSettings();
|
||||
- boolean flag = generatorsettings.isDebug();
|
||||
- long i = generatorsettings.seed();
|
||||
- long j = BiomeManager.obfuscateSeed(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.dimensions();
|
||||
- WorldDimension worlddimension = (WorldDimension) registrymaterials.get(WorldDimension.OVERWORLD);
|
||||
- DimensionManager dimensionmanager;
|
||||
- Object object;
|
||||
-
|
||||
- if (worlddimension == null) {
|
||||
- dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION);
|
||||
- object = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong());
|
||||
- } else {
|
||||
- dimensionmanager = worlddimension.type();
|
||||
- object = worlddimension.generator();
|
||||
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
|
||||
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension).j() : dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension);
|
||||
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension);
|
||||
+ }
|
||||
+
|
||||
+ overworldData = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
|
||||
+ }
|
||||
+
|
||||
+ GeneratorSettings overworldSettings = overworldData.getGeneratorSettings();
|
||||
+ RegistryMaterials<WorldDimension> registrymaterials = overworldSettings.d();
|
||||
+ for (Entry<ResourceKey<WorldDimension>, WorldDimension> entry : registrymaterials.d()) {
|
||||
+ GeneratorSettings overworldSettings = overworldData.worldGenSettings();
|
||||
+ RegistryMaterials<WorldDimension> registrymaterials = overworldSettings.dimensions();
|
||||
+ for (Entry<ResourceKey<WorldDimension>, WorldDimension> entry : registrymaterials.entrySet()) {
|
||||
+ ResourceKey<WorldDimension> dimensionKey = entry.getKey();
|
||||
+
|
||||
+ WorldServer world;
|
||||
+ int dimension = 0;
|
||||
|
||||
- this.a(worldloadlistener);
|
||||
+
|
||||
+ if (dimensionKey == WorldDimension.NETHER) {
|
||||
+ if (getAllowNether()) {
|
||||
+ if (isNetherEnabled()) {
|
||||
+ dimension = -1;
|
||||
+ } else {
|
||||
+ continue;
|
||||
@ -182,11 +211,11 @@
|
||||
+ dimension = -999;
|
||||
+ }
|
||||
+
|
||||
+ String worldType = (dimension == -999) ? dimensionKey.a().getNamespace() + "_" + dimensionKey.a().getKey() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
+ String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
+ String name = (dimensionKey == WorldDimension.OVERWORLD) ? s : s + "_" + worldType;
|
||||
+ if (dimension != 0) {
|
||||
+ File newWorld = Convertable.getFolder(new File(name), dimensionKey);
|
||||
+ File oldWorld = Convertable.getFolder(new File(s), dimensionKey);
|
||||
+ File newWorld = Convertable.getStorageFolder(new File(name).toPath(), dimensionKey).toFile();
|
||||
+ File oldWorld = Convertable.getStorageFolder(new File(s).toPath(), dimensionKey).toFile();
|
||||
+ File oldLevelDat = new File(new File(s), "level.dat"); // The data folders exist on first run as they are created in the PersistentCollection constructor above, but the level.dat won't
|
||||
+
|
||||
+ if (!newWorld.isDirectory() && oldWorld.isDirectory() && oldLevelDat.isFile()) {
|
||||
@ -220,58 +249,55 @@
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, dimensionKey);
|
||||
+ worldSession = Convertable.createDefault(server.getWorldContainer().toPath()).createAccess(name, dimensionKey);
|
||||
+ } catch (IOException ex) {
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+ MinecraftServer.convertWorld(worldSession); // Run conversion now
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
||||
+ org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name);
|
||||
+
|
||||
+ WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, datapackconfiguration);
|
||||
+ WorldDataServer worlddata = (WorldDataServer) worldSession.getDataTag((DynamicOps) registryreadops, datapackconfiguration);
|
||||
+ if (worlddata == null) {
|
||||
+ WorldSettings worldsettings;
|
||||
+ GeneratorSettings generatorsettings;
|
||||
+
|
||||
+ if (this.isDemoMode()) {
|
||||
+ if (this.isDemo()) {
|
||||
+ worldsettings = MinecraftServer.DEMO_SETTINGS;
|
||||
+ generatorsettings = GeneratorSettings.a((IRegistryCustom) iregistrycustom_dimension);
|
||||
+ generatorsettings = GeneratorSettings.demoSettings(iregistrycustom_dimension);
|
||||
+ } else {
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getDedicatedServerProperties();
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
|
||||
+
|
||||
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), datapackconfiguration);
|
||||
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension).j() : dedicatedserverproperties.a((IRegistryCustom) iregistrycustom_dimension);
|
||||
+ generatorsettings = options.has("bonusChest") ? dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension).withBonusChest() : dedicatedserverproperties.getWorldGenSettings(iregistrycustom_dimension);
|
||||
+ }
|
||||
+
|
||||
+ worlddata = new WorldDataServer(worldsettings, generatorsettings, Lifecycle.stable());
|
||||
+ }
|
||||
+ worlddata.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end)
|
||||
+ if (options.has("forceUpgrade")) {
|
||||
+ net.minecraft.server.Main.convertWorld(worldSession, DataConverterRegistry.a(), options.has("eraseCache"), () -> {
|
||||
+ net.minecraft.server.Main.forceUpgrade(worldSession, DataConverterRegistry.getDataFixer(), options.has("eraseCache"), () -> {
|
||||
+ return true;
|
||||
+ }, worlddata.getGeneratorSettings().d().d().stream().map((entry1) -> {
|
||||
+ return ResourceKey.a(IRegistry.DIMENSION_TYPE_REGISTRY, ((ResourceKey) entry1.getKey()).a());
|
||||
+ }).collect(ImmutableSet.toImmutableSet()));
|
||||
+ }, worlddata.worldGenSettings());
|
||||
+ }
|
||||
+
|
||||
+ IWorldDataServer iworlddataserver = worlddata;
|
||||
+ GeneratorSettings generatorsettings = worlddata.getGeneratorSettings();
|
||||
+ boolean flag = generatorsettings.isDebugWorld();
|
||||
+ long i = generatorsettings.getSeed();
|
||||
+ long j = BiomeManager.a(i);
|
||||
+ GeneratorSettings generatorsettings = worlddata.worldGenSettings();
|
||||
+ boolean flag = generatorsettings.isDebug();
|
||||
+ long i = generatorsettings.seed();
|
||||
+ long j = BiomeManager.obfuscateSeed(i);
|
||||
+ List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
+ WorldDimension worlddimension = (WorldDimension) registrymaterials.a(dimensionKey);
|
||||
+ WorldDimension worlddimension = (WorldDimension) registrymaterials.get(WorldDimension.OVERWORLD);
|
||||
+ DimensionManager dimensionmanager;
|
||||
+ ChunkGenerator chunkgenerator;
|
||||
+
|
||||
+ if (worlddimension == null) {
|
||||
+ dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION);
|
||||
+ chunkgenerator = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong());
|
||||
+ dimensionmanager = (DimensionManager) this.registryHolder.registryOrThrow(IRegistry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionManager.OVERWORLD_LOCATION);
|
||||
+ chunkgenerator = GeneratorSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong());
|
||||
+ } else {
|
||||
+ dimensionmanager = worlddimension.b();
|
||||
+ chunkgenerator = worlddimension.c();
|
||||
+ dimensionmanager = worlddimension.type();
|
||||
+ chunkgenerator = worlddimension.generator();
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), dimensionmanager);
|
||||
@ -280,23 +306,23 @@
|
||||
+ }
|
||||
+
|
||||
+ if (biomeProvider != null) {
|
||||
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.b(IRegistry.BIOME_REGISTRY));
|
||||
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(worldInfo, biomeProvider, registryHolder.ownedRegistryOrThrow(IRegistry.BIOME_REGISTRY));
|
||||
+ if (chunkgenerator instanceof ChunkGeneratorAbstract) {
|
||||
+ chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings);
|
||||
+ chunkgenerator = new ChunkGeneratorAbstract(((ChunkGeneratorAbstract) chunkgenerator).noises, worldChunkManager, chunkgenerator.strongholdSeed, ((ChunkGeneratorAbstract) chunkgenerator).settings);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ResourceKey<World> worldKey = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, dimensionKey.a());
|
||||
+ ResourceKey<World> worldKey = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, dimensionKey.location());
|
||||
+
|
||||
+ if (dimensionKey == WorldDimension.OVERWORLD) {
|
||||
+ this.worldData = worlddata;
|
||||
+ this.worldData.setGameType(((DedicatedServer) this).getDedicatedServerProperties().gamemode); // From DedicatedServer.init
|
||||
+ this.worldData.setGameType(((DedicatedServer) this).getProperties().gamemode); // From DedicatedServer.init
|
||||
+
|
||||
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
|
||||
+
|
||||
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, list, true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||
+ WorldPersistentData worldpersistentdata = world.getWorldPersistentData();
|
||||
+ this.initializeScoreboards(worldpersistentdata);
|
||||
+ WorldPersistentData worldpersistentdata = world.getDataStorage();
|
||||
+ this.readScoreboard(worldpersistentdata);
|
||||
+ this.server.scoreboardManager = new org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager(this, world.getScoreboard());
|
||||
+ this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+ } else {
|
||||
@ -304,108 +330,84 @@
|
||||
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, dimensionmanager, worldloadlistener, chunkgenerator, flag, j, ImmutableList.of(), true, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
|
||||
+ }
|
||||
+
|
||||
+ worlddata.a(this.getServerModName(), this.getModded().isPresent());
|
||||
+ this.initWorld(world, worlddata, worldData, worlddata.getGeneratorSettings());
|
||||
+ worlddata.setModdedInfo(this.getServerModName(), this.getModdedStatus().shouldReportAsModified());
|
||||
+ this.initWorld(world, worlddata, worldData, worlddata.worldGenSettings());
|
||||
+
|
||||
+ this.levels.put(world.getDimensionKey(), world);
|
||||
+ this.getPlayerList().setPlayerFileData(world);
|
||||
+ this.levels.put(world.dimension(), world);
|
||||
+ this.getPlayerList().addWorldborderListener(world);
|
||||
+
|
||||
+ if (worlddata.getCustomBossEvents() != null) {
|
||||
+ this.getBossBattleCustomData().load(worlddata.getCustomBossEvents());
|
||||
+ this.getCustomBossEvents().load(worlddata.getCustomBossEvents());
|
||||
+ }
|
||||
+ }
|
||||
this.updateWorldSettings();
|
||||
- this.loadSpawn(worldloadlistener);
|
||||
+ for (WorldServer worldserver : this.getWorlds()) {
|
||||
+ this.loadSpawn(worldserver.getChunkProvider().chunkMap.progressListener, worldserver);
|
||||
+ this.forceDifficulty();
|
||||
+ for (WorldServer worldserver : this.getAllLevels()) {
|
||||
+ this.prepareLevels(worldserver.getChunkSource().chunkMap.progressListener, worldserver);
|
||||
+ worldserver.entityManager.tick(); // SPIGOT-6526: Load pending entities so they are available to the API
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
|
||||
+ this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
||||
+ this.connection.acceptConnections();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected void updateWorldSettings() {}
|
||||
- this.levels.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
|
||||
+ protected void forceDifficulty() {}
|
||||
|
||||
- protected void a(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.worldData.H();
|
||||
- GeneratorSettings generatorsettings = this.worldData.getGeneratorSettings();
|
||||
- this.readScoreboard(worldpersistentdata);
|
||||
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+ // CraftBukkit start
|
||||
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, GeneratorSettings generatorsettings) {
|
||||
boolean flag = generatorsettings.isDebugWorld();
|
||||
- long i = generatorsettings.getSeed();
|
||||
- long j = BiomeManager.a(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- RegistryMaterials<WorldDimension> registrymaterials = generatorsettings.d();
|
||||
- WorldDimension worlddimension = (WorldDimension) registrymaterials.a(WorldDimension.OVERWORLD);
|
||||
- DimensionManager dimensionmanager;
|
||||
- Object object;
|
||||
-
|
||||
- if (worlddimension == null) {
|
||||
- dimensionmanager = (DimensionManager) this.registryHolder.d(IRegistry.DIMENSION_TYPE_REGISTRY).d(DimensionManager.OVERWORLD_LOCATION);
|
||||
- object = GeneratorSettings.a(this.registryHolder.d(IRegistry.BIOME_REGISTRY), this.registryHolder.d(IRegistry.NOISE_GENERATOR_SETTINGS_REGISTRY), (new Random()).nextLong());
|
||||
- } else {
|
||||
- dimensionmanager = worlddimension.b();
|
||||
- object = worlddimension.c();
|
||||
+ boolean flag = generatorsettings.isDebug();
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver.generator != null) {
|
||||
+ worldserver.getWorld().getPopulators().addAll(worldserver.generator.getDefaultPopulators(worldserver.getWorld()));
|
||||
}
|
||||
-
|
||||
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, dimensionmanager, worldloadlistener, (ChunkGenerator) object, flag, j, list, true);
|
||||
-
|
||||
- this.levels.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getWorldPersistentData();
|
||||
-
|
||||
- this.initializeScoreboards(worldpersistentdata);
|
||||
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
|
||||
+ }
|
||||
WorldBorder worldborder = worldserver.getWorldBorder();
|
||||
|
||||
worldborder.a(iworlddataserver.r());
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569
|
||||
if (!iworlddataserver.p()) {
|
||||
try {
|
||||
a(worldserver, iworlddataserver, generatorsettings.c(), flag);
|
||||
@@ -421,31 +646,8 @@
|
||||
|
||||
iworlddataserver.c(true);
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
@@ -411,31 +637,10 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
-
|
||||
- this.getPlayerList().setPlayerFileData(worldserver);
|
||||
|
||||
- this.getPlayerList().addWorldborderListener(worldserver);
|
||||
- if (this.worldData.getCustomBossEvents() != null) {
|
||||
- this.getBossBattleCustomData().load(this.worldData.getCustomBossEvents());
|
||||
- this.getCustomBossEvents().load(this.worldData.getCustomBossEvents());
|
||||
- }
|
||||
-
|
||||
- Iterator iterator = registrymaterials.d().iterator();
|
||||
- Iterator iterator = registrymaterials.entrySet().iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- Entry<ResourceKey<WorldDimension>, WorldDimension> entry = (Entry) iterator.next();
|
||||
- ResourceKey<WorldDimension> resourcekey = (ResourceKey) entry.getKey();
|
||||
-
|
||||
- if (resourcekey != WorldDimension.OVERWORLD) {
|
||||
- ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.DIMENSION_REGISTRY, resourcekey.a());
|
||||
- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).b();
|
||||
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).c();
|
||||
- ResourceKey<World> resourcekey1 = ResourceKey.create(IRegistry.DIMENSION_REGISTRY, resourcekey.location());
|
||||
- DimensionManager dimensionmanager1 = ((WorldDimension) entry.getValue()).type();
|
||||
- ChunkGenerator chunkgenerator = ((WorldDimension) entry.getValue()).generator();
|
||||
- SecondaryWorldData secondaryworlddata = new SecondaryWorldData(this.worldData, iworlddataserver);
|
||||
- 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.addListener(new IWorldBorderListener.a(worldserver1.getWorldBorder()));
|
||||
- this.levels.put(resourcekey1, worldserver1);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
worldborder.applySettings(iworlddataserver.getWorldBorder());
|
||||
+ this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldInitEvent(worldserver.getWorld())); // CraftBukkit - SPIGOT-5569
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
private static void a(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -458,6 +660,21 @@
|
||||
return biomebase.b().b();
|
||||
}, random);
|
||||
ChunkCoordIntPair chunkcoordintpair = blockposition == null ? new ChunkCoordIntPair(0, 0) : new ChunkCoordIntPair(blockposition);
|
||||
@@ -443,6 +648,21 @@
|
||||
} else {
|
||||
ChunkGenerator chunkgenerator = worldserver.getChunkSource().getGenerator();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkgenerator.climateSampler().findSpawnPosition());
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver.generator != null) {
|
||||
+ Random rand = new Random(worldserver.getSeed());
|
||||
@ -413,7 +415,7 @@
|
||||
+
|
||||
+ if (spawn != null) {
|
||||
+ if (spawn.getWorld() != worldserver.getWorld()) {
|
||||
+ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getName() + " to be in another world (" + spawn.getWorld().getName() + ")");
|
||||
+ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getLevelName() + " to be in another world (" + spawn.getWorld().getName() + ")");
|
||||
+ } else {
|
||||
+ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw());
|
||||
+ return;
|
||||
@ -421,97 +423,97 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
int i = chunkgenerator.getSpawnHeight(worldserver);
|
||||
|
||||
if (blockposition == null) {
|
||||
MinecraftServer.LOGGER.warn("Unable to find spawn biome");
|
||||
@@ -532,8 +749,15 @@
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -500,8 +720,15 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
- public void loadSpawn(WorldLoadListener worldloadlistener) {
|
||||
- WorldServer worldserver = this.E();
|
||||
- public void prepareLevels(WorldLoadListener worldloadlistener) {
|
||||
- WorldServer worldserver = this.overworld();
|
||||
+ // CraftBukkit start
|
||||
+ public void loadSpawn(WorldLoadListener worldloadlistener, WorldServer worldserver) {
|
||||
+ public void prepareLevels(WorldLoadListener worldloadlistener, WorldServer worldserver) {
|
||||
+ if (!worldserver.getWorld().getKeepSpawnInMemory()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // WorldServer worldserver = this.E();
|
||||
+ // WorldServer worldserver = this.overworld();
|
||||
+ this.forceTicks = true;
|
||||
+ // CraftBukkit end
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.getDimensionKey().a());
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
@@ -546,16 +770,20 @@
|
||||
chunkproviderserver.addTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -514,16 +741,20 @@
|
||||
chunkproviderserver.addRegionTicket(TicketType.START, new ChunkCoordIntPair(blockposition), 11, Unit.INSTANCE);
|
||||
|
||||
while (chunkproviderserver.b() != 441) {
|
||||
- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
while (chunkproviderserver.getTickingGenerated() != 441) {
|
||||
- this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
- this.waitUntilNextTick();
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
- this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
- this.waitUntilNextTick();
|
||||
- Iterator iterator = this.levels.values().iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- WorldServer worldserver1 = (WorldServer) iterator.next();
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // Iterator iterator = this.worldServer.values().iterator();
|
||||
+ // Iterator iterator = this.levels.values().iterator();
|
||||
+
|
||||
+ if (true) {
|
||||
+ WorldServer worldserver1 = worldserver;
|
||||
+ // CraftBukkit end
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getWorldPersistentData().a(ForcedChunk::b, "chunks");
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -570,11 +798,18 @@
|
||||
@@ -538,11 +769,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.nextTickTime = SystemUtils.getMonotonicMillis() + 10L;
|
||||
- this.sleepForTick();
|
||||
- this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
- this.waitUntilNextTick();
|
||||
+ // CraftBukkit start
|
||||
+ // this.nextTick = SystemUtils.getMonotonicMillis() + 10L;
|
||||
+ // this.nextTickTime = SystemUtils.getMillis() + 10L;
|
||||
+ this.executeModerately();
|
||||
+ // CraftBukkit end
|
||||
worldloadlistener.b();
|
||||
chunkproviderserver.getLightEngine().a(5);
|
||||
- this.updateSpawnFlags();
|
||||
worldloadlistener.stop();
|
||||
chunkproviderserver.getLightEngine().setTaskPerBatch(5);
|
||||
- this.updateMobSpawningFlags();
|
||||
+ // CraftBukkit start
|
||||
+ // this.updateSpawnFlags();
|
||||
+ worldserver.setSpawnFlags(this.getSpawnMonsters(), this.getSpawnAnimals());
|
||||
+ // this.updateMobSpawningFlags();
|
||||
+ worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
||||
+
|
||||
+ this.forceTicks = false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void loadResourcesZip() {
|
||||
@@ -619,12 +854,16 @@
|
||||
protected void detectBundledResources() {
|
||||
@@ -587,12 +825,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - moved to WorldServer.save
|
||||
+ /*
|
||||
WorldServer worldserver1 = this.E();
|
||||
IWorldDataServer iworlddataserver = this.worldData.H();
|
||||
WorldServer worldserver1 = this.overworld();
|
||||
IWorldDataServer iworlddataserver = this.worldData.overworldData();
|
||||
|
||||
iworlddataserver.a(worldserver1.getWorldBorder().t());
|
||||
this.worldData.setCustomBossEvents(this.getBossBattleCustomData().save());
|
||||
this.storageSource.a(this.registryHolder, this.worldData, this.getPlayerList().save());
|
||||
iworlddataserver.setWorldBorder(worldserver1.getWorldBorder().createSettings());
|
||||
this.worldData.setCustomBossEvents(this.getCustomBossEvents().save());
|
||||
this.storageSource.saveDataTag(this.registryHolder, this.worldData, this.getPlayerList().getSingleplayerData());
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getWorlds().iterator();
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -645,8 +884,29 @@
|
||||
this.stop();
|
||||
@@ -627,8 +869,29 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -524,7 +526,7 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void stop() {
|
||||
public void stopServer() {
|
||||
+ // CraftBukkit start - prevent double stopping on multiple threads
|
||||
+ synchronized(stopLock) {
|
||||
+ if (hasStopped) return;
|
||||
@ -537,20 +539,20 @@
|
||||
+ this.server.disablePlugins();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getServerConnection() != null) {
|
||||
this.getServerConnection().b();
|
||||
if (this.getConnection() != null) {
|
||||
this.getConnection().stop();
|
||||
}
|
||||
@@ -655,6 +915,7 @@
|
||||
@@ -638,6 +901,7 @@
|
||||
MinecraftServer.LOGGER.info("Saving players");
|
||||
this.playerList.savePlayers();
|
||||
this.playerList.shutdown();
|
||||
this.playerList.saveAll();
|
||||
this.playerList.removeAll();
|
||||
+ try { Thread.sleep(100); } catch (InterruptedException ex) {} // CraftBukkit - SPIGOT-625 - give server at least a chance to send packets
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -732,9 +993,10 @@
|
||||
@@ -712,9 +976,10 @@
|
||||
while (this.running) {
|
||||
long i = SystemUtils.getMonotonicMillis() - this.nextTickTime;
|
||||
long i = SystemUtils.getMillis() - this.nextTickTime;
|
||||
|
||||
- if (i > 2000L && this.nextTickTime - this.lastOverloadWarning >= 15000L) {
|
||||
+ if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
|
||||
@ -560,62 +562,71 @@
|
||||
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
|
||||
this.nextTickTime += j * 50L;
|
||||
this.lastOverloadWarning = this.nextTickTime;
|
||||
@@ -745,6 +1007,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getMonotonicNanos(), this.tickCount);
|
||||
@@ -725,6 +990,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.a(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
this.nextTickTime += 50L;
|
||||
this.bh();
|
||||
this.profiler.enter("tick");
|
||||
@@ -790,6 +1053,12 @@
|
||||
} catch (Throwable throwable1) {
|
||||
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
|
||||
} finally {
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -775,6 +1041,12 @@
|
||||
this.profileCache.clearExecutor();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Restore terminal to original settings
|
||||
+ try {
|
||||
+ reader.getTerminal().restore();
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.exit();
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -798,8 +1067,15 @@
|
||||
@@ -783,8 +1055,15 @@
|
||||
}
|
||||
|
||||
private boolean canSleepForTick() {
|
||||
- return this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
private boolean haveTime() {
|
||||
- return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
+ // CraftBukkit start
|
||||
+ return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
+ return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
|
||||
+ }
|
||||
+
|
||||
+ private void executeModerately() {
|
||||
+ this.executeAll();
|
||||
+ this.runAllTasks();
|
||||
+ java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected void sleepForTick() {
|
||||
this.executeAll();
|
||||
@@ -908,7 +1184,7 @@
|
||||
this.status.b().a(agameprofile);
|
||||
protected void waitUntilNextTick() {
|
||||
this.runAllTasks();
|
||||
@@ -830,7 +1109,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected void doRunTask(TickTask ticktask) {
|
||||
+ public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -901,7 +1180,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.tickCount % 6000 == 0) {
|
||||
+ if (autosavePeriod > 0 && this.tickCount % autosavePeriod == 0) { // CraftBukkit
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.enter("save");
|
||||
this.playerList.savePlayers();
|
||||
@@ -938,22 +1214,39 @@
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -920,22 +1199,39 @@
|
||||
}
|
||||
|
||||
public void b(BooleanSupplier booleansupplier) {
|
||||
public void tickChildren(BooleanSupplier booleansupplier) {
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit
|
||||
this.profiler.enter("commandFunctions");
|
||||
this.getFunctionData().tick();
|
||||
this.profiler.exitEnter("levels");
|
||||
Iterator iterator = this.getWorlds().iterator();
|
||||
this.profiler.push("commandFunctions");
|
||||
this.getFunctions().tick();
|
||||
this.profiler.popPush("levels");
|
||||
Iterator iterator = this.getAllLevels().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ // Run tasks that are waiting on processing
|
||||
@ -627,27 +638,27 @@
|
||||
+ if (this.tickCount % 20 == 0) {
|
||||
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
|
||||
+ EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.level.getTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
|
||||
+ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level.getGameTime(), entityplayer.getPlayerTime(), entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
this.profiler.a(() -> {
|
||||
return worldserver + " " + worldserver.getDimensionKey().a();
|
||||
this.profiler.push(() -> {
|
||||
return worldserver + " " + worldserver.dimension().location();
|
||||
});
|
||||
+ /* Drop global time updates
|
||||
if (this.tickCount % 20 == 0) {
|
||||
this.profiler.enter("timeSync");
|
||||
this.playerList.a((Packet) (new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))), worldserver.getDimensionKey());
|
||||
this.profiler.exit();
|
||||
this.profiler.push("timeSync");
|
||||
this.playerList.broadcastAll(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), worldserver.dimension());
|
||||
this.profiler.pop();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.profiler.enter("tick");
|
||||
this.profiler.push("tick");
|
||||
|
||||
@@ -1042,7 +1335,7 @@
|
||||
@@ -1024,7 +1320,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -655,35 +666,44 @@
|
||||
+ return server.getName(); // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport b(SystemReport systemreport) {
|
||||
@@ -1414,16 +1707,17 @@
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1351,16 +1647,17 @@
|
||||
|
||||
public CompletableFuture<Void> a(Collection<String> collection) {
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
- Stream stream = collection.stream();
|
||||
+ Stream<String> stream = collection.stream(); // CraftBukkit - decompile error
|
||||
ResourcePackRepository resourcepackrepository = this.packRepository;
|
||||
|
||||
Objects.requireNonNull(this.packRepository);
|
||||
- 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 (ImmutableList) stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList());
|
||||
+ return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(ResourcePackLoader::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
return DataPackResources.a(immutablelist, this.registryHolder, this.k() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.i(), this.executor, this);
|
||||
return DataPackResources.loadResources(immutablelist, this.registryHolder, this.isDedicatedServer() ? CommandDispatcher.ServerType.DEDICATED : CommandDispatcher.ServerType.INTEGRATED, this.getFunctionCompilationLevel(), this.executor, this);
|
||||
}).thenAcceptAsync((datapackresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = datapackresources;
|
||||
+ this.server.syncCommands(); // SPIGOT-5884: Lost on reload
|
||||
this.packRepository.a(collection);
|
||||
this.worldData.a(a(this.packRepository));
|
||||
datapackresources.j();
|
||||
@@ -1768,6 +2062,22 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
this.worldData.setDataPackConfig(getSelectedPacks(this.packRepository));
|
||||
datapackresources.updateGlobals();
|
||||
@@ -1714,7 +2011,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
- ArrayList arraylist;
|
||||
+ ArrayList<NativeModuleLister.a> arraylist; // CraftBukkit - decompile error
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -1764,6 +2061,22 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public boolean isMainThread() {
|
||||
+ return super.isMainThread() || this.isStopped(); // CraftBukkit - MC-142590
|
||||
+ public boolean isSameThread() {
|
||||
+ return super.isSameThread() || this.isStopped(); // CraftBukkit - MC-142590
|
||||
+ }
|
||||
+
|
||||
+ public boolean isDebugging() {
|
||||
@ -696,6 +716,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private void bh() {
|
||||
private void startMetricsRecordingTick() {
|
||||
if (this.willStartRecordingMetrics) {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.a(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.k()), SystemUtils.timeSource, SystemUtils.g(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
|
||||
|
@ -1,100 +1,100 @@
|
||||
--- a/net/minecraft/server/ScoreboardServer.java
|
||||
+++ b/net/minecraft/server/ScoreboardServer.java
|
||||
@@ -34,7 +34,7 @@
|
||||
public void handleScoreChanged(ScoreboardScore scoreboardscore) {
|
||||
super.handleScoreChanged(scoreboardscore);
|
||||
public void onScoreChanged(ScoreboardScore scoreboardscore) {
|
||||
super.onScoreChanged(scoreboardscore);
|
||||
if (this.trackedObjectives.contains(scoreboardscore.getObjective())) {
|
||||
- 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.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getOwner(), scoreboardscore.getScore()));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.CHANGE, scoreboardscore.getObjective().getName(), scoreboardscore.getOwner(), scoreboardscore.getScore()));
|
||||
}
|
||||
|
||||
this.a();
|
||||
this.setDirty();
|
||||
@@ -43,7 +43,7 @@
|
||||
@Override
|
||||
public void handlePlayerRemoved(String s) {
|
||||
super.handlePlayerRemoved(s);
|
||||
- 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.a();
|
||||
public void onPlayerRemoved(String s) {
|
||||
super.onPlayerRemoved(s);
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, (String) null, s, 0));
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
public void a(String s, ScoreboardObjective scoreboardobjective) {
|
||||
super.a(s, scoreboardobjective);
|
||||
public void onPlayerScoreRemoved(String s, ScoreboardObjective scoreboardobjective) {
|
||||
super.onPlayerScoreRemoved(s, scoreboardobjective);
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
- 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.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardScore(ScoreboardServer.Action.REMOVE, scoreboardobjective.getName(), s, 0));
|
||||
}
|
||||
|
||||
this.a();
|
||||
this.setDirty();
|
||||
@@ -64,7 +64,7 @@
|
||||
super.setDisplaySlot(i, scoreboardobjective);
|
||||
super.setDisplayObjective(i, scoreboardobjective);
|
||||
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
|
||||
if (this.h(scoreboardobjective1) > 0) {
|
||||
- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
} else {
|
||||
this.g(scoreboardobjective1);
|
||||
this.stopTrackingObjective(scoreboardobjective1);
|
||||
}
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
if (scoreboardobjective != null) {
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
|
||||
} else {
|
||||
this.e(scoreboardobjective);
|
||||
this.startTrackingObjective(scoreboardobjective);
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
@Override
|
||||
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
if (super.addPlayerToTeam(s, scoreboardteam)) {
|
||||
- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
|
||||
+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
|
||||
this.a();
|
||||
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
|
||||
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
|
||||
this.setDirty();
|
||||
return true;
|
||||
} else {
|
||||
@@ -95,7 +95,7 @@
|
||||
@Override
|
||||
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||
super.removePlayerFromTeam(s, scoreboardteam);
|
||||
- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
|
||||
+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
|
||||
this.a();
|
||||
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
|
||||
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) {
|
||||
super.handleObjectiveChanged(scoreboardobjective);
|
||||
public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) {
|
||||
super.onObjectiveChanged(scoreboardobjective);
|
||||
if (this.trackedObjectives.contains(scoreboardobjective)) {
|
||||
- this.server.getPlayerList().sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
+ this.sendAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
+ this.broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
|
||||
}
|
||||
|
||||
this.a();
|
||||
this.setDirty();
|
||||
@@ -128,21 +128,21 @@
|
||||
@Override
|
||||
public void handleTeamAdded(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamAdded(scoreboardteam);
|
||||
- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true));
|
||||
+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, true));
|
||||
this.a();
|
||||
public void onTeamAdded(ScoreboardTeam scoreboardteam) {
|
||||
super.onTeamAdded(scoreboardteam);
|
||||
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true));
|
||||
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true));
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTeamChanged(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamChanged(scoreboardteam);
|
||||
- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false));
|
||||
+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam, false));
|
||||
this.a();
|
||||
public void onTeamChanged(ScoreboardTeam scoreboardteam) {
|
||||
super.onTeamChanged(scoreboardteam);
|
||||
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false));
|
||||
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false));
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTeamRemoved(ScoreboardTeam scoreboardteam) {
|
||||
super.handleTeamRemoved(scoreboardteam);
|
||||
- this.server.getPlayerList().sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam));
|
||||
+ this.sendAll(PacketPlayOutScoreboardTeam.a(scoreboardteam));
|
||||
this.a();
|
||||
public void onTeamRemoved(ScoreboardTeam scoreboardteam) {
|
||||
super.onTeamRemoved(scoreboardteam);
|
||||
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam));
|
||||
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam));
|
||||
this.setDirty();
|
||||
}
|
||||
|
||||
@@ -189,6 +189,7 @@
|
||||
@ -114,14 +114,14 @@
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -257,6 +259,16 @@
|
||||
return this.b().b(nbttagcompound);
|
||||
return this.createData().load(nbttagcompound);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Send to players
|
||||
+ private void sendAll(Packet packet) {
|
||||
+ private void broadcastAll(Packet packet) {
|
||||
+ for (EntityPlayer entityplayer : (List<EntityPlayer>) this.server.getPlayerList().players) {
|
||||
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) {
|
||||
+ entityplayer.connection.sendPacket(packet);
|
||||
+ entityplayer.connection.send(packet);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/commands/CommandEffect.java
|
||||
+++ b/net/minecraft/server/commands/CommandEffect.java
|
||||
@@ -73,7 +73,7 @@
|
||||
@@ -72,7 +72,7 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
MobEffect mobeffect = new MobEffect(mobeffectlist, k, i, false, flag);
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@
|
||||
@@ -98,7 +98,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@
|
||||
@@ -123,7 +123,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
|
@ -2,19 +2,19 @@
|
||||
+++ b/net/minecraft/server/commands/CommandGamerule.java
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
static <T extends GameRules.GameRuleValue<T>> int a(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
static <T extends GameRules.GameRuleValue<T>> int setRule(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource();
|
||||
- T t0 = commandlistenerwrapper.getServer().getGameRules().get(gamerules_gamerulekey);
|
||||
+ T t0 = commandlistenerwrapper.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit
|
||||
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
|
||||
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
|
||||
|
||||
t0.b(commandcontext, "value");
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), true);
|
||||
t0.setFromArgument(commandcontext, "value");
|
||||
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.set", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), true);
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
|
||||
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.getWorld().getGameRules().get(gamerules_gamerulekey); // CraftBukkit
|
||||
static <T extends GameRules.GameRuleValue<T>> int queryRule(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
- T t0 = commandlistenerwrapper.getServer().getGameRules().getRule(gamerules_gamerulekey);
|
||||
+ T t0 = commandlistenerwrapper.getLevel().getGameRules().getRule(gamerules_gamerulekey); // CraftBukkit
|
||||
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.a(), t0.toString()}), false);
|
||||
return t0.getIntValue();
|
||||
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.gamerule.query", new Object[]{gamerules_gamerulekey.getId(), t0.toString()}), false);
|
||||
return t0.getCommandResult();
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/commands/CommandList.java
|
||||
+++ b/net/minecraft/server/commands/CommandList.java
|
||||
@@ -37,6 +37,12 @@
|
||||
private static int a(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
|
||||
private static int format(CommandListenerWrapper commandlistenerwrapper, Function<EntityPlayer, IChatBaseComponent> function) {
|
||||
PlayerList playerlist = commandlistenerwrapper.getServer().getPlayerList();
|
||||
List<EntityPlayer> list = playerlist.getPlayers();
|
||||
+ // CraftBukkit start
|
||||
@ -10,6 +10,6 @@
|
||||
+ list = list.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
IChatBaseComponent ichatbasecomponent = ChatComponentUtils.b(list, function);
|
||||
IChatBaseComponent ichatbasecomponent = ChatComponentUtils.formatList(list, function);
|
||||
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false);
|
||||
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.list.players", new Object[]{list.size(), playerlist.getMaxPlayers(), ichatbasecomponent}), false);
|
||||
|
@ -6,14 +6,14 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public static void reload(MinecraftServer minecraftserver) {
|
||||
+ ResourcePackRepository resourcepackrepository = minecraftserver.getResourcePackRepository();
|
||||
+ SaveData savedata = minecraftserver.getSaveData();
|
||||
+ Collection<String> collection = resourcepackrepository.d();
|
||||
+ Collection<String> collection1 = a(resourcepackrepository, savedata, collection);
|
||||
+ minecraftserver.a(collection1);
|
||||
+ ResourcePackRepository resourcepackrepository = minecraftserver.getPackRepository();
|
||||
+ SaveData savedata = minecraftserver.getWorldData();
|
||||
+ Collection<String> collection = resourcepackrepository.getSelectedIds();
|
||||
+ Collection<String> collection1 = discoverNewPacks(resourcepackrepository, savedata, collection);
|
||||
+ minecraftserver.reloadResources(collection1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static void a(CommandDispatcher<CommandListenerWrapper> commanddispatcher) {
|
||||
commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.a("reload").requires((commandlistenerwrapper) -> {
|
||||
public static void register(CommandDispatcher<CommandListenerWrapper> commanddispatcher) {
|
||||
commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.CommandDispatcher.literal("reload").requires((commandlistenerwrapper) -> {
|
||||
return commandlistenerwrapper.hasPermission(2);
|
||||
|
@ -1,20 +1,11 @@
|
||||
--- a/net/minecraft/server/commands/CommandSchedule.java
|
||||
+++ b/net/minecraft/server/commands/CommandSchedule.java
|
||||
@@ -57,7 +57,7 @@
|
||||
@@ -56,7 +56,7 @@
|
||||
} else {
|
||||
long j = commandlistenerwrapper.getWorld().getTime() + (long) i;
|
||||
long j = commandlistenerwrapper.getLevel().getGameTime() + (long) i;
|
||||
MinecraftKey minecraftkey = (MinecraftKey) pair.getFirst();
|
||||
- CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getSaveData().H().u();
|
||||
+ CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getWorld().serverLevelData.H().u(); // CraftBukkit - SPIGOT-6667: Use world specific function timer
|
||||
- CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getServer().getWorldData().overworldData().getScheduledEvents();
|
||||
+ CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue = commandlistenerwrapper.getLevel().serverLevelData.overworldData().getScheduledEvents(); // CraftBukkit - SPIGOT-6667: Use world specific function timer
|
||||
|
||||
((Either) pair.getSecond()).ifLeft((customfunction) -> {
|
||||
String s = minecraftkey.toString();
|
||||
@@ -78,7 +78,7 @@
|
||||
customfunctioncallbacktimerqueue.a(s, j, new CustomFunctionCallbackTag(minecraftkey));
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.schedule.created.tag", new Object[]{minecraftkey, i, j}), true);
|
||||
});
|
||||
- return Math.floorMod(j, Integer.MAX_VALUE);
|
||||
+ return (int) Math.floorMod(j, (long) Integer.MAX_VALUE); // CraftBukkit - Downgrade to Java 8 method
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,41 +1,41 @@
|
||||
--- a/net/minecraft/server/commands/CommandSpreadPlayers.java
|
||||
+++ b/net/minecraft/server/commands/CommandSpreadPlayers.java
|
||||
@@ -80,7 +80,7 @@
|
||||
@@ -79,7 +79,7 @@
|
||||
if (entity instanceof EntityHuman) {
|
||||
set.add(entity.getScoreboardTeam());
|
||||
set.add(entity.getTeam());
|
||||
} else {
|
||||
- set.add((Object) null);
|
||||
+ set.add((ScoreboardTeamBase) null); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@
|
||||
@@ -288,7 +288,7 @@
|
||||
|
||||
for (boolean flag2 = iblockaccess.getType(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
|
||||
blockposition_mutableblockposition.c(EnumDirection.DOWN);
|
||||
- flag1 = iblockaccess.getType(blockposition_mutableblockposition).isAir();
|
||||
+ flag1 = getType(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
|
||||
for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
|
||||
blockposition_mutableblockposition.move(EnumDirection.DOWN);
|
||||
- flag1 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir();
|
||||
+ flag1 = getBlockState(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
|
||||
if (!flag1 && flag2 && flag) {
|
||||
return blockposition_mutableblockposition.getY() + 1;
|
||||
}
|
||||
@@ -302,7 +302,7 @@
|
||||
@@ -301,7 +301,7 @@
|
||||
|
||||
public boolean b(IBlockAccess iblockaccess, int i) {
|
||||
BlockPosition blockposition = new BlockPosition(this.x, (double) (this.a(iblockaccess, i) - 1), this.z);
|
||||
- IBlockData iblockdata = iblockaccess.getType(blockposition);
|
||||
+ IBlockData iblockdata = getType(iblockaccess, blockposition); // CraftBukkit
|
||||
public boolean isSafe(IBlockAccess iblockaccess, int i) {
|
||||
BlockPosition blockposition = new BlockPosition(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z);
|
||||
- IBlockData iblockdata = iblockaccess.getBlockState(blockposition);
|
||||
+ IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit
|
||||
Material material = iblockdata.getMaterial();
|
||||
|
||||
return blockposition.getY() < i && !material.isLiquid() && material != Material.FIRE;
|
||||
@@ -312,5 +312,12 @@
|
||||
this.x = MathHelper.a(random, d0, d2);
|
||||
this.z = MathHelper.a(random, d1, d3);
|
||||
@@ -311,5 +311,12 @@
|
||||
this.x = MathHelper.nextDouble(random, d0, d2);
|
||||
this.z = MathHelper.nextDouble(random, d1, d3);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - add a version of getType which force loads chunks
|
||||
+ private static IBlockData getType(IBlockAccess iblockaccess, BlockPosition position) {
|
||||
+ ((WorldServer) iblockaccess).getChunkProvider().getChunkAt(position.getX() >> 4, position.getZ() >> 4, true);
|
||||
+ return iblockaccess.getType(position);
|
||||
+ // CraftBukkit start - add a version of getBlockState which force loads chunks
|
||||
+ private static IBlockData getBlockState(IBlockAccess iblockaccess, BlockPosition position) {
|
||||
+ ((WorldServer) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true);
|
||||
+ return iblockaccess.getBlockState(position);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/server/commands/CommandSummon.java
|
||||
+++ b/net/minecraft/server/commands/CommandSummon.java
|
||||
@@ -66,7 +66,7 @@
|
||||
((EntityInsentient) entity).prepare(commandlistenerwrapper.getWorld(), commandlistenerwrapper.getWorld().getDamageScaler(entity.getChunkCoordinates()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
@@ -65,7 +65,7 @@
|
||||
((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
}
|
||||
|
||||
- if (!worldserver.addAllEntitiesSafely(entity)) {
|
||||
+ if (!worldserver.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
|
||||
- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) {
|
||||
+ if (!worldserver.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND)) { // CraftBukkit - pass a spawn reason of "COMMAND"
|
||||
throw CommandSummon.ERROR_DUPLICATE_UUID.create();
|
||||
} else {
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.summon.success", new Object[]{entity.getScoreboardDisplayName()}), true);
|
||||
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.summon.success", new Object[]{entity.getDisplayName()}), true);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/commands/CommandTeleport.java
|
||||
+++ b/net/minecraft/server/commands/CommandTeleport.java
|
||||
@@ -36,6 +36,12 @@
|
||||
@@ -35,6 +35,12 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -13,20 +13,20 @@
|
||||
public class CommandTeleport {
|
||||
|
||||
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(new ChatMessage("commands.teleport.invalidPosition"));
|
||||
@@ -160,14 +166,29 @@
|
||||
@@ -159,14 +165,29 @@
|
||||
}
|
||||
|
||||
if (worldserver == entity.level) {
|
||||
- ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set);
|
||||
+ ((EntityPlayer) entity).connection.a(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
- ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set);
|
||||
+ ((EntityPlayer) entity).connection.teleport(d0, d1, d2, f2, f3, set, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
} else {
|
||||
- ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3);
|
||||
+ ((EntityPlayer) entity).a(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
- ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3);
|
||||
+ ((EntityPlayer) entity).teleportTo(worldserver, d0, d1, d2, f2, f3, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit
|
||||
}
|
||||
|
||||
entity.setHeadRotation(f2);
|
||||
entity.setYHeadRot(f2);
|
||||
} else {
|
||||
float f4 = MathHelper.a(f3, -90.0F, 90.0F);
|
||||
float f4 = MathHelper.clamp(f3, -90.0F, 90.0F);
|
||||
+ // CraftBukkit start - Teleport event
|
||||
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f4);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
|
||||
@ -44,4 +44,4 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (worldserver == entity.level) {
|
||||
entity.setPositionRotation(d0, d1, d2, f2, f4);
|
||||
entity.moveTo(d0, d1, d2, f2, f4);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/commands/CommandTime.java
|
||||
+++ b/net/minecraft/server/commands/CommandTime.java
|
||||
@@ -10,6 +10,11 @@
|
||||
@@ -9,6 +9,11 @@
|
||||
import net.minecraft.network.chat.ChatMessage;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
public class CommandTime {
|
||||
|
||||
public CommandTime() {}
|
||||
@@ -53,7 +58,13 @@
|
||||
@@ -52,7 +57,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
@ -26,8 +26,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true);
|
||||
@@ -66,7 +77,13 @@
|
||||
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.time.set", new Object[]{i}), true);
|
||||
@@ -65,7 +76,13 @@
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
@ -41,4 +41,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
int j = a(commandlistenerwrapper.getWorld());
|
||||
int j = getDayTime(commandlistenerwrapper.getLevel());
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -65,6 +65,15 @@
|
||||
@@ -61,6 +61,15 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -83,8 +92,10 @@
|
||||
@@ -81,8 +90,10 @@
|
||||
@Nullable
|
||||
private final IChatBaseComponent resourcePackPrompt;
|
||||
|
||||
@ -28,9 +28,9 @@
|
||||
+ // CraftBukkit end
|
||||
this.settings = dedicatedserversettings;
|
||||
this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
this.textFilterClient = TextFilter.a(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
@@ -95,13 +106,44 @@
|
||||
public boolean init() throws IOException {
|
||||
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
@@ -93,13 +104,44 @@
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
public void run() {
|
||||
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||
@ -52,7 +52,7 @@
|
||||
|
||||
try {
|
||||
- while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (s = bufferedreader.readLine()) != null) {
|
||||
- DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
|
||||
- DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
|
||||
+ // CraftBukkit start - JLine disabling compatibility
|
||||
+ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) {
|
||||
+ if (org.bukkit.craftbukkit.Main.useJline) {
|
||||
@ -71,13 +71,13 @@
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (s.trim().length() > 0) { // Trim to filter lines which are just spaces
|
||||
+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener());
|
||||
+ DedicatedServer.this.handleConsoleInput(s, DedicatedServer.this.createCommandSourceStack());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -110,6 +152,27 @@
|
||||
@@ -108,6 +150,27 @@
|
||||
}
|
||||
};
|
||||
|
||||
@ -105,83 +105,81 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -135,7 +198,7 @@
|
||||
@@ -133,7 +196,7 @@
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
super.setIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
|
||||
- this.worldData.setGameType(dedicatedserverproperties.gamemode);
|
||||
+ // this.worldData.setGameType(dedicatedserverproperties.gamemode); // CraftBukkit - moved to world loading
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -159,6 +222,12 @@
|
||||
@@ -157,6 +220,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
|
||||
+ this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage));
|
||||
+ server.loadPlugins();
|
||||
+ server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!this.getOnlineMode()) {
|
||||
if (!this.usesAuthentication()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
@@ -173,7 +242,7 @@
|
||||
if (!NameReferencingFileConverter.e(this)) {
|
||||
@@ -171,13 +240,13 @@
|
||||
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.a((PlayerList) (new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)));
|
||||
+ // this.a((PlayerList) (new DedicatedPlayerList(this, this.customRegistry, this.worldNBTStorage))); // CraftBukkit - moved up
|
||||
long i = SystemUtils.getMonotonicNanos();
|
||||
- this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage));
|
||||
+ // this.setPlayerList(new DedicatedPlayerList(this, this.registryHolder, this.playerDataStorage)); // CraftBukkit - moved up
|
||||
long i = SystemUtils.getNanos();
|
||||
|
||||
TileEntitySkull.a(this.getUserCache());
|
||||
@@ -181,7 +250,7 @@
|
||||
TileEntitySkull.a((Executor) this);
|
||||
UserCache.a(this.getOnlineMode());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld());
|
||||
- this.loadWorld();
|
||||
+ this.loadWorld(storageSource.getLevelName()); // CraftBukkit
|
||||
long j = SystemUtils.getMonotonicNanos() - i;
|
||||
TileEntitySkull.setup(this.getProfileCache(), this.getSessionService(), this);
|
||||
UserCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
- this.loadLevel();
|
||||
+ this.loadLevel(storageSource.getLevelId()); // CraftBukkit
|
||||
long j = SystemUtils.getNanos() - i;
|
||||
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
|
||||
|
||||
@@ -198,6 +267,7 @@
|
||||
@@ -194,6 +263,7 @@
|
||||
if (dedicatedserverproperties.enableRcon) {
|
||||
DedicatedServer.LOGGER.info("Starting remote control listener");
|
||||
this.rconThread = RemoteControlListener.a((IMinecraftServer) this);
|
||||
this.rconThread = RemoteControlListener.create(this);
|
||||
+ this.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this.rconConsoleSource); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.getMaxTickTime() > 0L) {
|
||||
@@ -347,6 +417,7 @@
|
||||
this.queryThreadGs4.b();
|
||||
if (this.getMaxTickLength() > 0L) {
|
||||
@@ -337,6 +407,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
+ System.exit(0); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -380,7 +451,15 @@
|
||||
@@ -358,7 +429,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
|
||||
- this.getCommandDispatcher().a(servercommand.source, servercommand.msg);
|
||||
- this.getCommands().performCommand(servercommand.source, servercommand.msg);
|
||||
+ // CraftBukkit start - ServerCommand for preprocessing
|
||||
+ ServerCommandEvent event = new ServerCommandEvent(console, servercommand.msg);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) continue;
|
||||
+ servercommand = new ServerCommand(event.getCommand(), servercommand.source);
|
||||
+
|
||||
+ // this.getCommandDispatcher().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
|
||||
+ // this.getCommands().performCommand(servercommand.source, servercommand.msg); // Called in dispatchServerCommand
|
||||
+ server.dispatchServerCommand(console, servercommand);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -585,14 +664,45 @@
|
||||
@@ -568,14 +647,45 @@
|
||||
|
||||
@Override
|
||||
public String getPlugins() {
|
||||
public String getPluginNames() {
|
||||
- return "";
|
||||
+ // CraftBukkit start - Whole method
|
||||
+ StringBuilder result = new StringBuilder();
|
||||
@ -210,30 +208,30 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public String executeRemoteCommand(String s) {
|
||||
this.rconConsoleSource.clearMessages();
|
||||
this.executeSync(() -> {
|
||||
- this.getCommandDispatcher().a(this.rconConsoleSource.getWrapper(), s);
|
||||
public String runCommand(String s) {
|
||||
this.rconConsoleSource.prepareForCommand();
|
||||
this.executeBlocking(() -> {
|
||||
- this.getCommands().performCommand(this.rconConsoleSource.createCommandSourceStack(), s);
|
||||
+ // CraftBukkit start - fire RemoteServerCommandEvent
|
||||
+ RemoteServerCommandEvent event = new RemoteServerCommandEvent(remoteConsole, s);
|
||||
+ server.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.getWrapper());
|
||||
+ ServerCommand serverCommand = new ServerCommand(event.getCommand(), rconConsoleSource.createCommandSourceStack());
|
||||
+ server.dispatchServerCommand(remoteConsole, serverCommand);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
return this.rconConsoleSource.getMessages();
|
||||
return this.rconConsoleSource.getCommandResponse();
|
||||
}
|
||||
@@ -665,4 +775,15 @@
|
||||
public IChatBaseComponent ba() {
|
||||
@@ -649,4 +759,15 @@
|
||||
public IChatBaseComponent getResourcePackPrompt() {
|
||||
return this.resourcePackPrompt;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean isDebugging() {
|
||||
+ return this.getDedicatedServerProperties().debug;
|
||||
+ return this.getProperties().debug;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
@ -11,11 +11,11 @@
|
||||
+
|
||||
public class DedicatedServerProperties extends PropertyManager<DedicatedServerProperties> {
|
||||
|
||||
+ public final boolean debug = this.getBoolean("debug", false); // CraftBukkit
|
||||
public final boolean onlineMode = this.getBoolean("online-mode", true);
|
||||
public final boolean preventProxyConnections = this.getBoolean("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.getString("server-ip", "");
|
||||
@@ -64,8 +70,10 @@
|
||||
+ public final boolean debug = this.get("debug", false); // CraftBukkit
|
||||
public final boolean onlineMode = this.get("online-mode", true);
|
||||
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
|
||||
public final String serverIp = this.get("server-ip", "");
|
||||
@@ -67,8 +73,10 @@
|
||||
@Nullable
|
||||
private GeneratorSettings worldGenSettings;
|
||||
|
||||
@ -25,18 +25,18 @@
|
||||
+ public DedicatedServerProperties(Properties properties, OptionSet optionset) {
|
||||
+ super(properties, optionset);
|
||||
+ // CraftBukkit end
|
||||
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.levelName = this.getString("level-name", "world");
|
||||
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
|
||||
this.levelName = this.get("level-name", "world");
|
||||
@@ -112,13 +120,15 @@
|
||||
this.whiteList = this.b("white-list", false);
|
||||
this.whiteList = this.getMutable("white-list", false);
|
||||
}
|
||||
|
||||
- public static DedicatedServerProperties load(Path path) {
|
||||
- return new DedicatedServerProperties(loadPropertiesFile(path));
|
||||
- public static DedicatedServerProperties fromFile(Path path) {
|
||||
- return new DedicatedServerProperties(loadFromFile(path));
|
||||
+ // CraftBukkit start
|
||||
+ public static DedicatedServerProperties load(Path path, OptionSet optionset) {
|
||||
+ return new DedicatedServerProperties(loadPropertiesFile(path), optionset);
|
||||
+ public static DedicatedServerProperties fromFile(Path path, OptionSet optionset) {
|
||||
+ return new DedicatedServerProperties(loadFromFile(path), optionset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,5 +46,5 @@
|
||||
+ DedicatedServerProperties dedicatedserverproperties = new DedicatedServerProperties(properties, optionset);
|
||||
+ // CraftBukkit end
|
||||
|
||||
dedicatedserverproperties.a(iregistrycustom);
|
||||
dedicatedserverproperties.getWorldGenSettings(iregistrycustom);
|
||||
return dedicatedserverproperties;
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
- public DedicatedServerSettings(Path path) {
|
||||
- this.source = path;
|
||||
- this.properties = DedicatedServerProperties.load(path);
|
||||
- this.properties = DedicatedServerProperties.fromFile(path);
|
||||
+ // CraftBukkit start
|
||||
+ public DedicatedServerSettings(OptionSet optionset) {
|
||||
+ this.source = ((File) optionset.valueOf("config")).toPath();
|
||||
+ this.properties = DedicatedServerProperties.load(source, optionset);
|
||||
+ this.properties = DedicatedServerProperties.fromFile(source, optionset);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
|
@ -29,12 +29,12 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static Properties loadPropertiesFile(Path path) {
|
||||
public static Properties loadFromFile(Path path) {
|
||||
Properties properties = new Properties();
|
||||
|
||||
@@ -58,6 +73,11 @@
|
||||
|
||||
public void savePropertiesFile(Path path) {
|
||||
public void store(Path path) {
|
||||
try {
|
||||
+ // CraftBukkit start - Don't attempt writing to file if it's read only
|
||||
+ if (path.toFile().exists() && !path.toFile().canWrite()) {
|
||||
@ -45,7 +45,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> wrapNumberDeserializer(Function<String, V> function) {
|
||||
return (s) -> {
|
||||
try {
|
||||
- return (Number) function.apply(s);
|
||||
@ -56,7 +56,7 @@
|
||||
@@ -105,7 +125,7 @@
|
||||
|
||||
@Nullable
|
||||
private String c(String s) {
|
||||
private String getStringRaw(String s) {
|
||||
- return (String) this.properties.get(s);
|
||||
+ return (String) getOverride(s, this.properties.getProperty(s)); // CraftBukkit
|
||||
}
|
||||
@ -70,25 +70,7 @@
|
||||
+ return new PropertyManager.EditableProperty(s, v1, function1); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected <V> V a(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -162,7 +182,7 @@
|
||||
}
|
||||
|
||||
protected int getInt(String s, int i) {
|
||||
- return (Integer) this.a(s, a(Integer::parseInt), (Object) i);
|
||||
+ return (Integer) this.a(s, a(Integer::parseInt), i); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected PropertyManager<T>.EditableProperty<Integer> b(String s, int i) {
|
||||
@@ -174,7 +194,7 @@
|
||||
}
|
||||
|
||||
protected long getLong(String s, long i) {
|
||||
- return (Long) this.a(s, a(Long::parseLong), (Object) i);
|
||||
+ return (Long) this.a(s, a(Long::parseLong), i); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected boolean getBoolean(String s, boolean flag) {
|
||||
protected <V> V get(String s, Function<String, V> function, UnaryOperator<V> unaryoperator, Function<V, String> function1, V v0) {
|
||||
@@ -197,7 +217,7 @@
|
||||
return properties;
|
||||
}
|
||||
@ -108,7 +90,7 @@
|
||||
this.value = object;
|
||||
this.serializer = function;
|
||||
@@ -219,7 +239,7 @@
|
||||
Properties properties = PropertyManager.this.a();
|
||||
Properties properties = PropertyManager.this.cloneProperties();
|
||||
|
||||
properties.put(this.key, this.serializer.apply(v0));
|
||||
- return PropertyManager.this.reload(iregistrycustom, properties);
|
||||
|
@ -1,20 +1,20 @@
|
||||
--- a/net/minecraft/server/gui/ServerGUI.java
|
||||
+++ b/net/minecraft/server/gui/ServerGUI.java
|
||||
@@ -96,7 +96,7 @@
|
||||
private JComponent c() {
|
||||
private JComponent buildInfoPanel() {
|
||||
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);
|
||||
collection.add(guistatscomponent::close);
|
||||
@@ -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
|
||||
public void a(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
|
||||
public void print(JTextArea jtextarea, JScrollPane jscrollpane, String s) {
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
@@ -181,7 +182,7 @@
|
||||
|
@ -1,15 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
||||
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
||||
@@ -73,7 +73,7 @@
|
||||
while (objectiterator.hasNext()) {
|
||||
Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next();
|
||||
|
||||
- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> {
|
||||
+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
|
||||
return ticket.b(this.ticketTickCounter);
|
||||
})) {
|
||||
this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
|
||||
@@ -109,10 +109,25 @@
|
||||
@@ -125,10 +125,25 @@
|
||||
}
|
||||
|
||||
if (!this.chunksToUpdateFutures.isEmpty()) {
|
||||
@ -23,7 +14,7 @@
|
||||
+ iter.remove();
|
||||
+ expectedSize--;
|
||||
+
|
||||
playerchunk.a(playerchunkmap, this.mainThreadExecutor);
|
||||
playerchunk.updateFutures(playerchunkmap, this.mainThreadExecutor);
|
||||
- });
|
||||
- this.chunksToUpdateFutures.clear();
|
||||
+
|
||||
@ -38,20 +29,17 @@
|
||||
return true;
|
||||
} else {
|
||||
if (!this.ticketsToRelease.isEmpty()) {
|
||||
@@ -148,23 +163,25 @@
|
||||
@@ -164,7 +179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- void addTicket(long i, Ticket<?> ticket) {
|
||||
+ boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
int j = getLowestTicketLevel(arraysetsorted);
|
||||
- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket);
|
||||
+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
|
||||
|
||||
ticket1.a(this.ticketTickCounter);
|
||||
if (ticket.b() < j) {
|
||||
this.ticketTracker.update(i, ticket.b(), true);
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
||||
int j = getTicketLevelAt(arraysetsorted);
|
||||
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
|
||||
@@ -174,13 +189,15 @@
|
||||
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
|
||||
}
|
||||
|
||||
+ return ticket == ticket1; // CraftBukkit
|
||||
@ -59,7 +47,7 @@
|
||||
|
||||
- void removeTicket(long i, Ticket<?> ticket) {
|
||||
+ boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
||||
|
||||
+ boolean removed = false; // CraftBukkit
|
||||
if (arraysetsorted.remove(ticket)) {
|
||||
@ -68,49 +56,49 @@
|
||||
}
|
||||
|
||||
if (arraysetsorted.isEmpty()) {
|
||||
@@ -172,16 +189,29 @@
|
||||
@@ -188,16 +205,29 @@
|
||||
}
|
||||
|
||||
this.ticketTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
|
||||
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
|
||||
+ return removed; // CraftBukkit
|
||||
}
|
||||
|
||||
public <T> void a(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
- this.addTicket(chunkcoordintpair.pair(), new Ticket<>(tickettype, i, t0));
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
- this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(tickettype, i, t0));
|
||||
+ // CraftBukkit start
|
||||
+ this.addTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
||||
+ }
|
||||
+
|
||||
+ public <T> boolean addTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
||||
+ return this.addTicket(chunkcoordintpair.pair(), new Ticket<>(ticketType, level, identifier));
|
||||
+ return this.addTicket(chunkcoordintpair.toLong(), new Ticket<>(ticketType, level, identifier));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <T> void b(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
public <T> void removeTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
- Ticket<T> ticket = new Ticket<>(tickettype, i, t0);
|
||||
+ // CraftBukkit start
|
||||
+ this.removeTicketAtLevel(tickettype, chunkcoordintpair, i, t0);
|
||||
+ }
|
||||
|
||||
- this.removeTicket(chunkcoordintpair.pair(), ticket);
|
||||
- this.removeTicket(chunkcoordintpair.toLong(), ticket);
|
||||
+ public <T> boolean removeTicketAtLevel(TicketType<T> ticketType, ChunkCoordIntPair chunkcoordintpair, int level, T identifier) {
|
||||
+ Ticket<T> ticket = new Ticket<>(ticketType, level, identifier);
|
||||
+
|
||||
+ return this.removeTicket(chunkcoordintpair.pair(), ticket);
|
||||
+ return this.removeTicket(chunkcoordintpair.toLong(), ticket);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -224,6 +254,7 @@
|
||||
public void b(SectionPosition sectionposition, EntityPlayer entityplayer) {
|
||||
long i = sectionposition.r().pair();
|
||||
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -252,6 +282,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
|
||||
long i = chunkcoordintpair.toLong();
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
||||
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208
|
||||
|
||||
objectset.remove(entityplayer);
|
||||
if (objectset.isEmpty()) {
|
||||
@@ -300,6 +331,26 @@
|
||||
|
||||
@@ -347,6 +378,26 @@
|
||||
return this.tickingTicketsTracker;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -122,7 +110,7 @@
|
||||
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue();
|
||||
+ if (tickets.remove(target)) {
|
||||
+ // copied from removeTicket
|
||||
+ this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false);
|
||||
+ this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(tickets), false);
|
||||
+
|
||||
+ // can't use entry after it's removed
|
||||
+ if (tickets.isEmpty()) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
+ // CraftBukkit start - properly implement isChunkLoaded
|
||||
+ public boolean isChunkLoaded(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkCoordIntPair.asLong(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
@ -14,7 +14,7 @@
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getChunkUnchecked(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunkIfPresent(ChunkCoordIntPair.asLong(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
@ -38,8 +38,8 @@
|
||||
if (playerchunk == null) {
|
||||
return null;
|
||||
} else {
|
||||
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow((Object) null);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
||||
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow((Object) null);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.getFutureIfPresent(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (either == null) {
|
||||
return null;
|
||||
@ -48,43 +48,43 @@
|
||||
+ IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess1 != null) {
|
||||
this.a(k, ichunkaccess1, ChunkStatus.FULL);
|
||||
this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL);
|
||||
@@ -228,7 +246,15 @@
|
||||
int l = 33 + ChunkStatus.a(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getChunk(k);
|
||||
int l = 33 + ChunkStatus.getDistance(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
|
||||
|
||||
- if (flag) {
|
||||
+ // CraftBukkit start - don't add new ticket for currently unloading chunk
|
||||
+ boolean currentlyUnloading = false;
|
||||
+ if (playerchunk != null) {
|
||||
+ PlayerChunk.State oldChunkState = PlayerChunk.getChunkState(playerchunk.oldTicketLevel);
|
||||
+ PlayerChunk.State currentChunkState = PlayerChunk.getChunkState(playerchunk.getTicketLevel());
|
||||
+ currentlyUnloading = (oldChunkState.isAtLeast(PlayerChunk.State.BORDER) && !currentChunkState.isAtLeast(PlayerChunk.State.BORDER));
|
||||
+ PlayerChunk.State oldChunkState = PlayerChunk.getFullChunkStatus(playerchunk.oldTicketLevel);
|
||||
+ PlayerChunk.State currentChunkState = PlayerChunk.getFullChunkStatus(playerchunk.getTicketLevel());
|
||||
+ currentlyUnloading = (oldChunkState.isOrAfter(PlayerChunk.State.BORDER) && !currentChunkState.isOrAfter(PlayerChunk.State.BORDER));
|
||||
+ }
|
||||
+ if (flag && !currentlyUnloading) {
|
||||
+ // CraftBukkit end
|
||||
this.distanceManager.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.a(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
@@ -247,7 +273,7 @@
|
||||
}
|
||||
|
||||
private boolean a(@Nullable PlayerChunk playerchunk, int i) {
|
||||
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
|
||||
- return playerchunk == null || playerchunk.getTicketLevel() > i;
|
||||
+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,7 +333,7 @@
|
||||
}
|
||||
@@ -314,7 +340,7 @@
|
||||
} else if (!this.level.shouldTickBlocksAt(i)) {
|
||||
return false;
|
||||
} else {
|
||||
- Either<Chunk, PlayerChunk.Failure> either = (Either) playerchunk.getTickingChunkFuture().getNow((Object) null);
|
||||
+ Either<Chunk, PlayerChunk.Failure> either = (Either) playerchunk.getTickingChunkFuture().getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
public boolean a(long i) {
|
||||
- return this.a(i, PlayerChunk::a);
|
||||
+ 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) {
|
||||
@@ -329,11 +355,31 @@
|
||||
return either != null && either.left().isPresent();
|
||||
}
|
||||
@@ -327,11 +353,31 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
@ -104,56 +104,50 @@
|
||||
|
||||
+ // CraftBukkit start - modelled on below
|
||||
+ public void purgeUnload() {
|
||||
+ this.level.getMethodProfiler().enter("purge");
|
||||
+ this.distanceManager.purgeTickets();
|
||||
+ this.tickDistanceManager();
|
||||
+ this.level.getMethodProfiler().exitEnter("unload");
|
||||
+ this.chunkMap.unloadChunks(() -> true);
|
||||
+ this.level.getMethodProfiler().exit();
|
||||
+ this.level.getProfiler().push("purge");
|
||||
+ this.distanceManager.purgeStaleTickets();
|
||||
+ this.runDistanceManagerUpdates();
|
||||
+ this.level.getProfiler().popPush("unload");
|
||||
+ this.chunkMap.tick(() -> true);
|
||||
+ this.level.getProfiler().pop();
|
||||
+ this.clearCache();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void tick(BooleanSupplier booleansupplier) {
|
||||
this.level.getMethodProfiler().enter("purge");
|
||||
@@ -354,12 +400,12 @@
|
||||
this.lastInhabitedUpdate = i;
|
||||
WorldData worlddata = this.level.getWorldData();
|
||||
boolean flag = this.level.isDebugWorld();
|
||||
- boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
|
||||
+ boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.getPlayers().isEmpty(); // CraftBukkit
|
||||
this.level.getProfiler().push("purge");
|
||||
@@ -360,7 +406,7 @@
|
||||
|
||||
if (!flag) {
|
||||
this.level.getMethodProfiler().enter("pollingChunks");
|
||||
gameprofilerfiller.push("pollingChunks");
|
||||
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
- boolean flag2 = worlddata.getTime() % 400L == 0L;
|
||||
+ boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
- boolean flag1 = worlddata.getGameTime() % 400L == 0L;
|
||||
+ boolean flag1 = level.ticksPerAnimalSpawns != 0L && worlddata.getGameTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
|
||||
this.level.getMethodProfiler().enter("naturalSpawnCount");
|
||||
int l = this.distanceManager.b();
|
||||
@@ -394,7 +440,7 @@
|
||||
gameprofilerfiller.push("naturalSpawnCount");
|
||||
int l = this.distanceManager.getNaturalSpawnChunkCount();
|
||||
@@ -381,7 +427,7 @@
|
||||
}
|
||||
|
||||
this.level.getMethodProfiler().exitEnter("broadcast");
|
||||
list.forEach((playerchunk) -> {
|
||||
- Optional optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).left();
|
||||
+ Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_LEVEL_CHUNK)).left(); // CraftBukkit - decompile error
|
||||
gameprofilerfiller.popPush("spawnAndTick");
|
||||
- boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
|
||||
+ boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.players().isEmpty(); // CraftBukkit
|
||||
|
||||
Objects.requireNonNull(playerchunk);
|
||||
optional.ifPresent(playerchunk::a);
|
||||
@@ -551,13 +597,19 @@
|
||||
Collections.shuffle(list);
|
||||
Iterator iterator1 = list.iterator();
|
||||
@@ -571,18 +617,26 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected boolean executeNext() {
|
||||
- protected boolean pollTask() {
|
||||
+ // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
|
||||
+ public boolean executeNext() {
|
||||
+ public boolean pollTask() {
|
||||
+ try {
|
||||
if (ChunkProviderServer.this.tickDistanceManager()) {
|
||||
if (ChunkProviderServer.this.runDistanceManagerUpdates()) {
|
||||
return true;
|
||||
} else {
|
||||
ChunkProviderServer.this.lightEngine.queueUpdate();
|
||||
return super.executeNext();
|
||||
ChunkProviderServer.this.lightEngine.tryScheduleUpdate();
|
||||
return super.pollTask();
|
||||
}
|
||||
+ } finally {
|
||||
+ chunkMap.callbackExecutor.run();
|
||||
@ -161,4 +155,21 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- private static final class a extends Record {
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ private static final record a(Chunk chunk, PlayerChunk holder) {
|
||||
|
||||
+ /*
|
||||
final Chunk chunk;
|
||||
final PlayerChunk holder;
|
||||
|
||||
@@ -602,6 +656,8 @@
|
||||
public final boolean equals(Object object) {
|
||||
return this.equals<invokedynamic>(this, object);
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public Chunk chunk() {
|
||||
return this.chunk;
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
+++ b/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
@@ -42,6 +42,12 @@
|
||||
@@ -40,6 +40,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
public class EntityTrackerEntry {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -63,8 +69,12 @@
|
||||
@@ -61,8 +67,12 @@
|
||||
private List<Entity> lastPassengers;
|
||||
private boolean wasRiding;
|
||||
private boolean wasOnGround;
|
||||
@ -27,12 +27,12 @@
|
||||
this.ap = Vec3D.ZERO;
|
||||
this.lastPassengers = Collections.emptyList();
|
||||
this.level = worldserver;
|
||||
@@ -84,22 +94,22 @@
|
||||
@@ -82,22 +92,22 @@
|
||||
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
this.lastPassengers = list;
|
||||
- this.broadcast.accept(new PacketPlayOutMount(this.entity));
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.entity)); // CraftBukkit
|
||||
+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit
|
||||
}
|
||||
|
||||
- if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) {
|
||||
@ -42,26 +42,26 @@
|
||||
|
||||
- if (itemstack.getItem() instanceof ItemWorldMap) {
|
||||
+ 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
|
||||
Integer integer = ItemWorldMap.d(itemstack);
|
||||
WorldMap worldmap = ItemWorldMap.a(integer, (World) this.level);
|
||||
Integer integer = ItemWorldMap.getMapId(itemstack);
|
||||
WorldMap worldmap = ItemWorldMap.getSavedData(integer, this.level);
|
||||
|
||||
if (worldmap != null) {
|
||||
- Iterator iterator = this.level.getPlayers().iterator();
|
||||
- Iterator iterator = this.level.players().iterator();
|
||||
+ Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
+ EntityPlayer entityplayer = iterator.next().d(); // CraftBukkit
|
||||
+ EntityPlayer entityplayer = iterator.next().getPlayer(); // CraftBukkit
|
||||
|
||||
worldmap.a((EntityHuman) entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.a(integer, entityplayer);
|
||||
@@ -142,6 +152,17 @@
|
||||
worldmap.tickCarriedBy(entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
|
||||
@@ -140,6 +150,17 @@
|
||||
boolean flag2 = flag1 || this.tickCount % 60 == 0;
|
||||
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
|
||||
|
||||
+ // CraftBukkit start - Code moved from below
|
||||
+ if (flag2) {
|
||||
+ this.d();
|
||||
+ this.updateSentPos();
|
||||
+ }
|
||||
+
|
||||
+ if (flag3) {
|
||||
@ -71,17 +71,17 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.tickCount > 0 || this.entity instanceof EntityArrow) {
|
||||
long k = PacketPlayOutEntity.a(vec3d.x);
|
||||
long l = PacketPlayOutEntity.a(vec3d.y);
|
||||
@@ -180,6 +201,7 @@
|
||||
long k = PacketPlayOutEntity.entityToPacket(vec3d.x);
|
||||
long l = PacketPlayOutEntity.entityToPacket(vec3d.y);
|
||||
@@ -178,6 +199,7 @@
|
||||
}
|
||||
|
||||
this.c();
|
||||
this.sendDirtyEntityData();
|
||||
+ /* CraftBukkit start - Code moved up
|
||||
if (flag2) {
|
||||
this.d();
|
||||
this.updateSentPos();
|
||||
}
|
||||
@@ -188,6 +210,7 @@
|
||||
@@ -186,6 +208,7 @@
|
||||
this.yRotp = i;
|
||||
this.xRotp = j;
|
||||
}
|
||||
@ -89,11 +89,11 @@
|
||||
|
||||
this.wasRiding = false;
|
||||
}
|
||||
@@ -203,7 +226,27 @@
|
||||
@@ -201,7 +224,27 @@
|
||||
|
||||
++this.tickCount;
|
||||
if (this.entity.hurtMarked) {
|
||||
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
|
||||
- this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ // CraftBukkit start - Create PlayerVelocity event
|
||||
+ boolean cancelled = false;
|
||||
+
|
||||
@ -112,23 +112,23 @@
|
||||
+ }
|
||||
+
|
||||
+ if (!cancelled) {
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.entity.hurtMarked = false;
|
||||
}
|
||||
|
||||
@@ -218,13 +261,16 @@
|
||||
@@ -216,13 +259,16 @@
|
||||
PlayerConnection playerconnection = entityplayer.connection;
|
||||
|
||||
Objects.requireNonNull(entityplayer.connection);
|
||||
- this.a(playerconnection::sendPacket);
|
||||
+ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player
|
||||
this.entity.c(entityplayer);
|
||||
- this.sendPairingData(playerconnection::send);
|
||||
+ this.sendPairingData(playerconnection::send, entityplayer); // CraftBukkit - add player
|
||||
this.entity.startSeenByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
- public void a(Consumer<Packet<?>> consumer) {
|
||||
+ public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
|
||||
- public void sendPairingData(Consumer<Packet<?>> consumer) {
|
||||
+ public void sendPairingData(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
|
||||
if (this.entity.isRemoved()) {
|
||||
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
|
||||
+ // CraftBukkit start - Remove useless error spam, just return
|
||||
@ -137,10 +137,10 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Packet<?> packet = this.entity.getPacket();
|
||||
@@ -240,6 +286,12 @@
|
||||
Packet<?> packet = this.entity.getAddEntityPacket();
|
||||
@@ -238,6 +284,12 @@
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributeMap().b();
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
|
||||
|
||||
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
||||
+ if (this.entity.getId() == entityplayer.getId()) {
|
||||
@ -151,23 +151,23 @@
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
|
||||
}
|
||||
@@ -271,8 +323,14 @@
|
||||
@@ -269,8 +321,14 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
|
||||
}
|
||||
+ ((EntityLiving) this.entity).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
|
||||
+ ((EntityLiving) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Fix for nonsensical head yaw
|
||||
+ this.yHeadRotp = MathHelper.d(this.entity.getHeadRotation() * 256.0F / 360.0F);
|
||||
+ this.yHeadRotp = MathHelper.floor(this.entity.getYHeadRot() * 256.0F / 360.0F);
|
||||
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
EntityLiving entityliving = (EntityLiving) this.entity;
|
||||
Iterator iterator = entityliving.getEffects().iterator();
|
||||
@@ -313,6 +371,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributeMap().getAttributes();
|
||||
Iterator iterator = entityliving.getActiveEffects().iterator();
|
||||
@@ -311,6 +369,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
+ // CraftBukkit start - Send scaled max health
|
||||
@ -175,6 +175,6 @@
|
||||
+ ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.entity.getId(), set));
|
||||
this.broadcastAndSend(new PacketPlayOutUpdateAttributes(this.entity.getId(), set));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunk.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunk.java
|
||||
@@ -38,6 +38,10 @@
|
||||
@@ -35,6 +35,10 @@
|
||||
import net.minecraft.world.level.chunk.ProtoChunkExtension;
|
||||
import net.minecraft.world.level.lighting.LightEngine;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
public class PlayerChunk {
|
||||
|
||||
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
|
||||
@@ -75,11 +79,11 @@
|
||||
@@ -72,11 +76,11 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
@ -25,30 +25,30 @@
|
||||
this.pos = chunkcoordintpair;
|
||||
this.levelHeightAccessor = levelheightaccessor;
|
||||
this.lightEngine = lightengine;
|
||||
@@ -92,6 +96,19 @@
|
||||
@@ -89,6 +93,19 @@
|
||||
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public Chunk getFullChunk() {
|
||||
+ if (!getChunkState(this.oldTicketLevel).isAtLeast(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
|
||||
+ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(PlayerChunk.State.BORDER)) return null; // note: using oldTicketLevel for isLoaded checks
|
||||
+ return this.getFullChunkUnchecked();
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getFullChunkUnchecked() {
|
||||
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getStatusFutureUnchecked(ChunkStatus.FULL);
|
||||
+ CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> statusFuture = this.getFutureIfPresentUnchecked(ChunkStatus.FULL);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either<IChunkAccess, PlayerChunk.Failure>) statusFuture.getNow(null);
|
||||
+ return (either == null) ? null : (Chunk) either.left().orElse(null);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.c());
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex());
|
||||
|
||||
@@ -117,9 +134,9 @@
|
||||
@@ -114,9 +131,9 @@
|
||||
@Nullable
|
||||
public Chunk getChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a();
|
||||
public Chunk getTickingChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getTickingChunkFuture();
|
||||
- Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
@ -57,15 +57,15 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -164,6 +181,7 @@
|
||||
@@ -161,6 +178,7 @@
|
||||
if (chunk != null) {
|
||||
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
|
||||
|
||||
+ if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
this.hasChangedSections = true;
|
||||
this.changedBlocksPerSection[i] = new ShortArraySet();
|
||||
@@ -274,7 +292,7 @@
|
||||
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
|
||||
@@ -271,7 +289,7 @@
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(i);
|
||||
|
||||
if (completablefuture != null) {
|
||||
@ -74,7 +74,7 @@
|
||||
boolean flag = either != null && either.right().isPresent();
|
||||
|
||||
if (!flag) {
|
||||
@@ -341,7 +359,7 @@
|
||||
@@ -338,7 +356,7 @@
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((either) -> {
|
||||
either.ifLeft((chunk) -> {
|
||||
@ -83,21 +83,21 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -358,6 +376,30 @@
|
||||
@@ -355,6 +373,30 @@
|
||||
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
|
||||
PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel);
|
||||
PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel);
|
||||
PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel);
|
||||
PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel);
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
|
||||
+ if (playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && !playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) {
|
||||
+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ if (playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && !playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) {
|
||||
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk)either.left().orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
+ // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick
|
||||
+ // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag.
|
||||
+ // These actions may however happen deferred, so we manually set the needsSaving flag already here.
|
||||
+ chunk.setNeedsSaving(true);
|
||||
+ chunk.setUnsaved(true);
|
||||
+ chunk.unloadCallback();
|
||||
+ });
|
||||
+ }
|
||||
@ -111,26 +111,17 @@
|
||||
+ playerchunkmap.callbackExecutor.run();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
CompletableFuture completablefuture;
|
||||
|
||||
if (flag) {
|
||||
@@ -388,7 +430,7 @@
|
||||
if (flag2 && !flag3) {
|
||||
completablefuture = this.fullChunkFuture;
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
- this.a(completablefuture.thenApply((either1) -> {
|
||||
+ this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error
|
||||
Objects.requireNonNull(playerchunkmap);
|
||||
return either1.ifLeft(playerchunkmap::a);
|
||||
}), "unfull");
|
||||
@@ -432,6 +474,26 @@
|
||||
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
|
||||
@@ -425,6 +467,26 @@
|
||||
|
||||
this.onLevelChange.a(this.pos, this::k, this.ticketLevel, this::d);
|
||||
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
|
||||
+ if (!playerchunk_state.isAtLeast(PlayerChunk.State.BORDER) && playerchunk_state1.isAtLeast(PlayerChunk.State.BORDER)) {
|
||||
+ this.getStatusFutureUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ if (!playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) {
|
||||
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
|
||||
+ Chunk chunk = (Chunk)either.left().orElse(null);
|
||||
+ if (chunk != null) {
|
||||
+ playerchunkmap.callbackExecutor.execute(() -> {
|
||||
@ -149,4 +140,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static ChunkStatus getChunkStatus(int i) {
|
||||
public static ChunkStatus getStatus(int i) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunkMap.java
|
||||
@@ -91,6 +91,8 @@
|
||||
@@ -95,6 +95,8 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
||||
|
||||
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
||||
@@ -129,6 +131,27 @@
|
||||
@@ -133,6 +135,27 @@
|
||||
private final Queue<Runnable> unloadQueue;
|
||||
int viewDistance;
|
||||
|
||||
@ -35,9 +35,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
|
||||
super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
|
||||
super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
|
||||
this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
@@ -281,9 +304,12 @@
|
||||
@@ -326,9 +349,12 @@
|
||||
|
||||
return completablefuture1.thenApply((list1) -> {
|
||||
List<IChunkAccess> list2 = Lists.newArrayList();
|
||||
@ -52,47 +52,39 @@
|
||||
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
||||
Optional<IChunkAccess> optional = either.left();
|
||||
|
||||
@@ -390,7 +416,7 @@
|
||||
this.j();
|
||||
@@ -435,7 +461,7 @@
|
||||
this.flushWorker();
|
||||
} else {
|
||||
this.visibleChunkMap.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
|
||||
this.visibleChunkMap.values().stream().filter(PlayerChunk::wasAccessibleSinceLastSave).forEach((playerchunk) -> {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkToSave().getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
||||
this.saveChunk(ichunkaccess);
|
||||
@@ -401,7 +427,6 @@
|
||||
}
|
||||
this.save(ichunkaccess);
|
||||
@@ -488,7 +514,7 @@
|
||||
|
||||
}
|
||||
-
|
||||
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
|
||||
|
||||
@@ -440,7 +465,7 @@
|
||||
|
||||
private void a(long i, PlayerChunk playerchunk) {
|
||||
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave();
|
||||
private void scheduleUnload(long i, PlayerChunk playerchunk) {
|
||||
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
|
||||
- Consumer consumer = (ichunkaccess) -> {
|
||||
+ Consumer<IChunkAccess> consumer = (ichunkaccess) -> { // CraftBukkit - decompile error
|
||||
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave();
|
||||
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
|
||||
|
||||
if (completablefuture1 != completablefuture) {
|
||||
@@ -616,7 +641,21 @@
|
||||
@@ -664,7 +690,21 @@
|
||||
|
||||
private static void a(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
if (!list.isEmpty()) {
|
||||
- worldserver.b(EntityTypes.a(list, (World) worldserver));
|
||||
- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver));
|
||||
+ // 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).filter((entity) -> {
|
||||
+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> {
|
||||
+ boolean needsRemoval = false;
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer();
|
||||
+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) {
|
||||
+ entity.die();
|
||||
+ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) {
|
||||
+ entity.discard();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
|
||||
+ entity.die();
|
||||
+ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
|
||||
+ entity.discard();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ return !needsRemoval;
|
||||
@ -101,35 +93,35 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -844,7 +883,8 @@
|
||||
@@ -894,7 +934,8 @@
|
||||
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.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
- csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse((Object) null), optional1.map(Chunk::getFullStatus).orElse((Object) null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
+ // 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.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return chunk.getTileEntities().size();
|
||||
}).orElse(0));
|
||||
}
|
||||
@@ -853,7 +893,7 @@
|
||||
+ csvwriter.writeRow(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getStatus).orElse(null), optional1.map(Chunk::getFullStatus).orElse(null), printFuture(playerchunk.getFullChunkFuture()), printFuture(playerchunk.getTickingChunkFuture()), printFuture(playerchunk.getEntityTickingChunkFuture()), this.distanceManager.getTicketDebugString(i), this.anyPlayerCloseEnoughForSpawning(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return chunk.getBlockEntities().size();
|
||||
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
|
||||
return chunk.getBlockTicks().count();
|
||||
@@ -907,7 +948,7 @@
|
||||
|
||||
private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
|
||||
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
|
||||
try {
|
||||
- Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<Chunk, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
return either != null ? (String) either.map((chunk) -> {
|
||||
return "done";
|
||||
@@ -871,7 +911,7 @@
|
||||
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
@@ -925,7 +966,7 @@
|
||||
private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
||||
|
||||
- return nbttagcompound == null ? null : this.getChunkData(this.level.getDimensionKey(), this.overworldDataStorage, nbttagcompound);
|
||||
+ return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, chunkcoordintpair, level); // CraftBukkit
|
||||
- return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer());
|
||||
+ return nbttagcompound == null ? null : this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, this.generator.getTypeNameForDataFixer(), chunkcoordintpair, level); // CraftBukkit
|
||||
}
|
||||
|
||||
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1238,7 +1278,7 @@
|
||||
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1349,7 +1390,7 @@
|
||||
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
|
||||
|
||||
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
||||
@ -137,15 +129,17 @@
|
||||
+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit
|
||||
this.entity = entity;
|
||||
this.range = i;
|
||||
this.lastSectionPos = SectionPosition.a(entity);
|
||||
@@ -1291,10 +1331,18 @@
|
||||
this.lastSectionPos = SectionPosition.of(entity);
|
||||
@@ -1402,12 +1443,20 @@
|
||||
|
||||
public void updatePlayer(EntityPlayer entityplayer) {
|
||||
if (entityplayer != this.entity) {
|
||||
- Vec3D vec3d = entityplayer.getPositionVector().d(this.serverEntity.b());
|
||||
+ Vec3D vec3d = entityplayer.getPositionVector().d(this.entity.getPositionVector()); // MC-155077, SPIGOT-5113
|
||||
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.entity.a(entityplayer);
|
||||
- Vec3D vec3d = entityplayer.position().subtract(this.serverEntity.sentPos());
|
||||
+ Vec3D vec3d = entityplayer.position().subtract(this.entity.position()); // MC-155077, SPIGOT-5113
|
||||
double d0 = (double) Math.min(this.getEffectiveRange(), (PlayerChunkMap.this.viewDistance - 1) * 16);
|
||||
double d1 = vec3d.x * vec3d.x + vec3d.z * vec3d.z;
|
||||
double d2 = d0 * d0;
|
||||
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);
|
||||
|
||||
+ // CraftBukkit start - respect vanish API
|
||||
+ if (this.entity instanceof EntityPlayer) {
|
||||
@ -157,4 +151,4 @@
|
||||
+ // CraftBukkit end
|
||||
if (flag) {
|
||||
if (this.seenBy.add(entityplayer.connection)) {
|
||||
this.serverEntity.b(entityplayer);
|
||||
this.serverEntity.addPairing(entityplayer);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/level/PlayerInteractManager.java
|
||||
@@ -25,6 +25,27 @@
|
||||
@@ -24,6 +24,27 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -55,6 +76,13 @@
|
||||
@@ -54,6 +75,13 @@
|
||||
if (enumgamemode == this.gameModeForPlayer) {
|
||||
return false;
|
||||
} else {
|
||||
@ -39,93 +39,93 @@
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.a(enumgamemode, this.gameModeForPlayer);
|
||||
this.setGameModeForPlayer(enumgamemode, this.gameModeForPlayer);
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +93,7 @@
|
||||
@@ -64,7 +92,7 @@
|
||||
this.gameModeForPlayer = enumgamemode;
|
||||
enumgamemode.a(this.player.getAbilities());
|
||||
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); // CraftBukkit
|
||||
this.level.everyoneSleeping();
|
||||
enumgamemode.updatePlayerAbilities(this.player.getAbilities());
|
||||
this.player.onUpdateAbilities();
|
||||
- this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}));
|
||||
+ this.player.server.getPlayerList().broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit
|
||||
this.level.updateSleepingPlayerList();
|
||||
}
|
||||
|
||||
@@ -87,7 +115,7 @@
|
||||
@@ -86,7 +114,7 @@
|
||||
}
|
||||
|
||||
public void a() {
|
||||
public void tick() {
|
||||
- ++this.gameTicks;
|
||||
+ this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.hasDelayedDestroy) {
|
||||
@@ -143,9 +171,31 @@
|
||||
@@ -142,9 +170,31 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.level.a((EntityHuman) this.player, blockposition)) {
|
||||
if (!this.level.mayInteract(this.player, blockposition)) {
|
||||
+ // CraftBukkit start - fire PlayerInteractEvent
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
|
||||
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = level.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = level.getBlockEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getSelected(), EnumHand.MAIN_HAND);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = this.level.getBlockEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.isCreative()) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
|
||||
@@ -161,11 +211,43 @@
|
||||
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
|
||||
@@ -160,11 +210,43 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.level.getType(blockposition);
|
||||
iblockdata = this.level.getBlockState(blockposition);
|
||||
- if (!iblockdata.isAir()) {
|
||||
+ // CraftBukkit start - Swings at air do *NOT* exist.
|
||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
+ IBlockData data = this.level.getType(blockposition);
|
||||
+ IBlockData data = this.level.getBlockState(blockposition);
|
||||
+ if (data.getBlock() instanceof BlockDoor) {
|
||||
+ // For some reason *BOTH* the bottom/top part have to be marked updated.
|
||||
+ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ boolean bottom = data.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.above() : blockposition.below()));
|
||||
+ } else if (data.getBlock() instanceof BlockTrapdoor) {
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ }
|
||||
+ } else if (!iblockdata.isAir()) {
|
||||
iblockdata.attack(this.level, blockposition, this.player);
|
||||
f = iblockdata.getDamage(this.player, this.player.level, blockposition);
|
||||
f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition);
|
||||
}
|
||||
|
||||
+ if (event.useItemInHand() == Event.Result.DENY) {
|
||||
+ // If we 'insta destroyed' then the client needs to be informed.
|
||||
+ if (f > 1.0f) {
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getItemInHand(), f >= 1.0f);
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getSelected(), f >= 1.0f);
|
||||
+
|
||||
+ if (blockEvent.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@ -135,42 +135,42 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
|
||||
this.destroyAndAck(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
|
||||
} else {
|
||||
@@ -209,7 +291,7 @@
|
||||
@@ -208,7 +290,7 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.isDestroyingBlock = false;
|
||||
if (!Objects.equals(this.destroyPos, blockposition)) {
|
||||
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
|
||||
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
|
||||
this.level.a(this.player.getId(), this.destroyPos, -1);
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getType(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
|
||||
this.player.connection.send(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getBlockState(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
}
|
||||
@@ -225,17 +307,72 @@
|
||||
if (this.breakBlock(blockposition)) {
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
@@ -224,17 +306,72 @@
|
||||
if (this.destroyBlock(blockposition)) {
|
||||
this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
} else {
|
||||
- this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
|
||||
- this.player.connection.send(new PacketPlayOutBlockBreak(blockposition, this.level.getBlockState(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean breakBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.level.getType(blockposition);
|
||||
public boolean destroyBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.level.getBlockState(blockposition);
|
||||
+ // CraftBukkit start - fire BlockBreakEvent
|
||||
+ org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
|
||||
+ BlockBreakEvent event = null;
|
||||
+
|
||||
+ if (this.player instanceof EntityPlayer) {
|
||||
+ // Sword + Creative mode pre-cancel
|
||||
+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.level, blockposition, (EntityHuman) this.player);
|
||||
+ boolean isSwordNoBreak = !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player);
|
||||
+
|
||||
+ // 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!
|
||||
+ if (level.getTileEntity(blockposition) == null && !isSwordNoBreak) {
|
||||
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.getBlockData());
|
||||
+ this.player.connection.sendPacket(packet);
|
||||
+ if (level.getBlockEntity(blockposition) == null && !isSwordNoBreak) {
|
||||
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.defaultBlockState());
|
||||
+ this.player.connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
|
||||
@ -179,12 +179,12 @@
|
||||
+ event.setCancelled(isSwordNoBreak);
|
||||
+
|
||||
+ // Calculate default block experience
|
||||
+ IBlockData nmsData = this.level.getType(blockposition);
|
||||
+ IBlockData nmsData = this.level.getBlockState(blockposition);
|
||||
+ Block nmsBlock = nmsData.getBlock();
|
||||
+
|
||||
+ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
|
||||
+ ItemStack itemstack = this.player.getItemBySlot(EnumItemSlot.MAINHAND);
|
||||
+
|
||||
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
|
||||
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasCorrectToolForDrops(nmsBlock.defaultBlockState())) {
|
||||
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack));
|
||||
+ }
|
||||
+
|
||||
@ -195,58 +195,58 @@
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+
|
||||
+ // Brute force all possible updates
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(level, blockposition.shift(dir)));
|
||||
+ this.player.connection.send(new PacketPlayOutBlockChange(level, blockposition.relative(dir)));
|
||||
+ }
|
||||
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) {
|
||||
- if (!this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) {
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = this.level.getBlockEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.send(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
|
||||
+ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(iblockdata, this.level, blockposition, this.player)) { // CraftBukkit - false
|
||||
return false;
|
||||
} else {
|
||||
+ iblockdata = this.level.getType(blockposition); // CraftBukkit - update state from plugins
|
||||
+ iblockdata = this.level.getBlockState(blockposition); // CraftBukkit - update state from plugins
|
||||
+ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
|
||||
TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
TileEntity tileentity = this.level.getBlockEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -245,6 +382,10 @@
|
||||
} else if (this.player.a((World) this.level, blockposition, this.gameModeForPlayer)) {
|
||||
@@ -244,6 +381,10 @@
|
||||
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.BlockState state = bblock.getState();
|
||||
+ level.captureDrops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
block.a((World) this.level, blockposition, iblockdata, (EntityHuman) this.player);
|
||||
boolean flag = this.level.a(blockposition, false);
|
||||
block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
|
||||
boolean flag = this.level.removeBlock(blockposition, false);
|
||||
|
||||
@@ -253,19 +394,32 @@
|
||||
@@ -252,19 +393,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
- return true;
|
||||
+ // return true; // CraftBukkit
|
||||
} else {
|
||||
ItemStack itemstack = this.player.getItemInMainHand();
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
boolean flag1 = this.player.hasBlock(iblockdata);
|
||||
ItemStack itemstack = this.player.getMainHandItem();
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
boolean flag1 = this.player.hasCorrectToolForDrops(iblockdata);
|
||||
|
||||
itemstack.a(this.level, iblockdata, blockposition, this.player);
|
||||
itemstack.mineBlock(this.level, iblockdata, blockposition, this.player);
|
||||
- if (flag && flag1) {
|
||||
+ if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
|
||||
block.a(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1);
|
||||
block.playerDestroy(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1);
|
||||
}
|
||||
|
||||
- return true;
|
||||
@ -260,7 +260,7 @@
|
||||
+
|
||||
+ // Drop event experience
|
||||
+ if (flag && event != null) {
|
||||
+ iblockdata.getBlock().dropExperience(this.level, blockposition, event.getExpToDrop());
|
||||
+ iblockdata.getBlock().popExperience(this.level, blockposition, event.getExpToDrop());
|
||||
}
|
||||
+
|
||||
+ return true;
|
||||
@ -268,7 +268,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,12 +461,52 @@
|
||||
@@ -306,12 +460,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,63 +278,63 @@
|
||||
+ public BlockPosition interactPosition;
|
||||
+ public EnumHand interactHand;
|
||||
+ public ItemStack interactItemStack;
|
||||
public EnumInteractionResult a(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
public EnumInteractionResult useItemOn(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
|
||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
|
||||
IBlockData iblockdata = world.getBlockState(blockposition);
|
||||
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS;
|
||||
+ boolean cancelledBlock = false;
|
||||
|
||||
if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
|
||||
ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition);
|
||||
+ cancelledBlock = !(itileinventory instanceof ITileInventory);
|
||||
+ }
|
||||
+
|
||||
+ if (entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) {
|
||||
+ if (entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
|
||||
+ cancelledBlock = true;
|
||||
+ }
|
||||
+
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
|
||||
+ firedInteract = true;
|
||||
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||
+ interactPosition = blockposition.immutableCopy();
|
||||
+ interactPosition = blockposition.immutable();
|
||||
+ interactHand = enumhand;
|
||||
+ interactItemStack = itemstack.cloneItemStack();
|
||||
+ interactItemStack = itemstack.copy();
|
||||
+
|
||||
+ 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 (iblockdata.getBlock() instanceof BlockDoor) {
|
||||
+ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ boolean bottom = iblockdata.getValue(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ entityplayer.connection.send(new PacketPlayOutBlockChange(world, bottom ? blockposition.above() : blockposition.below()));
|
||||
+ } else if (iblockdata.getBlock() instanceof BlockCake) {
|
||||
+ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
||||
+ } else if (interactItemStack.getItem() instanceof ItemBisected) {
|
||||
+ // send a correcting update to the client, as it already placed the upper half of the bisected item
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up()));
|
||||
+ entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.relative(movingobjectpositionblock.getDirection()).above()));
|
||||
+
|
||||
+ // 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.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up()));
|
||||
+ entityplayer.connection.send(new PacketPlayOutBlockChange(world, blockposition.above()));
|
||||
+ }
|
||||
+ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
||||
+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
+ } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
|
||||
+ ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
+ ITileInventory itileinventory = iblockdata.getMenuProvider(world, blockposition);
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openContainer(itileinventory);
|
||||
@@ -326,7 +520,7 @@
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
entityplayer.openMenu(itileinventory);
|
||||
@@ -325,7 +519,7 @@
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
|
||||
if (!flag1) {
|
||||
- EnumInteractionResult enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
+ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
- EnumInteractionResult enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
+ enuminteractionresult = iblockdata.use(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.a()) {
|
||||
CriterionTriggers.ITEM_USED_ON_BLOCK.a(entityplayer, blockposition, itemstack1);
|
||||
@@ -334,17 +528,17 @@
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
|
||||
@@ -333,17 +527,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!itemstack.isEmpty() && !entityplayer.getCooldownTracker().hasCooldown(itemstack.getItem())) {
|
||||
- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
|
||||
+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
|
||||
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
|
||||
EnumInteractionResult enuminteractionresult1;
|
||||
@ -342,16 +342,16 @@
|
||||
if (this.isCreative()) {
|
||||
int i = itemstack.getCount();
|
||||
|
||||
- enuminteractionresult1 = itemstack.placeItem(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand);
|
||||
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
|
||||
itemstack.setCount(i);
|
||||
} else {
|
||||
- enuminteractionresult1 = itemstack.placeItem(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.placeItem(itemactioncontext, enumhand);
|
||||
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
|
||||
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
|
||||
}
|
||||
|
||||
if (enuminteractionresult1.a()) {
|
||||
@@ -352,10 +546,10 @@
|
||||
if (enuminteractionresult1.consumesAction()) {
|
||||
@@ -351,10 +545,10 @@
|
||||
}
|
||||
|
||||
return enuminteractionresult1;
|
||||
@ -363,4 +363,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void a(WorldServer worldserver) {
|
||||
public void setLevel(WorldServer worldserver) {
|
||||
|
@ -1,16 +1,16 @@
|
||||
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
@@ -308,6 +308,13 @@
|
||||
@@ -319,6 +319,13 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ return addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
int i = SectionPosition.a(entity.cW());
|
||||
int j = SectionPosition.a(entity.dc());
|
||||
int i = SectionPosition.blockToSectionCoord(entity.getBlockX());
|
||||
int j = SectionPosition.blockToSectionCoord(entity.getBlockZ());
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/server/level/TicketType.java
|
||||
+++ b/net/minecraft/server/level/TicketType.java
|
||||
@@ -23,6 +23,8 @@
|
||||
public static final TicketType<BlockPosition> PORTAL = a("portal", BaseBlockPosition::compareTo, 300);
|
||||
public static final TicketType<Integer> POST_TELEPORT = a("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = a("unknown", Comparator.comparingLong(ChunkCoordIntPair::pair), 1);
|
||||
+ public static final TicketType<Unit> PLUGIN = a("plugin", (a, b) -> 0); // CraftBukkit
|
||||
+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = a("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
|
||||
public static final TicketType<BlockPosition> PORTAL = create("portal", BaseBlockPosition::compareTo, 300);
|
||||
public static final TicketType<Integer> POST_TELEPORT = create("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1);
|
||||
+ public static final TicketType<Unit> PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit
|
||||
+ public static final TicketType<org.bukkit.plugin.Plugin> PLUGIN_TICKET = create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit
|
||||
|
||||
public static <T> TicketType<T> a(String s, Comparator<T> comparator) {
|
||||
public static <T> TicketType<T> create(String s, Comparator<T> comparator) {
|
||||
return new TicketType<>(s, comparator, 0L);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/WorldServer.java
|
||||
+++ b/net/minecraft/server/level/WorldServer.java
|
||||
@@ -152,6 +152,19 @@
|
||||
@@ -147,6 +147,19 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
|
||||
@@ -160,7 +173,7 @@
|
||||
@@ -164,7 +177,7 @@
|
||||
final List<EntityPlayer> players;
|
||||
private final ChunkProviderServer chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@ -29,13 +29,13 @@
|
||||
final EntityTickList entityTickList;
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
public boolean noSave;
|
||||
@@ -180,31 +193,52 @@
|
||||
private final StructureManager structureFeatureManager;
|
||||
@@ -186,9 +199,24 @@
|
||||
private final StructureCheck structureCheck;
|
||||
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) {
|
||||
- Objects.requireNonNull(minecraftserver);
|
||||
- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i);
|
||||
- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ private int tickPosition;
|
||||
@ -43,39 +43,21 @@
|
||||
+ public final UUID uuid;
|
||||
+
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkSource.getChunkAt(x, z, false);
|
||||
+ return this.chunkSource.getChunk(x, z, false);
|
||||
+ }
|
||||
+
|
||||
+ // 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, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
|
||||
+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, biomeProvider, env);
|
||||
+ this.pvpMode = minecraftserver.getPVP();
|
||||
+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getProfiler, false, flag, i, gen, biomeProvider, env);
|
||||
+ this.pvpMode = minecraftserver.isPvpAllowed();
|
||||
+ convertable = convertable_conversionsession;
|
||||
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
|
||||
+ // CraftBukkit end
|
||||
this.players = Lists.newArrayList();
|
||||
this.entityTickList = new EntityTickList();
|
||||
- Predicate predicate = (block) -> {
|
||||
+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror
|
||||
return block == null || block.getBlockData().isAir();
|
||||
};
|
||||
RegistryBlocks registryblocks = IRegistry.BLOCK;
|
||||
|
||||
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.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
|
||||
@@ -200,7 +228,13 @@
|
||||
this.tickTime = flag1;
|
||||
this.server = minecraftserver;
|
||||
this.customSpawners = list;
|
||||
@ -87,18 +69,18 @@
|
||||
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
boolean flag2 = minecraftserver.isSyncChunkWrites();
|
||||
DataFixer datafixer = minecraftserver.getDataFixer();
|
||||
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, new File(convertable_conversionsession.a(resourcekey), "entities"), datafixer, flag2, minecraftserver);
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
@@ -231,14 +265,15 @@
|
||||
iworlddataserver.setGameType(minecraftserver.getGamemode());
|
||||
}
|
||||
long l = minecraftserver.getWorldData().worldGenSettings().seed();
|
||||
|
||||
- this.structureFeatureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings());
|
||||
+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.getGeneratorSettings()); // CraftBukkit
|
||||
if (this.getDimensionManager().isCreateDragonBattle()) {
|
||||
- this.dragonFight = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C());
|
||||
+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.getGeneratorSettings().getSeed(), this.serverLevelData.C()); // CraftBukkit
|
||||
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer);
|
||||
- this.structureFeatureManager = new StructureManager(this, minecraftserver.getWorldData().worldGenSettings(), this.structureCheck);
|
||||
+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.worldGenSettings(), structureCheck); // CraftBukkit
|
||||
if (this.dimensionType().createDragonFight()) {
|
||||
- this.dragonFight = new EnderDragonBattle(this, l, minecraftserver.getWorldData().endDragonFightData());
|
||||
+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.worldGenSettings().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@ -107,18 +89,101 @@
|
||||
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(int i, int j, boolean flag, boolean flag1) {
|
||||
@@ -331,6 +366,7 @@
|
||||
this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F);
|
||||
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
|
||||
@@ -270,12 +305,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
+ // CraftBukkit start
|
||||
+ j = this.levelData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime());
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- j = this.levelData.getDayTime() + 24000L;
|
||||
- this.setDayTime(j - j % 24000L);
|
||||
+ getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
+ }
|
||||
}
|
||||
|
||||
- this.wakeUpAllPlayers();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.wakeUpAllPlayers();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -301,7 +344,7 @@
|
||||
this.runBlockEvents();
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
- boolean flag = !this.players.isEmpty() || !this.getForcedChunks().isEmpty();
|
||||
+ boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
||||
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
@@ -317,7 +360,7 @@
|
||||
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
- if (this.shouldDiscardEntity(entity)) {
|
||||
+ if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.discard();
|
||||
} else {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
@@ -389,7 +432,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
- ((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
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -416,14 +459,14 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
- this.addFreshEntity(entityhorseskeleton);
|
||||
+ this.addFreshEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
|
||||
}
|
||||
|
||||
EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.create(this);
|
||||
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
- this.addFreshEntity(entitylightning);
|
||||
+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,12 +477,12 @@
|
||||
BiomeBase biomebase = this.getBiome(blockposition);
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition1)) {
|
||||
- this.setBlockAndUpdate(blockposition1, Blocks.ICE.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (biomebase.shouldSnow(this, blockposition)) {
|
||||
- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
IBlockData iblockdata = this.getBlockState(blockposition1);
|
||||
@@ -635,6 +678,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)), this.getDimensionKey());
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -349,16 +385,45 @@
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
@@ -653,14 +697,47 @@
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
}
|
||||
+ // */
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
@ -142,100 +207,17 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (this.sleepStatus.a(i) && this.sleepStatus.a(i, this.players)) {
|
||||
+ // CraftBukkit start
|
||||
+ long l = this.levelData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- long l = this.levelData.getDayTime() + 24000L;
|
||||
+ getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
+ }
|
||||
|
||||
- this.setDayTime(l - l % 24000L);
|
||||
}
|
||||
|
||||
- this.wakeupPlayers();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.wakeupPlayers();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) {
|
||||
this.clearWeather();
|
||||
}
|
||||
@@ -380,7 +445,7 @@
|
||||
this.aq();
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.exit();
|
||||
- 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
|
||||
|
||||
if (flag3) {
|
||||
this.resetEmptyTime();
|
||||
@@ -396,7 +461,7 @@
|
||||
|
||||
this.entityTickList.a((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
- if (this.i(entity)) {
|
||||
+ if (false && this.i(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.die();
|
||||
} else {
|
||||
gameprofilerfiller.enter("checkDespawn");
|
||||
@@ -461,7 +526,7 @@
|
||||
|
||||
private void wakeupPlayers() {
|
||||
this.sleepStatus.a();
|
||||
- ((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
|
||||
entityplayer.wakeup(false, false);
|
||||
});
|
||||
}
|
||||
@@ -488,14 +553,14 @@
|
||||
entityhorseskeleton.v(true);
|
||||
entityhorseskeleton.setAgeRaw(0);
|
||||
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
- this.addEntity(entityhorseskeleton);
|
||||
+ this.addEntity(entityhorseskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
|
||||
}
|
||||
|
||||
EntityLightning entitylightning = (EntityLightning) EntityTypes.LIGHTNING_BOLT.a((World) this);
|
||||
|
||||
entitylightning.d(Vec3D.c((BaseBlockPosition) blockposition));
|
||||
entitylightning.setEffect(flag1);
|
||||
- this.addEntity(entitylightning);
|
||||
+ this.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,12 +571,12 @@
|
||||
BiomeBase biomebase = this.getBiome(blockposition);
|
||||
|
||||
if (biomebase.a((IWorldReader) this, blockposition1)) {
|
||||
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (biomebase.b(this, blockposition)) {
|
||||
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
IBlockData iblockdata = this.getType(blockposition1);
|
||||
@@ -642,10 +707,22 @@
|
||||
}
|
||||
|
||||
private void clearWeather() {
|
||||
- this.serverLevelData.setWeatherDuration(0);
|
||||
private void resetWeatherCycle() {
|
||||
- this.serverLevelData.setRainTime(0);
|
||||
+ // CraftBukkit start
|
||||
this.serverLevelData.setStorm(false);
|
||||
- this.serverLevelData.setThunderDuration(0);
|
||||
this.serverLevelData.setRaining(false);
|
||||
- this.serverLevelData.setThunderTime(0);
|
||||
+ // 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....
|
||||
+ if (!this.serverLevelData.hasStorm()) {
|
||||
+ this.serverLevelData.setWeatherDuration(0);
|
||||
+ if (!this.serverLevelData.isRaining()) {
|
||||
+ this.serverLevelData.setRainTime(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.serverLevelData.setThundering(false);
|
||||
@ -243,37 +225,37 @@
|
||||
+ // 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....
|
||||
+ if (!this.serverLevelData.isThundering()) {
|
||||
+ this.serverLevelData.setThunderDuration(0);
|
||||
+ this.serverLevelData.setThunderTime(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -680,6 +757,7 @@
|
||||
@@ -695,6 +772,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickNonPassenger");
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
this.getMethodProfiler().exit();
|
||||
this.getProfiler().pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -703,6 +781,7 @@
|
||||
@@ -718,6 +796,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickPassenger");
|
||||
entity1.passengerTick();
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
+ entity1.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.exit();
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -727,6 +806,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
|
||||
@@ -742,6 +821,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.a(new ChatMessage("menu.savingLevel"));
|
||||
iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel"));
|
||||
}
|
||||
@@ -744,11 +824,19 @@
|
||||
@@ -759,11 +839,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -281,105 +263,100 @@
|
||||
+ // CraftBukkit start - moved from MinecraftServer.saveChunks
|
||||
+ WorldServer worldserver1 = this;
|
||||
+
|
||||
+ serverLevelData.a(worldserver1.getWorldBorder().t());
|
||||
+ serverLevelData.setCustomBossEvents(this.server.getBossBattleCustomData().save());
|
||||
+ convertable.a(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().save());
|
||||
+ serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings());
|
||||
+ serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save());
|
||||
+ convertable.saveDataTag(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().getSingleplayerData());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void ap() {
|
||||
private void saveLevelData() {
|
||||
if (this.dragonFight != null) {
|
||||
- this.server.getSaveData().a(this.dragonFight.a());
|
||||
+ this.serverLevelData.a(this.dragonFight.a()); // CraftBukkit
|
||||
- this.server.getWorldData().setEndDragonFightData(this.dragonFight.saveData());
|
||||
+ this.serverLevelData.setEndDragonFightData(this.dragonFight.saveData()); // CraftBukkit
|
||||
}
|
||||
|
||||
this.getChunkProvider().getWorldPersistentData().a();
|
||||
@@ -794,15 +882,34 @@
|
||||
this.getChunkSource().getDataStorage().save();
|
||||
@@ -809,15 +897,34 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
- return this.addEntity0(entity);
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
- return this.addEntity(entity);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return this.addFreshEntity(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity0(entity, reason);
|
||||
+ public boolean addFreshEntity(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public boolean addEntitySerialized(Entity entity) {
|
||||
- return this.addEntity0(entity);
|
||||
public boolean addWithUUID(Entity entity) {
|
||||
- return this.addEntity(entity);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return this.addWithUUID(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addEntitySerialized(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity0(entity, reason);
|
||||
+ public boolean addWithUUID(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ return this.addEntity(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void addEntityTeleport(Entity entity) {
|
||||
- this.addEntity0(entity);
|
||||
public void addDuringTeleport(Entity entity) {
|
||||
- this.addEntity(entity);
|
||||
+ // CraftBukkit start
|
||||
+ this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ this.addDuringTeleport(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ this.addEntity0(entity, reason);
|
||||
+ public void addDuringTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ this.addEntity(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void addPlayerCommand(EntityPlayer entityplayer) {
|
||||
@@ -830,27 +937,39 @@
|
||||
this.a((EntityPlayer) entity, Entity.RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
- this.entityManager.a((EntityAccess) entityplayer);
|
||||
+ this.entityManager.a(entityplayer); // CraftBukkit - decompile error
|
||||
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
|
||||
@@ -848,24 +955,36 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
- private boolean addEntity0(Entity entity) {
|
||||
- private boolean addEntity(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
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())); // CraftBukkit
|
||||
- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType()));
|
||||
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit
|
||||
return false;
|
||||
} else {
|
||||
- return this.entityManager.a((EntityAccess) entity);
|
||||
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ return this.entityManager.a(entity); // CraftBukkit - decompile error
|
||||
return this.entityManager.addNewEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addAllEntitiesSafely(Entity entity) {
|
||||
- Stream stream = entity.recursiveStream().map(Entity::getUniqueID);
|
||||
public boolean tryAddFreshEntityWithPassengers(Entity entity) {
|
||||
- Stream stream = entity.getSelfAndPassengers().map(Entity::getUUID);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return this.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ public boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
+ Stream<UUID> stream = entity.recursiveStream().map(Entity::getUniqueID); // CraftBukkit - decompile error
|
||||
+ Stream<UUID> stream = entity.getSelfAndPassengers().map(Entity::getUUID); // CraftBukkit - decompile error
|
||||
PersistentEntitySectionManager persistententitysectionmanager = this.entityManager;
|
||||
|
||||
Objects.requireNonNull(this.entityManager);
|
||||
if (stream.anyMatch(persistententitysectionmanager::a)) {
|
||||
if (stream.anyMatch(persistententitysectionmanager::isLoaded)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.addAllEntities(entity);
|
||||
+ this.addAllEntities(entity, reason); // CraftBukkit
|
||||
- this.addFreshEntityWithPassengers(entity);
|
||||
+ this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -863,10 +982,32 @@
|
||||
entityplayer.a(entity_removalreason);
|
||||
@@ -879,10 +998,32 @@
|
||||
entityplayer.remove(entity_removalreason);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -394,12 +371,12 @@
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return this.addEntity(entitylightning);
|
||||
+ return this.addFreshEntity(entitylightning);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void a(int i, BlockPosition blockposition, int j) {
|
||||
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
|
||||
Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -411,9 +388,9 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -875,6 +1016,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.locY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.locZ();
|
||||
@@ -891,6 +1032,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
@ -422,9 +399,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -923,7 +1070,18 @@
|
||||
@@ -938,7 +1085,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -437,19 +414,19 @@
|
||||
+ // 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
|
||||
+ // As this is a relative edge case it is much faster than copying navigators (on either read or write)
|
||||
+ notify(blockposition, iblockdata, iblockdata1, i);
|
||||
+ sendBlockUpdated(blockposition, iblockdata, iblockdata1, i);
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (!navigationabstract.i()) {
|
||||
@@ -946,10 +1104,20 @@
|
||||
if (!navigationabstract.hasDelayedRecomputation()) {
|
||||
@@ -961,10 +1119,20 @@
|
||||
|
||||
@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 explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
|
||||
+ // CraftBukkit start
|
||||
+ Explosion explosion = super.createExplosion(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect);
|
||||
+ Explosion explosion = super.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect);
|
||||
+
|
||||
+ if (explosion.wasCanceled) {
|
||||
+ return explosion;
|
||||
@ -458,17 +435,17 @@
|
||||
+ /* Remove
|
||||
Explosion explosion = new Explosion(this, entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, explosion_effect);
|
||||
|
||||
explosion.a();
|
||||
explosion.a(false);
|
||||
explosion.explode();
|
||||
explosion.finalizeExplosion(false);
|
||||
+ */
|
||||
+ // CraftBukkit end - TODO: Check if explosions are still properly implemented
|
||||
if (explosion_effect == Explosion.Effect.NONE) {
|
||||
explosion.clearBlocks();
|
||||
explosion.clearToBlow();
|
||||
}
|
||||
@@ -1023,13 +1191,20 @@
|
||||
@@ -1045,13 +1213,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 sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
|
||||
+ // CraftBukkit - visibility api support
|
||||
+ return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6, false);
|
||||
@ -483,72 +460,72 @@
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(k);
|
||||
+ if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
|
||||
|
||||
- if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
|
||||
+ if (this.a(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
|
||||
- if (this.sendParticles(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
|
||||
+ if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1079,7 +1254,7 @@
|
||||
@@ -1101,7 +1276,7 @@
|
||||
|
||||
@Nullable
|
||||
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.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
|
||||
public BlockPosition findNearestMapFeature(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
||||
- return !this.server.getWorldData().worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag);
|
||||
+ return !this.serverLevelData.worldGenSettings().generateFeatures() ? null : this.getChunkSource().getGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1116,11 +1291,21 @@
|
||||
@@ -1138,11 +1313,21 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap a(String s) {
|
||||
- return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().a(WorldMap::b, s);
|
||||
+ return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().a((nbttagcompound) -> {
|
||||
+ // CraftBukkit start
|
||||
public WorldMap getMapData(String s) {
|
||||
- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap::load, s);
|
||||
+ // CraftBukkit start
|
||||
+ return (WorldMap) this.getServer().overworld().getDataStorage().get((nbttagcompound) -> {
|
||||
+ // We only get here when the data file exists, but is not a valid map
|
||||
+ WorldMap newMap = WorldMap.b(nbttagcompound);
|
||||
+ WorldMap newMap = WorldMap.load(nbttagcompound);
|
||||
+ newMap.id = s;
|
||||
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ return newMap;
|
||||
+ // CraftBukkit end
|
||||
+ }, s);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(String s, WorldMap worldmap) {
|
||||
public void setMapData(String s, WorldMap worldmap) {
|
||||
+ worldmap.id = s; // CraftBukkit
|
||||
this.getMinecraftServer().E().getWorldPersistentData().a(s, (PersistentBase) worldmap);
|
||||
this.getServer().overworld().getDataStorage().set(s, worldmap);
|
||||
}
|
||||
|
||||
@@ -1432,6 +1617,11 @@
|
||||
@@ -1454,6 +1639,11 @@
|
||||
@Override
|
||||
public void update(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebugWorld()) {
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (populating) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.applyPhysics(blockposition, block);
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1451,12 +1641,12 @@
|
||||
@@ -1473,12 +1663,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlatWorld() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().isFlatWorld();
|
||||
+ return this.serverLevelData.getGeneratorSettings().isFlatWorld(); // CraftBukkit
|
||||
public boolean isFlat() {
|
||||
- return this.server.getWorldData().worldGenSettings().isFlatWorld();
|
||||
+ return this.serverLevelData.worldGenSettings().isFlatWorld(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().getSeed();
|
||||
+ return this.serverLevelData.getGeneratorSettings().getSeed(); // CraftBukkit
|
||||
- return this.server.getWorldData().worldGenSettings().seed();
|
||||
+ return this.serverLevelData.worldGenSettings().seed(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1484,7 +1674,7 @@
|
||||
private static <T> String a(Iterable<T> iterable, Function<T, String> function) {
|
||||
@@ -1506,7 +1696,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
- Iterator iterator = iterable.iterator();
|
||||
@ -556,7 +533,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1493,7 +1683,7 @@
|
||||
@@ -1515,7 +1705,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@ -565,15 +542,15 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1504,17 +1694,33 @@
|
||||
@@ -1526,17 +1716,33 @@
|
||||
}
|
||||
|
||||
public static void a(WorldServer worldserver) {
|
||||
public static void makeObsidianPlatform(WorldServer worldserver) {
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer.a(worldserver, null);
|
||||
+ WorldServer.makeObsidianPlatform(worldserver, null);
|
||||
+ }
|
||||
+
|
||||
+ public static void a(WorldServer worldserver, Entity entity) {
|
||||
+ public static void makeObsidianPlatform(WorldServer worldserver, Entity entity) {
|
||||
+ // CraftBukkit end
|
||||
BlockPosition blockposition = WorldServer.END_SPAWN_POINT;
|
||||
int i = blockposition.getX();
|
||||
@ -582,13 +559,13 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver);
|
||||
BlockPosition.b(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setTypeUpdate(blockposition1, Blocks.AIR.getBlockData());
|
||||
+ blockList.setTypeAndData(blockposition1, Blocks.AIR.getBlockData(), 3);
|
||||
BlockPosition.betweenClosed(i - 2, j + 1, k - 2, i + 2, j + 3, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setBlockAndUpdate(blockposition1, Blocks.AIR.defaultBlockState());
|
||||
+ blockList.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 3);
|
||||
});
|
||||
BlockPosition.b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setTypeUpdate(blockposition1, Blocks.OBSIDIAN.getBlockData());
|
||||
+ blockList.setTypeAndData(blockposition1, Blocks.OBSIDIAN.getBlockData(), 3);
|
||||
BlockPosition.betweenClosed(i - 2, j, k - 2, i + 2, j, k + 2).forEach((blockposition1) -> {
|
||||
- worldserver.setBlockAndUpdate(blockposition1, Blocks.OBSIDIAN.defaultBlockState());
|
||||
+ blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3);
|
||||
});
|
||||
+ org.bukkit.World bworld = worldserver.getWorld();
|
||||
+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM);
|
||||
@ -601,16 +578,16 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1601,6 +1807,7 @@
|
||||
@@ -1629,6 +1835,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ entity.valid = true; // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(Entity entity) {
|
||||
@@ -1633,6 +1840,7 @@
|
||||
gameeventlistenerregistrar.a(entity.level);
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1661,6 +1868,7 @@
|
||||
gameeventlistenerregistrar.onListenerRemoved(entity.level);
|
||||
}
|
||||
|
||||
+ entity.valid = false; // CraftBukkit
|
||||
|
@ -19,21 +19,21 @@
|
||||
private final MinecraftServer server;
|
||||
private final NetworkManager connection;
|
||||
@@ -27,6 +36,40 @@
|
||||
switch (packethandshakinginsetprotocol.b()) {
|
||||
switch (packethandshakinginsetprotocol.getIntention()) {
|
||||
case LOGIN:
|
||||
this.connection.setProtocol(EnumProtocol.LOGIN);
|
||||
+ // CraftBukkit start - Connection throttle
|
||||
+ try {
|
||||
+ long currentTime = System.currentTimeMillis();
|
||||
+ long connectionThrottle = this.server.server.getConnectionThrottle();
|
||||
+ InetAddress address = ((java.net.InetSocketAddress) this.connection.getSocketAddress()).getAddress();
|
||||
+ InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress();
|
||||
+
|
||||
+ synchronized (throttleTracker) {
|
||||
+ if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) {
|
||||
+ throttleTracker.put(address, currentTime);
|
||||
+ ChatMessage chatmessage = new ChatMessage("Connection throttled! Please wait before reconnecting.");
|
||||
+ this.connection.sendPacket(new PacketLoginOutDisconnect(chatmessage));
|
||||
+ this.connection.close(chatmessage);
|
||||
+ this.connection.send(new PacketLoginOutDisconnect(chatmessage));
|
||||
+ this.connection.disconnect(chatmessage);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@ -56,14 +56,14 @@
|
||||
+ org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (packethandshakinginsetprotocol.c() != SharedConstants.getGameVersion().getProtocolVersion()) {
|
||||
if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
ChatMessage chatmessage;
|
||||
|
||||
@@ -40,6 +83,7 @@
|
||||
this.connection.close(chatmessage);
|
||||
this.connection.disconnect(chatmessage);
|
||||
} else {
|
||||
this.connection.setPacketListener(new LoginListener(this.server, this.connection));
|
||||
+ ((LoginListener) this.connection.j()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
this.connection.setListener(new LoginListener(this.server, this.connection));
|
||||
+ ((LoginListener) this.connection.getPacketListener()).hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
|
||||
}
|
||||
break;
|
||||
case STATUS:
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/network/LegacyPingHandler.java
|
||||
+++ b/net/minecraft/server/network/LegacyPingHandler.java
|
||||
@@ -36,11 +36,12 @@
|
||||
MinecraftServer minecraftserver = this.serverConnectionListener.d();
|
||||
MinecraftServer minecraftserver = this.serverConnectionListener.getServer();
|
||||
int i = bytebuf.readableBytes();
|
||||
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
|
||||
@ -11,24 +11,24 @@
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ s = String.format("%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
|
||||
break;
|
||||
case 1:
|
||||
@@ -49,7 +50,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
this.a(channelhandlercontext, this.a(s));
|
||||
- s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
|
||||
break;
|
||||
default:
|
||||
@@ -68,7 +69,7 @@
|
||||
}
|
||||
|
||||
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
|
||||
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
ByteBuf bytebuf1 = this.a(s1);
|
||||
- String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
|
||||
+ String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
|
||||
ByteBuf bytebuf1 = this.createReply(s1);
|
||||
|
||||
try {
|
||||
|
@ -31,9 +31,9 @@
|
||||
+ public void disconnect(String s) {
|
||||
+ try {
|
||||
+ IChatBaseComponent ichatbasecomponent = new ChatComponentText(s);
|
||||
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.d(), s);
|
||||
+ this.connection.sendPacket(new PacketLoginOutDisconnect(ichatbasecomponent));
|
||||
+ this.connection.close(ichatbasecomponent);
|
||||
+ LoginListener.LOGGER.info("Disconnecting {}: {}", this.getUserName(), s);
|
||||
+ this.connection.send(new PacketLoginOutDisconnect(ichatbasecomponent));
|
||||
+ this.connection.disconnect(ichatbasecomponent);
|
||||
+ } catch (Exception exception) {
|
||||
+ LoginListener.LOGGER.error("Error whilst disconnecting player", exception);
|
||||
+ }
|
||||
@ -41,15 +41,15 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public NetworkManager a() {
|
||||
public NetworkManager getConnection() {
|
||||
return this.connection;
|
||||
@@ -101,10 +123,12 @@
|
||||
this.gameProfile = this.a(this.gameProfile);
|
||||
this.gameProfile = this.createFakeProfile(this.gameProfile);
|
||||
}
|
||||
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().attemptLogin(this.connection.getSocketAddress(), this.gameProfile);
|
||||
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
|
||||
+ // CraftBukkit start - fire PlayerLoginEvent
|
||||
+ EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.gameProfile, hostname);
|
||||
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile, hostname);
|
||||
|
||||
- if (ichatbasecomponent != null) {
|
||||
- this.disconnect(ichatbasecomponent);
|
||||
@ -58,19 +58,19 @@
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.state = LoginListener.EnumProtocolState.ACCEPTED;
|
||||
if (this.server.av() >= 0 && !this.connection.isLocal()) {
|
||||
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
|
||||
@@ -117,7 +141,7 @@
|
||||
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
|
||||
|
||||
try {
|
||||
- EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile);
|
||||
+ EntityPlayer entityplayer1 = this.server.getPlayerList().processLogin(this.gameProfile, s); // CraftBukkit - add player reference
|
||||
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile);
|
||||
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
|
||||
@@ -191,6 +215,43 @@
|
||||
@@ -192,6 +216,43 @@
|
||||
try {
|
||||
LoginListener.this.gameProfile = LoginListener.this.server.getMinecraftSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.a());
|
||||
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
|
||||
if (LoginListener.this.gameProfile != null) {
|
||||
+ // CraftBukkit start - fire PlayerPreLoginEvent
|
||||
+ if (!connection.isConnected()) {
|
||||
@ -78,7 +78,7 @@
|
||||
+ }
|
||||
+
|
||||
+ String playerName = gameProfile.getName();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getSocketAddress()).getAddress();
|
||||
+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress();
|
||||
+ java.util.UUID uniqueId = gameProfile.getId();
|
||||
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
|
||||
+
|
||||
@ -111,8 +111,8 @@
|
||||
+ // CraftBukkit end
|
||||
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
|
||||
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
|
||||
} else if (LoginListener.this.server.isEmbeddedServer()) {
|
||||
@@ -210,6 +271,11 @@
|
||||
} else if (LoginListener.this.server.isSingleplayer()) {
|
||||
@@ -211,6 +272,11 @@
|
||||
LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down"));
|
||||
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
public class PacketStatusListener implements PacketStatusInListener {
|
||||
|
||||
private static final IChatBaseComponent DISCONNECT_REASON = new ChatMessage("multiplayer.status.request_handled");
|
||||
@@ -36,8 +48,96 @@
|
||||
this.connection.close(PacketStatusListener.DISCONNECT_REASON);
|
||||
@@ -36,7 +48,95 @@
|
||||
this.connection.disconnect(PacketStatusListener.DISCONNECT_REASON);
|
||||
} else {
|
||||
this.hasRequestedStatus = true;
|
||||
- this.connection.sendPacket(new PacketStatusOutServerInfo(this.server.getServerPing()));
|
||||
- this.connection.send(new PacketStatusOutServerInfo(this.server.getStatus()));
|
||||
+ // CraftBukkit start
|
||||
+ // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
+ final Object[] players = server.getPlayerList().players.toArray();
|
||||
@ -32,7 +32,7 @@
|
||||
+ CraftIconCache icon = server.server.getServerIcon();
|
||||
+
|
||||
+ ServerListPingEvent() {
|
||||
+ super(((InetSocketAddress) connection.getSocketAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers());
|
||||
+ super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.getMotd(), server.getPlayerList().getMaxPlayers());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
@ -97,23 +97,22 @@
|
||||
+ java.util.List<GameProfile> profiles = new java.util.ArrayList<GameProfile>(players.length);
|
||||
+ for (Object player : players) {
|
||||
+ if (player != null) {
|
||||
+ profiles.add(((EntityPlayer) player).getProfile());
|
||||
+ profiles.add(((EntityPlayer) player).getGameProfile());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());
|
||||
+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()]));
|
||||
+ playerSample.setSample(profiles.toArray(new GameProfile[profiles.size()]));
|
||||
+
|
||||
+ ServerPing ping = new ServerPing();
|
||||
+ ping.setFavicon(event.icon.value);
|
||||
+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]);
|
||||
+ ping.setPlayerSample(playerSample);
|
||||
+ int version = SharedConstants.getGameVersion().getProtocolVersion();
|
||||
+ ping.setServerInfo(new ServerPing.ServerData(server.getServerModName() + " " + server.getVersion(), version));
|
||||
+ ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]);
|
||||
+ ping.setPlayers(playerSample);
|
||||
+ int version = SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
+ ping.setVersion(new ServerPing.ServerData(server.getServerModName() + " " + server.getServerVersion(), version));
|
||||
+
|
||||
+ this.connection.sendPacket(new PacketStatusOutServerInfo(ping));
|
||||
+ this.connection.send(new PacketStatusOutServerInfo(ping));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,16 +1,16 @@
|
||||
--- a/net/minecraft/server/network/ServerConnection.java
|
||||
+++ b/net/minecraft/server/network/ServerConnection.java
|
||||
@@ -96,14 +96,24 @@
|
||||
int j = ServerConnection.this.server.l();
|
||||
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
|
||||
Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
|
||||
|
||||
- ServerConnection.this.connections.add(object);
|
||||
+ ServerConnection.this.connections.add((NetworkManager) object); // CraftBukkit - decompile error
|
||||
channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
|
||||
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
|
||||
((NetworkManager) object).setListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
|
||||
}
|
||||
- }).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.get()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
|
||||
+ }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,6 +24,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public SocketAddress a() {
|
||||
public SocketAddress startMemoryChannel() {
|
||||
List list = this.channels;
|
||||
ChannelFuture channelfuture;
|
||||
|
@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/server/players/ExpirableListEntry.java
|
||||
+++ b/net/minecraft/server/players/ExpirableListEntry.java
|
||||
@@ -25,7 +25,7 @@
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
|
||||
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
|
||||
- super(t0);
|
||||
+ super(checkExpiry(t0, jsonobject));
|
||||
+ super(checkExpiry(t0, jsonobject)); // CraftBukkit
|
||||
|
||||
Date date;
|
||||
|
||||
@@ -80,4 +80,22 @@
|
||||
@@ -82,4 +82,22 @@
|
||||
jsonobject.addProperty("expires", this.expires == null ? "forever" : ExpirableListEntry.DATE_FORMAT.format(this.expires));
|
||||
jsonobject.addProperty("reason", this.reason);
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
@@ -54,7 +54,7 @@
|
||||
@Nullable
|
||||
public V get(K k0) {
|
||||
this.g();
|
||||
- return (JsonListEntry) this.map.get(this.a(k0));
|
||||
+ return (V) this.map.get(this.a(k0)); // CraftBukkit - fix decompile error
|
||||
this.removeExpired();
|
||||
- return (JsonListEntry) this.map.get(this.getKeyForUser(k0));
|
||||
+ return (V) this.map.get(this.getKeyForUser(k0)); // CraftBukkit - fix decompile error
|
||||
}
|
||||
|
||||
public void remove(K k0) {
|
||||
@ -30,7 +30,7 @@
|
||||
+ V v0 = (V) iterator.next(); // CraftBukkit - decompile error
|
||||
|
||||
if (v0.hasExpired()) {
|
||||
list.add(v0.getKey());
|
||||
list.add(v0.getUser());
|
||||
@@ -103,7 +109,7 @@
|
||||
iterator = list.iterator();
|
||||
|
||||
@ -38,9 +38,9 @@
|
||||
- K k0 = iterator.next();
|
||||
+ K k0 = (K) iterator.next(); // CraftBukkit - decompile error
|
||||
|
||||
this.map.remove(this.a(k0));
|
||||
this.map.remove(this.getKeyForUser(k0));
|
||||
}
|
||||
@@ -118,11 +124,11 @@
|
||||
@@ -118,7 +124,7 @@
|
||||
|
||||
public void save() throws IOException {
|
||||
JsonArray jsonarray = new JsonArray();
|
||||
@ -49,17 +49,12 @@
|
||||
JsonObject jsonobject = new JsonObject();
|
||||
|
||||
Objects.requireNonNull(jsonlistentry);
|
||||
- return (JsonObject) SystemUtils.a((Object) jsonobject, jsonlistentry::a);
|
||||
+ return (JsonObject) SystemUtils.a(jsonobject, jsonlistentry::a); // CraftBukkit - decompile error
|
||||
});
|
||||
|
||||
Objects.requireNonNull(jsonarray);
|
||||
@@ -165,7 +171,7 @@
|
||||
JsonListEntry<K> jsonlistentry = this.a(jsonobject);
|
||||
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
|
||||
|
||||
if (jsonlistentry.getKey() != null) {
|
||||
- this.map.put(this.a(jsonlistentry.getKey()), jsonlistentry);
|
||||
+ this.map.put(this.a(jsonlistentry.getKey()), (V) jsonlistentry); // CraftBukkit - fix decompile error
|
||||
if (jsonlistentry.getUser() != null) {
|
||||
- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry);
|
||||
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
|
@ -16,8 +16,8 @@
|
||||
try {
|
||||
gameprofilebanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", gameprofilebanlist.getFile().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
try {
|
||||
ipbanlist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", ipbanlist.getFile().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
try {
|
||||
oplist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", oplist.getFile().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@
|
||||
try {
|
||||
whitelist.load();
|
||||
} catch (IOException ioexception) {
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.b().getName()); // CraftBukkit - don't print stacktrace
|
||||
- NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName(), ioexception);
|
||||
+ NameReferencingFileConverter.LOGGER.warn("Could not load existing file {}", whitelist.getFile().getName()); // CraftBukkit - don't print stacktrace
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,26 +56,26 @@
|
||||
+ NBTTagCompound root = null;
|
||||
+
|
||||
+ try {
|
||||
+ root = NBTCompressedStreamTools.a(new java.io.FileInputStream(file5));
|
||||
+ root = NBTCompressedStreamTools.readCompressed(new java.io.FileInputStream(file5));
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ if (root != null) {
|
||||
+ if (!root.hasKey("bukkit")) {
|
||||
+ root.set("bukkit", new NBTTagCompound());
|
||||
+ if (!root.contains("bukkit")) {
|
||||
+ root.put("bukkit", new NBTTagCompound());
|
||||
+ }
|
||||
+ NBTTagCompound data = root.getCompound("bukkit");
|
||||
+ data.setString("lastKnownName", s2);
|
||||
+ data.putString("lastKnownName", s2);
|
||||
+
|
||||
+ try {
|
||||
+ NBTCompressedStreamTools.a(root, new java.io.FileOutputStream(file2));
|
||||
+ NBTCompressedStreamTools.writeCompressed(root, new java.io.FileOutputStream(file2));
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
NameReferencingFileConverter.a(file4);
|
||||
NameReferencingFileConverter.ensureDirectoryExists(file4);
|
||||
if (!file5.renameTo(file6)) {
|
||||
throw new NameReferencingFileConverter.FileConversionException("Could not convert file for " + s2);
|
||||
|
@ -47,7 +47,7 @@
|
||||
public final WorldNBTStorage playerIo;
|
||||
private boolean doWhiteList;
|
||||
private final IRegistryCustom.Dimension registryHolder;
|
||||
@@ -122,13 +144,23 @@
|
||||
@@ -123,13 +145,23 @@
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
|
||||
@ -73,51 +73,51 @@
|
||||
this.server = minecraftserver;
|
||||
this.registryHolder = iregistrycustom_dimension;
|
||||
this.maxPlayers = i;
|
||||
@@ -144,6 +176,12 @@
|
||||
usercache.a(gameprofile);
|
||||
NBTTagCompound nbttagcompound = this.a(entityplayer);
|
||||
@@ -145,6 +177,12 @@
|
||||
usercache.add(gameprofile);
|
||||
NBTTagCompound nbttagcompound = this.load(entityplayer);
|
||||
ResourceKey resourcekey;
|
||||
+ // CraftBukkit start - Better rename detection
|
||||
+ if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
|
||||
+ if (nbttagcompound != null && nbttagcompound.contains("bukkit")) {
|
||||
+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
|
||||
+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
|
||||
+ s = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension")));
|
||||
@@ -173,7 +211,8 @@
|
||||
s1 = networkmanager.getSocketAddress().toString();
|
||||
DataResult dataresult = DimensionManager.parseLegacy(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("Dimension")));
|
||||
@@ -174,7 +212,8 @@
|
||||
s1 = networkmanager.getRemoteAddress().toString();
|
||||
}
|
||||
|
||||
- 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.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ());
|
||||
+ // CraftBukkit - Moved message to after join
|
||||
+ // 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();
|
||||
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ());
|
||||
WorldData worlddata = worldserver1.getLevelData();
|
||||
|
||||
entityplayer.c(nbttagcompound);
|
||||
@@ -183,6 +222,7 @@
|
||||
entityplayer.loadGameTypes(nbttagcompound);
|
||||
@@ -184,6 +223,7 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
|
||||
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.gameMode.getGameMode(), entityplayer.gameMode.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.F(), this.registryHolder, worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld()));
|
||||
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.registryHolder, worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat()));
|
||||
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
|
||||
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 PacketPlayOutAbilities(entityplayer.getAbilities()));
|
||||
@@ -201,19 +241,66 @@
|
||||
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
|
||||
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
|
||||
@@ -202,19 +242,66 @@
|
||||
} else {
|
||||
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s});
|
||||
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getDisplayName(), s});
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ chatmessage.a(EnumChatFormat.YELLOW);
|
||||
+ chatmessage.withStyle(EnumChatFormat.YELLOW);
|
||||
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
|
||||
|
||||
- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
playerconnection.b(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
- this.broadcastMessage(chatmessage.withStyle(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
this.players.add(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})); // CraftBukkit - replaced with loop below
|
||||
this.playersByUUID.put(entityplayer.getUUID(), entityplayer);
|
||||
- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ CraftPlayer bukkitPlayer = entityplayer.getBukkitEntity();
|
||||
@ -136,7 +136,7 @@
|
||||
+
|
||||
+ if (joinMessage != null && joinMessage.length() > 0) {
|
||||
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
|
||||
+ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
|
||||
+ server.getPlayerList().broadcastAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@ -145,142 +145,142 @@
|
||||
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer);
|
||||
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
- entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)}));
|
||||
- entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)}));
|
||||
+ EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ if (entityplayer1.getBukkitEntity().canSee(bukkitPlayer)) {
|
||||
+ entityplayer1.connection.sendPacket(packet);
|
||||
+ entityplayer1.connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
|
||||
+ entityplayer.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer1}));
|
||||
}
|
||||
+ entityplayer.sentListPacket = true;
|
||||
+ // CraftBukkit end
|
||||
|
||||
- worldserver1.addPlayerJoin(entityplayer);
|
||||
- this.server.getBossBattleCustomData().a(entityplayer);
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getDataWatcher(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
||||
- worldserver1.addNewPlayer(entityplayer);
|
||||
- this.server.getCustomBossEvents().onPlayerConnect(entityplayer);
|
||||
+ entityplayer.connection.send(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.getEntityData(), true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
|
||||
+
|
||||
+ // CraftBukkit start - Only add if the player wasn't moved in the event
|
||||
+ if (entityplayer.level == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) {
|
||||
+ worldserver1.addPlayerJoin(entityplayer);
|
||||
+ this.server.getBossBattleCustomData().a(entityplayer);
|
||||
+ if (entityplayer.level == worldserver1 && !worldserver1.players().contains(entityplayer)) {
|
||||
+ worldserver1.addNewPlayer(entityplayer);
|
||||
+ this.server.getCustomBossEvents().onPlayerConnect(entityplayer);
|
||||
+ }
|
||||
+
|
||||
+ worldserver1 = entityplayer.getWorldServer(); // CraftBukkit - Update in case join event changed it
|
||||
+ worldserver1 = entityplayer.getLevel(); // CraftBukkit - Update in case join event changed it
|
||||
+ // CraftBukkit end
|
||||
this.a(entityplayer, worldserver1);
|
||||
this.sendLevelInfo(entityplayer, worldserver1);
|
||||
if (!this.server.getResourcePack().isEmpty()) {
|
||||
entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.aX(), this.server.ba());
|
||||
@@ -229,8 +316,11 @@
|
||||
entityplayer.sendTexturePack(this.server.getResourcePack(), this.server.getResourcePackHash(), this.server.isResourcePackRequired(), this.server.getResourcePackPrompt());
|
||||
@@ -230,8 +317,11 @@
|
||||
|
||||
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
|
||||
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
|
||||
- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> {
|
||||
- return !worldserver1.addEntitySerialized(entity1) ? null : entity1;
|
||||
- Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> {
|
||||
- return !worldserver1.addWithUUID(entity1) ? null : entity1;
|
||||
+ // CraftBukkit start
|
||||
+ WorldServer finalWorldServer = worldserver1;
|
||||
+ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
|
||||
+ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1;
|
||||
+ Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
|
||||
+ return !finalWorldServer.addWithUUID(entity1) ? null : entity1;
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -273,6 +363,8 @@
|
||||
@@ -274,6 +364,8 @@
|
||||
}
|
||||
|
||||
entityplayer.syncInventory();
|
||||
entityplayer.initInventoryMenu();
|
||||
+ // CraftBukkit - Moved from above, added world
|
||||
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
|
||||
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getName().getString(), s1, entityplayer.getId(), worldserver1.serverLevelData.getLevelName(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ());
|
||||
}
|
||||
|
||||
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -305,30 +397,31 @@
|
||||
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
|
||||
@@ -306,30 +398,31 @@
|
||||
}
|
||||
|
||||
public void setPlayerFileData(WorldServer worldserver) {
|
||||
public void addWorldborderListener(WorldServer worldserver) {
|
||||
+ if (playerIo != null) return; // CraftBukkit
|
||||
worldserver.getWorldBorder().a(new IWorldBorderListener() {
|
||||
worldserver.getWorldBorder().addListener(new IWorldBorderListener() {
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0) {
|
||||
- PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder));
|
||||
+ PlayerList.this.sendAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
public void onBorderSizeSet(WorldBorder worldborder, double d0) {
|
||||
- PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(worldborder));
|
||||
+ PlayerList.this.broadcastAll(new ClientboundSetBorderSizePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0, double d1, long i) {
|
||||
- PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder));
|
||||
+ PlayerList.this.sendAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
public void onBorderSizeLerping(WorldBorder worldborder, double d0, double d1, long i) {
|
||||
- PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(worldborder));
|
||||
+ PlayerList.this.broadcastAll(new ClientboundSetBorderLerpSizePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, double d0, double d1) {
|
||||
- PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder));
|
||||
+ PlayerList.this.sendAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit
|
||||
public void onBorderCenterSet(WorldBorder worldborder, double d0, double d1) {
|
||||
- PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(worldborder));
|
||||
+ PlayerList.this.broadcastAll(new ClientboundSetBorderCenterPacket(worldborder), worldborder.world); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder));
|
||||
+ PlayerList.this.sendAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit
|
||||
public void onBorderSetWarningTime(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(worldborder));
|
||||
+ PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDelayPacket(worldborder), worldborder.world); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder));
|
||||
+ PlayerList.this.sendAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
public void onBorderSetWarningBlocks(WorldBorder worldborder, int i) {
|
||||
- PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(worldborder));
|
||||
+ PlayerList.this.broadcastAll(new ClientboundSetBorderWarningDistancePacket(worldborder), worldborder.world); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -356,14 +449,15 @@
|
||||
@@ -357,14 +450,15 @@
|
||||
}
|
||||
|
||||
protected void savePlayerFile(EntityPlayer entityplayer) {
|
||||
protected void save(EntityPlayer entityplayer) {
|
||||
+ if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||
this.playerIo.save(entityplayer);
|
||||
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUniqueID());
|
||||
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
|
||||
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(entityplayer.getUUID());
|
||||
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStats(); // CraftBukkit
|
||||
|
||||
if (serverstatisticmanager != null) {
|
||||
serverstatisticmanager.save();
|
||||
}
|
||||
|
||||
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUniqueID());
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
|
||||
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(entityplayer.getUUID());
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancements(); // CraftBukkit
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.b();
|
||||
@@ -371,10 +465,24 @@
|
||||
advancementdataplayer.save();
|
||||
@@ -372,10 +466,24 @@
|
||||
|
||||
}
|
||||
|
||||
- public void disconnect(EntityPlayer entityplayer) {
|
||||
+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
|
||||
WorldServer worldserver = entityplayer.getWorldServer();
|
||||
- public void remove(EntityPlayer entityplayer) {
|
||||
+ public String remove(EntityPlayer entityplayer) { // CraftBukkit - return string
|
||||
WorldServer worldserver = entityplayer.getLevel();
|
||||
|
||||
entityplayer.a(StatisticList.LEAVE_GAME);
|
||||
entityplayer.awardStat(StatisticList.LEAVE_GAME);
|
||||
+
|
||||
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
|
||||
+ // See SPIGOT-5799, SPIGOT-6145
|
||||
+ if (entityplayer.containerMenu != entityplayer.inventoryMenu) {
|
||||
+ entityplayer.closeInventory();
|
||||
+ entityplayer.closeContainer();
|
||||
+ }
|
||||
+
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getName() + " left the game");
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), "\u00A7e" + entityplayer.getScoreboardName() + " left the game");
|
||||
+ cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
+
|
||||
+ entityplayer.playerTick(); // SPIGOT-924
|
||||
+ entityplayer.doTick(); // SPIGOT-924
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.savePlayerFile(entityplayer);
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -398,18 +506,66 @@
|
||||
@@ -399,18 +507,66 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.playersByUUID.remove(uuid);
|
||||
@ -293,13 +293,13 @@
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ // this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer);
|
||||
+ for (int i = 0; i < players.size(); i++) {
|
||||
+ EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
|
||||
+ entityplayer2.connection.sendPacket(packet);
|
||||
+ entityplayer2.connection.send(packet);
|
||||
+ } else {
|
||||
+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity());
|
||||
+ }
|
||||
@ -308,26 +308,26 @@
|
||||
+ cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
|
||||
+ // CraftBukkit end
|
||||
|
||||
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
|
||||
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit
|
||||
}
|
||||
|
||||
- @Nullable
|
||||
- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
|
||||
- public IChatBaseComponent canPlayerLogin(SocketAddress socketaddress, GameProfile gameprofile) {
|
||||
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
|
||||
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
|
||||
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
|
||||
ChatMessage chatmessage;
|
||||
|
||||
- if (this.bans.isBanned(gameprofile)) {
|
||||
+ // Moved from processLogin
|
||||
+ UUID uuid = EntityHuman.a(gameprofile);
|
||||
+ UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
|
||||
+ List<EntityPlayer> list = Lists.newArrayList();
|
||||
+
|
||||
+ EntityPlayer entityplayer;
|
||||
+
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ entityplayer = (EntityPlayer) this.players.get(i);
|
||||
+ if (entityplayer.getUniqueID().equals(uuid)) {
|
||||
+ if (entityplayer.getUUID().equals(uuid)) {
|
||||
+ list.add(entityplayer);
|
||||
+ }
|
||||
+ }
|
||||
@ -336,50 +336,50 @@
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ entityplayer = (EntityPlayer) iterator.next();
|
||||
+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
|
||||
+ save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
|
||||
+ entityplayer.connection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
+ }
|
||||
+
|
||||
+ // 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
|
||||
+ // depending on the outcome.
|
||||
+ SocketAddress socketaddress = loginlistener.connection.getSocketAddress();
|
||||
+ SocketAddress socketaddress = loginlistener.connection.getRemoteAddress();
|
||||
+
|
||||
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile);
|
||||
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile);
|
||||
+ Player player = entity.getBukkitEntity();
|
||||
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
||||
+
|
||||
+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
|
||||
+ if (getBans().isBanned(gameprofile) && !getBans().get(gameprofile).hasExpired()) {
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||
|
||||
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
|
||||
@@ -417,10 +573,12 @@
|
||||
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())}));
|
||||
@@ -418,10 +574,12 @@
|
||||
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})));
|
||||
}
|
||||
|
||||
- return chatmessage;
|
||||
+ // return 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");
|
||||
- } else if (this.ipBans.isBanned(socketaddress)) {
|
||||
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
|
||||
+ 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.ipBans.get(socketaddress);
|
||||
|
||||
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
|
||||
@@ -428,13 +586,25 @@
|
||||
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())}));
|
||||
@@ -429,13 +587,25 @@
|
||||
chatmessage.append((IChatBaseComponent) (new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())})));
|
||||
}
|
||||
|
||||
- return chatmessage;
|
||||
+ // return chatmessage;
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
|
||||
} else {
|
||||
- return this.players.size() >= this.maxPlayers && !this.d(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.d(gameprofile)) {
|
||||
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
|
||||
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
|
||||
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
|
||||
+ }
|
||||
}
|
||||
@ -392,41 +392,41 @@
|
||||
+ return entity;
|
||||
}
|
||||
|
||||
- public EntityPlayer processLogin(GameProfile gameprofile) {
|
||||
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
|
||||
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) {
|
||||
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
|
||||
+ /* CraftBukkit startMoved up
|
||||
UUID uuid = EntityHuman.a(gameprofile);
|
||||
UUID uuid = EntityHuman.createPlayerUUID(gameprofile);
|
||||
List<EntityPlayer> list = Lists.newArrayList();
|
||||
|
||||
@@ -461,14 +631,24 @@
|
||||
@@ -462,14 +632,24 @@
|
||||
}
|
||||
|
||||
return new EntityPlayer(this.server, this.server.E(), gameprofile);
|
||||
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
|
||||
+ */
|
||||
+ return player;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public EntityPlayer moveToWorld(EntityPlayer entityplayer, boolean flag) {
|
||||
+ return this.moveToWorld(entityplayer, this.server.getWorldServer(entityplayer.getSpawnDimension()), flag, null, true);
|
||||
public EntityPlayer respawn(EntityPlayer entityplayer, boolean flag) {
|
||||
+ return this.respawn(entityplayer, this.server.getLevel(entityplayer.getRespawnDimension()), flag, null, true);
|
||||
+ }
|
||||
+
|
||||
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) {
|
||||
+ public EntityPlayer respawn(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) {
|
||||
+ entityplayer.stopRiding(); // CraftBukkit
|
||||
this.players.remove(entityplayer);
|
||||
entityplayer.getWorldServer().a(entityplayer, Entity.RemovalReason.DISCARDED);
|
||||
BlockPosition blockposition = entityplayer.getSpawn();
|
||||
float f = entityplayer.getSpawnAngle();
|
||||
boolean flag1 = entityplayer.isSpawnForced();
|
||||
entityplayer.getLevel().removePlayerImmediately(entityplayer, Entity.RemovalReason.DISCARDED);
|
||||
BlockPosition blockposition = entityplayer.getRespawnPosition();
|
||||
float f = entityplayer.getRespawnAngle();
|
||||
boolean flag1 = entityplayer.isRespawnForced();
|
||||
+ /* CraftBukkit start
|
||||
WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension());
|
||||
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
Optional optional;
|
||||
|
||||
@@ -480,6 +660,11 @@
|
||||
@@ -481,6 +661,11 @@
|
||||
|
||||
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.E();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getProfile());
|
||||
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
|
||||
+ // */
|
||||
+ EntityPlayer entityplayer1 = entityplayer;
|
||||
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
|
||||
@ -434,69 +434,69 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityplayer1.connection = entityplayer.connection;
|
||||
entityplayer1.copyFrom(entityplayer, flag);
|
||||
@@ -495,49 +680,111 @@
|
||||
entityplayer1.restoreFrom(entityplayer, flag);
|
||||
@@ -496,49 +681,110 @@
|
||||
|
||||
boolean flag2 = false;
|
||||
|
||||
- if (optional.isPresent()) {
|
||||
- IBlockData iblockdata = worldserver1.getType(blockposition);
|
||||
- boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR);
|
||||
- IBlockData iblockdata = worldserver1.getBlockState(blockposition);
|
||||
- boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
|
||||
- Vec3D vec3d = (Vec3D) optional.get();
|
||||
- float f1;
|
||||
+ // CraftBukkit start - fire PlayerRespawnEvent
|
||||
+ if (location == null) {
|
||||
+ boolean isBedSpawn = false;
|
||||
+ WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension());
|
||||
+ WorldServer worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
+ if (worldserver1 != null) {
|
||||
+ Optional optional;
|
||||
|
||||
- if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
- if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
- f1 = f;
|
||||
- } else {
|
||||
- Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d();
|
||||
- Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
+ if (blockposition != null) {
|
||||
+ optional = EntityHuman.getBed(worldserver1, blockposition, f, flag1, flag);
|
||||
+ optional = EntityHuman.findRespawnPositionAndUseSpawnBlock(worldserver1, blockposition, f, flag1, flag);
|
||||
+ } else {
|
||||
+ optional = Optional.empty();
|
||||
+ }
|
||||
+
|
||||
+ if (optional.isPresent()) {
|
||||
+ IBlockData iblockdata = worldserver1.getType(blockposition);
|
||||
+ boolean flag3 = iblockdata.a(Blocks.RESPAWN_ANCHOR);
|
||||
+ IBlockData iblockdata = worldserver1.getBlockState(blockposition);
|
||||
+ boolean flag3 = iblockdata.is(Blocks.RESPAWN_ANCHOR);
|
||||
+ Vec3D vec3d = (Vec3D) optional.get();
|
||||
+ float f1;
|
||||
+
|
||||
+ if (!iblockdata.a((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
+ if (!iblockdata.is((Tag) TagsBlock.BEDS) && !flag3) {
|
||||
+ f1 = f;
|
||||
+ } else {
|
||||
+ Vec3D vec3d1 = Vec3D.c((BaseBlockPosition) blockposition).d(vec3d).d();
|
||||
+ Vec3D vec3d1 = Vec3D.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
|
||||
- f1 = (float) MathHelper.f(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.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ f1 = (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
+ }
|
||||
+
|
||||
+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
|
||||
+ entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false);
|
||||
+ flag2 = !flag && flag3;
|
||||
+ isBedSpawn = true;
|
||||
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
+ } else if (blockposition != null) {
|
||||
+ entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (location == null) {
|
||||
+ worldserver1 = this.server.getWorldServer(World.OVERWORLD);
|
||||
+ worldserver1 = this.server.getLevel(World.OVERWORLD);
|
||||
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
|
||||
}
|
||||
|
||||
- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, f, flag1, false);
|
||||
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, f1, 0.0F);
|
||||
- entityplayer1.setRespawnPosition(worldserver1.dimension(), blockposition, f, flag1, false);
|
||||
- flag2 = !flag && flag3;
|
||||
- } else if (blockposition != null) {
|
||||
- entityplayer1.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
- entityplayer1.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
+ Player respawnPlayer = entityplayer1.getBukkitEntity();
|
||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2);
|
||||
+ cserver.getPluginManager().callEvent(respawnEvent);
|
||||
@ -510,52 +510,51 @@
|
||||
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
+ // CraftBukkit end
|
||||
|
||||
- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
|
||||
- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
+ while (avoidSuffocation && !worldserver1.noCollision(entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
|
||||
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ WorldData worlddata = worldserver1.getWorldData();
|
||||
+ entityplayer1.connection.sendPacket(new PacketPlayOutRespawn(worldserver1.getDimensionManager(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.gameMode.getGameMode(), entityplayer1.gameMode.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag));
|
||||
+ WorldData worlddata = worldserver1.getLevelData();
|
||||
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionType(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), flag));
|
||||
+ entityplayer1.spawnIn(worldserver1);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
|
||||
+ entityplayer1.setSneaking(false);
|
||||
+ entityplayer1.connection.teleport(new Location(worldserver1.getWorld(), entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()));
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
|
||||
- WorldData worlddata = entityplayer1.level.getWorldData();
|
||||
- WorldData worlddata = entityplayer1.level.getLevelData();
|
||||
-
|
||||
- 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.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
+ // entityplayer1.connection.b(entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
entityplayer1.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn(), worldserver1.x()));
|
||||
entityplayer1.connection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.connection.sendPacket(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
|
||||
this.a(entityplayer1, worldserver1);
|
||||
this.d(entityplayer1);
|
||||
- worldserver1.addPlayerRespawn(entityplayer1);
|
||||
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level.dimensionType(), entityplayer1.level.dimension(), BiomeManager.obfuscateSeed(entityplayer1.getLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.getLevel().isDebug(), entityplayer1.getLevel().isFlat(), flag));
|
||||
- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
+ // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
|
||||
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
|
||||
entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
|
||||
this.sendLevelInfo(entityplayer1, worldserver1);
|
||||
this.sendPlayerPermissionLevel(entityplayer1);
|
||||
- worldserver1.addRespawnedPlayer(entityplayer1);
|
||||
- this.players.add(entityplayer1);
|
||||
- this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1);
|
||||
- entityplayer1.syncInventory();
|
||||
- this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1);
|
||||
- entityplayer1.initInventoryMenu();
|
||||
+ if (!entityplayer.connection.isDisconnected()) {
|
||||
+ worldserver1.addPlayerRespawn(entityplayer1);
|
||||
+ worldserver1.addRespawnedPlayer(entityplayer1);
|
||||
+ this.players.add(entityplayer1);
|
||||
+ this.playersByUUID.put(entityplayer1.getUniqueID(), entityplayer1);
|
||||
+ this.playersByUUID.put(entityplayer1.getUUID(), entityplayer1);
|
||||
+ }
|
||||
+ // entityplayer1.syncInventory();
|
||||
+ // entityplayer1.initInventoryMenu();
|
||||
entityplayer1.setHealth(entityplayer1.getHealth());
|
||||
if (flag2) {
|
||||
entityplayer1.connection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
|
||||
entityplayer1.connection.send(new PacketPlayOutNamedSoundEffect(SoundEffects.RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
|
||||
}
|
||||
+ // Added from changeDimension
|
||||
+ updateClient(entityplayer); // Update health, etc...
|
||||
+ entityplayer.updateAbilities();
|
||||
+ for (Object o1 : entityplayer.getEffects()) {
|
||||
+ MobEffect mobEffect = (MobEffect) o1;
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
|
||||
+ sendAllPlayerInfo(entityplayer); // Update health, etc...
|
||||
+ entityplayer.onUpdateAbilities();
|
||||
+ for (MobEffect mobEffect : entityplayer.getActiveEffects()) {
|
||||
+ entityplayer.connection.send(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
|
||||
+ }
|
||||
+
|
||||
+ // Fire advancement trigger
|
||||
+ entityplayer.triggerDimensionAdvancements(((CraftWorld) fromWorld).getHandle());
|
||||
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
|
||||
|
||||
+ // Don't fire on respawn
|
||||
+ if (fromWorld != location.getWorld()) {
|
||||
@ -565,22 +564,22 @@
|
||||
+
|
||||
+ // Save player file again if they were disconnected
|
||||
+ if (entityplayer.connection.isDisconnected()) {
|
||||
+ this.savePlayerFile(entityplayer);
|
||||
+ this.save(entityplayer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -550,7 +797,18 @@
|
||||
@@ -551,7 +797,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players));
|
||||
- this.broadcastAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players));
|
||||
+ // CraftBukkit start
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ final EntityPlayer target = (EntityPlayer) this.players.get(i);
|
||||
+
|
||||
+ target.connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() {
|
||||
+ target.connection.send(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players.stream().filter(new Predicate<EntityPlayer>() {
|
||||
+ @Override
|
||||
+ public boolean apply(EntityPlayer input) {
|
||||
+ return target.getBukkitEntity().canSee(input.getBukkitEntity());
|
||||
@ -591,41 +590,50 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -567,6 +825,25 @@
|
||||
@@ -568,6 +825,25 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add a world/entity limited version
|
||||
+ public void sendAll(Packet packet, EntityHuman entityhuman) {
|
||||
+ public void broadcastAll(Packet packet, EntityHuman entityhuman) {
|
||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||
+ EntityPlayer entityplayer = this.players.get(i);
|
||||
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ ((EntityPlayer) this.players.get(i)).connection.sendPacket(packet);
|
||||
+ ((EntityPlayer) this.players.get(i)).connection.send(packet);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void sendAll(Packet packet, World world) {
|
||||
+ for (int i = 0; i < world.getPlayers().size(); ++i) {
|
||||
+ ((EntityPlayer) world.getPlayers().get(i)).connection.sendPacket(packet);
|
||||
+ public void broadcastAll(Packet packet, World world) {
|
||||
+ for (int i = 0; i < world.players().size(); ++i) {
|
||||
+ ((EntityPlayer) world.players().get(i)).connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -669,6 +946,7 @@
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
@@ -646,7 +922,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile gameprofile) {
|
||||
- this.ops.remove((Object) gameprofile);
|
||||
+ this.ops.remove(gameprofile); // CraftBukkit - decompile error
|
||||
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -670,6 +946,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
|
||||
this.server.getCommandDispatcher().a(entityplayer);
|
||||
this.server.getCommands().sendCommands(entityplayer);
|
||||
}
|
||||
|
||||
@@ -701,6 +979,12 @@
|
||||
@@ -702,6 +979,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
@ -635,27 +643,27 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (entityplayer != entityhuman && entityplayer.level.getDimensionKey() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.locX();
|
||||
double d5 = d1 - entityplayer.locY();
|
||||
@@ -740,23 +1024,34 @@
|
||||
public void reloadWhitelist() {}
|
||||
if (entityplayer != entityhuman && entityplayer.level.dimension() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.getX();
|
||||
double d5 = d1 - entityplayer.getY();
|
||||
@@ -741,23 +1024,34 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
- WorldBorder worldborder = this.server.E().getWorldBorder();
|
||||
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
- WorldBorder worldborder = this.server.overworld().getWorldBorder();
|
||||
+ WorldBorder worldborder = entityplayer.level.getWorldBorder(); // CraftBukkit
|
||||
|
||||
entityplayer.connection.sendPacket(new ClientboundInitializeBorderPacket(worldborder));
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn(), worldserver.x()));
|
||||
entityplayer.connection.send(new ClientboundInitializeBorderPacket(worldborder));
|
||||
entityplayer.connection.send(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
||||
entityplayer.connection.send(new PacketPlayOutSpawnPosition(worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle()));
|
||||
if (worldserver.isRaining()) {
|
||||
- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
|
||||
- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.d(1.0F)));
|
||||
- entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.b(1.0F)));
|
||||
- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
|
||||
- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.getRainLevel(1.0F)));
|
||||
- entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.getThunderLevel(1.0F)));
|
||||
+ // CraftBukkit start - handle player weather
|
||||
+ // 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.i, worldserver.b(1.0F)));
|
||||
+ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
|
||||
+ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, worldserver.getRainLevel(1.0F)));
|
||||
+ // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, worldserver.getThunderLevel(1.0F)));
|
||||
+ entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
|
||||
+ entityplayer.updateWeather(-worldserver.rainLevel, worldserver.rainLevel, -worldserver.thunderLevel, worldserver.thunderLevel);
|
||||
+ // CraftBukkit end
|
||||
@ -663,25 +671,25 @@
|
||||
|
||||
}
|
||||
|
||||
public void updateClient(EntityPlayer entityplayer) {
|
||||
entityplayer.inventoryMenu.updateInventory();
|
||||
- entityplayer.triggerHealthUpdate();
|
||||
+ // entityplayer.triggerHealthUpdate();
|
||||
public void sendAllPlayerInfo(EntityPlayer entityplayer) {
|
||||
entityplayer.inventoryMenu.sendAllDataToRemote();
|
||||
- entityplayer.resetSentInfo();
|
||||
+ // entityplayer.resetSentInfo();
|
||||
+ entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
|
||||
entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
|
||||
+ // CraftBukkit start - from GameRules
|
||||
+ int i = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23;
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
+ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
+ float immediateRespawn = entityplayer.level.getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn));
|
||||
+ entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -807,12 +1102,22 @@
|
||||
@@ -813,12 +1107,22 @@
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
public void removeAll() {
|
||||
- for (int i = 0; i < this.players.size(); ++i) {
|
||||
- ((EntityPlayer) this.players.get(i)).connection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
|
||||
+ // CraftBukkit start - disconnect safely
|
||||
@ -693,45 +701,45 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
|
||||
+ public void broadcastMessage(IChatBaseComponent[] iChatBaseComponents) {
|
||||
+ for (IChatBaseComponent component : iChatBaseComponents) {
|
||||
+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
+ broadcastMessage(component, ChatMessageType.SYSTEM, SystemUtils.NIL_UUID);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
|
||||
public void broadcastMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
|
||||
this.server.sendMessage(ichatbasecomponent, uuid);
|
||||
Iterator iterator = this.players.iterator();
|
||||
@@ -840,16 +1145,23 @@
|
||||
@@ -846,16 +1150,23 @@
|
||||
|
||||
}
|
||||
|
||||
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
|
||||
- UUID uuid = entityhuman.getUniqueID();
|
||||
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.stats.get(uuid);
|
||||
- public ServerStatisticManager getPlayerStats(EntityHuman entityhuman) {
|
||||
- UUID uuid = entityhuman.getUUID();
|
||||
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.stats.get(uuid);
|
||||
+ // CraftBukkit start
|
||||
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager();
|
||||
+ return serverstatisticmanager == null ? getStatisticManager(entityhuman.getUniqueID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager;
|
||||
+ public ServerStatisticManager getPlayerStats(EntityPlayer entityhuman) {
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStats();
|
||||
+ return serverstatisticmanager == null ? getPlayerStats(entityhuman.getUUID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager;
|
||||
+ }
|
||||
+
|
||||
+ public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) {
|
||||
+ public ServerStatisticManager getPlayerStats(UUID uuid, String displayName) {
|
||||
+ EntityPlayer entityhuman = this.getPlayer(uuid);
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager();
|
||||
+ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStats();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (serverstatisticmanager == null) {
|
||||
File file = this.server.a(SavedFile.PLAYER_STATS_DIR).toFile();
|
||||
File file = this.server.getWorldPath(SavedFile.PLAYER_STATS_DIR).toFile();
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
|
||||
if (!file1.exists()) {
|
||||
- File file2 = new File(file, entityhuman.getDisplayName().getString() + ".json");
|
||||
- File file2 = new File(file, entityhuman.getName().getString() + ".json");
|
||||
+ File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtils.a(path) && FileUtils.b(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -858,7 +1170,7 @@
|
||||
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -864,7 +1175,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
@ -740,27 +748,27 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -866,14 +1178,14 @@
|
||||
@@ -872,14 +1183,14 @@
|
||||
|
||||
public AdvancementDataPlayer f(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUniqueID();
|
||||
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUUID();
|
||||
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.advancements.get(uuid);
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
|
||||
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancements(); // CraftBukkit
|
||||
|
||||
if (advancementdataplayer == null) {
|
||||
File file = this.server.a(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
File file = this.server.getWorldPath(SavedFile.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
|
||||
advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer);
|
||||
advancementdataplayer = new AdvancementDataPlayer(this.server.getFixerUpper(), this, this.server.getAdvancements(), file1, entityplayer);
|
||||
- this.advancements.put(uuid, advancementdataplayer);
|
||||
+ // this.advancements.put(uuid, advancementdataplayer); // CraftBukkit
|
||||
}
|
||||
|
||||
advancementdataplayer.a(entityplayer);
|
||||
@@ -909,13 +1221,20 @@
|
||||
advancementdataplayer.setPlayer(entityplayer);
|
||||
@@ -930,13 +1241,20 @@
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public void reloadResources() {
|
||||
- Iterator iterator = this.advancements.values().iterator();
|
||||
+ // CraftBukkit start
|
||||
+ /*Iterator iterator = this.advancements.values().iterator();
|
||||
@ -768,14 +776,14 @@
|
||||
while (iterator.hasNext()) {
|
||||
AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next();
|
||||
|
||||
advancementdataplayer.a(this.server.getAdvancementData());
|
||||
advancementdataplayer.reload(this.server.getAdvancements());
|
||||
+ }*/
|
||||
+
|
||||
+ for (EntityPlayer player : players) {
|
||||
+ player.getAdvancementData().a(this.server.getAdvancementData());
|
||||
+ player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements
|
||||
+ player.getAdvancements().reload(this.server.getAdvancements());
|
||||
+ player.getAdvancements().flushDirty(player); // CraftBukkit - trigger immediate flush of advancements
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry().a((IRegistryCustom) this.registryHolder)));
|
||||
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b());
|
||||
this.broadcastAll(new PacketPlayOutTags(this.server.getTags().serializeToNetwork(this.registryHolder)));
|
||||
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes());
|
||||
|
@ -3,18 +3,18 @@
|
||||
@@ -18,9 +18,12 @@
|
||||
}
|
||||
|
||||
public boolean a(int i, List<EntityPlayer> list) {
|
||||
- int j = (int) list.stream().filter(EntityHuman::isDeeplySleeping).count();
|
||||
public boolean areEnoughDeepSleeping(int i, List<EntityPlayer> list) {
|
||||
- int j = (int) list.stream().filter(EntityHuman::isSleepingLongEnough).count();
|
||||
+ // CraftBukkit start
|
||||
+ int j = (int) list.stream().filter((eh) -> { return eh.isDeeplySleeping() || eh.fauxSleeping; }).count();
|
||||
+ boolean anyDeepSleep = list.stream().anyMatch(EntityHuman::isDeeplySleeping);
|
||||
+ int j = (int) list.stream().filter((eh) -> { return eh.isSleepingLongEnough() || eh.fauxSleeping; }).count();
|
||||
+ boolean anyDeepSleep = list.stream().anyMatch(EntityHuman::isSleepingLongEnough);
|
||||
|
||||
- return j >= this.b(i);
|
||||
+ return anyDeepSleep && j >= this.b(i);
|
||||
- return j >= this.sleepersNeeded(i);
|
||||
+ return anyDeepSleep && j >= this.sleepersNeeded(i);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public int b(int i) {
|
||||
public int sleepersNeeded(int i) {
|
||||
@@ -42,18 +45,24 @@
|
||||
this.activePlayers = 0;
|
||||
this.sleepingPlayers = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
+++ b/net/minecraft/server/rcon/RemoteControlCommandListener.java
|
||||
@@ -37,6 +37,17 @@
|
||||
return new CommandListenerWrapper(this, Vec3D.b((BaseBlockPosition) worldserver.getSpawn()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
|
||||
@@ -36,6 +36,17 @@
|
||||
return new CommandListenerWrapper(this, Vec3D.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2F.ZERO, worldserver, 4, "Rcon", RemoteControlCommandListener.RCON_COMPONENT, this.server, (Entity) null);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Send a String
|
||||
|
@ -11,18 +11,18 @@
|
||||
public static final String RECIPE_BOOK_TAG = "recipeBook";
|
||||
@@ -36,7 +38,7 @@
|
||||
IRecipe<?> irecipe = (IRecipe) iterator.next();
|
||||
MinecraftKey minecraftkey = irecipe.getKey();
|
||||
MinecraftKey minecraftkey = irecipe.getId();
|
||||
|
||||
- if (!this.known.contains(minecraftkey) && !irecipe.isComplex()) {
|
||||
+ if (!this.known.contains(minecraftkey) && !irecipe.isComplex() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit
|
||||
this.a(minecraftkey);
|
||||
this.d(minecraftkey);
|
||||
- if (!this.known.contains(minecraftkey) && !irecipe.isSpecial()) {
|
||||
+ if (!this.known.contains(minecraftkey) && !irecipe.isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit
|
||||
this.add(minecraftkey);
|
||||
this.addHighlight(minecraftkey);
|
||||
list.add(minecraftkey);
|
||||
@@ -70,6 +72,7 @@
|
||||
}
|
||||
|
||||
private void a(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) {
|
||||
private void sendRecipes(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) {
|
||||
+ if (entityplayer.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.a()));
|
||||
entityplayer.connection.send(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.getBookSettings()));
|
||||
}
|
||||
|
||||
|
@ -8,19 +8,19 @@
|
||||
@@ -161,13 +162,12 @@
|
||||
}
|
||||
|
||||
private <T> Optional<Statistic<T>> a(StatisticWrapper<T> statisticwrapper, String s) {
|
||||
- Optional optional = Optional.ofNullable(MinecraftKey.a(s));
|
||||
private <T> Optional<Statistic<T>> getStat(StatisticWrapper<T> statisticwrapper, String s) {
|
||||
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(s));
|
||||
- IRegistry iregistry = statisticwrapper.getRegistry();
|
||||
+ // CraftBukkit - decompile error start
|
||||
+ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.a(s));
|
||||
+ Optional<MinecraftKey> optional = Optional.ofNullable(MinecraftKey.tryParse(s));
|
||||
+ IRegistry<T> iregistry = statisticwrapper.getRegistry();
|
||||
|
||||
- Objects.requireNonNull(iregistry);
|
||||
- optional = optional.flatMap(iregistry::getOptional);
|
||||
- Objects.requireNonNull(statisticwrapper);
|
||||
- return optional.map(statisticwrapper::b);
|
||||
+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::b);
|
||||
- return optional.map(statisticwrapper::get);
|
||||
+ return optional.flatMap(iregistry::getOptional).map(statisticwrapper::get);
|
||||
+ // CraftBukkit - decompile error end
|
||||
}
|
||||
|
||||
private static NBTTagCompound a(JsonObject jsonobject) {
|
||||
private static NBTTagCompound fromJson(JsonObject jsonobject) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/stats/StatisticManager.java
|
||||
+++ b/net/minecraft/stats/StatisticManager.java
|
||||
@@ -16,6 +16,12 @@
|
||||
public void b(EntityHuman entityhuman, Statistic<?> statistic, int i) {
|
||||
int j = (int) Math.min((long) this.getStatisticValue(statistic) + (long) i, 2147483647L);
|
||||
public void increment(EntityHuman entityhuman, Statistic<?> statistic, int i) {
|
||||
int j = (int) Math.min((long) this.getValue(statistic) + (long) i, 2147483647L);
|
||||
|
||||
+ // CraftBukkit start - fire Statistic events
|
||||
+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getStatisticValue(statistic), j);
|
||||
+ org.bukkit.event.Cancellable cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.handleStatisticsIncrease(entityhuman, statistic, this.getValue(statistic), j);
|
||||
+ if (cancellable != null && cancellable.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setStatistic(entityhuman, statistic, j);
|
||||
this.setValue(entityhuman, statistic, j);
|
||||
}
|
||||
|
||||
|
47
paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch
Normale Datei
47
paper-server/nms-patches/net/minecraft/util/InclusiveRange.patch
Normale Datei
@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/util/InclusiveRange.java
|
||||
+++ b/net/minecraft/util/InclusiveRange.java
|
||||
@@ -4,19 +4,23 @@
|
||||
import com.mojang.serialization.DataResult;
|
||||
import java.util.function.Function;
|
||||
|
||||
-public final class InclusiveRange extends Record {
|
||||
+// CraftBukkit start - decompile error
|
||||
+public final record InclusiveRange<T extends Comparable<T>>(T minInclusive, T maxInclusive) {
|
||||
|
||||
+ /*
|
||||
private final T minInclusive;
|
||||
private final T maxInclusive;
|
||||
+ */
|
||||
public static final Codec<InclusiveRange<Integer>> INT = codec(Codec.INT);
|
||||
|
||||
- public InclusiveRange(T t0, T t1) {
|
||||
- if (t0.compareTo(t1) > 0) {
|
||||
+ public InclusiveRange(T minInclusive, T maxInclusive) {
|
||||
+ if (minInclusive.compareTo(maxInclusive) > 0) {
|
||||
throw new IllegalArgumentException("min_inclusive must be less than or equal to max_inclusive");
|
||||
} else {
|
||||
- this.minInclusive = t0;
|
||||
- this.maxInclusive = t1;
|
||||
+ this.minInclusive = minInclusive;
|
||||
+ this.maxInclusive = maxInclusive;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static <T extends Comparable<T>> Codec<InclusiveRange<T>> codec(Codec<T> codec) {
|
||||
@@ -47,6 +51,8 @@
|
||||
return "[" + this.minInclusive + ", " + this.maxInclusive + "]";
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ /*
|
||||
public final int hashCode() {
|
||||
return this.hashCode < invokedynamic > (this);
|
||||
}
|
||||
@@ -62,4 +68,6 @@
|
||||
public T maxInclusive() {
|
||||
return this.maxInclusive;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
@@ -380,6 +380,18 @@
|
||||
@@ -391,6 +391,18 @@
|
||||
datafixerbuilder.addFixer(new DataConverterItemFrame(schema46, false));
|
||||
Schema schema47 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED);
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
+ protected com.mojang.datafixers.TypeRewriteRule makeRule() {
|
||||
+ return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(DataConverterTypes.PLAYER), (typed) -> {
|
||||
+ return typed.update(DSL.remainderFinder(), (dynamic) -> {
|
||||
+ return DataConverterCustomNameEntity.a(dynamic);
|
||||
+ return DataConverterCustomNameEntity.fixTagCustomName(dynamic);
|
||||
+ });
|
||||
+ });
|
||||
+ }
|
||||
@ -19,7 +19,7 @@
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema47, false));
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema47, false));
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema47, false));
|
||||
@@ -693,17 +705,20 @@
|
||||
@@ -704,12 +716,14 @@
|
||||
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);
|
||||
@ -27,19 +27,22 @@
|
||||
+ // 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)));
|
||||
datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Renamed copper block items to new oxidized terms", createRenamer(immutablemap)));
|
||||
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema131, "Renamed copper blocks to new oxidized terms", createRenamer(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);
|
||||
datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1)));
|
||||
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
|
||||
@@ -717,7 +731,8 @@
|
||||
|
||||
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
|
||||
Schema schema134 = 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)));
|
||||
datafixerbuilder.addFixer(DataConverterItemName.create(schema134, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2)));
|
||||
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema134, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2)));
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -34,11 +34,15 @@
|
||||
@@ -38,6 +38,10 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -11,43 +11,33 @@
|
||||
public class WorldUpgrader {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final ThreadFactory THREAD_FACTORY = (new ThreadFactoryBuilder()).setDaemon(true).build();
|
||||
- private final ImmutableSet<ResourceKey<World>> levels;
|
||||
+ private final ImmutableSet<ResourceKey<DimensionManager>> levels; // CraftBukkit
|
||||
private final boolean eraseCache;
|
||||
private final Convertable.ConversionSession levelStorage;
|
||||
private final Thread thread;
|
||||
@@ -49,12 +53,12 @@
|
||||
@@ -53,7 +57,7 @@
|
||||
private volatile int totalChunks;
|
||||
private volatile int converted;
|
||||
private volatile int skipped;
|
||||
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k()));
|
||||
+ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.k())); // CraftBukkit
|
||||
- private final Object2FloatMap<ResourceKey<World>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy()));
|
||||
+ private final Object2FloatMap<ResourceKey<DimensionManager>> progressMap = Object2FloatMaps.synchronize(new Object2FloatOpenCustomHashMap(SystemUtils.identityStrategy())); // CraftBukkit
|
||||
private volatile IChatBaseComponent status = new ChatMessage("optimizeWorld.stage.counting");
|
||||
private static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$");
|
||||
private final WorldPersistentData overworldDataStorage;
|
||||
@@ -86,13 +90,13 @@
|
||||
|
||||
- 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
|
||||
this.levels = immutableset;
|
||||
this.eraseCache = flag;
|
||||
this.dataFixer = datafixer;
|
||||
@@ -82,12 +86,12 @@
|
||||
|
||||
private void i() {
|
||||
private void work() {
|
||||
this.totalChunks = 0;
|
||||
- Builder<ResourceKey<World>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder();
|
||||
- ImmutableSet<ResourceKey<World>> immutableset = this.worldGenSettings.levels();
|
||||
+ Builder<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> builder = ImmutableMap.builder(); // CraftBukkit
|
||||
+ ImmutableSet<ResourceKey<DimensionManager>> immutableset = this.worldGenSettings.levels(); // CraftBukkit
|
||||
|
||||
List list;
|
||||
|
||||
for (UnmodifiableIterator unmodifiableiterator = this.levels.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) {
|
||||
for (UnmodifiableIterator unmodifiableiterator = immutableset.iterator(); unmodifiableiterator.hasNext(); this.totalChunks += list.size()) {
|
||||
- ResourceKey<World> resourcekey = (ResourceKey) unmodifiableiterator.next();
|
||||
+ ResourceKey<DimensionManager> resourcekey = (ResourceKey) unmodifiableiterator.next(); // CraftBukkit
|
||||
|
||||
list = this.b(resourcekey);
|
||||
list = this.getAllChunkPos(resourcekey);
|
||||
builder.put(resourcekey, list.listIterator());
|
||||
@@ -97,18 +101,18 @@
|
||||
@@ -102,18 +106,18 @@
|
||||
this.finished = true;
|
||||
} else {
|
||||
float f = (float) this.totalChunks;
|
||||
@ -55,57 +45,57 @@
|
||||
- Builder<ResourceKey<World>, IChunkLoader> builder1 = ImmutableMap.builder();
|
||||
+ ImmutableMap<ResourceKey<DimensionManager>, ListIterator<ChunkCoordIntPair>> immutablemap = builder.build(); // CraftBukkit
|
||||
+ Builder<ResourceKey<DimensionManager>, IChunkLoader> builder1 = ImmutableMap.builder(); // CraftBukkit
|
||||
UnmodifiableIterator unmodifiableiterator1 = this.levels.iterator();
|
||||
UnmodifiableIterator unmodifiableiterator1 = immutableset.iterator();
|
||||
|
||||
while (unmodifiableiterator1.hasNext()) {
|
||||
- ResourceKey<World> resourcekey1 = (ResourceKey) unmodifiableiterator1.next();
|
||||
- File file = this.levelStorage.a(resourcekey1);
|
||||
- Path path = this.levelStorage.getDimensionPath(resourcekey1);
|
||||
+ ResourceKey<DimensionManager> resourcekey1 = (ResourceKey) unmodifiableiterator1.next(); // CraftBukkit
|
||||
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
|
||||
+ Path path = this.levelStorage.getDimensionPath((ResourceKey) null); // CraftBukkit
|
||||
|
||||
builder1.put(resourcekey1, new IChunkLoader(new File(file, "region"), this.dataFixer, true));
|
||||
builder1.put(resourcekey1, new IChunkLoader(path.resolve("region"), this.dataFixer, true));
|
||||
}
|
||||
|
||||
- ImmutableMap<ResourceKey<World>, IChunkLoader> immutablemap1 = builder1.build();
|
||||
+ ImmutableMap<ResourceKey<DimensionManager>, IChunkLoader> immutablemap1 = builder1.build(); // CraftBukkit
|
||||
long i = SystemUtils.getMonotonicMillis();
|
||||
long i = SystemUtils.getMillis();
|
||||
|
||||
this.status = new ChatMessage("optimizeWorld.stage.upgrading");
|
||||
@@ -120,7 +124,7 @@
|
||||
@@ -125,7 +129,7 @@
|
||||
float f2;
|
||||
|
||||
for (UnmodifiableIterator unmodifiableiterator2 = this.levels.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
|
||||
for (UnmodifiableIterator unmodifiableiterator2 = immutableset.iterator(); unmodifiableiterator2.hasNext(); f1 += f2) {
|
||||
- ResourceKey<World> resourcekey2 = (ResourceKey) unmodifiableiterator2.next();
|
||||
+ ResourceKey<DimensionManager> resourcekey2 = (ResourceKey) unmodifiableiterator2.next(); // CraftBukkit
|
||||
ListIterator<ChunkCoordIntPair> listiterator = (ListIterator) immutablemap.get(resourcekey2);
|
||||
IChunkLoader ichunkloader = (IChunkLoader) immutablemap1.get(resourcekey2);
|
||||
|
||||
@@ -135,7 +139,7 @@
|
||||
int j = IChunkLoader.a(nbttagcompound);
|
||||
NBTTagCompound nbttagcompound1 = ichunkloader.getChunkData(resourcekey2, () -> {
|
||||
@@ -141,7 +145,7 @@
|
||||
ChunkGenerator chunkgenerator = ((WorldDimension) this.worldGenSettings.dimensions().get(GeneratorSettings.levelToLevelStem(resourcekey2))).generator();
|
||||
NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey2, () -> {
|
||||
return this.overworldDataStorage;
|
||||
- }, nbttagcompound);
|
||||
+ }, nbttagcompound, chunkcoordintpair, null); // CraftBukkit
|
||||
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("Level");
|
||||
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound2.getInt("xPos"), nbttagcompound2.getInt("zPos"));
|
||||
- }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer());
|
||||
+ }, nbttagcompound, chunkgenerator.getTypeNameForDataFixer(), chunkcoordintpair, null); // CraftBukkit
|
||||
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
|
||||
|
||||
@@ -208,8 +212,8 @@
|
||||
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
|
||||
@@ -213,8 +217,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private List<ChunkCoordIntPair> b(ResourceKey<World> resourcekey) {
|
||||
- File file = this.levelStorage.a(resourcekey);
|
||||
+ private List<ChunkCoordIntPair> b(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
|
||||
+ File file = this.levelStorage.a((ResourceKey) null); // CraftBukkit
|
||||
- private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<World> resourcekey) {
|
||||
- File file = this.levelStorage.getDimensionPath(resourcekey).toFile();
|
||||
+ private List<ChunkCoordIntPair> getAllChunkPos(ResourceKey<DimensionManager> resourcekey) { // CraftBukkit
|
||||
+ File file = this.levelStorage.getDimensionPath((ResourceKey) null).toFile(); // CraftBukkit
|
||||
File file1 = new File(file, "region");
|
||||
File[] afile = file1.listFiles((file2, s) -> {
|
||||
return s.endsWith(".mca");
|
||||
@@ -269,7 +273,7 @@
|
||||
@@ -274,7 +278,7 @@
|
||||
}
|
||||
|
||||
public ImmutableSet<ResourceKey<World>> c() {
|
||||
- return this.levels;
|
||||
public ImmutableSet<ResourceKey<World>> levels() {
|
||||
- return this.worldGenSettings.levels();
|
||||
+ throw new AssertionError("Unsupported"); // CraftBukkit
|
||||
}
|
||||
|
||||
public float a(ResourceKey<World> resourcekey) {
|
||||
public float dimensionProgress(ResourceKey<World> resourcekey) {
|
||||
|
@ -15,21 +15,21 @@
|
||||
@@ -16,7 +21,19 @@
|
||||
}
|
||||
|
||||
public boolean a(ItemStack itemstack) {
|
||||
- return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasName() && this.key.equals(itemstack.getName().getString());
|
||||
public boolean unlocksWith(ItemStack itemstack) {
|
||||
- return this.key.isEmpty() || !itemstack.isEmpty() && itemstack.hasCustomHoverName() && this.key.equals(itemstack.getHoverName().getString());
|
||||
+ // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes
|
||||
+ if (this.key.isEmpty()) return true;
|
||||
+ if (!itemstack.isEmpty() && itemstack.hasName()) {
|
||||
+ if (!itemstack.isEmpty() && itemstack.hasCustomHoverName()) {
|
||||
+ if (this.key.indexOf(ChatColor.COLOR_CHAR) == -1) {
|
||||
+ // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior):
|
||||
+ return this.key.equals(itemstack.getName().getString());
|
||||
+ return this.key.equals(itemstack.getHoverName().getString());
|
||||
+ } else {
|
||||
+ // The lock key contains color codes, so let's take them into account:
|
||||
+ return this.key.equals(CraftChatMessage.fromComponent(itemstack.getName()));
|
||||
+ return this.key.equals(CraftChatMessage.fromComponent(itemstack.getHoverName()));
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
public void addToTag(NBTTagCompound nbttagcompound) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
- }
|
||||
+ int getMaxStackSize(); // CraftBukkit
|
||||
|
||||
void update();
|
||||
void setChanged();
|
||||
|
||||
@@ -62,4 +65,29 @@
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ List<ItemStack> result = new ArrayList<ItemStack>(this.getSize());
|
||||
+ for (int i = 0; i < this.getSize(); i++) {
|
||||
+ List<ItemStack> result = new ArrayList<ItemStack>(this.getContainerSize());
|
||||
+ for (int i = 0; i < this.getContainerSize(); i++) {
|
||||
+ result.add(this.getItem(i));
|
||||
+ }
|
||||
+ return result;
|
||||
@ -61,9 +61,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryLargeChest(IInventory iinventory, IInventory iinventory1) {
|
||||
if (iinventory == null) {
|
||||
iinventory = iinventory1;
|
||||
@@ -62,7 +113,7 @@
|
||||
this.container1 = iinventory;
|
||||
this.container2 = iinventory1;
|
||||
@@ -54,7 +105,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/InventorySubcontainer.java
|
||||
+++ b/net/minecraft/world/InventorySubcontainer.java
|
||||
@@ -13,13 +13,71 @@
|
||||
@@ -14,6 +14,12 @@
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
|
||||
|
||||
private final int size;
|
||||
public final NonNullList<ItemStack> items;
|
||||
@@ -21,7 +27,59 @@
|
||||
@Nullable
|
||||
private List<IInventoryListener> listeners;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
@ -58,7 +59,7 @@
|
||||
+ public InventorySubcontainer(InventorySubcontainer original) {
|
||||
+ this(original.size);
|
||||
+ 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).copy());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -70,5 +71,5 @@
|
||||
+ this.bukkitOwner = owner;
|
||||
+ // CraftBukkit end
|
||||
this.size = i;
|
||||
this.items = NonNullList.a(i, ItemStack.EMPTY);
|
||||
this.items = NonNullList.withSize(i, ItemStack.EMPTY);
|
||||
}
|
||||
|
@ -17,5 +17,5 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static DamageSource b(EntityLiving entityliving) {
|
||||
public static DamageSource sting(EntityLiving entityliving) {
|
||||
return new EntityDamageSource("sting", entityliving);
|
||||
|
@ -2,7 +2,7 @@
|
||||
+++ b/net/minecraft/world/damagesource/EntityDamageSourceIndirect.java
|
||||
@@ -38,4 +38,10 @@
|
||||
|
||||
return !itemstack.isEmpty() && itemstack.hasName() ? new ChatMessage(s1, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent, itemstack.G()}) : new ChatMessage(s, new Object[]{entityliving.getScoreboardDisplayName(), ichatbasecomponent});
|
||||
return !itemstack.isEmpty() && itemstack.hasCustomHoverName() ? new ChatMessage(s1, new Object[]{entityliving.getDisplayName(), ichatbasecomponent, itemstack.getDisplayName()}) : new ChatMessage(s, new Object[]{entityliving.getDisplayName(), ichatbasecomponent});
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap();
|
||||
@@ -44,26 +51,37 @@
|
||||
public void tick(EntityLiving entityliving, int i) {
|
||||
public void applyEffectTick(EntityLiving entityliving, int i) {
|
||||
if (this == MobEffects.REGENERATION) {
|
||||
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
|
||||
- entityliving.heal(1.0F);
|
||||
@ -23,14 +23,14 @@
|
||||
}
|
||||
} else if (this == MobEffects.POISON) {
|
||||
if (entityliving.getHealth() > 1.0F) {
|
||||
- entityliving.damageEntity(DamageSource.MAGIC, 1.0F);
|
||||
+ entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
||||
- entityliving.hurt(DamageSource.MAGIC, 1.0F);
|
||||
+ entityliving.hurt(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
||||
}
|
||||
} else if (this == MobEffects.WITHER) {
|
||||
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
|
||||
entityliving.hurt(DamageSource.WITHER, 1.0F);
|
||||
} else if (this == MobEffects.HUNGER && entityliving instanceof EntityHuman) {
|
||||
- ((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).causeFoodExhaustion(0.005F * (float) (i + 1));
|
||||
+ ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
|
||||
} else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
|
||||
if (!entityliving.level.isClientSide) {
|
||||
- ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
|
||||
@ -44,12 +44,12 @@
|
||||
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
|
||||
+ }
|
||||
+
|
||||
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else if ((this != MobEffects.HEAL || entityliving.dT()) && (this != MobEffects.HARM || !entityliving.dT())) {
|
||||
if (this == MobEffects.HARM && !entityliving.dT() || this == MobEffects.HEAL && entityliving.dT()) {
|
||||
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
|
||||
} else if ((this != MobEffects.HEAL || entityliving.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entityliving.isInvertedHealAndHarm())) {
|
||||
if (this == MobEffects.HARM && !entityliving.isInvertedHealAndHarm() || this == MobEffects.HEAL && entityliving.isInvertedHealAndHarm()) {
|
||||
entityliving.hurt(DamageSource.MAGIC, (float) (6 << i));
|
||||
}
|
||||
} else {
|
||||
- entityliving.heal((float) Math.max(4 << i, 0));
|
||||
|
@ -2,7 +2,7 @@
|
||||
+++ b/net/minecraft/world/effect/MobEffects.java
|
||||
@@ -65,6 +65,14 @@
|
||||
});
|
||||
public static final MobEffectList HERO_OF_THE_VILLAGE = a(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796));
|
||||
public static final MobEffectList HERO_OF_THE_VILLAGE = register(32, "hero_of_the_village", new MobEffectList(MobEffectInfo.BENEFICIAL, 4521796));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ static {
|
||||
@ -14,4 +14,4 @@
|
||||
+
|
||||
public MobEffects() {}
|
||||
|
||||
private static MobEffectList a(int i, String s, MobEffectList mobeffectlist) {
|
||||
private static MobEffectList register(int i, String s, MobEffectList mobeffectlist) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -116,8 +116,58 @@
|
||||
@@ -117,8 +117,58 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
+ // CraftBukkit start
|
||||
+ private static final int CURRENT_LEVEL = 2;
|
||||
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
||||
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
+ }
|
||||
+
|
||||
+ private CraftEntity bukkitEntity;
|
||||
@ -59,10 +59,10 @@
|
||||
protected static final Logger LOGGER = LogManager.getLogger();
|
||||
public static final String ID_TAG = "id";
|
||||
public static final String PASSENGERS_TAG = "Passengers";
|
||||
@@ -224,6 +274,22 @@
|
||||
private float crystalSoundIntensity;
|
||||
private int lastCrystalSoundPlayTick;
|
||||
@@ -229,6 +279,22 @@
|
||||
public boolean hasVisualFire;
|
||||
@Nullable
|
||||
private IBlockData feetBlockState;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean persist = true;
|
||||
+ public boolean valid;
|
||||
@ -76,14 +76,14 @@
|
||||
+ }
|
||||
+
|
||||
+ public boolean isChunkLoaded() {
|
||||
+ return level.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4);
|
||||
+ return level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public Entity(EntityTypes<?> entitytypes, World world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
@@ -359,6 +425,12 @@
|
||||
public void ae() {}
|
||||
@@ -366,6 +432,12 @@
|
||||
public void onClientRemoval() {}
|
||||
|
||||
public void setPose(EntityPose entitypose) {
|
||||
+ // CraftBukkit start
|
||||
@ -95,10 +95,10 @@
|
||||
this.entityData.set(Entity.DATA_POSE, entitypose);
|
||||
}
|
||||
|
||||
@@ -375,6 +447,33 @@
|
||||
@@ -382,6 +454,33 @@
|
||||
}
|
||||
|
||||
protected void setYawPitch(float f, float f1) {
|
||||
protected void setRot(float f, float f1) {
|
||||
+ // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
|
||||
+ if (Float.isNaN(f)) {
|
||||
+ f = 0;
|
||||
@ -106,7 +106,7 @@
|
||||
+
|
||||
+ if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ this.level.getCraftServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
|
||||
+ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid yaw");
|
||||
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)");
|
||||
+ }
|
||||
+ f = 0;
|
||||
@ -119,7 +119,7 @@
|
||||
+
|
||||
+ if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ this.level.getCraftServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch");
|
||||
+ this.level.getCraftServer().getLogger().warning(this.getScoreboardName() + " was caught trying to crash the server with an invalid pitch");
|
||||
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)");
|
||||
+ }
|
||||
+ f1 = 0;
|
||||
@ -129,36 +129,36 @@
|
||||
this.setYRot(f % 360.0F);
|
||||
this.setXRot(f1 % 360.0F);
|
||||
}
|
||||
@@ -416,6 +515,15 @@
|
||||
this.entityBaseTick();
|
||||
@@ -423,6 +522,15 @@
|
||||
this.baseTick();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void postTick() {
|
||||
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
|
||||
+ if (!(this instanceof EntityPlayer)) {
|
||||
+ this.doPortalTick();
|
||||
+ this.handleNetherPortal();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void entityBaseTick() {
|
||||
this.level.getMethodProfiler().enter("entityBaseTick");
|
||||
public void baseTick() {
|
||||
this.level.getProfiler().push("entityBaseTick");
|
||||
if (this.isPassenger() && this.getVehicle().isRemoved()) {
|
||||
@@ -429,7 +537,7 @@
|
||||
@@ -436,7 +544,7 @@
|
||||
this.walkDistO = this.walkDist;
|
||||
this.xRotO = this.getXRot();
|
||||
this.yRotO = this.getYRot();
|
||||
- this.doPortalTick();
|
||||
+ if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick
|
||||
if (this.aV()) {
|
||||
this.aW();
|
||||
- this.handleNetherPortal();
|
||||
+ if (this instanceof EntityPlayer) this.handleNetherPortal(); // CraftBukkit - // Moved up to postTick
|
||||
if (this.canSpawnSprintParticle()) {
|
||||
this.spawnSprintParticle();
|
||||
}
|
||||
@@ -507,7 +615,23 @@
|
||||
@@ -514,7 +622,23 @@
|
||||
|
||||
public void burnFromLava() {
|
||||
if (!this.isFireProof()) {
|
||||
- this.setOnFire(15);
|
||||
public void lavaHurt() {
|
||||
if (!this.fireImmune()) {
|
||||
- this.setSecondsOnFire(15);
|
||||
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
|
||||
+ if (this instanceof EntityLiving && remainingFireTicks <= 0) {
|
||||
+ // not on fire yet
|
||||
@ -169,25 +169,25 @@
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (!combustEvent.isCancelled()) {
|
||||
+ this.setOnFire(combustEvent.getDuration(), false);
|
||||
+ this.setSecondsOnFire(combustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ } else {
|
||||
+ // This will be called every single tick the entity is in lava, so don't throw an event
|
||||
+ this.setOnFire(15, false);
|
||||
+ this.setSecondsOnFire(15, false);
|
||||
+ }
|
||||
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
||||
if (this.damageEntity(DamageSource.LAVA, 4.0F)) {
|
||||
if (this.hurt(DamageSource.LAVA, 4.0F)) {
|
||||
this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
|
||||
}
|
||||
@@ -516,6 +640,22 @@
|
||||
@@ -523,6 +647,22 @@
|
||||
}
|
||||
|
||||
public void setOnFire(int i) {
|
||||
public void setSecondsOnFire(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ this.setOnFire(i, true);
|
||||
+ this.setSecondsOnFire(i, true);
|
||||
+ }
|
||||
+
|
||||
+ public void setOnFire(int i, boolean callEvent) {
|
||||
+ public void setSecondsOnFire(int i, boolean callEvent) {
|
||||
+ if (callEvent) {
|
||||
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i);
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
||||
@ -202,14 +202,14 @@
|
||||
int j = i * 20;
|
||||
|
||||
if (this instanceof EntityLiving) {
|
||||
@@ -614,6 +754,28 @@
|
||||
block.a((IBlockAccess) this.level, this);
|
||||
@@ -627,6 +767,28 @@
|
||||
block.updateEntityAfterFallOn(this.level, this);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (horizontalCollision && getBukkitEntity() instanceof Vehicle) {
|
||||
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
+ org.bukkit.block.Block bl = this.level.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.getX()), MathHelper.floor(this.getY()), MathHelper.floor(this.getZ()));
|
||||
+
|
||||
+ if (vec3d.x > vec3d1.x) {
|
||||
+ bl = bl.getRelative(BlockFace.EAST);
|
||||
@ -228,43 +228,52 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.onGround && !this.bE()) {
|
||||
if (this.onGround && !this.isSteppingCarefully()) {
|
||||
block.stepOn(this.level, blockposition, iblockdata, this);
|
||||
}
|
||||
@@ -1276,6 +1438,7 @@
|
||||
@@ -846,7 +1008,7 @@
|
||||
boolean flag4 = flag && flag1 || flag && flag2 || flag1 && flag2;
|
||||
|
||||
if (flag4) {
|
||||
- List<VoxelShape> list1 = flag3 ? ImmutableList.builderWithExpectedSize(list.size() + 1).addAll(list).add(worldborder.getCollisionShape()).build() : list;
|
||||
+ List<VoxelShape> list1 = flag3 ? ImmutableList.<VoxelShape>builderWithExpectedSize(list.size() + 1).addAll(list).add(worldborder.getCollisionShape()).build() : list; // CraftBukkit - decompile error
|
||||
|
||||
return collideBoundingBox(vec3d, axisalignedbb, world, voxelshapecollision, (List) list1);
|
||||
} else {
|
||||
@@ -1306,6 +1468,7 @@
|
||||
this.yo = d1;
|
||||
this.zo = d4;
|
||||
this.setPosition(d3, d1, d4);
|
||||
+ if (valid) level.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit
|
||||
this.setPos(d3, d1, d4);
|
||||
+ if (valid) level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit
|
||||
}
|
||||
|
||||
public void d(Vec3D vec3d) {
|
||||
@@ -1466,6 +1629,12 @@
|
||||
public void moveTo(Vec3D vec3d) {
|
||||
@@ -1496,6 +1659,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - collidable API
|
||||
+ public boolean canCollideWithBukkit(Entity entity) {
|
||||
+ return isCollidable();
|
||||
+ return isPushable();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(Entity entity, int i, DamageSource damagesource) {
|
||||
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
CriterionTriggers.ENTITY_KILLED_PLAYER.a((EntityPlayer) entity, this, damagesource);
|
||||
@@ -1499,7 +1668,7 @@
|
||||
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
|
||||
@@ -1529,7 +1698,7 @@
|
||||
} else {
|
||||
String s = this.getSaveID();
|
||||
String s = this.getEncodeId();
|
||||
|
||||
- if (s == null) {
|
||||
+ if (!this.persist || s == null) { // CraftBukkit - persist flag
|
||||
return false;
|
||||
} else {
|
||||
nbttagcompound.setString("id", s);
|
||||
@@ -1524,6 +1693,18 @@
|
||||
Vec3D vec3d = this.getMot();
|
||||
nbttagcompound.putString("id", s);
|
||||
@@ -1554,6 +1723,18 @@
|
||||
Vec3D vec3d = this.getDeltaMovement();
|
||||
|
||||
nbttagcompound.set("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
|
||||
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
|
||||
+
|
||||
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
|
||||
+ // TODO: make sure this is the best way to address this.
|
||||
@ -277,29 +286,29 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
nbttagcompound.set("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
|
||||
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.setShort("Fire", (short) this.remainingFireTicks);
|
||||
@@ -1532,6 +1713,18 @@
|
||||
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.a("UUID", this.getUniqueID());
|
||||
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
|
||||
nbttagcompound.putFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
|
||||
@@ -1562,6 +1743,18 @@
|
||||
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.putUUID("UUID", this.getUUID());
|
||||
+ // CraftBukkit start
|
||||
+ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
|
||||
+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits());
|
||||
+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits());
|
||||
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
|
||||
+ nbttagcompound.putLong("WorldUUIDLeast", ((WorldServer) this.level).getWorld().getUID().getLeastSignificantBits());
|
||||
+ nbttagcompound.putLong("WorldUUIDMost", ((WorldServer) this.level).getWorld().getUID().getMostSignificantBits());
|
||||
+ nbttagcompound.putInt("Bukkit.updateLevel", CURRENT_LEVEL);
|
||||
+ if (!this.persist) {
|
||||
+ nbttagcompound.setBoolean("Bukkit.persist", this.persist);
|
||||
+ nbttagcompound.putBoolean("Bukkit.persist", this.persist);
|
||||
+ }
|
||||
+ if (this.persistentInvisibility) {
|
||||
+ nbttagcompound.setBoolean("Bukkit.invisible", this.persistentInvisibility);
|
||||
+ nbttagcompound.putBoolean("Bukkit.invisible", this.persistentInvisibility);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1599,6 +1792,11 @@
|
||||
@@ -1629,6 +1822,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,8 +319,8 @@
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
||||
@@ -1680,6 +1878,49 @@
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -1710,6 +1908,49 @@
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid position");
|
||||
}
|
||||
@ -323,10 +332,10 @@
|
||||
+ // Reset the persistence for tamed animals
|
||||
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ entityinsentient.setPersistenceRequired(!entityinsentient.isTypeNotPersistent(0));
|
||||
+ entityinsentient.setPersistenceRequired(!entityinsentient.removeWhenFarAway(0));
|
||||
+ }
|
||||
+ }
|
||||
+ this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
|
||||
+ this.persist = !nbttagcompound.contains("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit start - Reset world
|
||||
@ -337,7 +346,7 @@
|
||||
+ // TODO: Remove World related checks, replaced with WorldUID
|
||||
+ String worldName = nbttagcompound.getString("world");
|
||||
+
|
||||
+ if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
|
||||
+ if (nbttagcompound.contains("WorldUUIDMost") && nbttagcompound.contains("WorldUUIDLeast")) {
|
||||
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
|
||||
+ bworld = server.getWorld(uid);
|
||||
+ } else {
|
||||
@ -345,13 +354,13 @@
|
||||
+ }
|
||||
+
|
||||
+ if (bworld == null) {
|
||||
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld();
|
||||
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getLevel(World.OVERWORLD).getWorld();
|
||||
+ }
|
||||
+
|
||||
+ ((EntityPlayer) this).spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle());
|
||||
+ ((EntityPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle());
|
||||
+ }
|
||||
+ this.getBukkitEntity().readBukkitValues(nbttagcompound);
|
||||
+ if (nbttagcompound.hasKey("Bukkit.invisible")) {
|
||||
+ if (nbttagcompound.contains("Bukkit.invisible")) {
|
||||
+ boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible");
|
||||
+ this.setInvisible(bukkitInvisible);
|
||||
+ this.persistentInvisibility = bukkitInvisible;
|
||||
@ -359,9 +368,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1755,9 +1996,22 @@
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
||||
@@ -1785,9 +2026,22 @@
|
||||
} else if (this.level.isClientSide) {
|
||||
return null;
|
||||
} else {
|
||||
@ -371,9 +380,9 @@
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY() + (double) f, this.locZ(), itemstack);
|
||||
EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
|
||||
|
||||
entityitem.defaultPickupDelay();
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
+ // CraftBukkit start
|
||||
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
@ -381,19 +390,19 @@
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level.addEntity(entityitem);
|
||||
this.level.addFreshEntity(entityitem);
|
||||
return entityitem;
|
||||
}
|
||||
@@ -1849,7 +2103,7 @@
|
||||
@@ -1882,7 +2136,7 @@
|
||||
|
||||
this.setPose(EntityPose.STANDING);
|
||||
this.vehicle = entity;
|
||||
- this.vehicle.addPassenger(this);
|
||||
+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
|
||||
entity.n().filter((entity2) -> {
|
||||
entity.getIndirectPassengersStream().filter((entity2) -> {
|
||||
return entity2 instanceof EntityPlayer;
|
||||
}).forEach((entity2) -> {
|
||||
@@ -1880,7 +2134,7 @@
|
||||
@@ -1913,7 +2167,7 @@
|
||||
Entity entity = this.vehicle;
|
||||
|
||||
this.vehicle = null;
|
||||
@ -402,8 +411,8 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1889,10 +2143,31 @@
|
||||
this.bo();
|
||||
@@ -1922,10 +2176,31 @@
|
||||
this.removeVehicle();
|
||||
}
|
||||
|
||||
- protected void addPassenger(Entity entity) {
|
||||
@ -435,7 +444,7 @@
|
||||
if (this.passengers.isEmpty()) {
|
||||
this.passengers = ImmutableList.of(entity);
|
||||
} else {
|
||||
@@ -1908,12 +2183,32 @@
|
||||
@@ -1941,12 +2216,32 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -469,39 +478,39 @@
|
||||
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
|
||||
this.passengers = ImmutableList.of();
|
||||
} else {
|
||||
@@ -1924,6 +2219,7 @@
|
||||
@@ -1957,6 +2252,7 @@
|
||||
|
||||
entity.boardingCooldown = 60;
|
||||
}
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
protected boolean o(Entity entity) {
|
||||
@@ -1974,14 +2270,20 @@
|
||||
protected boolean canAddPassenger(Entity entity) {
|
||||
@@ -2007,14 +2303,20 @@
|
||||
|
||||
if (this.isInsidePortal) {
|
||||
MinecraftServer minecraftserver = worldserver.getMinecraftServer();
|
||||
- ResourceKey<World> resourcekey = this.level.getDimensionKey() == World.NETHER ? World.OVERWORLD : World.NETHER;
|
||||
MinecraftServer minecraftserver = worldserver.getServer();
|
||||
- ResourceKey<World> resourcekey = this.level.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER;
|
||||
+ ResourceKey<World> resourcekey = this.level.getTypeKey() == DimensionManager.NETHER_LOCATION ? World.OVERWORLD : World.NETHER; // CraftBukkit
|
||||
WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey);
|
||||
WorldServer worldserver1 = minecraftserver.getLevel(resourcekey);
|
||||
|
||||
- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTime++ >= i) {
|
||||
- if (worldserver1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) {
|
||||
+ if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
|
||||
this.level.getMethodProfiler().enter("portal");
|
||||
this.level.getProfiler().push("portal");
|
||||
this.portalTime = i;
|
||||
this.resetPortalCooldown();
|
||||
- this.b(worldserver1);
|
||||
this.setPortalCooldown();
|
||||
- this.changeDimension(worldserver1);
|
||||
+ // CraftBukkit start
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this).b(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL);
|
||||
+ ((EntityPlayer) this).changeDimension(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL);
|
||||
+ } else {
|
||||
+ this.b(worldserver1);
|
||||
+ this.changeDimension(worldserver1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level.getMethodProfiler().exit();
|
||||
this.level.getProfiler().pop();
|
||||
}
|
||||
|
||||
@@ -2099,6 +2401,13 @@
|
||||
@@ -2132,6 +2434,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
@ -512,27 +521,27 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setFlag(4, flag);
|
||||
this.setSharedFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -2147,8 +2456,12 @@
|
||||
return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false;
|
||||
@@ -2180,8 +2489,12 @@
|
||||
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit - start
|
||||
public void setInvisible(boolean flag) {
|
||||
- this.setFlag(5, flag);
|
||||
- this.setSharedFlag(5, flag);
|
||||
+ if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag
|
||||
+ this.setFlag(5, flag);
|
||||
+ this.setSharedFlag(5, flag);
|
||||
+ }
|
||||
+ // CraftBukkit - end
|
||||
}
|
||||
|
||||
public boolean getFlag(int i) {
|
||||
@@ -2175,7 +2488,17 @@
|
||||
public boolean getSharedFlag(int i) {
|
||||
@@ -2208,7 +2521,17 @@
|
||||
}
|
||||
|
||||
public void setAirTicks(int i) {
|
||||
public void setAirSupply(int i) {
|
||||
- this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i);
|
||||
+ // CraftBukkit start
|
||||
+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
|
||||
@ -548,10 +557,10 @@
|
||||
}
|
||||
|
||||
public int getTicksFrozen() {
|
||||
@@ -2202,11 +2525,41 @@
|
||||
@@ -2235,11 +2558,41 @@
|
||||
|
||||
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
this.setFireTicks(this.remainingFireTicks + 1);
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
this.setRemainingFireTicks(this.remainingFireTicks + 1);
|
||||
+ // CraftBukkit start
|
||||
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
||||
+ final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
|
||||
@ -559,12 +568,12 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.remainingFireTicks == 0) {
|
||||
- this.setOnFire(8);
|
||||
- this.setSecondsOnFire(8);
|
||||
+ // CraftBukkit start - Call a combust event when lightning strikes
|
||||
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
|
||||
+ pluginManager.callEvent(entityCombustEvent);
|
||||
+ if (!entityCombustEvent.isCancelled()) {
|
||||
+ this.setOnFire(entityCombustEvent.getDuration(), false);
|
||||
+ this.setSecondsOnFire(entityCombustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
@ -579,23 +588,23 @@
|
||||
+ }
|
||||
}
|
||||
|
||||
- this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F);
|
||||
+ if (this.isFireProof()) {
|
||||
- this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F);
|
||||
+ if (this.fireImmune()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ CraftEventFactory.entityDamage = entitylightning;
|
||||
+ if (!this.damageEntity(DamageSource.LIGHTNING_BOLT, 5.0F)) {
|
||||
+ if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) {
|
||||
+ CraftEventFactory.entityDamage = null;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void k(boolean flag) {
|
||||
@@ -2356,15 +2709,32 @@
|
||||
public void onAboveBubbleCol(boolean flag) {
|
||||
@@ -2393,15 +2746,32 @@
|
||||
|
||||
@Nullable
|
||||
public Entity b(WorldServer worldserver) {
|
||||
public Entity changeDimension(WorldServer worldserver) {
|
||||
+ // CraftBukkit start
|
||||
+ return teleportTo(worldserver, null);
|
||||
+ }
|
||||
@ -604,55 +613,55 @@
|
||||
+ public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
|
||||
+ // CraftBukkit end
|
||||
if (this.level instanceof WorldServer && !this.isRemoved()) {
|
||||
this.level.getMethodProfiler().enter("changeDimension");
|
||||
- this.decouple();
|
||||
this.level.getProfiler().push("changeDimension");
|
||||
- this.unRide();
|
||||
+ // CraftBukkit start
|
||||
+ // this.decouple();
|
||||
+ if (worldserver == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level.getMethodProfiler().enter("reposition");
|
||||
- ShapeDetectorShape shapedetectorshape = this.a(worldserver);
|
||||
+ 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
|
||||
this.level.getProfiler().push("reposition");
|
||||
- ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver);
|
||||
+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit
|
||||
|
||||
if (shapedetectorshape == null) {
|
||||
return null;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ worldserver = shapedetectorshape.world;
|
||||
+ this.decouple();
|
||||
+ this.unRide();
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.level.getMethodProfiler().exitEnter("reloading");
|
||||
Entity entity = this.getEntityType().a((World) worldserver);
|
||||
this.level.getProfiler().popPush("reloading");
|
||||
Entity entity = this.getType().create(worldserver);
|
||||
|
||||
@@ -2373,9 +2743,17 @@
|
||||
entity.setPositionRotation(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
|
||||
entity.setMot(shapedetectorshape.speed);
|
||||
worldserver.addEntityTeleport(entity);
|
||||
- if (worldserver.getDimensionKey() == World.END) {
|
||||
- WorldServer.a(worldserver);
|
||||
@@ -2410,9 +2780,17 @@
|
||||
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
|
||||
entity.setDeltaMovement(shapedetectorshape.speed);
|
||||
worldserver.addDuringTeleport(entity);
|
||||
- if (worldserver.dimension() == World.END) {
|
||||
- WorldServer.makeObsidianPlatform(worldserver);
|
||||
+ if (worldserver.getTypeKey() == DimensionManager.END_LOCATION) { // CraftBukkit
|
||||
+ WorldServer.a(worldserver, this); // CraftBukkit
|
||||
+ WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
||||
+ this.getBukkitEntity().setHandle(entity);
|
||||
+ entity.bukkitEntity = this.getBukkitEntity();
|
||||
+
|
||||
+ if (this instanceof EntityInsentient) {
|
||||
+ ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads.
|
||||
+ ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads.
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.cc();
|
||||
@@ -2396,13 +2774,18 @@
|
||||
this.removeAfterChangingDimensions();
|
||||
@@ -2433,20 +2811,33 @@
|
||||
|
||||
@Nullable
|
||||
protected ShapeDetectorShape a(WorldServer worldserver) {
|
||||
- boolean flag = this.level.getDimensionKey() == World.END && worldserver.getDimensionKey() == World.OVERWORLD;
|
||||
- boolean flag1 = worldserver.getDimensionKey() == World.END;
|
||||
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
|
||||
- boolean flag = this.level.dimension() == World.END && worldserver.dimension() == World.OVERWORLD;
|
||||
- boolean flag1 = worldserver.dimension() == World.END;
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver == null) {
|
||||
+ return null;
|
||||
@ -662,18 +671,16 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!flag && !flag1) {
|
||||
- boolean flag2 = worldserver.getDimensionKey() == World.NETHER;
|
||||
- boolean flag2 = worldserver.dimension() == World.NETHER;
|
||||
+ boolean flag2 = worldserver.getTypeKey() == DimensionManager.NETHER_LOCATION; // CraftBukkit
|
||||
|
||||
- if (this.level.getDimensionKey() != World.NETHER && !flag2) {
|
||||
- if (this.level.dimension() != World.NETHER && !flag2) {
|
||||
+ if (this.level.getTypeKey() != DimensionManager.NETHER_LOCATION && !flag2) {
|
||||
return null;
|
||||
} else {
|
||||
WorldBorder worldborder = worldserver.getWorldBorder();
|
||||
@@ -2412,8 +2795,16 @@
|
||||
double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D);
|
||||
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));
|
||||
double d0 = DimensionManager.getTeleportationScale(this.level.dimensionType(), worldserver.dimensionType());
|
||||
BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
|
||||
+ if (event == null) {
|
||||
@ -682,26 +689,26 @@
|
||||
+ final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
|
||||
- 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.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> {
|
||||
+ return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> {
|
||||
+ // CraftBukkit end
|
||||
IBlockData iblockdata = this.level.getType(this.portalEntrancePos);
|
||||
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
|
||||
EnumDirection.EnumAxis enumdirection_enumaxis;
|
||||
Vec3D vec3d;
|
||||
@@ -2430,8 +2821,8 @@
|
||||
@@ -2463,8 +2854,8 @@
|
||||
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.getYRot(), this.getXRot());
|
||||
- return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot());
|
||||
- }).orElse((Object) null);
|
||||
+ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.getYRot(), this.getXRot(), event); // CraftBukkit
|
||||
+ return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit
|
||||
+ }).orElse(null); // CraftBuukkit - decompile error
|
||||
}
|
||||
} else {
|
||||
BlockPosition blockposition1;
|
||||
@@ -2441,8 +2832,15 @@
|
||||
@@ -2474,8 +2865,15 @@
|
||||
} else {
|
||||
blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
|
||||
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
|
||||
@ -710,18 +717,18 @@
|
||||
+ }
|
||||
+ 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.getYRot(), this.getXRot());
|
||||
+ 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);
|
||||
- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot());
|
||||
+ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2450,8 +2848,23 @@
|
||||
return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose()));
|
||||
@@ -2483,8 +2881,23 @@
|
||||
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
|
||||
}
|
||||
|
||||
- protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag) {
|
||||
- return worldserver.getTravelAgent().findPortal(blockposition, flag);
|
||||
- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
|
||||
- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder);
|
||||
+ // CraftBukkit start
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
|
||||
@ -736,16 +743,16 @@
|
||||
+ return new CraftPortalEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) {
|
||||
+ return worldserver.getTravelAgent().findPortal(blockposition, searchRadius);
|
||||
+ protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) {
|
||||
+ return worldserver.getPortalForcer().findPortalAround(blockposition, worldborder, searchRadius);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public boolean canPortal() {
|
||||
@@ -2660,7 +3073,26 @@
|
||||
public boolean canChangeDimensions() {
|
||||
@@ -2693,7 +3106,26 @@
|
||||
}
|
||||
|
||||
public final void a(AxisAlignedBB axisalignedbb) {
|
||||
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
|
||||
- this.bb = axisalignedbb;
|
||||
+ // CraftBukkit start - block invalid bounding boxes
|
||||
+ double minX = axisalignedbb.minX,
|
||||
@ -769,4 +776,4 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected float getHeadHeight(EntityPose entitypose, EntitySize entitysize) {
|
||||
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
|
||||
|
@ -9,16 +9,16 @@
|
||||
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -102,6 +103,7 @@
|
||||
super.saveData(nbttagcompound);
|
||||
nbttagcompound.setInt("Age", this.getAge());
|
||||
nbttagcompound.setInt("ForcedAge", this.forcedAge);
|
||||
+ nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
nbttagcompound.putInt("Age", this.getAge());
|
||||
nbttagcompound.putInt("ForcedAge", this.forcedAge);
|
||||
+ nbttagcompound.putBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,6 +111,7 @@
|
||||
super.loadData(nbttagcompound);
|
||||
this.setAgeRaw(nbttagcompound.getInt("Age"));
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
this.setAge(nbttagcompound.getInt("Age"));
|
||||
this.forcedAge = nbttagcompound.getInt("ForcedAge");
|
||||
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
|
||||
}
|
||||
@ -26,10 +26,10 @@
|
||||
@Override
|
||||
@@ -123,7 +126,7 @@
|
||||
@Override
|
||||
public void movementTick() {
|
||||
super.movementTick();
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
- if (this.level.isClientSide) {
|
||||
+ if (this.level.isClientSide || ageLocked) { // CraftBukkit
|
||||
if (this.forcedAgeTimer > 0) {
|
||||
if (this.forcedAgeTimer % 4 == 0) {
|
||||
this.level.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.da() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D);
|
||||
this.level.addParticle(Particles.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D);
|
||||
|
@ -20,21 +20,21 @@
|
||||
+ // CraftBukkit start accessor methods
|
||||
+ public void refreshEffects() {
|
||||
+ if (!this.fixedColor) {
|
||||
+ this.getDataWatcher().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potion, (Collection) this.effects))); // PAIL: rename
|
||||
+ this.getEntityData().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, this.effects)));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public String getType() {
|
||||
+ public String getPotionType() {
|
||||
+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potion)).toString();
|
||||
+ }
|
||||
+
|
||||
+ public void setType(String string) {
|
||||
+ a(IRegistry.POTION.get(new MinecraftKey(string)));
|
||||
+ public void setPotionType(String string) {
|
||||
+ setPotion(IRegistry.POTION.get(new MinecraftKey(string)));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public int getColor() {
|
||||
return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.DATA_COLOR);
|
||||
return (Integer) this.getEntityData().get(EntityAreaEffectCloud.DATA_COLOR);
|
||||
}
|
||||
@@ -259,6 +281,7 @@
|
||||
if (!list1.isEmpty()) {
|
||||
@ -63,8 +63,8 @@
|
||||
Iterator iterator2 = list.iterator();
|
||||
|
||||
@@ -277,7 +311,7 @@
|
||||
if (mobeffect1.getMobEffect().isInstant()) {
|
||||
mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
if (mobeffect1.getEffect().isInstantenous()) {
|
||||
mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect1), this);
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
|
@ -10,20 +10,20 @@
|
||||
+
|
||||
public abstract class EntityCreature extends EntityInsentient {
|
||||
|
||||
protected EntityCreature(EntityTypes<? extends EntityCreature> entitytypes, World world) {
|
||||
@@ -41,6 +45,7 @@
|
||||
protected static final float DEFAULT_WALK_TARGET_VALUE = 0.0F;
|
||||
@@ -43,6 +47,7 @@
|
||||
|
||||
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
|
||||
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isInSittingPose()) {
|
||||
if (f > 10.0F) {
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -49,6 +54,7 @@
|
||||
@@ -51,6 +56,7 @@
|
||||
|
||||
this.y(f);
|
||||
this.onLeashDistance(f);
|
||||
if (f > 10.0F) {
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
this.goalSelector.a(PathfinderGoal.Type.MOVE);
|
||||
this.dropLeash(true, true);
|
||||
this.goalSelector.disableControlFlag(PathfinderGoal.Type.MOVE);
|
||||
} else if (f > 6.0F) {
|
||||
|
@ -18,9 +18,9 @@
|
||||
public void tick() {
|
||||
super.tick();
|
||||
+ EntityHuman prevTarget = this.followingPlayer;// CraftBukkit - store old target
|
||||
this.xo = this.locX();
|
||||
this.yo = this.locY();
|
||||
this.zo = this.locZ();
|
||||
this.xo = this.getX();
|
||||
this.yo = this.getY();
|
||||
this.zo = this.getZ();
|
||||
@@ -84,7 +91,22 @@
|
||||
this.followingPlayer = null;
|
||||
}
|
||||
@ -42,22 +42,22 @@
|
||||
+
|
||||
+ if (this.followingPlayer != null && !cancelled) {
|
||||
+ // CraftBukkit end
|
||||
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 d0 = vec3d.g();
|
||||
Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ());
|
||||
double d0 = vec3d.lengthSqr();
|
||||
|
||||
@@ -225,7 +247,7 @@
|
||||
int i = this.a(entityhuman, this.value);
|
||||
int i = this.repairPlayerItems(entityhuman, this.value);
|
||||
|
||||
if (i > 0) {
|
||||
- entityhuman.giveExp(i);
|
||||
+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
|
||||
- entityhuman.giveExperiencePoints(i);
|
||||
+ entityhuman.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
|
||||
}
|
||||
|
||||
--this.count;
|
||||
@@ -243,9 +265,17 @@
|
||||
if (entry != null) {
|
||||
ItemStack itemstack = (ItemStack) entry.getValue();
|
||||
int j = Math.min(this.c(this.value), itemstack.getDamage());
|
||||
int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue());
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j);
|
||||
+ j = event.getRepairAmount();
|
||||
@ -66,16 +66,16 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.setDamage(itemstack.getDamage() - j);
|
||||
int k = i - this.b(j);
|
||||
itemstack.setDamageValue(itemstack.getDamageValue() - j);
|
||||
int k = i - this.durabilityToXp(j);
|
||||
+ this.value = k; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls
|
||||
|
||||
return k > 0 ? this.a(entityhuman, k) : 0;
|
||||
return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0;
|
||||
} else {
|
||||
@@ -270,6 +300,24 @@
|
||||
}
|
||||
|
||||
public static int getOrbValue(int i) {
|
||||
public static int getExperienceValue(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ if (i > 162670129) return i - 100000;
|
||||
+ if (i > 81335063) return 81335063;
|
||||
|
@ -19,17 +19,8 @@
|
||||
+
|
||||
public abstract class EntityInsentient extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.BYTE);
|
||||
@@ -101,7 +114,7 @@
|
||||
private final NonNullList<ItemStack> armorItems;
|
||||
public final float[] armorDropChances;
|
||||
private boolean canPickUpLoot;
|
||||
- public boolean persistenceRequired;
|
||||
+ private boolean persistenceRequired;
|
||||
private final Map<PathType, Float> pathfindingMalus;
|
||||
public MinecraftKey lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -113,6 +126,8 @@
|
||||
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
|
||||
@@ -116,6 +129,8 @@
|
||||
private BlockPosition restrictCenter;
|
||||
private float restrictRadius;
|
||||
|
||||
@ -37,13 +28,13 @@
|
||||
+
|
||||
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.handItems = NonNullList.a(2, ItemStack.EMPTY);
|
||||
@@ -136,7 +151,14 @@
|
||||
this.initPathfinder();
|
||||
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
@@ -139,7 +154,14 @@
|
||||
this.registerGoals();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - default persistance to type's persistance value
|
||||
+ this.persistenceRequired = !isTypeNotPersistent(0);
|
||||
+ this.persistenceRequired = !removeWhenFarAway(0);
|
||||
+ }
|
||||
+
|
||||
+ public void setPersistenceRequired(boolean persistenceRequired) {
|
||||
@ -51,21 +42,21 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected void initPathfinder() {}
|
||||
protected void registerGoals() {}
|
||||
|
||||
@@ -216,7 +238,38 @@
|
||||
@@ -219,7 +241,38 @@
|
||||
}
|
||||
|
||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
public void setTarget(@Nullable EntityLiving entityliving) {
|
||||
+ // CraftBukkit start - fire event
|
||||
+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
+ public boolean setGoalTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (getGoalTarget() == entityliving) return false;
|
||||
+ public boolean setTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (getTarget() == entityliving) return false;
|
||||
+ if (fireEvent) {
|
||||
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getGoalTarget() != null && entityliving == null) {
|
||||
+ reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
|
||||
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getTarget() != null && entityliving == null) {
|
||||
+ reason = getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
|
||||
+ }
|
||||
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
|
||||
+ level.getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
|
||||
@ -92,23 +83,23 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -443,16 +496,26 @@
|
||||
nbttagcompound.setBoolean("NoAI", this.isNoAI());
|
||||
@@ -446,16 +499,26 @@
|
||||
nbttagcompound.putBoolean("NoAI", this.isNoAi());
|
||||
}
|
||||
|
||||
+ nbttagcompound.setBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
+ nbttagcompound.putBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(NBTTagCompound nbttagcompound) {
|
||||
super.loadData(nbttagcompound);
|
||||
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
+
|
||||
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
|
||||
if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) {
|
||||
- this.setCanPickupLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
|
||||
if (nbttagcompound.contains("CanPickUpLoot", 1)) {
|
||||
- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
|
||||
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
|
||||
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
||||
+ this.setCanPickupLoot(data);
|
||||
+ this.setCanPickUpLoot(data);
|
||||
+ }
|
||||
}
|
||||
|
||||
@ -121,207 +112,202 @@
|
||||
NBTTagList nbttaglist;
|
||||
int i;
|
||||
|
||||
@@ -499,6 +562,11 @@
|
||||
@@ -502,6 +565,11 @@
|
||||
}
|
||||
|
||||
this.setNoAI(nbttagcompound.getBoolean("NoAI"));
|
||||
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.Aware")) {
|
||||
+ if (nbttagcompound.contains("Bukkit.Aware")) {
|
||||
+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -562,7 +630,7 @@
|
||||
protected void b(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
@@ -565,7 +633,7 @@
|
||||
protected void pickUpItem(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
- if (this.j(itemstack)) {
|
||||
+ if (this.j(itemstack, entityitem)) { // CraftBukkit - add item
|
||||
this.a(entityitem);
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
entityitem.die();
|
||||
@@ -571,15 +639,29 @@
|
||||
- if (this.equipItemIfPossible(itemstack)) {
|
||||
+ if (this.equipItemIfPossible(itemstack, entityitem)) { // CraftBukkit - add item
|
||||
this.onItemPickup(entityitem);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
entityitem.discard();
|
||||
@@ -574,15 +642,29 @@
|
||||
}
|
||||
|
||||
public boolean j(ItemStack itemstack) {
|
||||
public boolean equipItemIfPossible(ItemStack itemstack) {
|
||||
+ // CraftBukkit start - add item
|
||||
+ return this.j(itemstack, null);
|
||||
+ return this.equipItemIfPossible(itemstack, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean j(ItemStack itemstack, EntityItem entityitem) {
|
||||
+ public boolean equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) {
|
||||
+ // CraftBukkit end
|
||||
EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||
boolean flag = this.a(itemstack, itemstack1);
|
||||
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
|
||||
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
|
||||
|
||||
- if (flag && this.canPickup(itemstack)) {
|
||||
- if (flag && this.canHoldItem(itemstack)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean canPickup = flag && this.canPickup(itemstack);
|
||||
+ boolean canPickup = flag && this.canHoldItem(itemstack);
|
||||
+ if (entityitem != null) {
|
||||
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
|
||||
+ }
|
||||
+ if (canPickup) {
|
||||
+ // CraftBukkit end
|
||||
double d0 = (double) this.e(enumitemslot);
|
||||
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.b(itemstack1);
|
||||
this.spawnAtLocation(itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
this.b(enumitemslot, itemstack);
|
||||
@@ -692,18 +774,18 @@
|
||||
EntityHuman entityhuman = this.level.findNearbyPlayer(this, -1.0D);
|
||||
|
||||
if (entityhuman != null) {
|
||||
- double d0 = entityhuman.f(this);
|
||||
+ double d0 = entityhuman.f((Entity) this); // CraftBukkit - decompile error
|
||||
int i = this.getEntityType().f().f();
|
||||
this.setItemSlotAndDropWhenKilled(enumitemslot, itemstack);
|
||||
@@ -699,14 +781,14 @@
|
||||
int i = this.getType().getCategory().getDespawnDistance();
|
||||
int j = i * i;
|
||||
|
||||
- if (d0 > (double) j && this.isTypeNotPersistent(d0)) {
|
||||
- if (d0 > (double) j && this.removeWhenFarAway(d0)) {
|
||||
+ if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
this.discard();
|
||||
}
|
||||
|
||||
int k = this.getEntityType().f().g();
|
||||
int k = this.getType().getCategory().getNoDespawnDistance();
|
||||
int l = k * k;
|
||||
|
||||
- if (this.noActionTime > 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.removeWhenFarAway(d0)) {
|
||||
+ if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
this.discard();
|
||||
} else if (d0 < (double) l) {
|
||||
this.noActionTime = 0;
|
||||
@@ -718,6 +800,7 @@
|
||||
@@ -721,6 +803,7 @@
|
||||
@Override
|
||||
protected final void doTick() {
|
||||
protected final void serverAiStep() {
|
||||
++this.noActionTime;
|
||||
+ if (!this.aware) return; // CraftBukkit
|
||||
this.level.getMethodProfiler().enter("sensing");
|
||||
this.sensing.a();
|
||||
this.level.getMethodProfiler().exit();
|
||||
@@ -1101,6 +1184,12 @@
|
||||
this.level.getProfiler().push("sensing");
|
||||
this.sensing.tick();
|
||||
this.level.getProfiler().pop();
|
||||
@@ -1116,6 +1199,12 @@
|
||||
if (!this.isAlive()) {
|
||||
return EnumInteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.unleash(true, !entityhuman.getAbilities().instabuild);
|
||||
return EnumInteractionResult.a(this.level.isClientSide);
|
||||
this.dropLeash(true, !entityhuman.getAbilities().instabuild);
|
||||
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
|
||||
} else {
|
||||
@@ -1119,6 +1208,12 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
@@ -1134,6 +1223,12 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.a(Items.LEAD) && this.a(entityhuman)) {
|
||||
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
|
||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return EnumInteractionResult.a(this.level.isClientSide);
|
||||
@@ -1134,7 +1229,7 @@
|
||||
this.setLeashedTo(entityhuman, true);
|
||||
itemstack.shrink(1);
|
||||
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
|
||||
@@ -1149,7 +1244,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.level instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
- 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.level, this.getPositionVector(), itemstack); // CraftBukkit - decompile error
|
||||
- Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level, this.position(), itemstack);
|
||||
+ Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getType(), (WorldServer) this.level, this.position(), itemstack); // CraftBukkit - decompile error
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.a(entityhuman, entityinsentient);
|
||||
@@ -1184,12 +1279,19 @@
|
||||
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
|
||||
@@ -1199,12 +1294,19 @@
|
||||
return this.restrictRadius != -1.0F;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag) {
|
||||
+ return this.a(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag) {
|
||||
+ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
- T t0 = (EntityInsentient) entitytypes.a(this.level);
|
||||
+ T t0 = entitytypes.a(this.level); // CraftBukkit - decompile error
|
||||
- T t0 = (EntityInsentient) entitytypes.create(this.level);
|
||||
+ T t0 = entitytypes.create(this.level); // CraftBukkit - decompile error
|
||||
|
||||
t0.s(this);
|
||||
t0.copyPosition(this);
|
||||
t0.setBaby(this.isBaby());
|
||||
@@ -1221,7 +1323,12 @@
|
||||
@@ -1236,7 +1338,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.level.addEntity(t0);
|
||||
- this.level.addFreshEntity(t0);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ this.level.addEntity(t0, spawnReason);
|
||||
+ this.level.addFreshEntity(t0, spawnReason);
|
||||
+ // CraftBukkit end
|
||||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
@@ -1241,6 +1348,7 @@
|
||||
@@ -1256,6 +1363,7 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -1252,7 +1360,9 @@
|
||||
@@ -1267,7 +1375,9 @@
|
||||
this.leashHolder = null;
|
||||
this.leashInfoTag = null;
|
||||
if (!this.level.isClientSide && flag1) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a((IMaterial) Items.LEAD);
|
||||
this.spawnAtLocation((IMaterial) Items.LEAD);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
|
||||
@@ -1302,6 +1412,7 @@
|
||||
boolean flag1 = super.a(entity, flag);
|
||||
@@ -1317,6 +1427,7 @@
|
||||
boolean flag1 = super.startRiding(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -1397,7 +1508,14 @@
|
||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||
@@ -1412,7 +1523,14 @@
|
||||
int i = EnchantmentManager.getFireAspect(this);
|
||||
|
||||
if (i > 0) {
|
||||
- entity.setOnFire(i * 4);
|
||||
- entity.setSecondsOnFire(i * 4);
|
||||
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
||||
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (!combustEvent.isCancelled()) {
|
||||
+ entity.setOnFire(combustEvent.getDuration(), false);
|
||||
+ entity.setSecondsOnFire(combustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
||||
@@ -1465,9 +1583,10 @@
|
||||
boolean flag = entity.hurt(DamageSource.mobAttack(this), f);
|
||||
@@ -1480,9 +1598,10 @@
|
||||
@Override
|
||||
protected void cc() {
|
||||
super.cc();
|
||||
protected void removeAfterChangingDimensions() {
|
||||
super.removeAfterChangingDimensions();
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, false);
|
||||
this.by().forEach((itemstack) -> {
|
||||
this.dropLeash(true, false);
|
||||
this.getAllSlots().forEach((itemstack) -> {
|
||||
- itemstack.setCount(0);
|
||||
+ if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit
|
||||
});
|
||||
|
@ -1,64 +1,63 @@
|
||||
--- a/net/minecraft/world/entity/EntityLightning.java
|
||||
+++ b/net/minecraft/world/entity/EntityLightning.java
|
||||
@@ -32,6 +32,11 @@
|
||||
@@ -31,6 +31,10 @@
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityLightning extends Entity {
|
||||
|
||||
private static final int START_LIFE = 2;
|
||||
@@ -132,7 +137,7 @@
|
||||
@@ -131,7 +135,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.life >= 0) {
|
||||
+ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.isEffect
|
||||
+ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly
|
||||
if (!(this.level instanceof WorldServer)) {
|
||||
this.level.c(2);
|
||||
this.level.setSkyFlashTime(2);
|
||||
} else if (!this.visualOnly) {
|
||||
@@ -166,8 +171,12 @@
|
||||
IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition);
|
||||
@@ -165,8 +169,12 @@
|
||||
IBlockData iblockdata = BlockFireAbstract.getState(this.level, blockposition);
|
||||
|
||||
if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) {
|
||||
- this.level.setTypeUpdate(blockposition, iblockdata);
|
||||
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
|
||||
- this.level.setBlockAndUpdate(blockposition, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!isEffect"
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) {
|
||||
+ this.level.setTypeUpdate(blockposition, iblockdata);
|
||||
+ this.level.setBlockAndUpdate(blockposition, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
@@ -175,8 +184,12 @@
|
||||
@@ -174,8 +182,12 @@
|
||||
|
||||
iblockdata = BlockFireAbstract.a((IBlockAccess) this.level, blockposition1);
|
||||
if (this.level.getType(blockposition1).isAir() && iblockdata.canPlace(this.level, blockposition1)) {
|
||||
- this.level.setTypeUpdate(blockposition1, iblockdata);
|
||||
iblockdata = BlockFireAbstract.getState(this.level, blockposition1);
|
||||
if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) {
|
||||
- this.level.setBlockAndUpdate(blockposition1, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!isEffect"
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition1, this).isCancelled()) {
|
||||
+ this.level.setTypeUpdate(blockposition1, iblockdata);
|
||||
+ this.level.setBlockAndUpdate(blockposition1, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,8 +253,9 @@
|
||||
iblockdata = world.getType(blockposition1);
|
||||
@@ -239,8 +251,9 @@
|
||||
iblockdata = world.getBlockState(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
|
||||
WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> {
|
||||
- world.setBlockAndUpdate(blockposition1, iblockdata1);
|
||||
+ world.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error
|
||||
});
|
||||
world.triggerEffect(3002, blockposition1, -1);
|
||||
world.levelEvent(3002, blockposition1, -1);
|
||||
return Optional.of(blockposition1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityLiving.java
|
||||
+++ b/net/minecraft/world/entity/EntityLiving.java
|
||||
@@ -119,6 +119,30 @@
|
||||
@@ -116,6 +116,30 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final UUID SPEED_MODIFIER_SPRINTING_UUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
@@ -227,6 +251,21 @@
|
||||
@@ -224,6 +248,21 @@
|
||||
private float swimAmount;
|
||||
private float swimAmountO;
|
||||
protected BehaviorController<?> brain;
|
||||
@ -47,83 +47,83 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public float getBukkitYaw() {
|
||||
+ return getHeadRotation();
|
||||
+ return getYHeadRot();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -239,7 +278,9 @@
|
||||
@@ -236,7 +275,9 @@
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
this.lastClimbablePos = Optional.empty();
|
||||
this.attributes = new AttributeMapBase(AttributeDefaults.a(entitytypes));
|
||||
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ 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
|
||||
+ this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue());
|
||||
+ this.entityData.set(EntityLiving.DATA_HEALTH_ID, (float) this.getAttribute(GenericAttributes.MAX_HEALTH).getValue());
|
||||
this.blocksBuilding = true;
|
||||
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.ah();
|
||||
@@ -306,7 +347,13 @@
|
||||
this.reapplyPosition();
|
||||
@@ -303,7 +344,13 @@
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d1);
|
||||
|
||||
- ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
- ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
+ // CraftBukkit start - visiblity api
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((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);
|
||||
+ ((WorldServer) this.level).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
|
||||
+ } else {
|
||||
+ ((WorldServer) this.level).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
+ ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +613,7 @@
|
||||
@@ -561,7 +608,7 @@
|
||||
|
||||
protected void dB() {
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime == 20 && !this.level.isClientSide()) {
|
||||
+ if (this.deathTime >= 20 && !this.isRemoved() && !this.level.isClientSide()) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
|
||||
this.level.broadcastEntityEffect(this, (byte) 60);
|
||||
this.a(Entity.RemovalReason.KILLED);
|
||||
this.level.broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
||||
@@ -658,9 +705,15 @@
|
||||
@@ -653,9 +700,15 @@
|
||||
}
|
||||
|
||||
protected void playEquipSound(ItemStack itemstack) {
|
||||
protected void equipEventAndSound(ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ this.playEquipSound(itemstack, false);
|
||||
+ this.equipEventAndSound(itemstack, false);
|
||||
+ }
|
||||
+
|
||||
+ protected void playEquipSound(ItemStack itemstack, boolean silent) {
|
||||
SoundEffect soundeffect = itemstack.M();
|
||||
+ protected void equipEventAndSound(ItemStack itemstack, boolean silent) {
|
||||
SoundEffect soundeffect = itemstack.getEquipSound();
|
||||
|
||||
- if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator()) {
|
||||
+ if (!itemstack.isEmpty() && soundeffect != null && !this.isSpectator() && !silent) {
|
||||
+ // CraftBukkit end
|
||||
this.a(GameEvent.EQUIP);
|
||||
this.gameEvent(GameEvent.EQUIP);
|
||||
this.playSound(soundeffect, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -722,6 +775,17 @@
|
||||
@@ -717,6 +770,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
|
||||
+ if (nbttagcompound.contains("Bukkit.MaxHealth")) {
|
||||
+ NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
|
||||
+ if (nbtbase.getTypeId() == 5) {
|
||||
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagFloat) nbtbase).asDouble());
|
||||
+ } else if (nbtbase.getTypeId() == 3) {
|
||||
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagInt) nbtbase).asDouble());
|
||||
+ if (nbtbase.getId() == 5) {
|
||||
+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagFloat) nbtbase).getAsDouble());
|
||||
+ } else if (nbtbase.getId() == 3) {
|
||||
+ this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(((NBTTagInt) nbtbase).getAsDouble());
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (nbttagcompound.hasKeyOfType("Health", 99)) {
|
||||
if (nbttagcompound.contains("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -759,9 +823,32 @@
|
||||
@@ -754,9 +818,32 @@
|
||||
|
||||
}
|
||||
|
||||
@ -149,15 +149,15 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected void tickPotionEffects() {
|
||||
protected void tickEffects() {
|
||||
Iterator iterator = this.activeEffects.keySet().iterator();
|
||||
|
||||
+ isTickingEffects = true; // CraftBukkit
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
@@ -771,6 +858,12 @@
|
||||
this.a(mobeffect, true, (Entity) null);
|
||||
@@ -766,6 +853,12 @@
|
||||
this.onEffectUpdated(mobeffect, true, (Entity) null);
|
||||
})) {
|
||||
if (!this.level.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
@ -167,9 +167,9 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
this.a(mobeffect);
|
||||
this.onEffectRemoved(mobeffect);
|
||||
}
|
||||
@@ -781,6 +874,17 @@
|
||||
@@ -776,6 +869,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
@ -187,7 +187,7 @@
|
||||
|
||||
if (this.effectsDirty) {
|
||||
if (!this.level.isClientSide) {
|
||||
@@ -907,7 +1011,13 @@
|
||||
@@ -902,7 +1006,13 @@
|
||||
this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0);
|
||||
}
|
||||
|
||||
@ -201,23 +201,23 @@
|
||||
if (this.level.isClientSide) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -916,7 +1026,14 @@
|
||||
@@ -911,7 +1021,14 @@
|
||||
boolean flag;
|
||||
|
||||
for (flag = false; iterator.hasNext(); flag = true) {
|
||||
- this.a((MobEffect) iterator.next());
|
||||
- this.onEffectRemoved((MobEffect) iterator.next());
|
||||
+ // CraftBukkit start
|
||||
+ MobEffect effect = (MobEffect) iterator.next();
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ this.a(effect);
|
||||
+ this.onEffectRemoved(effect);
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
@@ -945,18 +1062,48 @@
|
||||
@@ -940,18 +1057,48 @@
|
||||
return this.addEffect(mobeffect, (Entity) null);
|
||||
}
|
||||
|
||||
@ -237,15 +237,15 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!this.c(mobeffect)) {
|
||||
if (!this.canBeAffected(mobeffect)) {
|
||||
return false;
|
||||
} else {
|
||||
MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getMobEffect());
|
||||
MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getEffect());
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ boolean override = false;
|
||||
+ if (mobeffect1 != null) {
|
||||
+ override = new MobEffect(mobeffect1).b(mobeffect);
|
||||
+ override = new MobEffect(mobeffect1).update(mobeffect);
|
||||
+ }
|
||||
+
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override);
|
||||
@ -255,25 +255,25 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (mobeffect1 == null) {
|
||||
this.activeEffects.put(mobeffect.getMobEffect(), mobeffect);
|
||||
this.a(mobeffect, entity);
|
||||
this.activeEffects.put(mobeffect.getEffect(), mobeffect);
|
||||
this.onEffectAdded(mobeffect, entity);
|
||||
return true;
|
||||
- } else if (mobeffect1.b(mobeffect)) {
|
||||
- } else if (mobeffect1.update(mobeffect)) {
|
||||
+ // CraftBukkit start
|
||||
+ } else if (event.isOverride()) {
|
||||
+ mobeffect1.b(mobeffect);
|
||||
this.a(mobeffect1, true, entity);
|
||||
+ mobeffect1.update(mobeffect);
|
||||
this.onEffectUpdated(mobeffect1, true, entity);
|
||||
+ // CraftBukkit end
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -993,13 +1140,39 @@
|
||||
return this.getMonsterType() == EnumMonsterType.UNDEAD;
|
||||
@@ -988,13 +1135,39 @@
|
||||
return this.getMobType() == EnumMonsterType.UNDEAD;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
public MobEffect c(@Nullable MobEffectList mobeffectlist) {
|
||||
public MobEffect removeEffectNoUpdate(@Nullable MobEffectList mobeffectlist) {
|
||||
+ return c(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
@ -298,7 +298,7 @@
|
||||
}
|
||||
|
||||
public boolean removeEffect(MobEffectList mobeffectlist) {
|
||||
- MobEffect mobeffect = this.c(mobeffectlist);
|
||||
- MobEffect mobeffect = this.removeEffectNoUpdate(mobeffectlist);
|
||||
+ return removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
@ -307,8 +307,8 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (mobeffect != null) {
|
||||
this.a(mobeffect);
|
||||
@@ -1036,20 +1209,55 @@
|
||||
this.onEffectRemoved(mobeffect);
|
||||
@@ -1031,20 +1204,55 @@
|
||||
|
||||
}
|
||||
|
||||
@ -362,33 +362,33 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.a(f, 0.0F, this.getMaxHealth()));
|
||||
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -1063,7 +1271,7 @@
|
||||
@@ -1058,7 +1266,7 @@
|
||||
return false;
|
||||
} else if (this.level.isClientSide) {
|
||||
return false;
|
||||
- } else if (this.dV()) {
|
||||
- } else if (this.isDeadOrDying()) {
|
||||
+ } 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;
|
||||
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -1074,10 +1282,11 @@
|
||||
@@ -1069,10 +1277,11 @@
|
||||
|
||||
this.noActionTime = 0;
|
||||
float f1 = f;
|
||||
- boolean flag = false;
|
||||
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
|
||||
+ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below
|
||||
float f2 = 0.0F;
|
||||
|
||||
- if (f > 0.0F && this.applyBlockingModifier(damagesource)) {
|
||||
- if (f > 0.0F && this.isDamageSourceBlocked(damagesource)) {
|
||||
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
|
||||
this.damageShield(f);
|
||||
+ if (false && f > 0.0F && this.isDamageSourceBlocked(damagesource)) {
|
||||
this.hurtCurrentlyUsedShield(f);
|
||||
f2 = f;
|
||||
f = 0.0F;
|
||||
@@ -1095,27 +1304,47 @@
|
||||
@@ -1090,27 +1299,47 @@
|
||||
this.animationSpeed = 1.5F;
|
||||
boolean flag1 = true;
|
||||
|
||||
@ -399,7 +399,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- this.damageEntity0(damagesource, f - this.lastHurt);
|
||||
- this.actuallyHurt(damagesource, f - this.lastHurt);
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.damageEntity0(damagesource, f - this.lastHurt)) {
|
||||
+ return false;
|
||||
@ -414,7 +414,7 @@
|
||||
+ }
|
||||
this.lastHurt = f;
|
||||
- this.invulnerableTime = 20;
|
||||
- this.damageEntity0(damagesource, f);
|
||||
- this.actuallyHurt(damagesource, f);
|
||||
+ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks
|
||||
+ // this.damageEntity0(damagesource, f);
|
||||
+ // CraftBukkit end
|
||||
@ -422,10 +422,10 @@
|
||||
this.hurtTime = this.hurtDuration;
|
||||
}
|
||||
|
||||
- if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
- if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
+ if (false && damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
this.damageHelmet(damagesource, f);
|
||||
+ if (false && damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
|
||||
this.hurtHelmet(damagesource, f);
|
||||
f *= 0.75F;
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@
|
||||
+ if (this instanceof EntityAnimal) {
|
||||
+ ((EntityAnimal) this).resetLove();
|
||||
+ if (this instanceof EntityTameableAnimal) {
|
||||
+ ((EntityTameableAnimal) this).setWillSit(false);
|
||||
+ ((EntityTameableAnimal) this).setOrderedToSit(false);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@ -441,7 +441,7 @@
|
||||
this.hurtDir = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -1238,19 +1467,29 @@
|
||||
@@ -1233,19 +1462,29 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
@ -449,12 +449,12 @@
|
||||
+ ItemStack itemstack1 = ItemStack.EMPTY;
|
||||
for (int j = 0; j < i; ++j) {
|
||||
EnumHand enumhand = aenumhand[j];
|
||||
- ItemStack itemstack1 = this.b(enumhand);
|
||||
+ itemstack1 = this.b(enumhand);
|
||||
- ItemStack itemstack1 = this.getItemInHand(enumhand);
|
||||
+ itemstack1 = this.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack1.a(Items.TOTEM_OF_UNDYING)) {
|
||||
itemstack = itemstack1.cloneItemStack();
|
||||
- itemstack1.subtract(1);
|
||||
if (itemstack1.is(Items.TOTEM_OF_UNDYING)) {
|
||||
itemstack = itemstack1.copy();
|
||||
- itemstack1.shrink(1);
|
||||
+ // itemstack1.subtract(1); // CraftBukkit
|
||||
break;
|
||||
}
|
||||
@ -468,14 +468,14 @@
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ if (!itemstack1.isEmpty()) {
|
||||
+ itemstack1.subtract(1);
|
||||
+ itemstack1.shrink(1);
|
||||
+ }
|
||||
+ if (itemstack != null && this instanceof EntityPlayer) {
|
||||
+ // CraftBukkit end
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1258,14 +1497,16 @@
|
||||
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1253,14 +1492,16 @@
|
||||
}
|
||||
|
||||
this.setHealth(1.0F);
|
||||
@ -489,7 +489,7 @@
|
||||
+ 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);
|
||||
+ // CraftBukkit end
|
||||
this.level.broadcastEntityEffect(this, (byte) 35);
|
||||
this.level.broadcastEntityEvent(this, (byte) 35);
|
||||
}
|
||||
|
||||
- return itemstack != null;
|
||||
@ -497,11 +497,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1370,14 +1611,22 @@
|
||||
IBlockData iblockdata = Blocks.WITHER_ROSE.getBlockData();
|
||||
@@ -1365,14 +1606,22 @@
|
||||
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
||||
|
||||
if (this.level.getType(blockposition).isAir() && iblockdata.canPlace(this.level, blockposition)) {
|
||||
- this.level.setTypeAndData(blockposition, iblockdata, 3);
|
||||
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
|
||||
- this.level.setBlock(blockposition, iblockdata, 3);
|
||||
- flag = true;
|
||||
+ // CraftBukkit start - call EntityBlockFormEvent for Wither Rose
|
||||
+ flag = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, 3, this);
|
||||
@ -510,7 +510,7 @@
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.WITHER_ROSE));
|
||||
EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
@ -519,36 +519,36 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level.addEntity(entityitem);
|
||||
this.level.addFreshEntity(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -1397,21 +1646,40 @@
|
||||
@@ -1392,21 +1641,40 @@
|
||||
|
||||
boolean flag = this.lastHurtByPlayerTime > 0;
|
||||
|
||||
+ this.dropInventory(); // CraftBukkit - from below
|
||||
if (this.dD() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
this.a(damagesource, flag);
|
||||
this.dropDeathLoot(damagesource, i, flag);
|
||||
+ this.dropEquipment(); // CraftBukkit - from below
|
||||
if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
this.dropFromLootTable(damagesource, flag);
|
||||
this.dropCustomDeathLoot(damagesource, i, flag);
|
||||
}
|
||||
+ // CraftBukkit start - Call death event
|
||||
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
|
||||
+ this.drops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
|
||||
- this.dropInventory();
|
||||
- this.dropEquipment();
|
||||
+ // this.dropInventory();// CraftBukkit - moved up
|
||||
this.dropExperience();
|
||||
}
|
||||
|
||||
protected void dropInventory() {}
|
||||
protected void dropEquipment() {}
|
||||
|
||||
- protected void dropExperience() {
|
||||
+ // CraftBukkit start
|
||||
+ public int getExpReward() {
|
||||
if (this.level instanceof WorldServer && (this.alwaysGivesExp() || this.lastHurtByPlayerTime > 0 && this.isDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
|
||||
- EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.getExpValue(this.lastHurtByPlayer));
|
||||
+ int i = this.getExpValue(this.lastHurtByPlayer);
|
||||
if (this.level instanceof WorldServer && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
|
||||
- EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.getExperienceReward(this.lastHurtByPlayer));
|
||||
+ int i = this.getExperienceReward(this.lastHurtByPlayer);
|
||||
+ return i;
|
||||
+ } else {
|
||||
+ return 0;
|
||||
@ -559,39 +559,39 @@
|
||||
+ protected void dropExperience() {
|
||||
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
||||
+ if (true) {
|
||||
+ EntityExperienceOrb.a((WorldServer) this.level, this.getPositionVector(), this.expToDrop);
|
||||
+ EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.expToDrop);
|
||||
+ this.expToDrop = 0;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
@@ -1527,9 +1795,14 @@
|
||||
int i = this.d(f, f1);
|
||||
@@ -1526,9 +1794,14 @@
|
||||
int i = this.calculateFallDamage(f, f1);
|
||||
|
||||
if (i > 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.damageEntity(damagesource, (float) i)) {
|
||||
+ if (!this.hurt(damagesource, (float) i)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.playSound(this.getSoundFall(i), 1.0F, 1.0F);
|
||||
this.playBlockStepSound();
|
||||
- this.damageEntity(damagesource, (float) i);
|
||||
this.playSound(this.getFallDamageSound(i), 1.0F, 1.0F);
|
||||
this.playBlockFallSound();
|
||||
- this.hurt(damagesource, (float) i);
|
||||
+ // this.damageEntity(damagesource, (float) i); // CraftBukkit - moved up
|
||||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1578,7 +1851,7 @@
|
||||
@@ -1577,7 +1850,7 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
- this.damageArmor(damagesource, f);
|
||||
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
|
||||
if (!damagesource.isBypassArmor()) {
|
||||
- this.hurtArmor(damagesource, f);
|
||||
+ // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1591,7 +1864,8 @@
|
||||
@@ -1590,7 +1863,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
@ -601,24 +601,24 @@
|
||||
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1622,29 +1896,172 @@
|
||||
@@ -1621,29 +1895,172 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected void damageEntity0(DamageSource damagesource, float f) {
|
||||
- if (!this.isInvulnerable(damagesource)) {
|
||||
- f = this.applyArmorModifier(damagesource, f);
|
||||
- f = this.applyMagicModifier(damagesource, f);
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- if (!this.isInvulnerableTo(damagesource)) {
|
||||
- f = this.getDamageAfterArmorAbsorb(damagesource, f);
|
||||
- f = this.getDamageAfterMagicAbsorb(damagesource, f);
|
||||
- float f1 = f;
|
||||
+ // CraftBukkit start
|
||||
+ protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final
|
||||
+ if (!this.isInvulnerable(damagesource)) {
|
||||
+ if (!this.isInvulnerableTo(damagesource)) {
|
||||
+ final boolean human = this instanceof EntityHuman;
|
||||
+ float originalDamage = f;
|
||||
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if (damagesource.g() && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ if (damagesource.isDamageHelmet() && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ return -(f - (f * 0.75F));
|
||||
+
|
||||
+ }
|
||||
@ -631,7 +631,7 @@
|
||||
+ Function<Double, Double> blocking = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -((EntityLiving.this.applyBlockingModifier(damagesource)) ? f : 0.0);
|
||||
+ return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0);
|
||||
+ }
|
||||
+ };
|
||||
+ float blockingModifier = blocking.apply((double) f).floatValue();
|
||||
@ -640,7 +640,7 @@
|
||||
+ Function<Double, Double> armor = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.applyArmorModifier(damagesource, f.floatValue()));
|
||||
+ return -(f - EntityLiving.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue()));
|
||||
+ }
|
||||
+ };
|
||||
+ float armorModifier = armor.apply((double) f).floatValue();
|
||||
@ -649,7 +649,7 @@
|
||||
+ Function<Double, Double> resistance = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
|
||||
+ if (!damagesource.isBypassMagic() && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
|
||||
+ int i = (EntityLiving.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
+ int j = 25 - i;
|
||||
+ float f1 = f.floatValue() * (float) j;
|
||||
@ -664,7 +664,7 @@
|
||||
+ Function<Double, Double> magic = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.applyMagicModifier(damagesource, f.floatValue()));
|
||||
+ return -(f - EntityLiving.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue()));
|
||||
+ }
|
||||
+ };
|
||||
+ float magicModifier = magic.apply((double) f).floatValue();
|
||||
@ -673,104 +673,104 @@
|
||||
+ Function<Double, Double> absorption = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionHearts(), 0.0F), 0.0F));
|
||||
+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionAmount(), 0.0F), 0.0F));
|
||||
+ }
|
||||
+ };
|
||||
+ float absorptionModifier = absorption.apply((double) f).floatValue();
|
||||
+
|
||||
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
|
||||
+ if (damagesource.getEntity() instanceof EntityHuman) {
|
||||
+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ ((EntityHuman) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
- float f2 = f1 - f;
|
||||
+
|
||||
+ f = (float) event.getFinalDamage();
|
||||
|
||||
+
|
||||
+ // Resistance
|
||||
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
|
||||
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
|
||||
+ if (f3 > 0.0F && f3 < 3.4028235E37F) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ ((EntityPlayer) this).awardStat(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ } else if (damagesource.getEntity() instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ ((EntityPlayer) damagesource.getEntity()).awardStat(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Apply damage to helmet
|
||||
+ if (damagesource.g() && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ this.damageHelmet(damagesource, f);
|
||||
+ if (damagesource.isDamageHelmet() && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ this.hurtHelmet(damagesource, f);
|
||||
+ }
|
||||
+
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
|
||||
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
|
||||
- float f2 = f1 - f;
|
||||
+ // Apply damage to armor
|
||||
+ if (!damagesource.ignoresArmor()) {
|
||||
+ if (!damagesource.isBypassArmor()) {
|
||||
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
|
||||
+ this.damageArmor(damagesource, armorDamage);
|
||||
+ this.hurtArmor(damagesource, armorDamage);
|
||||
+ }
|
||||
+
|
||||
+ // Apply blocking code // PAIL: steal from above
|
||||
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
|
||||
+ this.level.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound
|
||||
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
+ Entity entity = damagesource.k();
|
||||
+ this.level.broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound
|
||||
+ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
+ Entity entity = damagesource.getDirectEntity();
|
||||
+
|
||||
+ if (entity instanceof EntityLiving) {
|
||||
+ this.shieldBlock((EntityLiving) entity);
|
||||
+ this.blockUsingShield((EntityLiving) entity);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
|
||||
+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F));
|
||||
+ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F));
|
||||
+ float f2 = absorptionModifier;
|
||||
+
|
||||
|
||||
+ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) {
|
||||
+ ((EntityHuman) this).a(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
|
||||
+ ((EntityHuman) this).awardStat(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
|
||||
+ }
|
||||
if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) {
|
||||
((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
|
||||
((EntityPlayer) damagesource.getEntity()).awardStat(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
|
||||
}
|
||||
|
||||
- if (f != 0.0F) {
|
||||
+ if (f > 0 || !human) {
|
||||
+ if (human) {
|
||||
+ // PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
|
||||
+ ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
|
||||
+ ((EntityHuman) this).causeFoodExhaustion(damagesource.getFoodExhaustion(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
|
||||
+ if (f < 3.4028235E37F) {
|
||||
+ ((EntityHuman) this).a(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F));
|
||||
+ ((EntityHuman) this).awardStat(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
float f3 = this.getHealth();
|
||||
|
||||
this.setHealth(f3 - f);
|
||||
this.getCombatTracker().trackDamage(damagesource, f3, f);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
|
||||
this.getCombatTracker().recordDamage(damagesource, f3, f);
|
||||
- this.setAbsorptionAmount(this.getAbsorptionAmount() - f);
|
||||
+ // CraftBukkit start
|
||||
+ if (!human) {
|
||||
+ this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
|
||||
+ this.setAbsorptionAmount(this.getAbsorptionAmount() - f);
|
||||
+ }
|
||||
this.a(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
|
||||
this.gameEvent(GameEvent.ENTITY_DAMAGED, damagesource.getEntity());
|
||||
+
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ // Duplicate triggers if blocking
|
||||
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ CriterionTriggers.ENTITY_HURT_PLAYER.a((EntityPlayer) this, damagesource, f, originalDamage, true);
|
||||
+ CriterionTriggers.ENTITY_HURT_PLAYER.trigger((EntityPlayer) this, damagesource, f, originalDamage, true);
|
||||
+ f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
|
||||
+ if (f2 > 0.0F && f2 < 3.4028235E37F) {
|
||||
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
|
||||
+ ((EntityPlayer) this).awardStat(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (damagesource.getEntity() instanceof EntityPlayer) {
|
||||
+ CriterionTriggers.PLAYER_HURT_ENTITY.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true);
|
||||
+ CriterionTriggers.PLAYER_HURT_ENTITY.trigger((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true);
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
@ -784,7 +784,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1665,8 +2082,18 @@
|
||||
@@ -1664,8 +2081,18 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int i) {
|
||||
@ -802,66 +802,66 @@
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public final int eh() {
|
||||
public final int getStingerCount() {
|
||||
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
|
||||
@@ -1962,6 +2389,12 @@
|
||||
@@ -1961,6 +2388,12 @@
|
||||
|
||||
public abstract ItemStack getEquipment(EnumItemSlot enumitemslot);
|
||||
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
||||
+ this.setSlot(enumitemslot, itemstack);
|
||||
+ public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
||||
+ this.setItemSlot(enumitemslot, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||
|
||||
@@ -2205,6 +2638,7 @@
|
||||
@@ -2204,6 +2637,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.level.isClientSide) {
|
||||
+ if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, false);
|
||||
+ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setSharedFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -2735,6 +3169,7 @@
|
||||
@@ -2734,6 +3168,7 @@
|
||||
}
|
||||
|
||||
if (!this.level.isClientSide) {
|
||||
+ if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, flag);
|
||||
+ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
|
||||
this.setSharedFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -2902,14 +3337,21 @@
|
||||
@@ -2901,14 +3336,21 @@
|
||||
|
||||
@Override
|
||||
public boolean isInteractable() {
|
||||
public boolean isPickable() {
|
||||
- return !this.isRemoved();
|
||||
+ return !this.isRemoved() && this.collides; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
- return this.isAlive() && !this.isSpectator() && !this.isClimbing();
|
||||
+ return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit
|
||||
public boolean isPushable() {
|
||||
- return this.isAlive() && !this.isSpectator() && !this.onClimbable();
|
||||
+ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - collidable API
|
||||
+ @Override
|
||||
+ public boolean canCollideWithBukkit(Entity entity) {
|
||||
+ return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID());
|
||||
+ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
protected void velocityChanged() {
|
||||
this.hurtMarked = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
@@ -3107,7 +3549,25 @@
|
||||
protected void markHurt() {
|
||||
this.hurtMarked = this.random.nextDouble() >= this.getAttributeValue(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
@@ -3106,7 +3548,25 @@
|
||||
} else {
|
||||
if (!this.useItem.isEmpty() && this.isHandRaised()) {
|
||||
this.b(this.useItem, 16);
|
||||
- ItemStack itemstack = this.useItem.a(this.level, this);
|
||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||
this.triggerItemUseEffects(this.useItem, 16);
|
||||
- ItemStack itemstack = this.useItem.finishUsingItem(this.level, this);
|
||||
+ // CraftBukkit start - fire PlayerItemConsumeEvent
|
||||
+ ItemStack itemstack;
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
@ -876,42 +876,42 @@
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.a(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).a(level, this);
|
||||
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(level, this);
|
||||
+ } else {
|
||||
+ itemstack = this.useItem.a(this.level, this);
|
||||
+ itemstack = this.useItem.finishUsingItem(this.level, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (itemstack != this.useItem) {
|
||||
this.a(enumhand, itemstack);
|
||||
@@ -3179,6 +3639,12 @@
|
||||
this.setItemInHand(enumhand, itemstack);
|
||||
@@ -3178,6 +3638,12 @@
|
||||
}
|
||||
|
||||
public boolean a(double d0, double d1, double d2, boolean flag) {
|
||||
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
|
||||
+ // CraftBukkit start
|
||||
+ return safeTeleport(d0, d1, d2, flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN).orElse(false);
|
||||
+ return randomTeleport(d0, d1, d2, flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN).orElse(false);
|
||||
+ }
|
||||
+
|
||||
+ public Optional<Boolean> safeTeleport(double d0, double d1, double d2, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ public Optional<Boolean> randomTeleport(double d0, double d1, double d2, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ // CraftBukkit end
|
||||
double d3 = this.locX();
|
||||
double d4 = this.locY();
|
||||
double d5 = this.locZ();
|
||||
@@ -3203,16 +3669,41 @@
|
||||
double d3 = this.getX();
|
||||
double d4 = this.getY();
|
||||
double d5 = this.getZ();
|
||||
@@ -3202,16 +3668,41 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
- this.enderTeleportTo(d0, d6, d2);
|
||||
- this.teleportTo(d0, d6, d2);
|
||||
+ // CraftBukkit start - Teleport event
|
||||
+ // this.enderTeleportTo(d0, d6, d2);
|
||||
+ // this.teleportTo(d0, d6, d2);
|
||||
+
|
||||
+ // first set position, to check if the place to teleport is valid
|
||||
+ this.setPosition(d0, d6, d2);
|
||||
if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) {
|
||||
+ this.setPos(d0, d6, d2);
|
||||
if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) {
|
||||
flag1 = true;
|
||||
}
|
||||
+ // now revert and call event if the teleport place is valid
|
||||
+ this.setPosition(d3, d4, d5);
|
||||
+ this.setPos(d3, d4, d5);
|
||||
+
|
||||
+ if (flag1) {
|
||||
+ if (!(this instanceof EntityPlayer)) {
|
||||
@ -919,13 +919,13 @@
|
||||
+ this.level.getCraftServer().getPluginManager().callEvent(teleport);
|
||||
+ if (!teleport.isCancelled()) {
|
||||
+ Location to = teleport.getTo();
|
||||
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
|
||||
+ this.teleportTo(to.getX(), to.getY(), to.getZ());
|
||||
+ } else {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ } else {
|
||||
+ // player teleport event is called in the underlining code
|
||||
+ if (((EntityPlayer) this).connection.a(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) {
|
||||
+ if (((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), false, cause)) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ }
|
||||
@ -935,15 +935,15 @@
|
||||
}
|
||||
|
||||
if (!flag1) {
|
||||
- this.enderTeleportTo(d3, d4, d5);
|
||||
- this.teleportTo(d3, d4, d5);
|
||||
- return false;
|
||||
+ // this.enderTeleportTo(d3, d4, d5); // CraftBukkit - already set the location back
|
||||
+ return Optional.of(false); // CraftBukkit
|
||||
} else {
|
||||
if (flag) {
|
||||
world.broadcastEntityEffect(this, (byte) 46);
|
||||
@@ -3222,7 +3713,7 @@
|
||||
((EntityCreature) this).getNavigation().o();
|
||||
world.broadcastEntityEvent(this, (byte) 46);
|
||||
@@ -3221,7 +3712,7 @@
|
||||
((EntityCreature) this).getNavigation().stop();
|
||||
}
|
||||
|
||||
- return true;
|
||||
@ -951,25 +951,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3305,7 +3796,7 @@
|
||||
@@ -3304,7 +3795,7 @@
|
||||
}
|
||||
|
||||
public void entityWakeup() {
|
||||
- Optional optional = this.getBedPosition();
|
||||
+ Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error
|
||||
public void stopSleeping() {
|
||||
- Optional optional = this.getSleepingPos();
|
||||
+ Optional<BlockPosition> optional = this.getSleepingPos(); // CraftBukkit - decompile error
|
||||
World world = this.level;
|
||||
|
||||
java.util.Objects.requireNonNull(this.level);
|
||||
@@ -3337,7 +3828,7 @@
|
||||
@@ -3336,7 +3827,7 @@
|
||||
|
||||
@Nullable
|
||||
public EnumDirection eX() {
|
||||
- BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse((Object) null);
|
||||
+ BlockPosition blockposition = (BlockPosition) this.getBedPosition().orElse(null); // CraftBukkit - decompile error
|
||||
public EnumDirection getBedOrientation() {
|
||||
- BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse((Object) null);
|
||||
+ BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
return blockposition != null ? BlockBed.a((IBlockAccess) this.level, blockposition) : null;
|
||||
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
|
||||
}
|
||||
@@ -3386,7 +3877,7 @@
|
||||
@@ -3385,7 +3876,7 @@
|
||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||
|
||||
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
||||
@ -978,3 +978,24 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3488,8 +3979,10 @@
|
||||
this.setDeltaMovement((double) ((float) packetplayoutspawnentityliving.getXd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getYd() / 8000.0F), (double) ((float) packetplayoutspawnentityliving.getZd() / 8000.0F));
|
||||
}
|
||||
|
||||
- public static final class a extends Record {
|
||||
+ // CraftBukkit start
|
||||
+ public static final record a(SoundEffect small, SoundEffect big) {
|
||||
|
||||
+ /*
|
||||
private final SoundEffect small;
|
||||
private final SoundEffect big;
|
||||
|
||||
@@ -3509,6 +4002,8 @@
|
||||
public final boolean equals(Object object) {
|
||||
return this.equals<invokedynamic>(this, object);
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public SoundEffect small() {
|
||||
return this.small;
|
||||
|
@ -4,35 +4,37 @@
|
||||
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(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<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20));
|
||||
public static final EntityTypes<Axolotl> AXOLOTL = a("axolotl", EntityTypes.Builder.a(Axolotl::new, EnumCreatureType.UNDERGROUND_WATER_CREATURE).a(0.75F, 0.42F).trackingRange(10));
|
||||
@@ -282,7 +282,7 @@
|
||||
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
|
||||
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
|
||||
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10));
|
||||
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20));
|
||||
public static final EntityTypes<Axolotl> AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10));
|
||||
@@ -282,8 +282,8 @@
|
||||
private MinecraftKey lootTable;
|
||||
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 entitytypes_builder) { // CraftBukkit - decompile error
|
||||
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
|
||||
- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) {
|
||||
- return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, entitytypes_builder.build(s));
|
||||
+ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
|
||||
+ return (EntityTypes) IRegistry.register(IRegistry.ENTITY_TYPE, s, (EntityTypes<T>) entitytypes_builder.build(s)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static MinecraftKey getKey(EntityTypes<?> entitytypes) {
|
||||
@@ -314,10 +314,18 @@
|
||||
|
||||
@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 spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.spawnCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
||||
+ return this.spawn(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
T t0 = this.createCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
|
||||
+ public T spawn(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
|
||||
|
||||
if (t0 != null) {
|
||||
- worldserver.addAllEntities(t0);
|
||||
+ worldserver.addAllEntities(t0, spawnReason);
|
||||
- worldserver.addFreshEntityWithPassengers(t0);
|
||||
+ worldserver.addFreshEntityWithPassengers(t0, spawnReason);
|
||||
+ return !t0.isRemoved() ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@ -42,12 +44,12 @@
|
||||
t0.setCustomName(ichatbasecomponent);
|
||||
}
|
||||
|
||||
- a((World) worldserver, entityhuman, t0, nbttagcompound);
|
||||
+ try { a((World) worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
|
||||
- updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound);
|
||||
+ try { updateCustomEntityTag(worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
|
||||
return t0;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +520,7 @@
|
||||
@@ -510,7 +518,7 @@
|
||||
}
|
||||
|
||||
return entity;
|
||||
@ -55,22 +57,22 @@
|
||||
+ }).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static Stream<Entity> a(final List<? extends NBTBase> list, final World world) {
|
||||
@@ -569,7 +577,7 @@
|
||||
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) {
|
||||
@@ -567,7 +575,7 @@
|
||||
|
||||
@Nullable
|
||||
public T a(Entity entity) {
|
||||
- return entity.getEntityType() == this ? entity : null;
|
||||
+ return entity.getEntityType() == this ? (T) entity : null; // CraftBukkit - decompile error
|
||||
public T tryCast(Entity entity) {
|
||||
- return entity.getType() == this ? entity : null;
|
||||
+ return entity.getType() == this ? (T) entity : null; // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -596,7 +604,7 @@
|
||||
@@ -594,7 +602,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 entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error
|
||||
- public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) {
|
||||
+ public static <T extends Entity> EntityTypes.Builder<T> of(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error
|
||||
return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype);
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/IEntityAngerable.java
|
||||
+++ b/net/minecraft/world/entity/IEntityAngerable.java
|
||||
@@ -108,7 +108,7 @@
|
||||
default void pacify() {
|
||||
this.setLastDamager((EntityLiving) null);
|
||||
this.setAngerTarget((UUID) null);
|
||||
- this.setGoalTarget((EntityLiving) null);
|
||||
+ this.setGoalTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
|
||||
this.setAnger(0);
|
||||
default void stopBeingAngry() {
|
||||
this.setLastHurtByMob((EntityLiving) null);
|
||||
this.setPersistentAngerTarget((UUID) null);
|
||||
- this.setTarget((EntityLiving) null);
|
||||
+ this.setTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
|
||||
this.setRemainingPersistentAngerTime(0);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@
|
||||
|
||||
void setGoalTarget(@Nullable EntityLiving entityliving);
|
||||
void setTarget(@Nullable EntityLiving entityliving);
|
||||
|
||||
+ boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit
|
||||
+ boolean setTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit
|
||||
+
|
||||
boolean c(EntityLiving entityliving);
|
||||
boolean canAttack(EntityLiving entityliving);
|
||||
|
||||
@Nullable
|
||||
|
@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/IEntitySelector.java
|
||||
+++ b/net/minecraft/world/entity/IEntitySelector.java
|
||||
@@ -42,7 +42,7 @@
|
||||
@@ -43,7 +43,7 @@
|
||||
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule();
|
||||
|
||||
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> {
|
||||
- if (!entity1.isCollidable()) {
|
||||
- if (!entity1.isPushable()) {
|
||||
+ if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API
|
||||
return false;
|
||||
} else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).fi())) {
|
||||
} else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) {
|
||||
return false;
|
||||
|
@ -13,6 +13,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setBoolean("Saddle", this.hasSaddle());
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.putBoolean("Saddle", this.hasSaddle());
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
@Override
|
||||
public double a(double d0) {
|
||||
+ if (d0 != d0) return getDefault(); // CraftBukkit
|
||||
public double sanitizeValue(double d0) {
|
||||
+ if (d0 != d0) return getDefaultValue(); // CraftBukkit
|
||||
+
|
||||
d0 = MathHelper.a(d0, this.minValue, this.maxValue);
|
||||
d0 = MathHelper.clamp(d0, this.minValue, this.maxValue);
|
||||
return d0;
|
||||
}
|
||||
|
@ -5,11 +5,3 @@
|
||||
package net.minecraft.world.entity.ai.attributes;
|
||||
|
||||
import net.minecraft.core.IRegistry;
|
||||
@@ -21,6 +22,6 @@
|
||||
public GenericAttributes() {}
|
||||
|
||||
private static AttributeBase a(String s, AttributeBase attributebase) {
|
||||
- return (AttributeBase) IRegistry.a(IRegistry.ATTRIBUTE, s, (Object) attributebase);
|
||||
+ return (AttributeBase) IRegistry.a(IRegistry.ATTRIBUTE, s, attributebase); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren