Skip to content

Commit

Permalink
Piston Retraction Bugfix
Browse files Browse the repository at this point in the history
-MC-88959
  • Loading branch information
IcarussOne committed Jan 20, 2024
1 parent ded3daa commit 06d8786
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ All changes are toggleable via config files.
* **Packet Size:** Increases the packet size limit to account for large packets in modded environments
* **Particle Spawning:** Fixes various particle types not showing up on the client
* **Piston Progress:** Properly saves the last state of pistons to tags
* **Piston Retraction:** Improves retraction behavior on double piston extenders
* **Portal Traveling Dupe:** Fixes duplication issues that can occur when entities travel through portals
* **Potion Amplifier Visibility:** Fixes potion effects not displaying their level above 'IV'
* **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package mod.acgaming.universaltweaks.bugfixes.blocks.piston.pistonretraction.mixin;

import static net.minecraft.block.BlockPistonBase.EXTENDED;

import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import mod.acgaming.universaltweaks.UniversalTweaks;
import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import org.objectweb.asm.Opcodes;
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.CallbackInfo;

// MC-88959
// https://bugs.mojang.com/browse/MC-88959
// Courtesy of mrgrim
@Mixin(BlockPistonBase.class)
public abstract class UTPistonBaseBlockMixin
{
@Inject(method = "checkForMove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addBlockEvent(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;II)V", ordinal = 1))
private void onPistonDepower(World worldIn, BlockPos pos, IBlockState state, CallbackInfo ci)
{
if (UTConfigBugfixes.BLOCKS.utPistonRetractionToggle)
{
worldIn.setBlockState(pos, state.withProperty(EXTENDED, false), 2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public static class BlocksCategory
@Config.Name("Piston Progress")
@Config.Comment("Properly saves the last state of pistons to tags")
public boolean utPistonTileToggle = true;

@Config.RequiresMcRestart
@Config.Name("Piston Retraction")
@Config.Comment("Improves retraction behavior on double piston extenders")
public boolean utPistonRetractionToggle = true;

@Config.RequiresMcRestart
@Config.Name("Sleep Resets Weather")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.bugfixes.blocks.ladderflying.json");
configs.add("mixins.bugfixes.blocks.miningglitch.server.json");
configs.add("mixins.bugfixes.blocks.pistontile.json");
configs.add("mixins.bugfixes.blocks.pistontile.pistonretraction.json");
configs.add("mixins.bugfixes.entities.ai.json");
configs.add("mixins.bugfixes.entities.attackradius.json");
configs.add("mixins.bugfixes.entities.blockfire.json");
Expand Down Expand Up @@ -336,6 +337,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfigBugfixes.BLOCKS.utMiningGlitchToggle;
case "mixins.bugfixes.blocks.pistontile.json":
return UTConfigBugfixes.BLOCKS.utPistonTileToggle;
case "mixins.bugfixes.blocks.pistontile.pistonretraction.json":
return UTConfigBugfixes.BLOCKS.utPistonRetractionToggle;
case "mixins.bugfixes.blocks.bed.json":
return UTConfigBugfixes.BLOCKS.utSleepResetsWeatherToggle;
case "mixins.bugfixes.misc.enchantment.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.bugfixes.blocks.piston.pistonretraction.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTPistonBaseBlockMixin"]
}

0 comments on commit 06d8786

Please sign in to comment.