diff --git a/README.md b/README.md index 38a7f346..b4a62454 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index 0286ea84..d88b7441 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -403,6 +403,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 diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index 39079fd4..af75bb3a 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -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); @@ -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")); diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/mixin/UTCubeToolsMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/render/mixin/UTCubeToolsMixin.java similarity index 98% rename from src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/mixin/UTCubeToolsMixin.java rename to src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/render/mixin/UTCubeToolsMixin.java index 5b818097..0bcfe633 100644 --- a/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/mixin/UTCubeToolsMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/render/mixin/UTCubeToolsMixin.java @@ -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; diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTChunkGeneratorMachinesMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTChunkGeneratorMachinesMixin.java new file mode 100644 index 00000000..616513fe --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTChunkGeneratorMachinesMixin.java @@ -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 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(); + } +} diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTWorldProviderMachinesMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTWorldProviderMachinesMixin.java new file mode 100644 index 00000000..eb86a1a7 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/compactmachines/spawns/mixin/UTWorldProviderMachinesMixin.java @@ -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); + } +} diff --git a/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java b/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java index 37f88113..0c9f3e3a 100644 --- a/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java +++ b/src/main/java/mod/acgaming/universaltweaks/util/compat/UTObsoleteModsHandler.java @@ -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); @@ -158,7 +159,7 @@ public static List 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"); diff --git a/src/main/resources/mixins.mods.compactmachines.json b/src/main/resources/mixins.mods.compactmachines.render.json similarity index 77% rename from src/main/resources/mixins.mods.compactmachines.json rename to src/main/resources/mixins.mods.compactmachines.render.json index b64c8c7b..69b2941f 100644 --- a/src/main/resources/mixins.mods.compactmachines.json +++ b/src/main/resources/mixins.mods.compactmachines.render.json @@ -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"] } \ No newline at end of file diff --git a/src/main/resources/mixins.mods.compactmachines.spawns.json b/src/main/resources/mixins.mods.compactmachines.spawns.json new file mode 100644 index 00000000..82c7d9e7 --- /dev/null +++ b/src/main/resources/mixins.mods.compactmachines.spawns.json @@ -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"] +} \ No newline at end of file