#Making a Status effect that stops block placing

10 messages · Page 1 of 1 (latest)

idle stream
#

Hi I was just wondering how to make a status effect that stops building/placing but I already have a potion effect just need help figuring out how to make a subscribe event and then cancels that event if you have the potion effect (I think that is what you do). Any help is appreciated, Thank You.

cobalt mirage
#

try PlayerBreakBlockEvents.BEFORE

#

hold on

#

UseBlockCallback.EVENT

idle stream
#
            if (player instanceof ServerPlayerEntity) {
                StatusEffectInstance effectInstance = player.getStatusEffect((RegistryEntry<StatusEffect>) ANTI_PLACE);
                if (effectInstance != null) {
                    if (hitResult instanceof BlockHitResult && !player.isCreative()) {
                        System.out.println("Block placement prevented due to effect");
                        return ActionResult.FAIL; // Cancel the placement
                    }
                }
            }
            return ActionResult.PASS; // Allow the placement
        });
#

that is what I had but it did not work?

#

would this work @cobalt mirage java UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> { if(player instanceof ServerPlayerEntity) { if(player.hasStatusEffect((RegistryEntry<StatusEffect>) ANTI_PLACE)) { return ActionResult.FAIL; } } return ActionResult.PASS; });

cobalt mirage
#

tryitandsee

idle stream
#

i did and no @cobalt mirage

cobalt mirage
#

straight fail the action and see if that works