Skip to content

Commit

Permalink
Some patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Oct 23, 2024
1 parent 15b8377 commit dcaef39
Show file tree
Hide file tree
Showing 208 changed files with 1,188 additions and 795 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
@@ -210,12 +236,17 @@

static EnumInteractionResult emptyBucket(World world, BlockPos blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
static EnumInteractionResult emptyBucket(World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack, IBlockData iblockdata, SoundEffect soundeffect) {
if (!world.isClientSide) {
+ // CraftBukkit start
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
+ // CraftBukkit end

if (!worldserver.isClientSide()) {
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));

- this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack));
+ this.setSuccess(tryShearBeehive(worldserver, blockposition) || tryShearLivingEntity(worldserver, blockposition, itemstack, bukkitBlock, craftItem)); // CraftBukkit
Expand All @@ -54,8 +54,8 @@
return false;
}

- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPos blockposition, ItemStack itemstack) {
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPos blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
- private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
+ private static boolean tryShearLivingEntity(WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, org.bukkit.block.Block bukkitBlock, CraftItemStack craftItem) { // CraftBukkit - add args
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, new AxisAlignedBB(blockposition), IEntitySelector.NO_SPECTATORS);
Iterator iterator = list.iterator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

private static final Logger LOGGER = LogUtils.getLogger();
@@ -26,6 +32,30 @@
BlockPos blockposition = sourceblock.pos().relative(enumdirection);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
EnumDirection enumdirection1 = sourceblock.level().isEmptyBlock(blockposition.below()) ? enumdirection : EnumDirection.UP;

+ // CraftBukkit start
Expand Down
16 changes: 8 additions & 8 deletions nms-patches/net/minecraft/core/dispenser/IDispenseBehavior.patch
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}
@@ -116,13 +160,41 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPos blockposition = sourceblock.pos().relative(enumdirection);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
WorldServer worldserver = sourceblock.level();
+
+ // CraftBukkit start
Expand Down Expand Up @@ -186,7 +186,7 @@
return itemstack;
}
@@ -202,6 +327,38 @@
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
WorldServer worldserver = sourceblock.level();

+ // CraftBukkit start
Expand Down Expand Up @@ -296,7 +296,7 @@
+
this.setSuccess(true);
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPos blockposition = sourceblock.pos().relative(enumdirection);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);
IBlockData iblockdata = worldserver.getBlockState(blockposition);

if (BlockFireAbstract.canBePlacedAt(worldserver, blockposition, enumdirection)) {
Expand All @@ -317,7 +317,7 @@
@@ -283,12 +494,62 @@
this.setSuccess(true);
WorldServer worldserver = sourceblock.level();
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
+ // CraftBukkit start
+ org.bukkit.block.Block block = CraftBlock.at(worldserver, sourceblock.pos());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
Expand Down Expand Up @@ -380,7 +380,7 @@
@@ -298,12 +559,41 @@
protected ItemStack execute(SourceBlock sourceblock, ItemStack itemstack) {
WorldServer worldserver = sourceblock.level();
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
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);
Expand Down Expand Up @@ -423,7 +423,7 @@
});
@@ -314,6 +604,30 @@
EnumDirection enumdirection = (EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING);
BlockPos blockposition = sourceblock.pos().relative(enumdirection);
BlockPosition blockposition = sourceblock.pos().relative(enumdirection);

+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = CraftBlock.at(worldserver, sourceblock.pos());
Expand Down Expand Up @@ -453,7 +453,7 @@
worldserver.setBlock(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.defaultBlockState().setValue(BlockSkull.ROTATION, RotationSegment.convertToSegment(enumdirection)), 3);
worldserver.gameEvent((Entity) null, (Holder) GameEvent.BLOCK_PLACE, blockposition);
@@ -339,6 +653,30 @@
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN;

+ // CraftBukkit start
Expand Down Expand Up @@ -484,7 +484,7 @@
if (!worldserver.isClientSide) {
worldserver.setBlock(blockposition, blockpumpkincarved.defaultBlockState(), 3);
@@ -377,6 +715,30 @@
BlockPos blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
BlockPosition blockposition = sourceblock.pos().relative((EnumDirection) sourceblock.state().getValue(BlockDispenser.FACING));
IBlockData iblockdata = worldserver.getBlockState(blockposition);

+ // CraftBukkit start
Expand Down
4 changes: 2 additions & 2 deletions nms-patches/net/minecraft/server/MinecraftServer.patch
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
+ if (spawn.getWorld() != worldserver.getWorld()) {
+ throw new IllegalStateException("Cannot set spawn point for " + iworlddataserver.getLevelName() + " to be in another world (" + spawn.getWorld().getName() + ")");
+ } else {
+ iworlddataserver.setSpawn(new BlockPos(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw());
+ iworlddataserver.setSpawn(new BlockPosition(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()), spawn.getYaw());
+ return;
+ }
+ }
Expand All @@ -442,7 +442,7 @@
+ // CraftBukkit end

MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPos blockposition = worldserver.getSharedSpawnPos();
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -527,20 +778,22 @@

this.nextTickTimeNanos = SystemUtils.getNanos();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- a/net/minecraft/server/commands/CommandSetWorldSpawn.java
+++ b/net/minecraft/server/commands/CommandSetWorldSpawn.java
@@ -30,7 +30,7 @@
private static int setSpawn(CommandListenerWrapper commandlistenerwrapper, BlockPos blockposition, float f) {
private static int setSpawn(CommandListenerWrapper commandlistenerwrapper, BlockPosition blockposition, float f) {
WorldServer worldserver = commandlistenerwrapper.getLevel();

- if (worldserver.dimension() != World.OVERWORLD) {
Expand Down
42 changes: 21 additions & 21 deletions nms-patches/net/minecraft/server/level/EntityPlayer.patch
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
+
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
+ // If this is an issue, PRs are welcome
+ public final BlockPos getSpawnPoint(WorldServer worldserver) {
+ BlockPos blockposition = worldserver.getSharedSpawnPos();
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
+ BlockPosition blockposition = worldserver.getSharedSpawnPos();
+
+ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) {
+ int i = Math.max(0, this.server.getSpawnRadius(worldserver));
Expand All @@ -135,7 +135,7 @@
+ int i2 = (k1 + j1 * l1) % i1;
+ int j2 = i2 % (i * 2 + 1);
+ int k2 = i2 / (i * 2 + 1);
+ BlockPos blockposition1 = WorldProviderNormal.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i);
+ BlockPosition blockposition1 = WorldProviderNormal.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i);
+
+ if (blockposition1 != null) {
+ return blockposition1;
Expand All @@ -148,9 +148,9 @@
+ // CraftBukkit end

@Override
public BlockPos adjustSpawnLocation(WorldServer worldserver, BlockPos blockposition) {
public BlockPosition adjustSpawnLocation(WorldServer worldserver, BlockPosition blockposition) {
AxisAlignedBB axisalignedbb = this.getDimensions(EntityPose.STANDING).makeBoundingBox(Vec3D.ZERO);
BlockPos blockposition1 = blockposition;
BlockPosition blockposition1 = blockposition;

- if (worldserver.dimensionType().hasSkyLight() && worldserver.getServer().getWorldData().getGameType() != EnumGamemode.ADVENTURE) {
+ if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit
Expand Down Expand Up @@ -208,7 +208,7 @@
+ // CraftBukkit end
+
if (nbttagcompound.contains("SpawnX", 99) && nbttagcompound.contains("SpawnY", 99) && nbttagcompound.contains("SpawnZ", 99)) {
this.respawnPosition = new BlockPos(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
this.respawnPosition = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
this.respawnForced = nbttagcompound.getBoolean("SpawnForced");
this.respawnAngle = nbttagcompound.getFloat("SpawnAngle");
if (nbttagcompound.contains("SpawnDimension")) {
Expand All @@ -218,11 +218,11 @@

Objects.requireNonNull(logger1);
@@ -484,7 +610,7 @@
dataresult = BlockPos.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
dataresult = BlockPosition.CODEC.parse(DynamicOpsNBT.INSTANCE, nbtbase);
logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
- dataresult.resultOrPartial(logger::error).ifPresent((blockposition) -> {
+ ((DataResult<BlockPos>) dataresult).resultOrPartial(logger::error).ifPresent((blockposition) -> { // CraftBukkit - decompile error
+ ((DataResult<BlockPosition>) dataresult).resultOrPartial(logger::error).ifPresent((blockposition) -> { // CraftBukkit - decompile error
this.raidOmenPosition = blockposition;
});
}
Expand Down Expand Up @@ -516,7 +516,7 @@
+ boolean isBedSpawn = false;
+ boolean isAnchorSpawn = false;
+ // CraftBukkit end
BlockPos blockposition = this.getRespawnPosition();
BlockPosition blockposition = this.getRespawnPosition();
float f = this.getRespawnAngle();
boolean flag1 = this.isRespawnForced();
@@ -1116,13 +1358,32 @@
Expand Down Expand Up @@ -554,7 +554,7 @@
+ // CraftBukkit end
}

public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPos blockposition, float f, boolean flag, boolean flag1) {
public static Optional<EntityPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) {
@@ -1137,11 +1398,11 @@
}

Expand Down Expand Up @@ -722,11 +722,11 @@
}

- @Override
- public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPos blockposition) {
- public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) {
- EnumDirection enumdirection = (EnumDirection) this.level().getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
-
+ // CraftBukkit start - moved bed result checks from below into separate method
+ private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPos blockposition, EnumDirection enumdirection) {
+ private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPosition blockposition, EnumDirection enumdirection) {
if (!this.isSleeping() && this.isAlive()) {
- if (!this.level().dimensionType().natural()) {
+ if (!this.level().dimensionType().natural() || !this.level().dimensionType().bedWorks()) {
Expand Down Expand Up @@ -755,7 +755,7 @@
+ }
+
+ @Override
+ public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPos blockposition, boolean force) {
+ public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition, boolean force) {
+ EnumDirection enumdirection = (EnumDirection) this.level().getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
+ Either<EntityHuman.EnumBedResult, Unit> bedResult = this.getBedResult(blockposition, enumdirection);
+
Expand Down Expand Up @@ -797,7 +797,7 @@
+ if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one!
+ // CraftBukkit start - fire PlayerBedLeaveEvent
+ CraftPlayer player = this.getBukkitEntity();
+ BlockPos bedPosition = this.getSleepingPos().orElse(null);
+ BlockPosition bedPosition = this.getSleepingPos().orElse(null);
+
+ org.bukkit.block.Block bed;
+ if (bedPosition != null) {
Expand Down Expand Up @@ -1032,7 +1032,7 @@
@Override
- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, TeleportCause cause) { // CraftBukkit
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPos.containing(d0, d1, d2));
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));

worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
@@ -1780,7 +2184,7 @@
Expand Down Expand Up @@ -1087,12 +1087,12 @@
@@ -2065,6 +2479,32 @@
}

public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPos blockposition, float f, boolean flag, boolean flag1) {
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
+ // CraftBukkit start
+ this.setRespawnPosition(resourcekey, blockposition, f, flag, flag1, PlayerSpawnChangeEvent.Cause.UNKNOWN);
+ }
+
+ public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPos blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) {
+ public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) {
+ WorldServer newWorld = this.server.getLevel(resourcekey);
+ Location newSpawn = (blockposition != null) ? CraftLocation.toBukkit(blockposition, newWorld.getWorld(), f, 0) : null;
+
Expand All @@ -1106,7 +1106,7 @@
+
+ if (newSpawn != null) {
+ resourcekey = ((CraftWorld) newSpawn.getWorld()).getHandle().dimension();
+ blockposition = BlockPos.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ());
+ blockposition = BlockPosition.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ());
+ f = newSpawn.getYaw();
+ } else {
+ resourcekey = World.OVERWORLD;
Expand Down Expand Up @@ -1165,14 +1165,14 @@
+ // CraftBukkit start
+ public static record RespawnPosAngle(Vec3D position, float yaw, boolean isBedSpawn, boolean isAnchorSpawn) {

- public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPos blockposition) {
- public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition) {
- return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition));
+ public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPos blockposition, boolean isBedSpawn, boolean isAnchorSpawn) {
+ public static EntityPlayer.RespawnPosAngle of(Vec3D vec3d, BlockPosition blockposition, boolean isBedSpawn, boolean isAnchorSpawn) {
+ return new EntityPlayer.RespawnPosAngle(vec3d, calculateLookAtYaw(vec3d, blockposition), isBedSpawn, isAnchorSpawn);
+ // CraftBukkit end
}

private static float calculateLookAtYaw(Vec3D vec3d, BlockPos blockposition) {
private static float calculateLookAtYaw(Vec3D vec3d, BlockPosition blockposition) {
@@ -2406,4 +2874,146 @@
return (float) MathHelper.wrapDegrees(MathHelper.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
}
@@ -242,10 +326,65 @@

public boolean destroyBlock(BlockPos blockposition) {
public boolean destroyBlock(BlockPosition blockposition) {
IBlockData iblockdata = this.level.getBlockState(blockposition);
+ // CraftBukkit start - fire BlockBreakEvent
+ org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
Expand Down Expand Up @@ -275,11 +275,11 @@
+ // CraftBukkit start - whole method
+ public boolean interactResult = false;
+ public boolean firedInteract = false;
+ public BlockPos interactPosition;
+ public BlockPosition interactPosition;
+ public EnumHand interactHand;
+ public ItemStack interactItemStack;
public EnumInteractionResult useItemOn(EntityPlayer entityplayer, World world, ItemStack itemstack, EnumHand enumhand, MovingObjectPositionBlock movingobjectpositionblock) {
BlockPos blockposition = movingobjectpositionblock.getBlockPos();
BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
IBlockData iblockdata = world.getBlockState(blockposition);
+ boolean cancelledBlock = false;

Expand Down
Loading

0 comments on commit dcaef39

Please sign in to comment.