Skip to content

Commit

Permalink
Implement Disable Sleeping Setting Spawn tweak
Browse files Browse the repository at this point in the history
Closes #578
  • Loading branch information
ACGaming committed Oct 28, 2024
1 parent 0d1d736 commit 2462c1a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.entities.sleeping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.entities.sleeping.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTSleepingMixin"]
}

0 comments on commit 2462c1a

Please sign in to comment.