diff --git a/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java b/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java index d8dc837..7730e2f 100644 --- a/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java +++ b/common/src/main/java/io/github/flemmli97/flan/CrossPlatformStuff.java @@ -3,6 +3,7 @@ package io.github.flemmli97.flan; import me.shedaniel.architectury.annotations.ExpectPlatform; import net.minecraft.block.Block; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.Item; @@ -30,6 +31,11 @@ public class CrossPlatformStuff { throw new AssertionError(); } + @ExpectPlatform + public static SimpleRegistryWrapper> registryEntities() { + throw new AssertionError(); + } + @ExpectPlatform public static boolean isInventoryTile(BlockEntity blockEntity) { throw new AssertionError(); diff --git a/common/src/main/java/io/github/flemmli97/flan/config/Config.java b/common/src/main/java/io/github/flemmli97/flan/config/Config.java index adda9ae..98ba2c7 100644 --- a/common/src/main/java/io/github/flemmli97/flan/config/Config.java +++ b/common/src/main/java/io/github/flemmli97/flan/config/Config.java @@ -35,7 +35,9 @@ public class Config { public int defaultClaimDepth = 10; public boolean lenientBlockEntityCheck; public List ignoredBlocks = new ArrayList<>(); - public List ignoredEntityTypes = new ArrayList<>(); + public List ignoredEntityTypes = Lists.newArrayList( + "corpse:corpse" + ); public List blockEntityTagIgnore = Lists.newArrayList( "IsDeathChest", //vanilla death chest "gunpowder.owner" //gunpowder diff --git a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java index 3c9a441..d80aaa8 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/BlockInteractEvents.java @@ -120,7 +120,8 @@ public class BlockInteractEvents { } public static boolean alwaysAllowBlock(Identifier id, BlockEntity blockEntity) { - return ConfigHandler.config.ignoredBlocks.contains(id.toString()) + return ConfigHandler.config.ignoredBlocks.contains(id.getNamespace()) + || ConfigHandler.config.ignoredBlocks.contains(id.toString()) || (blockEntity != null && ConfigHandler.config.blockEntityTagIgnore.stream().anyMatch(blockEntity.toTag(new CompoundTag())::contains)); } diff --git a/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java b/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java index 860efc6..c836e27 100644 --- a/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java +++ b/common/src/main/java/io/github/flemmli97/flan/event/EntityInteractEvents.java @@ -1,5 +1,6 @@ package io.github.flemmli97.flan.event; +import io.github.flemmli97.flan.CrossPlatformStuff; import io.github.flemmli97.flan.api.data.IPermissionContainer; import io.github.flemmli97.flan.api.permission.ClaimPermission; import io.github.flemmli97.flan.api.permission.ObjectToPermissionMap; @@ -43,6 +44,7 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundEvents; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; @@ -105,7 +107,10 @@ public class EntityInteractEvents { } public static boolean canInteract(Entity entity) { - return entity.getScoreboardTags().stream().anyMatch(ConfigHandler.config.entityTagIgnore::contains); + Identifier id = CrossPlatformStuff.registryEntities().getIDFrom(entity.getType()); + return ConfigHandler.config.ignoredEntityTypes.contains(id.getNamespace()) + || ConfigHandler.config.ignoredEntityTypes.contains(id.toString()) + || entity.getScoreboardTags().stream().anyMatch(ConfigHandler.config.entityTagIgnore::contains); } public static boolean projectileHit(ProjectileEntity proj, HitResult res) { diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java index d06bc32..d4ce159 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/CrossPlatformStuffImpl.java @@ -6,6 +6,7 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.block.Block; import net.minecraft.block.InventoryProvider; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.inventory.Inventory; import net.minecraft.item.Item; @@ -40,6 +41,10 @@ public class CrossPlatformStuffImpl { return new FabricRegistryWrapper<>(Registry.ITEM); } + public static SimpleRegistryWrapper> registryEntities() { + return new FabricRegistryWrapper<>(Registry.ENTITY_TYPE); + } + public static boolean isInventoryTile(BlockEntity blockEntity) { return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider; } diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java b/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java index d164bde..4afb7ed 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/CrossPlatformStuffImpl.java @@ -5,6 +5,7 @@ import io.github.flemmli97.flan.SimpleRegistryWrapper; import net.minecraft.block.Block; import net.minecraft.block.InventoryProvider; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.inventory.Inventory; import net.minecraft.item.Item; @@ -32,6 +33,10 @@ public class CrossPlatformStuffImpl { return new ForgeRegistryWrapper<>(ForgeRegistries.ITEMS); } + public static SimpleRegistryWrapper> registryEntities() { + return new ForgeRegistryWrapper<>(ForgeRegistries.ENTITIES); + } + public static boolean isInventoryTile(BlockEntity blockEntity) { return blockEntity instanceof Inventory || blockEntity instanceof InventoryProvider || blockEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).isPresent(); }