mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Fix FinalizeSpawn not blocking spawns during worldgen (#9420)
This commit is contained in:
1 parent
5c44992d1c
commit
1ab0685d04
2 files changed
+13
No files matched your search
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/level/WorldGenRegion.java
|
||||
+++ b/net/minecraft/server/level/WorldGenRegion.java
|
||||
@@ -297,6 +_,7 @@
|
||||
}
|
||||
|
||||
public boolean m_7967_(Entity p_9580_) {
|
||||
+ if (p_9580_ instanceof net.minecraft.world.entity.Mob mob && mob.isSpawnCancelled()) return false;
|
||||
int i = SectionPos.m_123171_(p_9580_.m_146903_());
|
||||
int j = SectionPos.m_123171_(p_9580_.m_146907_());
|
||||
this.m_6325_(i, j).m_6286_(p_9580_);
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
@@ -16,6 +17,7 @@ import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.level.BaseSpawner;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraftforge.common.ForgeInternalHandler;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
@@ -209,6 +211,7 @@ public abstract class MobSpawnEvent extends EntityEvent
|
||||
/**
|
||||
* Returns the current spawn cancellation status, which can be changed via {@link FinalizeSpawn#setSpawnCancelled(boolean)}.
|
||||
* @return If this mob's spawn is cancelled or not.
|
||||
* @implNote This is enforced in {@link ForgeInternalHandler#builtinMobSpawnBlocker} and a patch in {@link WorldGenRegion#addEntity}
|
||||
*/
|
||||
public boolean isSpawnCancelled() {
|
||||
return this.getEntity().isSpawnCancelled();
|
||||
|
||||
Reference in new issue
Block a user