mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
Fix interactable logic and update entity registration
Corrects the logic for interactable checks in ItemEventListener to ensure proper event triggering. Removes sneaking check from chiseled bookshelf interaction and updates HAPPY_GHAST entity registration to use valueOf instead of reflection for compatibility with newer versions.
This commit is contained in:
@@ -279,7 +279,7 @@ public class ItemEventListener implements Listener {
|
||||
.withParameter(DirectContextParameters.EVENT, dummy)
|
||||
);
|
||||
CustomItem<ItemStack> customItem = optionalCustomItem.get();
|
||||
if (!InteractUtils.isInteractable(player, blockData, hitResult, itemInHand) && !player.isSneaking()) {
|
||||
if (!(InteractUtils.isInteractable(player, blockData, hitResult, itemInHand) && !player.isSneaking())) {
|
||||
customItem.execute(context, EventTrigger.RIGHT_CLICK);
|
||||
}
|
||||
if (dummy.isCancelled()) {
|
||||
|
||||
@@ -94,7 +94,6 @@ public class InteractUtils {
|
||||
});
|
||||
registerInteraction(BlockKeys.CHISELED_BOOKSHELF, (player, item, blockState, result) -> {
|
||||
Direction direction = result.getDirection();
|
||||
if (player.isSneaking()) return false;
|
||||
if (blockState instanceof ChiseledBookshelf chiseledBookshelf) {
|
||||
Direction facing = DirectionUtils.toDirection(chiseledBookshelf.getFacing());
|
||||
return facing == direction;
|
||||
@@ -311,11 +310,7 @@ public class InteractUtils {
|
||||
EntityType.GLOW_ITEM_FRAME
|
||||
));
|
||||
if (VersionHelper.isOrAbove1_21_6()) {
|
||||
try {
|
||||
Field happyGhastField = EntityType.class.getField("HAPPY_GHAST");
|
||||
EntityType happyGhast = (EntityType) happyGhastField.get(null);
|
||||
set.add(happyGhast);
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {}
|
||||
set.add(EntityType.valueOf("HAPPY_GHAST"));
|
||||
}
|
||||
return Collections.unmodifiableSet(set);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user