Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-1.19-lts' into master-1.2…
Browse files Browse the repository at this point in the history
…0-lts
  • Loading branch information
rubensworks committed Jun 23, 2024
2 parents 05f038a + a3b8290 commit ea43446
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resources/changelog/1.19.2-1.9.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
As always, don't forget to backup your world before updating!
Requires CyclopsCore version 1.17.0 or higher.

Fixes:
* Fix entities sometimes spawning in chest, Closes #163

11 changes: 11 additions & 0 deletions src/main/java/org/cyclops/colossalchests/block/ChestWall.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -24,6 +25,8 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.MobSpawnEvent;
import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest;
import org.cyclops.cyclopscore.block.multi.CubeDetector;
import org.cyclops.cyclopscore.helper.MinecraftHelpers;
Expand All @@ -47,6 +50,14 @@ public ChestWall(Block.Properties properties, ChestMaterial material) {

this.registerDefaultState(this.stateDefinition.any()
.setValue(ENABLED, false));
MinecraftForge.EVENT_BUS.addListener(this::onLivingSpawn);
}

public void onLivingSpawn(MobSpawnEvent.FinalizeSpawn 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
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/cyclops/colossalchests/block/ColossalChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -41,6 +42,8 @@
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.MobSpawnEvent;
import org.cyclops.colossalchests.Advancements;
import org.cyclops.colossalchests.RegistryEntries;
import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest;
Expand Down Expand Up @@ -75,6 +78,14 @@ public ColossalChest(Properties properties, ChestMaterial material) {

this.registerDefaultState(this.stateDefinition.any()
.setValue(ENABLED, false));
MinecraftForge.EVENT_BUS.addListener(this::onLivingSpawn);
}

public void onLivingSpawn(MobSpawnEvent.FinalizeSpawn 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
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/cyclops/colossalchests/block/Interface.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -24,6 +25,8 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.MobSpawnEvent;
import org.cyclops.colossalchests.blockentity.BlockEntityColossalChest;
import org.cyclops.colossalchests.blockentity.BlockEntityInterface;
import org.cyclops.cyclopscore.block.BlockWithEntity;
Expand All @@ -50,8 +53,16 @@ public Interface(Block.Properties properties, ChestMaterial material) {

this.registerDefaultState(this.stateDefinition.any()
.setValue(ENABLED, false));
MinecraftForge.EVENT_BUS.addListener(this::onLivingSpawn);
}

public void onLivingSpawn(MobSpawnEvent.FinalizeSpawn 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();
Expand Down

0 comments on commit ea43446

Please sign in to comment.