Skip to content

Commit

Permalink
Fix interact with double slabs and little changes
Browse files Browse the repository at this point in the history
  • Loading branch information
illa4257 committed Sep 4, 2023
1 parent ef4d620 commit 69df46e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions PaperMC 1.20.1/src/main/java/illa4257/opensit/OpenSitListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ public void onDismount(final EntityDismountEvent event) {
if (!(event.getEntity() instanceof Player))
return;
final Entity e = event.getDismounted();
if (e instanceof BlockDisplay && e.getScoreboardTags().contains("sit")) {
event.getEntity().teleport(event.getEntity().getLocation().add(0, 1, 0));
e.remove();
} else if (e instanceof BlockDisplay && e.getScoreboardTags().contains("sit2")) {
event.getEntity().teleport(event.getEntity().getLocation().add(0, 1.5, 0));
e.remove();
}
if (e instanceof BlockDisplay)
if (e.getScoreboardTags().contains("sit")) {
event.getEntity().teleport(event.getEntity().getLocation().add(0, 1, 0));
e.remove();
} else if (e.getScoreboardTags().contains("sit2")) {
event.getEntity().teleport(event.getEntity().getLocation().add(0, 1.5, 0));
e.remove();
}
}

@EventHandler
Expand All @@ -35,10 +36,9 @@ public void onInteract(final PlayerInteractEvent event) {
return;
final BlockData d = event.getClickedBlock().getState().getBlockData();
if (d instanceof Slab || d instanceof Stairs) {
final boolean t = d instanceof Slab ? ((Slab) d).getType() == Slab.Type.TOP : ((Stairs) d).getHalf() == Bisected.Half.TOP;
final boolean t = d instanceof Slab ? ((Slab) d).getType() != Slab.Type.BOTTOM : ((Stairs) d).getHalf() == Bisected.Half.TOP;
final Location l = event.getClickedBlock().getLocation();
final BlockDisplay b = (BlockDisplay) l.getWorld().spawnEntity(new Location(l.getWorld(), l.getX() + .5, l.getY() + (t ? .8 : .3),
l.getZ() + .5), EntityType.BLOCK_DISPLAY);
final BlockDisplay b = (BlockDisplay) l.getWorld().spawnEntity(new Location(l.getWorld(), l.getX() + .5, l.getY() + (t ? .8 : .3), l.getZ() + .5), EntityType.BLOCK_DISPLAY);
b.addScoreboardTag(d instanceof Slab || t ? "sit" : "sit2");
b.addPassenger(event.getPlayer());
}
Expand All @@ -47,8 +47,8 @@ public void onInteract(final PlayerInteractEvent event) {
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
final Entity e = event.getPlayer().getVehicle();
if (e instanceof BlockDisplay && (e.getScoreboardTags().contains("sit") || e.getScoreboardTags().contains("sit2")) &&!e.getLocation().getBlock().isSolid())
e.remove();
if (e instanceof BlockDisplay && (e.getScoreboardTags().contains("sit") || e.getScoreboardTags().contains("sit2")) && !e.getLocation().getBlock().isSolid())
e.remove();
}

@EventHandler
Expand Down

0 comments on commit 69df46e

Please sign in to comment.