Skip to content

Commit

Permalink
Fix zombie appearing in 40 blocks range near the XU spikes (#155)
Browse files Browse the repository at this point in the history
* Fix zombie appearing in 40 blocks range near the XU spikes

Co-authored-by: Andrey <[email protected]>
Co-authored-by: Jason Mitchell <[email protected]>
  • Loading branch information
TimeConqueror and mitchej123 authored Jan 8, 2023
1 parent ca4994d commit 6cc4598
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/Hodgepodge.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraftforge.common.MinecraftForge;

@Mod(
modid = Hodgepodge.MODID,
Expand All @@ -20,13 +21,15 @@
dependencies = "required-after:gtnhmixins@[2.0.1,);")
public class Hodgepodge {
public static final AnchorAlarm ANCHOR_ALARM = new AnchorAlarm();
public static final HodgepodgeEventHandler EVENT_HANDLER = new HodgepodgeEventHandler();
public static final String MODID = "hodgepodge";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String NAME = "A Hodgepodge of Patches";

@EventHandler
public void preinit(FMLPreInitializationEvent event) {
Compat.init(event.getSide());
MinecraftForge.EVENT_BUS.register(EVENT_HANDLER);
}

@EventHandler
Expand All @@ -44,5 +47,9 @@ public void postInit(FMLPostInitializationEvent event) {
@EventHandler
public void onServerStarting(FMLServerStartingEvent aEvent) {
aEvent.registerServerCommand(new DebugCommand());

// needed in case ExtraUtilities' Spike was crashed (and game was switched to a main menu), so it didn't update
// the variable
EVENT_HANDLER.setAidTriggerDisabled(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.mitchej123.hodgepodge;

import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.event.entity.living.ZombieEvent;

public class HodgepodgeEventHandler {
private boolean xuDisableAidTrigger;

@SubscribeEvent
public void onZombieAidSummon(ZombieEvent.SummonAidEvent event) {
if (!event.world.isRemote && xuDisableAidTrigger) {
event.setResult(Event.Result.DENY);
}
}

public void setAidTriggerDisabled(boolean disableAidTrigger) {
xuDisableAidTrigger = disableAidTrigger;
}
}
5 changes: 4 additions & 1 deletion src/main/java/com/mitchej123/hodgepodge/LoadingConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public class LoadingConfig {
public boolean enableTileRendererProfiler;
public boolean pollutionAsm;

public boolean disableAidSpawnByXUSpikes;

public String thermosCraftServerClass;

public static Configuration config;
Expand Down Expand Up @@ -241,7 +243,8 @@ public LoadingConfig(File file) {
furnacesPollute = config.get(Category.POLLUTION.toString(), "furnacesPollute", true, "Make furnaces Pollute").getBoolean();
rocketsPollute = config.get(Category.POLLUTION.toString(), "rocketsPollute", true, "Make rockets Pollute").getBoolean();
railcraftPollutes = config.get(Category.POLLUTION.toString(), "railcraftPollutes", true, "Make Railcraft Pollute").getBoolean();


disableAidSpawnByXUSpikes = config.get(Category.TWEAKS.toString(), "disableAidSpawnByXUSpikes", true, "Disables the spawn of zombie aid when zombie is killed by Extra Utilities Spikes, since it can spawn them too far.").getBoolean();

furnacePollutionAmount = config.get(Category.POLLUTION.toString(), "furnacePollution", 20, "Furnace pollution per second, min 1!", 1, Integer.MAX_VALUE).getInt();
fireboxPollutionAmount = config.get(Category.POLLUTION.toString(), "fireboxPollution", 15, "Pollution Amount for RC Firebox", 1, Integer.MAX_VALUE).getInt();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,13 @@ public enum Mixins {
.addMixinClasses("galacticraftcore.MixinGalacticraftRocketPollution")
.setSide(Side.BOTH)
.setApplyIf(() -> Common.config.rocketsPollute)
.addTargetedMod(TargetedMod.GALACTICRAFT_CORE));
.addTargetedMod(TargetedMod.GALACTICRAFT_CORE)),
DISABLE_AID_SPAWN_XU_SPIKES(
new Builder("Fixes the vanilla zombie aid spawn triggering when killed by Extra Utilities Spikes")
.addMixinClasses("extrautilities.MixinBlockSpike")
.setSide(Side.BOTH)
.setApplyIf(() -> Common.config.disableAidSpawnByXUSpikes)
.addTargetedMod(TargetedMod.EXTRA_UTILITIES));

public final String name;
public final List<String> mixinClasses;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.mitchej123.hodgepodge.mixins.late.extrautilities;

import com.mitchej123.hodgepodge.Hodgepodge;
import com.rwtema.extrautils.block.BlockSpike;
import com.rwtema.extrautils.block.BlockSpikeDiamond;
import com.rwtema.extrautils.block.BlockSpikeGold;
import com.rwtema.extrautils.block.BlockSpikeWood;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = {BlockSpike.class, BlockSpikeDiamond.class, BlockSpikeGold.class, BlockSpikeWood.class})
public abstract class MixinBlockSpike {

@Inject(
method = "onEntityCollidedWithBlock(Lnet/minecraft/world/World;IIILnet/minecraft/entity/Entity;)V",
at = @At("HEAD"))
public void onEntityCollidedWithBlockStart(World world, int x, int y, int z, Entity target, CallbackInfo ci) {
if (!world.isRemote) {
Hodgepodge.EVENT_HANDLER.setAidTriggerDisabled(true);
}
}

@Inject(
method = "onEntityCollidedWithBlock(Lnet/minecraft/world/World;IIILnet/minecraft/entity/Entity;)V",
at = @At("RETURN"))
public void onEntityCollidedWithBlockEnd(World world, int x, int y, int z, Entity target, CallbackInfo ci) {
if (!world.isRemote) {
Hodgepodge.EVENT_HANDLER.setAidTriggerDisabled(false);
}
}
}

0 comments on commit 6cc4598

Please sign in to comment.