geforkt von Mirrors/Paper
Update to Minecraft 1.21.2
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
2c4beb962b
Commit
d3a23f42c3
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/commands/CommandDispatcher.java
|
||||
+++ b/net/minecraft/commands/CommandDispatcher.java
|
||||
@@ -135,6 +135,14 @@
|
||||
@@ -139,6 +139,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();
|
||||
@@ -147,6 +155,7 @@
|
||||
@@ -151,6 +159,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);
|
||||
@@ -247,6 +256,11 @@
|
||||
@@ -252,6 +261,11 @@
|
||||
CommandPublish.register(this.dispatcher);
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer());
|
||||
}
|
||||
|
||||
@@ -257,18 +271,65 @@
|
||||
@@ -262,18 +276,65 @@
|
||||
return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions());
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
+ public void performCommand(ParseResults<CommandListenerWrapper> parseresults, String s, String label) { // CraftBukkit
|
||||
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource();
|
||||
|
||||
commandlistenerwrapper.getServer().getProfiler().push(() -> {
|
||||
Profiler.get().push(() -> {
|
||||
return "/" + s;
|
||||
});
|
||||
- ContextChain<CommandListenerWrapper> contextchain = finishParsing(parseresults, s, commandlistenerwrapper);
|
||||
@ -103,7 +103,7 @@
|
||||
|
||||
try {
|
||||
if (contextchain != null) {
|
||||
@@ -302,7 +363,7 @@
|
||||
@@ -307,7 +368,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -112,7 +112,7 @@
|
||||
try {
|
||||
validateParseResults(parseresults);
|
||||
return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> {
|
||||
@@ -313,7 +374,7 @@
|
||||
@@ -318,7 +379,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) -> {
|
||||
@ -121,7 +121,7 @@
|
||||
});
|
||||
|
||||
if (i > 10) {
|
||||
@@ -363,7 +424,7 @@
|
||||
@@ -368,7 +429,7 @@
|
||||
|
||||
executioncontext1.close();
|
||||
} finally {
|
||||
@ -130,7 +130,7 @@
|
||||
}
|
||||
} else {
|
||||
consumer.accept(executioncontext);
|
||||
@@ -372,11 +433,36 @@
|
||||
@@ -377,11 +438,36 @@
|
||||
}
|
||||
|
||||
public void sendCommands(EntityPlayer entityplayer) {
|
||||
@ -168,7 +168,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
|
||||
}
|
||||
|
||||
@@ -387,7 +473,7 @@
|
||||
@@ -392,7 +478,7 @@
|
||||
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
|
||||
|
||||
if (commandnode2.canUse(commandlistenerwrapper)) {
|
||||
@ -177,7 +177,7 @@
|
||||
|
||||
argumentbuilder.requires((icompletionprovider) -> {
|
||||
return true;
|
||||
@@ -410,7 +496,7 @@
|
||||
@@ -415,7 +501,7 @@
|
||||
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@
|
||||
|
||||
map.put(commandnode2, commandnode3);
|
||||
commandnode1.addChild(commandnode3);
|
||||
@@ -471,7 +557,7 @@
|
||||
@@ -481,7 +567,7 @@
|
||||
}
|
||||
|
||||
private <T> HolderLookup.b.a<T> createLookup(final HolderLookup.b<T> holderlookup_b) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/commands/CommandListenerWrapper.java
|
||||
+++ b/net/minecraft/commands/CommandListenerWrapper.java
|
||||
@@ -44,6 +44,8 @@
|
||||
@@ -46,6 +46,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"));
|
||||
@@ -63,6 +65,7 @@
|
||||
@@ -65,6 +67,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));
|
||||
@@ -169,9 +172,23 @@
|
||||
@@ -171,9 +174,23 @@
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(int i) {
|
||||
@ -41,16 +41,16 @@
|
||||
public Vec3D getPosition() {
|
||||
return this.worldPosition;
|
||||
}
|
||||
@@ -300,7 +317,7 @@
|
||||
@@ -302,7 +319,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) {
|
||||
+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
|
||||
- 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);
|
||||
}
|
||||
}
|
||||
@@ -393,4 +410,10 @@
|
||||
@@ -400,4 +417,10 @@
|
||||
public boolean isSilent() {
|
||||
return this.silent;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
+++ b/net/minecraft/core/cauldron/CauldronInteraction.java
|
||||
@@ -34,9 +34,15 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@@ -36,14 +36,20 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||
@ -11,27 +11,28 @@
|
||||
public interface CauldronInteraction {
|
||||
|
||||
Map<String, CauldronInteraction.a> INTERACTIONS = new Object2ObjectArrayMap();
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ /*
|
||||
Codec<CauldronInteraction.a> CODEC;
|
||||
CauldronInteraction.a EMPTY;
|
||||
CauldronInteraction.a WATER;
|
||||
@@ -48,6 +54,8 @@
|
||||
CauldronInteraction SHULKER_BOX;
|
||||
CauldronInteraction BANNER;
|
||||
CauldronInteraction DYED_ITEM;
|
||||
+ */
|
||||
- Codec<CauldronInteraction.a> CODEC;
|
||||
- CauldronInteraction.a EMPTY;
|
||||
- CauldronInteraction.a WATER;
|
||||
- CauldronInteraction.a LAVA;
|
||||
- CauldronInteraction.a POWDER_SNOW;
|
||||
+ // CraftBukkit start - decompile errors
|
||||
+ Codec<CauldronInteraction.a> CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get);
|
||||
+ CauldronInteraction.a EMPTY = newInteractionMap("empty");
|
||||
+ CauldronInteraction.a WATER = newInteractionMap("water");
|
||||
+ CauldronInteraction.a LAVA = newInteractionMap("lava");
|
||||
+ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
+ // CraftBukkit end
|
||||
|
||||
static CauldronInteraction.a newInteractionMap(String s) {
|
||||
Object2ObjectOpenHashMap<Item, CauldronInteraction> object2objectopenhashmap = new Object2ObjectOpenHashMap();
|
||||
@@ -72,12 +80,17 @@
|
||||
@@ -68,12 +74,17 @@
|
||||
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@ -44,13 +45,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -97,12 +110,17 @@
|
||||
@@ -93,12 +104,17 @@
|
||||
});
|
||||
map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@ -63,13 +64,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -117,10 +135,15 @@
|
||||
@@ -113,10 +129,15 @@
|
||||
|
||||
if (potioncontents != null && potioncontents.is(Potions.WATER)) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
||||
@ -80,13 +81,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -198,12 +221,17 @@
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
@@ -194,12 +215,17 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@ -99,13 +100,13 @@
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
}
|
||||
@@ -214,12 +242,17 @@
|
||||
@@ -210,12 +236,17 @@
|
||||
|
||||
static ItemInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
|
||||
static EnumInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
Item item = itemstack.getItem();
|
||||
@ -118,113 +119,74 @@
|
||||
world.playSound((EntityHuman) null, blockposition, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PLACE, blockposition);
|
||||
}
|
||||
@@ -227,76 +260,89 @@
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
@@ -242,11 +273,16 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1);
|
||||
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -260,12 +296,17 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.copyWithCount(1);
|
||||
|
||||
itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast());
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -279,9 +320,14 @@
|
||||
return EnumInteractionResult.TRY_WITH_EMPTY_HAND;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
itemstack.remove(DataComponents.DYED_COLOR);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_ARMOR);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -294,6 +340,8 @@
|
||||
return fluid.is(TagsFluid.WATER);
|
||||
}
|
||||
|
||||
- static {
|
||||
- Function function = CauldronInteraction.a::name;
|
||||
- Map map = CauldronInteraction.INTERACTIONS;
|
||||
-
|
||||
- Objects.requireNonNull(map);
|
||||
- CODEC = Codec.stringResolver(function, map::get);
|
||||
- EMPTY = newInteractionMap("empty");
|
||||
- WATER = newInteractionMap("water");
|
||||
- LAVA = newInteractionMap("lava");
|
||||
- POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
- FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ // CraftBukkit start - decompile errors
|
||||
+ // static {
|
||||
+ Codec<CauldronInteraction.a> CODEC = Codec.stringResolver(CauldronInteraction.a::name, CauldronInteraction.INTERACTIONS::get);
|
||||
+ CauldronInteraction.a EMPTY = newInteractionMap("empty");
|
||||
+ CauldronInteraction.a WATER = newInteractionMap("water");
|
||||
+ CauldronInteraction.a LAVA = newInteractionMap("lava");
|
||||
+ CauldronInteraction.a POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
+ CauldronInteraction FILL_WATER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY);
|
||||
};
|
||||
- FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction FILL_LAVA = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, Blocks.LAVA_CAULDRON.defaultBlockState(), SoundEffects.BUCKET_EMPTY_LAVA);
|
||||
};
|
||||
- FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction FILL_POWDER_SNOW = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
return emptyBucket(world, blockposition, entityhuman, enumhand, itemstack, (IBlockData) Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEffects.BUCKET_EMPTY_POWDER_SNOW);
|
||||
};
|
||||
- SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ // CraftBukkit end
|
||||
Block block = Block.byItem(itemstack.getItem());
|
||||
|
||||
if (!(block instanceof BlockShulkerBox)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Blocks.SHULKER_BOX, 1);
|
||||
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_SHULKER_BOX);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction BANNER = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error
|
||||
BannerPatternLayers bannerpatternlayers = (BannerPatternLayers) itemstack.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY);
|
||||
|
||||
if (bannerpatternlayers.layers().isEmpty()) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack1 = itemstack.copyWithCount(1);
|
||||
|
||||
itemstack1.set(DataComponents.BANNER_PATTERNS, bannerpatternlayers.removeLast());
|
||||
entityhuman.setItemInHand(enumhand, ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false));
|
||||
entityhuman.awardStat(StatisticList.CLEAN_BANNER);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
||||
+ CauldronInteraction DYED_ITEM = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> { // CraftBukkit - decompile error
|
||||
if (!itemstack.is(TagsItem.DYEABLE)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else if (!itemstack.has(DataComponents.DYED_COLOR)) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
} else {
|
||||
if (!world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ return ItemInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
itemstack.remove(DataComponents.DYED_COLOR);
|
||||
entityhuman.awardStat(StatisticList.CLEAN_ARMOR);
|
||||
- LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition);
|
||||
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return ItemInteractionResult.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
};
|
||||
- }
|
||||
+ // } // CraftBukkit - decompile error
|
||||
+ /*
|
||||
static {
|
||||
Function function = CauldronInteraction.a::name;
|
||||
Map map = CauldronInteraction.INTERACTIONS;
|
||||
@@ -305,6 +353,8 @@
|
||||
LAVA = newInteractionMap("lava");
|
||||
POWDER_SNOW = newInteractionMap("powder_snow");
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static record a(String name, Map<Item, CauldronInteraction> map) {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
|
||||
+++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
|
||||
@@ -13,6 +13,12 @@
|
||||
@@ -12,6 +12,12 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -12,13 +12,11 @@
|
||||
+
|
||||
public class DispenseBehaviorBoat extends DispenseBehaviorItem {
|
||||
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior;
|
||||
@@ -51,13 +57,41 @@
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
|
||||
@@ -43,14 +49,40 @@
|
||||
d4 = 0.0D;
|
||||
}
|
||||
|
||||
- Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3);
|
||||
+ // Object object = this.isChestBoat ? new ChestBoat(worldserver, d1, d2 + d4, d3) : new EntityBoat(worldserver, d1, d2 + d4, d3);
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
@ -44,17 +42,18 @@
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ EntityBoat object = this.isChestBoat ? new ChestBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ()) : new EntityBoat(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
|
||||
+ // CraftBukkit end
|
||||
AbstractBoat 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);
|
||||
abstractboat.setYRot(enumdirection.toYRot());
|
||||
- worldserver.addFreshEntity(abstractboat);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity(abstractboat)) itemstack.grow(1); // CraftBukkit
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
}
|
||||
|
||||
EntityTypes.createDefaultStackConfig(worldserver, itemstack, (EntityHuman) null).accept(object);
|
||||
((EntityBoat) object).setVariant(this.type);
|
||||
((EntityBoat) object).setYRot(enumdirection.toYRot());
|
||||
- worldserver.addFreshEntity((Entity) object);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity((Entity) object)) itemstack.grow(1); // CraftBukkit
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,12 @@
|
||||
public class DispenseBehaviorProjectile extends DispenseBehaviorItem {
|
||||
|
||||
private final ProjectileItem projectileItem;
|
||||
@@ -32,9 +39,38 @@
|
||||
@@ -31,8 +38,37 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
IPosition iposition = this.dispenseConfig.positionFunction().getDispensePosition(sourceblock, enumdirection);
|
||||
IProjectile iprojectile = this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection);
|
||||
|
||||
- this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
- IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
- itemstack.shrink(1);
|
||||
+ // CraftBukkit start
|
||||
+ // this.projectileItem.shoot(iprojectile, (double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
@ -46,12 +47,10 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.projectileItem.shoot(iprojectile, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ IProjectile iprojectile = IProjectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(worldserver, iposition, itemstack, enumdirection), worldserver, itemstack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty());
|
||||
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
|
||||
+ // CraftBukkit end
|
||||
worldserver.addFreshEntity(iprojectile);
|
||||
- itemstack.shrink(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - Handled during event processing
|
||||
+ // CraftBukkit end
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@
|
||||
if (!worldserver.isClientSide()) {
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
|
||||
- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition));
|
||||
+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, bukkitBlock, craftItem)); // CraftBukkit
|
||||
- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack));
|
||||
+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack, bukkitBlock, craftItem)); // CraftBukkit
|
||||
if (this.isSuccess()) {
|
||||
itemstack.hurtAndBreak(1, worldserver, (EntityPlayer) null, (item) -> {
|
||||
});
|
||||
@ -54,8 +54,8 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition) {
|
||||
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
|
||||
- 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();
|
||||
|
||||
@ -68,6 +68,6 @@
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ishearable.shear(SoundCategory.BLOCKS);
|
||||
ishearable.shear(worldserver, SoundCategory.BLOCKS, itemstack);
|
||||
worldserver.gameEvent((Entity) null, (Holder) GameEvent.SHEAR, blockposition);
|
||||
return true;
|
||||
|
@ -1,28 +1,29 @@
|
||||
--- a/net/minecraft/world/item/ItemArmor.java
|
||||
+++ b/net/minecraft/world/item/ItemArmor.java
|
||||
@@ -29,6 +29,12 @@
|
||||
--- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java
|
||||
@@ -10,6 +10,13 @@
|
||||
import net.minecraft.world.level.block.BlockDispenser;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.level.World;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class ItemArmor extends Item implements Equipable {
|
||||
public class EquipmentDispenseItemBehavior extends DispenseBehaviorItem {
|
||||
|
||||
public static final IDispenseBehavior DISPENSE_ITEM_BEHAVIOR = new DispenseBehaviorItem() {
|
||||
@@ -51,8 +57,34 @@
|
||||
EntityLiving entityliving = (EntityLiving) list.get(0);
|
||||
public static final EquipmentDispenseItemBehavior INSTANCE = new EquipmentDispenseItemBehavior();
|
||||
@@ -34,7 +41,34 @@
|
||||
EnumItemSlot enumitemslot = entityliving.getEquipmentSlotForItem(itemstack);
|
||||
ItemStack itemstack1 = itemstack.split(1);
|
||||
|
||||
- entityliving.setItemSlot(enumitemslot, itemstack1);
|
||||
+ // CraftBukkit start
|
||||
+ World world = sourceblock.level();
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
|
||||
- entityliving.setItemSlot(enumitemslot, itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
@ -38,7 +39,7 @@
|
||||
+ // 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 != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return true;
|
||||
+ }
|
||||
@ -47,5 +48,5 @@
|
||||
+ entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
if (entityliving instanceof EntityInsentient) {
|
||||
((EntityInsentient) entityliving).setDropChance(enumitemslot, 2.0F);
|
||||
((EntityInsentient) entityliving).setPersistenceRequired();
|
||||
EntityInsentient entityinsentient = (EntityInsentient) entityliving;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
|
||||
@@ -67,6 +67,22 @@
|
||||
@@ -63,6 +63,22 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
public interface IDispenseBehavior {
|
||||
|
||||
Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -94,14 +110,42 @@
|
||||
@@ -90,14 +106,42 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
EntityTypes<?> entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack);
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
+ }
|
||||
+
|
||||
try {
|
||||
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
|
||||
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) 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
|
||||
@ -68,7 +68,7 @@
|
||||
sourceblock.level().gameEvent((Entity) null, (Holder) GameEvent.ENTITY_PLACE, sourceblock.pos());
|
||||
return itemstack;
|
||||
}
|
||||
@@ -120,13 +164,41 @@
|
||||
@@ -116,13 +160,41 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
@ -103,7 +103,7 @@
|
||||
Consumer<EntityArmorStand> consumer = EntityTypes.appendDefaultStackConfig((entityarmorstand) -> {
|
||||
entityarmorstand.setYRot(enumdirection.toYRot());
|
||||
}, worldserver, itemstack, (EntityHuman) null);
|
||||
EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EnumMobSpawn.DISPENSER, false, false);
|
||||
EntityArmorStand entityarmorstand = (EntityArmorStand) EntityTypes.ARMOR_STAND.spawn(worldserver, consumer, blockposition, EntitySpawnReason.DISPENSER, false, false);
|
||||
|
||||
if (entityarmorstand != null) {
|
||||
- itemstack.shrink(1);
|
||||
@ -111,7 +111,7 @@
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
@@ -145,7 +217,34 @@
|
||||
@@ -141,7 +213,34 @@
|
||||
});
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
@ -137,7 +137,7 @@
|
||||
+ // 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 != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
@ -147,44 +147,7 @@
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
} else {
|
||||
@@ -172,7 +271,35 @@
|
||||
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
|
||||
} while (!entityhorseabstract.isBodyArmorItem(itemstack) || entityhorseabstract.isWearingBodyArmor() || !entityhorseabstract.isTamed());
|
||||
|
||||
- entityhorseabstract.setBodyArmorItem(itemstack.split(1));
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ WorldServer world = sourceblock.level();
|
||||
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity());
|
||||
+ if (!BlockDispenser.eventFired) {
|
||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ itemstack.grow(1);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+
|
||||
+ if (!event.getItem().equals(craftItem)) {
|
||||
+ itemstack.grow(1);
|
||||
+ // Chain to handler for new item
|
||||
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ entityhorseabstract.setBodyArmorItem(CraftItemStack.asNMSCopy(event.getItem()));
|
||||
+ // CraftBukkit end
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -215,9 +342,35 @@
|
||||
@@ -166,9 +265,35 @@
|
||||
}
|
||||
|
||||
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
|
||||
@ -210,7 +173,7 @@
|
||||
+ // 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 != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
@ -222,7 +185,7 @@
|
||||
this.setSuccess(true);
|
||||
return itemstack;
|
||||
}
|
||||
@@ -249,6 +402,38 @@
|
||||
@@ -202,6 +327,38 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
|
||||
@ -261,7 +224,7 @@
|
||||
if (dispensiblecontaineritem.emptyContents((EntityHuman) null, worldserver, blockposition, (MovingObjectPositionBlock) null)) {
|
||||
dispensiblecontaineritem.checkExtraContent((EntityHuman) null, worldserver, itemstack, blockposition);
|
||||
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(Items.BUCKET));
|
||||
@@ -276,7 +461,7 @@
|
||||
@@ -229,7 +386,7 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof IFluidSource ifluidsource) {
|
||||
@ -270,7 +233,7 @@
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
return super.execute(sourceblock, itemstack);
|
||||
@@ -284,6 +469,32 @@
|
||||
@@ -237,6 +394,32 @@
|
||||
worldserver.gameEvent((Entity) null, (Holder) GameEvent.FLUID_PICKUP, blockposition);
|
||||
Item item = itemstack1.getItem();
|
||||
|
||||
@ -303,7 +266,7 @@
|
||||
return this.consumeWithRemainder(sourceblock, itemstack, new ItemStack(item));
|
||||
}
|
||||
} else {
|
||||
@@ -296,16 +507,44 @@
|
||||
@@ -249,16 +432,44 @@
|
||||
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
|
||||
@ -351,7 +314,7 @@
|
||||
BlockTNT.explode(worldserver, blockposition);
|
||||
worldserver.removeBlock(blockposition, false);
|
||||
} else {
|
||||
@@ -330,12 +569,62 @@
|
||||
@@ -283,12 +494,62 @@
|
||||
this.setSuccess(true);
|
||||
WorldServer worldserver = sourceblock.level();
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
@ -414,7 +377,7 @@
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -345,12 +634,41 @@
|
||||
@@ -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));
|
||||
@ -458,7 +421,7 @@
|
||||
return itemstack;
|
||||
}
|
||||
});
|
||||
@@ -375,6 +693,30 @@
|
||||
@@ -314,6 +604,30 @@
|
||||
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
|
||||
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
|
||||
|
||||
@ -489,7 +452,7 @@
|
||||
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);
|
||||
@@ -400,6 +742,30 @@
|
||||
@@ -339,6 +653,30 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
|
||||
|
||||
@ -520,7 +483,7 @@
|
||||
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
|
||||
if (!worldserver.isClientSide) {
|
||||
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
|
||||
@@ -438,6 +804,30 @@
|
||||
@@ -377,6 +715,30 @@
|
||||
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
|
||||
IBlockData iblockdata = worldserver.getBlockState(blockposition);
|
||||
|
||||
@ -551,7 +514,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) {
|
||||
@@ -487,6 +877,31 @@
|
||||
@@ -426,6 +788,31 @@
|
||||
this.setSuccess(false);
|
||||
return itemstack;
|
||||
} else {
|
||||
@ -574,7 +537,7 @@
|
||||
+ // 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 != ItemArmor.DISPENSE_ITEM_BEHAVIOR) {
|
||||
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != EquipmentDispenseItemBehavior.INSTANCE) {
|
||||
+ idispensebehavior.dispense(sourceblock, eventStack);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
|
@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
+++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java
|
||||
@@ -16,6 +16,12 @@
|
||||
import net.minecraft.world.level.block.state.properties.BlockPropertyTrackPosition;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockDispenseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class MinecartDispenseItemBehavior extends DispenseBehaviorItem {
|
||||
|
||||
private final DispenseBehaviorItem defaultDispenseItemBehavior = new DispenseBehaviorItem();
|
||||
@@ -62,11 +68,40 @@
|
||||
}
|
||||
|
||||
Vec3D vec3d1 = new Vec3D(d0, d1 + d3, d2);
|
||||
- EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null);
|
||||
+ // CraftBukkit start
|
||||
+ // EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, vec3d1.x, vec3d1.y, vec3d1.z, this.entityType, EntitySpawnReason.DISPENSER, itemstack, (EntityHuman) null);
|
||||
+ ItemStack itemstack1 = itemstack.split(1);
|
||||
+ org.bukkit.block.Block block2 = CraftBlock.at(worldserver, sourceblock.pos());
|
||||
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+
|
||||
+ BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(vec3d1.x, vec3d1.y, vec3d1.z));
|
||||
+ 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);
|
||||
+ return itemstack;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
|
||||
+ EntityMinecartAbstract entityminecartabstract = EntityMinecartAbstract.createMinecart(worldserver, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.entityType, EntitySpawnReason.DISPENSER, itemstack1, (EntityHuman) null);
|
||||
|
||||
if (entityminecartabstract != null) {
|
||||
- worldserver.addFreshEntity(entityminecartabstract);
|
||||
- itemstack.shrink(1);
|
||||
+ if (!worldserver.addFreshEntity(entityminecartabstract)) itemstack.grow(1);
|
||||
+ // itemstack.shrink(1); // CraftBukkit - handled during event processing
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return itemstack;
|
@ -51,7 +51,7 @@
|
||||
BitSet bitset = this.readFixedBitSet(ae.length);
|
||||
EnumSet<E> enumset = EnumSet.noneOf(oclass);
|
||||
|
||||
@@ -482,7 +482,7 @@
|
||||
@@ -498,7 +498,7 @@
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
|
||||
@ -60,7 +60,7 @@
|
||||
}
|
||||
|
||||
public PacketDataSerializer writeEnum(Enum<?> oenum) {
|
||||
@@ -549,7 +549,7 @@
|
||||
@@ -565,7 +565,7 @@
|
||||
|
||||
try {
|
||||
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(bytebuf));
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/network/chat/IChatBaseComponent.java
|
||||
+++ b/net/minecraft/network/chat/IChatBaseComponent.java
|
||||
@@ -36,7 +36,22 @@
|
||||
@@ -38,7 +38,22 @@
|
||||
import net.minecraft.util.FormattedString;
|
||||
import net.minecraft.world.level.ChunkCoordIntPair;
|
||||
|
||||
|
@ -15,4 +15,4 @@
|
||||
+ this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancementholder.toBukkit())); // CraftBukkit
|
||||
advancementholder.value().rewards().grant(this.player);
|
||||
advancementholder.value().display().ifPresent((advancementdisplay) -> {
|
||||
if (advancementdisplay.shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
|
||||
if (advancementdisplay.shouldAnnounceChat() && this.player.serverLevel().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/AdvancementDataWorld.java
|
||||
+++ b/net/minecraft/server/AdvancementDataWorld.java
|
||||
@@ -27,11 +27,15 @@
|
||||
@@ -21,10 +21,14 @@
|
||||
import net.minecraft.util.profiling.GameProfilerFiller;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -8,18 +8,17 @@
|
||||
+import java.util.HashMap;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class AdvancementDataWorld extends ResourceDataJson {
|
||||
public class AdvancementDataWorld extends ResourceDataJson<Advancement> {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final Gson GSON = (new GsonBuilder()).create();
|
||||
- public Map<MinecraftKey, AdvancementHolder> advancements = Map.of();
|
||||
+ public Map<MinecraftKey, AdvancementHolder> advancements = new HashMap<>(); // CraftBukkit - SPIGOT-7734: mutable
|
||||
private AdvancementTree tree = new AdvancementTree();
|
||||
private final HolderLookup.a registries;
|
||||
|
||||
@@ -55,7 +59,7 @@
|
||||
}
|
||||
|
||||
@@ -40,7 +44,7 @@
|
||||
this.validate(minecraftkey, advancement);
|
||||
builder.put(minecraftkey, new AdvancementHolder(minecraftkey, advancement));
|
||||
});
|
||||
- this.advancements = builder.buildOrThrow();
|
||||
+ this.advancements = new HashMap<>(builder.buildOrThrow()); // CraftBukkit - SPIGOT-7734: mutable
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/CustomFunctionData.java
|
||||
+++ b/net/minecraft/server/CustomFunctionData.java
|
||||
@@ -36,7 +36,7 @@
|
||||
@@ -37,7 +37,7 @@
|
||||
}
|
||||
|
||||
public CommandDispatcher<CommandListenerWrapper> getDispatcher() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/DispenserRegistry.java
|
||||
+++ b/net/minecraft/server/DispenserRegistry.java
|
||||
@@ -28,6 +28,12 @@
|
||||
import net.minecraft.world.level.block.BlockFire;
|
||||
@@ -29,6 +29,12 @@
|
||||
import net.minecraft.world.level.block.state.BlockBase;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -13,7 +13,7 @@
|
||||
public class DispenserRegistry {
|
||||
|
||||
public static final PrintStream STDOUT = System.out;
|
||||
@@ -39,6 +45,23 @@
|
||||
@@ -40,6 +46,23 @@
|
||||
|
||||
public static void bootStrap() {
|
||||
if (!DispenserRegistry.isBootstrapped) {
|
||||
@ -37,7 +37,7 @@
|
||||
DispenserRegistry.isBootstrapped = true;
|
||||
Instant instant = Instant.now();
|
||||
|
||||
@@ -58,6 +81,69 @@
|
||||
@@ -59,6 +82,69 @@
|
||||
wrapStreams();
|
||||
DispenserRegistry.bootstrapDuration.set(Duration.between(instant, Instant.now()).toMillis());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@
|
||||
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
|
||||
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
|
||||
+ worldLoader.set(worldloader_a); // CraftBukkit
|
||||
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
|
||||
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM);
|
||||
|
||||
if (dynamic1 != null) {
|
||||
@@ -199,7 +248,7 @@
|
||||
@ -150,7 +150,7 @@
|
||||
@@ -207,7 +256,7 @@
|
||||
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
|
||||
|
||||
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
|
||||
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration());
|
||||
- worldoptions = optionset.has(optionspec3) ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions;
|
||||
+ worldoptions = optionset.has("bonusChest") ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions; // CraftBukkit
|
||||
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
@ -213,5 +213,5 @@
|
||||
- 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);
|
||||
IChatBaseComponent ichatbasecomponent = null;
|
||||
|
||||
try {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -173,13 +173,38 @@
|
||||
@@ -180,13 +180,38 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
+import org.bukkit.event.server.ServerLoadEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ChunkIOErrorReporter, ICommandListener, AutoCloseable {
|
||||
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ChunkIOErrorReporter, ICommandListener {
|
||||
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String VANILLA_BRAND = "vanilla";
|
||||
@ -40,9 +40,9 @@
|
||||
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;
|
||||
@@ -266,6 +291,19 @@
|
||||
private volatile boolean isSaving;
|
||||
private static final AtomicReference<RuntimeException> fatalException = new AtomicReference();
|
||||
@@ -277,6 +302,19 @@
|
||||
private final SuppressedExceptionCollector suppressedExceptions;
|
||||
private final DiscontinuousFrame tickFrame;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final WorldLoader.a worldLoader;
|
||||
@ -60,7 +60,7 @@
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
|
||||
AtomicReference<S> atomicreference = new AtomicReference();
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -279,14 +317,14 @@
|
||||
@@ -290,14 +328,14 @@
|
||||
thread.setPriority(8);
|
||||
}
|
||||
|
||||
@ -76,19 +76,19 @@
|
||||
+ public MinecraftServer(OptionSet options, WorldLoader.a worldLoader, Thread thread, Convertable.ConversionSession convertable_conversionsession, ResourcePackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, WorldLoadListenerFactory worldloadlistenerfactory) {
|
||||
super("Server");
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
@@ -309,7 +347,7 @@
|
||||
this.customBossEvents = new BossBattleCustomData();
|
||||
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
|
||||
@@ -321,7 +359,7 @@
|
||||
this.suppressedExceptions = new SuppressedExceptionCollector();
|
||||
this.registries = worldstem.registries();
|
||||
this.worldData = worldstem.worldData();
|
||||
- if (!this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) {
|
||||
+ if (false && !this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later
|
||||
- if (!this.registries.compositeAccess().lookupOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) {
|
||||
+ if (false && !this.registries.compositeAccess().lookupOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) { // CraftBukkit - initialised later
|
||||
throw new IllegalStateException("Missing Overworld dimension data");
|
||||
} else {
|
||||
this.proxy = proxy;
|
||||
@@ -334,6 +372,33 @@
|
||||
this.executor = SystemUtils.backgroundExecutor();
|
||||
this.potionBrewing = PotionBrewer.bootstrap(this.worldData.enabledFeatures());
|
||||
@@ -349,6 +387,33 @@
|
||||
this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures());
|
||||
this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick");
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ this.options = options;
|
||||
@ -120,7 +120,7 @@
|
||||
}
|
||||
|
||||
private void readScoreboard(WorldPersistentData worldpersistentdata) {
|
||||
@@ -342,7 +407,7 @@
|
||||
@@ -357,7 +422,7 @@
|
||||
|
||||
protected abstract boolean initServer() throws IOException;
|
||||
|
||||
@ -129,7 +129,7 @@
|
||||
if (!JvmProfiler.INSTANCE.isRunning()) {
|
||||
;
|
||||
}
|
||||
@@ -350,12 +415,8 @@
|
||||
@@ -365,12 +430,8 @@
|
||||
boolean flag = false;
|
||||
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
|
||||
|
||||
@ -143,19 +143,19 @@
|
||||
if (profiledduration != null) {
|
||||
profiledduration.finish();
|
||||
}
|
||||
@@ -372,23 +433,217 @@
|
||||
@@ -387,23 +448,217 @@
|
||||
|
||||
protected void forceDifficulty() {}
|
||||
|
||||
- protected void createLevels(WorldLoadListener worldloadlistener) {
|
||||
- IWorldDataServer iworlddataserver = this.worldData.overworldData();
|
||||
- boolean flag = this.worldData.isDebugWorld();
|
||||
- IRegistry<WorldDimension> iregistry = this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM);
|
||||
- IRegistry<WorldDimension> iregistry = this.registries.compositeAccess().lookupOrThrow(Registries.LEVEL_STEM);
|
||||
- WorldOptions worldoptions = this.worldData.worldGenOptions();
|
||||
- long i = worldoptions.seed();
|
||||
- long j = BiomeManager.obfuscateSeed(i);
|
||||
- List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
- WorldDimension worlddimension = (WorldDimension) iregistry.get(WorldDimension.OVERWORLD);
|
||||
- WorldDimension worlddimension = (WorldDimension) iregistry.getValue(WorldDimension.OVERWORLD);
|
||||
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null);
|
||||
+ // CraftBukkit start
|
||||
+ private void loadWorld0(String s) {
|
||||
@ -164,7 +164,7 @@
|
||||
- this.levels.put(World.OVERWORLD, worldserver);
|
||||
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
|
||||
+ IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.compositeAccess();
|
||||
+ IRegistry<WorldDimension> dimensions = iregistrycustom_dimension.registryOrThrow(Registries.LEVEL_STEM);
|
||||
+ IRegistry<WorldDimension> dimensions = iregistrycustom_dimension.lookupOrThrow(Registries.LEVEL_STEM);
|
||||
+ for (WorldDimension worldDimension : dimensions) {
|
||||
+ ResourceKey<WorldDimension> dimensionKey = dimensions.getResourceKey(worldDimension).get();
|
||||
|
||||
@ -276,7 +276,7 @@
|
||||
+
|
||||
+ WorldDataServer worlddata;
|
||||
+ WorldLoader.a worldloader_a = this.worldLoader;
|
||||
+ IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
|
||||
+ IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().lookupOrThrow(Registries.LEVEL_STEM);
|
||||
+ if (dynamic != null) {
|
||||
+ LevelDataAndDimensions leveldataanddimensions = Convertable.getLevelDataAndDimensions(dynamic, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen());
|
||||
+
|
||||
@ -293,7 +293,7 @@
|
||||
+ } else {
|
||||
+ DedicatedServerProperties dedicatedserverproperties = ((DedicatedServer) this).getProperties();
|
||||
+
|
||||
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
|
||||
+ worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(worldloader_a.dataConfiguration().enabledFeatures()), worldloader_a.dataConfiguration());
|
||||
+ worldoptions = options.has("bonusChest") ? dedicatedserverproperties.worldOptions.withBonusChest(true) : dedicatedserverproperties.worldOptions;
|
||||
+ worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
|
||||
+ }
|
||||
@ -316,7 +316,7 @@
|
||||
+ long i = worldoptions.seed();
|
||||
+ long j = BiomeManager.obfuscateSeed(i);
|
||||
+ List<MobSpawner> list = ImmutableList.of(new MobSpawnerPhantom(), new MobSpawnerPatrol(), new MobSpawnerCat(), new VillageSiege(), new MobSpawnerTrader(iworlddataserver));
|
||||
+ WorldDimension worlddimension = (WorldDimension) dimensions.get(dimensionKey);
|
||||
+ WorldDimension worlddimension = (WorldDimension) dimensions.getValue(dimensionKey);
|
||||
+
|
||||
+ org.bukkit.generator.WorldInfo worldInfo = new org.bukkit.craftbukkit.generator.CraftWorldInfo(iworlddataserver, worldSession, org.bukkit.World.Environment.getEnvironment(dimension), worlddimension.type().value());
|
||||
+ if (biomeProvider == null && gen != null) {
|
||||
@ -375,7 +375,7 @@
|
||||
|
||||
if (!iworlddataserver.isInitialized()) {
|
||||
try {
|
||||
@@ -412,30 +667,8 @@
|
||||
@@ -427,30 +682,8 @@
|
||||
iworlddataserver.setInitialized(true);
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@
|
||||
|
||||
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
|
||||
if (flag1) {
|
||||
@@ -443,6 +676,21 @@
|
||||
@@ -458,6 +691,21 @@
|
||||
} else {
|
||||
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
|
||||
@ -428,8 +428,8 @@
|
||||
+ // CraftBukkit end
|
||||
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
|
||||
|
||||
if (i < worldserver.getMinBuildHeight()) {
|
||||
@@ -501,8 +749,11 @@
|
||||
if (i < worldserver.getMinY()) {
|
||||
@@ -516,8 +764,11 @@
|
||||
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@
|
||||
|
||||
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
|
||||
BlockPosition blockposition = worldserver.getSharedSpawnPos();
|
||||
@@ -512,20 +763,22 @@
|
||||
@@ -527,20 +778,22 @@
|
||||
|
||||
this.nextTickTimeNanos = SystemUtils.getNanos();
|
||||
worldserver.setDefaultSpawnPos(blockposition, worldserver.getSharedSpawnAngle());
|
||||
@ -474,7 +474,7 @@
|
||||
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks");
|
||||
|
||||
if (forcedchunk != null) {
|
||||
@@ -540,10 +793,17 @@
|
||||
@@ -555,10 +808,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,14 +488,14 @@
|
||||
- this.updateMobSpawningFlags();
|
||||
+ // CraftBukkit start
|
||||
+ // this.updateMobSpawningFlags();
|
||||
+ worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
|
||||
+ worldserver.setSpawnSettings(this.isSpawningMonsters());
|
||||
+
|
||||
+ this.forceTicks = false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public EnumGamemode getDefaultGameType() {
|
||||
@@ -573,12 +833,16 @@
|
||||
@@ -588,12 +848,16 @@
|
||||
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@
|
||||
if (flag1) {
|
||||
Iterator iterator1 = this.getAllLevels().iterator();
|
||||
|
||||
@@ -613,18 +877,40 @@
|
||||
@@ -628,18 +892,40 @@
|
||||
this.stopServer();
|
||||
}
|
||||
|
||||
@ -553,7 +553,7 @@
|
||||
}
|
||||
|
||||
MinecraftServer.LOGGER.info("Saving worlds");
|
||||
@@ -712,7 +998,7 @@
|
||||
@@ -727,7 +1013,7 @@
|
||||
}
|
||||
|
||||
this.nextTickTimeNanos = SystemUtils.getNanos();
|
||||
@ -562,7 +562,7 @@
|
||||
this.status = this.buildServerStatus();
|
||||
|
||||
while (this.running) {
|
||||
@@ -729,6 +1015,7 @@
|
||||
@@ -744,6 +1030,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,15 +570,15 @@
|
||||
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;
|
||||
@@ -742,6 +1029,7 @@
|
||||
@@ -757,6 +1044,7 @@
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
+ MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
this.nextTickTimeNanos += i;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
@@ -789,6 +1077,12 @@
|
||||
|
||||
try {
|
||||
@@ -830,6 +1118,12 @@
|
||||
this.services.profileCache().clearExecutor();
|
||||
}
|
||||
|
||||
@ -591,7 +591,7 @@
|
||||
this.onServerExit();
|
||||
}
|
||||
|
||||
@@ -848,7 +1142,14 @@
|
||||
@@ -889,7 +1183,14 @@
|
||||
}
|
||||
|
||||
private boolean haveTime() {
|
||||
@ -607,7 +607,7 @@
|
||||
}
|
||||
|
||||
public static boolean throwIfFatalException() {
|
||||
@@ -862,7 +1163,7 @@
|
||||
@@ -903,7 +1204,7 @@
|
||||
}
|
||||
|
||||
public static void setFatalException(RuntimeException runtimeexception) {
|
||||
@ -616,36 +616,49 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -928,7 +1229,7 @@
|
||||
@@ -977,7 +1278,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected void doRunTask(TickTask ticktask) {
|
||||
+ public void doRunTask(TickTask ticktask) { // CraftBukkit - decompile error
|
||||
this.getProfiler().incrementCounter("runTask");
|
||||
Profiler.get().incrementCounter("runTask");
|
||||
super.doRunTask(ticktask);
|
||||
}
|
||||
@@ -987,8 +1288,10 @@
|
||||
@@ -1041,6 +1342,7 @@
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||
this.tickConnection();
|
||||
return;
|
||||
}
|
||||
@@ -1055,7 +1357,7 @@
|
||||
}
|
||||
|
||||
--this.ticksUntilAutosave;
|
||||
- if (this.ticksUntilAutosave <= 0) {
|
||||
- this.ticksUntilAutosave = this.computeNextAutosaveInterval();
|
||||
+ // CraftBukkit start
|
||||
+ if (this.autosavePeriod > 0 && this.ticksUntilAutosave <= 0) {
|
||||
+ this.ticksUntilAutosave = this.autosavePeriod;
|
||||
+ // CraftBukkit end
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
this.profiler.push("save");
|
||||
this.saveEverything(true, false, false);
|
||||
@@ -1076,11 +1379,26 @@
|
||||
+ if (this.autosavePeriod > 0 && this.ticksUntilAutosave <= 0) { // CraftBukkit
|
||||
this.autoSave();
|
||||
}
|
||||
|
||||
@@ -1074,7 +1376,7 @@
|
||||
}
|
||||
|
||||
private void autoSave() {
|
||||
- this.ticksUntilAutosave = this.computeNextAutosaveInterval();
|
||||
+ this.ticksUntilAutosave = this.autosavePeriod; // CraftBukkit
|
||||
MinecraftServer.LOGGER.debug("Autosave started");
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -1154,11 +1456,26 @@
|
||||
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
|
||||
entityplayer.connection.suspendFlushing();
|
||||
});
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit
|
||||
this.profiler.push("commandFunctions");
|
||||
+ this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||
gameprofilerfiller.push("commandFunctions");
|
||||
this.getFunctions().tick();
|
||||
this.profiler.popPush("levels");
|
||||
gameprofilerfiller.popPush("levels");
|
||||
Iterator iterator = this.getAllLevels().iterator();
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -658,28 +671,28 @@
|
||||
+ if (this.tickCount % 20 == 0) {
|
||||
+ for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
|
||||
+ EntityPlayer entityplayer = (EntityPlayer) this.getPlayerList().players.get(i);
|
||||
+ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
|
||||
+ entityplayer.connection.send(new PacketPlayOutUpdateTime(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
WorldServer worldserver = (WorldServer) iterator.next();
|
||||
|
||||
@@ -1089,11 +1407,13 @@
|
||||
@@ -1167,11 +1484,13 @@
|
||||
|
||||
return s + " " + String.valueOf(worldserver.dimension().location());
|
||||
});
|
||||
+ /* Drop global time updates
|
||||
if (this.tickCount % 20 == 0) {
|
||||
this.profiler.push("timeSync");
|
||||
gameprofilerfiller.push("timeSync");
|
||||
this.synchronizeTime(worldserver);
|
||||
this.profiler.pop();
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.profiler.push("tick");
|
||||
gameprofilerfiller.push("tick");
|
||||
|
||||
@@ -1183,6 +1503,22 @@
|
||||
@@ -1267,6 +1586,22 @@
|
||||
return (WorldServer) this.levels.get(resourcekey);
|
||||
}
|
||||
|
||||
@ -702,7 +715,7 @@
|
||||
public Set<ResourceKey<World>> levelKeys() {
|
||||
return this.levels.keySet();
|
||||
}
|
||||
@@ -1212,7 +1548,7 @@
|
||||
@@ -1296,7 +1631,7 @@
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -711,7 +724,7 @@
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport systemreport) {
|
||||
@@ -1554,11 +1890,11 @@
|
||||
@@ -1634,11 +1969,11 @@
|
||||
|
||||
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
|
||||
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
||||
@ -724,8 +737,8 @@
|
||||
+ 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);
|
||||
|
||||
@@ -1573,6 +1909,7 @@
|
||||
List<IRegistry.a<?>> list = TagDataPack.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
|
||||
@@ -1654,6 +1989,7 @@
|
||||
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
|
||||
this.resources.close();
|
||||
this.resources = minecraftserver_reloadableresources;
|
||||
@ -733,16 +746,16 @@
|
||||
this.packRepository.setSelected(collection);
|
||||
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
|
||||
|
||||
@@ -1873,7 +2210,7 @@
|
||||
@@ -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
|
||||
- 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)));
|
||||
@@ -1979,7 +2316,7 @@
|
||||
@@ -2058,7 +2394,7 @@
|
||||
try {
|
||||
label51:
|
||||
{
|
||||
@ -751,7 +764,7 @@
|
||||
|
||||
try {
|
||||
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
|
||||
@@ -2029,6 +2366,22 @@
|
||||
@@ -2108,6 +2444,22 @@
|
||||
|
||||
}
|
||||
|
||||
@ -771,10 +784,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private void startMetricsRecordingTick() {
|
||||
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) -> {
|
||||
@@ -2159,6 +2512,11 @@
|
||||
@@ -2235,6 +2587,11 @@
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/commands/CommandGamerule.java
|
||||
+++ b/net/minecraft/server/commands/CommandGamerule.java
|
||||
@@ -31,7 +31,7 @@
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
static <T extends GameRules.GameRuleValue<T>> int setRule(CommandContext<CommandListenerWrapper> commandcontext, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) commandcontext.getSource();
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
t0.setFromArgument(commandcontext, "value");
|
||||
commandlistenerwrapper.sendSuccess(() -> {
|
||||
@@ -41,7 +41,7 @@
|
||||
@@ -44,7 +44,7 @@
|
||||
}
|
||||
|
||||
static <T extends GameRules.GameRuleValue<T>> int queryRule(CommandListenerWrapper commandlistenerwrapper, GameRules.GameRuleKey<T> gamerules_gamerulekey) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/commands/CommandLoot.java
|
||||
+++ b/net/minecraft/server/commands/CommandLoot.java
|
||||
@@ -91,7 +91,7 @@
|
||||
@@ -95,7 +95,7 @@
|
||||
}
|
||||
|
||||
private static <T extends ArgumentBuilder<CommandListenerWrapper, T>> T addTargets(T t0, CommandLoot.c commandloot_c) {
|
||||
@ -9,7 +9,7 @@
|
||||
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), list.size(), list, commandloot_a);
|
||||
}).then(commandloot_c.construct(net.minecraft.commands.CommandDispatcher.argument("count", IntegerArgumentType.integer(0)), (commandcontext, list, commandloot_a) -> {
|
||||
return entityReplace(ArgumentEntity.getEntities(commandcontext, "entities"), ArgumentInventorySlot.getSlot(commandcontext, "slot"), IntegerArgumentType.getInteger(commandcontext, "count"), list, commandloot_a);
|
||||
@@ -246,6 +246,7 @@
|
||||
@@ -250,6 +250,7 @@
|
||||
private static int dropInWorld(CommandListenerWrapper commandlistenerwrapper, Vec3D vec3d, List<ItemStack> list, CommandLoot.a commandloot_a) throws CommandSyntaxException {
|
||||
WorldServer worldserver = commandlistenerwrapper.getLevel();
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/server/commands/CommandSchedule.java
|
||||
+++ b/net/minecraft/server/commands/CommandSchedule.java
|
||||
@@ -55,7 +55,7 @@
|
||||
@@ -58,7 +58,7 @@
|
||||
} else {
|
||||
long j = commandlistenerwrapper.getLevel().getGameTime() + (long) i;
|
||||
MinecraftKey minecraftkey = (MinecraftKey) pair.getFirst();
|
||||
- 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;
|
||||
|
||||
((Either) pair.getSecond()).ifLeft((net_minecraft_commands_functions_commandfunction) -> {
|
||||
String s = minecraftkey.toString();
|
||||
|
@ -13,8 +13,8 @@
|
||||
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());
|
||||
+ 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(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.COMMAND); // CraftBukkit - handle teleport reason
|
||||
- entity.teleportTo(worldserver, (double) MathHelper.floor(commandspreadplayers_a.x) + 0.5D, (double) commandspreadplayers_a.getSpawnY(worldserver, i), (double) MathHelper.floor(commandspreadplayers_a.z) + 0.5D, Set.of(), entity.getYRot(), entity.getXRot(), true);
|
||||
+ 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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/server/commands/CommandSummon.java
|
||||
+++ b/net/minecraft/server/commands/CommandSummon.java
|
||||
@@ -67,7 +67,7 @@
|
||||
((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EnumMobSpawn.COMMAND, (GroupDataEntity) null);
|
||||
((EntityInsentient) entity).finalizeSpawn(commandlistenerwrapper.getLevel(), commandlistenerwrapper.getLevel().getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.COMMAND, (GroupDataEntity) null);
|
||||
}
|
||||
|
||||
- if (!worldserver.tryAddFreshEntityWithPassengers(entity)) {
|
||||
|
@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/server/commands/CommandTeleport.java
|
||||
+++ b/net/minecraft/server/commands/CommandTeleport.java
|
||||
@@ -33,6 +33,13 @@
|
||||
@@ -31,6 +31,14 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
@ -14,35 +15,35 @@
|
||||
public class CommandTeleport {
|
||||
|
||||
private static final SimpleCommandExceptionType INVALID_POSITION = new SimpleCommandExceptionType(IChatBaseComponent.translatable("commands.teleport.invalidPosition"));
|
||||
@@ -155,7 +162,30 @@
|
||||
float f2 = MathHelper.wrapDegrees(f);
|
||||
float f3 = MathHelper.wrapDegrees(f1);
|
||||
@@ -167,7 +175,30 @@
|
||||
float f4 = MathHelper.wrapDegrees(f2);
|
||||
float f5 = MathHelper.wrapDegrees(f3);
|
||||
|
||||
- if (entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3)) {
|
||||
- if (entity.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true)) {
|
||||
+ // CraftBukkit start - Teleport event
|
||||
+ boolean result;
|
||||
+ if (entity instanceof EntityPlayer player) {
|
||||
+ result = player.teleportTo(worldserver, d0, d1, d2, set, f2, f3, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
+ result = player.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
+ } else {
|
||||
+ Location to = new Location(worldserver.getWorld(), d0, d1, d2, f2, f3);
|
||||
+ Location to = new Location(worldserver.getWorld(), d3, d4, d5, f4, f5);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity.getBukkitEntity(), entity.getBukkitEntity().getLocation(), to);
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ d0 = to.getX();
|
||||
+ d1 = to.getY();
|
||||
+ d2 = to.getZ();
|
||||
+ f2 = to.getYaw();
|
||||
+ f3 = to.getPitch();
|
||||
+ d3 = to.getX();
|
||||
+ d4 = to.getY();
|
||||
+ d5 = to.getZ();
|
||||
+ f4 = to.getYaw();
|
||||
+ f5 = to.getPitch();
|
||||
+ worldserver = ((CraftWorld) to.getWorld()).getHandle();
|
||||
+
|
||||
+ result = entity.teleportTo(worldserver, d0, d1, d2, set, f2, f3);
|
||||
+ result = entity.teleportTo(worldserver, d3, d4, d5, set, f4, f5, true);
|
||||
+ }
|
||||
+
|
||||
+ if (result) {
|
||||
+ // CraftBukkit end
|
||||
if (commandteleport_a != null) {
|
||||
commandteleport_a.perform(commandlistenerwrapper, entity);
|
||||
if (lookat != null) {
|
||||
lookat.perform(commandlistenerwrapper, entity);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -60,6 +60,18 @@
|
||||
@@ -59,6 +59,18 @@
|
||||
import net.minecraft.world.level.storage.Convertable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
public class DedicatedServer extends MinecraftServer implements IMinecraftServer {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -68,7 +80,7 @@
|
||||
@@ -67,7 +79,7 @@
|
||||
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
|
||||
@Nullable
|
||||
private RemoteStatusListener queryThreadGs4;
|
||||
@ -28,7 +28,7 @@
|
||||
@Nullable
|
||||
private RemoteControlListener rconThread;
|
||||
public DedicatedServerSettings settings;
|
||||
@@ -82,10 +94,12 @@
|
||||
@@ -81,10 +93,12 @@
|
||||
private DebugSampleSubscriptionTracker debugSampleSubscriptionTracker;
|
||||
public ServerLinks serverLinks;
|
||||
|
||||
@ -41,10 +41,10 @@
|
||||
this.settings = dedicatedserversettings;
|
||||
- this.rconConsoleSource = new RemoteControlCommandListener(this);
|
||||
+ // this.rconConsoleSource = new RemoteControlCommandListener(this); // CraftBukkit - remove field
|
||||
this.textFilterClient = TextFilter.createFromConfig(dedicatedserversettings.getProperties().textFilteringConfig);
|
||||
this.serverTextFilter = ServerTextFilter.createFromConfig(dedicatedserversettings.getProperties());
|
||||
this.serverLinks = createServerLinks(dedicatedserversettings);
|
||||
}
|
||||
@@ -94,13 +108,44 @@
|
||||
@@ -93,13 +107,44 @@
|
||||
public boolean initServer() throws IOException {
|
||||
Thread thread = new Thread("Server console handler") {
|
||||
public void run() {
|
||||
@ -92,7 +92,7 @@
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
DedicatedServer.LOGGER.error("Exception handling console input", ioexception);
|
||||
@@ -109,6 +154,29 @@
|
||||
@@ -108,6 +153,29 @@
|
||||
}
|
||||
};
|
||||
|
||||
@ -122,7 +122,7 @@
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER));
|
||||
thread.start();
|
||||
@@ -133,7 +201,7 @@
|
||||
@@ -132,7 +200,7 @@
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
super.setPlayerIdleTimeout((Integer) dedicatedserverproperties.playerIdleTimeout.get());
|
||||
this.setEnforceWhitelist(dedicatedserverproperties.enforceWhitelist);
|
||||
@ -131,7 +131,7 @@
|
||||
DedicatedServer.LOGGER.info("Default game type: {}", dedicatedserverproperties.gamemode);
|
||||
InetAddress inetaddress = null;
|
||||
|
||||
@@ -157,6 +225,12 @@
|
||||
@@ -156,6 +224,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@
|
||||
if (!this.usesAuthentication()) {
|
||||
DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
|
||||
DedicatedServer.LOGGER.warn("The server will make no attempt to authenticate usernames. Beware.");
|
||||
@@ -171,7 +245,7 @@
|
||||
@@ -170,7 +244,7 @@
|
||||
if (!NameReferencingFileConverter.serverReadyAfterUserconversion(this)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -153,7 +153,7 @@
|
||||
this.debugSampleSubscriptionTracker = new DebugSampleSubscriptionTracker(this.getPlayerList());
|
||||
this.tickTimeLogger = new RemoteSampleLogger(TpsDebugDimensions.values().length, this.debugSampleSubscriptionTracker, RemoteDebugSampleType.TICK_TIME);
|
||||
long i = SystemUtils.getNanos();
|
||||
@@ -179,13 +253,13 @@
|
||||
@@ -178,13 +252,13 @@
|
||||
TileEntitySkull.setup(this.services, this);
|
||||
UserCache.setUsesAuthentication(this.usesAuthentication());
|
||||
DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getLevelIdName());
|
||||
@ -169,7 +169,7 @@
|
||||
}
|
||||
|
||||
if (dedicatedserverproperties.enableQuery) {
|
||||
@@ -311,6 +385,7 @@
|
||||
@@ -293,6 +367,7 @@
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,7 +407,15 @@
|
||||
@@ -314,7 +389,15 @@
|
||||
while (!this.consoleInput.isEmpty()) {
|
||||
ServerCommand servercommand = (ServerCommand) this.consoleInput.remove(0);
|
||||
|
||||
@ -194,7 +194,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -559,16 +642,52 @@
|
||||
@@ -541,16 +624,52 @@
|
||||
|
||||
@Override
|
||||
public String getPluginNames() {
|
||||
@ -251,7 +251,7 @@
|
||||
}
|
||||
|
||||
public void storeUsingWhiteList(boolean flag) {
|
||||
@@ -673,4 +792,15 @@
|
||||
@@ -660,4 +779,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
this.difficulty = (EnumDifficulty) this.get("difficulty", dispatchNumberOrString(EnumDifficulty::byId, EnumDifficulty::byName), EnumDifficulty::getKey, EnumDifficulty.EASY);
|
||||
this.gamemode = (EnumGamemode) this.get("gamemode", dispatchNumberOrString(EnumGamemode::byId, EnumGamemode::byName), EnumGamemode::getName, EnumGamemode.SURVIVAL);
|
||||
this.levelName = this.get("level-name", "world");
|
||||
@@ -165,13 +172,15 @@
|
||||
@@ -167,13 +174,15 @@
|
||||
this.initialDataPackConfiguration = getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -252,10 +261,10 @@
|
||||
@@ -254,10 +263,10 @@
|
||||
}).orElseThrow(() -> {
|
||||
return new IllegalStateException("Invalid datapack contents: can't find default preset");
|
||||
});
|
||||
@ -62,11 +62,11 @@
|
||||
+ return Optional.ofNullable(DedicatedServerProperties.WorldDimensionData.LEGACY_PRESET_NAMES.get(this.levelType)); // CraftBukkit - decompile error
|
||||
});
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
@@ -267,7 +276,7 @@
|
||||
Objects.requireNonNull(holderlookup);
|
||||
@@ -269,7 +278,7 @@
|
||||
|
||||
if (holder.is(WorldPresets.FLAT)) {
|
||||
RegistryOps<JsonElement> registryops = iregistrycustom.createSerializationContext(JsonOps.INSTANCE);
|
||||
RegistryOps<JsonElement> registryops = holderlookup_a.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;
|
||||
|
@ -1,18 +1,22 @@
|
||||
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
||||
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
||||
@@ -121,6 +121,11 @@
|
||||
}
|
||||
@@ -117,6 +117,15 @@
|
||||
|
||||
PlayerChunk playerchunk;
|
||||
|
||||
if (!this.chunksToUpdateFutures.isEmpty()) {
|
||||
+ // CraftBukkit start - SPIGOT-7780: Call chunk unload events before updateHighestAllowedStatus
|
||||
+ this.chunksToUpdateFutures.forEach((playerchunk) -> {
|
||||
+ while (iterator.hasNext()) {
|
||||
+ playerchunk = (PlayerChunk) iterator.next();
|
||||
+ playerchunk.callEventIfUnloading(playerchunkmap);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ iterator = this.chunksToUpdateFutures.iterator();
|
||||
+ // CraftBukkit end
|
||||
this.chunksToUpdateFutures.forEach((playerchunk) -> {
|
||||
+
|
||||
while (iterator.hasNext()) {
|
||||
playerchunk = (PlayerChunk) iterator.next();
|
||||
playerchunk.updateHighestAllowedStatus(playerchunkmap);
|
||||
});
|
||||
@@ -163,7 +168,7 @@
|
||||
@@ -165,7 +174,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +25,7 @@
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
|
||||
int j = getTicketLevelAt(arraysetsorted);
|
||||
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
|
||||
@@ -173,13 +178,15 @@
|
||||
@@ -175,13 +184,15 @@
|
||||
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
|
||||
}
|
||||
|
||||
@ -39,7 +43,7 @@
|
||||
}
|
||||
|
||||
if (arraysetsorted.isEmpty()) {
|
||||
@@ -187,6 +194,7 @@
|
||||
@@ -189,6 +200,7 @@
|
||||
}
|
||||
|
||||
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
|
||||
@ -47,7 +51,7 @@
|
||||
}
|
||||
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -200,19 +208,33 @@
|
||||
@@ -202,19 +214,33 @@
|
||||
}
|
||||
|
||||
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@ -83,7 +87,7 @@
|
||||
}
|
||||
|
||||
private ArraySetSorted<Ticket<?>> getTickets(long i) {
|
||||
@@ -251,6 +273,7 @@
|
||||
@@ -253,6 +279,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
|
||||
long i = chunkcoordintpair.toLong();
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
||||
@ -91,7 +95,7 @@
|
||||
|
||||
objectset.remove(entityplayer);
|
||||
if (objectset.isEmpty()) {
|
||||
@@ -380,6 +403,26 @@
|
||||
@@ -391,6 +418,26 @@
|
||||
return !this.tickets.isEmpty();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ChunkProviderServer.java
|
||||
+++ b/net/minecraft/server/level/ChunkProviderServer.java
|
||||
@@ -82,6 +82,16 @@
|
||||
@@ -96,6 +96,16 @@
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
@Override
|
||||
public LightEngineThreaded getLightEngine() {
|
||||
return this.lightEngine;
|
||||
@@ -125,7 +135,7 @@
|
||||
@@ -139,7 +149,7 @@
|
||||
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
|
||||
IChunkAccess ichunkaccess = this.lastChunk[l];
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
return ichunkaccess;
|
||||
}
|
||||
}
|
||||
@@ -138,7 +148,7 @@
|
||||
@@ -152,7 +162,7 @@
|
||||
Objects.requireNonNull(completablefuture);
|
||||
chunkproviderserver_b.managedBlock(completablefuture::isDone);
|
||||
ChunkResult<IChunkAccess> chunkresult = (ChunkResult) completablefuture.join();
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
if (ichunkaccess1 == null && flag) {
|
||||
throw (IllegalStateException) SystemUtils.pauseInIde(new IllegalStateException("Chunk not there when requested: " + chunkresult.getError()));
|
||||
@@ -218,7 +228,15 @@
|
||||
@@ -232,7 +242,15 @@
|
||||
int l = ChunkLevel.byStatus(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
|
||||
|
||||
@ -51,8 +51,8 @@
|
||||
+ // CraftBukkit end
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.chunkAbsent(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
@@ -237,7 +255,7 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
@@ -251,7 +269,7 @@
|
||||
}
|
||||
|
||||
private boolean chunkAbsent(@Nullable PlayerChunk playerchunk, int i) {
|
||||
@ -61,7 +61,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,11 +310,31 @@
|
||||
@@ -310,12 +328,34 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
@ -75,40 +75,63 @@
|
||||
+ this.save(true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.dataStorage.close();
|
||||
this.lightEngine.close();
|
||||
this.chunkMap.close();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - modelled on below
|
||||
+ public void purgeUnload() {
|
||||
+ this.level.getProfiler().push("purge");
|
||||
+ GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
+
|
||||
+ gameprofilerfiller.push("purge");
|
||||
+ this.distanceManager.purgeStaleTickets();
|
||||
+ this.runDistanceManagerUpdates();
|
||||
+ this.level.getProfiler().popPush("unload");
|
||||
+ gameprofilerfiller.popPush("unload");
|
||||
+ this.chunkMap.tick(() -> true);
|
||||
+ this.level.getProfiler().pop();
|
||||
+ gameprofilerfiller.pop();
|
||||
+ this.clearCache();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void tick(BooleanSupplier booleansupplier, boolean flag) {
|
||||
this.level.getProfiler().push("purge");
|
||||
@@ -346,11 +384,11 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
@@ -402,14 +442,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
|
||||
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;
|
||||
|
||||
SystemUtils.shuffle(list, this.level.random);
|
||||
int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
- 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
|
||||
Iterator iterator1 = list.iterator();
|
||||
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
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -560,13 +598,19 @@
|
||||
- list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
|
||||
+ list1 = SpawnerCreature.getFilteredSpawningCategories(spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1, this.level); // CraftBukkit
|
||||
} else {
|
||||
list1 = List.of();
|
||||
}
|
||||
@@ -542,8 +582,14 @@
|
||||
|
||||
@Override
|
||||
public void setSpawnSettings(boolean flag) {
|
||||
+ // CraftBukkit start
|
||||
+ this.setSpawnSettings(flag, this.spawnFriendlies);
|
||||
+ }
|
||||
+
|
||||
+ public void setSpawnSettings(boolean flag, boolean spawnFriendlies) {
|
||||
this.spawnEnemies = flag;
|
||||
- this.spawnFriendlies = this.spawnFriendlies;
|
||||
+ this.spawnFriendlies = spawnFriendlies;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public String getChunkDebugData(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -619,13 +665,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/level/EntityPlayer.java
|
||||
@@ -166,6 +166,40 @@
|
||||
@@ -184,6 +184,41 @@
|
||||
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.WeatherType;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.CraftWorldBorder;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
@ -28,20 +29,20 @@
|
||||
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
+import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
+import org.bukkit.event.player.PlayerLocaleChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerPortalEvent;
|
||||
+import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
+import org.bukkit.event.player.PlayerSpawnChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
+import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
+import org.bukkit.inventory.MainHand;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPlayer extends EntityHuman {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -204,7 +238,7 @@
|
||||
@@ -227,7 +262,7 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance;
|
||||
@ -50,7 +51,7 @@
|
||||
@Nullable
|
||||
private Vec3D startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -235,6 +269,21 @@
|
||||
@@ -261,6 +296,22 @@
|
||||
private int containerCounter;
|
||||
public boolean wonGame;
|
||||
|
||||
@ -58,6 +59,7 @@
|
||||
+ public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
||||
+ public String displayName;
|
||||
+ public IChatBaseComponent listName;
|
||||
+ public int listOrder = 0;
|
||||
+ public org.bukkit.Location compassTarget;
|
||||
+ public int newExp = 0;
|
||||
+ public int newLevel = 0;
|
||||
@ -72,7 +74,21 @@
|
||||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
|
||||
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
|
||||
this.chatVisibility = EnumChatVisibility.FULL;
|
||||
@@ -302,14 +351,67 @@
|
||||
@@ -342,6 +393,13 @@
|
||||
public void sendSystemMessage(IChatBaseComponent ichatbasecomponent) {
|
||||
EntityPlayer.this.sendSystemMessage(ichatbasecomponent);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return getBukkitEntity();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
this.textFilter = minecraftserver.createTextFilterForPlayer(this);
|
||||
this.gameMode = minecraftserver.createGameModeForPlayer(this);
|
||||
@@ -354,14 +412,67 @@
|
||||
this.moveTo(this.adjustSpawnLocation(worldserver, worldserver.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
|
||||
this.updateOptions(clientinformation);
|
||||
this.object = null;
|
||||
@ -81,8 +97,8 @@
|
||||
+ this.displayName = this.getScoreboardName();
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // 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() {
|
||||
@ -128,9 +144,9 @@
|
||||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) {
|
||||
AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO);
|
||||
@ -141,7 +157,30 @@
|
||||
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -366,7 +468,7 @@
|
||||
@@ -397,14 +508,20 @@
|
||||
|
||||
Objects.requireNonNull(blockposition);
|
||||
crashreportsystemdetails.setDetail("Origin", blockposition::toString);
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ int finalI = i;
|
||||
crashreportsystemdetails.setDetail("Radius", () -> {
|
||||
- return Integer.toString(i);
|
||||
+ return Integer.toString(finalI);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
crashreportsystemdetails.setDetail("Candidate", () -> {
|
||||
return "[" + l2 + "," + i3 + "]";
|
||||
});
|
||||
+ // CraftBukkit start - decompile error
|
||||
+ int finalL1 = l1;
|
||||
crashreportsystemdetails.setDetail("Progress", () -> {
|
||||
- return "" + l1 + " out of " + i1;
|
||||
+ return "" + finalL1 + " out of " + i1;
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
@@ -442,7 +559,7 @@
|
||||
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("warden_spawn_tracker")));
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@ -150,9 +189,9 @@
|
||||
this.wardenSpawnTracker = wardenspawntracker;
|
||||
});
|
||||
}
|
||||
@@ -381,17 +483,26 @@
|
||||
if (nbttagcompound.contains("recipeBook", 10)) {
|
||||
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
|
||||
@@ -459,17 +576,26 @@
|
||||
return this.server.getRecipeManager().byKey(resourcekey).isPresent();
|
||||
});
|
||||
}
|
||||
+ this.getBukkitEntity().readExtraData(nbttagcompound); // CraftBukkit
|
||||
|
||||
@ -178,7 +217,7 @@
|
||||
Logger logger1 = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger1);
|
||||
@@ -406,7 +517,7 @@
|
||||
@@ -484,7 +610,7 @@
|
||||
dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
|
||||
logger = EntityPlayer.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
@ -187,7 +226,7 @@
|
||||
this.raidOmenPosition = blockposition;
|
||||
});
|
||||
}
|
||||
@@ -416,7 +527,7 @@
|
||||
@@ -494,7 +620,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@ -196,7 +235,15 @@
|
||||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
Objects.requireNonNull(logger);
|
||||
@@ -437,7 +548,20 @@
|
||||
@@ -528,6 +654,7 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
||||
|
||||
nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
if (this.raidOmenPosition != null) {
|
||||
@@ -546,7 +673,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
@ -215,18 +262,43 @@
|
||||
+
|
||||
+ if (persistVehicle && entity1 != null && entity != this && entity.hasExactlyOnePlayerPassenger()) {
|
||||
+ // CraftBukkit end
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -462,6 +586,7 @@
|
||||
nbttagcompound.put("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
+ this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit
|
||||
@@ -600,12 +740,12 @@
|
||||
|
||||
nbttagcompound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
if (this.raidOmenPosition != null) {
|
||||
@@ -475,6 +600,29 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,7 +767,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);
|
||||
@@ -653,7 +793,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);
|
||||
@@ -688,6 +828,29 @@
|
||||
|
||||
}
|
||||
|
||||
@ -256,7 +328,7 @@
|
||||
public void setExperiencePoints(int i) {
|
||||
float f = (float) this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -533,6 +681,11 @@
|
||||
@@ -746,6 +909,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@ -268,7 +340,7 @@
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
--this.spawnInvulnerableTime;
|
||||
@@ -613,7 +766,7 @@
|
||||
@@ -822,7 +990,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@ -277,7 +349,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -644,6 +797,12 @@
|
||||
@@ -853,6 +1021,12 @@
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@ -290,7 +362,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
|
||||
@@ -658,6 +817,20 @@
|
||||
@@ -867,6 +1041,20 @@
|
||||
CriterionTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
|
||||
@ -311,7 +383,16 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
|
||||
@@ -703,7 +876,8 @@
|
||||
@@ -895,7 +1083,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()) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
|
||||
}
|
||||
|
||||
float f = this.foodData.getSaturationLevel();
|
||||
@@ -948,7 +1136,8 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
@ -321,16 +402,16 @@
|
||||
scoreaccess.set(i);
|
||||
});
|
||||
}
|
||||
@@ -712,9 +886,47 @@
|
||||
@@ -957,9 +1146,47 @@
|
||||
public void die(DamageSource damagesource) {
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
+ // CraftBukkit start - fire PlayerDeathEvent
|
||||
+ if (this.isRemoved()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize());
|
||||
+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
|
||||
+ boolean keepInventory = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
|
||||
|
||||
- if (flag) {
|
||||
- IChatBaseComponent ichatbasecomponent = this.getCombatTracker().getDeathMessage();
|
||||
@ -342,7 +423,7 @@
|
||||
+ }
|
||||
+ }
|
||||
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
|
||||
+ this.dropFromLootTable(damagesource, this.lastHurtByPlayerTime > 0);
|
||||
+ this.dropFromLootTable(this.serverLevel(), damagesource, this.lastHurtByPlayerTime > 0);
|
||||
+ this.dropCustomDeathLoot(this.serverLevel(), damagesource, flag);
|
||||
+
|
||||
+ loot.addAll(this.drops);
|
||||
@ -371,15 +452,15 @@
|
||||
|
||||
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
|
||||
boolean flag1 = true;
|
||||
@@ -745,12 +957,18 @@
|
||||
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
@@ -990,12 +1217,18 @@
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
-
|
||||
- if (!this.isSpectator()) {
|
||||
- this.dropAllDeathLoot(this.serverLevel(), damagesource);
|
||||
+ // SPIGOT-5478 must be called manually now
|
||||
+ this.dropExperience(damagesource.getEntity());
|
||||
+ this.dropExperience(this.serverLevel(), damagesource.getEntity());
|
||||
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
+ if (!event.getKeepInventory()) {
|
||||
+ this.getInventory().clearContent();
|
||||
@ -394,7 +475,7 @@
|
||||
EntityLiving entityliving = this.getKillCredit();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -785,10 +1003,12 @@
|
||||
@@ -1030,10 +1263,12 @@
|
||||
if (entity != this) {
|
||||
super.awardKillScore(entity, i, damagesource);
|
||||
this.increaseScore(i);
|
||||
@ -409,7 +490,7 @@
|
||||
} else {
|
||||
this.awardStat(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -806,7 +1026,8 @@
|
||||
@@ -1051,7 +1286,8 @@
|
||||
int i = scoreboardteam.getColor().getId();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
@ -419,7 +500,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,10 +1077,16 @@
|
||||
@@ -1101,10 +1337,16 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@ -428,53 +509,53 @@
|
||||
+ return this.level().pvpMode;
|
||||
}
|
||||
|
||||
- public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a) {
|
||||
- public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean flag, TeleportTransition.a teleporttransition_a) {
|
||||
+ // CraftBukkit start
|
||||
+ public DimensionTransition findRespawnPositionAndUseSpawnBlock(boolean flag, DimensionTransition.a dimensiontransition_a, PlayerRespawnEvent.RespawnReason reason) {
|
||||
+ DimensionTransition dimensionTransition;
|
||||
+ public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean flag, TeleportTransition.a teleporttransition_a, PlayerRespawnEvent.RespawnReason reason) {
|
||||
+ TeleportTransition teleportTransition;
|
||||
+ boolean isBedSpawn = false;
|
||||
+ boolean isAnchorSpawn = false;
|
||||
+ // CraftBukkit end
|
||||
BlockPosition blockposition = this.getRespawnPosition();
|
||||
float f = this.getRespawnAngle();
|
||||
boolean flag1 = this.isRespawnForced();
|
||||
@@ -871,13 +1098,32 @@
|
||||
@@ -1116,13 +1358,32 @@
|
||||
if (optional.isPresent()) {
|
||||
EntityPlayer.RespawnPosAngle entityplayer_respawnposangle = (EntityPlayer.RespawnPosAngle) optional.get();
|
||||
|
||||
- return new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a);
|
||||
- return new TeleportTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, teleporttransition_a);
|
||||
+ // CraftBukkit start
|
||||
+ isBedSpawn = entityplayer_respawnposangle.isBedSpawn();
|
||||
+ isAnchorSpawn = entityplayer_respawnposangle.isAnchorSpawn();
|
||||
+ dimensionTransition = new DimensionTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, dimensiontransition_a);
|
||||
+ teleportTransition = new TeleportTransition(worldserver, entityplayer_respawnposangle.position(), Vec3D.ZERO, entityplayer_respawnposangle.yaw(), 0.0F, teleporttransition_a);
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
- return DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a);
|
||||
+ dimensionTransition = DimensionTransition.missingRespawnBlock(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit
|
||||
- return TeleportTransition.missingRespawnBlock(this.server.overworld(), this, teleporttransition_a);
|
||||
+ teleportTransition = TeleportTransition.missingRespawnBlock(this.server.overworld(), this, teleporttransition_a); // CraftBukkit
|
||||
}
|
||||
} else {
|
||||
- return new DimensionTransition(this.server.overworld(), this, dimensiontransition_a);
|
||||
+ dimensionTransition = new DimensionTransition(this.server.overworld(), this, dimensiontransition_a); // CraftBukkit
|
||||
- return new TeleportTransition(this.server.overworld(), this, teleporttransition_a);
|
||||
+ teleportTransition = new TeleportTransition(this.server.overworld(), this, teleporttransition_a); // CraftBukkit
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (reason == null) {
|
||||
+ return dimensionTransition;
|
||||
+ return teleportTransition;
|
||||
+ }
|
||||
+
|
||||
+ Player respawnPlayer = this.getBukkitEntity();
|
||||
+ Location location = CraftLocation.toBukkit(dimensionTransition.pos(), dimensionTransition.newLevel().getWorld(), dimensionTransition.yRot(), dimensionTransition.xRot());
|
||||
+ Location location = CraftLocation.toBukkit(teleportTransition.position(), teleportTransition.newLevel().getWorld(), teleportTransition.yRot(), teleportTransition.xRot());
|
||||
+
|
||||
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn, isAnchorSpawn, reason);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(respawnEvent);
|
||||
+
|
||||
+ location = respawnEvent.getRespawnLocation();
|
||||
+
|
||||
+ return new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), dimensionTransition.speed(), location.getYaw(), location.getPitch(), dimensionTransition.missingRespawnBlock(), dimensionTransition.postDimensionTransition(), dimensionTransition.cause());
|
||||
+ return new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), teleportTransition.deltaMovement(), location.getYaw(), location.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), teleportTransition.relatives(), teleportTransition.postTeleportTransition(), teleportTransition.cause());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@@ -892,11 +1138,11 @@
|
||||
@@ -1137,11 +1398,11 @@
|
||||
}
|
||||
|
||||
return optional.map((vec3d) -> {
|
||||
@ -488,7 +569,7 @@
|
||||
});
|
||||
} else if (!flag) {
|
||||
return Optional.empty();
|
||||
@@ -905,7 +1151,7 @@
|
||||
@@ -1150,7 +1411,7 @@
|
||||
IBlockData iblockdata1 = worldserver.getBlockState(blockposition.above());
|
||||
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
|
||||
|
||||
@ -497,32 +578,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -923,6 +1169,7 @@
|
||||
@@ -1168,6 +1429,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(DimensionTransition dimensiontransition) {
|
||||
public EntityPlayer teleport(TeleportTransition teleporttransition) {
|
||||
+ if (this.isSleeping()) return null; // CraftBukkit - SPIGOT-3154
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -932,14 +1179,21 @@
|
||||
@@ -1177,18 +1439,38 @@
|
||||
|
||||
WorldServer worldserver = dimensiontransition.newLevel();
|
||||
WorldServer worldserver = teleporttransition.newLevel();
|
||||
WorldServer worldserver1 = this.serverLevel();
|
||||
- ResourceKey<World> resourcekey = worldserver1.dimension();
|
||||
+ // CraftBukkit start
|
||||
+ ResourceKey<WorldDimension> resourcekey = worldserver1.getTypeKey();
|
||||
+
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
|
||||
+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(absolutePosition.position(), worldserver.getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
|
||||
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleporttransition.cause());
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
|
||||
+ Location newExit = tpEvent.getTo();
|
||||
+ if (tpEvent.isCancelled() || newExit == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ if (!newExit.equals(exit)) {
|
||||
+ worldserver = ((CraftWorld) newExit.getWorld()).getHandle();
|
||||
+ teleporttransition = new TeleportTransition(worldserver, CraftLocation.toVec3D(newExit), Vec3D.ZERO, newExit.getYaw(), newExit.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!teleporttransition.asPassenger()) {
|
||||
this.stopRiding();
|
||||
}
|
||||
|
||||
- if (worldserver.dimension() == resourcekey) {
|
||||
- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) { // CraftBukkit
|
||||
+ boolean result = this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot(), dimensiontransition.cause());
|
||||
+ if (!result) {
|
||||
+ return null;
|
||||
+ }
|
||||
- this.connection.teleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver != null && worldserver.dimension() == worldserver1.dimension()) {
|
||||
+ this.connection.internalTeleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
|
||||
+ // CraftBukkit end
|
||||
this.connection.resetPosition();
|
||||
dimensiontransition.postDimensionTransition().onTransition(this);
|
||||
teleporttransition.postTeleportTransition().onTransition(this);
|
||||
return this;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
@ -530,31 +628,22 @@
|
||||
this.isChangingDimension = true;
|
||||
WorldData worlddata = worldserver.getLevelData();
|
||||
|
||||
@@ -950,15 +1204,40 @@
|
||||
@@ -1199,17 +1481,31 @@
|
||||
playerlist.sendPlayerPermissionLevel(this);
|
||||
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
worldserver1.getProfiler().push("moving");
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("moving");
|
||||
- if (resourcekey == World.OVERWORLD && worldserver.dimension() == World.NETHER) {
|
||||
+ if (worldserver != null && resourcekey == WorldDimension.OVERWORLD && worldserver.getTypeKey() == WorldDimension.NETHER) { // CraftBukkit - empty to fall through to null to event
|
||||
this.enteredNetherPosition = this.position();
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ Location enter = this.getBukkitEntity().getLocation();
|
||||
+ Location exit = (worldserver == null) ? null : CraftLocation.toBukkit(dimensiontransition.pos(), worldserver.getWorld(), dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ PlayerTeleportEvent tpEvent = new PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, dimensiontransition.cause());
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(tpEvent);
|
||||
+ if (tpEvent.isCancelled() || tpEvent.getTo() == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ exit = tpEvent.getTo();
|
||||
+ worldserver = ((CraftWorld) exit.getWorld()).getHandle();
|
||||
+ // CraftBukkit end
|
||||
|
||||
worldserver1.getProfiler().pop();
|
||||
worldserver1.getProfiler().push("placing");
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("placing");
|
||||
+ // CraftBukkit start
|
||||
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
|
||||
+ WorldData worlddata = worldserver.getLevelData();
|
||||
@ -568,12 +657,12 @@
|
||||
+ this.unsetRemoved();
|
||||
+ // CraftBukkit end
|
||||
this.setServerLevel(worldserver);
|
||||
- this.connection.teleport(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ this.connection.teleport(exit); // CraftBukkit - use internal teleport without event
|
||||
- this.connection.teleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
|
||||
+ this.connection.internalTeleport(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives()); // CraftBukkit - use internal teleport without event
|
||||
this.connection.resetPosition();
|
||||
worldserver.addDuringTeleport(this);
|
||||
worldserver1.getProfiler().pop();
|
||||
@@ -971,21 +1250,47 @@
|
||||
gameprofilerfiller.pop();
|
||||
@@ -1223,11 +1519,29 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@ -600,6 +689,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void forceSetRotation(float f, float f1) {
|
||||
this.connection.send(new ClientboundPlayerRotationPacket(f, f1));
|
||||
@@ -1236,13 +1550,21 @@
|
||||
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
|
||||
ResourceKey<World> resourcekey = worldserver.dimension();
|
||||
ResourceKey<World> resourcekey1 = this.level().dimension();
|
||||
@ -624,7 +717,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
|
||||
@@ -1002,19 +1307,17 @@
|
||||
@@ -1259,19 +1581,17 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@ -648,7 +741,7 @@
|
||||
if (this.level().isDay()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -1031,7 +1334,36 @@
|
||||
@@ -1288,7 +1608,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -686,7 +779,7 @@
|
||||
this.awardStat(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1044,9 +1376,8 @@
|
||||
@@ -1301,9 +1650,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
@ -697,7 +790,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1073,13 +1404,31 @@
|
||||
@@ -1330,13 +1678,31 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean flag, boolean flag1) {
|
||||
@ -730,7 +823,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1146,8 +1495,9 @@
|
||||
@@ -1403,8 +1769,9 @@
|
||||
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
|
||||
}
|
||||
|
||||
@ -741,7 +834,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1155,13 +1505,35 @@
|
||||
@@ -1412,13 +1779,35 @@
|
||||
if (itileinventory == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@ -777,7 +870,7 @@
|
||||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
|
||||
@@ -1169,9 +1541,11 @@
|
||||
@@ -1426,9 +1815,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@ -791,7 +884,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1184,15 +1558,26 @@
|
||||
@@ -1441,15 +1832,26 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
@ -820,7 +913,7 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1215,6 +1600,7 @@
|
||||
@@ -1472,6 +1874,7 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@ -828,24 +921,7 @@
|
||||
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
|
||||
this.doCloseContainer();
|
||||
}
|
||||
@@ -1237,6 +1623,16 @@
|
||||
}
|
||||
|
||||
this.jumping = flag;
|
||||
+ // CraftBukkit start
|
||||
+ if (flag1 != this.isShiftKeyDown()) {
|
||||
+ PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(this.getBukkitEntity(), flag1);
|
||||
+ this.server.server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setShiftKeyDown(flag1);
|
||||
}
|
||||
|
||||
@@ -1270,19 +1666,19 @@
|
||||
@@ -1501,19 +1904,19 @@
|
||||
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.awardStat(StatisticList.SWIM_ONE_CM, i);
|
||||
@ -868,7 +944,7 @@
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (d1 > 0.0D) {
|
||||
@@ -1293,13 +1689,13 @@
|
||||
@@ -1524,13 +1927,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
|
||||
@ -885,7 +961,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1342,7 +1738,7 @@
|
||||
@@ -1573,7 +1976,7 @@
|
||||
@Override
|
||||
public void awardStat(Statistic<?> statistic, int i) {
|
||||
this.stats.increment(this, statistic, i);
|
||||
@ -894,7 +970,7 @@
|
||||
scoreaccess.add(i);
|
||||
});
|
||||
}
|
||||
@@ -1350,7 +1746,7 @@
|
||||
@@ -1581,7 +1984,7 @@
|
||||
@Override
|
||||
public void resetStat(Statistic<?> statistic) {
|
||||
this.stats.setValue(this, statistic, 0);
|
||||
@ -903,7 +979,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1398,6 +1794,7 @@
|
||||
@@ -1613,9 +2016,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(StatisticList.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
- this.causeFoodExhaustion(0.2F);
|
||||
+ this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent
|
||||
} else {
|
||||
- this.causeFoodExhaustion(0.05F);
|
||||
+ this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1641,6 +2044,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@ -911,16 +999,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1433,7 +1830,7 @@
|
||||
this.gameMode.setGameModeForPlayer(entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer());
|
||||
this.onUpdateAbilities();
|
||||
this.getAttributes().assignBaseValues(entityplayer.getAttributes());
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ // this.setHealth(this.getMaxHealth()); // CraftBukkit
|
||||
if (flag) {
|
||||
this.getInventory().replaceWith(entityplayer.getInventory());
|
||||
this.setHealth(entityplayer.getHealth());
|
||||
@@ -1443,7 +1840,7 @@
|
||||
@@ -1685,7 +2089,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
@ -928,8 +1007,17 @@
|
||||
+ // this.addEffect(new MobEffect(mobeffect)); // CraftBukkit
|
||||
}
|
||||
|
||||
this.experienceLevel = entityplayer.experienceLevel;
|
||||
@@ -1465,7 +1862,7 @@
|
||||
this.getInventory().replaceWith(entityplayer.getInventory());
|
||||
@@ -1696,7 +2100,7 @@
|
||||
this.portalProcess = entityplayer.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(entityplayer.getAttributes());
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ // this.setHealth(this.getMaxHealth()); // CraftBukkit
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || entityplayer.isSpectator()) {
|
||||
this.getInventory().replaceWith(entityplayer.getInventory());
|
||||
this.experienceLevel = entityplayer.experienceLevel;
|
||||
@@ -1712,7 +2116,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@ -938,32 +1026,25 @@
|
||||
this.seenCredits = entityplayer.seenCredits;
|
||||
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
|
||||
this.chunkTrackingView = entityplayer.chunkTrackingView;
|
||||
@@ -1516,6 +1913,12 @@
|
||||
@@ -1768,7 +2172,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
|
||||
+ // CraftBukkit start
|
||||
+ return teleportTo(worldserver, d0, d1, d2, set, f, f1, TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1, TeleportCause cause) {
|
||||
+ // CraftBukkit end
|
||||
- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
|
||||
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, TeleportCause cause) { // CraftBukkit
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
|
||||
|
||||
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
|
||||
@@ -1525,9 +1928,9 @@
|
||||
@@ -1780,7 +2184,7 @@
|
||||
this.setCamera(this);
|
||||
}
|
||||
|
||||
if (worldserver == this.level()) {
|
||||
- this.connection.teleport(d0, d1, d2, f, f1, set);
|
||||
+ this.connection.teleport(d0, d1, d2, f, f1, set, cause); // CraftBukkit
|
||||
} else {
|
||||
- this.teleportTo(worldserver, d0, d1, d2, f, f1);
|
||||
+ this.teleportTo(worldserver, d0, d1, d2, f, f1, cause); // CraftBukkit
|
||||
}
|
||||
- boolean flag1 = super.teleportTo(worldserver, d0, d1, d2, set, f, f1, flag);
|
||||
+ boolean flag1 = super.teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, cause); // CraftBukkit
|
||||
|
||||
this.setYHeadRot(f);
|
||||
@@ -1635,6 +2038,16 @@
|
||||
if (flag1) {
|
||||
this.setYHeadRot(set.contains(Relative.Y_ROT) ? this.getYHeadRot() + f : f);
|
||||
@@ -1897,6 +2301,16 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientinformation) {
|
||||
@ -980,16 +1061,16 @@
|
||||
this.language = clientinformation.language();
|
||||
this.requestedViewDistance = clientinformation.viewDistance();
|
||||
this.chatVisibility = clientinformation.chatVisibility();
|
||||
@@ -1718,7 +2131,7 @@
|
||||
@@ -1981,7 +2395,7 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
- this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot());
|
||||
+ this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit
|
||||
- this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false);
|
||||
+ this.teleportTo(worldserver, this.camera.getX(), this.camera.getY(), this.camera.getZ(), Set.of(), this.getYRot(), this.getXRot(), false, TeleportCause.SPECTATE); // CraftBukkit
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1755,7 +2168,7 @@
|
||||
@@ -2018,11 +2432,11 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getTabListDisplayName() {
|
||||
@ -997,33 +1078,13 @@
|
||||
+ return listName; // CraftBukkit
|
||||
}
|
||||
|
||||
public int getTabListOrder() {
|
||||
- return 0;
|
||||
+ return listOrder; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1776,14 +2189,24 @@
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) {
|
||||
+ this.teleportTo(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ // CraftBukkit end
|
||||
this.setCamera(this);
|
||||
this.stopRiding();
|
||||
+ /* CraftBukkit start - replace with bukkit handling for multi-world
|
||||
if (worldserver == this.level()) {
|
||||
this.connection.teleport(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
this.changeDimension(new DimensionTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1, DimensionTransition.DO_NOTHING));
|
||||
}
|
||||
+ */
|
||||
+ this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause);
|
||||
+ // CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
@@ -1809,6 +2232,32 @@
|
||||
@@ -2065,6 +2479,32 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
|
||||
@ -1056,24 +1117,48 @@
|
||||
if (blockposition != null) {
|
||||
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
|
||||
|
||||
@@ -1852,7 +2301,14 @@
|
||||
@@ -2107,12 +2547,38 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
|
||||
- EntityItem entityitem = super.drop(itemstack, flag, flag1);
|
||||
+ // CraftBukkit start - SPIGOT-2942: Add boolean to call event
|
||||
+ return drop(itemstack, flag, flag1, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) {
|
||||
+ EntityItem entityitem = super.drop(itemstack, flag, flag1, callEvent);
|
||||
+ // CraftBukkit end
|
||||
- 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);
|
||||
|
||||
if (entityitem == null) {
|
||||
return null;
|
||||
@@ -2049,10 +2505,12 @@
|
||||
this.awardStat(StatisticList.ITEM_BROKEN.get(item));
|
||||
} 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();
|
||||
|
||||
@@ -2394,10 +2860,12 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
- public static record RespawnPosAngle(Vec3D position, float yaw) {
|
||||
@ -1088,7 +1173,7 @@
|
||||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) {
|
||||
@@ -2061,4 +2519,147 @@
|
||||
@@ -2406,4 +2874,146 @@
|
||||
return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
}
|
||||
}
|
||||
@ -1195,7 +1280,6 @@
|
||||
+
|
||||
+ public void reset() {
|
||||
+ float exp = 0;
|
||||
+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY);
|
||||
+
|
||||
+ if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent)
|
||||
+ exp = this.experienceProgress;
|
||||
@ -1207,7 +1291,7 @@
|
||||
+ this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset
|
||||
+ this.setRemainingFireTicks(0);
|
||||
+ this.fallDistance = 0;
|
||||
+ this.foodData = new FoodMetaData(this);
|
||||
+ this.foodData = new FoodMetaData();
|
||||
+ this.experienceLevel = this.newLevel;
|
||||
+ this.totalExperience = this.newTotalExp;
|
||||
+ this.experienceProgress = 0;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
+++ b/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
@@ -46,6 +46,12 @@
|
||||
@@ -50,6 +50,12 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
public class EntityTrackerEntry {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -70,8 +76,12 @@
|
||||
@@ -74,8 +80,12 @@
|
||||
private boolean wasOnGround;
|
||||
@Nullable
|
||||
private List<DataWatcher.c<?>> trackedDataValues;
|
||||
@ -27,7 +27,7 @@
|
||||
this.level = worldserver;
|
||||
this.broadcast = consumer;
|
||||
this.entity = entity;
|
||||
@@ -90,7 +100,7 @@
|
||||
@@ -94,7 +104,7 @@
|
||||
List<Entity> list = this.entity.getPassengers();
|
||||
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
@ -36,7 +36,7 @@
|
||||
removedPassengers(list, this.lastPassengers).forEach((entity) -> {
|
||||
if (entity instanceof EntityPlayer entityplayer) {
|
||||
entityplayer.connection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
@@ -103,18 +113,18 @@
|
||||
@@ -107,18 +117,18 @@
|
||||
Entity entity = this.entity;
|
||||
|
||||
if (entity instanceof EntityItemFrame entityitemframe) {
|
||||
@ -59,7 +59,7 @@
|
||||
|
||||
worldmap.tickCarriedBy(entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.getUpdatePacket(mapid, entityplayer);
|
||||
@@ -232,6 +242,27 @@
|
||||
@@ -248,6 +258,27 @@
|
||||
|
||||
++this.tickCount;
|
||||
if (this.entity.hurtMarked) {
|
||||
@ -87,7 +87,7 @@
|
||||
this.entity.hurtMarked = false;
|
||||
this.broadcastAndSend(new PacketPlayOutEntityVelocity(this.entity));
|
||||
}
|
||||
@@ -260,7 +291,10 @@
|
||||
@@ -298,7 +329,10 @@
|
||||
|
||||
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
|
||||
if (this.entity.isRemoved()) {
|
||||
@ -99,7 +99,7 @@
|
||||
}
|
||||
|
||||
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket(this);
|
||||
@@ -275,6 +309,12 @@
|
||||
@@ -313,6 +347,12 @@
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
|
||||
}
|
||||
@@ -305,6 +345,7 @@
|
||||
@@ -344,6 +384,7 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
|
||||
}
|
||||
@ -120,7 +120,7 @@
|
||||
}
|
||||
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
@@ -358,6 +399,11 @@
|
||||
@@ -396,6 +437,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getAttributesToSync();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
|
@ -52,15 +52,15 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -134,6 +150,7 @@
|
||||
if (chunk != null) {
|
||||
@@ -138,6 +154,7 @@
|
||||
boolean flag = this.hasChangedSections;
|
||||
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
|
||||
|
||||
+ if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
+ if (i < 0 || i >= this.changedBlocksPerSection.length) return false; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
this.hasChangedSections = true;
|
||||
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
|
||||
@@ -208,8 +225,11 @@
|
||||
@@ -224,8 +241,11 @@
|
||||
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
|
||||
|
||||
this.broadcast(list, packetplayoutmultiblockchange);
|
||||
@ -73,7 +73,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -275,7 +295,7 @@
|
||||
@@ -291,7 +311,7 @@
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((chunkresult) -> {
|
||||
chunkresult.ifSuccess((chunk) -> {
|
||||
@ -82,7 +82,7 @@
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -285,6 +305,38 @@
|
||||
@@ -301,6 +321,38 @@
|
||||
playerchunkmap.onFullChunkStatusChange(this.pos, fullchunkstatus);
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
+ // Minecraft will apply the chunks tick lists to the world once the chunk got loaded, and then store the tick
|
||||
+ // lists again inside the chunk once the chunk becomes inaccessible and set the chunk's needsSaving flag.
|
||||
+ // These actions may however happen deferred, so we manually set the needsSaving flag already here.
|
||||
+ chunk.setUnsaved(true);
|
||||
+ chunk.markUnsaved();
|
||||
+ chunk.unloadCallback();
|
||||
+ });
|
||||
+ }
|
||||
@ -121,7 +121,7 @@
|
||||
protected void updateFutures(PlayerChunkMap playerchunkmap, Executor executor) {
|
||||
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
|
||||
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
|
||||
@@ -341,6 +393,26 @@
|
||||
@@ -357,6 +409,26 @@
|
||||
|
||||
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunkMap.java
|
||||
@@ -102,6 +102,10 @@
|
||||
@@ -104,6 +104,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");
|
||||
@@ -145,6 +149,27 @@
|
||||
@@ -149,6 +153,27 @@
|
||||
public int serverViewDistance;
|
||||
private final WorldGenContext worldGenContext;
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
|
||||
super(new RegionStorageInfo(convertable_conversionsession.getLevelId(), worldserver.dimension(), "chunk"), convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
|
||||
this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
@@ -164,7 +189,13 @@
|
||||
@@ -170,7 +195,13 @@
|
||||
IRegistryCustom iregistrycustom = worldserver.registryAccess();
|
||||
long j = worldserver.getSeed();
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
this.randomState = RandomState.create((GeneratorSettingBase) chunkgeneratorabstract.generatorSettings().value(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j);
|
||||
} else {
|
||||
this.randomState = RandomState.create(GeneratorSettingBase.dummy(), (HolderGetter) iregistrycustom.lookupOrThrow(Registries.NOISE), j);
|
||||
@@ -318,7 +349,7 @@
|
||||
@@ -325,7 +356,7 @@
|
||||
throw this.debugFuturesAndCreateReportedException(new IllegalStateException("At least one of the chunk futures were null"), "n/a");
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
|
||||
if (ichunkaccess == null) {
|
||||
return PlayerChunkMap.UNLOADED_CHUNK_LIST_RESULT;
|
||||
@@ -937,7 +968,8 @@
|
||||
@@ -977,7 +1008,8 @@
|
||||
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
|
||||
});
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
return chunk.getBlockEntities().size();
|
||||
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
|
||||
return chunk.getBlockTicks().count();
|
||||
@@ -950,7 +982,7 @@
|
||||
@@ -990,7 +1022,7 @@
|
||||
|
||||
private static String printFuture(CompletableFuture<ChunkResult<Chunk>> completablefuture) {
|
||||
try {
|
||||
@ -82,13 +82,13 @@
|
||||
|
||||
return chunkresult != null ? (chunkresult.isSuccess() ? "done" : "unloaded") : "not completed";
|
||||
} catch (CompletionException completionexception) {
|
||||
@@ -962,12 +994,14 @@
|
||||
@@ -1002,12 +1034,14 @@
|
||||
|
||||
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
|
||||
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
|
||||
- return optional.map(this::upgradeChunkTag);
|
||||
+ return optional.map((nbttagcompound) -> upgradeChunkTag(nbttagcompound, chunkcoordintpair)); // CraftBukkit
|
||||
}, SystemUtils.backgroundExecutor());
|
||||
}, SystemUtils.backgroundExecutor().forName("upgradeChunk"));
|
||||
}
|
||||
|
||||
- private NBTTagCompound upgradeChunkTag(NBTTagCompound nbttagcompound) {
|
||||
@ -99,8 +99,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1370,7 +1404,7 @@
|
||||
void forEachSpawnCandidateChunk(Consumer<PlayerChunk> consumer) {
|
||||
@@ -1424,7 +1458,7 @@
|
||||
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
|
||||
|
||||
public EntityTracker(final Entity entity, final int i, final int j, final boolean flag) {
|
||||
@ -109,7 +109,7 @@
|
||||
this.entity = entity;
|
||||
this.range = i;
|
||||
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
|
||||
@@ -1430,6 +1464,11 @@
|
||||
@@ -1484,6 +1518,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);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/level/PlayerInteractManager.java
|
||||
@@ -28,6 +28,27 @@
|
||||
@@ -26,6 +26,27 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -58,9 +79,16 @@
|
||||
@@ -56,9 +77,16 @@
|
||||
if (enumgamemode == this.gameModeForPlayer) {
|
||||
return false;
|
||||
} else {
|
||||
@ -46,7 +46,7 @@
|
||||
this.level.updateSleepingPlayerList();
|
||||
if (enumgamemode == EnumGamemode.CREATIVE) {
|
||||
this.player.resetCurrentImpulseContext();
|
||||
@@ -94,7 +122,7 @@
|
||||
@@ -92,7 +120,7 @@
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@ -55,7 +55,7 @@
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.hasDelayedDestroy) {
|
||||
@@ -148,11 +176,33 @@
|
||||
@@ -146,11 +174,33 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.level.mayInteract(this.player, blockposition)) {
|
||||
@ -89,7 +89,7 @@
|
||||
if (this.isCreative()) {
|
||||
this.destroyAndAck(blockposition, j, "creative destroy");
|
||||
return;
|
||||
@@ -168,7 +218,19 @@
|
||||
@@ -166,7 +216,19 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.level.getBlockState(blockposition);
|
||||
@ -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);
|
||||
});
|
||||
@@ -176,6 +238,26 @@
|
||||
@@ -174,6 +236,26 @@
|
||||
f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.destroyAndAck(blockposition, j, "insta mine");
|
||||
} else {
|
||||
@@ -220,13 +302,15 @@
|
||||
@@ -218,13 +300,15 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.isDestroyingBlock = false;
|
||||
if (!Objects.equals(this.destroyPos, blockposition)) {
|
||||
@ -154,7 +154,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -244,10 +328,65 @@
|
||||
@@ -242,10 +326,65 @@
|
||||
|
||||
public boolean destroyBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.level.getBlockState(blockposition);
|
||||
@ -221,7 +221,7 @@
|
||||
TileEntity tileentity = this.level.getBlockEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -257,6 +396,10 @@
|
||||
@@ -255,6 +394,10 @@
|
||||
} else if (this.player.blockActionRestricted(this.level, blockposition, this.gameModeForPlayer)) {
|
||||
return false;
|
||||
} else {
|
||||
@ -232,7 +232,7 @@
|
||||
IBlockData iblockdata1 = block.playerWillDestroy(this.level, blockposition, iblockdata, this.player);
|
||||
boolean flag = this.level.removeBlock(blockposition, false);
|
||||
|
||||
@@ -265,19 +408,32 @@
|
||||
@@ -263,19 +406,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
@ -268,7 +268,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,14 +471,53 @@
|
||||
@@ -321,14 +477,53 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@
|
||||
+ cancelledBlock = !(itileinventory instanceof ITileInventory);
|
||||
+ }
|
||||
+
|
||||
+ if (entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
|
||||
+ if (entityplayer.getCooldowns().isOnCooldown(itemstack)) {
|
||||
+ cancelledBlock = true;
|
||||
+ }
|
||||
+
|
||||
@ -322,11 +322,11 @@
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openMenu(itileinventory);
|
||||
@@ -353,7 +548,7 @@
|
||||
@@ -359,7 +554,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack.getItem())) {
|
||||
- if (!itemstack.isEmpty() && !entityplayer.getCooldowns().isOnCooldown(itemstack)) {
|
||||
+ if (!itemstack.isEmpty() && !interactResult) { // add !interactResult SPIGOT-764
|
||||
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- 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);
|
||||
@@ -23,6 +23,8 @@
|
||||
public static final TicketType<ChunkCoordIntPair> ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkCoordIntPair::toLong), 40);
|
||||
public static final TicketType<Integer> POST_TELEPORT = create("post_teleport", Integer::compareTo, 5);
|
||||
public static final TicketType<ChunkCoordIntPair> UNKNOWN = create("unknown", Comparator.comparingLong(ChunkCoordIntPair::toLong), 1);
|
||||
+ public static final TicketType<Unit> PLUGIN = create("plugin", (a, b) -> 0); // CraftBukkit
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/WorldServer.java
|
||||
+++ b/net/minecraft/server/level/WorldServer.java
|
||||
@@ -171,6 +171,23 @@
|
||||
@@ -173,6 +173,23 @@
|
||||
import net.minecraft.world.ticks.TickListServer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -21,31 +21,28 @@
|
||||
+import org.bukkit.event.world.TimeSkipEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
public class WorldServer extends World implements ServerEntityGetter, GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
|
||||
@@ -184,7 +201,7 @@
|
||||
final List<EntityPlayer> players;
|
||||
@@ -186,7 +203,7 @@
|
||||
final List<EntityPlayer> players = Lists.newArrayList();
|
||||
private final ChunkProviderServer chunkSource;
|
||||
private final MinecraftServer server;
|
||||
- public final IWorldDataServer serverLevelData;
|
||||
+ public final WorldDataServer serverLevelData; // CraftBukkit - type
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList;
|
||||
final EntityTickList entityTickList = new EntityTickList();
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -211,12 +228,30 @@
|
||||
@@ -213,13 +230,47 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences) {
|
||||
- IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess();
|
||||
- Holder holder = worlddimension.type();
|
||||
- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
|
||||
+ // CraftBukkit start
|
||||
+ public final Convertable.ConversionSession convertable;
|
||||
+ public final UUID uuid;
|
||||
|
||||
- Objects.requireNonNull(minecraftserver);
|
||||
- super(iworlddataserver, resourcekey, iregistrycustom_dimension, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
|
||||
+
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkSource.getChunk(x, z, false);
|
||||
+ }
|
||||
@ -57,19 +54,13 @@
|
||||
+
|
||||
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
+ // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
||||
+ // Holder holder = worlddimension.type(); // CraftBukkit - decompile error
|
||||
+
|
||||
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
|
||||
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
|
||||
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env);
|
||||
+ this.pvpMode = minecraftserver.isPvpAllowed();
|
||||
+ convertable = convertable_conversionsession;
|
||||
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
|
||||
+ // CraftBukkit end
|
||||
this.players = Lists.newArrayList();
|
||||
this.entityTickList = new EntityTickList();
|
||||
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
|
||||
@@ -231,6 +266,22 @@
|
||||
this.tickTime = flag1;
|
||||
this.server = minecraftserver;
|
||||
this.customSpawners = list;
|
||||
this.serverLevelData = iworlddataserver;
|
||||
ChunkGenerator chunkgenerator = worlddimension.generator();
|
||||
@ -77,7 +68,7 @@
|
||||
+ serverLevelData.setWorld(this);
|
||||
+
|
||||
+ if (biomeProvider != null) {
|
||||
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryAccess().registryOrThrow(Registries.BIOME));
|
||||
+ WorldChunkManager worldChunkManager = new CustomWorldChunkManager(getWorld(), biomeProvider, server.registryAccess().lookupOrThrow(Registries.BIOME));
|
||||
+ if (chunkgenerator instanceof ChunkGeneratorAbstract cga) {
|
||||
+ chunkgenerator = new ChunkGeneratorAbstract(worldChunkManager, cga.settings);
|
||||
+ } else if (chunkgenerator instanceof ChunkProviderFlat cpf) {
|
||||
@ -92,7 +83,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);
|
||||
@@ -258,9 +309,9 @@
|
||||
@@ -247,9 +298,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);
|
||||
@ -105,7 +96,7 @@
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -270,6 +321,7 @@
|
||||
@@ -259,6 +310,7 @@
|
||||
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
|
||||
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences");
|
||||
});
|
||||
@ -113,7 +104,7 @@
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@@ -314,12 +366,20 @@
|
||||
@@ -304,12 +356,20 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
@ -137,7 +128,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -354,7 +414,7 @@
|
||||
@@ -344,7 +404,7 @@
|
||||
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.pop();
|
||||
@ -146,16 +137,7 @@
|
||||
|
||||
if (flag1) {
|
||||
this.resetEmptyTime();
|
||||
@@ -370,7 +430,7 @@
|
||||
|
||||
this.entityTickList.forEach((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
- if (this.shouldDiscardEntity(entity)) {
|
||||
+ if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.discard();
|
||||
} else if (!tickratemanager.isEntityFrozen(entity)) {
|
||||
gameprofilerfiller.push("checkDespawn");
|
||||
@@ -442,7 +502,7 @@
|
||||
@@ -428,7 +488,7 @@
|
||||
|
||||
private void wakeUpAllPlayers() {
|
||||
this.sleepStatus.removeAllSleepers();
|
||||
@ -164,7 +146,7 @@
|
||||
entityplayer.stopSleepInBed(false, false);
|
||||
});
|
||||
}
|
||||
@@ -469,7 +529,7 @@
|
||||
@@ -455,7 +515,7 @@
|
||||
entityhorseskeleton.setTrap(true);
|
||||
entityhorseskeleton.setAge(0);
|
||||
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
@ -173,7 +155,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +538,7 @@
|
||||
@@ -464,7 +524,7 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
|
||||
entitylightning.setVisualOnly(flag1);
|
||||
@ -182,7 +164,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -534,7 +594,7 @@
|
||||
@@ -520,7 +580,7 @@
|
||||
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
|
||||
|
||||
if (biomebase.shouldFreeze(this, blockposition2)) {
|
||||
@ -191,7 +173,7 @@
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -550,10 +610,10 @@
|
||||
@@ -536,10 +596,10 @@
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
|
||||
|
||||
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
|
||||
@ -204,7 +186,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,6 +774,7 @@
|
||||
@@ -700,6 +760,7 @@
|
||||
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@ -212,7 +194,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
|
||||
}
|
||||
@@ -732,15 +793,48 @@
|
||||
@@ -718,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));
|
||||
}
|
||||
@ -263,15 +245,15 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -775,6 +869,7 @@
|
||||
@@ -762,6 +856,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickNonPassenger");
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
this.getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -798,6 +893,7 @@
|
||||
@@ -785,6 +880,7 @@
|
||||
});
|
||||
gameprofilerfiller.incrementCounter("tickPassenger");
|
||||
entity1.rideTick();
|
||||
@ -279,7 +261,7 @@
|
||||
gameprofilerfiller.pop();
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -822,6 +918,7 @@
|
||||
@@ -809,6 +905,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkSource();
|
||||
|
||||
if (!flag1) {
|
||||
@ -287,7 +269,7 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -839,11 +936,19 @@
|
||||
@@ -826,11 +923,19 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -301,14 +283,14 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void saveLevelData() {
|
||||
private void saveLevelData(boolean flag) {
|
||||
if (this.dragonFight != null) {
|
||||
- this.server.getWorldData().setEndDragonFightData(this.dragonFight.saveData());
|
||||
+ this.serverLevelData.setEndDragonFightData(this.dragonFight.saveData()); // CraftBukkit
|
||||
}
|
||||
|
||||
this.getChunkSource().getDataStorage().save();
|
||||
@@ -908,18 +1013,40 @@
|
||||
WorldPersistentData worldpersistentdata = this.getChunkSource().getDataStorage();
|
||||
@@ -902,18 +1007,40 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@ -352,7 +334,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -944,24 +1071,37 @@
|
||||
@@ -938,24 +1065,37 @@
|
||||
this.entityManager.addNewEntity(entityplayer);
|
||||
}
|
||||
|
||||
@ -394,19 +376,19 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -972,13 +1112,35 @@
|
||||
@@ -966,13 +1106,35 @@
|
||||
}
|
||||
|
||||
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
|
||||
- entityplayer.remove(entity_removalreason);
|
||||
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean strikeLightning(Entity entitylightning) {
|
||||
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ public boolean strikeLightning(Entity entitylightning, LightningStrikeEvent.Cause cause) {
|
||||
+ LightningStrikeEvent lightning = CraftEventFactory.callLightningStrikeEvent((org.bukkit.entity.LightningStrike) entitylightning.getBukkitEntity(), cause);
|
||||
+
|
||||
@ -431,7 +413,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -987,6 +1149,12 @@
|
||||
@@ -981,6 +1143,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.getY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
|
||||
|
||||
@ -444,7 +426,7 @@
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1047,7 +1215,18 @@
|
||||
@@ -1059,7 +1227,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -464,19 +446,52 @@
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(blockposition)) {
|
||||
@@ -1109,6 +1288,11 @@
|
||||
@@ -1125,6 +1304,12 @@
|
||||
|
||||
@Override
|
||||
public Explosion 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) {
|
||||
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false, particleparam, particleparam1, holder);
|
||||
public void explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a, ParticleParam particleparam, ParticleParam particleparam1, Holder<SoundEffect> holder) {
|
||||
+ // CraftBukkit start
|
||||
+ if (explosion.wasCanceled) {
|
||||
+ return explosion;
|
||||
+ this.explode0(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, particleparam, particleparam1, holder);
|
||||
+ }
|
||||
+
|
||||
+ public ServerExplosion explode0(@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) {
|
||||
+ // CraftBukkit end
|
||||
Explosion.Effect explosion_effect;
|
||||
|
||||
switch (world_a) {
|
||||
@@ -1143,6 +1328,11 @@
|
||||
case TRIGGER:
|
||||
explosion_effect = Explosion.Effect.TRIGGER_BLOCK;
|
||||
break;
|
||||
+ // CraftBukkit start - handle custom explosion type
|
||||
+ case STANDARD:
|
||||
+ explosion_effect = Explosion.Effect.DESTROY;
|
||||
+ break;
|
||||
+ // CraftBukkit end
|
||||
default:
|
||||
throw new MatchException((String) null, (Throwable) null);
|
||||
}
|
||||
@@ -1152,6 +1342,11 @@
|
||||
ServerExplosion serverexplosion = new ServerExplosion(this, entity, damagesource, explosiondamagecalculator, vec3d, f, flag, explosion_effect1);
|
||||
|
||||
serverexplosion.explode();
|
||||
+ // CraftBukkit start
|
||||
+ if (serverexplosion.wasCanceled) {
|
||||
+ return serverexplosion;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ParticleParam particleparam2 = serverexplosion.isSmall() ? particleparam : particleparam1;
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
if (!explosion.interactsWithBlocks()) {
|
||||
explosion.clearToBlow();
|
||||
@@ -1181,13 +1365,20 @@
|
||||
@@ -1165,6 +1360,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ return serverexplosion; // CraftBukkit
|
||||
}
|
||||
|
||||
private Explosion.Effect getDestroyType(GameRules.GameRuleKey<GameRules.GameRuleBoolean> gamerules_gamerulekey) {
|
||||
@@ -1225,13 +1421,20 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
@ -499,7 +514,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1238,7 +1429,7 @@
|
||||
@@ -1282,7 +1485,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
|
||||
@ -507,8 +522,8 @@
|
||||
+ if (!this.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
|
||||
@@ -1280,11 +1471,22 @@
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(tagkey);
|
||||
@@ -1324,11 +1527,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap getMapData(MapId mapid) {
|
||||
@ -532,7 +547,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(mapid.key(), worldmap);
|
||||
}
|
||||
|
||||
@@ -1595,6 +1797,11 @@
|
||||
@@ -1639,6 +1853,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@ -544,7 +559,7 @@
|
||||
this.updateNeighborsAt(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1614,12 +1821,12 @@
|
||||
@@ -1658,12 +1877,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@ -559,7 +574,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1642,7 +1849,7 @@
|
||||
@@ -1686,7 +1905,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@ -568,7 +583,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1651,7 +1858,7 @@
|
||||
@@ -1695,7 +1914,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@ -577,7 +592,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1796,6 +2003,8 @@
|
||||
@@ -1854,6 +2073,8 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@ -586,7 +601,7 @@
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -1827,6 +2036,14 @@
|
||||
@@ -1885,6 +2106,14 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -191,6 +191,67 @@
|
||||
@@ -196,6 +196,69 @@
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
+import net.minecraft.network.chat.OutgoingChatMessage;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutAttachEntity;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSetSlot;
|
||||
+import net.minecraft.world.entity.EntityInsentient;
|
||||
+import net.minecraft.world.entity.animal.Bucketable;
|
||||
+import net.minecraft.world.entity.EntityLiving;
|
||||
@ -30,7 +30,9 @@
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
@ -68,18 +70,7 @@
|
||||
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
|
||||
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -204,7 +265,9 @@
|
||||
public final PlayerChunkSender chunkSender;
|
||||
private int tickCount;
|
||||
private int ackBlockChangesUpTo = -1;
|
||||
- private int chatSpamTickCount;
|
||||
+ // CraftBukkit start - multithreaded fields
|
||||
+ private final AtomicInteger chatSpamTickCount = new AtomicInteger();
|
||||
+ // CraftBukkit end
|
||||
private int dropSpamTickCount;
|
||||
private double firstGoodX;
|
||||
private double firstGoodY;
|
||||
@@ -239,7 +302,7 @@
|
||||
@@ -245,7 +308,7 @@
|
||||
private boolean waitingForSwitchToConfig;
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
@ -88,7 +79,7 @@
|
||||
this.chunkSender = new PlayerChunkSender(networkmanager.isMemoryConnection());
|
||||
this.player = entityplayer;
|
||||
entityplayer.connection = this;
|
||||
@@ -248,9 +311,25 @@
|
||||
@@ -254,9 +317,25 @@
|
||||
|
||||
Objects.requireNonNull(minecraftserver);
|
||||
this.signedMessageDecoder = SignedMessageChain.b.unsigned(uuid, minecraftserver::enforceSecureProfile);
|
||||
@ -115,29 +106,15 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
if (this.ackBlockChangesUpTo > -1) {
|
||||
@@ -302,15 +381,21 @@
|
||||
}
|
||||
|
||||
this.keepConnectionAlive();
|
||||
+ // CraftBukkit start
|
||||
+ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ;
|
||||
+ /* Use thread-safe field access instead
|
||||
if (this.chatSpamTickCount > 0) {
|
||||
--this.chatSpamTickCount;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.dropSpamTickCount > 0) {
|
||||
--this.dropSpamTickCount;
|
||||
}
|
||||
|
||||
@@ -311,6 +390,7 @@
|
||||
this.chatSpamThrottler.tick();
|
||||
this.dropSpamThrottler.tick();
|
||||
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && SystemUtils.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
+ this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
||||
}
|
||||
|
||||
@@ -399,6 +484,13 @@
|
||||
@@ -399,6 +479,13 @@
|
||||
|
||||
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
@ -151,7 +128,7 @@
|
||||
double d0 = entity.getX();
|
||||
double d1 = entity.getY();
|
||||
double d2 = entity.getZ();
|
||||
@@ -413,7 +505,33 @@
|
||||
@@ -413,7 +500,33 @@
|
||||
double d9 = entity.getDeltaMovement().lengthSqr();
|
||||
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
||||
|
||||
@ -186,7 +163,7 @@
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
||||
this.send(new PacketPlayOutVehicleMove(entity));
|
||||
return;
|
||||
@@ -453,14 +571,76 @@
|
||||
@@ -453,14 +566,76 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
@ -261,9 +238,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
entity.recordMovementThroughBlocks(new Vec3D(d0, d1, d2), entity.position());
|
||||
Vec3D vec3d = new Vec3D(entity.getX() - d0, entity.getY() - d1, entity.getZ() - d2);
|
||||
|
||||
@@ -497,6 +677,7 @@
|
||||
@@ -498,6 +673,7 @@
|
||||
}
|
||||
|
||||
this.awaitingPositionFromClient = null;
|
||||
@ -271,16 +248,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -504,7 +685,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel());
|
||||
- Optional optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe());
|
||||
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error
|
||||
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
||||
|
||||
Objects.requireNonNull(recipebookserver);
|
||||
@@ -514,6 +695,7 @@
|
||||
@@ -521,6 +697,7 @@
|
||||
@Override
|
||||
public void handleRecipeBookChangeSettingsPacket(PacketPlayInRecipeSettings packetplayinrecipesettings) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipesettings, this, this.player.serverLevel());
|
||||
@ -288,12 +256,12 @@
|
||||
this.player.getRecipeBook().setBookSetting(packetplayinrecipesettings.getBookType(), packetplayinrecipesettings.isOpen(), packetplayinrecipesettings.isFiltering());
|
||||
}
|
||||
|
||||
@@ -534,6 +716,12 @@
|
||||
@@ -541,6 +718,12 @@
|
||||
@Override
|
||||
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
||||
+ // CraftBukkit start
|
||||
+ if (chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
|
||||
+ if (!this.chatSpamThrottler.isIncrementAndUnderThreshold(1, 500) && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
||||
+ return;
|
||||
+ }
|
||||
@ -301,7 +269,7 @@
|
||||
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
||||
|
||||
if (stringreader.canRead() && stringreader.peek() == '/') {
|
||||
@@ -543,6 +731,7 @@
|
||||
@@ -550,6 +733,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
||||
|
||||
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
||||
@ -309,7 +277,7 @@
|
||||
Suggestions suggestions1 = suggestions.getList().size() <= 1000 ? suggestions : new Suggestions(suggestions.getRange(), suggestions.getList().subList(0, 1000));
|
||||
|
||||
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions1));
|
||||
@@ -787,6 +976,13 @@
|
||||
@@ -796,6 +980,13 @@
|
||||
Container container = this.player.containerMenu;
|
||||
|
||||
if (container instanceof ContainerMerchant containermerchant) {
|
||||
@ -323,7 +291,7 @@
|
||||
if (!containermerchant.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
||||
return;
|
||||
@@ -800,6 +996,13 @@
|
||||
@@ -809,6 +1000,13 @@
|
||||
|
||||
@Override
|
||||
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
||||
@ -337,16 +305,7 @@
|
||||
int i = packetplayinbedit.slot();
|
||||
|
||||
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
||||
@@ -808,7 +1011,7 @@
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
optional.ifPresent(list::add);
|
||||
- Stream stream = packetplayinbedit.pages().stream().limit(100L);
|
||||
+ Stream<String> stream = packetplayinbedit.pages().stream().limit(100L); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(list);
|
||||
stream.forEach(list::add);
|
||||
@@ -823,12 +1026,16 @@
|
||||
@@ -829,12 +1027,16 @@
|
||||
}
|
||||
|
||||
private void updateBookContents(List<FilteredText> list, int i) {
|
||||
@ -356,7 +315,7 @@
|
||||
+ ItemStack itemstack = handItem.copy();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (itemstack.is(Items.WRITABLE_BOOK)) {
|
||||
if (itemstack.has(DataComponents.WRITABLE_BOOK_CONTENT)) {
|
||||
List<Filterable<String>> list1 = list.stream().map(this::filterableFromOutgoing).toList();
|
||||
|
||||
itemstack.set(DataComponents.WRITABLE_BOOK_CONTENT, new WritableBookContent(list1));
|
||||
@ -364,7 +323,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,12 +1046,13 @@
|
||||
@@ -845,12 +1047,13 @@
|
||||
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
|
||||
|
||||
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
|
||||
@ -380,7 +339,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -906,7 +1114,7 @@
|
||||
@@ -912,7 +1115,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
|
||||
@ -389,7 +348,7 @@
|
||||
if (this.tickCount == 0) {
|
||||
this.resetPosition();
|
||||
}
|
||||
@@ -921,7 +1129,15 @@
|
||||
@@ -927,7 +1130,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
||||
this.player.serverLevel().getChunkSource().move(this.player);
|
||||
@ -405,7 +364,7 @@
|
||||
double d3 = this.player.getX();
|
||||
double d4 = this.player.getY();
|
||||
double d5 = this.player.getZ();
|
||||
@@ -943,15 +1159,33 @@
|
||||
@@ -949,15 +1160,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
@ -432,16 +391,16 @@
|
||||
+ speed = player.getAbilities().walkingSpeed * 10f;
|
||||
+ }
|
||||
+
|
||||
if (!this.player.isChangingDimension() && (!this.player.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !flag)) {
|
||||
if (this.shouldCheckPlayerMovement(flag)) {
|
||||
float f2 = flag ? 300.0F : 100.0F;
|
||||
|
||||
- if (d10 - d9 > (double) (f2 * (float) i) && !this.isSingleplayerOwner()) {
|
||||
+ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
|
||||
- if (d10 - d9 > (double) (f2 * (float) i)) {
|
||||
+ if (d10 - d9 > Math.max(f2, Math.pow((double) (10.0F * (float) i * speed), 2))) {
|
||||
+ // CraftBukkit end
|
||||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
|
||||
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -973,6 +1207,7 @@
|
||||
@@ -979,6 +1208,7 @@
|
||||
boolean flag2 = this.player.verticalCollisionBelow;
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
||||
@ -449,12 +408,12 @@
|
||||
double d11 = d7;
|
||||
|
||||
d6 = d0 - this.player.getX();
|
||||
@@ -991,9 +1226,75 @@
|
||||
@@ -997,9 +1227,75 @@
|
||||
}
|
||||
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag3 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
||||
- this.teleport(d3, d4, d5, f, f1);
|
||||
+ this.internalTeleport(d3, d4, d5, f, f1, Collections.emptySet()); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet.
|
||||
+ this.internalTeleport(d3, d4, d5, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet.
|
||||
this.player.doCheckFallDamage(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5, packetplayinflying.isOnGround());
|
||||
} else {
|
||||
+ // CraftBukkit start - fire PlayerMoveEvent
|
||||
@ -526,7 +485,7 @@
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
boolean flag4 = this.player.isAutoSpinAttack();
|
||||
|
||||
@@ -1030,6 +1331,7 @@
|
||||
@@ -1049,6 +1345,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
@ -534,38 +493,33 @@
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -1057,11 +1359,68 @@
|
||||
return true;
|
||||
@@ -1077,10 +1374,62 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Delegate to teleport(Location)
|
||||
public void teleport(double d0, double d1, double d2, float f, float f1) {
|
||||
- this.teleport(d0, d1, d2, f, f1, Collections.emptySet());
|
||||
- this.teleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet());
|
||||
+ // CraftBukkit start - Delegate to teleport(Location)
|
||||
+ this.teleport(d0, d1, d2, f, f1, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean teleport(double d0, double d1, double d2, float f, float f1, PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ return this.teleport(d0, d1, d2, f, f1, Collections.emptySet(), cause);
|
||||
+ return this.teleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet(), cause);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void teleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) {
|
||||
+ this.teleport(d0, d1, d2, f, f1, set, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
public void teleport(PositionMoveRotation positionmoverotation, Set<Relative> set) {
|
||||
+ // CraftBukkit start
|
||||
+ this.teleport(positionmoverotation, set, PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean teleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status
|
||||
+ public boolean teleport(PositionMoveRotation positionmoverotation, Set<Relative> set, PlayerTeleportEvent.TeleportCause cause) { // CraftBukkit - Return event status
|
||||
+ Player player = this.getCraftPlayer();
|
||||
+ Location from = player.getLocation();
|
||||
+
|
||||
+ double x = d0;
|
||||
+ double y = d1;
|
||||
+ double z = d2;
|
||||
+ float yaw = f;
|
||||
+ float pitch = f1;
|
||||
+
|
||||
+ Location to = new Location(this.getCraftPlayer().getWorld(), x, y, z, yaw, pitch);
|
||||
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this.player), positionmoverotation, set);
|
||||
+ Location to = CraftLocation.toBukkit(absolutePosition.position(), this.getCraftPlayer().getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
|
||||
+ // SPIGOT-5171: Triggered on join
|
||||
+ if (from.equals(to)) {
|
||||
+ this.internalTeleport(d0, d1, d2, f, f1, set);
|
||||
+ this.internalTeleport(positionmoverotation, set);
|
||||
+ return true; // CraftBukkit - Return event status
|
||||
+ }
|
||||
+
|
||||
@ -575,51 +529,48 @@
|
||||
+ if (event.isCancelled() || !to.equals(event.getTo())) {
|
||||
+ set = Collections.emptySet(); // Can't relative teleport
|
||||
+ to = event.isCancelled() ? event.getFrom() : event.getTo();
|
||||
+ d0 = to.getX();
|
||||
+ d1 = to.getY();
|
||||
+ d2 = to.getZ();
|
||||
+ f = to.getYaw();
|
||||
+ f1 = to.getPitch();
|
||||
+ positionmoverotation = new PositionMoveRotation(CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch());
|
||||
+ }
|
||||
+
|
||||
+ this.internalTeleport(d0, d1, d2, f, f1, set);
|
||||
+ this.internalTeleport(positionmoverotation, set);
|
||||
+ return !event.isCancelled(); // CraftBukkit - Return event status
|
||||
+ }
|
||||
+
|
||||
+ public void teleport(Location dest) {
|
||||
+ internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch(), Collections.emptySet());
|
||||
+ this.internalTeleport(dest.getX(), dest.getY(), dest.getZ(), dest.getYaw(), dest.getPitch());
|
||||
+ }
|
||||
+
|
||||
+ private void internalTeleport(double d0, double d1, double d2, float f, float f1, Set<RelativeMovement> set) {
|
||||
+ // CraftBukkit start
|
||||
+ if (Float.isNaN(f)) {
|
||||
+ f = 0;
|
||||
+ private void internalTeleport(double d0, double d1, double d2, float f, float f1) {
|
||||
+ this.internalTeleport(new PositionMoveRotation(new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f1), Collections.emptySet());
|
||||
+ }
|
||||
+
|
||||
+ public void internalTeleport(PositionMoveRotation positionmoverotation, Set<Relative> set) {
|
||||
+ if (Float.isNaN(positionmoverotation.yRot())) {
|
||||
+ positionmoverotation = new PositionMoveRotation(positionmoverotation.position(), positionmoverotation.deltaMovement(), 0, positionmoverotation.xRot());
|
||||
+ }
|
||||
+ if (Float.isNaN(f1)) {
|
||||
+ f1 = 0;
|
||||
+ if (Float.isNaN(positionmoverotation.xRot())) {
|
||||
+ positionmoverotation = new PositionMoveRotation(positionmoverotation.position(), positionmoverotation.deltaMovement(), positionmoverotation.yRot(), 0);
|
||||
+ }
|
||||
+
|
||||
+ this.justTeleported = true;
|
||||
+ // CraftBukkit end
|
||||
double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D;
|
||||
double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D;
|
||||
double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D;
|
||||
@@ -1073,6 +1432,14 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
if (++this.awaitingTeleport == Integer.MAX_VALUE) {
|
||||
this.awaitingTeleport = 0;
|
||||
}
|
||||
@@ -1088,12 +1437,20 @@
|
||||
|
||||
this.player.teleportSetPosition(positionmoverotation, set);
|
||||
this.awaitingPositionFromClient = this.player.position();
|
||||
+ // CraftBukkit start - update last location
|
||||
+ this.lastPosX = this.awaitingPositionFromClient.x;
|
||||
+ this.lastPosY = this.awaitingPositionFromClient.y;
|
||||
+ this.lastPosZ = this.awaitingPositionFromClient.z;
|
||||
+ this.lastYaw = f;
|
||||
+ this.lastPitch = f1;
|
||||
+ this.lastYaw = this.player.getYRot();
|
||||
+ this.lastPitch = this.player.getXRot();
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.player.absMoveTo(d0, d1, d2, f, f1);
|
||||
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
|
||||
@@ -1081,6 +1448,7 @@
|
||||
this.player.connection.send(PacketPlayOutPosition.of(this.awaitingTeleport, positionmoverotation, set));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
||||
@ -627,7 +578,7 @@
|
||||
BlockPosition blockposition = packetplayinblockdig.getPos();
|
||||
|
||||
this.player.resetLastActionTime();
|
||||
@@ -1091,14 +1459,46 @@
|
||||
@@ -1104,14 +1461,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
||||
|
||||
@ -676,7 +627,7 @@
|
||||
this.player.drop(false);
|
||||
}
|
||||
|
||||
@@ -1136,6 +1536,7 @@
|
||||
@@ -1149,6 +1538,7 @@
|
||||
@Override
|
||||
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
||||
@ -684,15 +635,15 @@
|
||||
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinuseitem.getHand();
|
||||
@@ -1158,6 +1559,7 @@
|
||||
@@ -1171,6 +1561,7 @@
|
||||
|
||||
if (blockposition.getY() < i) {
|
||||
if (blockposition.getY() <= i) {
|
||||
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
|
||||
+ this.player.stopUsingItem(); // CraftBukkit - SPIGOT-4706
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
@@ -1190,6 +1592,7 @@
|
||||
@@ -1207,6 +1598,7 @@
|
||||
@Override
|
||||
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
||||
@ -700,7 +651,7 @@
|
||||
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
EnumHand enumhand = packetplayinblockplace.getHand();
|
||||
@@ -1204,6 +1607,47 @@
|
||||
@@ -1221,6 +1613,47 @@
|
||||
this.player.absRotateTo(f, f1);
|
||||
}
|
||||
|
||||
@ -747,17 +698,17 @@
|
||||
+ // CraftBukkit end
|
||||
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1224,7 +1668,7 @@
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
@@ -1245,7 +1678,7 @@
|
||||
Entity entity = packetplayinspectate.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
- this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
|
||||
+ this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
|
||||
- this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true);
|
||||
+ this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), Set.of(), entity.getYRot(), entity.getXRot(), true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1245,6 +1689,13 @@
|
||||
@@ -1266,6 +1699,13 @@
|
||||
|
||||
@Override
|
||||
public void onDisconnect(DisconnectionDetails disconnectiondetails) {
|
||||
@ -771,7 +722,7 @@
|
||||
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), disconnectiondetails.reason().getString());
|
||||
this.removePlayerFromWorld();
|
||||
super.onDisconnect(disconnectiondetails);
|
||||
@@ -1252,10 +1703,18 @@
|
||||
@@ -1273,10 +1713,18 @@
|
||||
|
||||
private void removePlayerFromWorld() {
|
||||
this.chatMessageChain.close();
|
||||
@ -791,7 +742,7 @@
|
||||
this.player.getTextFilter().leave();
|
||||
}
|
||||
|
||||
@@ -1270,7 +1729,16 @@
|
||||
@@ -1291,7 +1739,16 @@
|
||||
@Override
|
||||
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
||||
@ -808,7 +759,7 @@
|
||||
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.stopUsingItem();
|
||||
}
|
||||
@@ -1279,11 +1747,18 @@
|
||||
@@ -1300,11 +1757,18 @@
|
||||
this.player.resetLastActionTime();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
||||
@ -827,7 +778,7 @@
|
||||
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packetplayinchat.lastSeenMessages());
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
@@ -1297,7 +1772,7 @@
|
||||
@@ -1318,7 +1782,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -836,7 +787,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.server.getChatDecorator().decorate(this.player, playerchatmessage.decoratedContent());
|
||||
|
||||
this.chatMessageChain.append(completablefuture, (filteredtext) -> {
|
||||
@@ -1305,19 +1780,36 @@
|
||||
@@ -1326,19 +1790,36 @@
|
||||
|
||||
this.broadcastChatMessage(playerchatmessage1);
|
||||
});
|
||||
@ -875,7 +826,7 @@
|
||||
ParseResults<CommandListenerWrapper> parseresults = this.parseCommand(s);
|
||||
|
||||
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
|
||||
@@ -1334,19 +1826,37 @@
|
||||
@@ -1355,19 +1836,37 @@
|
||||
|
||||
if (!optional.isEmpty()) {
|
||||
this.tryHandleChat(serverboundchatcommandsignedpacket.command(), () -> {
|
||||
@ -916,7 +867,7 @@
|
||||
} catch (SignedMessageChain.a signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
@@ -1354,10 +1864,10 @@
|
||||
@@ -1375,10 +1874,10 @@
|
||||
|
||||
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
||||
|
||||
@ -929,7 +880,7 @@
|
||||
}
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
||||
@@ -1433,14 +1943,20 @@
|
||||
@@ -1454,14 +1953,20 @@
|
||||
return com_mojang_brigadier_commanddispatcher.parse(s, this.player.createCommandSourceStack());
|
||||
}
|
||||
|
||||
@ -953,7 +904,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1469,6 +1985,116 @@
|
||||
@@ -1490,6 +1995,116 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1070,7 +1021,7 @@
|
||||
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
||||
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
||||
|
||||
@@ -1476,13 +2102,33 @@
|
||||
@@ -1497,13 +2112,33 @@
|
||||
}
|
||||
|
||||
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
||||
@ -1098,16 +1049,16 @@
|
||||
}
|
||||
|
||||
private void detectRateSpam() {
|
||||
- this.chatSpamTickCount += 20;
|
||||
- if (this.chatSpamTickCount > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
- this.chatSpamThrottler.increment();
|
||||
- if (!this.chatSpamThrottler.isUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ // CraftBukkit start - replaced with thread safe throttle
|
||||
+ // this.chatSpamTickCount += 20;
|
||||
+ if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ // this.chatSpamThrottler.increment();
|
||||
+ if (!this.chatSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
|
||||
+ // CraftBukkit end
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("disconnect.spam"));
|
||||
}
|
||||
|
||||
@@ -1504,13 +2150,62 @@
|
||||
@@ -1525,13 +2160,62 @@
|
||||
@Override
|
||||
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
||||
@ -1170,7 +1121,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
Entity entity;
|
||||
|
||||
@@ -1587,6 +2282,12 @@
|
||||
@@ -1608,6 +2292,12 @@
|
||||
}
|
||||
|
||||
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
||||
@ -1183,7 +1134,7 @@
|
||||
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a));
|
||||
this.addPendingMessage(playerchatmessage);
|
||||
}
|
||||
@@ -1614,6 +2315,7 @@
|
||||
@@ -1635,6 +2325,7 @@
|
||||
@Override
|
||||
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
||||
@ -1191,9 +1142,9 @@
|
||||
final WorldServer worldserver = this.player.serverLevel();
|
||||
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
||||
|
||||
@@ -1628,13 +2330,51 @@
|
||||
@@ -1649,13 +2340,51 @@
|
||||
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 1.0D)) {
|
||||
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
|
||||
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
||||
- private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a) {
|
||||
+ private void performInteraction(EnumHand enumhand, PlayerConnection.a playerconnection_a, PlayerInteractEntityEvent event) { // CraftBukkit
|
||||
@ -1241,10 +1192,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (enuminteractionresult.consumesAction()) {
|
||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, enuminteractionresult.indicateItemUse() ? itemstack1 : ItemStack.EMPTY, entity);
|
||||
if (enuminteractionresult.shouldSwing()) {
|
||||
@@ -1647,19 +2387,20 @@
|
||||
if (enuminteractionresult instanceof EnumInteractionResult.d) {
|
||||
EnumInteractionResult.d enuminteractionresult_d = (EnumInteractionResult.d) enuminteractionresult;
|
||||
ItemStack itemstack2 = enuminteractionresult_d.wasItemInteraction() ? itemstack1 : ItemStack.EMPTY;
|
||||
@@ -1671,19 +2400,20 @@
|
||||
|
||||
@Override
|
||||
public void onInteraction(EnumHand enumhand) {
|
||||
@ -1268,7 +1219,7 @@
|
||||
label23:
|
||||
{
|
||||
if (entity instanceof EntityArrow) {
|
||||
@@ -1677,6 +2418,11 @@
|
||||
@@ -1701,6 +2431,11 @@
|
||||
}
|
||||
|
||||
PlayerConnection.this.player.attack(entity);
|
||||
@ -1280,28 +1231,30 @@
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1700,17 +2446,17 @@
|
||||
@@ -1724,7 +2459,7 @@
|
||||
case PERFORM_RESPAWN:
|
||||
if (this.player.wonGame) {
|
||||
this.player.wonGame = false;
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, true, Entity.RemovalReason.CHANGED_DIMENSION, RespawnReason.END_PORTAL); // CraftBukkit
|
||||
this.resetPosition();
|
||||
CriterionTriggers.CHANGED_DIMENSION.trigger(this.player, World.END, World.OVERWORLD);
|
||||
} else {
|
||||
if (this.player.getHealth() > 0.0F) {
|
||||
@@ -1732,11 +2467,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED);
|
||||
+ this.player = this.server.getPlayerList().respawn(this.player, false, Entity.RemovalReason.KILLED, RespawnReason.DEATH); // CraftBukkit
|
||||
this.resetPosition();
|
||||
if (this.server.isHardcore()) {
|
||||
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
||||
- ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
||||
+ ((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // CraftBukkit - per-world
|
||||
- ((GameRules.GameRuleBoolean) this.player.serverLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
||||
+ ((GameRules.GameRuleBoolean) this.player.serverLevel().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // CraftBukkit - per-world
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1723,15 +2469,21 @@
|
||||
@@ -1749,15 +2484,21 @@
|
||||
@Override
|
||||
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
||||
@ -1325,7 +1278,7 @@
|
||||
this.player.containerMenu.sendAllDataToRemote();
|
||||
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
@@ -1744,7 +2496,284 @@
|
||||
@@ -1770,7 +2511,284 @@
|
||||
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
@ -1611,28 +1564,30 @@
|
||||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1774,9 +2803,18 @@
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
||||
} else {
|
||||
- this.server.getRecipeManager().byKey(packetplayinautorecipe.getRecipe()).ifPresent((recipeholder) -> {
|
||||
- ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(packetplayinautorecipe.isShiftDown(), recipeholder, this.player);
|
||||
+ // CraftBukkit start - implement PlayerRecipeBookClickEvent
|
||||
+ org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(CraftNamespacedKey.fromMinecraft(packetplayinautorecipe.getRecipe()));
|
||||
+ if (recipe == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.isShiftDown());
|
||||
@@ -1816,7 +2834,21 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- ContainerRecipeBook.a containerrecipebook_a = containerrecipebook.handlePlacement(packetplayinautorecipe.useMaxItems(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
|
||||
+ // CraftBukkit start - implement PlayerRecipeBookClickEvent
|
||||
+ org.bukkit.inventory.Recipe recipe = recipeholder.toBukkitRecipe();
|
||||
+ if (recipe == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.useMaxItems());
|
||||
+
|
||||
+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
|
||||
+ this.server.getRecipeManager().byKey(CraftNamespacedKey.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).ifPresent((recipeholder) -> {
|
||||
+ ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(event.isShiftClick(), recipeholder, this.player);
|
||||
});
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1784,6 +2822,7 @@
|
||||
+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
|
||||
+ recipeholder = this.server.getRecipeManager().byKey(CraftRecipe.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).orElse(null);
|
||||
+ if (recipeholder == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ContainerRecipeBook.a containerrecipebook_a = containerrecipebook.handlePlacement(event.isShiftClick(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (containerrecipebook_a == ContainerRecipeBook.a.PLACE_GHOST_RECIPE) {
|
||||
this.player.connection.send(new PacketPlayOutAutoRecipe(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
|
||||
@@ -1832,6 +2864,7 @@
|
||||
@Override
|
||||
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
||||
@ -1640,7 +1595,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.containerId() && !this.player.isSpectator()) {
|
||||
if (!this.player.containerMenu.stillValid(this.player)) {
|
||||
@@ -1826,6 +2865,43 @@
|
||||
@@ -1875,6 +2908,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.slotNum() >= 1 && packetplayinsetcreativeslot.slotNum() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
|
||||
@ -1684,7 +1639,7 @@
|
||||
|
||||
if (flag1 && flag2) {
|
||||
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.slotNum()).setByPlayer(itemstack);
|
||||
@@ -1848,6 +2924,7 @@
|
||||
@@ -1902,6 +2972,7 @@
|
||||
}
|
||||
|
||||
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
||||
@ -1692,7 +1647,7 @@
|
||||
this.player.resetLastActionTime();
|
||||
WorldServer worldserver = this.player.serverLevel();
|
||||
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
||||
@@ -1869,7 +2946,17 @@
|
||||
@@ -1923,7 +2994,17 @@
|
||||
@Override
|
||||
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
||||
@ -1711,7 +1666,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1928,7 +3015,7 @@
|
||||
@@ -1982,7 +3063,7 @@
|
||||
if (!this.waitingForSwitchToConfig) {
|
||||
throw new IllegalStateException("Client acknowledged config, but none was requested");
|
||||
} else {
|
||||
@ -1720,7 +1675,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1953,8 +3040,10 @@
|
||||
@@ -2007,8 +3088,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
@ -1732,4 +1687,4 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
public void handleClientTickEnd(ServerboundClientTickEndPacket serverboundclienttickendpacket) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -28,8 +28,44 @@
|
||||
@@ -29,8 +29,44 @@
|
||||
import net.minecraft.util.thread.IAsyncTaskHandler;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final int LATENCY_CHECK_INTERVAL = 15000;
|
||||
private static final int CLOSED_LISTENER_TIMEOUT = 15000;
|
||||
@@ -46,12 +82,24 @@
|
||||
@@ -47,12 +83,24 @@
|
||||
private int latency;
|
||||
private volatile boolean suspendFlushingOnServerThread = false;
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
}
|
||||
|
||||
private void close() {
|
||||
@@ -73,6 +121,7 @@
|
||||
@@ -80,6 +128,7 @@
|
||||
|
||||
@Override
|
||||
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
|
||||
@ -80,7 +80,7 @@
|
||||
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
|
||||
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
||||
|
||||
@@ -87,8 +136,56 @@
|
||||
@@ -94,8 +143,56 @@
|
||||
@Override
|
||||
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
|
||||
@Override
|
||||
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
|
||||
@@ -97,11 +194,18 @@
|
||||
@@ -104,11 +201,18 @@
|
||||
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack {} rejection", this.playerProfile().getName(), serverboundresourcepackpacket.id());
|
||||
this.disconnect((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
@ -157,8 +157,8 @@
|
||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||
}
|
||||
|
||||
@@ -109,7 +213,7 @@
|
||||
this.server.getProfiler().push("keepAlive");
|
||||
@@ -116,7 +220,7 @@
|
||||
Profiler.get().push("keepAlive");
|
||||
long i = SystemUtils.getMillis();
|
||||
|
||||
- if (!this.isSingleplayerOwner() && i - this.keepAliveTime >= 15000L) {
|
||||
@ -166,7 +166,7 @@
|
||||
if (this.keepAlivePending) {
|
||||
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
|
||||
} else if (this.checkIfClosed(i)) {
|
||||
@@ -149,6 +253,14 @@
|
||||
@@ -156,6 +260,14 @@
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
||||
@ -181,7 +181,7 @@
|
||||
if (packet.isTerminal()) {
|
||||
this.close();
|
||||
}
|
||||
@@ -173,15 +285,61 @@
|
||||
@@ -180,15 +292,61 @@
|
||||
}
|
||||
|
||||
public void disconnect(DisconnectionDetails disconnectiondetails) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -103,6 +103,27 @@
|
||||
@@ -104,6 +104,27 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
public abstract class PlayerList {
|
||||
|
||||
public static final File USERBANLIST_FILE = new File("banned-players.json");
|
||||
@@ -115,14 +136,16 @@
|
||||
@@ -116,14 +137,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;
|
||||
@@ -133,13 +156,23 @@
|
||||
@@ -134,13 +157,23 @@
|
||||
private static final boolean ALLOW_LOGOUTIVATOR = false;
|
||||
private int sendAllPlayerInfoIn;
|
||||
|
||||
@ -74,7 +74,7 @@
|
||||
this.server = minecraftserver;
|
||||
this.registries = layeredregistryaccess;
|
||||
this.maxPlayers = i;
|
||||
@@ -149,25 +182,34 @@
|
||||
@@ -150,25 +183,34 @@
|
||||
public void placeNewPlayer(NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
|
||||
GameProfile gameprofile = entityplayer.getGameProfile();
|
||||
UserCache usercache = this.server.getProfileCache();
|
||||
@ -114,7 +114,7 @@
|
||||
WorldServer worldserver = this.server.getLevel(resourcekey);
|
||||
WorldServer worldserver1;
|
||||
|
||||
@@ -181,10 +223,11 @@
|
||||
@@ -182,10 +224,11 @@
|
||||
entityplayer.setServerLevel(worldserver1);
|
||||
String s1 = networkmanager.getLoggableAddress(this.server.logIPs());
|
||||
|
||||
@ -128,7 +128,7 @@
|
||||
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer, commonlistenercookie);
|
||||
|
||||
networkmanager.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
@@ -194,6 +237,7 @@
|
||||
@@ -195,6 +238,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()));
|
||||
@ -136,7 +136,7 @@
|
||||
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
|
||||
playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
|
||||
@@ -210,8 +254,10 @@
|
||||
@@ -213,8 +257,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
|
||||
}
|
||||
@ -148,7 +148,7 @@
|
||||
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
|
||||
ServerPing serverping = this.server.getStatus();
|
||||
|
||||
@@ -219,18 +265,70 @@
|
||||
@@ -222,17 +268,70 @@
|
||||
entityplayer.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@ -215,39 +215,15 @@
|
||||
+ worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it
|
||||
+ // CraftBukkit end
|
||||
this.sendActivePlayerEffects(entityplayer);
|
||||
if (optional.isPresent() && ((NBTTagCompound) optional.get()).contains("RootVehicle", 10)) {
|
||||
NBTTagCompound nbttagcompound = ((NBTTagCompound) optional.get()).getCompound("RootVehicle");
|
||||
+ WorldServer finalWorldServer = worldserver1; // CraftBukkit - decompile error
|
||||
Entity entity = EntityTypes.loadEntityRecursive(nbttagcompound.getCompound("Entity"), worldserver1, (entity1) -> {
|
||||
- return !worldserver1.addWithUUID(entity1) ? null : entity1;
|
||||
+ return !finalWorldServer.addWithUUID(entity1) ? null : entity1; // CraftBukkit - decompile error
|
||||
});
|
||||
|
||||
if (entity != null) {
|
||||
@@ -261,18 +359,20 @@
|
||||
|
||||
if (!entityplayer.isPassenger()) {
|
||||
PlayerList.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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entityplayer.loadAndSpawnEnderpearls(optional);
|
||||
entityplayer.loadAndSpawnParentVehicle(optional);
|
||||
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) {
|
||||
@@ -309,30 +409,31 @@
|
||||
@@ -269,30 +368,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(WorldServer worldserver) {
|
||||
@ -284,7 +260,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,14 +460,15 @@
|
||||
@@ -319,14 +419,15 @@
|
||||
}
|
||||
|
||||
protected void save(EntityPlayer entityplayer) {
|
||||
@ -302,7 +278,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -374,10 +476,24 @@
|
||||
@@ -334,10 +435,24 @@
|
||||
|
||||
}
|
||||
|
||||
@ -328,7 +304,7 @@
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -386,7 +502,7 @@
|
||||
@@ -346,7 +461,7 @@
|
||||
PlayerList.LOGGER.debug("Removing player mount");
|
||||
entityplayer.stopRiding();
|
||||
entity.getPassengersAndSelf().forEach((entity1) -> {
|
||||
@ -337,7 +313,16 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -401,17 +517,66 @@
|
||||
@@ -357,7 +472,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityEnderPearl entityenderpearl = (EntityEnderPearl) iterator.next();
|
||||
|
||||
- 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 @@
|
||||
|
||||
if (entityplayer1 == entityplayer) {
|
||||
this.playersByUUID.remove(uuid);
|
||||
@ -409,7 +394,7 @@
|
||||
if (this.bans.isBanned(gameprofile)) {
|
||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||
|
||||
@@ -420,9 +585,11 @@
|
||||
@@ -388,9 +552,11 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
||||
}
|
||||
|
||||
@ -423,7 +408,7 @@
|
||||
} else if (this.ipBans.isBanned(socketaddress)) {
|
||||
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||
|
||||
@@ -431,17 +598,32 @@
|
||||
@@ -399,17 +565,32 @@
|
||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
||||
}
|
||||
|
||||
@ -436,13 +421,13 @@
|
||||
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
|
||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ cserver.getPluginManager().callEvent(event);
|
||||
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
||||
+ loginlistener.disconnect(event.getKickMessage());
|
||||
+ return null;
|
||||
}
|
||||
+ }
|
||||
+ return entity;
|
||||
}
|
||||
|
||||
@ -461,7 +446,7 @@
|
||||
UUID uuid = gameprofile.getId();
|
||||
Set<EntityPlayer> set = Sets.newIdentityHashSet();
|
||||
Iterator iterator = this.players.iterator();
|
||||
@@ -469,22 +651,41 @@
|
||||
@@ -437,22 +618,41 @@
|
||||
}
|
||||
|
||||
return !set.isEmpty();
|
||||
@ -481,8 +466,8 @@
|
||||
this.players.remove(entityplayer);
|
||||
entityplayer.serverLevel().removePlayerImmediately(entityplayer, entity_removalreason);
|
||||
+ /* CraftBukkit start
|
||||
DimensionTransition dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING);
|
||||
WorldServer worldserver = dimensiontransition.newLevel();
|
||||
TeleportTransition teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING);
|
||||
WorldServer worldserver = teleporttransition.newLevel();
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver, entityplayer.getGameProfile(), entityplayer.clientInformation());
|
||||
+ // */
|
||||
+ EntityPlayer entityplayer1 = entityplayer;
|
||||
@ -496,7 +481,7 @@
|
||||
entityplayer1.setMainArm(entityplayer.getMainArm());
|
||||
+ // CraftBukkit - not required, just copies old location into reused entity
|
||||
+ /*
|
||||
if (!dimensiontransition.missingRespawnBlock()) {
|
||||
if (!teleporttransition.missingRespawnBlock()) {
|
||||
entityplayer1.copyRespawnPosition(entityplayer);
|
||||
}
|
||||
+ */
|
||||
@ -504,35 +489,35 @@
|
||||
|
||||
Iterator iterator = entityplayer.getTags().iterator();
|
||||
|
||||
@@ -494,11 +695,26 @@
|
||||
@@ -462,11 +662,26 @@
|
||||
entityplayer1.addTag(s);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - fire PlayerRespawnEvent
|
||||
+ DimensionTransition dimensiontransition;
|
||||
+ TeleportTransition teleporttransition;
|
||||
+ if (location == null) {
|
||||
+ dimensiontransition = entityplayer.findRespawnPositionAndUseSpawnBlock(flag, DimensionTransition.DO_NOTHING, reason);
|
||||
+ teleporttransition = entityplayer.findRespawnPositionAndUseSpawnBlock(!flag, TeleportTransition.DO_NOTHING, reason);
|
||||
+
|
||||
+ if (!flag) entityplayer.reset(); // SPIGOT-4785
|
||||
+ } else {
|
||||
+ dimensiontransition = new DimensionTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), DimensionTransition.DO_NOTHING);
|
||||
+ teleporttransition = new TeleportTransition(((CraftWorld) location.getWorld()).getHandle(), CraftLocation.toVec3D(location), Vec3D.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING);
|
||||
+ }
|
||||
+ WorldServer worldserver = dimensiontransition.newLevel();
|
||||
+ WorldServer worldserver = teleporttransition.newLevel();
|
||||
+ entityplayer1.spawnIn(worldserver);
|
||||
+ entityplayer1.unsetRemoved();
|
||||
+ entityplayer1.setShiftKeyDown(false);
|
||||
Vec3D vec3d = dimensiontransition.pos();
|
||||
Vec3D vec3d = teleporttransition.position();
|
||||
|
||||
- entityplayer1.moveTo(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
- entityplayer1.moveTo(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 (dimensiontransition.missingRespawnBlock()) {
|
||||
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
|
||||
}
|
||||
|
||||
int i = flag ? 1 : 0;
|
||||
@@ -506,17 +722,19 @@
|
||||
@@ -474,17 +689,19 @@
|
||||
WorldData worlddata = worldserver1.getLevelData();
|
||||
|
||||
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver1), (byte) i));
|
||||
@ -555,9 +540,9 @@
|
||||
+ }
|
||||
+ // entityplayer1.initInventoryMenu();
|
||||
entityplayer1.setHealth(entityplayer1.getHealth());
|
||||
if (!flag) {
|
||||
BlockPosition blockposition = BlockPosition.containing(dimensiontransition.pos());
|
||||
@@ -526,6 +744,27 @@
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@ -585,7 +570,7 @@
|
||||
|
||||
return entityplayer1;
|
||||
}
|
||||
@@ -554,7 +793,18 @@
|
||||
@@ -524,7 +762,18 @@
|
||||
|
||||
public void tick() {
|
||||
if (++this.sendAllPlayerInfoIn > 600) {
|
||||
@ -605,7 +590,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -571,6 +821,25 @@
|
||||
@@ -541,6 +790,25 @@
|
||||
|
||||
}
|
||||
|
||||
@ -631,7 +616,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -649,7 +918,7 @@
|
||||
@@ -619,7 +887,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile gameprofile) {
|
||||
@ -640,7 +625,7 @@
|
||||
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -673,6 +942,7 @@
|
||||
@@ -643,6 +911,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
|
||||
}
|
||||
|
||||
@ -648,7 +633,7 @@
|
||||
this.server.getCommands().sendCommands(entityplayer);
|
||||
}
|
||||
|
||||
@@ -703,6 +973,12 @@
|
||||
@@ -673,6 +942,12 @@
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
|
||||
|
||||
@ -661,7 +646,7 @@
|
||||
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
|
||||
double d4 = d0 - entityplayer.getX();
|
||||
double d5 = d1 - entityplayer.getY();
|
||||
@@ -742,15 +1018,19 @@
|
||||
@@ -712,15 +987,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
|
||||
@ -685,7 +670,7 @@
|
||||
}
|
||||
|
||||
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -759,8 +1039,16 @@
|
||||
@@ -729,8 +1008,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(EntityPlayer entityplayer) {
|
||||
entityplayer.inventoryMenu.sendAllDataToRemote();
|
||||
@ -695,15 +680,15 @@
|
||||
+ entityplayer.refreshEntityData(entityplayer); // CraftBukkkit - SPIGOT-7218: sync metadata
|
||||
entityplayer.connection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
|
||||
+ // CraftBukkit start - from GameRules
|
||||
+ int i = entityplayer.level().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23;
|
||||
+ int i = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23;
|
||||
+ entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
|
||||
+ float immediateRespawn = entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
|
||||
+ float immediateRespawn = entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
|
||||
+ entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.IMMEDIATE_RESPAWN, immediateRespawn));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -816,12 +1104,22 @@
|
||||
@@ -786,12 +1073,22 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@ -728,7 +713,7 @@
|
||||
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
|
||||
return ichatbasecomponent;
|
||||
@@ -879,16 +1177,23 @@
|
||||
@@ -849,16 +1146,23 @@
|
||||
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@ -756,7 +741,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -897,7 +1202,7 @@
|
||||
@@ -867,7 +1171,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
|
||||
@ -765,7 +750,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -905,13 +1210,13 @@
|
||||
@@ -875,13 +1179,13 @@
|
||||
|
||||
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
|
||||
UUID uuid = entityplayer.getUUID();
|
||||
@ -781,7 +766,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(entityplayer);
|
||||
@@ -962,13 +1267,20 @@
|
||||
@@ -932,13 +1236,20 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
@ -802,4 +787,4 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
|
||||
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getOrderedRecipes());
|
||||
CraftingManager craftingmanager = this.server.getRecipeManager();
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/stats/RecipeBookServer.java
|
||||
+++ b/net/minecraft/stats/RecipeBookServer.java
|
||||
@@ -20,6 +20,8 @@
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
@@ -29,6 +29,8 @@
|
||||
import net.minecraft.world.item.crafting.display.RecipeDisplayId;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
@ -9,20 +9,30 @@
|
||||
public class RecipeBookServer extends RecipeBook {
|
||||
|
||||
public static final String RECIPE_BOOK_TAG = "recipeBook";
|
||||
@@ -36,7 +38,7 @@
|
||||
@@ -72,7 +74,7 @@
|
||||
RecipeHolder<?> recipeholder = (RecipeHolder) iterator.next();
|
||||
MinecraftKey minecraftkey = recipeholder.id();
|
||||
ResourceKey<IRecipe<?>> resourcekey = recipeholder.id();
|
||||
|
||||
- if (!this.known.contains(minecraftkey) && !recipeholder.value().isSpecial()) {
|
||||
+ if (!this.known.contains(minecraftkey) && !recipeholder.value().isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit
|
||||
this.add(minecraftkey);
|
||||
this.addHighlight(minecraftkey);
|
||||
list.add(minecraftkey);
|
||||
@@ -73,6 +75,7 @@
|
||||
}
|
||||
- if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial()) {
|
||||
+ if (!this.known.contains(resourcekey) && !recipeholder.value().isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, resourcekey.location())) { // CraftBukkit
|
||||
this.add(resourcekey);
|
||||
this.addHighlight(resourcekey);
|
||||
this.displayResolver.displaysForRecipe(resourcekey, (recipedisplayentry) -> {
|
||||
@@ -82,7 +84,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRecipes(PacketPlayOutRecipes.Action packetplayoutrecipes_action, EntityPlayer entityplayer, List<MinecraftKey> list) {
|
||||
+ if (entityplayer.connection == null) return; // SPIGOT-4478 during PlayerLoginEvent
|
||||
entityplayer.connection.send(new PacketPlayOutRecipes(packetplayoutrecipes_action, list, Collections.emptyList(), this.getBookSettings()));
|
||||
}
|
||||
- if (!list.isEmpty()) {
|
||||
+ if (!list.isEmpty() && entityplayer.connection != null) { // SPIGOT-4478 during PlayerLoginEvent
|
||||
entityplayer.connection.send(new ClientboundRecipeBookAddPacket(list, false));
|
||||
}
|
||||
|
||||
@@ -105,7 +107,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
+ if (!list.isEmpty() && entityplayer.connection != null) { // SPIGOT-4478 during PlayerLoginEvent
|
||||
entityplayer.connection.send(new ClientboundRecipeBookRemovePacket(list));
|
||||
}
|
||||
|
||||
|
@ -1,27 +1,27 @@
|
||||
--- a/net/minecraft/util/SpawnUtil.java
|
||||
+++ b/net/minecraft/util/SpawnUtil.java
|
||||
@@ -20,6 +20,12 @@
|
||||
@@ -21,6 +21,12 @@
|
||||
public SpawnUtil() {}
|
||||
|
||||
public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EnumMobSpawn enummobspawn, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) {
|
||||
public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a) {
|
||||
+ // CraftBukkit start
|
||||
+ return trySpawnMob(entitytypes, enummobspawn, worldserver, blockposition, i, j, k, spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return trySpawnMob(entitytypes, entityspawnreason, worldserver, blockposition, i, j, k, spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EnumMobSpawn enummobspawn, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ public static <T extends EntityInsentient> Optional<T> trySpawnMob(EntityTypes<T> entitytypes, EntitySpawnReason entityspawnreason, WorldServer worldserver, BlockPosition blockposition, int i, int j, int k, SpawnUtil.a spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable();
|
||||
|
||||
for (int l = 0; l < i; ++l) {
|
||||
@@ -28,15 +34,15 @@
|
||||
@@ -29,15 +35,15 @@
|
||||
|
||||
blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1);
|
||||
if (worldserver.getWorldBorder().isWithinBounds((BlockPosition) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) {
|
||||
- T t0 = (EntityInsentient) entitytypes.create(worldserver, (Consumer) null, blockposition_mutableblockposition, enummobspawn, false, false);
|
||||
+ T t0 = entitytypes.create(worldserver, (Consumer<T>) null, blockposition_mutableblockposition, enummobspawn, false, false); // CraftBukkit - decompile error
|
||||
- T t0 = (EntityInsentient) 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) {
|
||||
if (t0.checkSpawnRules(worldserver, enummobspawn) && t0.checkSpawnObstruction(worldserver)) {
|
||||
if (t0.checkSpawnRules(worldserver, entityspawnreason) && t0.checkSpawnObstruction(worldserver)) {
|
||||
- worldserver.addFreshEntityWithPassengers(t0);
|
||||
+ worldserver.addFreshEntityWithPassengers(t0, reason); // CraftBukkit
|
||||
return Optional.of(t0);
|
||||
|
53
paper-server/nms-patches/net/minecraft/util/TickThrottler.patch
Normale Datei
53
paper-server/nms-patches/net/minecraft/util/TickThrottler.patch
Normale Datei
@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/util/TickThrottler.java
|
||||
+++ b/net/minecraft/util/TickThrottler.java
|
||||
@@ -1,10 +1,14 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.concurrent.atomic.AtomicInteger;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TickThrottler {
|
||||
|
||||
private final int incrementStep;
|
||||
private final int threshold;
|
||||
- private int count;
|
||||
+ private final AtomicInteger count = new AtomicInteger(); // CraftBukkit - multithreaded field
|
||||
|
||||
public TickThrottler(int i, int j) {
|
||||
this.incrementStep = i;
|
||||
@@ -12,17 +16,32 @@
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
- this.count += this.incrementStep;
|
||||
+ this.count.addAndGet(this.incrementStep); // CraftBukkit - use thread-safe field access instead
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
+ // CraftBukkit start
|
||||
+ for (int val; (val = this.count.get()) > 0 && !count.compareAndSet(val, val - 1); ) ;
|
||||
+ /* Use thread-safe field access instead
|
||||
if (this.count > 0) {
|
||||
--this.count;
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
public boolean isUnderThreshold() {
|
||||
- return this.count < this.threshold;
|
||||
+ // CraftBukkit start - use thread-safe field access instead
|
||||
+ return this.count.get() < this.threshold;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isIncrementAndUnderThreshold() {
|
||||
+ return isIncrementAndUnderThreshold(this.incrementStep, this.threshold);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isIncrementAndUnderThreshold(int incrementStep, int threshold) {
|
||||
+ return this.count.addAndGet(incrementStep) < threshold;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
@@ -495,6 +495,18 @@
|
||||
@@ -510,6 +510,18 @@
|
||||
datafixerbuilder.addFixer(new DataConverterItemFrame(schema44, false));
|
||||
Schema schema45 = datafixerbuilder.addSchema(1458, DataConverterRegistry.SAME_NAMESPACED);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameEntity(schema45, false));
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameItem(schema45, false));
|
||||
datafixerbuilder.addFixer(new DataConverterCustomNameTile(schema45, false));
|
||||
@@ -753,7 +765,8 @@
|
||||
@@ -768,7 +780,8 @@
|
||||
datafixerbuilder.addFixer(new DataConverterAddChoices(schema110, "Added Zoglin", DataConverterTypes.ENTITY));
|
||||
Schema schema111 = datafixerbuilder.addSchema(2523, DataConverterRegistry.SAME_NAMESPACED);
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
Schema schema112 = datafixerbuilder.addSchema(2527, DataConverterRegistry.SAME_NAMESPACED);
|
||||
|
||||
datafixerbuilder.addFixer(new DataConverterBitStorageAlign(schema112));
|
||||
@@ -816,12 +829,14 @@
|
||||
@@ -831,12 +844,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);
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
datafixerbuilder.addFixer(DataConverterItemName.create(schema132, "Rename copper item suffixes", createRenamer(immutablemap1)));
|
||||
datafixerbuilder.addFixer(DataConverterBlockRename.create(schema132, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
|
||||
@@ -829,7 +844,8 @@
|
||||
@@ -844,7 +859,8 @@
|
||||
|
||||
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema133, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
|
||||
Schema schema134 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
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)));
|
||||
@@ -916,10 +932,11 @@
|
||||
@@ -931,10 +947,11 @@
|
||||
datafixerbuilder.addFixer(new DataConverterAddChoices(schema159, "Added Allay", DataConverterTypes.ENTITY));
|
||||
Schema schema160 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED);
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
int2objectopenhashmap1.defaultReturnValue("minecraft:tabby");
|
||||
int2objectopenhashmap1.put(0, "minecraft:tabby");
|
||||
int2objectopenhashmap1.put(1, "minecraft:black");
|
||||
@@ -936,7 +953,8 @@
|
||||
@@ -951,7 +968,8 @@
|
||||
|
||||
Objects.requireNonNull(int2objectopenhashmap);
|
||||
datafixerbuilder.addFixer(new EntityVariantFix(schema161, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get));
|
||||
|
@ -1,18 +1,18 @@
|
||||
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
|
||||
@@ -81,7 +81,7 @@
|
||||
@@ -80,7 +80,7 @@
|
||||
|
||||
public WorldUpgrader(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, IRegistryCustom iregistrycustom, boolean flag, boolean flag1) {
|
||||
this.dimensions = iregistrycustom.registryOrThrow(Registries.LEVEL_STEM);
|
||||
this.dimensions = iregistrycustom.lookupOrThrow(Registries.LEVEL_STEM);
|
||||
- this.levels = (Set) this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet());
|
||||
+ this.levels = (Set) 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;
|
||||
@@ -194,9 +194,9 @@
|
||||
@@ -197,9 +197,9 @@
|
||||
if (nbttagcompound != null) {
|
||||
int i = IChunkLoader.getVersion(nbttagcompound);
|
||||
ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getOrThrow(Registries.levelToLevelStem(resourcekey))).generator();
|
||||
ChunkGenerator chunkgenerator = ((WorldDimension) WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(resourcekey))).generator();
|
||||
- NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(resourcekey, () -> {
|
||||
+ NBTTagCompound nbttagcompound1 = ichunkloader.upgradeChunkTag(Registries.levelToLevelStem(resourcekey), () -> { // CraftBukkit
|
||||
return WorldUpgrader.this.overworldDataStorage;
|
||||
@ -21,7 +21,7 @@
|
||||
ChunkCoordIntPair chunkcoordintpair1 = new ChunkCoordIntPair(nbttagcompound1.getInt("xPos"), nbttagcompound1.getInt("zPos"));
|
||||
|
||||
if (!chunkcoordintpair1.equals(chunkcoordintpair)) {
|
||||
@@ -316,7 +316,7 @@
|
||||
@@ -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;
|
||||
|
@ -1,35 +0,0 @@
|
||||
--- a/net/minecraft/world/ChestLock.java
|
||||
+++ b/net/minecraft/world/ChestLock.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.ChatColor;
|
||||
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record ChestLock(String key) {
|
||||
|
||||
public static final ChestLock NO_LOCK = new ChestLock("");
|
||||
@@ -18,7 +23,19 @@
|
||||
} else {
|
||||
IChatBaseComponent ichatbasecomponent = (IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME);
|
||||
|
||||
- return ichatbasecomponent != null && this.key.equals(ichatbasecomponent.getString());
|
||||
+ // CraftBukkit start - SPIGOT-6307: Check for color codes if the lock contains color codes
|
||||
+ if (this.key.isEmpty()) return true;
|
||||
+ if (ichatbasecomponent != null) {
|
||||
+ if (this.key.indexOf(ChatColor.COLOR_CHAR) == -1) {
|
||||
+ // The lock key contains no color codes, so let's ignore colors in the item display name (vanilla Minecraft behavior):
|
||||
+ return this.key.equals(ichatbasecomponent.getString());
|
||||
+ } else {
|
||||
+ // The lock key contains color codes, so let's take them into account:
|
||||
+ return this.key.equals(CraftChatMessage.fromComponent(ichatbasecomponent));
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/damagesource/DamageSources.java
|
||||
+++ b/net/minecraft/world/damagesource/DamageSources.java
|
||||
@@ -42,9 +42,15 @@
|
||||
@@ -43,9 +43,15 @@
|
||||
private final DamageSource stalagmite;
|
||||
private final DamageSource outsideBorder;
|
||||
private final DamageSource genericKill;
|
||||
@ -9,15 +9,15 @@
|
||||
+ private final DamageSource poison;
|
||||
|
||||
public DamageSources(IRegistryCustom iregistrycustom) {
|
||||
this.damageTypes = iregistrycustom.registryOrThrow(Registries.DAMAGE_TYPE);
|
||||
this.damageTypes = iregistrycustom.lookupOrThrow(Registries.DAMAGE_TYPE);
|
||||
+ this.melting = this.source(DamageTypes.ON_FIRE).melting();
|
||||
+ this.poison = this.source(DamageTypes.MAGIC).poison();
|
||||
+ // CraftBukkit end
|
||||
this.inFire = this.source(DamageTypes.IN_FIRE);
|
||||
this.campfire = this.source(DamageTypes.CAMPFIRE);
|
||||
this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT);
|
||||
@@ -83,6 +89,16 @@
|
||||
return new DamageSource(this.damageTypes.getHolderOrThrow(resourcekey), entity, entity1);
|
||||
@@ -85,6 +91,16 @@
|
||||
return new DamageSource(this.damageTypes.getOrThrow(resourcekey), entity, entity1);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -33,7 +33,7 @@
|
||||
public DamageSource inFire() {
|
||||
return this.inFire;
|
||||
}
|
||||
@@ -248,7 +264,13 @@
|
||||
@@ -254,7 +270,13 @@
|
||||
}
|
||||
|
||||
public DamageSource explosion(@Nullable Entity entity, @Nullable Entity entity1) {
|
||||
@ -48,17 +48,17 @@
|
||||
}
|
||||
|
||||
public DamageSource sonicBoom(Entity entity) {
|
||||
@@ -256,7 +278,13 @@
|
||||
@@ -262,7 +284,13 @@
|
||||
}
|
||||
|
||||
public DamageSource badRespawnPointExplosion(Vec3D vec3d) {
|
||||
- return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d);
|
||||
- return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d);
|
||||
+ // CraftBukkit start
|
||||
+ return badRespawnPointExplosion(vec3d, null);
|
||||
+ }
|
||||
+
|
||||
+ public DamageSource badRespawnPointExplosion(Vec3D vec3d, org.bukkit.block.BlockState blockState) {
|
||||
+ return new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState);
|
||||
+ return new DamageSource(this.damageTypes.getOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d).directBlockState(blockState);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
--- a/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||
@@ -16,7 +16,7 @@
|
||||
@@ -17,7 +17,7 @@
|
||||
@Override
|
||||
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
||||
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
||||
if (this.isHarm == entityliving.isInvertedHealAndHarm()) {
|
||||
- entityliving.heal((float) Math.max(4 << i, 0));
|
||||
+ entityliving.heal((float) Math.max(4 << i, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
||||
} else {
|
||||
entityliving.hurt(entityliving.damageSources().magic(), (float) (6 << i));
|
||||
entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), (float) (6 << i));
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
if (this.isHarm == entityliving.isInvertedHealAndHarm()) {
|
||||
j = (int) (d0 * (double) (4 << i) + 0.5D);
|
||||
|
@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/effect/HungerMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/HungerMobEffect.java
|
||||
@@ -12,7 +12,7 @@
|
||||
@@ -13,7 +13,7 @@
|
||||
@Override
|
||||
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
||||
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
||||
if (entityliving instanceof EntityHuman entityhuman) {
|
||||
- entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1));
|
||||
+ entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
|
||||
|
@ -1,12 +1,12 @@
|
||||
--- a/net/minecraft/world/effect/InfestedMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/InfestedMobEffect.java
|
||||
@@ -47,7 +47,11 @@
|
||||
@@ -48,7 +48,11 @@
|
||||
|
||||
entitysilverfish.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F);
|
||||
entitysilverfish.moveTo(d0, d1, d2, worldserver.getRandom().nextFloat() * 360.0F, 0.0F);
|
||||
entitysilverfish.setDeltaMovement(new Vec3D(vector3f));
|
||||
- world.addFreshEntity(entitysilverfish);
|
||||
- worldserver.addFreshEntity(entitysilverfish);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addFreshEntity(entitysilverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) {
|
||||
+ if (!worldserver.addFreshEntity(entitysilverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/effect/OozingMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/OozingMobEffect.java
|
||||
@@ -51,7 +51,7 @@
|
||||
@@ -52,7 +52,7 @@
|
||||
if (entityslime != null) {
|
||||
entityslime.setSize(2, true);
|
||||
entityslime.moveTo(d0, d1, d2, world.getRandom().nextFloat() * 360.0F, 0.0F);
|
||||
|
@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/effect/PoisonMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/PoisonMobEffect.java
|
||||
@@ -11,7 +11,7 @@
|
||||
@@ -12,7 +12,7 @@
|
||||
@Override
|
||||
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
||||
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
||||
if (entityliving.getHealth() > 1.0F) {
|
||||
- entityliving.hurt(entityliving.damageSources().magic(), 1.0F);
|
||||
+ entityliving.hurt(entityliving.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
||||
- entityliving.hurtServer(worldserver, entityliving.damageSources().magic(), 1.0F);
|
||||
+ entityliving.hurtServer(worldserver, entityliving.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/effect/RegenerationMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/RegenerationMobEffect.java
|
||||
@@ -11,7 +11,7 @@
|
||||
@@ -12,7 +12,7 @@
|
||||
@Override
|
||||
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
||||
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
||||
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
|
||||
- entityliving.heal(1.0F);
|
||||
+ entityliving.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
||||
@@ -3,6 +3,11 @@
|
||||
@@ -4,6 +4,11 @@
|
||||
import net.minecraft.world.entity.EntityLiving;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
class SaturationMobEffect extends InstantMobEffect {
|
||||
|
||||
protected SaturationMobEffect(MobEffectInfo mobeffectinfo, int i) {
|
||||
@@ -12,7 +17,15 @@
|
||||
@@ -13,7 +18,15 @@
|
||||
@Override
|
||||
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
||||
if (!entityliving.level().isClientSide && entityliving instanceof EntityHuman entityhuman) {
|
||||
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
||||
if (entityliving instanceof EntityHuman entityhuman) {
|
||||
- entityhuman.getFoodData().eat(i + 1, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
||||
|
@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/world/entity/ConversionType.java
|
||||
+++ b/net/minecraft/world/entity/ConversionType.java
|
||||
@@ -12,6 +12,11 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.BlockPosition;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public enum ConversionType {
|
||||
|
||||
SINGLE(true) {
|
||||
@@ -31,7 +36,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
entity1 = (Entity) iterator.next();
|
||||
entity1.stopRiding();
|
||||
- entity1.remove(Entity.RemovalReason.DISCARDED);
|
||||
+ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
entity.startRiding(entityinsentient1);
|
||||
@@ -64,7 +69,7 @@
|
||||
entityinsentient1.hurtTime = entityinsentient.hurtTime;
|
||||
entityinsentient1.yBodyRot = entityinsentient.yBodyRot;
|
||||
entityinsentient1.setOnGround(entityinsentient.onGround());
|
||||
- Optional optional = entityinsentient.getSleepingPos();
|
||||
+ Optional<BlockPosition> optional = entityinsentient.getSleepingPos(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(entityinsentient1);
|
||||
optional.ifPresent(entityinsentient1::setSleepingPos);
|
||||
@@ -156,7 +161,7 @@
|
||||
entityinsentient1.setNoGravity(entityinsentient.isNoGravity());
|
||||
entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown());
|
||||
entityinsentient1.setSilent(entityinsentient.isSilent());
|
||||
- Set set = entityinsentient.getTags();
|
||||
+ Set<String> set = entityinsentient.getTags(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(entityinsentient1);
|
||||
set.forEach(entityinsentient1::addTag);
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -131,8 +131,72 @@
|
||||
@@ -139,8 +139,67 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeamBase;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ICommandListener, ScoreHolder {
|
||||
public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private static final int CURRENT_LEVEL = 2;
|
||||
@ -59,11 +59,6 @@
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ public int getDefaultMaxAirSupply() {
|
||||
+ return TOTAL_AIR_SUPPLY;
|
||||
@ -73,10 +68,10 @@
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String ID_TAG = "id";
|
||||
public static final String PASSENGERS_TAG = "Passengers";
|
||||
@@ -245,6 +309,30 @@
|
||||
public boolean hasVisualFire;
|
||||
@Nullable
|
||||
private IBlockData inBlockState;
|
||||
@@ -253,6 +312,30 @@
|
||||
private final List<Entity.b> movementThisTick;
|
||||
private final Set<IBlockData> blocksInside;
|
||||
private final LongSet visitedBlocks;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean forceDrops;
|
||||
+ public boolean persist = true;
|
||||
@ -104,10 +99,10 @@
|
||||
|
||||
public Entity(EntityTypes<?> entitytypes, World world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
@@ -351,12 +439,18 @@
|
||||
@@ -362,12 +445,18 @@
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
public void kill(WorldServer worldserver) {
|
||||
- this.remove(Entity.RemovalReason.KILLED);
|
||||
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
@ -125,7 +120,7 @@
|
||||
}
|
||||
|
||||
protected abstract void defineSynchedData(DataWatcher.a datawatcher_a);
|
||||
@@ -365,6 +459,16 @@
|
||||
@@ -376,6 +465,16 @@
|
||||
return this.entityData;
|
||||
}
|
||||
|
||||
@ -142,7 +137,7 @@
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof Entity ? ((Entity) object).id == this.id : false;
|
||||
}
|
||||
@@ -374,12 +478,24 @@
|
||||
@@ -385,7 +484,13 @@
|
||||
}
|
||||
|
||||
public void remove(Entity.RemovalReason entity_removalreason) {
|
||||
@ -157,6 +152,8 @@
|
||||
}
|
||||
|
||||
public void onClientRemoval() {}
|
||||
@@ -393,6 +498,12 @@
|
||||
public void onRemoval(Entity.RemovalReason entity_removalreason) {}
|
||||
|
||||
public void setPose(EntityPose entitypose) {
|
||||
+ // CraftBukkit start
|
||||
@ -168,7 +165,7 @@
|
||||
this.entityData.set(Entity.DATA_POSE, entitypose);
|
||||
}
|
||||
|
||||
@@ -404,6 +520,33 @@
|
||||
@@ -417,6 +528,33 @@
|
||||
}
|
||||
|
||||
protected void setRot(float f, float f1) {
|
||||
@ -202,7 +199,7 @@
|
||||
this.setYRot(f % 360.0F);
|
||||
this.setXRot(f1 % 360.0F);
|
||||
}
|
||||
@@ -445,6 +588,15 @@
|
||||
@@ -458,6 +596,15 @@
|
||||
this.baseTick();
|
||||
}
|
||||
|
||||
@ -216,18 +213,18 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void baseTick() {
|
||||
this.level().getProfiler().push("entityBaseTick");
|
||||
this.inBlockState = null;
|
||||
@@ -459,7 +611,7 @@
|
||||
this.walkDistO = this.walkDist;
|
||||
this.xRotO = this.getXRot();
|
||||
this.yRotO = this.getYRot();
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
@@ -471,7 +618,7 @@
|
||||
--this.boardingCooldown;
|
||||
}
|
||||
|
||||
- this.handlePortal();
|
||||
+ if (this instanceof EntityPlayer) this.handlePortal(); // CraftBukkit - // Moved up to postTick
|
||||
if (this.canSpawnSprintParticle()) {
|
||||
this.spawnSprintParticle();
|
||||
}
|
||||
@@ -494,6 +646,10 @@
|
||||
@@ -510,6 +657,10 @@
|
||||
if (this.isInLava()) {
|
||||
this.lavaHurt();
|
||||
this.fallDistance *= 0.5F;
|
||||
@ -238,21 +235,20 @@
|
||||
}
|
||||
|
||||
this.checkBelowWorld();
|
||||
@@ -503,7 +659,7 @@
|
||||
|
||||
this.firstTick = false;
|
||||
if (!this.level().isClientSide && this instanceof Leashable) {
|
||||
- Leashable.tickLeash((Entity) ((Leashable) this));
|
||||
+ Leashable.tickLeash((Entity & Leashable) this); // CraftBukkit - decompile error
|
||||
@@ -521,7 +672,7 @@
|
||||
world = this.level();
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (this instanceof Leashable) {
|
||||
- Leashable.tickLeash(worldserver, (Entity) ((Leashable) this));
|
||||
+ Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
this.level().getProfiler().pop();
|
||||
@@ -545,15 +701,47 @@
|
||||
@@ -564,15 +715,32 @@
|
||||
|
||||
public void lavaHurt() {
|
||||
if (!this.fireImmune()) {
|
||||
- this.igniteForSeconds(15.0F);
|
||||
- if (this.hurt(this.damageSources().lava(), 4.0F)) {
|
||||
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
|
||||
+ if (this instanceof EntityLiving && remainingFireTicks <= 0) {
|
||||
+ // not on fire yet
|
||||
@ -268,13 +264,22 @@
|
||||
+ // This will be called every single tick the entity is in lava, so don't throw an event
|
||||
+ this.igniteForSeconds(15.0F, false);
|
||||
+ }
|
||||
+
|
||||
+ if (this.hurt(this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F)) {
|
||||
this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
|
||||
+ // CraftBukkit end
|
||||
World world = this.level();
|
||||
|
||||
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);
|
||||
}
|
||||
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
||||
}
|
||||
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
||||
|
||||
}
|
||||
@@ -583,6 +751,22 @@
|
||||
}
|
||||
|
||||
public final void igniteForSeconds(float f) {
|
||||
@ -297,7 +302,7 @@
|
||||
this.igniteForTicks(MathHelper.floor(f * 20.0F));
|
||||
}
|
||||
|
||||
@@ -577,7 +765,7 @@
|
||||
@@ -606,7 +790,7 @@
|
||||
}
|
||||
|
||||
protected void onBelowWorld() {
|
||||
@ -306,8 +311,8 @@
|
||||
}
|
||||
|
||||
public boolean isFree(double d0, double d1, double d2) {
|
||||
@@ -702,6 +890,28 @@
|
||||
block.updateEntityAfterFallOn(this.level(), this);
|
||||
@@ -739,6 +923,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@ -332,10 +337,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.onGround()) {
|
||||
block.stepOn(this.level(), blockposition, iblockdata, this);
|
||||
}
|
||||
@@ -1073,6 +1283,20 @@
|
||||
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
|
||||
Entity.MovementEmission entity_movementemission = this.getMovementEmission();
|
||||
|
||||
@@ -1120,6 +1326,20 @@
|
||||
return SoundEffects.GENERIC_SPLASH;
|
||||
}
|
||||
|
||||
@ -353,10 +358,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected void checkInsideBlocks() {
|
||||
AxisAlignedBB axisalignedbb = this.getBoundingBox();
|
||||
BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D);
|
||||
@@ -1512,6 +1736,7 @@
|
||||
public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) {
|
||||
this.movementThisTick.add(new Entity.b(vec3d, vec3d1));
|
||||
}
|
||||
@@ -1586,6 +1806,7 @@
|
||||
this.yo = d1;
|
||||
this.zo = d4;
|
||||
this.setPos(d3, d1, d4);
|
||||
@ -364,7 +369,7 @@
|
||||
}
|
||||
|
||||
public void moveTo(Vec3D vec3d) {
|
||||
@@ -1718,6 +1943,12 @@
|
||||
@@ -1838,6 +2059,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -377,7 +382,7 @@
|
||||
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
|
||||
@@ -1746,16 +1977,22 @@
|
||||
@@ -1866,16 +2093,22 @@
|
||||
}
|
||||
|
||||
public boolean saveAsPassenger(NBTTagCompound nbttagcompound) {
|
||||
@ -402,7 +407,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1766,16 +2003,38 @@
|
||||
@@ -1886,16 +2119,38 @@
|
||||
}
|
||||
|
||||
public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) {
|
||||
@ -445,7 +450,7 @@
|
||||
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
|
||||
nbttagcompound.putFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
|
||||
@@ -1783,7 +2042,28 @@
|
||||
@@ -1903,7 +2158,28 @@
|
||||
nbttagcompound.putBoolean("OnGround", this.onGround());
|
||||
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
|
||||
@ -475,7 +480,7 @@
|
||||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1832,7 +2112,7 @@
|
||||
@@ -1952,7 +2228,7 @@
|
||||
nbttagcompound.put("Tags", nbttaglist);
|
||||
}
|
||||
|
||||
@ -484,7 +489,7 @@
|
||||
if (this.isVehicle()) {
|
||||
nbttaglist = new NBTTagList();
|
||||
iterator = this.getPassengers().iterator();
|
||||
@@ -1841,7 +2121,7 @@
|
||||
@@ -1961,7 +2237,7 @@
|
||||
Entity entity = (Entity) iterator.next();
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
|
||||
@ -493,7 +498,7 @@
|
||||
nbttaglist.add(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
@@ -1851,6 +2131,11 @@
|
||||
@@ -1971,6 +2247,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +510,7 @@
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -1934,6 +2219,45 @@
|
||||
@@ -2055,6 +2336,45 @@
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid position");
|
||||
}
|
||||
@ -551,7 +556,7 @@
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
||||
@@ -1955,6 +2279,12 @@
|
||||
@@ -2076,6 +2396,12 @@
|
||||
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
|
||||
}
|
||||
|
||||
@ -564,8 +569,8 @@
|
||||
protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound);
|
||||
|
||||
protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound);
|
||||
@@ -2009,9 +2339,22 @@
|
||||
} else if (this.level().isClientSide) {
|
||||
@@ -2128,9 +2454,22 @@
|
||||
if (itemstack.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
+ // CraftBukkit start - Capture drops for death event
|
||||
@ -574,7 +579,7 @@
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
|
||||
EntityItem entityitem = new EntityItem(worldserver, this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
|
||||
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
+ // CraftBukkit start
|
||||
@ -584,10 +589,10 @@
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level().addFreshEntity(entityitem);
|
||||
worldserver.addFreshEntity(entityitem);
|
||||
return entityitem;
|
||||
}
|
||||
@@ -2040,6 +2383,12 @@
|
||||
@@ -2159,6 +2498,12 @@
|
||||
if (this.isAlive() && this instanceof Leashable leashable) {
|
||||
if (leashable.getLeashHolder() == entityhuman) {
|
||||
if (!this.level().isClientSide()) {
|
||||
@ -600,7 +605,7 @@
|
||||
leashable.dropLeash(true, !entityhuman.hasInfiniteMaterials());
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
|
||||
}
|
||||
@@ -2051,6 +2400,13 @@
|
||||
@@ -2170,6 +2515,13 @@
|
||||
|
||||
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
|
||||
if (!this.level().isClientSide()) {
|
||||
@ -614,7 +619,7 @@
|
||||
leashable.setLeashedTo(entityhuman, true);
|
||||
}
|
||||
|
||||
@@ -2134,6 +2490,27 @@
|
||||
@@ -2255,6 +2607,27 @@
|
||||
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
|
||||
return false;
|
||||
} else {
|
||||
@ -642,7 +647,7 @@
|
||||
if (this.isPassenger()) {
|
||||
this.stopRiding();
|
||||
}
|
||||
@@ -2167,7 +2544,7 @@
|
||||
@@ -2288,7 +2661,7 @@
|
||||
Entity entity = this.vehicle;
|
||||
|
||||
this.vehicle = null;
|
||||
@ -651,7 +656,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2198,10 +2575,38 @@
|
||||
@@ -2319,10 +2692,38 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -691,7 +696,7 @@
|
||||
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
|
||||
this.passengers = ImmutableList.of();
|
||||
} else {
|
||||
@@ -2213,6 +2618,7 @@
|
||||
@@ -2334,6 +2735,7 @@
|
||||
entity.boardingCooldown = 60;
|
||||
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
|
||||
}
|
||||
@ -699,16 +704,16 @@
|
||||
}
|
||||
|
||||
protected boolean canAddPassenger(Entity entity) {
|
||||
@@ -2307,7 +2713,7 @@
|
||||
if (dimensiontransition != null) {
|
||||
WorldServer worldserver1 = dimensiontransition.newLevel();
|
||||
@@ -2434,7 +2836,7 @@
|
||||
if (teleporttransition != null) {
|
||||
WorldServer worldserver1 = teleporttransition.newLevel();
|
||||
|
||||
- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1))) {
|
||||
+ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1)))) { // CraftBukkit - always call event for players
|
||||
this.changeDimension(dimensiontransition);
|
||||
- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1))) {
|
||||
+ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1)))) { // CraftBukkit - always call event for players
|
||||
this.teleport(teleporttransition);
|
||||
}
|
||||
}
|
||||
@@ -2414,6 +2820,13 @@
|
||||
@@ -2541,6 +2943,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
@ -722,7 +727,7 @@
|
||||
this.setSharedFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -2463,8 +2876,12 @@
|
||||
@@ -2594,8 +3003,12 @@
|
||||
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
|
||||
}
|
||||
|
||||
@ -736,7 +741,7 @@
|
||||
}
|
||||
|
||||
public boolean getSharedFlag(int i) {
|
||||
@@ -2483,7 +2900,7 @@
|
||||
@@ -2614,7 +3027,7 @@
|
||||
}
|
||||
|
||||
public int getMaxAirSupply() {
|
||||
@ -745,7 +750,7 @@
|
||||
}
|
||||
|
||||
public int getAirSupply() {
|
||||
@@ -2491,7 +2908,18 @@
|
||||
@@ -2622,7 +3035,18 @@
|
||||
}
|
||||
|
||||
public void setAirSupply(int i) {
|
||||
@ -765,7 +770,7 @@
|
||||
}
|
||||
|
||||
public int getTicksFrozen() {
|
||||
@@ -2518,11 +2946,40 @@
|
||||
@@ -2649,11 +3073,40 @@
|
||||
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
this.setRemainingFireTicks(this.remainingFireTicks + 1);
|
||||
@ -786,7 +791,7 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- this.hurt(this.damageSources().lightningBolt(), 5.0F);
|
||||
- this.hurtServer(worldserver, this.damageSources().lightningBolt(), 5.0F);
|
||||
+ // CraftBukkit start
|
||||
+ if (thisBukkitEntity instanceof Hanging) {
|
||||
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
|
||||
@ -801,47 +806,47 @@
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) {
|
||||
+ if (!this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void onAboveBubbleCol(boolean flag) {
|
||||
@@ -2691,6 +3148,15 @@
|
||||
@@ -2822,6 +3275,18 @@
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (!this.isRemoved()) {
|
||||
+ // CraftBukkit start
|
||||
+ Location to = new Location(dimensiontransition.newLevel().getWorld(), dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
|
||||
+ 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());
|
||||
+ EntityTeleportEvent teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to);
|
||||
+ if (teleEvent.isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ to = teleEvent.getTo();
|
||||
+ dimensiontransition = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), dimensiontransition.speed(), to.getYaw(), to.getPitch(), dimensiontransition.missingRespawnBlock(), dimensiontransition.postDimensionTransition(), dimensiontransition.cause());
|
||||
+ if (!to.equals(teleEvent.getTo())) {
|
||||
+ to = teleEvent.getTo();
|
||||
+ 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 = dimensiontransition.newLevel();
|
||||
List<Entity> list = this.getPassengers();
|
||||
WorldServer worldserver1 = teleporttransition.newLevel();
|
||||
boolean flag = worldserver1.dimension() != worldserver.dimension();
|
||||
|
||||
@@ -2716,11 +3182,15 @@
|
||||
if (this != entity2) {
|
||||
entity2.restoreFrom(this);
|
||||
this.removeAfterChangingDimensions();
|
||||
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
||||
+ this.getBukkitEntity().setHandle(entity2);
|
||||
+ entity2.bukkitEntity = this.getBukkitEntity();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -2890,8 +3355,12 @@
|
||||
} else {
|
||||
entity.restoreFrom(this);
|
||||
this.removeAfterChangingDimensions();
|
||||
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
||||
+ this.getBukkitEntity().setHandle(entity);
|
||||
+ entity.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.moveTo(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), entity2.getXRot());
|
||||
entity2.setDeltaMovement(dimensiontransition.speed());
|
||||
- if (this != entity2) {
|
||||
+ if (this != entity2 && this.inWorld) { // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned
|
||||
worldserver1.addDuringTeleport(entity2);
|
||||
}
|
||||
|
||||
@@ -2754,8 +3224,9 @@
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -2965,8 +3434,9 @@
|
||||
}
|
||||
|
||||
protected void removeAfterChangingDimensions() {
|
||||
@ -852,7 +857,7 @@
|
||||
leashable.dropLeash(true, false);
|
||||
}
|
||||
|
||||
@@ -2765,6 +3236,20 @@
|
||||
@@ -2976,6 +3446,20 @@
|
||||
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
|
||||
}
|
||||
|
||||
@ -873,35 +878,25 @@
|
||||
public boolean canUsePortal(boolean flag) {
|
||||
return (flag || !this.isPassenger()) && this.isAlive();
|
||||
}
|
||||
@@ -2877,6 +3362,12 @@
|
||||
@@ -3104,9 +3588,15 @@
|
||||
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) {
|
||||
+ // CraftBukkit start
|
||||
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
|
||||
+ return this.teleportTo(worldserver, d0, d1, d2, set, f, f1);
|
||||
+ 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);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
|
||||
+ 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));
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -2895,8 +3386,12 @@
|
||||
entity.restoreFrom(this);
|
||||
entity.moveTo(d0, d1, d2, f, f2);
|
||||
entity.setYHeadRot(f);
|
||||
- this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
- worldserver.addDuringTeleport(entity);
|
||||
+ this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause
|
||||
+ // CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned
|
||||
+ if (inWorld) {
|
||||
+ worldserver.addDuringTeleport(entity);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3023,7 +3518,26 @@
|
||||
return entity != null;
|
||||
}
|
||||
@@ -3228,7 +3718,26 @@
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
|
||||
@ -929,7 +924,7 @@
|
||||
}
|
||||
|
||||
public final float getEyeHeight(EntityPose entitypose) {
|
||||
@@ -3332,6 +3846,11 @@
|
||||
@@ -3525,6 +4034,11 @@
|
||||
vec3d = vec3d.add(vec3d1);
|
||||
++k1;
|
||||
}
|
||||
@ -941,7 +936,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3601,6 +4120,14 @@
|
||||
@@ -3792,6 +4306,14 @@
|
||||
|
||||
@Override
|
||||
public final void setRemoved(Entity.RemovalReason entity_removalreason) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityAgeable.java
|
||||
+++ b/net/minecraft/world/entity/EntityAgeable.java
|
||||
@@ -20,6 +20,7 @@
|
||||
@@ -21,6 +21,7 @@
|
||||
protected int age;
|
||||
protected int forcedAge;
|
||||
protected int forcedAgeTimer;
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -103,6 +104,7 @@
|
||||
@@ -104,6 +105,7 @@
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
nbttagcompound.putInt("Age", this.getAge());
|
||||
nbttagcompound.putInt("ForcedAge", this.forcedAge);
|
||||
@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,6 +112,7 @@
|
||||
@@ -111,6 +113,7 @@
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
this.setAge(nbttagcompound.getInt("Age"));
|
||||
this.forcedAge = nbttagcompound.getInt("ForcedAge");
|
||||
@ -24,7 +24,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +127,7 @@
|
||||
@@ -125,7 +128,7 @@
|
||||
@Override
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
|
||||
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
|
||||
@@ -32,6 +32,12 @@
|
||||
@@ -33,6 +33,12 @@
|
||||
import net.minecraft.world.level.material.EnumPistonReaction;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -13,81 +13,81 @@
|
||||
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -188,7 +194,7 @@
|
||||
}
|
||||
@@ -200,7 +206,7 @@
|
||||
|
||||
private void serverTick(WorldServer worldserver) {
|
||||
if (this.tickCount >= this.waitTime + this.duration) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
if (this.tickCount >= this.waitTime + this.duration) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
boolean flag = this.isWaiting();
|
||||
boolean flag1 = this.tickCount < this.waitTime;
|
||||
@@ -215,7 +221,7 @@
|
||||
if (this.radiusPerTick != 0.0F) {
|
||||
f += this.radiusPerTick;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +211,7 @@
|
||||
if (this.radiusPerTick != 0.0F) {
|
||||
f += this.radiusPerTick;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
@@ -249,11 +255,12 @@
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator1 = list1.iterator();
|
||||
|
||||
@@ -239,11 +245,12 @@
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator1 = list1.iterator();
|
||||
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
|
||||
while (iterator1.hasNext()) {
|
||||
EntityLiving entityliving = (EntityLiving) iterator1.next();
|
||||
|
||||
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
|
||||
while (iterator1.hasNext()) {
|
||||
EntityLiving entityliving = (EntityLiving) iterator1.next();
|
||||
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
|
||||
- Stream stream = list.stream();
|
||||
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
|
||||
|
||||
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 @@
|
||||
double d2 = d0 * d0 + d1 * d1;
|
||||
|
||||
Objects.requireNonNull(entityliving);
|
||||
if (!stream.noneMatch(entityliving::canBeAffected)) {
|
||||
@@ -252,6 +259,19 @@
|
||||
double d5 = d3 * d3 + d4 * d4;
|
||||
|
||||
if (d5 <= (double) (f * f)) {
|
||||
+ // CraftBukkit start
|
||||
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
|
||||
if (d2 <= (double) (f * f)) {
|
||||
+ // CraftBukkit start
|
||||
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ {
|
||||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity entity : event.getAffectedEntities()) {
|
||||
+ if (entity instanceof CraftLivingEntity) {
|
||||
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
|
||||
+ // CraftBukkit end
|
||||
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
|
||||
Iterator iterator2 = list.iterator();
|
||||
+ {
|
||||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity entity : event.getAffectedEntities()) {
|
||||
+ if (entity instanceof CraftLivingEntity) {
|
||||
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
|
||||
+ // CraftBukkit end
|
||||
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
|
||||
Iterator iterator2 = list.iterator();
|
||||
|
||||
@@ -261,14 +281,14 @@
|
||||
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) {
|
||||
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect1), this);
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
if (this.radiusOnUse != 0.0F) {
|
||||
f += this.radiusOnUse;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
@@ -271,14 +291,14 @@
|
||||
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) {
|
||||
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect1), this);
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +298,7 @@
|
||||
if (this.durationOnUse != 0) {
|
||||
this.duration += this.durationOnUse;
|
||||
if (this.duration <= 0) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
if (this.radiusOnUse != 0.0F) {
|
||||
f += this.radiusOnUse;
|
||||
if (f < 0.5F) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -288,7 +308,7 @@
|
||||
if (this.durationOnUse != 0) {
|
||||
this.duration += this.durationOnUse;
|
||||
if (this.duration <= 0) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
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();
|
||||
|
||||
@@ -118,7 +142,7 @@
|
||||
@@ -119,7 +143,7 @@
|
||||
|
||||
++this.age;
|
||||
if (this.age >= 6000) {
|
||||
@ -56,7 +56,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -187,7 +211,7 @@
|
||||
@@ -188,7 +212,7 @@
|
||||
private void merge(EntityExperienceOrb entityexperienceorb) {
|
||||
this.count += entityexperienceorb.count;
|
||||
this.age = Math.min(this.age, entityexperienceorb.age);
|
||||
@ -65,7 +65,7 @@
|
||||
}
|
||||
|
||||
private void setUnderwaterMovement() {
|
||||
@@ -209,7 +233,7 @@
|
||||
@@ -213,7 +237,7 @@
|
||||
this.markHurt();
|
||||
this.health = (int) ((float) this.health - f);
|
||||
if (this.health <= 0) {
|
||||
@ -74,7 +74,7 @@
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -236,17 +260,17 @@
|
||||
@@ -240,17 +264,17 @@
|
||||
public void playerTouch(EntityHuman entityhuman) {
|
||||
if (entityhuman instanceof EntityPlayer entityplayer) {
|
||||
if (entityhuman.takeXpDelay == 0) {
|
||||
@ -95,7 +95,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,12 +284,20 @@
|
||||
@@ -264,12 +288,20 @@
|
||||
ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack();
|
||||
int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i);
|
||||
int k = Math.min(j, itemstack.getDamageValue());
|
||||
@ -116,7 +116,7 @@
|
||||
return this.repairPlayerItems(entityplayer, l);
|
||||
}
|
||||
}
|
||||
@@ -285,6 +317,24 @@
|
||||
@@ -289,6 +321,24 @@
|
||||
}
|
||||
|
||||
public static int getExperienceValue(int i) {
|
||||
|
@ -1,15 +1,13 @@
|
||||
--- a/net/minecraft/world/entity/EntityInsentient.java
|
||||
+++ b/net/minecraft/world/entity/EntityInsentient.java
|
||||
@@ -87,6 +87,20 @@
|
||||
@@ -89,6 +89,18 @@
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
@ -21,7 +19,7 @@
|
||||
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);
|
||||
@@ -134,6 +148,8 @@
|
||||
@@ -136,6 +148,8 @@
|
||||
private BlockPosition restrictCenter;
|
||||
private float restrictRadius;
|
||||
|
||||
@ -30,7 +28,7 @@
|
||||
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
@@ -161,6 +177,12 @@
|
||||
@@ -164,6 +178,12 @@
|
||||
|
||||
}
|
||||
|
||||
@ -43,7 +41,7 @@
|
||||
protected void registerGoals() {}
|
||||
|
||||
public static AttributeProvider.Builder createMobAttributes() {
|
||||
@@ -265,11 +287,42 @@
|
||||
@@ -268,11 +288,42 @@
|
||||
|
||||
@Nullable
|
||||
protected final EntityLiving getTargetFromBrain() {
|
||||
@ -87,7 +85,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -405,6 +458,12 @@
|
||||
@@ -403,6 +454,12 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
@@ -478,16 +537,26 @@
|
||||
@@ -476,16 +533,26 @@
|
||||
nbttagcompound.putBoolean("NoAI", this.isNoAi());
|
||||
}
|
||||
|
||||
@ -112,7 +110,7 @@
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
+
|
||||
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
|
||||
if (nbttagcompound.contains("CanPickUpLoot", 1)) {
|
||||
if (nbttagcompound.contains("CanPickUpLoot", 99)) {
|
||||
- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
|
||||
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
|
||||
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
||||
@ -129,7 +127,7 @@
|
||||
NBTTagList nbttaglist;
|
||||
NBTTagCompound nbttagcompound1;
|
||||
int i;
|
||||
@@ -541,6 +610,11 @@
|
||||
@@ -539,6 +606,11 @@
|
||||
}
|
||||
|
||||
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
|
||||
@ -141,12 +139,12 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -615,20 +689,26 @@
|
||||
@@ -615,20 +687,26 @@
|
||||
|
||||
protected void pickUpItem(EntityItem entityitem) {
|
||||
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy());
|
||||
+ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), entityitem); // CraftBukkit - add item
|
||||
- ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy());
|
||||
+ ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy(), entityitem); // CraftBukkit - add item
|
||||
|
||||
if (!itemstack1.isEmpty()) {
|
||||
this.onItemPickup(entityitem);
|
||||
@ -160,17 +158,17 @@
|
||||
|
||||
}
|
||||
|
||||
public ItemStack equipItemIfPossible(ItemStack itemstack) {
|
||||
public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack) {
|
||||
+ // CraftBukkit start - add item
|
||||
+ return this.equipItemIfPossible(itemstack, null);
|
||||
+ return this.equipItemIfPossible(worldserver, itemstack, null);
|
||||
+ }
|
||||
+
|
||||
+ public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) {
|
||||
+ 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);
|
||||
@@ -639,11 +719,19 @@
|
||||
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot);
|
||||
@@ -639,11 +717,19 @@
|
||||
flag = itemstack1.isEmpty();
|
||||
}
|
||||
|
||||
@ -186,12 +184,12 @@
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(itemstack1);
|
||||
this.spawnAtLocation(worldserver, itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
ItemStack itemstack2 = enumitemslot.limit(itemstack);
|
||||
@@ -772,7 +860,7 @@
|
||||
@@ -770,7 +856,7 @@
|
||||
@Override
|
||||
public void checkDespawn() {
|
||||
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||
@ -200,7 +198,7 @@
|
||||
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
|
||||
EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D);
|
||||
|
||||
@@ -782,14 +870,14 @@
|
||||
@@ -780,14 +866,14 @@
|
||||
int j = i * i;
|
||||
|
||||
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
|
||||
@ -217,15 +215,15 @@
|
||||
} else if (d0 < (double) l) {
|
||||
this.noActionTime = 0;
|
||||
}
|
||||
@@ -803,6 +891,7 @@
|
||||
@@ -801,6 +887,7 @@
|
||||
@Override
|
||||
protected final void serverAiStep() {
|
||||
++this.noActionTime;
|
||||
+ if (!this.aware) return; // CraftBukkit
|
||||
GameProfilerFiller gameprofilerfiller = this.level().getProfiler();
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("sensing");
|
||||
@@ -1354,7 +1443,7 @@
|
||||
@@ -1340,7 +1427,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.level() instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
@ -234,51 +232,71 @@
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
|
||||
@@ -1403,12 +1492,19 @@
|
||||
@@ -1391,12 +1478,19 @@
|
||||
return this.restrictRadius != -1.0F;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag) {
|
||||
+ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a) {
|
||||
+ return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
- T t0 = (EntityInsentient) entitytypes.create(this.level());
|
||||
+ T t0 = entitytypes.create(this.level()); // CraftBukkit - decompile error
|
||||
- T t0 = (EntityInsentient) entitytypes.create(this.level(), entityspawnreason);
|
||||
+ T t0 = entitytypes.create(this.level(), EntitySpawnReason.CONVERSION); // CraftBukkit - decompile error
|
||||
|
||||
if (t0 == null) {
|
||||
return null;
|
||||
@@ -1442,7 +1538,12 @@
|
||||
}
|
||||
}
|
||||
@@ -1405,14 +1499,24 @@
|
||||
conversionparams_a.finalizeConversion(t0);
|
||||
World world = this.level();
|
||||
|
||||
- this.level().addFreshEntity(t0);
|
||||
+ // CraftBukkit start
|
||||
+ if (transformReason == null) {
|
||||
+ // Special handling for slime split and pig lightning
|
||||
+ return t0;
|
||||
+ }
|
||||
+
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ this.level().addFreshEntity(t0, spawnReason);
|
||||
+ // CraftBukkit end
|
||||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
@@ -1450,7 +1551,7 @@
|
||||
t0.startRiding(entity, true);
|
||||
- worldserver.addFreshEntity(t0);
|
||||
+ worldserver.addFreshEntity(t0, spawnReason); // CraftBukkit
|
||||
}
|
||||
|
||||
if (conversionparams.type().shouldDiscardAfterConversion()) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
return t0;
|
||||
}
|
||||
}
|
||||
@@ -1492,6 +1593,7 @@
|
||||
@@ -1422,7 +1526,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);
|
||||
+ // CraftBukkit start
|
||||
+ return 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);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1461,6 +1572,7 @@
|
||||
boolean flag1 = super.startRiding(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
@ -286,10 +304,10 @@
|
||||
this.dropLeash(true, true);
|
||||
}
|
||||
|
||||
@@ -1578,7 +1680,7 @@
|
||||
if (f1 > 0.0F && entity instanceof EntityLiving) {
|
||||
EntityLiving entityliving = (EntityLiving) entity;
|
||||
@@ -1545,7 +1657,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
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityLightning.java
|
||||
+++ b/net/minecraft/world/entity/EntityLightning.java
|
||||
@@ -30,6 +30,11 @@
|
||||
@@ -31,6 +31,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;
|
||||
@@ -121,7 +126,7 @@
|
||||
@@ -120,7 +125,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
} else if (this.life < -this.random.nextInt(10)) {
|
||||
--this.flashes;
|
||||
this.life = 1;
|
||||
@@ -130,7 +135,7 @@
|
||||
@@ -129,7 +134,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,37 +30,37 @@
|
||||
if (!(this.level() instanceof WorldServer)) {
|
||||
this.level().setSkyFlashTime(2);
|
||||
} else if (!this.visualOnly) {
|
||||
@@ -164,8 +169,12 @@
|
||||
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
|
||||
@@ -169,8 +174,12 @@
|
||||
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
- this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
|
||||
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
- this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
|
||||
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
@@ -173,8 +182,12 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
@@ -178,8 +187,12 @@
|
||||
|
||||
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
|
||||
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
|
||||
- this.level().setBlockAndUpdate(blockposition1, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) {
|
||||
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
|
||||
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
|
||||
- this.level().setBlockAndUpdate(blockposition1, iblockdata);
|
||||
- ++this.blocksSetOnFire;
|
||||
+ // CraftBukkit start - add "!visualOnly"
|
||||
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) {
|
||||
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
|
||||
+ ++this.blocksSetOnFire;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,8 +251,9 @@
|
||||
@@ -247,8 +260,9 @@
|
||||
iblockdata = world.getBlockState(blockposition1);
|
||||
} while (!(iblockdata.getBlock() instanceof WeatheringCopper));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityLiving.java
|
||||
+++ b/net/minecraft/world/entity/EntityLiving.java
|
||||
@@ -132,6 +132,32 @@
|
||||
@@ -137,6 +137,33 @@
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -8,10 +8,11 @@
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+import com.google.common.base.Function;
|
||||
+import java.util.LinkedList;
|
||||
+import java.util.UUID;
|
||||
+import net.minecraft.nbt.NBTTagFloat;
|
||||
+import net.minecraft.nbt.NBTTagInt;
|
||||
+import net.minecraft.world.item.component.Consumable;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
@ -33,18 +34,9 @@
|
||||
public abstract class EntityLiving extends Entity implements Attackable {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -157,7 +183,7 @@
|
||||
private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0D;
|
||||
protected static final int LIVING_ENTITY_FLAG_IS_USING = 1;
|
||||
protected static final int LIVING_ENTITY_FLAG_OFF_HAND = 2;
|
||||
- protected static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
|
||||
+ public static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
|
||||
protected static final DataWatcherObject<Byte> DATA_LIVING_ENTITY_FLAGS = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.BYTE);
|
||||
public static final DataWatcherObject<Float> DATA_HEALTH_ID = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.FLOAT);
|
||||
private static final DataWatcherObject<List<ParticleParam>> DATA_EFFECT_PARTICLES = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.PARTICLES);
|
||||
@@ -249,6 +275,19 @@
|
||||
@@ -262,6 +289,19 @@
|
||||
protected boolean skipDropExperience;
|
||||
private final Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>> activeLocationDependentEnchantments;
|
||||
private final EnumMap<EnumItemSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments;
|
||||
protected float appliedScale;
|
||||
+ // CraftBukkit start
|
||||
+ public int expToDrop;
|
||||
@ -62,8 +54,8 @@
|
||||
|
||||
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -264,7 +303,9 @@
|
||||
this.activeLocationDependentEnchantments = new Reference2ObjectArrayMap();
|
||||
@@ -278,7 +318,9 @@
|
||||
this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class);
|
||||
this.appliedScale = 1.0F;
|
||||
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
@ -73,22 +65,22 @@
|
||||
this.blocksBuilding = true;
|
||||
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.reapplyPosition();
|
||||
@@ -344,7 +385,13 @@
|
||||
@@ -358,7 +400,13 @@
|
||||
double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d8);
|
||||
|
||||
- ((WorldServer) this.level()).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, 0.15000000596046448D);
|
||||
+ // CraftBukkit start - visiblity api
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((WorldServer) this.level()).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
|
||||
+ worldserver.sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
|
||||
+ } else {
|
||||
+ ((WorldServer) this.level()).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, 0.15000000596046448D);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,7 +602,7 @@
|
||||
@@ -573,7 +621,7 @@
|
||||
++this.deathTime;
|
||||
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
||||
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||
@ -97,7 +89,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -661,13 +708,19 @@
|
||||
@@ -679,13 +727,19 @@
|
||||
}
|
||||
|
||||
public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) {
|
||||
@ -107,18 +99,18 @@
|
||||
+
|
||||
+ public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
|
||||
+ // CraftBukkit end
|
||||
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
|
||||
if (!this.level().isClientSide() && !this.isSpectator()) {
|
||||
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
|
||||
|
||||
if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
|
||||
Equipable equipable = Equipable.get(itemstack1);
|
||||
if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
|
||||
Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
|
||||
|
||||
if (!this.level().isClientSide() && !this.isSpectator()) {
|
||||
- if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot) {
|
||||
+ if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot && !silent) { // CraftBukkit
|
||||
this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
|
||||
- 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());
|
||||
}
|
||||
|
||||
@@ -681,11 +734,18 @@
|
||||
@@ -699,6 +753,13 @@
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason entity_removalreason) {
|
||||
@ -130,7 +122,10 @@
|
||||
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
||||
+ // CraftBukkit end
|
||||
if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) {
|
||||
this.triggerOnDeathMobEffects(entity_removalreason);
|
||||
World world = this.level();
|
||||
|
||||
@@ -709,7 +770,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- super.remove(entity_removalreason);
|
||||
@ -138,15 +133,15 @@
|
||||
this.brain.clearMemories();
|
||||
}
|
||||
|
||||
@@ -698,6 +758,7 @@
|
||||
mobeffect.onMobRemoved(this, entity_removalreason);
|
||||
@@ -722,6 +783,7 @@
|
||||
mobeffect.onMobRemoved(worldserver, this, entity_removalreason);
|
||||
}
|
||||
|
||||
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH); // CraftBukkit
|
||||
this.activeEffects.clear();
|
||||
}
|
||||
|
||||
@@ -757,6 +818,17 @@
|
||||
@@ -781,6 +843,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +159,7 @@
|
||||
if (nbttagcompound.contains("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -795,9 +867,32 @@
|
||||
@@ -819,9 +892,32 @@
|
||||
|
||||
}
|
||||
|
||||
@ -197,7 +192,7 @@
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
Holder<MobEffectList> holder = (Holder) iterator.next();
|
||||
@@ -807,6 +902,12 @@
|
||||
@@ -831,6 +927,12 @@
|
||||
this.onEffectUpdated(mobeffect, true, (Entity) null);
|
||||
})) {
|
||||
if (!this.level().isClientSide) {
|
||||
@ -208,9 +203,9 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
this.onEffectRemoved(mobeffect);
|
||||
this.onEffectsRemoved(List.of(mobeffect));
|
||||
}
|
||||
@@ -817,6 +918,17 @@
|
||||
@@ -841,6 +943,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
@ -228,7 +223,7 @@
|
||||
|
||||
if (this.effectsDirty) {
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -932,7 +1044,13 @@
|
||||
@@ -952,17 +1065,36 @@
|
||||
this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of());
|
||||
}
|
||||
|
||||
@ -241,24 +236,35 @@
|
||||
+ // CraftBukkit end
|
||||
if (this.level().isClientSide) {
|
||||
return false;
|
||||
} else if (this.activeEffects.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -941,7 +1059,14 @@
|
||||
boolean flag;
|
||||
- Map<Holder<MobEffectList>, MobEffect> map = Maps.newHashMap(this.activeEffects);
|
||||
+ // CraftBukkit start
|
||||
+ List<MobEffect> toRemove = new LinkedList<>();
|
||||
+ Iterator<MobEffect> iterator = this.activeEffects.values().iterator();
|
||||
|
||||
for (flag = false; iterator.hasNext(); flag = true) {
|
||||
- this.onEffectRemoved((MobEffect) iterator.next());
|
||||
+ // CraftBukkit start
|
||||
+ MobEffect effect = (MobEffect) iterator.next();
|
||||
- this.activeEffects.clear();
|
||||
- this.onEffectsRemoved(map.values());
|
||||
- return true;
|
||||
+ while (iterator.hasNext()) {
|
||||
+ MobEffect effect = iterator.next();
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ this.onEffectRemoved(effect);
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
}
|
||||
+
|
||||
+ iterator.remove();
|
||||
+ toRemove.add(effect);
|
||||
+ }
|
||||
+
|
||||
+ this.onEffectsRemoved(toRemove);
|
||||
+ return !toRemove.isEmpty();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,20 +1095,50 @@
|
||||
@@ -987,20 +1119,50 @@
|
||||
return this.addEffect(mobeffect, (Entity) null);
|
||||
}
|
||||
|
||||
@ -310,7 +316,7 @@
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -1014,13 +1169,39 @@
|
||||
@@ -1031,13 +1193,39 @@
|
||||
return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM);
|
||||
}
|
||||
|
||||
@ -350,8 +356,8 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (mobeffect != null) {
|
||||
this.onEffectRemoved(mobeffect);
|
||||
@@ -1118,20 +1299,55 @@
|
||||
this.onEffectsRemoved(List.of(mobeffect));
|
||||
@@ -1142,20 +1330,55 @@
|
||||
|
||||
}
|
||||
|
||||
@ -408,18 +414,18 @@
|
||||
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -1145,7 +1361,7 @@
|
||||
return false;
|
||||
} else if (this.level().isClientSide) {
|
||||
@@ -1167,7 +1390,7 @@
|
||||
public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
- } else if (this.isDeadOrDying()) {
|
||||
+ } else if (this.isRemoved() || this.dead || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die
|
||||
return false;
|
||||
} else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -1156,10 +1372,11 @@
|
||||
@@ -1182,10 +1405,11 @@
|
||||
}
|
||||
|
||||
this.noActionTime = 0;
|
||||
float f1 = f;
|
||||
- boolean flag = false;
|
||||
+ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below
|
||||
@ -431,7 +437,7 @@
|
||||
this.hurtCurrentlyUsedShield(f);
|
||||
f2 = f;
|
||||
f = 0.0F;
|
||||
@@ -1176,30 +1393,50 @@
|
||||
@@ -1202,15 +1426,26 @@
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@ -458,6 +464,10 @@
|
||||
+ // 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;
|
||||
|
||||
- if ((float) this.invulnerableTime > 10.0F && !damagesource.is(DamageTypeTags.BYPASSES_COOLDOWN)) {
|
||||
@ -466,9 +476,9 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
- this.actuallyHurt(damagesource, f - this.lastHurt);
|
||||
- this.actuallyHurt(worldserver, damagesource, f - this.lastHurt);
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) {
|
||||
+ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@ -476,20 +486,20 @@
|
||||
flag1 = false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage(), event)) {
|
||||
+ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage(), event)) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.lastHurt = f;
|
||||
- this.invulnerableTime = 20;
|
||||
- this.actuallyHurt(damagesource, f);
|
||||
- this.actuallyHurt(worldserver, damagesource, f);
|
||||
+ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks
|
||||
+ // this.actuallyHurt(damagesource, f);
|
||||
+ // this.actuallyHurt(worldserver, damagesource, f);
|
||||
+ // CraftBukkit end
|
||||
this.hurtDuration = 10;
|
||||
this.hurtTime = this.hurtDuration;
|
||||
}
|
||||
@@ -1245,7 +1482,7 @@
|
||||
this.level().broadcastDamageEvent(this, damagesource);
|
||||
@@ -1275,7 +1519,7 @@
|
||||
worldserver.broadcastDamageEvent(this, damagesource);
|
||||
}
|
||||
|
||||
- if (!damagesource.is(DamageTypeTags.NO_IMPACT) && (!flag || f > 0.0F)) {
|
||||
@ -497,7 +507,7 @@
|
||||
this.markHurt();
|
||||
}
|
||||
|
||||
@@ -1265,7 +1502,7 @@
|
||||
@@ -1295,7 +1539,7 @@
|
||||
d1 = damagesource.getSourcePosition().z() - this.getZ();
|
||||
}
|
||||
|
||||
@ -506,7 +516,7 @@
|
||||
if (!flag) {
|
||||
this.indicateDamage(d0, d1);
|
||||
}
|
||||
@@ -1284,7 +1521,7 @@
|
||||
@@ -1314,7 +1558,7 @@
|
||||
this.playHurtSound(damagesource);
|
||||
}
|
||||
|
||||
@ -515,7 +525,7 @@
|
||||
|
||||
if (flag2) {
|
||||
this.lastDamageSource = damagesource;
|
||||
@@ -1318,7 +1555,7 @@
|
||||
@@ -1352,7 +1596,7 @@
|
||||
}
|
||||
|
||||
protected void blockedByShield(EntityLiving entityliving) {
|
||||
@ -524,7 +534,7 @@
|
||||
}
|
||||
|
||||
private boolean checkTotemDeathProtection(DamageSource damagesource) {
|
||||
@@ -1329,19 +1566,32 @@
|
||||
@@ -1364,20 +1608,33 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
@ -536,7 +546,8 @@
|
||||
- ItemStack itemstack1 = this.getItemInHand(enumhand);
|
||||
+ itemstack1 = this.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack1.is(Items.TOTEM_OF_UNDYING)) {
|
||||
deathprotection = (DeathProtection) itemstack1.get(DataComponents.DEATH_PROTECTION);
|
||||
if (deathprotection != null) {
|
||||
+ hand = enumhand; // CraftBukkit
|
||||
itemstack = itemstack1.copy();
|
||||
- itemstack1.shrink(1);
|
||||
@ -560,30 +571,8 @@
|
||||
+ // CraftBukkit end
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1350,14 +1600,16 @@
|
||||
}
|
||||
|
||||
this.setHealth(1.0F);
|
||||
- this.removeAllEffects();
|
||||
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1));
|
||||
- this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1));
|
||||
- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0));
|
||||
+ // CraftBukkit start
|
||||
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ // CraftBukkit end
|
||||
this.level().broadcastEntityEvent(this, (byte) 35);
|
||||
}
|
||||
|
||||
- return itemstack != null;
|
||||
+ return !event.isCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,14 +1716,22 @@
|
||||
entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
|
||||
@@ -1501,14 +1758,22 @@
|
||||
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
@ -608,13 +597,13 @@
|
||||
this.level().addFreshEntity(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -1482,26 +1742,41 @@
|
||||
@@ -1519,22 +1784,37 @@
|
||||
protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) {
|
||||
boolean flag = this.lastHurtByPlayerTime > 0;
|
||||
|
||||
+ this.dropEquipment(); // CraftBukkit - from below
|
||||
+ this.dropEquipment(worldserver); // CraftBukkit - from below
|
||||
if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
this.dropFromLootTable(damagesource, flag);
|
||||
this.dropFromLootTable(worldserver, damagesource, flag);
|
||||
this.dropCustomDeathLoot(worldserver, damagesource, flag);
|
||||
}
|
||||
+ // CraftBukkit start - Call death event
|
||||
@ -622,38 +611,34 @@
|
||||
+ this.drops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
|
||||
- this.dropEquipment();
|
||||
+ // this.dropEquipment();// CraftBukkit - moved up
|
||||
this.dropExperience(damagesource.getEntity());
|
||||
- this.dropEquipment(worldserver);
|
||||
+ // this.dropEquipment(worldserver);// CraftBukkit - moved up
|
||||
this.dropExperience(worldserver, damagesource.getEntity());
|
||||
}
|
||||
|
||||
protected void dropEquipment() {}
|
||||
protected void dropEquipment(WorldServer worldserver) {}
|
||||
|
||||
- protected void dropExperience(@Nullable Entity entity) {
|
||||
+ public int getExpReward(@Nullable Entity entity) { // CraftBukkit
|
||||
World world = this.level();
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
|
||||
- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity));
|
||||
+ return this.getExperienceReward(worldserver, entity); // CraftBukkit
|
||||
}
|
||||
- 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))) {
|
||||
- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity));
|
||||
+ return this.getExperienceReward(worldserver, entity); // CraftBukkit }
|
||||
}
|
||||
|
||||
+ return 0; // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
+ protected void dropExperience(@Nullable Entity entity) {
|
||||
+ protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) {
|
||||
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
||||
+ if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
|
||||
+ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop);
|
||||
+ EntityExperienceOrb.award(worldserver, this.position(), this.expToDrop);
|
||||
+ this.expToDrop = 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {}
|
||||
@@ -1540,9 +1815,14 @@
|
||||
@@ -1601,9 +1881,14 @@
|
||||
}
|
||||
|
||||
public void knockback(double d0, double d1, double d2) {
|
||||
@ -670,7 +655,7 @@
|
||||
|
||||
Vec3D vec3d;
|
||||
|
||||
@@ -1552,7 +1832,14 @@
|
||||
@@ -1613,7 +1898,14 @@
|
||||
|
||||
Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0);
|
||||
|
||||
@ -686,8 +671,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1613,6 +1900,28 @@
|
||||
return itemstack.getEatingSound();
|
||||
@@ -1668,6 +1960,20 @@
|
||||
return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Add delegate methods
|
||||
@ -702,25 +687,17 @@
|
||||
+ public SoundEffect getFallDamageSound0(int fallHeight) {
|
||||
+ return getFallDamageSound(fallHeight);
|
||||
+ }
|
||||
+
|
||||
+ public SoundEffect getDrinkingSound0(ItemStack itemstack) {
|
||||
+ return getDrinkingSound(itemstack);
|
||||
+ }
|
||||
+
|
||||
+ public SoundEffect getEatingSound0(ItemStack itemstack) {
|
||||
+ return getEatingSound(itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public Optional<BlockPosition> getLastClimbablePos() {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
@@ -1666,9 +1975,14 @@
|
||||
@@ -1746,9 +2052,14 @@
|
||||
int i = this.calculateFallDamage(f, f1);
|
||||
|
||||
if (i > 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.hurt(damagesource, (float) i)) {
|
||||
+ if (!this.hurtServer((WorldServer) this.level(), damagesource, (float) i)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@ -731,7 +708,7 @@
|
||||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1738,7 +2052,7 @@
|
||||
@@ -1819,7 +2130,7 @@
|
||||
|
||||
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
|
||||
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
|
||||
@ -740,7 +717,7 @@
|
||||
f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1749,7 +2063,8 @@
|
||||
@@ -1830,7 +2141,8 @@
|
||||
if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) {
|
||||
return f;
|
||||
} else {
|
||||
@ -750,16 +727,16 @@
|
||||
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1792,15 +2107,140 @@
|
||||
@@ -1873,15 +2185,140 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start
|
||||
+ private EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float f) {
|
||||
+ float originalDamage = f;
|
||||
+
|
||||
+ Function<Double, Double> freezing = new Function<Double, Double>() {
|
||||
+ com.google.common.base.Function<Double, Double> freezing = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if (damagesource.is(DamageTypeTags.IS_FREEZING) && EntityLiving.this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) {
|
||||
@ -771,7 +748,7 @@
|
||||
+ float freezingModifier = freezing.apply((double) f).floatValue();
|
||||
+ f += freezingModifier;
|
||||
+
|
||||
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
|
||||
+ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
|
||||
@ -783,7 +760,7 @@
|
||||
+ float hardHatModifier = hardHat.apply((double) f).floatValue();
|
||||
+ f += hardHatModifier;
|
||||
+
|
||||
+ Function<Double, Double> blocking = new Function<Double, Double>() {
|
||||
+ 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);
|
||||
@ -792,7 +769,7 @@
|
||||
+ float blockingModifier = blocking.apply((double) f).floatValue();
|
||||
+ f += blockingModifier;
|
||||
+
|
||||
+ Function<Double, Double> armor = new Function<Double, Double>() {
|
||||
+ com.google.common.base.Function<Double, Double> armor = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue()));
|
||||
@ -801,7 +778,7 @@
|
||||
+ float armorModifier = armor.apply((double) f).floatValue();
|
||||
+ f += armorModifier;
|
||||
+
|
||||
+ Function<Double, Double> resistance = new Function<Double, Double>() {
|
||||
+ 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)) {
|
||||
@ -816,7 +793,7 @@
|
||||
+ float resistanceModifier = resistance.apply((double) f).floatValue();
|
||||
+ f += resistanceModifier;
|
||||
+
|
||||
+ Function<Double, Double> magic = new Function<Double, Double>() {
|
||||
+ com.google.common.base.Function<Double, Double> magic = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue()));
|
||||
@ -825,7 +802,7 @@
|
||||
+ float magicModifier = magic.apply((double) f).floatValue();
|
||||
+ f += magicModifier;
|
||||
+
|
||||
+ Function<Double, Double> absorption = new Function<Double, Double>() {
|
||||
+ com.google.common.base.Function<Double, Double> absorption = new com.google.common.base.Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionAmount(), 0.0F), 0.0F));
|
||||
@ -836,8 +813,8 @@
|
||||
+ return CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption);
|
||||
+ }
|
||||
+
|
||||
+ protected boolean actuallyHurt(final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final
|
||||
if (!this.isInvulnerableTo(damagesource)) {
|
||||
+ protected boolean actuallyHurt(WorldServer worldserver, final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final
|
||||
if (!this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
- f = this.getDamageAfterArmorAbsorb(damagesource, f);
|
||||
- f = this.getDamageAfterMagicAbsorb(damagesource, f);
|
||||
- float f1 = f;
|
||||
@ -898,7 +875,7 @@
|
||||
|
||||
if (f2 > 0.0F && f2 < 3.4028235E37F) {
|
||||
Entity entity = damagesource.getEntity();
|
||||
@@ -1812,13 +2252,48 @@
|
||||
@@ -1893,13 +2330,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -949,7 +926,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1843,9 +2318,19 @@
|
||||
@@ -1924,9 +2396,19 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int i) {
|
||||
@ -970,7 +947,7 @@
|
||||
public final int getStingerCount() {
|
||||
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
|
||||
}
|
||||
@@ -2086,6 +2571,12 @@
|
||||
@@ -2171,6 +2653,12 @@
|
||||
|
||||
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
|
||||
|
||||
@ -983,15 +960,7 @@
|
||||
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||
|
||||
public Iterable<ItemStack> getHandSlots() {
|
||||
@@ -2336,6 +2827,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround() && !this.level().isClientSide) {
|
||||
+ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setSharedFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -2506,7 +2998,7 @@
|
||||
@@ -2623,7 +3111,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -1000,8 +969,8 @@
|
||||
if (this.tickCount % 20 == 0) {
|
||||
this.getCombatTracker().recheckStatus();
|
||||
}
|
||||
@@ -2610,7 +3102,7 @@
|
||||
|
||||
@@ -2730,7 +3218,7 @@
|
||||
this.elytraAnimationState.tick();
|
||||
}
|
||||
|
||||
- public void detectEquipmentUpdates() {
|
||||
@ -1009,15 +978,15 @@
|
||||
Map<EnumItemSlot, ItemStack> map = this.collectEquipmentChanges();
|
||||
|
||||
if (map != null) {
|
||||
@@ -2949,6 +3441,7 @@
|
||||
}
|
||||
|
||||
@@ -3052,6 +3540,7 @@
|
||||
this.checkSlowFallDistance();
|
||||
if (!this.level().isClientSide) {
|
||||
+ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
|
||||
this.setSharedFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -3141,13 +3634,20 @@
|
||||
if (!this.canGlide()) {
|
||||
+ if (this.getSharedFlag(7) != false && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setSharedFlag(7, false);
|
||||
return;
|
||||
}
|
||||
@@ -3298,14 +3787,21 @@
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
@ -1029,30 +998,22 @@
|
||||
public boolean isPushable() {
|
||||
- return this.isAlive() && !this.isSpectator() && !this.onClimbable();
|
||||
+ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - collidable API
|
||||
+ @Override
|
||||
+ public boolean canCollideWithBukkit(Entity entity) {
|
||||
+ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID());
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
@Override
|
||||
public float getYHeadRot() {
|
||||
@@ -3245,7 +3745,7 @@
|
||||
|
||||
}
|
||||
|
||||
- protected void setLivingEntityFlag(int i, boolean flag) {
|
||||
+ public void setLivingEntityFlag(int i, boolean flag) {
|
||||
int j = (Byte) this.entityData.get(EntityLiving.DATA_LIVING_ENTITY_FLAGS);
|
||||
|
||||
if (flag) {
|
||||
@@ -3346,7 +3846,29 @@
|
||||
return this.yHeadRot;
|
||||
@@ -3476,7 +3972,30 @@
|
||||
this.releaseUsingItem();
|
||||
} else {
|
||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||
this.triggerItemUseEffects(this.useItem, 16);
|
||||
- ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this);
|
||||
+ // CraftBukkit start - fire PlayerItemConsumeEvent
|
||||
+ ItemStack itemstack;
|
||||
@ -1064,8 +1025,9 @@
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Update client
|
||||
+ if (this.useItem.getItem() instanceof net.minecraft.world.item.ItemSuspiciousStew itemSuspiciousStew) {
|
||||
+ itemSuspiciousStew.cancelUsingItem(entityPlayer, this.useItem);
|
||||
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||
+ if (consumable != null) {
|
||||
+ consumable.cancelUsingItem(entityPlayer, this.useItem);
|
||||
+ }
|
||||
+ entityPlayer.getBukkitEntity().updateInventory();
|
||||
+ entityPlayer.getBukkitEntity().updateScaledHealth();
|
||||
@ -1080,7 +1042,7 @@
|
||||
|
||||
if (itemstack != this.useItem) {
|
||||
this.setItemInHand(enumhand, itemstack);
|
||||
@@ -3424,6 +3946,12 @@
|
||||
@@ -3561,6 +4080,12 @@
|
||||
}
|
||||
|
||||
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
|
||||
@ -1093,7 +1055,7 @@
|
||||
double d3 = this.getX();
|
||||
double d4 = this.getY();
|
||||
double d5 = this.getZ();
|
||||
@@ -3448,16 +3976,41 @@
|
||||
@@ -3585,16 +4110,41 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@ -1121,7 +1083,7 @@
|
||||
+ }
|
||||
+ } else {
|
||||
+ // player teleport event is called in the underlining code
|
||||
+ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), cause)) {
|
||||
+ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), cause)) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ }
|
||||
@ -1138,7 +1100,7 @@
|
||||
} else {
|
||||
if (flag) {
|
||||
world.broadcastEntityEvent(this, (byte) 46);
|
||||
@@ -3469,7 +4022,7 @@
|
||||
@@ -3606,7 +4156,7 @@
|
||||
entitycreature.getNavigation().stop();
|
||||
}
|
||||
|
||||
@ -1147,7 +1109,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3562,7 +4115,7 @@
|
||||
@@ -3699,7 +4249,7 @@
|
||||
}
|
||||
|
||||
public void stopSleeping() {
|
||||
@ -1156,7 +1118,7 @@
|
||||
World world = this.level();
|
||||
|
||||
java.util.Objects.requireNonNull(world);
|
||||
@@ -3596,7 +4149,7 @@
|
||||
@@ -3733,7 +4283,7 @@
|
||||
|
||||
@Nullable
|
||||
public EnumDirection getBedOrientation() {
|
||||
@ -1165,12 +1127,3 @@
|
||||
|
||||
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
|
||||
}
|
||||
@@ -3633,7 +4186,7 @@
|
||||
FoodInfo.b foodinfo_b = (FoodInfo.b) iterator.next();
|
||||
|
||||
if (this.random.nextFloat() < foodinfo_b.probability()) {
|
||||
- this.addEffect(foodinfo_b.effect());
|
||||
+ this.addEffect(foodinfo_b.effect(), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityTameableAnimal.java
|
||||
+++ b/net/minecraft/world/entity/EntityTameableAnimal.java
|
||||
@@ -27,6 +27,12 @@
|
||||
@@ -28,6 +28,12 @@
|
||||
import net.minecraft.world.level.pathfinder.PathfinderNormal;
|
||||
import net.minecraft.world.scores.ScoreboardTeam;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity {
|
||||
|
||||
public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144;
|
||||
@@ -281,7 +287,14 @@
|
||||
@@ -292,7 +298,14 @@
|
||||
if (!this.canTeleportTo(new BlockPosition(i, j, k))) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/EntityTypes.java
|
||||
+++ b/net/minecraft/world/entity/EntityTypes.java
|
||||
@@ -168,6 +168,7 @@
|
||||
@@ -176,6 +176,7 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
@ -8,83 +8,81 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class EntityTypes<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> {
|
||||
@@ -177,7 +178,7 @@
|
||||
private static final float MAGIC_HORSE_WIDTH = 1.3964844F;
|
||||
private static final int DISPLAY_TRACKING_RANGE = 10;
|
||||
@@ -191,7 +192,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));
|
||||
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
|
||||
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
|
||||
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
|
||||
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
|
||||
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).sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20));
|
||||
@@ -325,8 +326,8 @@
|
||||
private final float spawnDimensionsScale;
|
||||
private final FeatureFlagSet requiredFeatures;
|
||||
|
||||
- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) {
|
||||
- return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, entitytypes_builder.build(s));
|
||||
+ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
|
||||
+ return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, (EntityTypes<T>) entitytypes_builder.build(s)); // CraftBukkit - decompile error
|
||||
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 @@
|
||||
return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s));
|
||||
}
|
||||
|
||||
public static MinecraftKey getKey(EntityTypes<?> entitytypes) {
|
||||
@@ -355,7 +356,14 @@
|
||||
- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) {
|
||||
+ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
|
||||
return register(vanillaEntityId(s), entitytypes_builder);
|
||||
}
|
||||
|
||||
@@ -431,7 +432,14 @@
|
||||
|
||||
@Nullable
|
||||
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
|
||||
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) {
|
||||
- Consumer consumer;
|
||||
+ // CraftBukkit start
|
||||
+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
||||
+ return this.spawn(worldserver, itemstack, entityhuman, 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, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ 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) {
|
||||
+ // CraftBukkit end
|
||||
+ Consumer<T> consumer; // CraftBukkit - decompile error
|
||||
|
||||
if (itemstack != null) {
|
||||
consumer = createDefaultStackConfig(worldserver, itemstack, entityhuman);
|
||||
@@ -364,7 +372,7 @@
|
||||
@@ -440,7 +448,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
- return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1);
|
||||
+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, spawnReason); // CraftBukkit
|
||||
- return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1);
|
||||
+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit
|
||||
}
|
||||
|
||||
public static <T extends Entity> Consumer<T> createDefaultStackConfig(WorldServer worldserver, ItemStack itemstack, @Nullable EntityHuman entityhuman) {
|
||||
@@ -388,21 +396,37 @@
|
||||
public static <T extends Entity> Consumer<T> createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) {
|
||||
@@ -464,21 +472,37 @@
|
||||
CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY);
|
||||
|
||||
return !customdata.isEmpty() ? consumer.andThen((entity) -> {
|
||||
- updateCustomEntityTag(worldserver, entityhuman, entity, customdata);
|
||||
+ try { updateCustomEntityTag(worldserver, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
|
||||
- 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
|
||||
}) : consumer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn) {
|
||||
- return this.spawn(worldserver, (Consumer) null, blockposition, enummobspawn, false, false);
|
||||
public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) {
|
||||
- return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false);
|
||||
+ // CraftBukkit start
|
||||
+ return this.spawn(worldserver, blockposition, enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ return this.spawn(worldserver, (Consumer<T>) null, blockposition, enummobspawn, false, false, spawnReason); // CraftBukkit - decompile error
|
||||
+ 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
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
|
||||
public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
T t0 = this.create(worldserver, consumer, blockposition, enummobspawn, flag, flag1);
|
||||
T t0 = this.create(worldserver, consumer, blockposition, entityspawnreason, flag, flag1);
|
||||
|
||||
if (t0 != null) {
|
||||
- worldserver.addFreshEntityWithPassengers(t0);
|
||||
@ -94,7 +92,7 @@
|
||||
}
|
||||
|
||||
return t0;
|
||||
@@ -583,7 +607,7 @@
|
||||
@@ -649,7 +673,7 @@
|
||||
}
|
||||
|
||||
return entity;
|
||||
@ -102,8 +100,8 @@
|
||||
+ }).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) {
|
||||
@@ -644,7 +668,7 @@
|
||||
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world, final EntitySpawnReason entityspawnreason) {
|
||||
@@ -710,7 +734,7 @@
|
||||
|
||||
@Nullable
|
||||
public T tryCast(Entity entity) {
|
||||
@ -112,7 +110,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -681,7 +705,7 @@
|
||||
@@ -779,7 +803,7 @@
|
||||
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/IEntitySelector.java
|
||||
+++ b/net/minecraft/world/entity/IEntitySelector.java
|
||||
@@ -44,7 +44,7 @@
|
||||
@@ -43,7 +43,7 @@
|
||||
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteam == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteam.getCollisionRule();
|
||||
|
||||
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/Interaction.java
|
||||
+++ b/net/minecraft/world/entity/Interaction.java
|
||||
@@ -24,6 +24,12 @@
|
||||
@@ -26,6 +26,12 @@
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
public class Interaction extends Entity implements Attackable, Targeting {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -62,7 +68,7 @@
|
||||
@@ -64,7 +70,7 @@
|
||||
this.setHeight(nbttagcompound.getFloat("height"));
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
Logger logger;
|
||||
|
||||
if (nbttagcompound.contains("attack")) {
|
||||
@@ -142,9 +148,16 @@
|
||||
@@ -144,9 +150,16 @@
|
||||
@Override
|
||||
public boolean skipAttackInteraction(Entity entity) {
|
||||
if (entity instanceof EntityHuman entityhuman) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/Leashable.java
|
||||
+++ b/net/minecraft/world/entity/Leashable.java
|
||||
@@ -15,6 +15,11 @@
|
||||
@@ -16,6 +16,11 @@
|
||||
import net.minecraft.world.level.IMaterial;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
public interface Leashable {
|
||||
|
||||
String LEASH_TAG = "leash";
|
||||
@@ -44,7 +49,7 @@
|
||||
@@ -45,7 +50,7 @@
|
||||
|
||||
default void setDelayedLeashHolderId(int i) {
|
||||
this.setLeashData(new Leashable.a(i));
|
||||
@ -21,7 +21,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -53,7 +58,7 @@
|
||||
@@ -54,7 +59,7 @@
|
||||
return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID")));
|
||||
} else {
|
||||
if (nbttagcompound.contains("leash", 11)) {
|
||||
@ -30,7 +30,7 @@
|
||||
|
||||
if (either != null) {
|
||||
return new Leashable.a(either);
|
||||
@@ -68,6 +73,11 @@
|
||||
@@ -69,6 +74,11 @@
|
||||
if (leashable_a != null) {
|
||||
Either<UUID, BlockPosition> either = leashable_a.delayedLeashInfo;
|
||||
Entity entity = leashable_a.leashHolder;
|
||||
@ -42,17 +42,17 @@
|
||||
|
||||
if (entity instanceof EntityLeash) {
|
||||
EntityLeash entityleash = (EntityLeash) entity;
|
||||
@@ -110,7 +120,9 @@
|
||||
@@ -111,7 +121,9 @@
|
||||
}
|
||||
|
||||
if (e0.tickCount > 100) {
|
||||
+ e0.forceDrops = true; // CraftBukkit
|
||||
e0.spawnAtLocation((IMaterial) Items.LEAD);
|
||||
e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD);
|
||||
+ e0.forceDrops = false; // CraftBukkit
|
||||
((Leashable) e0).setLeashData((Leashable.a) null);
|
||||
}
|
||||
}
|
||||
@@ -119,7 +131,7 @@
|
||||
@@ -120,7 +132,7 @@
|
||||
}
|
||||
|
||||
default void dropLeash(boolean flag, boolean flag1) {
|
||||
@ -61,27 +61,27 @@
|
||||
}
|
||||
|
||||
private static <E extends Entity & Leashable> void dropLeash(E e0, boolean flag, boolean flag1) {
|
||||
@@ -128,7 +140,9 @@
|
||||
if (leashable_a != null && leashable_a.leashHolder != null) {
|
||||
((Leashable) e0).setLeashData((Leashable.a) null);
|
||||
if (!e0.level().isClientSide && flag1) {
|
||||
+ e0.forceDrops = true; // CraftBukkit
|
||||
e0.spawnAtLocation((IMaterial) Items.LEAD);
|
||||
+ e0.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
@@ -134,7 +146,9 @@
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (flag) {
|
||||
@@ -153,7 +167,8 @@
|
||||
if (flag1) {
|
||||
+ e0.forceDrops = true; // CraftBukkit
|
||||
e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD);
|
||||
+ e0.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@@ -154,7 +168,8 @@
|
||||
|
||||
if (leashable_a != null && leashable_a.leashHolder != null) {
|
||||
if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) {
|
||||
- dropLeash(e0, true, true);
|
||||
+ e0.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
||||
+ dropLeash(e0, true, !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
|
||||
- dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS));
|
||||
+ worldserver.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
||||
+ dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
|
||||
}
|
||||
|
||||
Entity entity = ((Leashable) e0).getLeashHolder();
|
||||
@@ -183,13 +198,18 @@
|
||||
@@ -184,13 +199,18 @@
|
||||
}
|
||||
|
||||
default void leashTooFarBehaviour() {
|
||||
@ -101,7 +101,7 @@
|
||||
}
|
||||
|
||||
private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) {
|
||||
@@ -201,7 +221,7 @@
|
||||
@@ -202,7 +222,7 @@
|
||||
}
|
||||
|
||||
default void setLeashedTo(Entity entity, boolean flag) {
|
||||
@ -110,7 +110,7 @@
|
||||
}
|
||||
|
||||
private static <E extends Entity & Leashable> void setLeashedTo(E e0, Entity entity, boolean flag) {
|
||||
@@ -232,7 +252,7 @@
|
||||
@@ -233,7 +253,7 @@
|
||||
|
||||
@Nullable
|
||||
default Entity getLeashHolder() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java
|
||||
@@ -8,6 +8,12 @@
|
||||
@@ -7,6 +7,12 @@
|
||||
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
public class BehaviorAttackTargetForget {
|
||||
|
||||
private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200;
|
||||
@@ -41,6 +47,17 @@
|
||||
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !predicate.test(entityliving)) {
|
||||
@@ -40,6 +46,17 @@
|
||||
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !behaviorattacktargetforget_a.test(worldserver, entityliving)) {
|
||||
return true;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
@ -28,6 +28,6 @@
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
biconsumer.accept(entityinsentient, entityliving);
|
||||
behaviorattacktargetforget_b.accept(worldserver, entityinsentient, entityliving);
|
||||
memoryaccessor.erase();
|
||||
return true;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java
|
||||
@@ -8,6 +8,13 @@
|
||||
@@ -7,6 +7,13 @@
|
||||
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
public class BehaviorAttackTargetSet {
|
||||
|
||||
public BehaviorAttackTargetSet() {}
|
||||
@@ -35,6 +42,17 @@
|
||||
@@ -34,6 +41,17 @@
|
||||
if (!entityinsentient.canAttack(entityliving)) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@
|
||||
@@ -28,6 +28,20 @@
|
||||
EntityItem entityitem = (EntityItem) behaviorbuilder_b.get(memoryaccessor2);
|
||||
|
||||
if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition())) {
|
||||
if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition()) && entityliving.canPickUpLoot()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (entityliving instanceof net.minecraft.world.entity.animal.allay.Allay) {
|
||||
+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(entityliving, entityitem, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
public static final int TIME_OUT_DURATION = 160;
|
||||
@@ -63,6 +70,13 @@
|
||||
return this.ramTargeting.test(entitycreature, entityliving);
|
||||
return this.ramTargeting.test(worldserver, entitycreature, entityliving);
|
||||
});
|
||||
}).ifPresent((entityliving) -> {
|
||||
+ // CraftBukkit start
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
|
||||
@@ -71,6 +71,12 @@
|
||||
@@ -72,6 +72,12 @@
|
||||
}
|
||||
|
||||
if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) {
|
||||
|
@ -15,8 +15,8 @@
|
||||
BlockPosition blockposition = this.mob.blockPosition();
|
||||
|
||||
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
|
||||
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
|
||||
- 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);
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
BlockPosition blockposition1 = blockposition.below();
|
||||
|
||||
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {
|
||||
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
|
||||
- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
|
||||
this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState()));
|
||||
this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
|
||||
@@ -21,6 +21,11 @@
|
||||
@@ -22,6 +22,11 @@
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
||||
|
||||
private final Block blockToRemove;
|
||||
@@ -96,6 +101,11 @@
|
||||
@@ -97,6 +102,11 @@
|
||||
}
|
||||
|
||||
if (this.ticksSinceReachedGoal > 60) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
|
||||
@@ -10,6 +10,13 @@
|
||||
@@ -11,6 +11,13 @@
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
+
|
||||
public class PathfinderGoalTempt extends PathfinderGoal {
|
||||
|
||||
private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.forNonCombat().range(10.0D).ignoreLineOfSight();
|
||||
@@ -22,7 +29,7 @@
|
||||
private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight();
|
||||
@@ -23,7 +30,7 @@
|
||||
private double pRotX;
|
||||
private double pRotY;
|
||||
@Nullable
|
||||
@ -23,10 +23,10 @@
|
||||
private int calmDown;
|
||||
private boolean isRunning;
|
||||
private final Predicate<ItemStack> items;
|
||||
@@ -44,6 +51,15 @@
|
||||
@@ -47,6 +54,15 @@
|
||||
return false;
|
||||
} else {
|
||||
this.player = this.mob.level().getNearestPlayer(this.targetingConditions, this.mob);
|
||||
this.player = getServerLevel((Entity) this.mob).getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(GenericAttributes.TEMPT_RANGE)), this.mob);
|
||||
+ // CraftBukkit start
|
||||
+ if (this.player != null) {
|
||||
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT);
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
|
||||
@@ -58,7 +58,7 @@
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
|
||||
@@ -67,7 +67,7 @@
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
|
||||
@@ -18,6 +18,14 @@
|
||||
@@ -19,6 +19,14 @@
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@ -14,17 +14,17 @@
|
||||
+
|
||||
public class TemptingSensor extends Sensor<EntityCreature> {
|
||||
|
||||
public static final int TEMPTATION_RANGE = 10;
|
||||
@@ -30,7 +38,7 @@
|
||||
|
||||
private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight();
|
||||
@@ -31,7 +39,7 @@
|
||||
protected void doTick(WorldServer worldserver, EntityCreature entitycreature) {
|
||||
BehaviorController<?> behaviorcontroller = entitycreature.getBrain();
|
||||
PathfinderTargetCondition pathfindertargetcondition = TemptingSensor.TEMPT_TARGETING.copy().range((double) ((float) entitycreature.getAttributeValue(GenericAttributes.TEMPT_RANGE)));
|
||||
- Stream stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> {
|
||||
+ Stream<net.minecraft.server.level.EntityPlayer> stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> { // CraftBukkit - decompile error
|
||||
return TemptingSensor.TEMPT_TARGETING.test(entitycreature, entityplayer);
|
||||
}).filter((entityplayer) -> {
|
||||
return entitycreature.closerThan(entityplayer, 10.0D);
|
||||
@@ -44,7 +52,17 @@
|
||||
return pathfindertargetcondition.test(worldserver, entitycreature, entityplayer);
|
||||
}).filter(this::playerHoldingTemptation).filter((entityplayer) -> {
|
||||
return !entitycreature.hasPassenger((Entity) entityplayer);
|
||||
@@ -43,7 +51,17 @@
|
||||
if (!list.isEmpty()) {
|
||||
EntityHuman entityhuman = (EntityHuman) list.get(0);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/ambient/EntityBat.java
|
||||
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
|
||||
@@ -27,6 +27,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@@ -30,6 +30,10 @@
|
||||
import net.minecraft.world.level.levelgen.HeightMap;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -11,37 +11,37 @@
|
||||
public class EntityBat extends EntityAmbient {
|
||||
|
||||
public static final float FLAP_LENGTH_SECONDS = 0.5F;
|
||||
@@ -141,13 +145,13 @@
|
||||
@@ -144,13 +148,13 @@
|
||||
this.yHeadRot = (float) this.random.nextInt(360);
|
||||
}
|
||||
|
||||
- if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
|
||||
+ if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
- if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
|
||||
+ if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
this.setResting(false);
|
||||
if (!flag) {
|
||||
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
||||
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
||||
}
|
||||
}
|
||||
- } else {
|
||||
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
this.setResting(false);
|
||||
if (!flag) {
|
||||
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
||||
@@ -174,7 +178,7 @@
|
||||
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
|
||||
@@ -177,7 +181,7 @@
|
||||
|
||||
this.zza = 0.5F;
|
||||
this.setYRot(this.getYRot() + f1);
|
||||
- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
|
||||
+ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
- if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1)) {
|
||||
+ if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
this.setResting(true);
|
||||
}
|
||||
}
|
||||
@@ -199,7 +203,7 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
@@ -202,7 +206,7 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
- if (!this.level().isClientSide && this.isResting()) {
|
||||
+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
- if (this.isResting()) {
|
||||
+ if (this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
|
||||
this.setResting(false);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,6 @@
|
||||
|
||||
- t0.discard();
|
||||
+ t0.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
return Optional.of(EnumInteractionResult.sidedSuccess(world.isClientSide));
|
||||
return Optional.of(EnumInteractionResult.SUCCESS);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
@@ -29,12 +29,20 @@
|
||||
@@ -35,12 +35,20 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
|
||||
@ -21,25 +21,25 @@
|
||||
|
||||
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -72,9 +80,15 @@
|
||||
@@ -82,9 +90,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.resetLove();
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,10 +176,17 @@
|
||||
@@ -188,10 +202,17 @@
|
||||
}
|
||||
|
||||
public void setInLove(@Nullable EntityHuman entityhuman) {
|
||||
@ -58,7 +58,7 @@
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
}
|
||||
@@ -207,12 +228,29 @@
|
||||
@@ -233,12 +254,29 @@
|
||||
if (entityageable != null) {
|
||||
entityageable.setBaby(true);
|
||||
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
@ -90,7 +90,7 @@
|
||||
Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
return Optional.ofNullable(entityanimal.getLoveCause());
|
||||
}).ifPresent((entityplayer) -> {
|
||||
@@ -225,7 +263,11 @@
|
||||
@@ -251,7 +289,11 @@
|
||||
entityanimal.resetLove();
|
||||
worldserver.broadcastEntityEvent(this, (byte) 18);
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityBee.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityBee.java
|
||||
@@ -87,6 +87,12 @@
|
||||
@@ -89,6 +89,12 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird {
|
||||
|
||||
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
|
||||
@@ -186,12 +192,19 @@
|
||||
@@ -194,12 +200,19 @@
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
@ -35,18 +35,18 @@
|
||||
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos()));
|
||||
}
|
||||
|
||||
@@ -205,8 +218,8 @@
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
@@ -219,8 +232,8 @@
|
||||
this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination");
|
||||
this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks");
|
||||
this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination");
|
||||
- this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null);
|
||||
- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null);
|
||||
+ this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error
|
||||
+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
this.setHasNectar(nbttagcompound.getBoolean("HasNectar"));
|
||||
this.setHasStung(nbttagcompound.getBoolean("HasStung"));
|
||||
@@ -243,7 +256,7 @@
|
||||
this.readPersistentAngerSaveData(this.level(), nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -244,7 +257,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
@ -55,24 +55,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,11 +649,14 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
@@ -502,7 +515,7 @@
|
||||
|
||||
@Nullable
|
||||
TileEntityBeehive getBeehiveBlockEntity() {
|
||||
- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse((Object) null));
|
||||
+ return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse(null)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
boolean isHiveValid() {
|
||||
@@ -638,8 +651,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
- if (!this.level().isClientSide) {
|
||||
+ // CraftBukkit start - Only stop pollinating if entity was damaged
|
||||
+ boolean result = super.hurt(damagesource, f);
|
||||
+ if (result && !this.level().isClientSide) {
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.beePollinateGoal.stopPollinating();
|
||||
}
|
||||
|
||||
- return super.hurt(damagesource, f);
|
||||
this.beePollinateGoal.stopPollinating();
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,7 +1008,7 @@
|
||||
@@ -1048,7 +1067,7 @@
|
||||
|
||||
e() {
|
||||
super();
|
||||
@ -81,7 +89,7 @@
|
||||
this.blacklistedTargets = Lists.newArrayList();
|
||||
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
@@ -1109,7 +1125,7 @@
|
||||
@@ -1162,7 +1181,7 @@
|
||||
|
||||
f() {
|
||||
super();
|
||||
@ -90,7 +98,7 @@
|
||||
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
|
||||
@@ -1209,7 +1225,7 @@
|
||||
@@ -1267,7 +1286,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +107,7 @@
|
||||
EntityBee.this.level().levelEvent(2011, blockposition, 15);
|
||||
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
|
||||
EntityBee.this.incrementNumCropsGrownSincePollination();
|
||||
@@ -1282,7 +1298,7 @@
|
||||
@@ -1344,7 +1363,7 @@
|
||||
@Override
|
||||
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
|
||||
@ -108,7 +116,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1291,7 +1307,7 @@
|
||||
@@ -1353,7 +1372,7 @@
|
||||
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
|
||||
|
||||
c(EntityBee entitybee) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityCat.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityCat.java
|
||||
@@ -181,10 +181,10 @@
|
||||
@@ -174,10 +174,10 @@
|
||||
@Override
|
||||
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
@ -12,8 +12,8 @@
|
||||
+ IRegistry<CatVariant> iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
optional.flatMap(iregistry::getHolder).ifPresent(this::setVariant);
|
||||
@@ -452,7 +452,7 @@
|
||||
optional.flatMap(iregistry::get).ifPresent(this::setVariant);
|
||||
@@ -463,7 +463,7 @@
|
||||
}
|
||||
|
||||
private void tryToTame(EntityHuman entityhuman) {
|
||||
@ -22,7 +22,7 @@
|
||||
this.tame(entityhuman);
|
||||
this.setOrderedToSit(true);
|
||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||
@@ -470,7 +470,7 @@
|
||||
@@ -481,7 +481,7 @@
|
||||
private static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
|
||||
|
||||
@Nullable
|
||||
@ -31,24 +31,24 @@
|
||||
private final EntityCat cat;
|
||||
|
||||
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate<ItemStack> predicate, boolean flag) {
|
||||
@@ -611,7 +611,15 @@
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack = (ItemStack) iterator.next();
|
||||
|
||||
- this.cat.level().addFreshEntity(new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack));
|
||||
@@ -615,7 +615,15 @@
|
||||
this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false);
|
||||
blockposition_mutableblockposition.set(this.cat.blockPosition());
|
||||
this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> {
|
||||
- worldserver.addFreshEntity(new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack));
|
||||
+ // CraftBukkit start
|
||||
+ EntityItem entityitem = new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack);
|
||||
+ EntityItem entityitem = new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack);
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ entityitem.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ return;
|
||||
+ }
|
||||
+ this.cat.level().addFreshEntity(entityitem);
|
||||
+ worldserver.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@@ -643,10 +651,10 @@
|
||||
|
||||
@@ -646,10 +654,10 @@
|
||||
private final EntityCat cat;
|
||||
|
||||
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {
|
||||
|
@ -1,12 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityChicken.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
|
||||
@@ -98,7 +98,9 @@
|
||||
this.flap += this.flapping * 2.0F;
|
||||
if (!this.level().isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
|
||||
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation((IMaterial) Items.EGG);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
this.eggTime = this.random.nextInt(6000) + 6000;
|
||||
}
|
||||
@@ -99,10 +99,12 @@
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
if (this.dropFromGiftLootTable(worldserver, LootTables.CHICKEN_LAY, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
this.eggTime = this.random.nextInt(6000) + 6000;
|
||||
}
|
||||
|
@ -30,4 +30,4 @@
|
||||
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
entityhuman.setItemInHand(enumhand, itemstack1);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
|
||||
@@ -59,8 +59,20 @@
|
||||
@@ -62,8 +62,20 @@
|
||||
import net.minecraft.world.level.pathfinder.PathMode;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityDolphin extends EntityWaterAnimal {
|
||||
public class EntityDolphin extends AgeableWaterCreature {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
@ -21,7 +21,7 @@
|
||||
private static final DataWatcherObject<BlockPosition> TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS);
|
||||
private static final DataWatcherObject<Boolean> GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN);
|
||||
private static final DataWatcherObject<Integer> MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT);
|
||||
@@ -176,7 +188,7 @@
|
||||
@@ -200,7 +212,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,11 +224,17 @@
|
||||
@@ -234,11 +246,17 @@
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
if (this.canHoldItem(itemstack)) {
|
||||
@ -49,7 +49,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +485,7 @@
|
||||
@@ -495,7 +513,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -486,7 +504,7 @@
|
||||
@@ -514,7 +532,7 @@
|
||||
}
|
||||
|
||||
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityFox.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityFox.java
|
||||
@@ -93,6 +93,10 @@
|
||||
@@ -91,6 +91,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
public class EntityFox extends EntityAnimal implements VariantHolder<EntityFox.Type> {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT);
|
||||
@@ -518,7 +522,8 @@
|
||||
protected void pickUpItem(EntityItem entityitem) {
|
||||
@@ -503,7 +507,8 @@
|
||||
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
- if (this.canHoldItem(itemstack)) {
|
||||
@ -21,7 +21,7 @@
|
||||
int i = itemstack.getCount();
|
||||
|
||||
if (i > 1) {
|
||||
@@ -530,7 +535,7 @@
|
||||
@@ -515,7 +520,7 @@
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1));
|
||||
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
@ -30,7 +30,7 @@
|
||||
this.ticksSinceEaten = 0;
|
||||
}
|
||||
|
||||
@@ -868,6 +873,16 @@
|
||||
@@ -853,6 +858,16 @@
|
||||
if (entityplayer1 != null && entityplayer != entityplayer1) {
|
||||
entityfox.addTrustedUUID(entityplayer1.getUUID());
|
||||
}
|
||||
@ -47,7 +47,7 @@
|
||||
|
||||
if (entityplayer2 != null) {
|
||||
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
|
||||
@@ -878,12 +893,14 @@
|
||||
@@ -863,12 +878,14 @@
|
||||
this.partner.setAge(6000);
|
||||
this.animal.resetLove();
|
||||
this.partner.resetLove();
|
||||
@ -56,7 +56,7 @@
|
||||
- worldserver.addFreshEntityWithPassengers(entityfox);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
this.level.broadcastEntityEvent(this.animal, (byte) 18);
|
||||
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
@ -66,7 +66,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1279,6 +1296,11 @@
|
||||
@@ -1264,6 +1281,11 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
|
||||
|
||||
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
|
||||
@ -78,12 +78,12 @@
|
||||
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
|
||||
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
|
||||
|
||||
@@ -1436,7 +1458,7 @@
|
||||
private EntityLiving trustedLastHurt;
|
||||
private int timestamp;
|
||||
|
||||
- public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate predicate) {
|
||||
+ public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
|
||||
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
|
||||
@@ -1494,7 +1516,7 @@
|
||||
}
|
||||
|
||||
public static EntityFox.Type byName(String s) {
|
||||
- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED);
|
||||
+ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static EntityFox.Type byId(int i) {
|
||||
|
@ -1,66 +1,59 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
||||
@@ -42,6 +42,14 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@@ -44,6 +44,13 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder<EntityMushroomCow.Type> {
|
||||
|
||||
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
|
||||
@@ -114,6 +122,11 @@
|
||||
this.playSound(soundeffect, 1.0F, 1.0F);
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
|
||||
} else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -157,7 +170,7 @@
|
||||
@@ -121,6 +128,11 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (entitycow != null) {
|
||||
((WorldServer) this.level()).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
- this.discard();
|
||||
+ // this.discard(); // CraftBukkit - moved down
|
||||
entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
entitycow.setHealth(this.getHealth());
|
||||
entitycow.yBodyRot = this.yBodyRot;
|
||||
@@ -171,10 +184,25 @@
|
||||
}
|
||||
|
||||
entitycow.setInvulnerable(this.isInvulnerable());
|
||||
- this.level().addFreshEntity(entitycow);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
||||
+ return;
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ this.level().addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
||||
+
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause
|
||||
+ // CraftBukkit end
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
- this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())));
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -162,11 +174,19 @@
|
||||
worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
- worldserver1.addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)));
|
||||
+ // CraftBukkit start
|
||||
+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()));
|
||||
+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1));
|
||||
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ this.level().addFreshEntity(entityitem);
|
||||
+ worldserver1.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
- });
|
||||
+ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +282,7 @@
|
||||
}
|
||||
|
||||
static EntityMushroomCow.Type byName(String s) {
|
||||
- return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, (Enum) EntityMushroomCow.Type.RED);
|
||||
+ return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, EntityMushroomCow.Type.RED); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
|
||||
@@ -168,7 +168,7 @@
|
||||
@@ -167,7 +167,7 @@
|
||||
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) {
|
||||
this.usePlayerItem(entityhuman, enumhand, itemstack);
|
||||
if (!this.level().isClientSide) {
|
||||
@ -9,7 +9,7 @@
|
||||
this.setTrusting(true);
|
||||
this.spawnTrustingParticles(true);
|
||||
this.level().broadcastEntityEvent(this, (byte) 41);
|
||||
@@ -299,10 +299,10 @@
|
||||
@@ -298,10 +298,10 @@
|
||||
private final EntityOcelot ocelot;
|
||||
|
||||
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPanda.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
|
||||
@@ -73,6 +73,12 @@
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
|
||||
@@ -69,6 +69,12 @@
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start;
|
||||
@ -13,12 +13,12 @@
|
||||
public class EntityPanda extends EntityAnimal {
|
||||
|
||||
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT);
|
||||
@@ -558,14 +564,14 @@
|
||||
@@ -541,14 +547,14 @@
|
||||
|
||||
@Override
|
||||
protected void pickUpItem(EntityItem entityitem) {
|
||||
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) {
|
||||
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit
|
||||
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
||||
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem)) {
|
||||
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem))).isCancelled()) { // CraftBukkit
|
||||
this.onItemPickup(entityitem);
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
@ -30,7 +30,16 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -889,10 +895,10 @@
|
||||
@@ -772,7 +778,7 @@
|
||||
}
|
||||
|
||||
public static EntityPanda.Gene byName(String s) {
|
||||
- return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, (Enum) EntityPanda.Gene.NORMAL);
|
||||
+ return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, EntityPanda.Gene.NORMAL); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static EntityPanda.Gene getRandom(RandomSource randomsource) {
|
||||
@@ -876,10 +882,10 @@
|
||||
private final EntityPanda panda;
|
||||
|
||||
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
|
||||
@ -44,7 +53,7 @@
|
||||
this.panda = entitypanda;
|
||||
}
|
||||
|
||||
@@ -1131,7 +1137,7 @@
|
||||
@@ -1116,7 +1122,7 @@
|
||||
@Override
|
||||
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityParrot.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
|
||||
@@ -248,7 +248,7 @@
|
||||
@@ -250,7 +250,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
@ -9,16 +9,16 @@
|
||||
this.tame(entityhuman);
|
||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||
} else {
|
||||
@@ -269,7 +269,7 @@
|
||||
@@ -271,7 +271,7 @@
|
||||
}
|
||||
} else {
|
||||
itemstack.consume(1, entityhuman);
|
||||
this.usePlayerItem(entityhuman, enumhand, itemstack);
|
||||
- this.addEffect(new MobEffect(MobEffects.POISON, 900));
|
||||
+ this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
if (entityhuman.isCreative() || !this.isInvulnerable()) {
|
||||
this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE);
|
||||
}
|
||||
@@ -363,7 +363,7 @@
|
||||
@@ -365,7 +365,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
@ -27,19 +27,18 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -378,11 +378,14 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
@@ -380,8 +380,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
- if (!this.level().isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurt(damagesource, f);
|
||||
+ if (!this.level().isClientSide && result) {
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
}
|
||||
|
||||
- return super.hurt(damagesource, f);
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPig.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPig.java
|
||||
@@ -49,6 +49,11 @@
|
||||
@@ -50,6 +50,11 @@
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -12,20 +12,19 @@
|
||||
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -253,8 +258,14 @@
|
||||
@@ -247,7 +252,14 @@
|
||||
}
|
||||
|
||||
entitypigzombie.setPersistenceRequired();
|
||||
- worldserver.addFreshEntity(entitypigzombie);
|
||||
- this.discard();
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit - added a reason for spawning this creature
|
||||
+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ // CraftBukkit end
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
} else {
|
||||
entitypigzombie1.setPersistenceRequired();
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, null, null);
|
||||
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entitypigzombie == null) {
|
||||
super.thunderHit(worldserver, entitylightning);
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPufferFish.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPufferFish.java
|
||||
@@ -150,7 +150,7 @@
|
||||
@@ -155,7 +155,7 @@
|
||||
int i = this.getPuffState();
|
||||
|
||||
if (entityinsentient.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) {
|
||||
if (entityinsentient.hurtServer(worldserver, this.damageSources().mobAttack(this), (float) (1 + i))) {
|
||||
- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
((EntityPlayer) entityhuman).connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
|
||||
}
|
||||
@@ -171,7 +171,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
|
||||
}
|
||||
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
|
||||
@@ -67,6 +67,10 @@
|
||||
@@ -66,6 +66,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathEntity;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
public class EntityRabbit extends EntityAnimal implements VariantHolder<EntityRabbit.Variant> {
|
||||
|
||||
public static final double STROLL_SPEED_MOD = 0.6D;
|
||||
@@ -91,7 +95,6 @@
|
||||
@@ -90,7 +94,6 @@
|
||||
super(entitytypes, world);
|
||||
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
|
||||
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
|
||||
@ -19,7 +19,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -578,9 +581,19 @@
|
||||
@@ -577,9 +580,19 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntitySheep.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
|
||||
@@ -63,6 +63,12 @@
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
@@ -57,6 +57,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -13,29 +13,29 @@
|
||||
public class EntitySheep extends EntityAnimal implements IShearable {
|
||||
|
||||
private static final int EAT_ANIMATION_TICKS = 40;
|
||||
@@ -250,6 +256,11 @@
|
||||
@@ -167,6 +173,11 @@
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (itemstack.is(Items.SHEARS)) {
|
||||
if (!this.level().isClientSide && this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -269,7 +280,9 @@
|
||||
int i = 1 + this.random.nextInt(3);
|
||||
if (this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -185,7 +196,9 @@
|
||||
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
EntityItem entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
if (entityitem != null) {
|
||||
entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
||||
@@ -362,6 +375,12 @@
|
||||
if (entityitem != null) {
|
||||
entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
||||
@@ -280,6 +293,12 @@
|
||||
|
||||
@Override
|
||||
public void ate() {
|
||||
@ -48,12 +48,12 @@
|
||||
super.ate();
|
||||
this.setSheared(false);
|
||||
if (this.isBaby()) {
|
||||
@@ -381,7 +400,7 @@
|
||||
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
|
||||
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
|
||||
@@ -299,7 +318,7 @@
|
||||
EnumColor enumcolor = entitysheep.getColor();
|
||||
EnumColor enumcolor1 = entitysheep1.getColor();
|
||||
CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1);
|
||||
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> {
|
||||
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
|
||||
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess());
|
||||
- Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> {
|
||||
+ Optional<Item> optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { // CraftBukkit - decompile error
|
||||
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess());
|
||||
}).map(ItemStack::getItem);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntitySnowman.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntitySnowman.java
|
||||
@@ -40,6 +40,10 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
@@ -43,6 +43,10 @@
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
@ -11,16 +11,16 @@
|
||||
public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity {
|
||||
|
||||
private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE);
|
||||
@@ -95,7 +99,7 @@
|
||||
super.aiStep();
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -100,7 +104,7 @@
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
|
||||
- this.hurt(this.damageSources().onFire(), 1.0F);
|
||||
+ this.hurt(this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
|
||||
- this.hurtServer(worldserver, this.damageSources().onFire(), 1.0F);
|
||||
+ this.hurtServer(worldserver, this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
|
||||
}
|
||||
|
||||
if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
@@ -111,7 +115,11 @@
|
||||
if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
@@ -116,7 +120,11 @@
|
||||
BlockPosition blockposition = new BlockPosition(j, k, l);
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
@ -33,25 +33,25 @@
|
||||
this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
|
||||
}
|
||||
}
|
||||
@@ -138,6 +146,11 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
@@ -153,6 +161,11 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -155,7 +168,9 @@
|
||||
this.level().playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
if (!this.level().isClientSide()) {
|
||||
this.setPumpkin(false);
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -169,7 +182,9 @@
|
||||
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
this.setPumpkin(false);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (worldserver1, itemstack1) -> {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), this.getEyeHeight());
|
||||
this.spawnAtLocation(worldserver1, itemstack1, this.getEyeHeight());
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
|
||||
@@ -305,7 +305,9 @@
|
||||
protected void ageBoundaryReached() {
|
||||
super.ageBoundaryReached();
|
||||
if (!this.isBaby() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(Items.TURTLE_SCUTE, 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
@@ -310,7 +310,9 @@
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
}
|
||||
@@ -332,7 +334,7 @@
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, Items.TURTLE_SCUTE, 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +341,7 @@
|
||||
|
||||
@Override
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
- this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE);
|
||||
+ this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
|
||||
- this.hurtServer(worldserver, this.damageSources().lightningBolt(), Float.MAX_VALUE);
|
||||
+ this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -489,12 +491,14 @@
|
||||
@@ -496,12 +498,14 @@
|
||||
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
|
||||
World world = this.turtle.level();
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
@@ -90,6 +90,13 @@
|
||||
@@ -86,6 +86,13 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@ -14,32 +14,31 @@
|
||||
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder<Holder<WolfVariant>> {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -360,11 +367,14 @@
|
||||
if (this.isInvulnerableTo(damagesource)) {
|
||||
@@ -345,8 +352,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
- if (!this.level().isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurt(damagesource, f);
|
||||
+ if (!this.level().isClientSide && result) {
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
}
|
||||
|
||||
- return super.hurt(damagesource, f);
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,10 +384,15 @@
|
||||
@@ -356,10 +369,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
|
||||
if (!this.canArmorAbsorb(damagesource)) {
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
+ return super.actuallyHurt(damagesource, f, event); // CraftBukkit
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return super.actuallyHurt(worldserver, damagesource, f, event); // CraftBukkit
|
||||
} else {
|
||||
+ // CraftBukkit start - SPIGOT-7815: if the damage was cancelled, no need to run the wolf armor behaviour
|
||||
+ if (event.isCancelled()) {
|
||||
@ -49,7 +48,7 @@
|
||||
ItemStack itemstack = this.getBodyArmorItem();
|
||||
int i = itemstack.getDamageValue();
|
||||
int j = itemstack.getMaxDamage();
|
||||
@@ -395,6 +410,7 @@
|
||||
@@ -371,6 +389,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -57,7 +56,7 @@
|
||||
}
|
||||
|
||||
private boolean canArmorAbsorb(DamageSource damagesource) {
|
||||
@@ -405,7 +421,7 @@
|
||||
@@ -381,7 +400,7 @@
|
||||
protected void applyTamingSideEffects() {
|
||||
if (this.isTame()) {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D);
|
||||
@ -66,35 +65,35 @@
|
||||
} else {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
|
||||
}
|
||||
@@ -432,7 +448,7 @@
|
||||
@@ -404,7 +423,7 @@
|
||||
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
||||
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
|
||||
|
||||
- this.heal(2.0F * f);
|
||||
+ this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
return EnumInteractionResult.sidedSuccess(this.level().isClientSide());
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else {
|
||||
if (item instanceof ItemDye) {
|
||||
@@ -463,7 +479,9 @@
|
||||
this.playSound(SoundEffects.ARMOR_UNEQUIP_WOLF);
|
||||
itemstack1 = this.getBodyArmorItem();
|
||||
this.setBodyArmorItem(ItemStack.EMPTY);
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
@@ -440,7 +459,9 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else if (((RecipeItemStack) ((ArmorMaterial) EnumArmorMaterial.ARMADILLO.value()).repairIngredient().get()).test(itemstack) && this.isInSittingPose() && this.hasArmor() && this.isOwnedBy(entityhuman) && this.getBodyArmorItem().isDamaged()) {
|
||||
itemstack.shrink(1);
|
||||
@@ -480,7 +498,7 @@
|
||||
@@ -459,7 +480,7 @@
|
||||
this.setOrderedToSit(!this.isOrderedToSit());
|
||||
this.jumping = false;
|
||||
this.navigation.stop();
|
||||
- this.setTarget((EntityLiving) null);
|
||||
+ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
||||
return EnumInteractionResult.SUCCESS_NO_ITEM_USED;
|
||||
return EnumInteractionResult.SUCCESS.withoutItem();
|
||||
} else {
|
||||
return enuminteractionresult;
|
||||
@@ -498,7 +516,8 @@
|
||||
@@ -477,7 +498,8 @@
|
||||
}
|
||||
|
||||
private void tryToTame(EntityHuman entityhuman) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -101,6 +101,7 @@
|
||||
@@ -103,6 +103,7 @@
|
||||
private float dancingAnimationTicks;
|
||||
private float spinningAnimationTicks;
|
||||
private float spinningAnimationTicks0;
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -112,6 +113,12 @@
|
||||
@@ -114,6 +115,12 @@
|
||||
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()));
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
@Override
|
||||
protected BehaviorController.b<Allay> brainProvider() {
|
||||
return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
|
||||
@@ -124,7 +131,7 @@
|
||||
@@ -126,7 +133,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Allay> getBrain() {
|
||||
@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
public static AttributeProvider.Builder createAttributes() {
|
||||
@@ -225,7 +232,7 @@
|
||||
@@ -229,7 +236,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
|
||||
@ -39,10 +39,10 @@
|
||||
}
|
||||
|
||||
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
|
||||
@@ -295,7 +302,12 @@
|
||||
@@ -299,7 +306,12 @@
|
||||
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
|
||||
|
||||
if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) {
|
||||
if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) {
|
||||
- this.duplicateAllay();
|
||||
+ // CraftBukkit start - handle cancel duplication
|
||||
+ Allay allay = this.duplicateAllay();
|
||||
@ -53,7 +53,7 @@
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F);
|
||||
this.removeInteractionItem(entityhuman, itemstack);
|
||||
@@ -306,7 +318,7 @@
|
||||
@@ -310,7 +322,7 @@
|
||||
this.setItemInHand(EnumHand.MAIN_HAND, itemstack2);
|
||||
this.removeInteractionItem(entityhuman, itemstack);
|
||||
this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F);
|
||||
@ -62,7 +62,7 @@
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) {
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY);
|
||||
@@ -407,6 +419,7 @@
|
||||
@@ -411,6 +423,7 @@
|
||||
}
|
||||
|
||||
private boolean shouldStopDancing() {
|
||||
@ -70,16 +70,16 @@
|
||||
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
|
||||
}
|
||||
|
||||
@@ -500,7 +513,7 @@
|
||||
return Allay.DUPLICATION_ITEM.test(itemstack);
|
||||
@@ -502,7 +515,7 @@
|
||||
|
||||
}
|
||||
|
||||
- public void duplicateAllay() {
|
||||
+ public Allay duplicateAllay() { // CraftBukkit - return allay
|
||||
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level());
|
||||
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
|
||||
|
||||
if (allay != null) {
|
||||
@@ -508,9 +521,9 @@
|
||||
@@ -510,9 +523,9 @@
|
||||
allay.setPersistenceRequired();
|
||||
allay.resetDuplicationCooldown();
|
||||
this.resetDuplicationCooldown();
|
||||
|
@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -47,6 +47,10 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@@ -48,6 +48,10 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -11,33 +11,35 @@
|
||||
public class Armadillo extends EntityAnimal {
|
||||
|
||||
public static final float BABY_SCALE = 0.6F;
|
||||
@@ -132,14 +136,16 @@
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("armadilloBrain");
|
||||
- this.brain.tick((WorldServer) this.level(), this);
|
||||
+ ((BehaviorController<Armadillo>) this.brain).tick((WorldServer) this.level(), this); // CraftBukkit - decompile error
|
||||
this.level().getProfiler().pop();
|
||||
this.level().getProfiler().push("armadilloActivityUpdate");
|
||||
@@ -135,16 +139,18 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("armadilloBrain");
|
||||
- this.brain.tick(worldserver, this);
|
||||
+ ((BehaviorController<Armadillo>) this.brain).tick(worldserver, this); // CraftBukkit - decompile error
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("armadilloActivityUpdate");
|
||||
ArmadilloAi.updateActivity(this);
|
||||
this.level().getProfiler().pop();
|
||||
gameprofilerfiller.pop();
|
||||
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
||||
this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation((IMaterial) Items.ARMADILLO_SCUTE);
|
||||
if (this.dropFromGiftLootTable(worldserver, LootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
|
||||
this.scuteTime = this.pickNextScuteDropTime();
|
||||
}
|
||||
@@ -286,8 +292,13 @@
|
||||
@@ -291,8 +297,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
@ -45,7 +47,7 @@
|
||||
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
||||
if (damagesource.getEntity() instanceof EntityLiving) {
|
||||
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
|
||||
@@ -299,6 +310,7 @@
|
||||
@@ -304,6 +315,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -53,13 +55,22 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,7 +338,9 @@
|
||||
if (this.isBaby()) {
|
||||
return false;
|
||||
} else {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(new ItemStack(Items.ARMADILLO_SCUTE));
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
||||
this.playSound(SoundEffects.ARMADILLO_BRUSH);
|
||||
return true;
|
||||
@@ -327,7 +339,9 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE));
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
||||
this.playSound(SoundEffects.ARMADILLO_BRUSH);
|
||||
}
|
||||
@@ -431,7 +445,7 @@
|
||||
}
|
||||
|
||||
public static Armadillo.a fromName(String s) {
|
||||
- return (Armadillo.a) Armadillo.a.CODEC.byName(s, (Enum) Armadillo.a.IDLE);
|
||||
+ return (Armadillo.a) Armadillo.a.CODEC.byName(s, Armadillo.a.IDLE); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -68,9 +68,16 @@
|
||||
@@ -67,10 +67,17 @@
|
||||
|
||||
public class Axolotl extends EntityAnimal implements LerpingModel, VariantHolder<Axolotl.Variant>, Bucketable {
|
||||
public class Axolotl extends EntityAnimal implements VariantHolder<Axolotl.Variant>, Bucketable {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
@ -11,6 +11,7 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public static final int TOTAL_PLAYDEAD_TIME = 200;
|
||||
private static final int POSE_ANIMATION_TICKS = 10;
|
||||
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Axolotl>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS);
|
||||
- protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
|
||||
+ // CraftBukkit - decompile error
|
||||
@ -18,7 +19,7 @@
|
||||
private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT);
|
||||
private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
|
||||
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -187,7 +194,7 @@
|
||||
@@ -210,7 +217,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
@ -27,7 +28,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -391,7 +398,7 @@
|
||||
@@ -414,7 +421,7 @@
|
||||
int i = mobeffect != null ? mobeffect.getDuration() : 0;
|
||||
int j = Math.min(2400, 100 + i);
|
||||
|
||||
@ -36,7 +37,7 @@
|
||||
}
|
||||
|
||||
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
|
||||
@@ -441,7 +448,7 @@
|
||||
@@ -464,7 +471,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Axolotl> getBrain() {
|
||||
|
@ -8,32 +8,32 @@
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Camel extends EntityHorseAbstract implements IJumpable, ISaddleable {
|
||||
public class Camel extends EntityHorseAbstract {
|
||||
|
||||
public static final float BABY_SCALE = 0.45F;
|
||||
@@ -141,7 +145,7 @@
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level().getProfiler().push("camelBrain");
|
||||
@@ -143,7 +147,7 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("camelBrain");
|
||||
- BehaviorController<?> behaviorcontroller = this.getBrain();
|
||||
+ BehaviorController<Camel> behaviorcontroller = (BehaviorController<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
||||
|
||||
behaviorcontroller.tick((WorldServer) this.level(), this);
|
||||
this.level().getProfiler().pop();
|
||||
@@ -452,9 +456,15 @@
|
||||
behaviorcontroller.tick(worldserver, this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -454,9 +458,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource damagesource, float f) {
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.standUpInstantly();
|
||||
- super.actuallyHurt(damagesource, f);
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
}
|
||||
@@ -85,7 +89,7 @@
|
||||
if (entity.isAlive()) {
|
||||
frog.doHurtTarget(entity);
|
||||
frog.doHurtTarget(worldserver, entity);
|
||||
if (!entity.isAlive()) {
|
||||
- entity.remove(Entity.RemovalReason.KILLED);
|
||||
+ entity.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren