diff --git a/README.md b/README.md index 18b79576..019ed4c5 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ All changes are toggleable via config files. * **Disable Glint Overlay on Enchantment Books:** Disables the glint overlay on enchantment books * **Disable Glint Overlay on Potions:** Disables the glint overlay on potions * **Disable Sleeping:** Disables skipping night by using a bed while making it still able to set spawn +* **Disable Sleeping Setting Spawn:** Disables setting the spawn point by using a bed while making it still able to sleep * **Disable Text Shadowing:** Disables all text shadowing, where text has a darker version of itself rendered behind the normal text, changing the appearance and can improve fps on some screens * **Disable Villager Trade Leveling:** Disables leveling of villager careers, only allowing base level trades * **Disable Villager Trade Restock:** Disables restocking of villager trades, only allowing one trade per offer diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index 4381cd45..6e380ad9 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -858,6 +858,11 @@ public static class SleepingCategory @Config.Comment("Disables skipping night by using a bed while making it still able to set spawn") public boolean utDisableSleepingToggle = false; + @Config.RequiresMcRestart + @Config.Name("Disable Sleeping Setting Spawn") + @Config.Comment("Disables setting the spawn point by using a bed while making it still able to sleep") + public boolean utDisableSettingSpawnToggle = false; + @Config.Name("Sleeping Time") @Config.RangeInt(min = -1, max = 23999) @Config.Comment diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index a07dc5b3..fb3a9170 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -111,6 +111,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader put("mixins.tweaks.entities.loot.json", () -> UTConfigTweaks.ENTITIES.utCreeperMusicDiscsToggle); put("mixins.tweaks.entities.minecart.json", () -> UTConfigTweaks.ENTITIES.utMinecartDropsType); put("mixins.tweaks.entities.saturation.json", () -> UTConfigTweaks.ENTITIES.utRidingExhaustion != 0.0D); + put("mixins.tweaks.entities.sleeping.json", () -> UTConfigTweaks.ENTITIES.SLEEPING.utDisableSettingSpawnToggle); put("mixins.tweaks.entities.spawning.caps.json", () -> UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle); put("mixins.tweaks.entities.spawning.creeper.confetti.json", () -> UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiChance != 0.0D); put("mixins.tweaks.entities.spawning.golem.json", () -> UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGIronGolemToggle || UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGSnowGolemToggle || UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGWitherToggle); diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/sleeping/mixin/UTSleepingMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/sleeping/mixin/UTSleepingMixin.java new file mode 100644 index 00000000..ed4b67ef --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/sleeping/mixin/UTSleepingMixin.java @@ -0,0 +1,22 @@ +package mod.acgaming.universaltweaks.tweaks.entities.sleeping.mixin; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import mod.acgaming.universaltweaks.UniversalTweaks; +import mod.acgaming.universaltweaks.config.UTConfigGeneral; +import mod.acgaming.universaltweaks.config.UTConfigTweaks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(EntityPlayer.class) +public class UTSleepingMixin +{ + @WrapWithCondition(method = "wakeUpPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;setSpawnPoint(Lnet/minecraft/util/math/BlockPos;Z)V")) + public boolean utSleepingSpawn(EntityPlayer player, BlockPos pos, boolean forced) + { + if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTSleepingSpawn ::: Sleeping set spawn point"); + return !UTConfigTweaks.ENTITIES.SLEEPING.utDisableSettingSpawnToggle; + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.tweaks.entities.sleeping.json b/src/main/resources/mixins.tweaks.entities.sleeping.json new file mode 100644 index 00000000..310f5142 --- /dev/null +++ b/src/main/resources/mixins.tweaks.entities.sleeping.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.entities.sleeping.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTSleepingMixin"] +} \ No newline at end of file