Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Compact Machines tweak to properly control mob spawn checks #540

Merged
merged 4 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ All changes are toggleable via config files.
* **Memory Leak Fix:** Fixes memory leak when unloading worlds/switching dimensions
* **Compact Machines**
* **Invisible Wall Render Fix:** Fixes some compact machine walls being invisible if [Nothirium](https://www.curseforge.com/minecraft/mc-mods/nothirium) 0.2.x (and up) or [Vintagium](https://github.com/Asek3/sodium-1.12) is installed
* **Allowed Spawns Improvement:** Improves server performance by properly controlling spawn checks (effectiveness depends on CM's config)
* **Effortless Building**
* **Block Transmutation Fix:** Fixes Effortless Building ignoring Metadata when checking for items in inventory
* **Elementary Staffs**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,16 @@ public static class CompactMachinesCoreCategory
@Config.Name("Invisible Wall Render Fix")
@Config.Comment("Fixes some compact machine walls being invisible if Nothirium 0.2.x (and up) or Vintagium is installed")
public boolean utCMRenderFixToggle = true;

@Config.RequiresMcRestart
@Config.Name("Allowed Spawns Improvement")
@Config.Comment
({
"Improves server performance by properly controlling spawn checks (effectiveness depends on CM's config)",
"Disable both 'allowHostileSpawns' and 'allowPeacefulSpawns' in the CM config for best performance",
"Does nothing if both config values are true"
})
public boolean utAllowedSpawnsImprovementToggle = true;
}

public static class EffortlessBuildingCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UTMixinLoader implements ILateMixinLoader
{
{
put("mixins.mods.cbmultipart.client.json", () -> loaded("forgemultipartcbe") && UTConfigMods.CB_MULTIPART.utMemoryLeakFixToggle);
put("mixins.mods.compactmachines.json", () -> loaded("compactmachines3") && UTConfigMods.COMPACT_MACHINES.utCMRenderFixToggle);
put("mixins.mods.compactmachines.render.json", () -> loaded("compactmachines3") && UTConfigMods.COMPACT_MACHINES.utCMRenderFixToggle);
put("mixins.mods.crafttweaker.json", () -> loaded("crafttweaker"));
put("mixins.mods.hwyla.json", () -> loaded("waila"));
put("mixins.mods.modularrouters.json", () -> loaded("modularrouters") && UTConfigMods.MODULAR_ROUTERS.utParticleThreadToggle);
Expand Down Expand Up @@ -51,6 +51,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins.mods.codechickenlib.json", () -> loaded("codechickenlib") && UTConfigMods.CCL.utPacketLeakFixToggle);
put("mixins.mods.cofhcore.json", () -> loaded("cofhcore"));
put("mixins.mods.collective.json", () -> loaded("collective"));
put("mixins.mods.compactmachines.spawns.json", () -> loaded("compactmachines3") && UTConfigMods.COMPACT_MACHINES.utAllowedSpawnsImprovementToggle);
put("mixins.mods.cqrepoured.json", () -> loaded("cqrepoured"));
put("mixins.mods.effortlessbuilding.json", () -> loaded("effortlessbuilding"));
put("mixins.mods.elementarystaffs.json", () -> loaded("element"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mod.acgaming.universaltweaks.mods.compactmachines.mixin;
package mod.acgaming.universaltweaks.mods.compactmachines.render.mixin;

import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package mod.acgaming.universaltweaks.mods.compactmachines.spawns.mixin;

import java.util.Collections;
import java.util.List;

import net.minecraft.entity.EnumCreatureType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;

import org.dave.compactmachines3.misc.ConfigurationHandler;
import org.dave.compactmachines3.world.ChunkGeneratorMachines;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;

// Courtesy of jchung01
@Mixin(value = ChunkGeneratorMachines.class)
public class UTChunkGeneratorMachinesMixin
{
@Shadow(remap = false)
@Final
private World world;

/**
* Another spot the CM config should control spawns; here for redundancy.
* @reason Control mob spawn based on type
* @author jchung01
*/
@Overwrite
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos)
{
if ((creatureType.getPeacefulCreature() && ConfigurationHandler.MachineSettings.allowPeacefulSpawns) ||
(!creatureType.getPeacefulCreature() && ConfigurationHandler.MachineSettings.allowHostileSpawns))
{
return this.world.getBiome(pos).getSpawnableList(creatureType);
}
else return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package mod.acgaming.universaltweaks.mods.compactmachines.spawns.mixin;

import net.minecraft.world.WorldProvider;

import org.dave.compactmachines3.misc.ConfigurationHandler;
import org.dave.compactmachines3.world.WorldProviderMachines;
import org.spongepowered.asm.mixin.Mixin;

// Courtesy of jchung01
@Mixin(value = WorldProviderMachines.class)
public abstract class UTWorldProviderMachinesMixin extends WorldProvider
{
/**
* Let CM config set allowed spawns when the dim loads.
* This helps server performance especially when both hostile and peaceful spawns are disabled.
*/
@Override
public void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful)
{
super.setAllowedSpawnTypes(ConfigurationHandler.MachineSettings.allowHostileSpawns, ConfigurationHandler.MachineSettings.allowPeacefulSpawns);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class UTObsoleteModsHandler
put("bannerpatch", () -> UTConfigBugfixes.BLOCKS.utBannerBoundingBoxToggle);
put("bedbreakbegone", () -> UTConfigTweaks.BLOCKS.utBedObstructionToggle);
put("bedfix", () -> UTConfigTweaks.ENTITIES.SLEEPING.utSleepingTime != -1);
put("bedpatch", () -> true); // Fix integrated in Forge 14.23.2.2643 (#4784)
put("bedsaynosleep", () -> UTConfigTweaks.ENTITIES.SLEEPING.utDisableSleepingToggle);
put("betterburning", () -> UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBArrowsToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBCookedToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBExtinguishToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBOverlayToggle || UTConfigTweaks.ENTITIES.BETTER_BURNING.utBBSpreadingToggle);
put("betterpingdisplay", () -> UTConfigTweaks.MISC.utBetterPing);
Expand Down Expand Up @@ -158,7 +159,7 @@ public static List<String> obsoleteModsMessage()
}

// Mods checked by class
if (UTReflectionUtil.isClassLoaded("com.chocohead.biab.BornInABarn")) messages.add("Born in a Barn");
if (UTReflectionUtil.isClassLoaded("com.chocohead.biab.BornInABarn")) messages.add("Born in a Barn"); // Fix integrated in Forge 14.23.2.2623 (#4689)
if (UTReflectionUtil.isClassLoaded("io.github.jikuja.LocaleTweaker") && UTConfigBugfixes.MISC.utLocaleToggle) messages.add("LocaleFixer");
if (UTReflectionUtil.isClassLoaded("com.cleanroommc.blockdelayremover.BlockDelayRemoverCore") && UTConfigTweaks.BLOCKS.utBlockHitDelay != 5) messages.add("Block Delay Remover");
if (UTReflectionUtil.isClassLoaded("io.github.barteks2x.chunkgenlimiter.ChunkGenLimitMod") && UTConfigTweaks.WORLD.CHUNK_GEN_LIMIT.utChunkGenLimitToggle) messages.add("Chunk Generation Limiter");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.compactmachines.mixin",
"package": "mod.acgaming.universaltweaks.mods.compactmachines.render.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTCubeToolsMixin"]
"client": ["UTCubeToolsMixin"]
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.compactmachines.spawns.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.compactmachines.spawns.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTChunkGeneratorMachinesMixin", "UTWorldProviderMachinesMixin"]
}