Skip to content

Commit

Permalink
Implement hardcore buckets tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jan 14, 2023
1 parent fcc922d commit f8032f1
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ All changes are toggleable via the config file.
* Fast Prefix Checking: Optimizes Forge's ID prefix checking and removes prefix warnings impacting load time
* Fence/Wall Jump: Allows the player to jump over fences and walls
* Finite Water: Prevents creation of infinite water sources outside of ocean and river biomes
* Hardcore Buckets: Prevents placing of liquid source blocks in the world
* Horizontal Collision Damage: Applies horizontal collision damage to the player akin to elytra collision
* Husk & Stray Spawning: Lets husks and strays spawn underground like regular zombies and skeletons
* Infinite Music: Lets background music play continuously without delays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ public static class TweaksCategory
@Config.Comment("Maximum time in ms to spend generating chunks per tick per dimension")
public int utChunkGenLimitTime = 5;

@Config.Name("Crafting Cache")
@Config.Name("[Experimental] Crafting Cache")
@Config.Comment("Adds an IRecipe cache to improve recipe performance in large modpacks")
public boolean utCraftingCacheToggle = true;
public boolean utCraftingCacheToggle = false;

@Config.Name("Creeper Confetti")
@Config.Comment("Replaces deadly creeper explosions with delightful confetti")
Expand Down Expand Up @@ -396,6 +396,10 @@ public static class TweaksCategory
@Config.Comment("Prevents creation of infinite water sources outside of ocean and river biomes")
public boolean utFiniteWaterToggle = false;

@Config.Name("Hardcore Buckets")
@Config.Comment("Prevents placing of liquid source blocks in the world")
public boolean utHardcoreBucketsToggle = false;

@Config.Name("Horizontal Collision Damage")
@Config.Comment("Applies horizontal collision damage to the player akin to elytra collision")
public boolean utCollisionDamageToggle = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public List<String> getMixinConfigs()
"mixins.tweaks.creeperconfetti.json",
"mixins.tweaks.dyeblending.json",
"mixins.tweaks.falldamage.json",
"mixins.tweaks.hardcorebuckets.json",
"mixins.tweaks.infinitemusic.json",
"mixins.tweaks.itementity.json",
"mixins.tweaks.lightningflash.json",
Expand Down Expand Up @@ -155,6 +156,7 @@ public List<String> getMixinConfigs()
"mixins.tweaks.creeperconfetti.json",
"mixins.tweaks.dyeblending.json",
"mixins.tweaks.falldamage.json",
"mixins.tweaks.hardcorebuckets.json",
"mixins.tweaks.itementity.json",
"mixins.tweaks.linearxp.json",
"mixins.tweaks.mobdespawn.json",
Expand Down Expand Up @@ -273,13 +275,15 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
case "mixins.tweaks.collisiondamage.json":
return !firstLaunch && UTConfigParser.isEnabled("B:\"Horizontal Collision Damage\"=true");
case "mixins.tweaks.craftingcache.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Crafting Cache\"=true");
return !firstLaunch && UTConfigParser.isEnabled("B:\"Crafting Cache\"=true");
case "mixins.tweaks.creeperconfetti.json":
return !firstLaunch && UTConfigParser.isEnabled("B:\"Creeper Confetti\"=true");
case "mixins.tweaks.dyeblending.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Fast Dye Blending\"=true");
case "mixins.tweaks.falldamage.json":
return !firstLaunch && UTConfigParser.isEnabled("B:\"Water Fall Damage\"=true");
case "mixins.tweaks.hardcorebuckets.json":
return !firstLaunch && UTConfigParser.isEnabled("B:\"Hardcore Buckets\"=true");
case "mixins.tweaks.itementity.json":
return firstLaunch || UTConfigParser.isEnabled("B:\"Item Entity Combination\"=true");
case "mixins.tweaks.linearxp.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package mod.acgaming.universaltweaks.tweaks.hardcorebuckets.mixin;

import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandler;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
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.CallbackInfoReturnable;

@Mixin(value = FluidUtil.class, remap = false)
public class UTFluidUtilMixin
{
@Inject(method = "tryPlaceFluid(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraftforge/fluids/capability/IFluidHandler;Lnet/minecraftforge/fluids/FluidStack;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/SoundEvent;Lnet/minecraft/util/SoundCategory;FF)V"))
private static void utFluidUtil(EntityPlayer player, World world, BlockPos pos, IFluidHandler fluidSource, FluidStack resource, CallbackInfoReturnable<Boolean> cir)
{
if (!UTConfig.tweaks.utHardcoreBucketsToggle) return;
if (UTConfig.debug.utDebugToggle) UniversalTweaks.LOGGER.debug("UTFluidUtil ::: Replace liquid");
try
{
world.setBlockState(pos, resource.getFluid().getBlock().getDefaultState().withProperty(BlockLiquid.LEVEL, 1));
}
catch (Exception ignored) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package mod.acgaming.universaltweaks.tweaks.hardcorebuckets.mixin;

import net.minecraft.block.BlockLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBucket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(ItemBucket.class)
public class UTItemBucketMixin
{
@Redirect(method = "tryPlaceContainedLiquid", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;I)Z"))
public boolean utItemBucket(World world, BlockPos blockPos, IBlockState blockState, int flags)
{
if (!UTConfig.tweaks.utHardcoreBucketsToggle) return world.setBlockState(blockPos, blockState, flags);
if (UTConfig.debug.utDebugToggle) UniversalTweaks.LOGGER.debug("UTItemBucket ::: Place liquid");
try
{
return world.setBlockState(blockPos, blockState.withProperty(BlockLiquid.LEVEL, 1), flags);
}
catch (Exception ignored)
{
return world.setBlockState(blockPos, blockState, flags);
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.hardcorebuckets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.hardcorebuckets.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTFluidUtilMixin", "UTItemBucketMixin"]
}

0 comments on commit f8032f1

Please sign in to comment.