Skip to content

Commit

Permalink
better support iron trapdoors/doors on 1.7 clients
Browse files Browse the repository at this point in the history
  • Loading branch information
MWHunter committed Dec 12, 2022
1 parent 59e0101 commit 26a9e3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ private static void handleBlockPlaceOrUseItem(PacketWrapper packet, GrimPlayer p
BlockPlace blockPlace = new BlockPlace(player, place.getHand(), blockPosition, place.getFace(), placedWith, getNearestHitResult(player, null, true));

// Right-clicking a trapdoor/door/etc.
if (Materials.isClientSideInteractable(blockPlace.getPlacedAgainstMaterial())) {
StateType placedAgainst = blockPlace.getPlacedAgainstMaterial();
if ((player.getClientVersion().isOlderThan(ClientVersion.V_1_8) && (placedAgainst == StateTypes.IRON_TRAPDOOR || placedAgainst == StateTypes.IRON_DOOR))
|| Materials.isClientSideInteractable(placedAgainst)) {
Vector3i location = blockPlace.getPlacedAgainstBlockLocation();
player.compensatedWorld.tickOpenable(location.getX(), location.getY(), location.getZ());
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void updateBlock(int x, int y, int z, int combinedID) {
public void tickOpenable(int blockX, int blockY, int blockZ) {
WrappedBlockState data = player.compensatedWorld.getWrappedBlockStateAt(blockX, blockY, blockZ);

if (BlockTags.WOODEN_DOORS.contains(data.getType())) {
if (BlockTags.WOODEN_DOORS.contains(data.getType()) || (player.getClientVersion().isOlderThan(ClientVersion.V_1_8) && data.getType() == StateTypes.IRON_DOOR)) {
WrappedBlockState otherDoor = player.compensatedWorld.getWrappedBlockStateAt(blockX,
blockY + (data.getHalf() == Half.LOWER ? 1 : -1), blockZ);

Expand All @@ -316,7 +316,8 @@ public void tickOpenable(int blockX, int blockY, int blockZ) {
player.compensatedWorld.updateBlock(blockX, blockY - 1, blockZ, otherDoor.getGlobalId());
}
}
} else if (BlockTags.WOODEN_TRAPDOORS.contains(data.getType()) || BlockTags.FENCE_GATES.contains(data.getType())) {
} else if (BlockTags.WOODEN_TRAPDOORS.contains(data.getType()) || BlockTags.FENCE_GATES.contains(data.getType())
|| (player.getClientVersion().isOlderThan(ClientVersion.V_1_8) && data.getType() == StateTypes.IRON_TRAPDOOR)) {
// Take 12 most significant bytes -> the material ID. Combine them with the new block magic data.
data.setOpen(!data.isOpen());
player.compensatedWorld.updateBlock(blockX, blockY, blockZ, data.getGlobalId());
Expand Down

0 comments on commit 26a9e3f

Please sign in to comment.