Update to Minecraft 1.21.5

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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