Update to Minecraft 1.20.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2023-09-22 02:40:00 +10:00
parent 193398c0ff
commit 8a3c8cfcd4
238 changed files with 2448 additions and 2344 deletions

View File

@ -1,10 +0,0 @@
--- a/net/minecraft/advancements/Advancement.java
+++ b/net/minecraft/advancements/Advancement.java
@@ -41,6 +41,7 @@
private final Set<Advancement> children = Sets.newLinkedHashSet();
private final IChatBaseComponent chatComponent;
private final boolean sendsTelemetryEvent;
+ public final org.bukkit.advancement.Advancement bukkit = new org.bukkit.craftbukkit.advancement.CraftAdvancement(this); // CraftBukkit
public Advancement(MinecraftKey minecraftkey, @Nullable Advancement advancement, @Nullable AdvancementDisplay advancementdisplay, AdvancementRewards advancementrewards, Map<String, Criterion> map, String[][] astring, boolean flag) {
this.id = minecraftkey;

View File

@ -0,0 +1,25 @@
--- a/net/minecraft/advancements/AdvancementHolder.java
+++ b/net/minecraft/advancements/AdvancementHolder.java
@@ -3,6 +3,11 @@
import net.minecraft.network.PacketDataSerializer;
import net.minecraft.resources.MinecraftKey;
+// CraftBukkit start
+import org.bukkit.craftbukkit.advancement.CraftAdvancement;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+// CraftBukkit end
+
public record AdvancementHolder(MinecraftKey id, Advancement value) {
public void write(PacketDataSerializer packetdataserializer) {
@@ -41,4 +46,10 @@
public String toString() {
return this.id.toString();
}
+
+ // CraftBukkit start
+ public final org.bukkit.advancement.Advancement toBukkit() {
+ return new CraftAdvancement(this);
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,20 @@
--- a/net/minecraft/advancements/AdvancementTree.java
+++ b/net/minecraft/advancements/AdvancementTree.java
@@ -68,7 +68,7 @@
}
public void addAll(Collection<AdvancementHolder> collection) {
- ArrayList arraylist = new ArrayList(collection);
+ ArrayList<AdvancementHolder> arraylist = new ArrayList(collection); // CraftBukkit - decompile error
while (!arraylist.isEmpty()) {
if (!arraylist.removeIf(this::tryInsert)) {
@@ -77,7 +77,7 @@
}
}
- AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size());
+ // AdvancementTree.LOGGER.info("Loaded {} advancements", this.nodes.size()); // CraftBukkit - moved to AdvancementDataWorld#reload
}
private boolean tryInsert(AdvancementHolder advancementholder) {

View File

@ -1,20 +0,0 @@
--- a/net/minecraft/advancements/Advancements.java
+++ b/net/minecraft/advancements/Advancements.java
@@ -80,7 +80,7 @@
entry = (Entry) iterator.next();
MinecraftKey minecraftkey = (MinecraftKey) entry.getKey();
Advancement.SerializedAdvancement advancement_serializedadvancement = (Advancement.SerializedAdvancement) entry.getValue();
- Map map1 = this.advancements;
+ Map<MinecraftKey, Advancement> map1 = this.advancements; // CraftBukkit - decompile error
Objects.requireNonNull(this.advancements);
if (advancement_serializedadvancement.canBuild(map1::get)) {
@@ -117,7 +117,7 @@
}
}
- Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size());
+ // Advancements.LOGGER.info("Loaded {} advancements", this.advancements.size()); // CraftBukkit - moved to AdvancementDataWorld#reload
}
public void clear() {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -120,6 +120,14 @@
@@ -122,6 +122,14 @@
import net.minecraft.util.profiling.jfr.JvmProfiler;
import org.slf4j.Logger;
@ -15,7 +15,7 @@
public class CommandDispatcher {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -131,6 +139,7 @@
@@ -133,6 +141,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);
@@ -220,6 +229,11 @@
@@ -226,6 +235,11 @@
CommandPublish.register(this.dispatcher);
}
@ -35,7 +35,7 @@
this.dispatcher.setConsumer((commandcontext, flag, i) -> {
((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i);
});
@@ -232,12 +246,59 @@
@@ -238,12 +252,59 @@
return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions());
}
@ -96,7 +96,7 @@
CommandListenerWrapper commandlistenerwrapper = (CommandListenerWrapper) parseresults.getContext().getSource();
commandlistenerwrapper.getServer().getProfiler().push(() -> {
@@ -262,7 +323,7 @@
@@ -268,7 +329,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.empty().withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
@ -105,7 +105,7 @@
});
if (j > 10) {
@@ -312,11 +373,36 @@
@@ -318,11 +379,36 @@
}
public void sendCommands(EntityPlayer entityplayer) {
@ -143,7 +143,7 @@
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
}
@@ -327,7 +413,7 @@
@@ -333,7 +419,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@ -152,7 +152,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -350,7 +436,7 @@
@@ -356,7 +442,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View File

@ -17,7 +17,7 @@
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -179,9 +182,23 @@
@@ -175,9 +178,23 @@
@Override
public boolean hasPermission(int i) {
@ -41,7 +41,7 @@
public Vec3D getPosition() {
return this.worldPosition;
}
@@ -318,7 +335,7 @@
@@ -314,7 +331,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@ -50,7 +50,7 @@
entityplayer.sendSystemMessage(ichatmutablecomponent);
}
}
@@ -391,4 +408,10 @@
@@ -387,4 +404,10 @@
public FeatureFlagSet enabledFeatures() {
return this.level.enabledFeatures();
}

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorBoat.java
@@ -12,6 +12,11 @@
import net.minecraft.world.item.ItemStack;
@@ -12,6 +12,12 @@
import net.minecraft.world.level.block.BlockDispenser;
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
@ -12,7 +13,7 @@
public class DispenseBehaviorBoat extends DispenseBehaviorItem {
private final DispenseBehaviorItem defaultDispenseItemBehavior;
@@ -49,12 +54,40 @@
@@ -50,12 +56,40 @@
d4 = 0.0D;
}
@ -20,7 +21,7 @@
+ // 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 = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d1, d2 + d4, d3));
@ -39,7 +40,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorItem.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorItem.java
@@ -8,8 +8,22 @@
@@ -7,8 +7,23 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.BlockDispenser;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftVector;
+import org.bukkit.event.block.BlockDispenseEvent;
@ -23,13 +24,13 @@
public DispenseBehaviorItem() {}
@Override
@@ -26,11 +40,19 @@
IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
@@ -25,11 +40,19 @@
IPosition iposition = BlockDispenser.getDispensePosition(sourceblock);
ItemStack itemstack1 = itemstack.split(1);
- spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, iposition);
- spawnItem(sourceblock.level(), itemstack1, 6, enumdirection, iposition);
+ // CraftBukkit start
+ if (!spawnItem(isourceblock.getLevel(), itemstack1, 6, enumdirection, isourceblock, dropper)) {
+ if (!spawnItem(sourceblock.level(), itemstack1, 6, enumdirection, sourceblock, dropper)) {
+ itemstack.grow(1);
+ }
+ // CraftBukkit end
@ -38,20 +39,20 @@
- public static void spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, IPosition iposition) {
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument, dropper
+ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, ISourceBlock isourceblock, boolean dropper) {
+ public static boolean spawnItem(World world, ItemStack itemstack, int i, EnumDirection enumdirection, SourceBlock sourceblock, boolean dropper) {
+ if (itemstack.isEmpty()) return true;
+ IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
+ IPosition iposition = BlockDispenser.getDispensePosition(sourceblock);
+ // CraftBukkit end
double d0 = iposition.x();
double d1 = iposition.y();
double d2 = iposition.z();
@@ -45,7 +67,39 @@
@@ -44,7 +67,39 @@
double d3 = world.random.nextDouble() * 0.1D + 0.2D;
entityitem.setDeltaMovement(world.random.triangle((double) enumdirection.getStepX() * d3, 0.0172275D * (double) i), world.random.triangle(0.2D, 0.0172275D * (double) i), world.random.triangle((double) enumdirection.getStepZ() * d3, 0.0172275D * (double) i));
+
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), CraftVector.toBukkit(entityitem.getDeltaMovement()));
@ -71,7 +72,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior.getClass() != DispenseBehaviorItem.class) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ } else {
+ world.addFreshEntity(entityitem);
+ }
@ -84,4 +85,4 @@
+ // CraftBukkit end
}
protected void playSound(ISourceBlock isourceblock) {
protected void playSound(SourceBlock sourceblock) {

View File

@ -1,12 +1,12 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorProjectile.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorProjectile.java
@@ -9,6 +9,13 @@
@@ -8,6 +8,13 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.BlockDispenser;
+// CraftBukkit start
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.level.block.entity.TileEntityDispenser;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
@ -14,15 +14,15 @@
public abstract class DispenseBehaviorProjectile extends DispenseBehaviorItem {
public DispenseBehaviorProjectile() {}
@@ -20,9 +27,38 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
@@ -19,9 +26,38 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
IProjectile iprojectile = this.getProjectile(worldserver, iposition, itemstack);
- iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty());
+ // CraftBukkit start
+ // iprojectile.shoot((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ(), this.getPower(), this.getUncertainty());
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) ((float) enumdirection.getStepY() + 0.1F), (double) enumdirection.getStepZ()));
@ -41,13 +41,13 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.getPower(), this.getUncertainty());
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity());
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
+ // CraftBukkit end
worldserver.addFreshEntity(iprojectile);
- itemstack.shrink(1);

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorShears.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShears.java
@@ -23,6 +23,12 @@
@@ -22,6 +22,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
@ -13,12 +14,12 @@
public class DispenseBehaviorShears extends DispenseBehaviorMaybe {
public DispenseBehaviorShears() {}
@@ -30,11 +36,34 @@
@@ -29,11 +36,34 @@
@Override
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
@ -35,21 +36,21 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
if (!worldserver.isClientSide()) {
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
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
if (this.isSuccess() && itemstack.hurt(1, worldserver.getRandom(), (EntityPlayer) null)) {
itemstack.setCount(0);
}
@@ -63,7 +92,7 @@
@@ -62,7 +92,7 @@
return false;
}
@ -58,7 +59,7 @@
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
Iterator iterator = list.iterator();
@@ -74,6 +103,11 @@
@@ -73,6 +103,11 @@
IShearable ishearable = (IShearable) entityliving;
if (ishearable.readyForShearing()) {

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
+++ b/net/minecraft/core/dispenser/DispenseBehaviorShulkerBox.java
@@ -11,6 +11,11 @@
@@ -10,6 +10,12 @@
import net.minecraft.world.level.block.BlockDispenser;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
@ -12,17 +13,17 @@
public class DispenseBehaviorShulkerBox extends DispenseBehaviorMaybe {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -27,6 +32,30 @@
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
EnumDirection enumdirection1 = isourceblock.getLevel().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP;
@@ -26,6 +32,30 @@
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
EnumDirection enumdirection1 = sourceblock.level().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP;
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = isourceblock.getLevel().getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(sourceblock.level(), sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
+ if (!BlockDispenser.eventFired) {
+ isourceblock.getLevel().getCraftServer().getPluginManager().callEvent(event);
+ sourceblock.level().getCraftServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
@ -34,12 +35,12 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
try {
this.setSuccess(((ItemBlock) item).place(new BlockActionContextDirectional(isourceblock.getLevel(), blockposition, enumdirection, itemstack, enumdirection1)).consumesAction());
this.setSuccess(((ItemBlock) item).place(new BlockActionContextDirectional(sourceblock.level(), blockposition, enumdirection, itemstack, enumdirection1)).consumesAction());
} catch (Exception exception) {

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/core/dispenser/IDispenseBehavior.java
+++ b/net/minecraft/core/dispenser/IDispenseBehavior.java
@@ -78,6 +78,21 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
@@ -77,6 +77,22 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
@ -10,6 +10,7 @@
+import net.minecraft.world.level.block.IFluidContainer;
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
@ -22,14 +23,14 @@
public interface IDispenseBehavior {
Logger LOGGER = LogUtils.getLogger();
@@ -202,14 +217,42 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
@@ -201,14 +217,42 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).getType(itemstack.getTag());
+ // CraftBukkit start
+ WorldServer worldserver = isourceblock.getLevel();
+ WorldServer worldserver = sourceblock.level();
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
@ -48,33 +49,33 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
try {
entitytypes.spawn(isourceblock.getLevel(), itemstack, (EntityHuman) null, isourceblock.getPos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
entitytypes.spawn(sourceblock.level(), itemstack, (EntityHuman) null, sourceblock.pos().relative(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false);
} catch (Exception exception) {
- null.LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception);
+ LOGGER.error("Error while dispensing spawn egg from dispenser at {}", isourceblock.getPos(), exception); // CraftBukkit - decompile error
- 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
return ItemStack.EMPTY;
}
- itemstack.shrink(1);
+ // itemstack.shrink(1); // Handled during event processing
+ // CraftBukkit end
isourceblock.getLevel().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, isourceblock.getPos());
sourceblock.level().gameEvent((Entity) null, GameEvent.ENTITY_PLACE, sourceblock.pos());
return itemstack;
}
@@ -228,13 +271,41 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
WorldServer worldserver = isourceblock.getLevel();
@@ -227,13 +271,41 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
WorldServer worldserver = sourceblock.level();
+
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
@ -93,7 +94,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -110,14 +111,14 @@
}
return itemstack;
@@ -255,8 +326,35 @@
@@ -254,8 +326,35 @@
});
if (!list.isEmpty()) {
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
+ World world = isourceblock.getLevel();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ World world = sourceblock.level();
+ org.bukkit.block.Block block = CraftBlock.at(world, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity());
@ -136,7 +137,7 @@
+ 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(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -147,15 +148,15 @@
this.setSuccess(true);
return itemstack;
} else {
@@ -283,7 +381,35 @@
@@ -282,7 +381,35 @@
entityhorseabstract = (EntityHorseAbstract) iterator1.next();
} while (!entityhorseabstract.isArmor(itemstack) || entityhorseabstract.isWearingArmor() || !entityhorseabstract.isTamed());
- entityhorseabstract.getSlot(401).set(itemstack.split(1));
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
+ World world = isourceblock.getLevel();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ World 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());
@ -174,7 +175,7 @@
+ 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(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -184,7 +185,7 @@
this.setSuccess(true);
return itemstack;
}
@@ -326,9 +452,35 @@
@@ -325,9 +452,35 @@
}
entityhorsechestedabstract = (EntityHorseChestedAbstract) iterator1.next();
@ -192,8 +193,8 @@
+ // CraftBukkit start
+ } while (!entityhorsechestedabstract.isTamed());
+ ItemStack itemstack1 = itemstack.split(1);
+ World world = isourceblock.getLevel();
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ World 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) entityhorsechestedabstract.getBukkitEntity());
@ -211,7 +212,7 @@
+ 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(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -222,14 +223,14 @@
this.setSuccess(true);
return itemstack;
}
@@ -337,12 +489,41 @@
@@ -336,12 +489,41 @@
@Override
public ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
public ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
+ // CraftBukkit start
+ WorldServer worldserver = isourceblock.getLevel();
+ WorldServer worldserver = sourceblock.level();
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(enumdirection.getStepX(), enumdirection.getStepY(), enumdirection.getStepZ()));
@ -248,24 +249,24 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
EntityFireworks entityfireworks = new EntityFireworks(isourceblock.getLevel(), itemstack, isourceblock.x(), isourceblock.y(), isourceblock.x(), true);
Vec3D vec3d = IDispenseBehavior.getEntityPokingOutOfBlockPos(sourceblock, EntityTypes.FIREWORK_ROCKET, enumdirection);
EntityFireworks entityfireworks = new EntityFireworks(sourceblock.level(), itemstack, vec3d.x(), vec3d.y(), vec3d.z(), true);
IDispenseBehavior.setEntityPokingOutOfBlock(isourceblock, entityfireworks, enumdirection);
entityfireworks.shoot((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ(), 0.5F, 1.0F);
isourceblock.getLevel().addFreshEntity(entityfireworks);
sourceblock.level().addFreshEntity(entityfireworks);
- itemstack.shrink(1);
+ // itemstack.shrink(1); // Handled during event processing
+ // CraftBukkit end
return itemstack;
}
@@ -364,12 +545,40 @@
@@ -363,12 +545,40 @@
double d3 = randomsource.triangle((double) enumdirection.getStepX(), 0.11485000000000001D);
double d4 = randomsource.triangle((double) enumdirection.getStepY(), 0.11485000000000001D);
double d5 = randomsource.triangle((double) enumdirection.getStepZ(), 0.11485000000000001D);
@ -277,7 +278,7 @@
- itemstack.shrink(1);
+ // CraftBukkit start
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d3, d4, d5));
@ -296,14 +297,14 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(worldserver, d0, d1, d2, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ());
+ entitysmallfireball.setItem(itemstack1);
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getEntity());
+ entitysmallfireball.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(sourceblock.blockEntity());
+
+ worldserver.addFreshEntity(entitysmallfireball);
+ // itemstack.shrink(1); // Handled during event processing
@ -311,17 +312,17 @@
return itemstack;
}
@@ -405,9 +614,51 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
WorldServer worldserver = isourceblock.getLevel();
@@ -404,9 +614,51 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
WorldServer worldserver = sourceblock.level();
+ // CraftBukkit start
+ int x = blockposition.getX();
+ int y = blockposition.getY();
+ int z = blockposition.getZ();
+ IBlockData iblockdata = worldserver.getBlockState(blockposition);
+ if (iblockdata.isAir() || iblockdata.canBeReplaced() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlaceLiquid(worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) {
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ if (iblockdata.isAir() || iblockdata.canBeReplaced() || (dispensiblecontaineritem instanceof ItemBucket && iblockdata.getBlock() instanceof IFluidContainer && ((IFluidContainer) iblockdata.getBlock()).canPlaceLiquid((EntityHuman) null, worldserver, blockposition, iblockdata, ((ItemBucket) dispensiblecontaineritem).content))) {
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z));
@ -338,7 +339,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -356,29 +357,29 @@
+ if (itemstack.isEmpty()) {
+ itemstack.setItem(Items.BUCKET);
+ itemstack.setCount(1);
+ } else if (((TileEntityDispenser) isourceblock.getEntity()).addItem(new ItemStack(item)) < 0) {
+ this.defaultDispenseItemBehavior.dispense(isourceblock, new ItemStack(item));
+ } else if (sourceblock.blockEntity().addItem(new ItemStack(item)) < 0) {
+ this.defaultDispenseItemBehavior.dispense(sourceblock, new ItemStack(item));
+ }
+ return itemstack;
+ // CraftBukkit end
} else {
return this.defaultDispenseItemBehavior.dispense(isourceblock, itemstack);
return this.defaultDispenseItemBehavior.dispense(sourceblock, itemstack);
}
@@ -434,7 +685,7 @@
Block block = iblockdata.getBlock();
@@ -434,7 +686,7 @@
if (block instanceof IFluidSource) {
- ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata);
+ ItemStack itemstack1 = ((IFluidSource) block).pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
IFluidSource ifluidsource = (IFluidSource) block;
- ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata);
+ ItemStack itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit
if (itemstack1.isEmpty()) {
return super.execute(isourceblock, itemstack);
@@ -442,6 +693,32 @@
return super.execute(sourceblock, itemstack);
@@ -442,6 +694,32 @@
worldserver.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
Item item = itemstack1.getItem();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
@ -395,23 +396,23 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+
+ itemstack1 = ((IFluidSource) block).pickupBlock(worldserver, blockposition, iblockdata); // From above
+ itemstack1 = ifluidsource.pickupBlock((EntityHuman) null, worldserver, blockposition, iblockdata); // From above
+ // CraftBukkit end
+
itemstack.shrink(1);
if (itemstack.isEmpty()) {
return new ItemStack(item);
@@ -463,16 +740,44 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
@@ -463,16 +741,44 @@
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level();
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
@ -428,38 +429,38 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
+ // CraftBukkit end
+
this.setSuccess(true);
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
IBlockData iblockdata = worldserver.getBlockState(blockposition);
if (BlockFireAbstract.canBePlacedAt(worldserver, blockposition, enumdirection)) {
- worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition));
- worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
+ // CraftBukkit start - Ignition by dispensing flint and steel
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, isourceblock.getPos()).isCancelled()) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition, sourceblock.pos()).isCancelled()) {
+ worldserver.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(worldserver, blockposition));
+ worldserver.gameEvent((Entity) null, GameEvent.BLOCK_PLACE, blockposition);
+ }
+ // CraftBukkit end
} else if (!BlockCampfire.canLight(iblockdata) && !CandleBlock.canLight(iblockdata) && !CandleCakeBlock.canLight(iblockdata)) {
- if (iblockdata.getBlock() instanceof BlockTNT) {
+ if (iblockdata.getBlock() instanceof BlockTNT && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(worldserver, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, isourceblock.getPos())) { // CraftBukkit - TNTPrimeEvent
+ if (iblockdata.getBlock() instanceof BlockTNT && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(worldserver, blockposition, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, sourceblock.pos())) { // CraftBukkit - TNTPrimeEvent
BlockTNT.explode(worldserver, blockposition);
worldserver.removeBlock(blockposition, false);
} else {
@@ -496,12 +801,62 @@
@@ -496,12 +802,62 @@
this.setSuccess(true);
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
WorldServer worldserver = sourceblock.level();
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
+ // CraftBukkit start
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0));
@ -476,7 +477,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -517,16 +518,16 @@
return itemstack;
}
@@ -511,12 +866,41 @@
protected ItemStack execute(ISourceBlock isourceblock, ItemStack itemstack) {
WorldServer worldserver = isourceblock.getLevel();
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@@ -511,12 +867,41 @@
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level();
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
- EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+ // CraftBukkit start
+ // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null);
+
+ ItemStack itemstack1 = itemstack.split(1);
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D));
@ -545,7 +546,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -561,12 +562,12 @@
return itemstack;
}
});
@@ -541,6 +925,30 @@
EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
BlockPosition blockposition = isourceblock.getPos().relative(enumdirection);
@@ -541,6 +926,30 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
@ -583,7 +584,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -592,12 +593,12 @@
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, GameEvent.BLOCK_PLACE, blockposition);
@@ -566,6 +974,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@@ -566,6 +975,30 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
@ -614,7 +615,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }
@ -623,12 +624,12 @@
if (worldserver.isEmptyBlock(blockposition) && blockpumpkincarved.canSpawnGolem(worldserver, blockposition)) {
if (!worldserver.isClientSide) {
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
@@ -615,6 +1047,30 @@
BlockPosition blockposition = isourceblock.getPos().relative((EnumDirection) isourceblock.getBlockState().getValue(BlockDispenser.FACING));
@@ -615,6 +1048,30 @@
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getBlockState(blockposition);
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = worldserver.getWorld().getBlockAt(isourceblock.getPos().getX(), isourceblock.getPos().getY(), isourceblock.getPos().getZ());
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+
+ BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
@ -645,7 +646,7 @@
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.DISPENSER_REGISTRY.get(eventStack.getItem());
+ if (idispensebehavior != IDispenseBehavior.NOOP && idispensebehavior != this) {
+ idispensebehavior.dispense(isourceblock, eventStack);
+ idispensebehavior.dispense(sourceblock, eventStack);
+ return itemstack;
+ }
+ }

View File

@ -1,14 +1,14 @@
--- a/net/minecraft/network/NetworkManager.java
+++ b/net/minecraft/network/NetworkManager.java
@@ -88,6 +88,7 @@
private boolean handlingFault;
@Nullable
@@ -105,6 +105,7 @@
private volatile IChatBaseComponent delayedDisconnect;
@Nullable
BandwidthDebugMonitor bandwidthDebugMonitor;
+ public String hostname = ""; // CraftBukkit - add field
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
this.receiving = enumprotocoldirection;
@@ -173,7 +174,7 @@
@@ -194,7 +195,7 @@
}
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener packetlistener) {
@ -16,8 +16,8 @@
+ packet.handle((T) packetlistener); // CraftBukkit - decompile error
}
public void setListener(PacketListener packetlistener) {
@@ -306,7 +307,7 @@
public void suspendInboundAfterProtocolChange() {
@@ -421,7 +422,7 @@
}
if (this.isConnected()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/network/PacketDataSerializer.java
+++ b/net/minecraft/network/PacketDataSerializer.java
@@ -81,6 +81,8 @@
@@ -80,6 +80,8 @@
import org.joml.Quaternionf;
import org.joml.Vector3f;
@ -8,8 +8,8 @@
+
public class PacketDataSerializer extends ByteBuf {
private static final int MAX_VARINT_SIZE = 5;
@@ -220,7 +222,7 @@
public static final int DEFAULT_NBT_QUOTA = 2097152;
@@ -204,7 +206,7 @@
public <T, C extends Collection<T>> C readCollection(IntFunction<C> intfunction, PacketDataSerializer.a<T> packetdataserializer_a) {
int i = this.readVarInt();
@ -18,7 +18,7 @@
for (int j = 0; j < i; ++j) {
c0.add(packetdataserializer_a.apply(this));
@@ -231,7 +233,7 @@
@@ -215,7 +217,7 @@
public <T> void writeCollection(Collection<T> collection, PacketDataSerializer.b<T> packetdataserializer_b) {
this.writeVarInt(collection.size());
@ -27,7 +27,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -258,12 +260,12 @@
@@ -242,12 +244,12 @@
public void writeIntIdList(IntList intlist) {
this.writeVarInt(intlist.size());
@ -42,7 +42,7 @@
for (int j = 0; j < i; ++j) {
K k0 = packetdataserializer_a.apply(this);
@@ -297,7 +299,7 @@
@@ -281,7 +283,7 @@
}
public <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass) {
@ -51,7 +51,7 @@
BitSet bitset = new BitSet(ae.length);
for (int i = 0; i < ae.length; ++i) {
@@ -308,7 +310,7 @@
@@ -292,7 +294,7 @@
}
public <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass) {
@ -60,7 +60,7 @@
BitSet bitset = this.readFixedBitSet(ae.length);
EnumSet<E> enumset = EnumSet.noneOf(oclass);
@@ -545,7 +547,7 @@
@@ -530,7 +532,7 @@
}
public <T extends Enum<T>> T readEnum(Class<T> oclass) {
@ -69,16 +69,16 @@
}
public PacketDataSerializer writeEnum(Enum<?> oenum) {
@@ -622,7 +624,7 @@
} else {
try {
NBTCompressedStreamTools.write(nbttagcompound, (DataOutput) (new ByteBufOutputStream(this)));
- } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception);
}
@@ -585,7 +587,7 @@
try {
NBTCompressedStreamTools.writeAnyTag((NBTBase) nbtbase, new ByteBufOutputStream(this));
return this;
- } catch (IOException ioexception) {
+ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception
throw new EncoderException(ioexception);
}
@@ -659,7 +661,7 @@
}
@@ -613,7 +615,7 @@
}
public PacketDataSerializer writeItem(ItemStack itemstack) {
@ -87,7 +87,7 @@
this.writeBoolean(false);
} else {
this.writeBoolean(true);
@@ -688,6 +690,11 @@
@@ -642,6 +644,11 @@
ItemStack itemstack = new ItemStack(item, b0);
itemstack.setTag(this.readNbt());

View File

@ -1,31 +1,31 @@
--- a/net/minecraft/network/protocol/PlayerConnectionUtils.java
+++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java
@@ -7,6 +7,11 @@
@@ -8,6 +8,11 @@
import net.minecraft.util.thread.IAsyncTaskHandler;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.network.PlayerConnection;
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
+// CraftBukkit end
+
public class PlayerConnectionUtils {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -20,6 +25,7 @@
@@ -21,6 +26,7 @@
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
if (!iasynctaskhandler.isSameThread()) {
iasynctaskhandler.executeIfPossible(() -> {
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
if (t0.isAcceptingMessages()) {
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
if (t0.shouldHandleMessage(packet)) {
try {
packet.handle(t0);
@@ -36,6 +42,10 @@
@@ -46,6 +52,10 @@
});
throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
+ // CraftBukkit start - SPIGOT-5477, MC-142590
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) {
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) t0).processedDisconnect)) {
+ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
+ // CraftBukkit end
}

View File

@ -0,0 +1,43 @@
--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
+++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java
@@ -12,7 +12,7 @@
public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> {
private static final int MAX_PAYLOAD_SIZE = 32767;
- private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.builder().put(BrandPayload.ID, BrandPayload::new).build();
+ private static final Map<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<MinecraftKey, PacketDataSerializer.a<? extends CustomPacketPayload>>builder().put(BrandPayload.ID, BrandPayload::new).build(); // CraftBukkit - decompile error
public ServerboundCustomPayloadPacket(PacketDataSerializer packetdataserializer) {
this(readPayload(packetdataserializer.readResourceLocation(), packetdataserializer));
@@ -24,12 +24,13 @@
return (CustomPacketPayload) (packetdataserializer_a != null ? (CustomPacketPayload) packetdataserializer_a.apply(packetdataserializer) : readUnknownPayload(minecraftkey, packetdataserializer));
}
- private static DiscardedPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) {
+ private static UnknownPayload readUnknownPayload(MinecraftKey minecraftkey, PacketDataSerializer packetdataserializer) { // CraftBukkit
int i = packetdataserializer.readableBytes();
if (i >= 0 && i <= 32767) {
- packetdataserializer.skipBytes(i);
- return new DiscardedPayload(minecraftkey);
+ // CraftBukkit start
+ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i));
+ // CraftBukkit end
} else {
throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
}
@@ -44,4 +45,14 @@
public void handle(ServerCommonPacketListener servercommonpacketlistener) {
servercommonpacketlistener.handleCustomPayload(this);
}
+
+ // CraftBukkit start
+ public record UnknownPayload(MinecraftKey id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload {
+
+ @Override
+ public void write(PacketDataSerializer packetdataserializer) {
+ packetdataserializer.writeBytes(data);
+ }
+ }
+ // CraftBukkit end
}

View File

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

View File

@ -1,23 +1,18 @@
--- a/net/minecraft/server/AdvancementDataPlayer.java
+++ b/net/minecraft/server/AdvancementDataPlayer.java
@@ -144,7 +144,11 @@
Advancement advancement = advancementdataworld.getAdvancement((MinecraftKey) entry.getKey());
@@ -197,6 +197,7 @@
AdvancementHolder advancementholder = advancementdataworld.get(minecraftkey);
if (advancement == null) {
- AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath);
+ // CraftBukkit start
+ if (entry.getKey().getNamespace().equals("minecraft")) {
+ AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.playerSavePath);
+ }
+ // CraftBukkit end
} else {
this.startProgress(advancement, (AdvancementProgress) entry.getValue());
this.progressChanged.add(advancement);
@@ -227,6 +231,7 @@
this.progressChanged.add(advancement);
if (advancementholder == null) {
+ if (!minecraftkey.getNamespace().equals("minecraft")) return; // CraftBukkit
AdvancementDataPlayer.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", minecraftkey, this.playerSavePath);
} else {
this.startProgress(advancementholder, advancementprogress);
@@ -228,6 +229,7 @@
this.progressChanged.add(advancementholder);
flag = true;
if (!flag1 && advancementprogress.isDone()) {
+ this.player.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.player.PlayerAdvancementDoneEvent(this.player.getBukkitEntity(), advancement.bukkit)); // CraftBukkit
advancement.getRewards().grant(this.player);
if (advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && this.player.level().getGameRules().getBoolean(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)) {
this.playerList.broadcastSystemMessage(IChatBaseComponent.translatable("chat.type.advancement." + advancement.getDisplay().getFrame().getName(), this.player.getDisplayName(), advancement.getChatComponent()), false);
+ 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)) {

View File

@ -4,4 +4,4 @@
+// mc-dev import
package net.minecraft.server;
import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap;

View File

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

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/Main.java
+++ b/net/minecraft/server/Main.java
@@ -64,6 +64,16 @@
@@ -61,6 +61,17 @@
import net.minecraft.world.level.storage.WorldInfo;
import org.slf4j.Logger;
@ -11,13 +11,14 @@
+import net.minecraft.SharedConstants;
+import net.minecraft.server.packs.EnumResourcePackType;
+import net.minecraft.world.level.dimension.WorldDimension;
+import net.minecraft.world.level.storage.SavedFile;
+import org.bukkit.configuration.file.YamlConfiguration;
+// CraftBukkit end
+
public class Main {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -71,8 +81,9 @@
@@ -68,8 +79,9 @@
public Main() {}
@DontObfuscate
@ -28,7 +29,7 @@
OptionParser optionparser = new OptionParser();
OptionSpec<Void> optionspec = optionparser.accepts("nogui");
OptionSpec<Void> optionspec1 = optionparser.accepts("initSettings", "Initializes 'server.properties' and 'eula.txt', then quits");
@@ -98,15 +109,18 @@
@@ -94,15 +106,18 @@
optionparser.printHelpOn(System.err);
return;
}
@ -36,7 +37,7 @@
+
+ try {
- Path path = (Path) optionset.valueOf(optionspec14);
- Path path = (Path) optionset.valueOf(optionspec13);
+ Path path = (Path) optionset.valueOf("pidFile"); // CraftBukkit
if (path != null) {
@ -44,12 +45,12 @@
}
CrashReport.preload();
- if (optionset.has(optionspec13)) {
- if (optionset.has(optionspec12)) {
+ if (optionset.has("jfrProfile")) { // CraftBukkit
JvmProfiler.INSTANCE.start(Environment.SERVER);
}
@@ -114,13 +128,26 @@
@@ -110,13 +125,26 @@
DispenserRegistry.validate();
SystemUtils.startTimerHackThread();
Path path1 = Paths.get("server.properties");
@ -78,14 +79,14 @@
Main.LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
return;
}
@@ -130,11 +157,12 @@
@@ -126,11 +154,12 @@
return;
}
- File file = new File((String) optionset.valueOf(optionspec9));
- File file = new File((String) optionset.valueOf(optionspec8));
+ File file = (File) optionset.valueOf("universe"); // CraftBukkit
Services services = Services.create(new YggdrasilAuthenticationService(Proxy.NO_PROXY), file);
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec10)).orElse(dedicatedserversettings.getProperties().levelName);
- String s = (String) Optional.ofNullable((String) optionset.valueOf(optionspec9)).orElse(dedicatedserversettings.getProperties().levelName);
+ // CraftBukkit start
+ String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
Convertable convertable = Convertable.createDefault(file.toPath());
@ -94,7 +95,7 @@
WorldInfo worldinfo = convertable_conversionsession.getSummary();
if (worldinfo != null) {
@@ -149,13 +177,31 @@
@@ -145,13 +174,31 @@
}
}
@ -105,7 +106,7 @@
Main.LOGGER.warn("Safe mode active, only vanilla datapack will be loaded");
}
ResourcePackRepository resourcepackrepository = ResourcePackSourceVanilla.createPackRepository(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR));
ResourcePackRepository resourcepackrepository = ResourcePackSourceVanilla.createPackRepository(convertable_conversionsession);
+ // CraftBukkit start
+ File bukkitDataPackFolder = new File(convertable_conversionsession.getLevelPath(SavedFile.DATAPACK_DIR).toFile(), "bukkit");
+ if (!bukkitDataPackFolder.exists()) {
@ -127,7 +128,7 @@
WorldStem worldstem;
@@ -164,6 +210,7 @@
@@ -160,6 +207,7 @@
worldstem = (WorldStem) SystemUtils.blockUntilDone((executor) -> {
return WorldLoader.load(worldloader_c, (worldloader_a) -> {
@ -135,7 +136,7 @@
IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) worldloader_a.datapackWorldgen());
Pair<SaveData, WorldDimensions.b> pair = convertable_conversionsession.getDataTag(dynamicops, worldloader_a.dataConfiguration(), iregistry, worldloader_a.datapackWorldgen().allRegistriesLifecycle());
@@ -175,7 +222,7 @@
@@ -171,7 +219,7 @@
WorldOptions worldoptions;
WorldDimensions worlddimensions;
@ -144,7 +145,7 @@
worldsettings = MinecraftServer.DEMO_SETTINGS;
worldoptions = WorldOptions.DEMO_OPTIONS;
worlddimensions = WorldPresets.createNormalWorldDimensions(worldloader_a.datapackWorldgen());
@@ -183,7 +230,7 @@
@@ -179,7 +227,7 @@
DedicatedServerProperties dedicatedserverproperties = dedicatedserversettings.getProperties();
worldsettings = new WorldSettings(dedicatedserverproperties.levelName, dedicatedserverproperties.gamemode, dedicatedserverproperties.hardcore, dedicatedserverproperties.difficulty, false, new GameRules(), worldloader_a.dataConfiguration());
@ -153,7 +154,7 @@
worlddimensions = dedicatedserverproperties.createDimensions(worldloader_a.datapackWorldgen());
}
@@ -199,6 +246,7 @@
@@ -195,6 +243,7 @@
return;
}
@ -161,7 +162,7 @@
IRegistryCustom.Dimension iregistrycustom_dimension = worldstem.registries().compositeAccess();
if (optionset.has(optionspec4)) {
@@ -210,21 +258,32 @@
@@ -206,20 +255,31 @@
SaveData savedata = worldstem.worldData();
convertable_conversionsession.saveDataTag(iregistrycustom_dimension, savedata);
@ -171,10 +172,9 @@
+ DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataConverterRegistry.getDataFixer(), services, WorldLoadListenerLogger::new);
+ /*
dedicatedserver1.setSingleplayerProfile(optionset.has(optionspec8) ? new GameProfile((UUID) null, (String) optionset.valueOf(optionspec8)) : null);
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec11));
dedicatedserver1.setPort((Integer) optionset.valueOf(optionspec10));
dedicatedserver1.setDemo(optionset.has(optionspec2));
dedicatedserver1.setId((String) optionset.valueOf(optionspec12));
dedicatedserver1.setId((String) optionset.valueOf(optionspec11));
- boolean flag1 = !optionset.has(optionspec) && !optionset.valuesOf(nonoptionargumentspec).contains("nogui");
+ */
+ boolean flag1 = !optionset.has("nogui") && !optionset.nonOptionArguments().contains("nogui");
@ -196,7 +196,7 @@
Thread thread = new Thread("Server Shutdown Thread") {
public void run() {
dedicatedserver.halt(true);
@@ -233,6 +292,7 @@
@@ -228,6 +288,7 @@
thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(Main.LOGGER));
Runtime.getRuntime().addShutdownHook(thread);
@ -204,7 +204,7 @@
} catch (Exception exception1) {
Main.LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", exception1);
}
@@ -268,7 +328,7 @@
@@ -263,7 +324,7 @@
}
public static void forceUpgrade(Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, boolean flag, BooleanSupplier booleansupplier, IRegistry<WorldDimension> iregistry) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -164,6 +164,33 @@
@@ -163,6 +163,30 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@ -25,16 +25,13 @@
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.Main;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
+import org.bukkit.event.player.AsyncPlayerChatPreviewEvent;
+import org.bukkit.event.server.ServerLoadEvent;
+// CraftBukkit end
+
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ICommandListener, AutoCloseable {
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements ServerInfo, ICommandListener, AutoCloseable {
public static final Logger LOGGER = LogUtils.getLogger();
@@ -249,6 +276,19 @@
@@ -247,6 +271,19 @@
protected SaveData worldData;
private volatile boolean isSaving;
@ -54,7 +51,7 @@
public static <S extends MinecraftServer> S spin(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -262,14 +302,14 @@
@@ -260,14 +297,14 @@
thread.setPriority(8);
}
@ -71,8 +68,8 @@
super("Server");
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
@@ -289,7 +329,7 @@
this.frameTimer = new CircularTimer();
@@ -286,7 +323,7 @@
this.customBossEvents = new BossBattleCustomData();
this.registries = worldstem.registries();
this.worldData = worldstem.worldData();
- if (!this.registries.compositeAccess().registryOrThrow(Registries.LEVEL_STEM).containsKey(WorldDimension.OVERWORLD)) {
@ -80,7 +77,7 @@
throw new IllegalStateException("Missing Overworld dimension data");
} else {
this.proxy = proxy;
@@ -312,13 +352,40 @@
@@ -309,6 +346,33 @@
this.serverThread = thread;
this.executor = SystemUtils.backgroundExecutor();
}
@ -110,19 +107,11 @@
+ }
+ }
+ Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
+ // CraftBukkit end
}
+ // CraftBukkit end
private void readScoreboard(WorldPersistentData worldpersistentdata) {
ScoreboardServer scoreboardserver = this.getScoreboard();
Objects.requireNonNull(scoreboardserver);
- Function function = scoreboardserver::createData;
+ Function<net.minecraft.nbt.NBTTagCompound, net.minecraft.world.scores.PersistentScoreboard> function = scoreboardserver::createData; // CraftBukkit - decompile error
ScoreboardServer scoreboardserver1 = this.getScoreboard();
Objects.requireNonNull(scoreboardserver1);
@@ -327,7 +394,7 @@
@@ -317,7 +381,7 @@
protected abstract boolean initServer() throws IOException;
@ -131,7 +120,7 @@
if (!JvmProfiler.INSTANCE.isRunning()) {
;
}
@@ -335,12 +402,8 @@
@@ -325,12 +389,8 @@
boolean flag = false;
ProfiledDuration profiledduration = JvmProfiler.INSTANCE.onWorldLoadedStarted();
@ -145,11 +134,20 @@
if (profiledduration != null) {
profiledduration.finish();
}
@@ -355,25 +418,183 @@
@@ -347,23 +407,179 @@
}
protected void forceDifficulty() {}
- 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);
- 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);
- 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) {
+ Convertable.ConversionSession worldSession = this.storageSource;
@ -176,17 +174,7 @@
+ } else if (dimensionKey != WorldDimension.OVERWORLD) {
+ dimension = -999;
+ }
- 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);
- 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);
- WorldServer worldserver = new WorldServer(this, this.executor, this.storageSource, iworlddataserver, World.OVERWORLD, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null);
+
+ String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
+ String name = (dimensionKey == WorldDimension.OVERWORLD) ? s : s + "_" + worldType;
+ if (dimension != 0) {
@ -230,10 +218,14 @@
+ throw new RuntimeException(ex);
+ }
+ }
+
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+ org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
+ org.bukkit.generator.BiomeProvider biomeProvider = this.server.getBiomeProvider(name);
+
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+ WorldDataServer worlddata;
+ WorldLoader.a worldloader_a = this.worldLoader;
+ IRegistry<WorldDimension> iregistry = worldloader_a.datapackDimensions().registryOrThrow(Registries.LEVEL_STEM);
@ -289,13 +281,9 @@
+ if (dimensionKey == WorldDimension.OVERWORLD) {
+ this.worldData = worlddata;
+ this.worldData.setGameType(((DedicatedServer) this).getProperties().gamemode); // From DedicatedServer.init
- this.levels.put(World.OVERWORLD, worldserver);
- WorldPersistentData worldpersistentdata = worldserver.getDataStorage();
+
+ WorldLoadListener worldloadlistener = this.progressListenerFactory.create(11);
- this.readScoreboard(worldpersistentdata);
- this.commandStorage = new PersistentCommandStorage(worldpersistentdata);
+
+ world = new WorldServer(this, this.executor, worldSession, iworlddataserver, worldKey, worlddimension, worldloadlistener, flag, j, list, true, (RandomSequences) null, org.bukkit.World.Environment.getEnvironment(dimension), gen, biomeProvider);
+ WorldPersistentData worldpersistentdata = world.getDataStorage();
+ this.readScoreboard(worldpersistentdata);
@ -327,11 +315,7 @@
+ this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
+ this.connection.acceptConnections();
+ }
+ // CraftBukkit end
+
+ protected void forceDifficulty() {}
+
+ // CraftBukkit start
+ public void initWorld(WorldServer worldserver, IWorldDataServer iworlddataserver, SaveData saveData, WorldOptions worldoptions) {
+ boolean flag = saveData.isDebugWorld();
+ // CraftBukkit start
@ -344,7 +328,7 @@
if (!iworlddataserver.isInitialized()) {
try {
@@ -397,30 +618,8 @@
@@ -387,30 +603,8 @@
iworlddataserver.setInitialized(true);
}
@ -376,7 +360,7 @@
private static void setInitialSpawn(WorldServer worldserver, IWorldDataServer iworlddataserver, boolean flag, boolean flag1) {
if (flag1) {
@@ -428,6 +627,21 @@
@@ -418,6 +612,21 @@
} else {
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(chunkproviderserver.randomState().sampler().findSpawnPosition());
@ -398,7 +382,7 @@
int i = chunkproviderserver.getGenerator().getSpawnHeight(worldserver);
if (i < worldserver.getMinBuildHeight()) {
@@ -487,8 +701,11 @@
@@ -477,8 +686,11 @@
iworlddataserver.setGameType(EnumGamemode.SPECTATOR);
}
@ -412,7 +396,7 @@
MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -497,19 +714,23 @@
@@ -487,19 +699,23 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
this.nextTickTime = SystemUtils.getMillis();
@ -442,10 +426,10 @@
+ if (true) {
+ WorldServer worldserver1 = worldserver;
+ // CraftBukkit end
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk::load, "chunks");
ForcedChunk forcedchunk = (ForcedChunk) worldserver1.getDataStorage().get(ForcedChunk.factory(), "chunks");
if (forcedchunk != null) {
@@ -524,10 +745,17 @@
@@ -514,10 +730,17 @@
}
}
@ -466,7 +450,7 @@
}
public EnumGamemode getDefaultGameType() {
@@ -557,12 +785,16 @@
@@ -547,12 +770,16 @@
worldserver.save((IProgressUpdate) null, flag1, worldserver.noSave && !flag2);
}
@ -483,7 +467,7 @@
if (flag1) {
Iterator iterator1 = this.getAllLevels().iterator();
@@ -597,12 +829,33 @@
@@ -587,18 +814,40 @@
this.stopServer();
}
@ -514,10 +498,9 @@
+ this.server.disablePlugins();
+ }
+ // CraftBukkit end
if (this.getConnection() != null) {
this.getConnection().stop();
}
@@ -612,6 +865,7 @@
this.getConnection().stop();
this.isSaving = true;
if (this.playerList != null) {
MinecraftServer.LOGGER.info("Saving players");
this.playerList.saveAll();
this.playerList.removeAll();
@ -525,7 +508,7 @@
}
MinecraftServer.LOGGER.info("Saving worlds");
@@ -699,15 +953,16 @@
@@ -686,15 +935,16 @@
}
this.nextTickTime = SystemUtils.getMillis();
@ -544,7 +527,7 @@
MinecraftServer.LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", i, j);
this.nextTickTime += j * 50L;
this.lastOverloadWarning = this.nextTickTime;
@@ -718,6 +973,7 @@
@@ -705,6 +955,7 @@
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(SystemUtils.getNanos(), this.tickCount);
}
@ -552,7 +535,7 @@
this.nextTickTime += 50L;
this.startMetricsRecordingTick();
this.profiler.push("tick");
@@ -756,6 +1012,12 @@
@@ -743,6 +994,12 @@
this.services.profileCache().clearExecutor();
}
@ -565,25 +548,23 @@
this.onServerExit();
}
@@ -789,9 +1051,16 @@
@@ -776,7 +1033,14 @@
}
private boolean haveTime() {
- return this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
+ // CraftBukkit start
+ return this.forceTicks || this.runningTask() || SystemUtils.getMillis() < (this.mayHaveDelayedTasks ? this.delayedTasksMaxNextTickTime : this.nextTickTime);
}
+ }
+
+ private void executeModerately() {
+ this.runAllTasks();
+ java.util.concurrent.locks.LockSupport.parkNanos("executing tasks", 1000L);
+ }
+ // CraftBukkit end
+
+ // CraftBukkit end
}
protected void waitUntilNextTick() {
this.runAllTasks();
this.managedBlock(() -> {
@@ -836,7 +1105,7 @@
@@ -823,7 +1087,7 @@
}
}
@ -592,7 +573,7 @@
this.getProfiler().incrementCounter("runTask");
super.doRunTask(ticktask);
}
@@ -889,7 +1158,7 @@
@@ -876,7 +1140,7 @@
this.status = this.buildServerStatus();
}
@ -601,10 +582,10 @@
MinecraftServer.LOGGER.debug("Autosave started");
this.profiler.push("save");
this.saveEverything(true, false, false);
@@ -936,22 +1205,39 @@
}
public void tickChildren(BooleanSupplier booleansupplier) {
@@ -928,22 +1192,39 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing();
});
+ this.server.getScheduler().mainThreadHeartbeat(this.tickCount); // CraftBukkit
this.profiler.push("commandFunctions");
this.getFunctions().tick();
@ -641,7 +622,7 @@
this.profiler.push("tick");
@@ -1031,6 +1317,22 @@
@@ -1033,6 +1314,22 @@
return (WorldServer) this.levels.get(resourcekey);
}
@ -664,7 +645,7 @@
public Set<ResourceKey<World>> levelKeys() {
return this.levels.keySet();
}
@@ -1057,7 +1359,7 @@
@@ -1062,7 +1359,7 @@
@DontObfuscate
public String getServerModName() {
@ -673,7 +654,7 @@
}
public SystemReport fillSystemReport(SystemReport systemreport) {
@@ -1398,11 +1700,11 @@
@@ -1403,11 +1700,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> collection) {
IRegistryCustom.Dimension iregistrycustom_dimension = this.registries.getAccessForLoading(RegistryLayer.RELOADABLE);
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -687,7 +668,7 @@
}, this).thenCompose((immutablelist) -> {
ResourceManager resourcemanager = new ResourceManager(EnumResourcePackType.SERVER_DATA, immutablelist);
@@ -1417,6 +1719,7 @@
@@ -1422,6 +1719,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close();
this.resources = minecraftserver_reloadableresources;
@ -695,7 +676,7 @@
this.packRepository.setSelected(collection);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(getSelectedPacks(this.packRepository), this.worldData.enabledFeatures());
@@ -1777,7 +2080,7 @@
@@ -1778,7 +2076,7 @@
try {
label51:
{
@ -704,7 +685,7 @@
try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -1827,6 +2130,22 @@
@@ -1828,6 +2126,22 @@
}
@ -727,35 +708,15 @@
private void startMetricsRecordingTick() {
if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(SystemUtils.timeSource, this.isDedicatedServer()), SystemUtils.timeSource, SystemUtils.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -1953,8 +2272,30 @@
@@ -1954,6 +2268,11 @@
}
+ // CraftBukkit start
+ public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").build());
+ // CraftBukkit end
+
public ChatDecorator getChatDecorator() {
- return ChatDecorator.PLAIN;
+ return (entityplayer, ichatbasecomponent) -> {
+ // SPIGOT-7127: Console /say and similar
+ if (entityplayer == null) {
+ return CompletableFuture.completedFuture(ichatbasecomponent);
+ }
+
+ return CompletableFuture.supplyAsync(() -> {
+ AsyncPlayerChatPreviewEvent event = new AsyncPlayerChatPreviewEvent(true, entityplayer.getBukkitEntity(), CraftChatMessage.fromComponent(ichatbasecomponent), new LazyPlayerSet(this));
+ String originalFormat = event.getFormat(), originalMessage = event.getMessage();
+ this.server.getPluginManager().callEvent(event);
+
+ if (originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) {
+ return ichatbasecomponent;
+ }
+
+ return CraftChatMessage.fromStringOrNull(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()));
+ }, chatExecutor);
+ };
+ // CraftBukkit end
return ChatDecorator.PLAIN;
}
public static record ReloadableResources(IReloadableResourceManager resourceManager, DataPackResources managers) implements AutoCloseable {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/ScoreboardServer.java
+++ b/net/minecraft/server/ScoreboardServer.java
@@ -34,7 +34,7 @@
@@ -37,7 +37,7 @@
public void onScoreChanged(ScoreboardScore scoreboardscore) {
super.onScoreChanged(scoreboardscore);
if (this.trackedObjectives.contains(scoreboardscore.getObjective())) {
@ -9,7 +9,7 @@
}
this.setDirty();
@@ -43,7 +43,7 @@
@@ -46,7 +46,7 @@
@Override
public void onPlayerRemoved(String s) {
super.onPlayerRemoved(s);
@ -18,7 +18,7 @@
this.setDirty();
}
@@ -51,7 +51,7 @@
@@ -54,7 +54,7 @@
public void onPlayerScoreRemoved(String s, ScoreboardObjective scoreboardobjective) {
super.onPlayerScoreRemoved(s, scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -27,25 +27,25 @@
}
this.setDirty();
@@ -64,7 +64,7 @@
super.setDisplayObjective(i, scoreboardobjective);
@@ -67,7 +67,7 @@
super.setDisplayObjective(displayslot, scoreboardobjective);
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
} else {
this.stopTrackingObjective(scoreboardobjective1);
}
@@ -72,7 +72,7 @@
@@ -75,7 +75,7 @@
if (scoreboardobjective != null) {
if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(i, scoreboardobjective));
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
} else {
this.startTrackingObjective(scoreboardobjective);
}
@@ -84,7 +84,7 @@
@@ -87,7 +87,7 @@
@Override
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
if (super.addPlayerToTeam(s, scoreboardteam)) {
@ -54,7 +54,7 @@
this.setDirty();
return true;
} else {
@@ -95,7 +95,7 @@
@@ -98,7 +98,7 @@
@Override
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
super.removePlayerFromTeam(s, scoreboardteam);
@ -63,7 +63,7 @@
this.setDirty();
}
@@ -109,7 +109,7 @@
@@ -112,7 +112,7 @@
public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) {
super.onObjectiveChanged(scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) {
@ -72,7 +72,7 @@
}
this.setDirty();
@@ -128,21 +128,21 @@
@@ -131,21 +131,21 @@
@Override
public void onTeamAdded(ScoreboardTeam scoreboardteam) {
super.onTeamAdded(scoreboardteam);
@ -97,7 +97,7 @@
this.setDirty();
}
@@ -189,6 +189,7 @@
@@ -196,6 +196,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@ -105,7 +105,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -221,6 +222,7 @@
@@ -232,6 +233,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@ -113,7 +113,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -257,6 +259,16 @@
@@ -276,6 +278,16 @@
return this.createData().load(nbttagcompound);
}

View File

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

View File

@ -21,8 +21,8 @@
private final List<ServerCommand> consoleInput = Collections.synchronizedList(Lists.newArrayList());
@Nullable
private RemoteStatusListener queryThreadGs4;
- public final RemoteControlCommandListener rconConsoleSource;
+ // public final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
- private final RemoteControlCommandListener rconConsoleSource;
+ // private final RemoteControlCommandListener rconConsoleSource; // CraftBukkit - remove field
@Nullable
private RemoteControlListener rconThread;
public DedicatedServerSettings settings;
@ -181,7 +181,7 @@
}
}
@@ -539,16 +618,52 @@
@@ -544,16 +623,52 @@
@Override
public String getPluginNames() {
@ -238,7 +238,7 @@
}
public void storeUsingWhiteList(boolean flag) {
@@ -599,4 +714,15 @@
@@ -604,4 +719,15 @@
public Optional<MinecraftServer.ServerResourcePackInfo> getServerResourcePack() {
return this.settings.getProperties().serverResourcePackInfo;
}

View File

@ -17,7 +17,7 @@
public final boolean onlineMode = this.get("online-mode", true);
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
@@ -103,8 +108,10 @@
@@ -104,8 +109,10 @@
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
public final WorldOptions worldOptions;
@ -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");
@@ -160,13 +167,15 @@
@@ -162,13 +169,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
@@ -247,10 +256,10 @@
@@ -249,10 +258,10 @@
}).orElseThrow(() -> {
return new IllegalStateException("Invalid datapack contents: can't find default preset");
});
@ -63,7 +63,7 @@
});
Objects.requireNonNull(iregistry);
@@ -262,7 +271,7 @@
@@ -264,7 +273,7 @@
if (holder.is(WorldPresets.FLAT)) {
RegistryOps<JsonElement> registryops = RegistryOps.create(JsonOps.INSTANCE, (HolderLookup.b) iregistrycustom);

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -155,6 +155,38 @@
@@ -151,6 +151,37 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.core.Position;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.world.damagesource.CombatTracker;
+import net.minecraft.world.food.FoodMetaData;
@ -39,8 +38,17 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -212,6 +244,21 @@
public int latency;
@@ -185,7 +216,7 @@
private int levitationStartTime;
private boolean disconnected;
private int requestedViewDistance;
- public String language;
+ public String language = "en_us"; // CraftBukkit - default
@Nullable
private Vec3D startingToFallPosition;
@Nullable
@@ -210,6 +241,20 @@
private int containerCounter;
public boolean wonGame;
+ // CraftBukkit start
@ -54,17 +62,16 @@
+ public double maxHealthCache;
+ public boolean joining = true;
+ public boolean sentListPacket = false;
+ public Integer clientViewDistance;
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -274,12 +321,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
@@ -276,12 +321,56 @@
this.setMaxUpStep(1.0F);
this.fudgeSpawnLocation(worldserver);
this.updateOptions(clientinformation);
+
+ // CraftBukkit start
+ this.displayName = this.getScoreboardName();
@ -119,7 +126,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -328,7 +419,7 @@
@@ -330,7 +419,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
@ -128,7 +135,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -347,17 +438,26 @@
@@ -349,17 +438,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@ -156,7 +163,7 @@
Logger logger1 = EntityPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -370,7 +470,7 @@
@@ -372,7 +470,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@ -165,7 +172,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -391,7 +491,20 @@
@@ -393,7 +491,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@ -187,7 +194,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -416,8 +529,32 @@
@@ -418,8 +529,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@ -220,7 +227,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
@@ -477,6 +614,11 @@
@@ -479,6 +614,11 @@
@Override
public void tick() {
@ -232,7 +239,7 @@
this.gameMode.tick();
this.wardenSpawnTracker.tick();
--this.spawnInvulnerableTime;
@@ -533,7 +675,7 @@
@@ -535,7 +675,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@ -241,7 +248,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -564,6 +706,12 @@
@@ -566,6 +706,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@ -254,7 +261,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -578,6 +726,20 @@
@@ -580,6 +726,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@ -275,7 +282,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -620,7 +782,8 @@
@@ -622,7 +782,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
@ -285,7 +292,7 @@
scoreboardscore.setScore(i);
});
}
@@ -629,9 +792,47 @@
@@ -631,9 +792,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@ -335,7 +342,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
@@ -662,12 +863,18 @@
@@ -664,12 +863,18 @@
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@ -358,7 +365,7 @@
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -705,10 +912,12 @@
@@ -707,10 +912,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
@ -373,7 +380,7 @@
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -726,7 +935,8 @@
@@ -728,7 +935,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
@ -383,7 +390,7 @@
}
}
@@ -776,18 +986,20 @@
@@ -778,18 +986,20 @@
}
private boolean isPvpAllowed() {
@ -407,7 +414,7 @@
} else {
return shapedetectorshape;
}
@@ -796,11 +1008,20 @@
@@ -798,11 +1008,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@ -431,7 +438,7 @@
this.unRide();
this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -811,6 +1032,8 @@
@@ -813,6 +1032,8 @@
return this;
} else {
@ -439,8 +446,8 @@
+ /*
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
@@ -820,20 +1043,50 @@
this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
@@ -822,20 +1043,50 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@ -479,7 +486,7 @@
+ if (true) { // CraftBukkit
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
+ this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked()));
+ PlayerList playerlist = this.server.getPlayerList();
+
@ -496,7 +503,7 @@
this.connection.resetPosition();
worldserver.addDuringPortalTeleport(this);
worldserver1.getProfiler().pop();
@@ -853,39 +1106,66 @@
@@ -855,39 +1106,66 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -513,7 +520,7 @@
+ // CraftBukkit start
+ @Override
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, TeleportCause cause, int searchRadius, int creationRadius) {
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld(), getYRot(), getXRot());
+ PlayerPortalEvent event = new PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius);
@ -563,13 +570,13 @@
- Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis);
+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit
if (!optional1.isPresent()) {
if (optional1.isEmpty()) {
- EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder");
+ // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit
}
return optional1;
@@ -895,13 +1175,21 @@
@@ -897,13 +1175,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level().dimension();
@ -594,7 +601,7 @@
this.enteredNetherPosition = null;
}
@@ -918,19 +1206,17 @@
@@ -920,19 +1206,17 @@
this.containerMenu.broadcastChanges();
}
@ -618,7 +625,7 @@
if (this.level().isDay()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
} else {
@@ -947,7 +1233,36 @@
@@ -949,7 +1233,36 @@
}
}
@ -656,7 +663,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -960,9 +1275,8 @@
@@ -962,9 +1275,8 @@
return either;
}
}
@ -667,7 +674,7 @@
}
@Override
@@ -989,13 +1303,31 @@
@@ -991,13 +1303,31 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@ -700,7 +707,7 @@
}
}
@@ -1037,8 +1369,9 @@
@@ -1039,8 +1369,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
}
@ -711,7 +718,7 @@
}
@Override
@@ -1046,13 +1379,35 @@
@@ -1048,13 +1379,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@ -747,7 +754,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1060,9 +1415,11 @@
@@ -1062,9 +1415,11 @@
return OptionalInt.empty();
} else {
@ -761,7 +768,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1075,13 +1432,24 @@
@@ -1077,13 +1432,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -788,7 +795,7 @@
this.initMenu(this.containerMenu);
}
@@ -1104,6 +1472,7 @@
@@ -1106,6 +1472,7 @@
@Override
public void closeContainer() {
@ -796,7 +803,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1126,6 +1495,16 @@
@@ -1128,6 +1495,16 @@
}
this.jumping = flag;
@ -813,7 +820,7 @@
this.setShiftKeyDown(flag1);
}
@@ -1134,7 +1513,7 @@
@@ -1136,7 +1513,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
@ -822,7 +829,7 @@
scoreboardscore.add(i);
});
}
@@ -1142,7 +1521,7 @@
@@ -1144,7 +1521,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
@ -831,16 +838,16 @@
}
@Override
@@ -1163,7 +1542,7 @@
@@ -1165,7 +1542,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
- Optional optional = this.server.getRecipeManager().byKey(minecraftkey);
+ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1198,6 +1577,7 @@
@@ -1200,6 +1577,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@ -848,7 +855,7 @@
}
@Override
@@ -1256,7 +1636,7 @@
@@ -1257,7 +1635,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@ -856,8 +863,8 @@
+ // this.recipeBook.copyOverData(entityplayer.recipeBook); // CraftBukkit
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1306,6 +1686,12 @@
this.chunkTrackingView = entityplayer.chunkTrackingView;
@@ -1308,6 +1686,12 @@
@Override
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
@ -870,7 +877,7 @@
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
@@ -1315,9 +1701,9 @@
@@ -1317,9 +1701,9 @@
}
if (worldserver == this.level()) {
@ -882,28 +889,24 @@
}
this.setYHeadRot(f);
@@ -1420,7 +1806,20 @@
}
@@ -1423,6 +1807,16 @@
}
+ public String locale = "en_us"; // CraftBukkit - add, lowercase
public void updateOptions(PacketPlayInSettings packetplayinsettings) {
public void updateOptions(ClientInformation clientinformation) {
+ // CraftBukkit start
+ if (getMainArm() != packetplayinsettings.mainHand()) {
+ if (getMainArm() != clientinformation.mainHand()) {
+ PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT);
+ this.server.server.getPluginManager().callEvent(event);
+ }
+ if (!this.locale.equals(packetplayinsettings.language)) {
+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.language);
+ if (!this.language.equals(clientinformation.language())) {
+ PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), clientinformation.language());
+ this.server.server.getPluginManager().callEvent(event);
+ }
+ this.locale = packetplayinsettings.language;
+ this.clientViewDistance = packetplayinsettings.viewDistance;
+ // CraftBukkit end
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1495,7 +1894,7 @@
this.language = clientinformation.language();
this.requestedViewDistance = clientinformation.viewDistance();
this.chatVisibility = clientinformation.chatVisibility();
@@ -1506,7 +1900,7 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
@ -912,7 +915,7 @@
}
if (entity != null) {
@@ -1532,7 +1931,7 @@
@@ -1543,7 +1937,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@ -921,7 +924,7 @@
}
@Override
@@ -1553,9 +1952,16 @@
@@ -1564,9 +1958,16 @@
return this.advancements;
}
@ -938,7 +941,7 @@
if (worldserver == this.level()) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1575,6 +1981,9 @@
@@ -1586,6 +1987,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@ -948,7 +951,7 @@
}
@@ -1596,6 +2005,32 @@
@@ -1607,6 +2011,32 @@
}
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
@ -981,9 +984,9 @@
if (blockposition != null) {
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
@@ -1805,4 +2240,146 @@
}
@@ -1812,4 +2242,146 @@
public CommonPlayerSpawnInfo createCommonSpawnInfo(WorldServer worldserver) {
return new CommonPlayerSpawnInfo(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), this.getLastDeathLocation(), this.getPortalCooldown());
}
+
+ // CraftBukkit start - Add per-player time and weather.

View File

@ -13,7 +13,7 @@
public class EntityTrackerEntry {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -63,8 +69,12 @@
@@ -66,8 +72,12 @@
private boolean wasOnGround;
@Nullable
private List<DataWatcher.b<?>> trackedDataValues;
@ -27,7 +27,7 @@
this.ap = Vec3D.ZERO;
this.lastPassengers = Collections.emptyList();
this.level = worldserver;
@@ -84,7 +94,7 @@
@@ -87,7 +97,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 = (EntityPlayer) entity;
@@ -101,18 +111,18 @@
@@ -104,18 +114,18 @@
if (entity instanceof EntityItemFrame) {
EntityItemFrame entityitemframe = (EntityItemFrame) entity;
@ -59,7 +59,7 @@
worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
@@ -225,7 +235,27 @@
@@ -228,7 +238,27 @@
++this.tickCount;
if (this.entity.hurtMarked) {
@ -88,7 +88,7 @@
this.entity.hurtMarked = false;
}
@@ -253,7 +283,10 @@
@@ -256,7 +286,10 @@
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
if (this.entity.isRemoved()) {
@ -100,7 +100,7 @@
}
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket();
@@ -269,6 +302,12 @@
@@ -272,6 +305,12 @@
if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
@ -113,7 +113,7 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -300,8 +339,15 @@
@@ -303,8 +342,15 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
@ -129,7 +129,7 @@
if (!this.entity.getPassengers().isEmpty()) {
consumer.accept(new PacketPlayOutMount(this.entity));
}
@@ -333,6 +379,11 @@
@@ -338,6 +384,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@ -11,7 +11,7 @@
public class PlayerChunk {
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
@@ -71,11 +75,11 @@
@@ -72,12 +76,12 @@
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
@ -21,11 +21,13 @@
this.blockChangedLightSectionFilter = new BitSet();
this.skyChangedLightSectionFilter = new BitSet();
- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null);
- this.sendSync = CompletableFuture.completedFuture((Object) null);
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
+ this.sendSync = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
this.pos = chunkcoordintpair;
this.levelHeightAccessor = levelheightaccessor;
this.lightEngine = levellightengine;
@@ -88,6 +92,20 @@
@@ -90,6 +94,20 @@
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
}
@ -46,7 +48,7 @@
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex());
@@ -113,17 +131,17 @@
@@ -115,9 +133,9 @@
@Nullable
public Chunk getTickingChunk() {
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getTickingChunkFuture();
@ -57,6 +59,8 @@
+ return either == null ? null : (Chunk) either.left().orElse(null); // CraftBukkit - decompile error
}
public CompletableFuture<?> getChunkSendSyncFuture() {
@@ -132,9 +150,9 @@
@Nullable
public Chunk getFullChunk() {
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getFullChunkFuture();
@ -68,7 +72,7 @@
}
@Nullable
@@ -168,6 +186,7 @@
@@ -179,6 +197,7 @@
if (chunk != null) {
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
@ -76,7 +80,7 @@
if (this.changedBlocksPerSection[i] == null) {
this.hasChangedSections = true;
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
@@ -178,10 +197,10 @@
@@ -189,10 +208,10 @@
}
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
@ -89,7 +93,7 @@
if (ichunkaccess != null) {
ichunkaccess.setUnsaved(true);
@@ -246,8 +265,11 @@
@@ -257,8 +276,11 @@
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
this.broadcast(list, packetplayoutmultiblockchange);
@ -102,7 +106,7 @@
});
}
}
@@ -372,7 +394,7 @@
@@ -394,7 +416,7 @@
this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((either) -> {
either.ifLeft((chunk) -> {
@ -111,7 +115,7 @@
});
});
}
@@ -389,6 +411,30 @@
@@ -411,6 +433,30 @@
boolean flag1 = ChunkLevel.isLoaded(this.ticketLevel);
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
@ -142,7 +146,7 @@
if (flag) {
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
@@ -459,6 +505,26 @@
@@ -481,6 +527,26 @@
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
this.oldTicketLevel = this.ticketLevel;

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/server/level/PlayerChunkMap.java
+++ b/net/minecraft/server/level/PlayerChunkMap.java
@@ -109,6 +109,12 @@
import org.apache.commons.lang3.mutable.MutableObject;
@@ -101,6 +101,12 @@
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.slf4j.Logger;
+// CraftBukkit start
@ -13,9 +13,9 @@
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -151,6 +157,27 @@
@@ -143,6 +149,27 @@
private final Queue<Runnable> unloadQueue;
int viewDistance;
private int serverViewDistance;
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
@ -41,7 +41,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(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -169,6 +196,11 @@
@@ -161,6 +188,11 @@
this.storageName = path.getFileName().toString();
this.level = worldserver;
this.generator = chunkgenerator;
@ -53,7 +53,7 @@
IRegistryCustom iregistrycustom = worldserver.registryAccess();
long j = worldserver.getSeed();
@@ -335,9 +367,12 @@
@@ -332,9 +364,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList();
@ -68,7 +68,7 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
if (either == null) {
@@ -543,7 +578,7 @@
@@ -540,7 +575,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@ -77,7 +77,7 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) {
@@ -634,9 +669,9 @@
@@ -631,9 +666,9 @@
ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get());
this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType());
@ -89,7 +89,7 @@
}
}, this.mainThreadExecutor).exceptionallyAsync((throwable) -> {
return this.handleChunkLoadFailure(throwable, chunkcoordintpair);
@@ -751,7 +786,21 @@
@@ -748,7 +783,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
@ -112,7 +112,7 @@
}
}
@@ -852,7 +901,7 @@
@@ -860,7 +909,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) {
return false;
} else {
@ -121,7 +121,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false;
@@ -1014,7 +1063,8 @@
@@ -1017,7 +1066,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
});
@ -131,7 +131,7 @@
return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count();
@@ -1027,7 +1077,7 @@
@@ -1030,7 +1080,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try {
@ -140,7 +140,7 @@
return either != null ? (String) either.map((chunk) -> {
return "done";
@@ -1043,12 +1093,14 @@
@@ -1046,12 +1096,14 @@
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
@ -158,7 +158,7 @@
}
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1503,7 +1555,7 @@
@@ -1460,7 +1512,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) {
@ -167,9 +167,9 @@
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1562,6 +1614,11 @@
@@ -1520,6 +1572,11 @@
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer) && PlayerChunkMap.this.isChunkTracked(entityplayer, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
+ // CraftBukkit start - respect vanish API
+ if (!entityplayer.getBukkitEntity().canSee(this.entity.getBukkitEntity())) {

View File

@ -95,7 +95,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -250,9 +304,9 @@
@@ -246,9 +300,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);
@ -108,15 +108,15 @@
} else {
this.dragonFight = null;
}
@@ -266,6 +320,7 @@
return new RandomSequences(l);
}, "random_sequences");
@@ -258,6 +312,7 @@
this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
return (RandomSequences) this.getDataStorage().computeIfAbsent(RandomSequences.factory(l), "random_sequences");
});
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
}
/** @deprecated */
@@ -304,12 +359,20 @@
@@ -296,12 +351,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -140,7 +140,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -335,7 +398,7 @@
@@ -327,7 +390,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@ -149,7 +149,7 @@
if (flag) {
this.resetEmptyTime();
@@ -351,7 +414,7 @@
@@ -343,7 +406,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@ -158,7 +158,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -423,7 +486,7 @@
@@ -415,7 +478,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@ -167,7 +167,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -451,7 +514,7 @@
@@ -442,7 +505,7 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -176,7 +176,7 @@
}
}
@@ -460,7 +523,7 @@
@@ -451,7 +514,7 @@
if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1);
@ -185,29 +185,29 @@
}
}
}
@@ -475,7 +538,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
@@ -506,7 +569,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition1).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
- this.setBlockAndUpdate(blockposition1, Blocks.ICE.defaultBlockState());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
if (biomebase.shouldFreeze(this, blockposition2)) {
- this.setBlockAndUpdate(blockposition2, Blocks.ICE.defaultBlockState());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition2, Blocks.ICE.defaultBlockState(), null); // CraftBukkit
}
if (flag) {
@@ -522,10 +585,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, j + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
- this.setBlockAndUpdate(blockposition1, iblockdata1);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, iblockdata1, null); // CraftBukkit
}
} else {
- this.setBlockAndUpdate(blockposition1, Blocks.SNOW.defaultBlockState());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
}
}
if (flag) {
@@ -489,10 +552,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, i1 + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition);
- this.setBlockAndUpdate(blockposition, iblockdata1);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, iblockdata1, null); // CraftBukkit
}
} else {
- this.setBlockAndUpdate(blockposition, Blocks.SNOW.defaultBlockState());
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit
}
}
@@ -688,6 +751,7 @@
@@ -686,6 +749,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@ -215,7 +215,7 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -706,14 +770,47 @@
@@ -704,14 +768,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
@ -265,7 +265,7 @@
}
public void resetEmptyTime() {
@@ -748,6 +845,7 @@
@@ -746,6 +843,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@ -273,7 +273,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -771,6 +869,7 @@
@@ -769,6 +867,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@ -281,7 +281,7 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -795,6 +894,7 @@
@@ -793,6 +892,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
@ -289,7 +289,7 @@
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -812,11 +912,19 @@
@@ -810,11 +910,19 @@
}
}
@ -310,7 +310,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -881,15 +989,37 @@
@@ -879,15 +987,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@ -351,7 +351,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -920,24 +1050,37 @@
@@ -918,24 +1048,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@ -393,7 +393,7 @@
return true;
}
}
@@ -951,10 +1094,32 @@
@@ -949,10 +1092,32 @@
entityplayer.remove(entity_removalreason);
}
@ -426,7 +426,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -963,6 +1128,12 @@
@@ -961,6 +1126,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -439,7 +439,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -1022,7 +1193,18 @@
@@ -1020,7 +1191,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@ -459,7 +459,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1084,6 +1266,11 @@
@@ -1082,6 +1264,11 @@
@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) {
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false);
@ -471,7 +471,7 @@
if (!explosion.interactsWithBlocks()) {
explosion.clearToBlow();
@@ -1156,13 +1343,20 @@
@@ -1154,13 +1341,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) {
@ -494,7 +494,7 @@
++j;
}
}
@@ -1213,7 +1407,7 @@
@@ -1211,7 +1405,7 @@
@Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@ -503,22 +503,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
@@ -1250,11 +1444,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
- return (WorldMap) this.getServer().overworld().getDataStorage().get(WorldMap::load, s);
+ // CraftBukkit start
+ return (WorldMap) this.getServer().overworld().getDataStorage().get((nbttagcompound) -> {
+ // We only get here when the data file exists, but is not a valid map
+ WorldMap newMap = WorldMap.load(nbttagcompound);
+ newMap.id = s;
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ return newMap;
+ }, s);
+ // CraftBukkit end
}
@@ -1253,6 +1447,7 @@
@Override
public void setMapData(String s, WorldMap worldmap) {
@ -526,7 +511,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1552,6 +1756,11 @@
@@ -1550,6 +1745,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@ -538,7 +523,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1571,12 +1780,12 @@
@@ -1569,12 +1769,12 @@
}
public boolean isFlat() {
@ -553,7 +538,7 @@
}
@Nullable
@@ -1599,7 +1808,7 @@
@@ -1597,7 +1797,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -562,7 +547,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1608,7 +1817,7 @@
@@ -1606,7 +1806,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -571,7 +556,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1619,17 +1828,33 @@
@@ -1617,17 +1817,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@ -607,7 +592,7 @@
}
@Override
@@ -1753,6 +1978,7 @@
@@ -1751,6 +1967,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -615,7 +600,7 @@
}
public void onTrackingEnd(Entity entity) {
@@ -1789,6 +2015,14 @@
@@ -1787,6 +2004,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -22,10 +22,10 @@
@Override
public void handleIntention(PacketHandshakingInSetProtocol packethandshakinginsetprotocol) {
+ this.connection.hostname = packethandshakinginsetprotocol.hostName + ":" + packethandshakinginsetprotocol.port; // CraftBukkit - set hostname
switch (packethandshakinginsetprotocol.getIntention()) {
+ this.connection.hostname = packethandshakinginsetprotocol.hostName() + ":" + packethandshakinginsetprotocol.port(); // CraftBukkit - set hostname
switch (packethandshakinginsetprotocol.intention()) {
case LOGIN:
this.connection.setProtocol(EnumProtocol.LOGIN);
this.connection.setClientboundProtocolAfterHandshake(ClientIntent.LOGIN);
+ // CraftBukkit start - Connection throttle
+ try {
+ long currentTime = System.currentTimeMillis();
@ -60,6 +60,6 @@
+ org.apache.logging.log4j.LogManager.getLogger().debug("Failed to check connection throttle", t);
+ }
+ // CraftBukkit end
if (packethandshakinginsetprotocol.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
if (packethandshakinginsetprotocol.protocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
IChatMutableComponent ichatmutablecomponent;

View File

@ -1,34 +1,45 @@
--- a/net/minecraft/server/network/LegacyPingHandler.java
+++ b/net/minecraft/server/network/LegacyPingHandler.java
@@ -37,11 +37,12 @@
MinecraftServer minecraftserver = this.serverConnectionListener.getServer();
int i = bytebuf.readableBytes();
String s;
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(minecraftserver.server, inetsocketaddress.getAddress(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers()); // CraftBukkit
@@ -35,10 +35,11 @@
SocketAddress socketaddress = channelhandlercontext.channel().remoteAddress();
int i = bytebuf.readableBytes();
String s;
+ org.bukkit.event.server.ServerListPingEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(socketaddress, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers()); // CraftBukkit
switch (i) {
case 0:
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- s = String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break;
case 1:
@@ -50,7 +51,7 @@
if (i == 0) {
LegacyPingHandler.LOGGER.debug("Ping: (<1.3.x) from {}", socketaddress);
- s = createVersion0Response(this.server);
+ s = createVersion0Response(this.server, event); // CraftBukkit
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
} else {
if (bytebuf.readUnsignedByte() != 1) {
@@ -55,7 +56,7 @@
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}", socketaddress);
}
LegacyPingHandler.LOGGER.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- s = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ s = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
this.sendFlushAndClose(channelhandlercontext, this.createReply(s));
break;
default:
@@ -69,7 +70,7 @@
}
- s = createVersion1Response(this.server);
+ s = createVersion1Response(this.server, event); // CraftBukkit
sendFlushAndClose(channelhandlercontext, createLegacyDisconnectPacket(channelhandlercontext.alloc(), s));
}
LegacyPingHandler.LOGGER.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
- String s1 = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), minecraftserver.getMotd(), minecraftserver.getPlayerCount(), minecraftserver.getMaxPlayers());
+ String s1 = String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers()); // CraftBukkit
ByteBuf bytebuf1 = this.createReply(s1);
@@ -106,12 +107,16 @@
}
}
try {
- private static String createVersion0Response(ServerInfo serverinfo) {
- return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
+ // CraftBukkit start
+ private static String createVersion0Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
+ return String.format(Locale.ROOT, "%s\u00a7%d\u00a7%d", event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
+ // CraftBukkit end
}
- private static String createVersion1Response(ServerInfo serverinfo) {
- return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), serverinfo.getMotd(), serverinfo.getPlayerCount(), serverinfo.getMaxPlayers());
+ // CraftBukkit start
+ private static String createVersion1Response(ServerInfo serverinfo, org.bukkit.event.server.ServerListPingEvent event) {
+ return String.format(Locale.ROOT, "\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, serverinfo.getServerVersion(), event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
+ // CraftBukkit end
}
private static void sendFlushAndClose(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {

View File

@ -1,10 +1,11 @@
--- a/net/minecraft/server/network/LoginListener.java
+++ b/net/minecraft/server/network/LoginListener.java
@@ -38,6 +38,12 @@
@@ -39,6 +39,13 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
+import org.bukkit.event.player.PlayerPreLoginEvent;
@ -13,7 +14,15 @@
public class LoginListener implements PacketLoginInListener, TickablePacketListener {
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
@@ -83,6 +89,13 @@
@@ -55,6 +62,7 @@
@Nullable
private GameProfile authenticatedProfile;
private final String serverId;
+ private EntityPlayer player; // CraftBukkit
public LoginListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
this.state = LoginListener.EnumProtocolState.HELLO;
@@ -80,6 +88,13 @@
}
@ -27,43 +36,43 @@
@Override
public boolean isAcceptingMessages() {
return this.connection.isConnected();
@@ -104,10 +117,12 @@
this.gameProfile = this.createFakeProfile(this.gameProfile);
}
@@ -138,10 +153,12 @@
- IChatBaseComponent ichatbasecomponent = this.server.getPlayerList().canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
private void verifyLoginAndFinishConnectionSetup(GameProfile gameprofile) {
PlayerList playerlist = this.server.getPlayerList();
- IChatBaseComponent ichatbasecomponent = playerlist.canPlayerLogin(this.connection.getRemoteAddress(), gameprofile);
+ // CraftBukkit start - fire PlayerLoginEvent
+ EntityPlayer s = this.server.getPlayerList().canPlayerLogin(this, this.gameProfile);
+ this.player = playerlist.canPlayerLogin(this, gameprofile); // CraftBukkit
- if (ichatbasecomponent != null) {
- this.disconnect(ichatbasecomponent);
+ if (s == null) {
+ if (this.player == null) {
+ // this.disconnect(ichatbasecomponent);
+ // CraftBukkit end
} else {
this.state = LoginListener.EnumProtocolState.ACCEPTED;
if (this.server.getCompressionThreshold() >= 0 && !this.connection.isMemoryConnection()) {
@@ -120,7 +135,7 @@
EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.gameProfile.getId());
this.connection.send(new PacketLoginOutSetCompression(this.server.getCompressionThreshold()), PacketSendListener.thenRun(() -> {
@@ -149,7 +166,7 @@
}));
}
try {
- EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile);
+ EntityPlayer entityplayer1 = this.server.getPlayerList().getPlayerForLogin(this.gameProfile, s); // CraftBukkit - add player reference
- boolean flag = playerlist.disconnectAllPlayersWithProfile(gameprofile);
+ boolean flag = playerlist.disconnectAllPlayersWithProfile(gameprofile, this.player); // CraftBukkit - add player reference
if (flag) {
this.state = LoginListener.EnumProtocolState.WAITING_FOR_DUPE_DISCONNECT;
@@ -205,6 +222,43 @@
if (profileresult != null) {
GameProfile gameprofile = profileresult.profile();
if (entityplayer != null) {
this.state = LoginListener.EnumProtocolState.DELAY_ACCEPT;
@@ -210,6 +225,43 @@
try {
LoginListener.this.gameProfile = LoginListener.this.server.getSessionService().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s, this.getAddress());
if (LoginListener.this.gameProfile != null) {
+ // CraftBukkit start - fire PlayerPreLoginEvent
+ if (!connection.isConnected()) {
+ return;
+ }
+
+ String playerName = gameProfile.getName();
+ String playerName = gameprofile.getName();
+ java.net.InetAddress address = ((java.net.InetSocketAddress) connection.getRemoteAddress()).getAddress();
+ java.util.UUID uniqueId = gameProfile.getId();
+ java.util.UUID uniqueId = gameprofile.getId();
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.this.server.server;
+
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
@ -93,18 +102,27 @@
+ }
+ }
+ // CraftBukkit end
LoginListener.LOGGER.info("UUID of player {} is {}", LoginListener.this.gameProfile.getName(), LoginListener.this.gameProfile.getId());
LoginListener.this.state = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
LoginListener.LOGGER.info("UUID of player {} is {}", gameprofile.getName(), gameprofile.getId());
LoginListener.this.startClientVerification(gameprofile);
} else if (LoginListener.this.server.isSingleplayer()) {
@@ -229,6 +281,11 @@
@@ -222,6 +276,11 @@
LoginListener.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.authservers_down"));
LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
}
+ // CraftBukkit start - catch all exceptions
+ } catch (Exception exception) {
+ disconnect("Failed to verify username!");
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + gameprofile.getName(), exception);
+ server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + s1, exception);
+ // CraftBukkit end
}
}
@@ -247,7 +306,7 @@
public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket serverboundloginacknowledgedpacket) {
Validate.validState(this.state == LoginListener.EnumProtocolState.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet", new Object[0]);
CommonListenerCookie commonlistenercookie = CommonListenerCookie.createInitial((GameProfile) Objects.requireNonNull(this.authenticatedProfile));
- ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie);
+ ServerConfigurationPacketListenerImpl serverconfigurationpacketlistenerimpl = new ServerConfigurationPacketListenerImpl(this.server, this.connection, commonlistenercookie, this.player); // CraftBukkit
this.connection.setListener(serverconfigurationpacketlistenerimpl);
serverconfigurationpacketlistenerimpl.startConfiguration();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/network/PlayerConnection.java
+++ b/net/minecraft/server/network/PlayerConnection.java
@@ -185,6 +185,71 @@
@@ -180,6 +180,66 @@
import net.minecraft.world.phys.shapes.VoxelShapes;
import org.slf4j.Logger;
@ -13,7 +13,6 @@
+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.PacketPlayOutSpawnPosition;
+import net.minecraft.world.entity.EntityInsentient;
+import net.minecraft.world.entity.animal.Bucketable;
+import net.minecraft.world.entity.EntityLiving;
@ -21,7 +20,7 @@
+import net.minecraft.world.entity.animal.allay.Allay;
+import net.minecraft.world.inventory.InventoryClickType;
+import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.item.crafting.IRecipe;
+import net.minecraft.world.item.crafting.RecipeHolder;
+import net.minecraft.world.level.RayTrace;
+import net.minecraft.world.phys.MovingObjectPosition;
+import org.bukkit.Location;
@ -30,7 +29,6 @@
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+import org.bukkit.craftbukkit.util.LazyPlayerSet;
@ -38,7 +36,6 @@
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.block.SignChangeEvent;
+import org.bukkit.event.inventory.ClickType;
+import org.bukkit.event.inventory.CraftItemEvent;
+import org.bukkit.event.inventory.InventoryAction;
@ -54,9 +51,7 @@
+import org.bukkit.event.player.PlayerInteractAtEntityEvent;
+import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.event.player.PlayerItemHeldEvent;
+import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
+import org.bukkit.event.player.PlayerRespawnEvent.RespawnReason;
+import org.bukkit.event.player.PlayerSwapHandItemsEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
@ -69,13 +64,13 @@
+import org.bukkit.inventory.SmithingInventory;
+// CraftBukkit end
+
public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn {
public class PlayerConnection extends ServerCommonPacketListenerImpl implements PacketListenerPlayIn, ServerPlayerConnection, TickablePacketListener {
static final Logger LOGGER = LogUtils.getLogger();
@@ -201,7 +266,9 @@
private long keepAliveTime;
private boolean keepAlivePending;
private long keepAliveChallenge;
@@ -191,7 +251,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();
@ -83,18 +78,24 @@
private int dropSpamTickCount;
private double firstGoodX;
private double firstGoodY;
@@ -247,8 +314,31 @@
this.keepAliveTime = SystemUtils.getMillis();
@@ -227,7 +289,7 @@
private boolean waitingForSwitchToConfig;
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer, CommonListenerCookie commonlistenercookie) {
- super(minecraftserver, networkmanager, commonlistenercookie);
+ super(minecraftserver, networkmanager, commonlistenercookie, entityplayer); // CraftBukkit
this.lastChatTimeStamp = new AtomicReference(Instant.EPOCH);
this.lastSeenMessages = new LastSeenMessagesValidator(20);
this.messageSignatureCache = MessageSignatureCache.createDefault();
@@ -237,9 +299,25 @@
entityplayer.connection = this;
entityplayer.getTextFilter().join();
this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID());
- this.chatMessageChain = new FutureChain(minecraftserver);
+ this.chatMessageChain = new FutureChain(minecraftserver.chatExecutor); // CraftBukkit - async chat
+ // CraftBukkit start - add fields and methods
+ this.cserver = minecraftserver.server;
+ }
+
+ private final org.bukkit.craftbukkit.CraftServer cserver;
+ public boolean processedDisconnect;
}
+ // CraftBukkit start - add fields
+ private int lastTick = MinecraftServer.currentTick;
+ private int allowedPlayerTicks = 1;
+ private int lastDropTick = MinecraftServer.currentTick;
@ -108,27 +109,15 @@
+ private float lastPitch = Float.MAX_VALUE;
+ private float lastYaw = Float.MAX_VALUE;
+ private boolean justTeleported = false;
+
+ public CraftPlayer getCraftPlayer() {
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
}
+ // CraftBukkit end
+
@Override
public void tick() {
@@ -303,7 +393,7 @@
this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis();
- if (i - this.keepAliveTime >= 15000L) {
+ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
if (this.keepAlivePending) {
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
} else {
@@ -315,15 +405,21 @@
if (this.ackBlockChangesUpTo > -1) {
@@ -291,15 +369,21 @@
}
this.server.getProfiler().pop();
this.keepConnectionAlive();
+ // CraftBukkit start
+ for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !chatSpamTickCount.compareAndSet(spam, spam - 1); ) ;
+ /* Use thread-safe field access instead
@ -147,76 +136,7 @@
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
}
@@ -347,16 +443,67 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile());
}
+ // CraftBukkit start
+ @Deprecated
public void disconnect(IChatBaseComponent ichatbasecomponent) {
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent));
+ }
+ // CraftBukkit end
+
+ public void disconnect(String s) {
+ // CraftBukkit start - fire PlayerKickEvent
+ if (this.processedDisconnect) {
+ return;
+ }
+ if (!this.cserver.isPrimaryThread()) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ PlayerConnection.this.disconnect(s);
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ return;
+ }
+
+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game.";
+
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage);
+
+ if (this.cserver.getServer().isRunning()) {
+ this.cserver.getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ // Do not kick the player
+ return;
+ }
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // Send the possibly modified leave message
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
+ // CraftBukkit end
+
this.connection.send(new PacketPlayOutKickDisconnect(ichatbasecomponent), PacketSendListener.thenRun(() -> {
this.connection.disconnect(ichatbasecomponent);
}));
+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
this.connection.setReadOnly();
MinecraftServer minecraftserver = this.server;
NetworkManager networkmanager = this.connection;
Objects.requireNonNull(this.connection);
- minecraftserver.executeBlocking(networkmanager::handleDisconnection);
+ // CraftBukkit - Don't wait
+ minecraftserver.wrapRunnable(networkmanager::handleDisconnection);
}
private <T, R> CompletableFuture<R> filterTextPacket(T t0, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -420,7 +567,34 @@
@@ -390,7 +474,34 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -250,9 +170,9 @@
+ if (d10 - d9 > Math.max(100.0D, Math.pow((double) (10.0F * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
+ // CraftBukkit end
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new PacketPlayOutVehicleMove(entity));
this.send(new PacketPlayOutVehicleMove(entity));
return;
@@ -460,14 +634,72 @@
@@ -430,14 +541,72 @@
}
entity.absMoveTo(d3, d4, d5, f, f1);
@ -262,7 +182,7 @@
if (flag && (flag2 || !flag3)) {
entity.absMoveTo(d0, d1, d2, f, f1);
+ player.absMoveTo(d0, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit
this.connection.send(new PacketPlayOutVehicleMove(entity));
this.send(new PacketPlayOutVehicleMove(entity));
return;
}
@ -325,7 +245,7 @@
this.player.serverLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
@@ -501,6 +733,7 @@
@@ -471,6 +640,7 @@
}
this.awaitingPositionFromClient = null;
@ -333,16 +253,16 @@
}
}
@@ -508,7 +741,7 @@
@@ -478,7 +648,7 @@
@Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel());
- Optional optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe());
+ Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(packetplayinrecipedisplayed.getRecipe()); // CraftBukkit - decompile error
RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver);
@@ -538,6 +771,12 @@
@@ -508,6 +678,12 @@
@Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
@ -355,15 +275,15 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -547,6 +786,7 @@
@@ -517,6 +693,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
+ if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
this.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
});
}
@@ -792,6 +1032,13 @@
@@ -762,6 +939,13 @@
if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container;
@ -377,7 +297,7 @@
if (!containermerchant.stillValid(this.player)) {
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
@@ -806,6 +1053,13 @@
@@ -776,6 +960,13 @@
@Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@ -391,7 +311,7 @@
int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -814,7 +1068,7 @@
@@ -784,7 +975,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@ -400,7 +320,7 @@
Objects.requireNonNull(list);
stream.forEach(list::add);
@@ -832,7 +1086,7 @@
@@ -802,7 +993,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) {
@ -409,7 +329,7 @@
}
}
@@ -857,16 +1111,16 @@
@@ -827,16 +1018,16 @@
this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
@ -430,7 +350,7 @@
return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
});
@@ -892,6 +1146,7 @@
@@ -862,6 +1053,7 @@
}
itemstack.addTagElement("pages", nbttaglist);
@ -438,7 +358,7 @@
}
@Override
@@ -928,7 +1183,7 @@
@@ -898,7 +1090,7 @@
} else {
WorldServer worldserver = this.player.serverLevel();
@ -447,7 +367,7 @@
if (this.tickCount == 0) {
this.resetPosition();
}
@@ -938,7 +1193,7 @@
@@ -908,7 +1100,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@ -456,7 +376,7 @@
} else {
this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -950,7 +1205,15 @@
@@ -920,7 +1112,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);
@ -472,7 +392,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -969,15 +1232,33 @@
@@ -939,15 +1139,33 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -508,7 +428,7 @@
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;
@@ -998,6 +1279,7 @@
@@ -968,6 +1186,7 @@
boolean flag1 = this.player.verticalCollisionBelow;
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
@ -516,7 +436,7 @@
double d11 = d7;
d6 = d0 - this.player.getX();
@@ -1016,9 +1298,70 @@
@@ -986,9 +1205,70 @@
}
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
@ -588,7 +508,7 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
this.clientIsFloating = d11 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
this.player.serverLevel().getChunkSource().move(this.player);
@@ -1059,11 +1402,68 @@
@@ -1029,11 +1309,68 @@
return true;
}
@ -658,7 +578,7 @@
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;
@@ -1075,6 +1475,14 @@
@@ -1045,6 +1382,14 @@
this.awaitingTeleport = 0;
}
@ -673,7 +593,7 @@
this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
@@ -1083,6 +1491,7 @@
@@ -1053,6 +1398,7 @@
@Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
@ -681,7 +601,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime();
@@ -1093,14 +1502,46 @@
@@ -1063,14 +1409,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@ -730,7 +650,7 @@
this.player.drop(false);
}
@@ -1138,6 +1579,7 @@
@@ -1108,6 +1486,7 @@
@Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
@ -738,7 +658,7 @@
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
WorldServer worldserver = this.player.serverLevel();
EnumHand enumhand = packetplayinuseitem.getHand();
@@ -1161,6 +1603,7 @@
@@ -1131,6 +1510,7 @@
if (blockposition.getY() < i) {
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
@ -746,7 +666,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
@@ -1189,6 +1632,7 @@
@@ -1159,6 +1539,7 @@
@Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
@ -754,7 +674,7 @@
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
WorldServer worldserver = this.player.serverLevel();
EnumHand enumhand = packetplayinblockplace.getHand();
@@ -1196,6 +1640,49 @@
@@ -1166,6 +1547,49 @@
this.player.resetLastActionTime();
if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) {
@ -804,7 +724,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) {
@@ -1216,7 +1703,7 @@
@@ -1186,7 +1610,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) {
@ -813,15 +733,7 @@
return;
}
}
@@ -1231,6 +1718,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packetplayinresourcepackstatus.action.ordinal()])); // CraftBukkit
}
@@ -1252,12 +1740,27 @@
@@ -1209,6 +1633,13 @@
@Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@ -832,8 +744,13 @@
+ this.processedDisconnect = true;
+ }
+ // CraftBukkit end
this.chatMessageChain.close();
PlayerConnection.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), ichatbasecomponent.getString());
this.removePlayerFromWorld();
super.onDisconnect(ichatbasecomponent);
@@ -1216,10 +1647,18 @@
private void removePlayerFromWorld() {
this.chatMessageChain.close();
+ // CraftBukkit start - Replace vanilla quit message handling with our own.
+ /*
this.server.invalidateStatus();
@ -848,25 +765,9 @@
+ }
+ // CraftBukkit end
this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1280,6 +1783,15 @@
}
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
+ // CraftBukkit start
+ if (packet == null) {
+ return;
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
+ this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
+ }
+ // CraftBukkit end
+
try {
this.connection.send(packet, packetsendlistener);
} catch (Throwable throwable) {
@@ -1296,7 +1808,16 @@
@@ -1234,7 +1673,16 @@
@Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
@ -883,7 +784,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1305,18 +1826,25 @@
@@ -1243,18 +1691,25 @@
this.player.resetLastActionTime();
} else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -910,8 +811,8 @@
PlayerChatMessage playerchatmessage;
try {
@@ -1334,9 +1862,9 @@
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask());
@@ -1272,9 +1727,9 @@
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent(ichatbasecomponent).filter(filteredtext.mask());
this.broadcastChatMessage(playerchatmessage1);
- }, executor);
@ -922,7 +823,7 @@
}
}
@@ -1351,6 +1879,12 @@
@@ -1289,6 +1744,12 @@
if (optional.isPresent()) {
this.server.submit(() -> {
@ -935,7 +836,7 @@
this.performChatCommand(serverboundchatcommandpacket, (LastSeenMessages) optional.get());
this.detectRateSpam();
});
@@ -1360,12 +1894,25 @@
@@ -1298,12 +1759,25 @@
}
private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) {
@ -963,20 +864,20 @@
} catch (SignedMessageChain.a signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a);
return;
@@ -1373,10 +1920,10 @@
@@ -1311,10 +1785,10 @@
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
- parseresults = CommandDispatcher.mapSource(parseresults, (commandlistenerwrapper) -> {
+ parseresults = CommandDispatcher.<CommandListenerWrapper>mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a);
return commandlistenerwrapper.withSigningContext(commandsigningcontext_a, this.chatMessageChain);
});
- this.server.getCommands().performCommand(parseresults, serverboundchatcommandpacket.command());
+ this.server.getCommands().performCommand(parseresults, command); // CraftBukkit
}
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
@@ -1417,7 +1964,7 @@
@@ -1355,7 +1829,7 @@
} else {
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(lastseenmessages_b);
@ -985,7 +886,7 @@
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
return Optional.empty();
} else {
@@ -1465,6 +2012,116 @@
@@ -1403,6 +1877,116 @@
return false;
}
@ -1102,7 +1003,7 @@
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
@@ -1472,13 +2129,33 @@
@@ -1410,13 +1994,33 @@
}
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
@ -1139,7 +1040,7 @@
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
}
@@ -1500,13 +2177,62 @@
@@ -1438,13 +2042,62 @@
@Override
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
@ -1202,7 +1103,7 @@
this.player.resetLastActionTime();
Entity entity;
IJumpable ijumpable;
@@ -1588,6 +2314,12 @@
@@ -1526,6 +2179,12 @@
}
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
@ -1215,7 +1116,7 @@
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess())));
this.addPendingMessage(playerchatmessage);
}
@@ -1603,6 +2335,7 @@
@@ -1552,6 +2211,7 @@
@Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
@ -1223,7 +1124,7 @@
final WorldServer worldserver = this.player.serverLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1617,13 +2350,51 @@
@@ -1566,13 +2226,51 @@
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
@ -1276,7 +1177,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
if (enuminteractionresult.shouldSwing()) {
@@ -1636,23 +2407,29 @@
@@ -1585,23 +2283,29 @@
@Override
public void onInteraction(EnumHand enumhand) {
@ -1309,7 +1210,7 @@
}
} else {
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
@@ -1675,14 +2452,14 @@
@@ -1624,14 +2328,14 @@
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
@ -1326,7 +1227,7 @@
if (this.server.isHardcore()) {
this.player.setGameMode(EnumGamemode.SPECTATOR);
((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
@@ -1698,15 +2475,21 @@
@@ -1647,15 +2351,21 @@
@Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
@ -1350,7 +1251,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);
@@ -1719,7 +2502,284 @@
@@ -1668,7 +2378,284 @@
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -1636,12 +1537,12 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1749,9 +2809,18 @@
@@ -1698,9 +2685,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((irecipe) -> {
- ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(packetplayinautorecipe.isShiftDown(), irecipe, this.player);
- 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) {
@ -1650,14 +1551,14 @@
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packetplayinautorecipe.isShiftDown());
+
+ // 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((irecipe) -> {
+ ((ContainerRecipeBook) this.player.containerMenu).handlePlacement(event.isShiftClick(), irecipe, this.player);
+ 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
}
}
}
@@ -1759,6 +2828,7 @@
@@ -1708,6 +2704,7 @@
@Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
@ -1665,7 +1566,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1801,6 +2871,43 @@
@@ -1750,6 +2747,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1709,7 +1610,7 @@
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
@@ -1823,6 +2930,7 @@
@@ -1772,6 +2806,7 @@
}
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
@ -1717,15 +1618,7 @@
this.player.resetLastActionTime();
WorldServer worldserver = this.player.serverLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1843,6 +2951,7 @@
@Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
+ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinkeepalive, this, this.player.serverLevel()); // CraftBukkit
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1857,7 +2966,17 @@
@@ -1793,7 +2828,17 @@
@Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
@ -1744,56 +1637,12 @@
}
@Override
@@ -1866,8 +2985,50 @@
this.player.updateOptions(packetplayinsettings);
@@ -1852,7 +2897,7 @@
if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested");
} else {
- this.connection.setListener(new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation())));
+ this.connection.setListener(new ServerConfigurationPacketListenerImpl(this.server, this.connection, this.createCookie(this.player.clientInformation()), this.player)); // CraftBukkit
}
}
- @Override
- public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) {}
+ // CraftBukkit start
+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
+
+ @Override
+ public void handleCustomPayload(PacketPlayInCustomPayload packetplayincustompayload) {
+ PlayerConnectionUtils.ensureRunningOnSameThread(packetplayincustompayload, this, this.player.serverLevel());
+ if (packetplayincustompayload.identifier.equals(CUSTOM_REGISTER)) {
+ try {
+ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
+ for (String channel : channels.split("\0")) {
+ getCraftPlayer().addChannel(channel);
+ }
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
+ this.disconnect("Invalid payload REGISTER!");
+ }
+ } else if (packetplayincustompayload.identifier.equals(CUSTOM_UNREGISTER)) {
+ try {
+ String channels = packetplayincustompayload.data.toString(com.google.common.base.Charsets.UTF_8);
+ for (String channel : channels.split("\0")) {
+ getCraftPlayer().removeChannel(channel);
+ }
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
+ this.disconnect("Invalid payload UNREGISTER!");
+ }
+ } else {
+ try {
+ byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
+ packetplayincustompayload.data.readBytes(data);
+ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.identifier.toString(), data);
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
+ this.disconnect("Invalid custom payload!");
+ }
+ }
+
+ }
+
+ public final boolean isDisconnected() {
+ return !this.player.joining && !this.connection.isConnected();
+ }
+ // CraftBukkit end
@Override
public void handleChangeDifficulty(PacketPlayInDifficultyChange packetplayindifficultychange) {

View File

@ -0,0 +1,215 @@
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -26,6 +26,21 @@
import net.minecraft.util.thread.IAsyncTaskHandler;
import org.slf4j.Logger;
+// CraftBukkit start
+import io.netty.buffer.ByteBuf;
+import java.util.concurrent.ExecutionException;
+import net.minecraft.EnumChatFormat;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnPosition;
+import net.minecraft.resources.MinecraftKey;
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.craftbukkit.util.Waitable;
+import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerResourcePackStatusEvent;
+// CraftBukkit end
+
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -39,11 +54,22 @@
private int latency;
private volatile boolean suspendFlushingOnServerThread = false;
- public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie) {
+ public ServerCommonPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie, EntityPlayer player) { // CraftBukkit
this.server = minecraftserver;
this.connection = networkmanager;
this.keepAliveTime = SystemUtils.getMillis();
this.latency = commonlistenercookie.latency();
+ // CraftBukkit start - add fields and methods
+ this.player = player;
+ this.cserver = minecraftserver.server;
+ }
+ protected final EntityPlayer player;
+ protected final org.bukkit.craftbukkit.CraftServer cserver;
+ public boolean processedDisconnect;
+
+ public CraftPlayer getCraftPlayer() {
+ return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
+ // CraftBukkit end
}
@Override
@@ -57,6 +83,7 @@
@Override
public void handleKeepAlive(ServerboundKeepAlivePacket serverboundkeepalivepacket) {
+ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundkeepalivepacket, this, this.player.serverLevel()); // CraftBukkit
if (this.keepAlivePending && serverboundkeepalivepacket.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -71,8 +98,56 @@
@Override
public void handlePong(ServerboundPongPacket serverboundpongpacket) {}
+ // CraftBukkit start
+ private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
+ private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
+
@Override
- public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {}
+ public void handleCustomPayload(ServerboundCustomPayloadPacket serverboundcustompayloadpacket) {
+ if (!(serverboundcustompayloadpacket.payload() instanceof ServerboundCustomPayloadPacket.UnknownPayload)) {
+ return;
+ }
+ PlayerConnectionUtils.ensureRunningOnSameThread(serverboundcustompayloadpacket, this, this.player.serverLevel());
+ MinecraftKey identifier = serverboundcustompayloadpacket.payload().id();
+ ByteBuf payload = ((ServerboundCustomPayloadPacket.UnknownPayload)serverboundcustompayloadpacket.payload()).data();
+
+ if (identifier.equals(CUSTOM_REGISTER)) {
+ try {
+ String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
+ for (String channel : channels.split("\0")) {
+ getCraftPlayer().addChannel(channel);
+ }
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t register custom payload", ex);
+ this.disconnect("Invalid payload REGISTER!");
+ }
+ } else if (identifier.equals(CUSTOM_UNREGISTER)) {
+ try {
+ String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
+ for (String channel : channels.split("\0")) {
+ getCraftPlayer().removeChannel(channel);
+ }
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t unregister custom payload", ex);
+ this.disconnect("Invalid payload UNREGISTER!");
+ }
+ } else {
+ try {
+ byte[] data = new byte[payload.readableBytes()];
+ payload.readBytes(data);
+ cserver.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), identifier.toString(), data);
+ } catch (Exception ex) {
+ PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
+ this.disconnect("Invalid custom payload!");
+ }
+ }
+
+ }
+
+ public final boolean isDisconnected() {
+ return !this.player.joining && !this.connection.isConnected();
+ }
+ // CraftBukkit end
@Override
public void handleResourcePackResponse(ServerboundResourcePackPacket serverboundresourcepackpacket) {
@@ -81,6 +156,7 @@
ServerCommonPacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.playerProfile().getName());
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
}
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[serverboundresourcepackpacket.getAction().ordinal()])); // CraftBukkit
}
@@ -88,7 +164,7 @@
this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis();
- if (i - this.keepAliveTime >= 15000L) {
+ if (i - this.keepAliveTime >= 25000L) { // CraftBukkit
if (this.keepAlivePending) {
this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE);
} else {
@@ -116,6 +192,14 @@
}
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
+ // CraftBukkit start
+ if (packet == null) {
+ return;
+ } else if (packet instanceof PacketPlayOutSpawnPosition) {
+ PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition) packet;
+ this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
+ }
+ // CraftBukkit end
boolean flag = !this.suspendFlushingOnServerThread || !this.server.isSameThread();
try {
@@ -131,16 +215,67 @@
}
}
+ // CraftBukkit start
+ @Deprecated
public void disconnect(IChatBaseComponent ichatbasecomponent) {
+ disconnect(CraftChatMessage.fromComponent(ichatbasecomponent));
+ }
+ // CraftBukkit end
+
+ public void disconnect(String s) {
+ // CraftBukkit start - fire PlayerKickEvent
+ if (this.processedDisconnect) {
+ return;
+ }
+ if (!this.cserver.isPrimaryThread()) {
+ Waitable waitable = new Waitable() {
+ @Override
+ protected Object evaluate() {
+ ServerCommonPacketListenerImpl.this.disconnect(s);
+ return null;
+ }
+ };
+
+ this.server.processQueue.add(waitable);
+
+ try {
+ waitable.get();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ return;
+ }
+
+ String leaveMessage = EnumChatFormat.YELLOW + this.player.getScoreboardName() + " left the game.";
+
+ PlayerKickEvent event = new PlayerKickEvent(this.player.getBukkitEntity(), s, leaveMessage);
+
+ if (this.cserver.getServer().isRunning()) {
+ this.cserver.getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled()) {
+ // Do not kick the player
+ return;
+ }
+ this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // Send the possibly modified leave message
+ final IChatBaseComponent ichatbasecomponent = CraftChatMessage.fromString(event.getReason(), true)[0];
+ // CraftBukkit end
+
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> {
this.connection.disconnect(ichatbasecomponent);
}));
+ this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
this.connection.setReadOnly();
MinecraftServer minecraftserver = this.server;
NetworkManager networkmanager = this.connection;
Objects.requireNonNull(this.connection);
- minecraftserver.executeBlocking(networkmanager::handleDisconnection);
+ // CraftBukkit - Don't wait
+ minecraftserver.wrapRunnable(networkmanager::handleDisconnection);
}
protected boolean isSingleplayerOwner() {

View File

@ -0,0 +1,30 @@
--- a/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerConfigurationPacketListenerImpl.java
@@ -44,8 +44,8 @@
private ConfigurationTask currentTask;
private ClientInformation clientInformation;
- public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie) {
- super(minecraftserver, networkmanager, commonlistenercookie);
+ public ServerConfigurationPacketListenerImpl(MinecraftServer minecraftserver, NetworkManager networkmanager, CommonListenerCookie commonlistenercookie, EntityPlayer player) { // CraftBukkit
+ super(minecraftserver, networkmanager, commonlistenercookie, player); // CraftBukkit
this.gameProfile = commonlistenercookie.gameProfile();
this.clientInformation = commonlistenercookie.clientInformation();
}
@@ -117,14 +117,14 @@
return;
}
- IChatBaseComponent ichatbasecomponent = playerlist.canPlayerLogin(this.connection.getRemoteAddress(), this.gameProfile);
+ IChatBaseComponent ichatbasecomponent = null; // CraftBukkit - login checks already completed
if (ichatbasecomponent != null) {
this.disconnect(ichatbasecomponent);
return;
}
- EntityPlayer entityplayer = playerlist.getPlayerForLogin(this.gameProfile, this.clientInformation);
+ EntityPlayer entityplayer = playerlist.getPlayerForLogin(this.gameProfile, this.clientInformation, this.player); // CraftBukkit
playerlist.placeNewPlayer(this.connection, entityplayer, this.createCookie(this.clientInformation));
this.connection.resumeInboundAfterProtocolChange();

View File

@ -1,18 +1,18 @@
--- a/net/minecraft/server/network/ServerConnection.java
+++ b/net/minecraft/server/network/ServerConnection.java
@@ -95,16 +95,26 @@
@@ -98,16 +98,26 @@
NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND);
NetworkManager.configureSerialization(channelpipeline, EnumProtocolDirection.SERVERBOUND, (BandwidthDebugMonitor) null);
int j = ServerConnection.this.server.getRateLimitPacketsPerSecond();
- Object object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND);
+ NetworkManager object = j > 0 ? new NetworkManagerServer(j) : new NetworkManager(EnumProtocolDirection.SERVERBOUND); // CraftBukkit - decompile error
ServerConnection.this.connections.add(object);
channelpipeline.addLast("packet_handler", (ChannelHandler) object);
((NetworkManager) object).setListener(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
((NetworkManager) object).configurePacketHandler(channelpipeline);
((NetworkManager) object).setListenerForServerboundHandshake(new HandshakeListener(ServerConnection.this.server, (NetworkManager) object));
}
- }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).bind().syncUninterruptibly());
+ }).group((EventLoopGroup) lazyinitvar.get()).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
- }).group(eventloopgroup).localAddress(inetaddress, i)).bind().syncUninterruptibly());
+ }).group(eventloopgroup).localAddress(inetaddress, i)).option(ChannelOption.AUTO_READ, false).bind().syncUninterruptibly()); // CraftBukkit
}
}

View File

@ -3,7 +3,7 @@
@@ -27,7 +27,7 @@
}
protected ExpirableListEntry(T t0, JsonObject jsonobject) {
protected ExpirableListEntry(@Nullable T t0, JsonObject jsonobject) {
- super(t0);
+ super(checkExpiry(t0, jsonobject)); // CraftBukkit

View File

@ -41,12 +41,12 @@
JsonObject jsonobject = new JsonObject();
Objects.requireNonNull(jsonlistentry);
@@ -165,7 +166,7 @@
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
@@ -171,7 +172,7 @@
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
if (jsonlistentry.getUser() != null) {
- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry);
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
if (jsonlistentry.getUser() != null) {
- this.map.put(this.getKeyForUser(jsonlistentry.getUser()), jsonlistentry);
+ this.map.put(this.getKeyForUser(jsonlistentry.getUser()), (V) jsonlistentry); // CraftBukkit - decompile error
}
}
}
} catch (Throwable throwable) {
} catch (Throwable throwable) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/NameReferencingFileConverter.java
+++ b/net/minecraft/server/players/NameReferencingFileConverter.java
@@ -28,6 +28,11 @@
@@ -27,6 +27,11 @@
import net.minecraft.world.level.storage.SavedFile;
import org.slf4j.Logger;
@ -12,7 +12,7 @@
public class NameReferencingFileConverter {
static final Logger LOGGER = LogUtils.getLogger();
@@ -88,7 +93,7 @@
@@ -87,7 +92,7 @@
try {
gameprofilebanlist.load();
} catch (IOException ioexception) {
@ -21,7 +21,7 @@
}
}
@@ -146,7 +151,7 @@
@@ -145,7 +150,7 @@
try {
ipbanlist.load();
} catch (IOException ioexception) {
@ -30,7 +30,7 @@
}
}
@@ -187,7 +192,7 @@
@@ -186,7 +191,7 @@
try {
oplist.load();
} catch (IOException ioexception) {
@ -39,7 +39,7 @@
}
}
@@ -231,7 +236,7 @@
@@ -230,7 +235,7 @@
try {
whitelist.load();
} catch (IOException ioexception) {
@ -48,7 +48,7 @@
}
}
@@ -354,6 +359,30 @@
@@ -349,6 +354,30 @@
File file5 = new File(file, s2 + ".dat");
File file6 = new File(file4, s3 + ".dat");

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -108,6 +108,26 @@
@@ -102,6 +102,26 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@ -27,7 +27,7 @@
public abstract class PlayerList {
public static final File USERBANLIST_FILE = new File("banned-players.json");
@@ -119,14 +139,16 @@
@@ -114,14 +134,16 @@
private static final int SEND_PLAYER_INFO_INTERVAL = 600;
private static final SimpleDateFormat BAN_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server;
@ -47,7 +47,7 @@
public final WorldNBTStorage playerIo;
private boolean doWhiteList;
private final LayeredRegistryAccess<RegistryLayer> registries;
@@ -138,13 +160,23 @@
@@ -132,13 +154,23 @@
private static final boolean ALLOW_LOGOUTIVATOR = false;
private int sendAllPlayerInfoIn;
@ -72,8 +72,8 @@
+ // CraftBukkit end
this.server = minecraftserver;
this.registries = layeredregistryaccess;
this.synchronizedRegistries = (new IRegistryCustom.c(RegistrySynchronization.networkedRegistries(layeredregistryaccess))).freeze();
@@ -168,9 +200,15 @@
this.maxPlayers = i;
@@ -161,9 +193,15 @@
NBTTagCompound nbttagcompound = this.load(entityplayer);
ResourceKey resourcekey;
@ -90,9 +90,9 @@
Logger logger = PlayerList.LOGGER;
Objects.requireNonNull(logger);
@@ -197,7 +235,8 @@
s1 = networkmanager.getRemoteAddress().toString();
}
@@ -186,7 +224,8 @@
entityplayer.setServerLevel(worldserver1);
String s1 = networkmanager.getLoggableAddress(this.server.logIPs());
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()});
+ // CraftBukkit - Moved message to after join
@ -100,15 +100,15 @@
WorldData worlddata = worldserver1.getLevelData();
entityplayer.loadGameTypes(nbttagcompound);
@@ -207,6 +246,7 @@
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
@@ -197,6 +236,7 @@
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), entityplayer.gameMode.getGameModeForPlayer(), entityplayer.gameMode.getPreviousGameModeForPlayer(), this.server.levelKeys(), this.synchronizedRegistries, worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, worldserver1.isDebug(), worldserver1.isFlat(), entityplayer.getLastDeathLocation(), entityplayer.getPortalCooldown()));
playerconnection.send(new PacketPlayOutLogin(entityplayer.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), this.viewDistance, this.simulationDistance, flag1, !flag, flag2, entityplayer.createCommonSpawnInfo(worldserver1)));
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.send(new ClientboundUpdateEnabledFeaturesPacket(FeatureFlags.REGISTRY.toNames(worldserver1.enabledFeatures())));
playerconnection.send(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.BRAND, (new PacketDataSerializer(Unpooled.buffer())).writeUtf(this.getServer().getServerModName())));
playerconnection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
@@ -226,8 +266,10 @@
playerconnection.send(new PacketPlayOutAbilities(entityplayer.getAbilities()));
playerconnection.send(new PacketPlayOutHeldItemSlot(entityplayer.getInventory().selected));
@@ -213,8 +253,10 @@
} else {
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.player.joined.renamed", entityplayer.getDisplayName(), s);
}
@ -120,7 +120,7 @@
playerconnection.teleport(entityplayer.getX(), entityplayer.getY(), entityplayer.getZ(), entityplayer.getYRot(), entityplayer.getXRot());
ServerPing serverping = this.server.getStatus();
@@ -235,13 +277,64 @@
@@ -222,13 +264,64 @@
entityplayer.sendServerStatus(serverping);
}
@ -186,10 +186,10 @@
+
+ worldserver1 = entityplayer.serverLevel(); // CraftBukkit - Update in case join event changed it
+ // CraftBukkit end
this.server.getServerResourcePack().ifPresent((minecraftserver_serverresourcepackinfo) -> {
entityplayer.sendTexturePack(minecraftserver_serverresourcepackinfo.url(), minecraftserver_serverresourcepackinfo.hash(), minecraftserver_serverresourcepackinfo.isRequired(), minecraftserver_serverresourcepackinfo.prompt());
});
@@ -255,8 +348,11 @@
Iterator iterator = entityplayer.getActiveEffects().iterator();
while (iterator.hasNext()) {
@@ -239,8 +332,11 @@
if (nbttagcompound != null && nbttagcompound.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@ -203,7 +203,7 @@
});
if (entity != null) {
@@ -299,6 +395,8 @@
@@ -283,6 +379,8 @@
}
entityplayer.initInventoryMenu();
@ -212,7 +212,7 @@
}
public void updateEntireScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
@@ -331,30 +429,31 @@
@@ -319,30 +417,31 @@
}
public void addWorldborderListener(WorldServer worldserver) {
@ -249,7 +249,7 @@
}
@Override
@@ -382,14 +481,15 @@
@@ -370,14 +469,15 @@
}
protected void save(EntityPlayer entityplayer) {
@ -267,7 +267,7 @@
if (advancementdataplayer != null) {
advancementdataplayer.save();
@@ -397,10 +497,24 @@
@@ -385,10 +485,24 @@
}
@ -293,7 +293,7 @@
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -424,18 +538,66 @@
@@ -412,18 +526,66 @@
if (entityplayer1 == entityplayer) {
this.playersByUUID.remove(uuid);
@ -333,7 +333,7 @@
- if (this.bans.isBanned(gameprofile)) {
+ // Moved from processLogin
+ UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
+ UUID uuid = gameprofile.getId();
+ List<EntityPlayer> list = Lists.newArrayList();
+
+ EntityPlayer entityplayer;
@ -358,7 +358,7 @@
+ // depending on the outcome.
+ SocketAddress socketaddress = loginlistener.connection.getRemoteAddress();
+
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile);
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getLevel(World.OVERWORLD), gameprofile, ClientInformation.createDefault());
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
+
@ -366,7 +366,7 @@
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
@@ -443,10 +605,12 @@
@@ -431,10 +593,12 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
}
@ -382,7 +382,7 @@
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
@@ -454,13 +618,25 @@
@@ -442,17 +606,32 @@
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
}
@ -405,18 +405,27 @@
+ return entity;
}
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile) {
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
+ /* CraftBukkit startMoved up
UUID uuid = UUIDUtil.getOrCreatePlayerUUID(gameprofile);
List<EntityPlayer> list = Lists.newArrayList();
- public EntityPlayer getPlayerForLogin(GameProfile gameprofile, ClientInformation clientinformation) {
- return new EntityPlayer(this.server, this.server.overworld(), gameprofile, clientinformation);
+ // CraftBukkit start - added EntityPlayer
+ public EntityPlayer getPlayerForLogin(GameProfile gameprofile, ClientInformation clientinformation, EntityPlayer player) {
+ player.updateOptions(clientinformation);
+ return player;
+ // CraftBukkit end
}
@@ -487,14 +663,24 @@
- public boolean disconnectAllPlayersWithProfile(GameProfile gameprofile) {
+ public boolean disconnectAllPlayersWithProfile(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
+ /* CraftBukkit startMoved up
UUID uuid = gameprofile.getId();
Set<EntityPlayer> set = Sets.newIdentityHashSet();
Iterator iterator = this.players.iterator();
@@ -480,14 +659,24 @@
}
return new EntityPlayer(this.server, this.server.overworld(), gameprofile);
return !set.isEmpty();
+ */
+ return player;
+ return player == null;
+ // CraftBukkit end
+ }
+
@ -437,10 +446,10 @@
WorldServer worldserver = this.server.getLevel(entityplayer.getRespawnDimension());
Optional optional;
@@ -506,6 +692,11 @@
@@ -499,6 +688,11 @@
WorldServer worldserver1 = worldserver != null && optional.isPresent() ? worldserver : this.server.overworld();
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile());
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, entityplayer.getGameProfile(), entityplayer.clientInformation());
+ // */
+ EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
@ -449,7 +458,7 @@
entityplayer1.connection = entityplayer.connection;
entityplayer1.restoreFrom(entityplayer, flag);
@@ -521,50 +712,112 @@
@@ -514,28 +708,66 @@
boolean flag2 = false;
@ -521,27 +530,23 @@
+ location.setWorld(worldserver.getWorld());
}
+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle();
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.unsetRemoved();
+ entityplayer1.setShiftKeyDown(false);
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ // CraftBukkit end
- while (!worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
+ while (avoidSuffocation && !worldserver1.noCollision((Entity) entityplayer1) && entityplayer1.getY() < (double) worldserver1.getMaxBuildHeight()) {
+ // CraftBukkit end
entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ());
}
int i = flag ? 1 : 0;
- WorldData worlddata = entityplayer1.level().getLevelData();
+ // CraftBukkit start
+ WorldData worlddata = worldserver1.getLevelData();
+ entityplayer1.connection.send(new PacketPlayOutRespawn(worldserver1.dimensionTypeId(), worldserver1.dimension(), BiomeManager.obfuscateSeed(worldserver1.getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), worldserver1.isDebug(), worldserver1.isFlat(), (byte) i, entityplayer1.getLastDeathLocation(), entityplayer1.getPortalCooldown()));
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.unsetRemoved();
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver1.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot()));
+ entityplayer1.setShiftKeyDown(false);
@@ -544,21 +776,43 @@
WorldData worlddata = worldserver2.getLevelData();
- entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.level().dimensionTypeId(), entityplayer1.level().dimension(), BiomeManager.obfuscateSeed(entityplayer1.serverLevel().getSeed()), entityplayer1.gameMode.getGameModeForPlayer(), entityplayer1.gameMode.getPreviousGameModeForPlayer(), entityplayer1.level().isDebug(), entityplayer1.serverLevel().isFlat(), (byte) i, entityplayer1.getLastDeathLocation(), entityplayer1.getPortalCooldown()));
entityplayer1.connection.send(new PacketPlayOutRespawn(entityplayer1.createCommonSpawnInfo(worldserver2), (byte) i));
- entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
+ // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot());
+ entityplayer1.connection.teleport(CraftLocation.toBukkit(entityplayer1.position(), worldserver2.getWorld(), entityplayer1.getYRot(), entityplayer1.getXRot())); // CraftBukkit
entityplayer1.connection.send(new PacketPlayOutSpawnPosition(worldserver1.getSharedSpawnPos(), worldserver1.getSharedSpawnAngle()));
entityplayer1.connection.send(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
entityplayer1.connection.send(new PacketPlayOutExperience(entityplayer1.experienceProgress, entityplayer1.totalExperience, entityplayer1.experienceLevel));
@ -570,13 +575,13 @@
+
+ // Fire advancement trigger
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
+
+ // Don't fire on respawn
+ if (fromWorld != location.getWorld()) {
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
+ server.server.getPluginManager().callEvent(event);
+ }
+
+ // Save player file again if they were disconnected
+ if (entityplayer.connection.isDisconnected()) {
+ this.save(entityplayer);
@ -585,7 +590,7 @@
return entityplayer1;
}
@@ -577,7 +830,18 @@
@@ -571,7 +825,18 @@
public void tick() {
if (++this.sendAllPlayerInfoIn > 600) {
@ -605,7 +610,7 @@
this.sendAllPlayerInfoIn = 0;
}
@@ -594,6 +858,25 @@
@@ -588,6 +853,25 @@
}
@ -631,7 +636,7 @@
public void broadcastAll(Packet<?> packet, ResourceKey<World> resourcekey) {
Iterator iterator = this.players.iterator();
@@ -672,7 +955,7 @@
@@ -666,7 +950,7 @@
}
public void deop(GameProfile gameprofile) {
@ -640,7 +645,7 @@
EntityPlayer entityplayer = this.getPlayer(gameprofile.getId());
if (entityplayer != null) {
@@ -696,6 +979,7 @@
@@ -690,6 +974,7 @@
entityplayer.connection.send(new PacketPlayOutEntityStatus(entityplayer, b0));
}
@ -648,7 +653,7 @@
this.server.getCommands().sendCommands(entityplayer);
}
@@ -728,6 +1012,12 @@
@@ -722,6 +1007,12 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
@ -661,7 +666,7 @@
if (entityplayer != entityhuman && entityplayer.level().dimension() == resourcekey) {
double d4 = d0 - entityplayer.getX();
double d5 = d1 - entityplayer.getY();
@@ -767,23 +1057,35 @@
@@ -761,23 +1052,35 @@
public void reloadWhiteList() {}
public void sendLevelInfo(EntityPlayer entityplayer, WorldServer worldserver) {
@ -702,7 +707,7 @@
}
public int getPlayerCount() {
@@ -839,12 +1141,22 @@
@@ -833,12 +1136,22 @@
}
public void removeAll() {
@ -727,7 +732,7 @@
public void broadcastSystemMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.broadcastSystemMessage(ichatbasecomponent, (entityplayer) -> {
return ichatbasecomponent;
@@ -902,16 +1214,23 @@
@@ -896,16 +1209,23 @@
return playerchatmessage.hasSignature() && !playerchatmessage.hasExpiredServer(Instant.now());
}
@ -755,7 +760,7 @@
Path path = file2.toPath();
if (FileUtils.isPathNormalized(path) && FileUtils.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
@@ -920,7 +1239,7 @@
@@ -914,7 +1234,7 @@
}
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
@ -764,7 +769,7 @@
}
return serverstatisticmanager;
@@ -928,13 +1247,13 @@
@@ -922,13 +1242,13 @@
public AdvancementDataPlayer getPlayerAdvancements(EntityPlayer entityplayer) {
UUID uuid = entityplayer.getUUID();
@ -780,7 +785,7 @@
}
advancementdataplayer.setPlayer(entityplayer);
@@ -985,13 +1304,20 @@
@@ -979,13 +1299,20 @@
}
public void reloadResources() {
@ -800,5 +805,5 @@
}
+ // CraftBukkit end
this.broadcastAll(new PacketPlayOutTags(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getRecipeManager().getRecipes());

View File

@ -5,10 +5,10 @@
package net.minecraft.server.players;
import com.google.common.collect.ImmutableList;
@@ -93,7 +94,7 @@
@@ -81,7 +82,7 @@
}
public void onProfileLookupFailed(GameProfile gameprofile, Exception exception) {
public void onProfileLookupFailed(String s1, Exception exception) {
- atomicreference.set((Object) null);
+ atomicreference.set(null); // CraftBukkit - decompile error
}

View File

@ -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.IRecipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import org.slf4j.Logger;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
@ -10,11 +10,11 @@
public static final String RECIPE_BOOK_TAG = "recipeBook";
@@ -36,7 +38,7 @@
IRecipe<?> irecipe = (IRecipe) iterator.next();
MinecraftKey minecraftkey = irecipe.getId();
RecipeHolder<?> recipeholder = (RecipeHolder) iterator.next();
MinecraftKey minecraftkey = recipeholder.id();
- if (!this.known.contains(minecraftkey) && !irecipe.isSpecial()) {
+ if (!this.known.contains(minecraftkey) && !irecipe.isSpecial() && CraftEventFactory.handlePlayerRecipeListUpdateEvent(entityplayer, minecraftkey)) { // CraftBukkit
- 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);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/util/datafix/DataConverterRegistry.java
+++ b/net/minecraft/util/datafix/DataConverterRegistry.java
@@ -445,6 +445,18 @@
@@ -448,6 +448,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));
@@ -762,12 +774,14 @@
@@ -766,12 +778,14 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema129, "Added Glow Squid", DataConverterTypes.ENTITY));
datafixerbuilder.addFixer(new DataConverterAddChoices(schema129, "Added Glow Item Frame", DataConverterTypes.ENTITY));
Schema schema130 = datafixerbuilder.addSchema(2690, DataConverterRegistry.SAME_NAMESPACED);
@ -36,7 +36,7 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema131, "Rename copper item suffixes", createRenamer(immutablemap1)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema131, "Rename copper blocks suffixes", createRenamer(immutablemap1)));
@@ -775,7 +789,8 @@
@@ -779,7 +793,8 @@
datafixerbuilder.addFixer(new AddFlagIfNotPresentFix(schema132, DataConverterTypes.WORLD_GEN_SETTINGS, "has_increased_height_already", false));
Schema schema133 = datafixerbuilder.addSchema(2696, DataConverterRegistry.SAME_NAMESPACED);
@ -46,7 +46,7 @@
datafixerbuilder.addFixer(DataConverterItemName.create(schema133, "Renamed grimstone block items to deepslate", createRenamer(immutablemap2)));
datafixerbuilder.addFixer(BlockRenameFixWithJigsaw.create(schema133, "Renamed grimstone blocks to deepslate", createRenamer(immutablemap2)));
@@ -862,10 +877,11 @@
@@ -866,10 +881,11 @@
datafixerbuilder.addFixer(new DataConverterAddChoices(schema158, "Added Allay", DataConverterTypes.ENTITY));
Schema schema159 = datafixerbuilder.addSchema(3084, DataConverterRegistry.SAME_NAMESPACED);
@ -60,7 +60,7 @@
int2objectopenhashmap1.defaultReturnValue("minecraft:tabby");
int2objectopenhashmap1.put(0, "minecraft:tabby");
int2objectopenhashmap1.put(1, "minecraft:black");
@@ -882,7 +898,8 @@
@@ -886,7 +902,8 @@
Objects.requireNonNull(int2objectopenhashmap);
datafixerbuilder.addFixer(new EntityVariantFix(schema160, "Change cat variant type", typereference, "minecraft:cat", "CatType", int2objectopenhashmap::get));

View File

@ -5,7 +5,7 @@
import net.minecraft.world.level.block.entity.TileEntity;
+// CraftBukkit start
+import net.minecraft.world.item.crafting.IRecipe;
+import net.minecraft.world.item.crafting.RecipeHolder;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+// CraftBukkit end
+
@ -43,11 +43,11 @@
+
+ org.bukkit.Location getLocation();
+
+ default IRecipe getCurrentRecipe() {
+ default RecipeHolder<?> getCurrentRecipe() {
+ return null;
+ }
+
+ default void setCurrentRecipe(IRecipe recipe) {
+ default void setCurrentRecipe(RecipeHolder<?> recipe) {
+ }
+
+ int MAX_STACK = 64;

View File

@ -0,0 +1,20 @@
--- a/net/minecraft/world/effect/HealOrHarmMobEffect.java
+++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java
@@ -17,7 +17,7 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
super.applyEffectTick(entityliving, 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));
}
@@ -30,7 +30,7 @@
if (this.isHarm == entityliving.isInvertedHealAndHarm()) {
j = (int) (d0 * (double) (4 << i) + 0.5D);
- entityliving.heal((float) j);
+ entityliving.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
} else {
j = (int) (d0 * (double) (6 << i) + 0.5D);
if (entity == null) {

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/world/effect/HungerMobEffect.java
+++ b/net/minecraft/world/effect/HungerMobEffect.java
@@ -15,7 +15,7 @@
if (entityliving instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entityliving;
- entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1));
+ entityhuman.causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
}
}

View File

@ -1,67 +0,0 @@
--- a/net/minecraft/world/effect/MobEffectList.java
+++ b/net/minecraft/world/effect/MobEffectList.java
@@ -19,6 +19,14 @@
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.EntityHuman;
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth;
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
+// CraftBukkit end
+
public class MobEffectList {
private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap();
@@ -55,26 +63,35 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
- entityliving.heal(1.0F);
+ entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this == MobEffects.POISON) {
if (entityliving.getHealth() > 1.0F) {
- entityliving.hurt(entityliving.damageSources().magic(), 1.0F);
+ entityliving.hurt(entityliving.damageSources().poison, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
} else if (this == MobEffects.WITHER) {
entityliving.hurt(entityliving.damageSources().wither(), 1.0F);
} else if (this == MobEffects.HUNGER && entityliving instanceof EntityHuman) {
- ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1));
+ ((EntityHuman) entityliving).causeFoodExhaustion(0.005F * (float) (i + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
} else if (this == MobEffects.SATURATION && entityliving instanceof EntityHuman) {
if (!entityliving.level().isClientSide) {
- ((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
+ // CraftBukkit start
+ EntityHuman entityhuman = (EntityHuman) entityliving;
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
+ if (!event.isCancelled()) {
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
+ }
+
+ ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate();
+ // CraftBukkit end
}
} else if ((this != MobEffects.HEAL || entityliving.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entityliving.isInvertedHealAndHarm())) {
if (this == MobEffects.HARM && !entityliving.isInvertedHealAndHarm() || this == MobEffects.HEAL && entityliving.isInvertedHealAndHarm()) {
entityliving.hurt(entityliving.damageSources().magic(), (float) (6 << i));
}
} else {
- entityliving.heal((float) Math.max(4 << i, 0));
+ entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
}
}
@@ -95,7 +112,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);
- entityliving.heal((float) j);
+ entityliving.heal((float) j, RegainReason.MAGIC); // CraftBukkit
}
}

View File

@ -1,12 +1,12 @@
--- a/net/minecraft/world/effect/MobEffects.java
+++ b/net/minecraft/world/effect/MobEffects.java
@@ -73,6 +73,10 @@
@@ -47,6 +47,10 @@
public MobEffects() {}
private static MobEffectList register(int i, String s, MobEffectList mobeffectlist) {
- return (MobEffectList) IRegistry.registerMapping(BuiltInRegistries.MOB_EFFECT, i, s, mobeffectlist);
private static MobEffectList register(String s, MobEffectList mobeffectlist) {
- return (MobEffectList) IRegistry.register(BuiltInRegistries.MOB_EFFECT, s, mobeffectlist);
+ // CraftBukkit start
+ mobeffectlist = (MobEffectList) IRegistry.registerMapping(BuiltInRegistries.MOB_EFFECT, i, s, mobeffectlist);
+ mobeffectlist = (MobEffectList) IRegistry.register(BuiltInRegistries.MOB_EFFECT, s, mobeffectlist);
+ org.bukkit.potion.PotionEffectType.registerPotionEffectType(new org.bukkit.craftbukkit.potion.CraftPotionEffectType(mobeffectlist));
+ return mobeffectlist;
+ // CraftBukkit end

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/world/effect/PoisonMobEffect.java
+++ b/net/minecraft/world/effect/PoisonMobEffect.java
@@ -12,7 +12,7 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
super.applyEffectTick(entityliving, 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
}
}

View File

@ -0,0 +1,11 @@
--- a/net/minecraft/world/effect/RegenerationMobEffect.java
+++ b/net/minecraft/world/effect/RegenerationMobEffect.java
@@ -12,7 +12,7 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
super.applyEffectTick(entityliving, i);
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
- entityliving.heal(1.0F);
+ entityliving.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit
}
}

View File

@ -0,0 +1,31 @@
--- a/net/minecraft/world/effect/SaturationMobEffect.java
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
@@ -3,6 +3,11 @@
import net.minecraft.world.entity.EntityLiving;
import net.minecraft.world.entity.player.EntityHuman;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
class SaturationMobEffect extends InstantMobEffect {
protected SaturationMobEffect(MobEffectInfo mobeffectinfo, int i) {
@@ -15,7 +20,15 @@
if (!entityliving.level().isClientSide && entityliving instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entityliving;
- entityhuman.getFoodData().eat(i + 1, 1.0F);
+ // CraftBukkit start
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
+ if (!event.isCancelled()) {
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
+ }
+
+ ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate();
+ // CraftBukkit end
}
}

View File

@ -1,90 +0,0 @@
--- a/net/minecraft/world/entity/Display.java
+++ b/net/minecraft/world/entity/Display.java
@@ -183,11 +183,11 @@
@Override
protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
- DataResult dataresult;
+ // DataResult dataresult; // CraftBukkit - decompile error
Logger logger;
if (nbttagcompound.contains("transformation")) {
- dataresult = Transformation.EXTENDED_CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("transformation"));
+ DataResult<Pair<Transformation, net.minecraft.nbt.NBTBase>> dataresult = Transformation.EXTENDED_CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("transformation")); // CraftBukkit - decompile error
logger = Display.LOGGER;
Objects.requireNonNull(logger);
dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> {
@@ -208,7 +208,7 @@
}
if (nbttagcompound.contains("billboard", 8)) {
- dataresult = Display.BillboardConstraints.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("billboard"));
+ DataResult<Pair<Display.BillboardConstraints, net.minecraft.nbt.NBTBase>> dataresult = Display.BillboardConstraints.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("billboard")); // CraftBukkit - decompile error
logger = Display.LOGGER;
Objects.requireNonNull(logger);
dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> {
@@ -241,7 +241,7 @@
}
if (nbttagcompound.contains("brightness", 10)) {
- dataresult = Brightness.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("brightness"));
+ DataResult<Pair<Brightness, net.minecraft.nbt.NBTBase>> dataresult = Brightness.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("brightness")); // CraftBukkit - decompile error
logger = Display.LOGGER;
Objects.requireNonNull(logger);
dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> {
@@ -594,8 +594,8 @@
private static final byte INITIAL_TEXT_OPACITY = -1;
public static final int INITIAL_BACKGROUND = 1073741824;
private static final DataWatcherObject<IChatBaseComponent> DATA_TEXT_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.COMPONENT);
- private static final DataWatcherObject<Integer> DATA_LINE_WIDTH_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT);
- private static final DataWatcherObject<Integer> DATA_BACKGROUND_COLOR_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT);
+ public static final DataWatcherObject<Integer> DATA_LINE_WIDTH_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT);
+ public static final DataWatcherObject<Integer> DATA_BACKGROUND_COLOR_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT);
private static final DataWatcherObject<Byte> DATA_TEXT_OPACITY_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.BYTE);
private static final DataWatcherObject<Byte> DATA_STYLE_FLAGS_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.BYTE);
private static final IntSet TEXT_RENDER_STATE_IDS = IntSet.of(new int[]{Display.TextDisplay.DATA_TEXT_ID.getId(), Display.TextDisplay.DATA_LINE_WIDTH_ID.getId(), Display.TextDisplay.DATA_BACKGROUND_COLOR_ID.getId(), Display.TextDisplay.DATA_TEXT_OPACITY_ID.getId(), Display.TextDisplay.DATA_STYLE_FLAGS_ID.getId()});
@@ -614,7 +614,7 @@
this.entityData.define(Display.TextDisplay.DATA_TEXT_ID, IChatBaseComponent.empty());
this.entityData.define(Display.TextDisplay.DATA_LINE_WIDTH_ID, 200);
this.entityData.define(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, 1073741824);
- this.entityData.define(Display.TextDisplay.DATA_TEXT_OPACITY_ID, -1);
+ this.entityData.define(Display.TextDisplay.DATA_TEXT_OPACITY_ID, (byte) -1); // CraftBukkit - decompile error
this.entityData.define(Display.TextDisplay.DATA_STYLE_FLAGS_ID, (byte) 0);
}
@@ -639,7 +639,7 @@
return (Integer) this.entityData.get(Display.TextDisplay.DATA_LINE_WIDTH_ID);
}
- public void setLineWidth(int i) {
+ private void setLineWidth(int i) {
this.entityData.set(Display.TextDisplay.DATA_LINE_WIDTH_ID, i);
}
@@ -655,7 +655,7 @@
return (Integer) this.entityData.get(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID);
}
- public void setBackgroundColor(int i) {
+ private void setBackgroundColor(int i) {
this.entityData.set(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, i);
}
@@ -690,7 +690,7 @@
b0 = loadFlag(b0, nbttagcompound, "see_through", (byte) 2);
b0 = loadFlag(b0, nbttagcompound, "default_background", (byte) 4);
- DataResult dataresult = Display.TextDisplay.Align.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("alignment"));
+ DataResult<Pair<Display.TextDisplay.Align, net.minecraft.nbt.NBTBase>> dataresult = Display.TextDisplay.Align.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("alignment")); // CraftBukkit - decompile error
Logger logger = Display.LOGGER;
Objects.requireNonNull(logger);
@@ -961,7 +961,7 @@
super.readAdditionalSaveData(nbttagcompound);
this.setItemStack(ItemStack.of(nbttagcompound.getCompound("item")));
if (nbttagcompound.contains("item_display", 8)) {
- DataResult dataresult = ItemDisplayContext.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("item_display"));
+ DataResult<Pair<ItemDisplayContext, net.minecraft.nbt.NBTBase>> dataresult = ItemDisplayContext.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("item_display")); // CraftBukkit - decompile error
Logger logger = Display.LOGGER;
Objects.requireNonNull(logger);

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -124,8 +124,66 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
@@ -125,8 +125,65 @@
import org.joml.Vector3f;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.core.Position;
+import net.minecraft.world.level.dimension.WorldDimension;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
@ -67,7 +66,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -240,6 +298,25 @@
@@ -241,6 +298,25 @@
public boolean hasVisualFire;
@Nullable
private IBlockData feetBlockState;
@ -93,7 +92,7 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -373,6 +450,12 @@
@@ -374,6 +450,12 @@
public void onClientRemoval() {}
public void setPose(EntityPose entitypose) {
@ -106,7 +105,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -397,6 +480,33 @@
@@ -398,6 +480,33 @@
}
protected void setRot(float f, float f1) {
@ -140,7 +139,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -438,6 +548,15 @@
@@ -439,6 +548,15 @@
this.baseTick();
}
@ -156,7 +155,7 @@
public void baseTick() {
this.level().getProfiler().push("entityBaseTick");
this.feetBlockState = null;
@@ -452,7 +571,7 @@
@@ -453,7 +571,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@ -165,7 +164,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -487,6 +606,10 @@
@@ -488,6 +606,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@ -176,7 +175,7 @@
}
this.checkBelowWorld();
@@ -538,15 +661,48 @@
@@ -539,15 +661,48 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@ -226,7 +225,7 @@
int j = i * 20;
if (this instanceof EntityLiving) {
@@ -697,6 +853,28 @@
@@ -698,6 +853,28 @@
block.updateEntityAfterFallOn(this.level(), this);
}
@ -255,7 +254,7 @@
if (this.onGround()) {
block.stepOn(this.level(), blockposition, iblockdata, this);
}
@@ -1024,6 +1202,20 @@
@@ -1025,6 +1202,20 @@
return SoundEffects.GENERIC_SPLASH;
}
@ -276,7 +275,7 @@
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);
@@ -1430,6 +1622,7 @@
@@ -1439,6 +1630,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@ -284,7 +283,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1624,6 +1817,12 @@
@@ -1633,6 +1825,12 @@
return false;
}
@ -297,7 +296,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1657,7 +1856,7 @@
@@ -1666,7 +1864,7 @@
} else {
String s = this.getEncodeId();
@ -306,7 +305,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1682,6 +1881,18 @@
@@ -1691,6 +1889,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@ -325,7 +324,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1690,6 +1901,25 @@
@@ -1699,6 +1909,25 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@ -351,7 +350,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1757,6 +1987,11 @@
@@ -1766,6 +1995,11 @@
}
}
@ -363,7 +362,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1840,6 +2075,45 @@
@@ -1849,6 +2083,45 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@ -409,7 +408,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1915,9 +2189,22 @@
@@ -1924,9 +2197,22 @@
} else if (this.level().isClientSide) {
return null;
} else {
@ -432,7 +431,7 @@
this.level().addFreshEntity(entityitem);
return entityitem;
}
@@ -2007,6 +2294,18 @@
@@ -2024,6 +2310,18 @@
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@ -451,7 +450,7 @@
if (this.isPassenger()) {
this.stopRiding();
}
@@ -2044,7 +2343,7 @@
@@ -2057,7 +2355,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -460,7 +459,7 @@
}
}
@@ -2075,10 +2374,29 @@
@@ -2088,10 +2386,29 @@
}
}
@ -491,7 +490,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -2090,6 +2408,7 @@
@@ -2103,6 +2420,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@ -499,7 +498,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2156,14 +2475,20 @@
@@ -2189,14 +2507,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@ -523,7 +522,7 @@
this.level().getProfiler().pop();
}
@@ -2283,6 +2608,13 @@
@@ -2320,6 +2644,13 @@
}
public void setSwimming(boolean flag) {
@ -537,7 +536,7 @@
this.setSharedFlag(4, flag);
}
@@ -2332,8 +2664,12 @@
@@ -2369,8 +2700,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@ -551,7 +550,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2352,7 +2688,7 @@
@@ -2389,7 +2724,7 @@
}
public int getMaxAirSupply() {
@ -560,7 +559,7 @@
}
public int getAirSupply() {
@@ -2360,7 +2696,18 @@
@@ -2397,7 +2732,18 @@
}
public void setAirSupply(int i) {
@ -580,7 +579,7 @@
}
public int getTicksFrozen() {
@@ -2387,11 +2734,41 @@
@@ -2424,11 +2770,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -624,7 +623,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2556,15 +2933,38 @@
@@ -2593,15 +2969,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@ -633,7 +632,7 @@
+ }
+
+ @Nullable
+ public Entity teleportTo(WorldServer worldserver, Position location) {
+ public Entity teleportTo(WorldServer worldserver, Vec3D location) {
+ // CraftBukkit end
if (this.level() instanceof WorldServer && !this.isRemoved()) {
this.level().getProfiler().push("changeDimension");
@ -665,7 +664,7 @@
this.level().getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2573,9 +2973,17 @@
@@ -2610,9 +3009,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@ -685,7 +684,7 @@
}
this.removeAfterChangingDimensions();
@@ -2596,20 +3004,34 @@
@@ -2633,20 +3040,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -711,7 +710,7 @@
double d0 = DimensionManager.getTeleportationScale(this.level().dimensionType(), worldserver.dimensionType());
BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
+ // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
+ if (event == null) {
+ return null;
+ }
@ -725,7 +724,7 @@
IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2626,8 +3048,8 @@
@@ -2663,8 +3084,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@ -736,12 +735,12 @@
}
} else {
BlockPosition blockposition1;
@@ -2637,8 +3059,14 @@
@@ -2674,8 +3095,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
+ // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Vec3D(blockposition1.getX() + 0.5D, blockposition1.getY(), blockposition1.getZ() + 0.5D), PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
+ if (event == null) {
+ return null;
+ }
@ -752,14 +751,14 @@
}
}
@@ -2646,8 +3074,23 @@
@@ -2683,8 +3110,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
- protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) {
- return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder);
+ // CraftBukkit start
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Position exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, Vec3D exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
+ Location enter = bukkitEntity.getLocation();
+ Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld());
@ -778,7 +777,7 @@
}
public boolean canChangeDimensions() {
@@ -2767,6 +3210,12 @@
@@ -2804,6 +3246,12 @@
}
}
@ -791,7 +790,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2901,7 +3350,26 @@
@@ -2929,7 +3377,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -819,7 +818,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3212,6 +3680,11 @@
@@ -3240,6 +3707,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View File

@ -13,25 +13,7 @@
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -44,7 +50,7 @@
private static final float DEFAULT_RADIUS = 3.0F;
public static final float DEFAULT_WIDTH = 6.0F;
public static final float HEIGHT = 0.5F;
- private PotionRegistry potion;
+ public PotionRegistry potion; // CraftBukkit - private -> public
public List<MobEffect> effects;
private final Map<Entity, Integer> victims;
private int duration;
@@ -112,7 +118,7 @@
}
- private void updateColor() {
+ public void updateColor() { // Craftbukkit - private -> public
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
this.getEntityData().set(EntityAreaEffectCloud.DATA_COLOR, 0);
} else {
@@ -263,6 +269,7 @@
@@ -264,6 +270,7 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
@ -39,7 +21,7 @@
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
@@ -272,6 +279,17 @@
@@ -273,6 +280,17 @@
double d8 = d6 * d6 + d7 * d7;
if (d8 <= (double) (f * f)) {
@ -57,7 +39,7 @@
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -281,7 +299,7 @@
@@ -282,7 +300,7 @@
if (mobeffect1.getEffect().isInstantenous()) {
mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityCreature.java
+++ b/net/minecraft/world/entity/EntityCreature.java
@@ -7,6 +7,10 @@
@@ -9,6 +9,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
@ -11,7 +11,7 @@
public abstract class EntityCreature extends EntityInsentient {
protected static final float DEFAULT_WALK_TARGET_VALUE = 0.0F;
@@ -43,6 +47,7 @@
@@ -51,6 +55,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isInSittingPose()) {
if (f > 10.0F) {
@ -19,7 +19,7 @@
this.dropLeash(true, true);
}
@@ -51,6 +56,7 @@
@@ -59,6 +64,7 @@
this.onLeashDistance(f);
if (f > 10.0F) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -74,6 +74,19 @@
import net.minecraft.world.level.material.FluidType;
@@ -75,6 +75,19 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
@ -20,7 +20,7 @@
public abstract class EntityInsentient extends EntityLiving implements Targeting {
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -120,6 +133,8 @@
@@ -122,6 +135,8 @@
private BlockPosition restrictCenter;
private float restrictRadius;
@ -29,7 +29,7 @@
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -145,6 +160,12 @@
@@ -147,6 +162,12 @@
}
@ -42,7 +42,7 @@
protected void registerGoals() {}
public static AttributeProvider.Builder createMobAttributes() {
@@ -257,7 +278,38 @@
@@ -258,7 +279,38 @@
}
public void setTarget(@Nullable EntityLiving entityliving) {
@ -81,7 +81,7 @@
}
@Override
@@ -397,6 +449,12 @@
@@ -398,6 +450,12 @@
return null;
}
@ -94,7 +94,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -486,16 +544,26 @@
@@ -487,16 +545,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@ -123,7 +123,7 @@
NBTTagList nbttaglist;
int i;
@@ -542,6 +610,11 @@
@@ -543,6 +611,11 @@
}
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
@ -135,7 +135,7 @@
}
@Override
@@ -609,7 +682,7 @@
@@ -610,7 +683,7 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@ -144,7 +144,7 @@
if (!itemstack1.isEmpty()) {
this.onItemPickup(entityitem);
@@ -623,6 +696,12 @@
@@ -624,6 +697,12 @@
}
public ItemStack equipItemIfPossible(ItemStack itemstack) {
@ -157,7 +157,7 @@
EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
@@ -633,11 +712,19 @@
@@ -634,11 +713,19 @@
flag = itemstack1.isEmpty();
}
@ -178,7 +178,7 @@
}
if (enumitemslot.isArmor() && itemstack.getCount() > 1) {
@@ -782,6 +869,7 @@
@@ -790,6 +877,7 @@
@Override
protected final void serverAiStep() {
++this.noActionTime;
@ -186,7 +186,7 @@
this.level().getProfiler().push("sensing");
this.sensing.tick();
this.level().getProfiler().pop();
@@ -1175,6 +1263,12 @@
@@ -1183,6 +1271,12 @@
if (!this.isAlive()) {
return EnumInteractionResult.PASS;
} else if (this.getLeashHolder() == entityhuman) {
@ -199,7 +199,7 @@
this.dropLeash(true, !entityhuman.getAbilities().instabuild);
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
@@ -1200,6 +1294,12 @@
@@ -1208,6 +1302,12 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
@ -212,7 +212,7 @@
this.setLeashedTo(entityhuman, true);
itemstack.shrink(1);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
@@ -1215,7 +1315,7 @@
@@ -1223,7 +1323,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level() instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
@ -221,7 +221,7 @@
optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1265,12 +1365,19 @@
@@ -1273,12 +1373,19 @@
return this.restrictRadius != -1.0F;
}
@ -242,7 +242,7 @@
if (t0 == null) {
return null;
@@ -1304,7 +1411,12 @@
@@ -1312,7 +1419,12 @@
}
}
@ -256,7 +256,7 @@
if (this.isPassenger()) {
Entity entity = this.getVehicle();
@@ -1325,6 +1437,7 @@
@@ -1333,6 +1445,7 @@
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
@ -264,7 +264,7 @@
this.dropLeash(true, true);
}
@@ -1336,7 +1449,9 @@
@@ -1344,7 +1457,9 @@
this.leashHolder = null;
this.leashInfoTag = null;
if (!this.level().isClientSide && flag1) {
@ -274,7 +274,7 @@
}
if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) {
@@ -1386,6 +1501,7 @@
@@ -1394,6 +1509,7 @@
boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) {
@ -282,7 +282,7 @@
this.dropLeash(true, true);
}
@@ -1410,7 +1526,9 @@
@@ -1418,7 +1534,9 @@
}
if (this.tickCount > 100) {
@ -292,7 +292,7 @@
this.leashInfoTag = null;
}
}
@@ -1486,7 +1604,14 @@
@@ -1500,7 +1618,14 @@
int i = EnchantmentManager.getFireAspect(this);
if (i > 0) {
@ -308,7 +308,7 @@
}
boolean flag = entity.hurt(this.damageSources().mobAttack(this), f);
@@ -1560,6 +1685,7 @@
@@ -1574,6 +1699,7 @@
@Override
protected void removeAfterChangingDimensions() {
super.removeAfterChangingDimensions();

View File

@ -93,9 +93,9 @@
if (!flag && !ItemStack.isSameItemSameTags(itemstack, itemstack1) && !this.firstTick) {
Equipable equipable = Equipable.get(itemstack1);
if (equipable != null && !this.isSpectator() && equipable.getEquipmentSlot() == enumitemslot) {
- if (!this.level().isClientSide() && !this.isSilent()) {
+ if (!this.level().isClientSide() && !this.isSilent() && !silent) { // CraftBukkit
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().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F);
}
@ -211,7 +211,7 @@
iterator.remove();
}
@@ -976,18 +1092,48 @@
@@ -976,19 +1092,49 @@
return this.addEffect(mobeffect, (Entity) null);
}
@ -235,6 +235,7 @@
return false;
} else {
MobEffect mobeffect1 = (MobEffect) this.activeEffects.get(mobeffect.getEffect());
boolean flag = false;
+ // CraftBukkit start
+ boolean override = false;
@ -251,17 +252,17 @@
if (mobeffect1 == null) {
this.activeEffects.put(mobeffect.getEffect(), mobeffect);
this.onEffectAdded(mobeffect, entity);
return true;
flag = true;
- } else if (mobeffect1.update(mobeffect)) {
+ // CraftBukkit start
+ } else if (event.isOverride()) {
+ mobeffect1.update(mobeffect);
this.onEffectUpdated(mobeffect1, true, entity);
+ // CraftBukkit end
return true;
} else {
return false;
@@ -1024,13 +1170,39 @@
flag = true;
}
@@ -1026,13 +1172,39 @@
return this.getMobType() == EnumMonsterType.UNDEAD;
}
@ -302,7 +303,7 @@
if (mobeffect != null) {
this.onEffectRemoved(mobeffect);
@@ -1098,20 +1270,55 @@
@@ -1130,20 +1302,55 @@
}
@ -359,7 +360,7 @@
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
}
@@ -1125,7 +1332,7 @@
@@ -1157,7 +1364,7 @@
return false;
} else if (this.level().isClientSide) {
return false;
@ -368,7 +369,7 @@
return false;
} else if (damagesource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
@@ -1136,10 +1343,11 @@
@@ -1168,10 +1375,11 @@
this.noActionTime = 0;
float f1 = f;
@ -382,7 +383,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1163,23 +1371,33 @@
@@ -1195,23 +1403,33 @@
this.walkAnimation.setSpeed(1.5F);
boolean flag1 = true;
@ -421,7 +422,7 @@
this.hurtHelmet(damagesource, f);
f *= 0.75F;
}
@@ -1297,19 +1515,32 @@
@@ -1329,19 +1547,32 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@ -458,7 +459,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1317,14 +1548,16 @@
@@ -1350,14 +1581,16 @@
}
this.setHealth(1.0F);
@ -480,7 +481,7 @@
}
}
@@ -1433,14 +1666,22 @@
@@ -1466,14 +1699,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@ -505,7 +506,7 @@
this.level().addFreshEntity(entityitem);
}
}
@@ -1460,21 +1701,40 @@
@@ -1493,21 +1734,40 @@
boolean flag = this.lastHurtByPlayerTime > 0;
@ -549,7 +550,7 @@
}
@@ -1565,6 +1825,28 @@
@@ -1599,6 +1859,28 @@
return itemstack.getEatingSound();
}
@ -578,7 +579,7 @@
public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1611,9 +1893,14 @@
@@ -1645,9 +1927,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
@ -594,7 +595,7 @@
return true;
} else {
return flag;
@@ -1665,7 +1952,7 @@
@@ -1699,7 +1986,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@ -603,7 +604,7 @@
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1678,7 +1965,8 @@
@@ -1712,7 +1999,8 @@
} else {
int i;
@ -613,7 +614,7 @@
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1711,16 +1999,125 @@
@@ -1745,16 +2033,125 @@
}
}
@ -747,7 +748,7 @@
if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity();
@@ -1731,13 +2128,47 @@
@@ -1765,13 +2162,47 @@
}
}
@ -797,7 +798,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1758,8 +2189,18 @@
@@ -1796,8 +2227,18 @@
}
public final void setArrowCount(int i) {
@ -817,7 +818,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
@@ -2001,6 +2442,12 @@
@@ -2039,6 +2480,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@ -830,7 +831,7 @@
@Override
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -2238,6 +2685,7 @@
@@ -2273,6 +2720,7 @@
}
if (this.onGround() && !this.level().isClientSide) {
@ -838,7 +839,7 @@
this.setSharedFlag(7, false);
}
} else {
@@ -2809,6 +3257,7 @@
@@ -2837,6 +3285,7 @@
}
if (!this.level().isClientSide) {
@ -846,7 +847,7 @@
this.setSharedFlag(7, flag);
}
@@ -2968,14 +3417,21 @@
@@ -3027,14 +3476,21 @@
@Override
public boolean isPickable() {
@ -870,7 +871,7 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3170,7 +3626,26 @@
@@ -3229,7 +3685,26 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
@ -898,7 +899,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3248,6 +3723,12 @@
@@ -3307,6 +3782,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@ -911,7 +912,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3272,16 +3753,41 @@
@@ -3331,16 +3812,41 @@
}
if (flag2) {
@ -956,7 +957,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3291,7 +3797,7 @@
@@ -3350,7 +3856,7 @@
((EntityCreature) this).getNavigation().stop();
}
@ -965,7 +966,7 @@
}
}
@@ -3374,7 +3880,7 @@
@@ -3439,7 +3945,7 @@
}
public void stopSleeping() {
@ -974,7 +975,7 @@
World world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3408,7 +3914,7 @@
@@ -3473,7 +3979,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@ -983,7 +984,7 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3456,7 +3962,7 @@
@@ -3521,7 +4027,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityTypes.java
+++ b/net/minecraft/world/entity/EntityTypes.java
@@ -157,6 +157,7 @@
@@ -158,6 +158,7 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@ -8,7 +8,7 @@
import org.slf4j.Logger;
public class EntityTypes<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> {
@@ -167,7 +168,7 @@
@@ -168,7 +169,7 @@
private static final float MAGIC_HORSE_WIDTH = 1.3964844F;
private static final int DISPLAY_TRACKING_RANGE = 10;
public static final EntityTypes<Allay> ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).clientTrackingRange(8).updateInterval(2));
@ -17,7 +17,7 @@
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).clientTrackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).clientTrackingRange(4).updateInterval(20));
public static final EntityTypes<Axolotl> AXOLOTL = register("axolotl", EntityTypes.Builder.of(Axolotl::new, EnumCreatureType.AXOLOTLS).sized(0.75F, 0.42F).clientTrackingRange(10));
@@ -308,8 +309,8 @@
@@ -309,8 +310,8 @@
private final EntitySize dimensions;
private final FeatureFlagSet requiredFeatures;
@ -28,7 +28,7 @@
}
public static MinecraftKey getKey(EntityTypes<?> entitytypes) {
@@ -337,8 +338,15 @@
@@ -338,8 +339,15 @@
@Nullable
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
@ -45,7 +45,7 @@
if (itemstack != null) {
nbttagcompound = itemstack.getTag();
@@ -349,7 +357,7 @@
@@ -350,7 +358,7 @@
nbttagcompound = null;
}
@ -54,7 +54,7 @@
}
public static <T extends Entity> Consumer<T> createDefaultStackConfig(WorldServer worldserver, ItemStack itemstack, @Nullable EntityHuman entityhuman) {
@@ -371,21 +379,37 @@
@@ -372,21 +380,37 @@
NBTTagCompound nbttagcompound = itemstack.getTag();
return nbttagcompound != null ? consumer.andThen((entity) -> {
@ -95,7 +95,7 @@
}
return t0;
@@ -572,7 +596,7 @@
@@ -573,7 +597,7 @@
}
return entity;
@ -104,7 +104,7 @@
}
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) {
@@ -629,7 +653,7 @@
@@ -634,7 +658,7 @@
@Nullable
public T tryCast(Entity entity) {
@ -113,7 +113,7 @@
}
@Override
@@ -664,7 +688,7 @@
@@ -669,7 +693,7 @@
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
}

View File

@ -12,12 +12,12 @@
public class PathfinderGoalTame extends PathfinderGoal {
private final EntityHorseAbstract horse;
@@ -62,7 +67,7 @@
@@ -63,7 +68,7 @@
int i = this.horse.getTemper();
int j = this.horse.getMaxTemper();
- if (j > 0 && this.horse.getRandom().nextInt(j) < i) {
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent
this.horse.tameWithName((EntityHuman) entity);
this.horse.tameWithName(entityhuman);
return;
}

View File

@ -35,7 +35,7 @@
}
}
@@ -175,10 +187,17 @@
@@ -170,10 +182,17 @@
}
public void setInLove(@Nullable EntityHuman entityhuman) {
@ -54,7 +54,7 @@
this.level().broadcastEntityEvent(this, (byte) 18);
}
@@ -220,12 +239,29 @@
@@ -215,12 +234,29 @@
if (entityageable != null) {
entityageable.setBaby(true);
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
@ -86,7 +86,7 @@
Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(entityanimal.getLoveCause());
}).ifPresent((entityplayer) -> {
@@ -238,7 +274,11 @@
@@ -233,7 +269,11 @@
entityanimal.resetLove();
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {

View File

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

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityChicken.java
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -96,7 +96,9 @@
@@ -97,7 +97,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);

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntityCow.java
+++ b/net/minecraft/world/entity/animal/EntityCow.java
@@ -31,6 +31,12 @@
import net.minecraft.world.level.World;
@@ -33,6 +33,12 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -13,7 +13,7 @@
public class EntityCow extends EntityAnimal {
public EntityCow(EntityTypes<? extends EntityCow> entitytypes, World world) {
@@ -83,8 +89,16 @@
@@ -85,8 +91,16 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityFox.java
+++ b/net/minecraft/world/entity/animal/EntityFox.java
@@ -517,7 +517,8 @@
@@ -523,7 +523,8 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@ -10,7 +10,7 @@
int i = itemstack.getCount();
if (i > 1) {
@@ -872,6 +873,16 @@
@@ -883,6 +884,16 @@
if (entityplayer1 != null && entityplayer != entityplayer1) {
entityfox.addTrustedUUID(entityplayer1.getUUID());
}
@ -27,7 +27,7 @@
if (entityplayer2 != null) {
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
@@ -882,12 +893,14 @@
@@ -893,12 +904,14 @@
this.partner.setAge(6000);
this.animal.resetLove();
this.partner.resetLove();
@ -46,7 +46,7 @@
}
}
@@ -1285,6 +1298,11 @@
@@ -1294,6 +1307,11 @@
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
@ -58,7 +58,7 @@
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
@@ -1441,7 +1459,7 @@
@@ -1451,7 +1469,7 @@
private EntityLiving trustedLastHurt;
private int timestamp;

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
@@ -42,6 +42,13 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
import org.apache.commons.lang3.tuple.Pair;
+// CraftBukkit start
+import org.bukkit.Bukkit;
@ -14,7 +14,7 @@
public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder<EntityMushroomCow.Type> {
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
@@ -115,6 +122,11 @@
@@ -114,6 +121,11 @@
this.playSound(soundeffect, 1.0F, 1.0F);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
} else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
@ -26,7 +26,7 @@
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level().isClientSide) {
@@ -165,7 +177,7 @@
@@ -161,7 +173,7 @@
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);
@ -35,7 +35,7 @@
entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
entitycow.setHealth(this.getHealth());
entitycow.yBodyRot = this.yBodyRot;
@@ -179,10 +191,25 @@
@@ -175,10 +187,25 @@
}
entitycow.setInvulnerable(this.isInvulnerable());

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
@@ -177,7 +177,7 @@
@@ -179,7 +179,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);
@@ -308,10 +308,10 @@
@@ -315,10 +315,10 @@
private final EntityOcelot ocelot;
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntityPanda.java
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
@@ -65,6 +65,11 @@
import net.minecraft.world.level.gameevent.GameEvent;
@@ -67,6 +67,11 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -12,7 +12,7 @@
public class EntityPanda extends EntityAnimal {
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT);
@@ -532,7 +537,7 @@
@@ -534,7 +539,7 @@
@Override
protected void pickUpItem(EntityItem entityitem) {
@ -21,7 +21,7 @@
this.onItemPickup(entityitem);
ItemStack itemstack = entityitem.getItem();
@@ -863,10 +868,10 @@
@@ -870,10 +875,10 @@
private final EntityPanda panda;
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
@ -35,7 +35,7 @@
this.panda = entitypanda;
}
@@ -1105,7 +1110,7 @@
@@ -1112,7 +1117,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityParrot.java
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
@@ -261,7 +261,7 @@
@@ -262,7 +262,7 @@
}
if (!this.level().isClientSide) {
@ -9,7 +9,7 @@
this.tame(entityhuman);
this.level().broadcastEntityEvent(this, (byte) 7);
} else {
@@ -275,7 +275,7 @@
@@ -276,7 +276,7 @@
itemstack.shrink(1);
}
@ -18,7 +18,7 @@
if (entityhuman.isCreative() || !this.isInvulnerable()) {
this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE);
}
@@ -382,7 +382,7 @@
@@ -383,7 +383,7 @@
@Override
public boolean isPushable() {
@ -27,7 +27,7 @@
}
@Override
@@ -397,11 +397,14 @@
@@ -398,11 +398,14 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntityPig.java
+++ b/net/minecraft/world/entity/animal/EntityPig.java
@@ -49,6 +49,10 @@
import net.minecraft.world.phys.AxisAlignedBB;
@@ -51,6 +51,10 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,7 +11,7 @@
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN);
@@ -250,7 +254,13 @@
@@ -252,7 +256,13 @@
}
entitypigzombie.setPersistenceRequired();

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
@@ -66,6 +66,10 @@
@@ -67,6 +67,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;
@@ -88,7 +92,6 @@
@@ -89,7 +93,6 @@
super(entitytypes, world);
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
@ -19,7 +19,7 @@
}
@Override
@@ -576,9 +579,19 @@
@@ -577,9 +580,19 @@
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
if (i == 0) {
@ -37,5 +37,5 @@
+ }
+ // CraftBukkit end
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCarrots.AGE, i - 1), 2);
world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of((Entity) this.rabbit));
world.levelEvent(2001, blockposition, Block.getId(iblockdata));
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
@@ -64,6 +64,14 @@
import net.minecraft.world.level.gameevent.GameEvent;
@@ -66,6 +66,14 @@
import net.minecraft.world.level.storage.loot.LootTables;
import org.joml.Vector3f;
+// CraftBukkit start
+import net.minecraft.world.inventory.InventoryCraftResult;
@ -15,7 +15,7 @@
public class EntitySheep extends EntityAnimal implements IShearable {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -244,6 +252,11 @@
@@ -246,6 +254,11 @@
if (itemstack.is(Items.SHEARS)) {
if (!this.level().isClientSide && this.readyForShearing()) {
@ -27,7 +27,7 @@
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
@@ -265,7 +278,9 @@
@@ -267,7 +280,9 @@
int i = 1 + this.random.nextInt(3);
for (int j = 0; j < i; ++j) {
@ -37,7 +37,7 @@
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)));
@@ -358,6 +373,12 @@
@@ -360,6 +375,12 @@
@Override
public void ate() {
@ -50,16 +50,16 @@
super.ate();
this.setSheared(false);
if (this.isBaby()) {
@@ -377,7 +398,7 @@
@@ -379,7 +400,7 @@
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1);
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipecrafting) -> {
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipecrafting) -> { // CraftBukkit - decompile error
return recipecrafting.assemble(inventorycrafting, this.level().registryAccess());
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> {
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
return ((RecipeCrafting) recipeholder.value()).assemble(inventorycrafting, this.level().registryAccess());
}).map(ItemStack::getItem);
@@ -400,10 +421,18 @@
@@ -402,10 +423,18 @@
public boolean stillValid(EntityHuman entityhuman) {
return false;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
@@ -308,7 +308,9 @@
@@ -312,7 +312,9 @@
protected void ageBoundaryReached() {
super.ageBoundaryReached();
if (!this.isBaby() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
@ -10,7 +10,7 @@
}
}
@@ -335,7 +337,9 @@
@@ -339,7 +341,9 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
@ -19,8 +19,8 @@
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit
}
private static class e extends ControllerMove {
@@ -487,12 +491,14 @@
@Override
@@ -496,12 +500,14 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level();

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntityWolf.java
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
@@ -69,6 +69,12 @@
import net.minecraft.world.level.pathfinder.PathType;
@@ -70,6 +70,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRegainHealthEvent;
@ -13,7 +13,7 @@
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable {
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
@@ -297,15 +303,19 @@
@@ -298,15 +304,19 @@
} else {
Entity entity = damagesource.getEntity();
@ -37,7 +37,7 @@
}
}
@@ -325,7 +335,7 @@
@@ -326,7 +336,7 @@
super.setTame(flag);
if (flag) {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(20.0D);
@ -46,7 +46,7 @@
} else {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
}
@@ -348,7 +358,7 @@
@@ -349,7 +359,7 @@
itemstack.shrink(1);
}
@ -55,7 +55,7 @@
return EnumInteractionResult.SUCCESS;
} else {
if (item instanceof ItemDye) {
@@ -376,7 +386,7 @@
@@ -377,7 +387,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
@ -64,7 +64,7 @@
return EnumInteractionResult.SUCCESS;
} else {
return enuminteractionresult;
@@ -387,7 +397,8 @@
@@ -388,7 +398,8 @@
itemstack.shrink(1);
}

View File

@ -1,15 +1,6 @@
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -93,13 +93,14 @@
private final DynamicGameEventListener<Allay.a> dynamicJukeboxListener;
private final InventorySubcontainer inventory = new InventorySubcontainer(1);
@Nullable
- private BlockPosition jukeboxPos;
- private long duplicationCooldown;
+ public BlockPosition jukeboxPos; // PAIL private -> public
+ public long duplicationCooldown; // PAIL private -> public
private float holdingItemAnimationTicks;
private float holdingItemAnimationTicks0;
@@ -99,6 +99,7 @@
private float dancingAnimationTicks;
private float spinningAnimationTicks;
private float spinningAnimationTicks0;
@ -17,7 +8,7 @@
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
super(entitytypes, world);
@@ -111,6 +112,12 @@
@@ -110,6 +111,12 @@
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), GameEvent.JUKEBOX_PLAY.getNotificationRadius()));
}
@ -30,7 +21,7 @@
@Override
protected BehaviorController.b<Allay> brainProvider() {
return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
@@ -123,7 +130,7 @@
@@ -122,7 +129,7 @@
@Override
public BehaviorController<Allay> getBrain() {
@ -39,7 +30,7 @@
}
public static AttributeProvider.Builder createAttributes() {
@@ -230,7 +237,7 @@
@@ -229,7 +236,7 @@
public void aiStep() {
super.aiStep();
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
@ -48,7 +39,7 @@
}
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
@@ -300,7 +307,12 @@
@@ -299,7 +306,12 @@
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) {
@ -62,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);
@@ -311,7 +323,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);
@ -71,7 +62,7 @@
return EnumInteractionResult.SUCCESS;
} else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) {
this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY);
@@ -432,6 +444,7 @@
@@ -427,6 +439,7 @@
}
private boolean shouldStopDancing() {
@ -79,7 +70,7 @@
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
}
@@ -476,7 +489,7 @@
@@ -471,7 +484,7 @@
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
this.writeInventoryToTag(nbttagcompound);
@ -88,7 +79,7 @@
Logger logger = Allay.LOGGER;
Objects.requireNonNull(logger);
@@ -492,7 +505,7 @@
@@ -487,7 +500,7 @@
super.readAdditionalSaveData(nbttagcompound);
this.readInventoryFromTag(nbttagcompound);
if (nbttagcompound.contains("listener", 10)) {
@ -97,16 +88,16 @@
Logger logger = Allay.LOGGER;
Objects.requireNonNull(logger);
@@ -525,7 +538,7 @@
@@ -520,7 +533,7 @@
return Allay.DUPLICATION_ITEM.test(itemstack);
}
- private void duplicateAllay() {
+ public Allay duplicateAllay() { // CraftBukkit - return allay and private -> public
- public void duplicateAllay() {
+ public Allay duplicateAllay() { // CraftBukkit - return allay
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level());
if (allay != null) {
@@ -533,17 +546,17 @@
@@ -528,9 +541,9 @@
allay.setPersistenceRequired();
allay.resetDuplicationCooldown();
this.resetDuplicationCooldown();
@ -117,14 +108,4 @@
+ return allay; // CraftBukkit
}
- private void resetDuplicationCooldown() {
+ public void resetDuplicationCooldown() { // PAIL private -> public
this.duplicationCooldown = 6000L;
this.entityData.set(Allay.DATA_CAN_DUPLICATE, false);
}
- private boolean canDuplicate() {
+ public boolean canDuplicate() { // PAIL private -> public
return (Boolean) this.entityData.get(Allay.DATA_CAN_DUPLICATE);
}
public void resetDuplicationCooldown() {

View File

@ -27,7 +27,7 @@
}
@Override
@@ -419,7 +426,7 @@
@@ -414,7 +421,7 @@
int i = mobeffect != null ? mobeffect.getDuration() : 0;
int j = Math.min(2400, 100 + i);
@ -36,7 +36,7 @@
}
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
@@ -469,7 +476,7 @@
@@ -464,7 +471,7 @@
@Override
public BehaviorController<Axolotl> getBrain() {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -54,6 +54,12 @@
import net.minecraft.world.level.pathfinder.PathType;
@@ -55,6 +55,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -13,7 +13,7 @@
public class Goat extends EntityAnimal {
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F);
@@ -181,7 +187,7 @@
@@ -182,7 +188,7 @@
@Override
public BehaviorController<Goat> getBrain() {
@ -22,7 +22,7 @@
}
@Override
@@ -219,8 +225,15 @@
@@ -220,8 +226,15 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
@@ -78,6 +78,12 @@
import net.minecraft.world.phys.Vec2F;
@@ -79,6 +79,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -13,7 +13,7 @@
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable {
public static final int EQUIPMENT_SLOT_OFFSET = 400;
@@ -139,6 +145,7 @@
@@ -140,6 +146,7 @@
protected int gallopSoundCounter;
@Nullable
private UUID owner;
@ -21,7 +21,7 @@
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -334,7 +341,7 @@
@@ -335,7 +342,7 @@
public void createInventory() {
InventorySubcontainer inventorysubcontainer = this.inventory;
@ -30,7 +30,7 @@
if (inventorysubcontainer != null) {
inventorysubcontainer.removeListener(this);
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
@@ -442,7 +449,7 @@
@@ -443,7 +450,7 @@
}
public int getMaxTemper() {
@ -39,7 +39,7 @@
}
@Override
@@ -513,7 +520,7 @@
@@ -514,7 +521,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@ -48,7 +48,7 @@
flag = true;
}
@@ -590,7 +597,7 @@
@@ -591,7 +598,7 @@
super.aiStep();
if (!this.level().isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
@ -57,7 +57,7 @@
}
if (this.canEatGrass()) {
@@ -857,6 +864,7 @@
@@ -858,6 +865,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
}
@ -65,7 +65,7 @@
if (!this.inventory.getItem(0).isEmpty()) {
nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound()));
@@ -884,6 +892,11 @@
@@ -885,6 +893,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
@ -77,7 +77,7 @@
if (nbttagcompound.contains("SaddleItem", 10)) {
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem"));
@@ -986,6 +999,17 @@
@@ -987,6 +1000,17 @@
@Override
public void handleStartJump(int i) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityLlama.java
+++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java
@@ -82,6 +82,11 @@
@@ -84,6 +84,11 @@
return false;
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -82,14 +82,23 @@
@@ -83,14 +83,23 @@
public Sniffer(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@ -26,7 +26,7 @@
@Override
protected float getStandingEyeHeight(EntityPose entitypose, EntitySize entitysize) {
return this.getDimensions(entitypose).height * 0.6F;
@@ -270,6 +279,13 @@
@@ -267,6 +276,13 @@
ItemStack itemstack = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
@ -40,7 +40,7 @@
entityitem.setDefaultPickUpDelay();
worldserver.addFreshEntity(entityitem);
}
@@ -309,7 +325,7 @@
@@ -306,7 +322,7 @@
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
list.add(0, GlobalPos.of(this.level().dimension(), blockposition));
@ -49,7 +49,7 @@
return this;
}
@@ -461,7 +477,7 @@
@@ -458,7 +474,7 @@
@Override
public BehaviorController<Sniffer> getBrain() {

View File

@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
@@ -51,6 +51,19 @@
import net.minecraft.world.phys.Vec3D;
@@ -53,6 +53,19 @@
import org.joml.Vector3f;
import org.slf4j.Logger;
+// CraftBukkit start
@ -20,7 +20,7 @@
public class EntityEnderDragon extends EntityInsentient implements IMonster {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -88,6 +101,7 @@
@@ -90,6 +103,7 @@
private final PathPoint[] nodes;
private final int[] nodeAdjacency;
private final Path openSet;
@ -28,7 +28,7 @@
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
super(EntityTypes.ENDER_DRAGON, world);
@@ -109,6 +123,7 @@
@@ -111,6 +125,7 @@
this.noPhysics = true;
this.noCulling = true;
this.phaseManager = new DragonControllerManager(this);
@ -36,16 +36,16 @@
}
public void setDragonFight(EnderDragonBattle enderdragonbattle) {
@@ -267,7 +282,7 @@
@@ -258,7 +273,7 @@
Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation();
- if (vec3d1 != null) {
+ if (vec3d1 != null && idragoncontroller.getPhase() != DragonControllerPhase.HOVERING) { // CraftBukkit - Don't move when hovering
d0 = vec3d1.x - this.getX();
d1 = vec3d1.y - this.getY();
d2 = vec3d1.z - this.getZ();
@@ -408,7 +423,14 @@
double d0 = vec3d1.x - this.getX();
double d1 = vec3d1.y - this.getY();
double d2 = vec3d1.z - this.getZ();
@@ -399,7 +414,14 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
} else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
@ -61,7 +61,7 @@
}
}
@@ -483,6 +505,9 @@
@@ -474,6 +496,9 @@
int j1 = MathHelper.floor(axisalignedbb.maxZ);
boolean flag = false;
boolean flag1 = false;
@ -71,7 +71,7 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
@@ -492,7 +517,11 @@
@@ -483,7 +508,11 @@
if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) {
if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) {
@ -84,7 +84,7 @@
} else {
flag = true;
}
@@ -501,6 +530,51 @@
@@ -492,6 +521,51 @@
}
}
@ -136,7 +136,7 @@
if (flag1) {
BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
@@ -565,6 +639,21 @@
@@ -556,6 +630,21 @@
}
@ -158,7 +158,7 @@
@Override
protected void tickDeath() {
if (this.dragonFight != null) {
@@ -580,15 +669,20 @@
@@ -571,15 +660,20 @@
this.level().addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
}
@ -180,7 +180,7 @@
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.08F));
}
@@ -599,7 +693,7 @@
@@ -590,7 +684,7 @@
this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D));
if (this.dragonDeathTime == 200 && this.level() instanceof WorldServer) {
@ -189,7 +189,7 @@
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.2F));
}
@@ -820,6 +914,7 @@
@@ -811,6 +905,7 @@
super.addAdditionalSaveData(nbttagcompound);
nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime);
@ -197,7 +197,7 @@
}
@Override
@@ -833,6 +928,11 @@
@@ -824,6 +919,11 @@
this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime");
}

View File

@ -53,7 +53,7 @@
}
}
@@ -401,7 +424,25 @@
@@ -402,7 +425,25 @@
return false;
} else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterFlag() + 16) != 0) {
return false;
@ -80,7 +80,7 @@
this.setItemSlot(enumitemslot, itemstack.copyWithCount(1));
return true;
} else if (!itemstack.isEmpty() && itemstack.getCount() > 1) {
@@ -416,15 +457,26 @@
@@ -417,15 +458,26 @@
entityhuman.setItemInHand(enumhand, itemstack1);
return true;
}
@ -108,7 +108,7 @@
if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) {
this.brokenByAnything(damagesource);
this.kill();
@@ -473,7 +525,7 @@
@@ -486,7 +538,7 @@
} else {
this.brokenByPlayer(damagesource);
this.showBreakingParticles();
@ -117,7 +117,7 @@
}
return true;
@@ -541,13 +593,13 @@
@@ -554,13 +606,13 @@
itemstack.setHoverName(this.getCustomName());
}
@ -133,7 +133,7 @@
ItemStack itemstack;
int i;
@@ -555,7 +607,7 @@
@@ -568,7 +620,7 @@
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
@ -142,7 +142,7 @@
this.handItems.set(i, ItemStack.EMPTY);
}
}
@@ -563,10 +615,11 @@
@@ -576,10 +628,11 @@
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {
@ -155,7 +155,7 @@
}
@@ -667,8 +720,16 @@
@@ -675,8 +728,16 @@
return this.isSmall();
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
@@ -49,13 +49,17 @@
@@ -49,6 +49,10 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@ -11,14 +11,6 @@
public class EntityFallingBlock extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
private IBlockData blockState;
public int time;
public boolean dropItem;
- private boolean cancelDrop;
+ public boolean cancelDrop; // PAIL private -> public
public boolean hurtEntities;
public int fallDamageMax;
public float fallDamagePerDistance;
@@ -83,10 +87,17 @@
}

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityCaveSpider.java
+++ b/net/minecraft/world/entity/monster/EntityCaveSpider.java
@@ -41,7 +41,7 @@
@@ -42,7 +42,7 @@
}
if (b0 > 0) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntityEnderman.java
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
@@ -70,6 +70,11 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
@@ -71,6 +71,11 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -12,7 +12,7 @@
public class EntityEnderman extends EntityMonster implements IEntityAngerable {
private static final UUID SPEED_MODIFIER_ATTACKING_UUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
@@ -114,7 +119,17 @@
@@ -115,7 +120,17 @@
@Override
public void setTarget(@Nullable EntityLiving entityliving) {
@ -31,7 +31,7 @@
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED);
if (entityliving == null) {
@@ -129,6 +144,7 @@
@@ -130,6 +145,7 @@
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
}
}
@ -39,7 +39,7 @@
}
@@ -487,9 +503,11 @@
@@ -493,9 +509,11 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
@ -51,7 +51,7 @@
}
}
@@ -528,9 +546,11 @@
@@ -534,9 +552,11 @@
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityEvoker.java
+++ b/net/minecraft/world/entity/monster/EntityEvoker.java
@@ -192,7 +192,7 @@
@@ -194,7 +194,7 @@
entityvex.setOwner(EntityEvoker.this);
entityvex.setBoundOrigin(blockposition);
entityvex.setLimitedLife(20 * (30 + EntityEvoker.this.random.nextInt(90)));
- worldserver.addFreshEntityWithPassengers(entityvex);
+ worldserver.addFreshEntityWithPassengers(entityvex, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPELL); // CraftBukkit - Add SpawnReason
worldserver.gameEvent(GameEvent.ENTITY_PLACE, blockposition, GameEvent.a.of((Entity) EntityEvoker.this));
}
}

View File

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

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityGuardian.java
+++ b/net/minecraft/world/entity/monster/EntityGuardian.java
@@ -62,6 +62,7 @@
@@ -63,6 +63,7 @@
private boolean clientSideTouchedGround;
@Nullable
public PathfinderGoalRandomStroll randomStrollGoal;
@ -8,7 +8,7 @@
public EntityGuardian(EntityTypes<? extends EntityGuardian> entitytypes, World world) {
super(entitytypes, world);
@@ -77,7 +78,7 @@
@@ -78,7 +79,7 @@
PathfinderGoalMoveTowardsRestriction pathfindergoalmovetowardsrestriction = new PathfinderGoalMoveTowardsRestriction(this, 1.0D);
this.randomStrollGoal = new PathfinderGoalRandomStroll(this, 1.0D, 80);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityGuardianElder.java
+++ b/net/minecraft/world/entity/monster/EntityGuardianElder.java
@@ -67,7 +67,7 @@
@@ -70,7 +70,7 @@
super.customServerAiStep();
if ((this.tickCount + this.getId()) % 1200 == 0) {
MobEffect mobeffect = new MobEffect(MobEffects.DIG_SLOWDOWN, 6000, 2);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityPhantom.java
+++ b/net/minecraft/world/entity/monster/EntityPhantom.java
@@ -538,14 +538,14 @@
@@ -543,14 +543,14 @@
List<EntityHuman> list = EntityPhantom.this.level().getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
if (!list.isEmpty()) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityPigZombie.java
+++ b/net/minecraft/world/entity/monster/EntityPigZombie.java
@@ -154,7 +154,7 @@
@@ -150,7 +150,7 @@
}).filter((entitypigzombie) -> {
return !entitypigzombie.isAlliedTo((Entity) this.getTarget());
}).forEach((entitypigzombie) -> {
@ -9,7 +9,7 @@
});
}
@@ -163,7 +163,7 @@
@@ -159,7 +159,7 @@
}
@Override
@ -18,7 +18,7 @@
if (this.getTarget() == null && entityliving != null) {
this.playFirstAngerSoundIn = EntityPigZombie.FIRST_ANGER_SOUND_DELAY.sample(this.random);
this.ticksUntilNextAlert = EntityPigZombie.ALERT_INTERVAL.sample(this.random);
@@ -173,12 +173,21 @@
@@ -169,12 +169,21 @@
this.setLastHurtByPlayer((EntityHuman) entityliving);
}

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntityRavager.java
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
@@ -41,6 +41,10 @@
import net.minecraft.world.phys.AxisAlignedBB;
@@ -43,6 +43,10 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,7 +11,7 @@
public class EntityRavager extends EntityRaider {
private static final Predicate<Entity> NO_RAVAGER_AND_ALIVE = (entity) -> {
@@ -171,6 +175,11 @@
@@ -153,6 +157,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockLeaves) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityShulker.java
+++ b/net/minecraft/world/entity/monster/EntityShulker.java
@@ -60,6 +60,12 @@
@@ -59,6 +59,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
@ -13,7 +13,7 @@
public class EntityShulker extends EntityGolem implements VariantHolder<Optional<EnumColor>>, IMonster {
private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
@@ -408,6 +414,14 @@
@@ -400,6 +406,14 @@
EnumDirection enumdirection = this.findAttachableSurface(blockposition1);
if (enumdirection != null) {
@ -28,7 +28,7 @@
this.unRide();
this.setAttachFace(enumdirection);
this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F);
@@ -478,7 +492,7 @@
@@ -470,7 +484,7 @@
if (entityshulker != null) {
entityshulker.setVariant(this.getVariant());
entityshulker.moveTo(vec3d);

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntitySilverfish.java
+++ b/net/minecraft/world/entity/monster/EntitySilverfish.java
@@ -33,6 +33,10 @@
import net.minecraft.world.level.block.BlockMonsterEggs;
@@ -34,6 +34,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.joml.Vector3f;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@ -11,7 +11,7 @@
public class EntitySilverfish extends EntityMonster {
@Nullable
@@ -175,6 +179,11 @@
@@ -176,6 +180,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockMonsterEggs) {
@ -23,7 +23,7 @@
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
world.destroyBlock(blockposition1, true, this.silverfish);
} else {
@@ -244,6 +253,11 @@
@@ -245,6 +254,11 @@
IBlockData iblockdata = world.getBlockState(blockposition);
if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntitySkeletonWither.java
+++ b/net/minecraft/world/entity/monster/EntitySkeletonWither.java
@@ -106,7 +106,7 @@
@@ -111,7 +111,7 @@
return false;
} else {
if (entity instanceof EntityLiving) {

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntitySlime.java
+++ b/net/minecraft/world/entity/monster/EntitySlime.java
@@ -42,6 +42,14 @@
import net.minecraft.world.level.levelgen.SeededRandom;
@@ -44,6 +44,14 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
+// CraftBukkit start
+import java.util.ArrayList;
@ -15,7 +15,7 @@
public class EntitySlime extends EntityInsentient implements IMonster {
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
@@ -185,7 +193,7 @@
@@ -192,7 +200,7 @@
@Override
public EntityTypes<? extends EntitySlime> getType() {
@ -24,7 +24,7 @@
}
@Override
@@ -199,6 +207,19 @@
@@ -206,6 +214,19 @@
int j = i / 2;
int k = 2 + this.random.nextInt(3);
@ -44,7 +44,7 @@
for (int l = 0; l < k; ++l) {
float f1 = ((float) (l % 2) - 0.5F) * f;
float f2 = ((float) (l / 2) - 0.5F) * f;
@@ -214,9 +235,18 @@
@@ -221,9 +242,18 @@
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSize(j, true);
entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntitySpider.java
+++ b/net/minecraft/world/entity/monster/EntitySpider.java
@@ -180,7 +180,7 @@
@@ -182,7 +182,7 @@
MobEffectList mobeffectlist = entityspider_groupdataspider.effect;
if (mobeffectlist != null) {

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityStrider.java
+++ b/net/minecraft/world/entity/monster/EntityStrider.java
@@ -349,7 +349,14 @@
@@ -351,7 +351,14 @@
boolean flag2 = flag1;

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityVex.java
+++ b/net/minecraft/world/entity/monster/EntityVex.java
@@ -388,7 +388,7 @@
@@ -393,7 +393,7 @@
@Override
public void start() {

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