Monster repeller blocks portal spawns - #7915
Open
Spaghetti-OberNub wants to merge 5 commits into
Open
Conversation
Caedis
requested changes
Sep 3, 2026
…ub.com/GTNewHorizons/GT5-Unofficial into monster-repellent-blocks-portal-spawns
Contributor
Author
|
Just FYI, this was used to test spawning if someone else wants to verify or play around with it. (Warning dirty vibe code) // in GTProxy.java
FMLCommonHandler.instance().bus().register(new SpeedupTickHandler());
// in SpeedupTickHandler.java
package gregtech;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.block.BlockPortal;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
public class SpeedupTickHandler {
private int debugTimer = 0;
@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent event) {
if (event.phase == TickEvent.Phase.START && !event.world.isRemote) {
WorldServer world = (WorldServer) event.world;
debugTimer++;
if (debugTimer >= 20) {
debugTimer = 0;
}
for (Object chunkObj : world.theChunkProviderServer.loadedChunks) {
Chunk chunk = (Chunk) chunkObj;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 256; y++) {
int realX = chunk.xPosition * 16 + x;
int realZ = chunk.zPosition * 16 + z;
if (world.getBlock(realX, y, realZ) instanceof BlockPortal) {
BlockPortal portal = (BlockPortal) world.getBlock(realX, y, realZ);
for (int i = 0; i < 20; i++) {
portal.updateTick(world, realX, y, realZ, world.rand);
}
}
}
}
}
}
}
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Added a static instance for
GTSpawnEventHandler, as well as anisAreaProtected-method to check if mobs should spawn in a portal. The condition is tested in a mixin.This is the first time writing a mixin so please take a short look at it when reviewing. :)
Closes Issue 26004
Checklist
* tested by forcing 20 portal update ticks per tick (see comment)