generated from Fallen-Breath/fabric-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added mc tweak
movingPistonBlockSelectable
- Loading branch information
1 parent
476a25a
commit a0c236c
Showing
10 changed files
with
273 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...kermore/impl/mc_tweaks/movingPistonBlockSelectable/MovingPistonBlockSelectableHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* This file is part of the TweakerMore project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* TweakerMore is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* TweakerMore is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package me.fallenbreath.tweakermore.impl.mc_tweaks.movingPistonBlockSelectable; | ||
|
||
public class MovingPistonBlockSelectableHelper | ||
{ | ||
public static boolean enabled = false; | ||
public static final ThreadLocal<Boolean> applyOutlineShapeOverride = ThreadLocal.withInitial(() -> false); | ||
} |
87 changes: 87 additions & 0 deletions
87
...th/tweakermore/mixins/tweaks/mc_tweaks/movingPistonBlockSelectable/GameRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* This file is part of the TweakerMore project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* TweakerMore is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* TweakerMore is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.movingPistonBlockSelectable; | ||
|
||
import com.llamalad7.mixinextras.sugar.Share; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; | ||
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; | ||
import me.fallenbreath.tweakermore.impl.mc_tweaks.movingPistonBlockSelectable.MovingPistonBlockSelectableHelper; | ||
import net.minecraft.client.render.GameRenderer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
|
||
//#if MC >= 12006 | ||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
//#else | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
//#endif | ||
|
||
@Mixin(GameRenderer.class) | ||
public abstract class GameRendererMixin | ||
{ | ||
@Inject( | ||
//#if MC >= 12006 | ||
//$$ method = "findCrosshairTarget", | ||
//#else | ||
method = "updateTargetedEntity", | ||
//#endif | ||
at = @At("HEAD") | ||
) | ||
private void movingPistonBlockSelectable_clientCrosshairTargetUpdate_start( | ||
//#if MC >= 12006 | ||
//$$ CallbackInfoReturnable<?> cir, | ||
//#else | ||
CallbackInfo ci, | ||
//#endif | ||
@Share("") LocalBooleanRef hasSet | ||
) | ||
{ | ||
if (TweakerMoreConfigs.MOVING_PISTON_BLOCK_SELECTABLE.getBooleanValue()) | ||
{ | ||
MovingPistonBlockSelectableHelper.applyOutlineShapeOverride.set(true); | ||
hasSet.set(true); | ||
} | ||
} | ||
|
||
@Inject( | ||
//#if MC >= 12006 | ||
//$$ method = "findCrosshairTarget", | ||
//#else | ||
method = "updateTargetedEntity", | ||
//#endif | ||
at = @At("TAIL") | ||
) | ||
private void movingPistonBlockSelectable_clientCrosshairTargetUpdate_end( | ||
//#if MC >= 12006 | ||
//$$ CallbackInfoReturnable<?> cir, | ||
//#else | ||
CallbackInfo ci, | ||
//#endif | ||
@Share("") LocalBooleanRef hasSet | ||
) | ||
{ | ||
if (hasSet.get()) | ||
{ | ||
MovingPistonBlockSelectableHelper.applyOutlineShapeOverride.set(false); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...ermore/mixins/tweaks/mc_tweaks/movingPistonBlockSelectable/PistonExtensionBlockMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of the TweakerMore project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* TweakerMore is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* TweakerMore is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.movingPistonBlockSelectable; | ||
|
||
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; | ||
import me.fallenbreath.tweakermore.impl.mc_tweaks.movingPistonBlockSelectable.MovingPistonBlockSelectableHelper; | ||
import net.minecraft.block.PistonExtensionBlock; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.util.shape.VoxelShapes; | ||
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(PistonExtensionBlock.class) | ||
public abstract class PistonExtensionBlockMixin | ||
{ | ||
@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true) | ||
private void movingPistonBlockSelectable_modifyOutlineShapeToFullCube(CallbackInfoReturnable<VoxelShape> cir) | ||
{ | ||
// Add a check to avoid the TweakerMoreConfigs class being loaded too early (e.g. at Blocks.<clinit>) | ||
// since TweakerMoreConfigs.<clinit> might require accessing MinecraftClient.getInstance() | ||
if (MovingPistonBlockSelectableHelper.enabled) | ||
{ | ||
if (TweakerMoreConfigs.MOVING_PISTON_BLOCK_SELECTABLE.getBooleanValue() && MovingPistonBlockSelectableHelper.applyOutlineShapeOverride.get()) | ||
{ | ||
cir.setReturnValue(VoxelShapes.fullCube()); | ||
} | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...h/tweakermore/mixins/tweaks/mc_tweaks/movingPistonBlockSelectable/WorldRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This file is part of the TweakerMore project, licensed under the | ||
* GNU Lesser General Public License v3.0 | ||
* | ||
* Copyright (C) 2024 Fallen_Breath and contributors | ||
* | ||
* TweakerMore is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* TweakerMore is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.movingPistonBlockSelectable; | ||
|
||
import com.llamalad7.mixinextras.sugar.Share; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; | ||
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs; | ||
import me.fallenbreath.tweakermore.impl.mc_tweaks.movingPistonBlockSelectable.MovingPistonBlockSelectableHelper; | ||
import net.minecraft.client.render.WorldRenderer; | ||
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; | ||
|
||
@Mixin(WorldRenderer.class) | ||
public abstract class WorldRendererMixin | ||
{ | ||
@Inject( | ||
//#if MC >= 11500 | ||
method = "drawBlockOutline", | ||
//#else | ||
//$$ method = "drawHighlightedBlockOutline", | ||
//#endif | ||
at = @At("HEAD") | ||
) | ||
private void movingPistonBlockSelectable_blockOutlineRender_start(CallbackInfo ci, @Share("") LocalBooleanRef hasSet) | ||
{ | ||
if (TweakerMoreConfigs.MOVING_PISTON_BLOCK_SELECTABLE.getBooleanValue()) | ||
{ | ||
MovingPistonBlockSelectableHelper.applyOutlineShapeOverride.set(true); | ||
hasSet.set(true); | ||
} | ||
} | ||
|
||
@Inject( | ||
//#if MC >= 11500 | ||
method = "drawBlockOutline", | ||
//#else | ||
//$$ method = "drawHighlightedBlockOutline", | ||
//#endif | ||
at = @At("TAIL") | ||
) | ||
private void movingPistonBlockSelectable_blockOutlineRender_end(CallbackInfo ci, @Share("") LocalBooleanRef hasSet) | ||
{ | ||
if (hasSet.get()) | ||
{ | ||
MovingPistonBlockSelectableHelper.applyOutlineShapeOverride.set(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters