From c7d1316416818a492cb029cef68508fa069af60c Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Tue, 16 Jul 2024 16:21:27 +0200 Subject: [PATCH] Revert "Fix entities sometimes spawning in chest, Closes #163" This reverts commit 143b480a45c1344033aa3c6232ea0f19cd17acde. Closes #165 --- .../org/cyclops/colossalchests/block/ChestWall.java | 11 ----------- .../cyclops/colossalchests/block/ColossalChest.java | 12 +----------- .../org/cyclops/colossalchests/block/Interface.java | 11 ----------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/main/java/org/cyclops/colossalchests/block/ChestWall.java b/src/main/java/org/cyclops/colossalchests/block/ChestWall.java index 73ae886d..d046cccb 100644 --- a/src/main/java/org/cyclops/colossalchests/block/ChestWall.java +++ b/src/main/java/org/cyclops/colossalchests/block/ChestWall.java @@ -4,7 +4,6 @@ import net.minecraft.core.Vec3i; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; @@ -22,8 +21,6 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; -import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.living.FinalizeSpawnEvent; import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest; import org.cyclops.cyclopscore.block.multi.CubeDetector; import org.cyclops.cyclopscore.helper.MinecraftHelpers; @@ -47,14 +44,6 @@ public ChestWall(Block.Properties properties, ChestMaterial material) { this.registerDefaultState(this.stateDefinition.any() .setValue(ENABLED, false)); - NeoForge.EVENT_BUS.addListener(this::onLivingSpawn); - } - - public void onLivingSpawn(FinalizeSpawnEvent event) { - // Only isValidSpawn is insufficient in some cases, so we add this forceful check as well. - if (event.getSpawnType() != MobSpawnType.CHUNK_GENERATION && event.getEntity().getBlockStateOn().getBlock() == this) { - event.setSpawnCancelled(true); - } } @Override diff --git a/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java b/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java index f7f813a9..2df55c10 100644 --- a/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java +++ b/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java @@ -18,7 +18,6 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; @@ -42,8 +41,6 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.living.FinalizeSpawnEvent; import org.cyclops.colossalchests.RegistryEntries; import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest; import org.cyclops.cyclopscore.block.BlockWithEntityGui; @@ -55,6 +52,7 @@ import org.cyclops.cyclopscore.helper.LocationHelpers; import org.cyclops.cyclopscore.helper.MinecraftHelpers; import org.cyclops.cyclopscore.inventory.SimpleInventory; +import org.spongepowered.asm.mixin.Interface; import javax.annotation.Nullable; @@ -79,14 +77,6 @@ public ColossalChest(Properties properties, ChestMaterial material) { this.registerDefaultState(this.stateDefinition.any() .setValue(ENABLED, false)); - NeoForge.EVENT_BUS.addListener(this::onLivingSpawn); - } - - public void onLivingSpawn(FinalizeSpawnEvent event) { - // Only isValidSpawn is insufficient in some cases, so we add this forceful check as well. - if (event.getSpawnType() != MobSpawnType.CHUNK_GENERATION && event.getEntity().getBlockStateOn().getBlock() == this) { - event.setSpawnCancelled(true); - } } @org.jetbrains.annotations.Nullable diff --git a/src/main/java/org/cyclops/colossalchests/block/Interface.java b/src/main/java/org/cyclops/colossalchests/block/Interface.java index b3bfa1fc..b57b0a20 100644 --- a/src/main/java/org/cyclops/colossalchests/block/Interface.java +++ b/src/main/java/org/cyclops/colossalchests/block/Interface.java @@ -5,7 +5,6 @@ import net.minecraft.core.Vec3i; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockAndTintGetter; @@ -24,8 +23,6 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; -import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.living.FinalizeSpawnEvent; import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest; import org.cyclops.colossalchests.blockentity.BlockEntityInterface; import org.cyclops.cyclopscore.block.BlockWithEntity; @@ -54,16 +51,8 @@ public Interface(Block.Properties properties, ChestMaterial material) { this.registerDefaultState(this.stateDefinition.any() .setValue(ENABLED, false)); - NeoForge.EVENT_BUS.addListener(this::onLivingSpawn); } - public void onLivingSpawn(FinalizeSpawnEvent event) { - // Only isValidSpawn is insufficient in some cases, so we add this forceful check as well. - if (event.getSpawnType() != MobSpawnType.CHUNK_GENERATION && event.getEntity().getBlockStateOn().getBlock() == this) { - event.setSpawnCancelled(true); - } -} - @Override public String getDescriptionId() { String baseKey = super.getDescriptionId();