Skip to content

Commit

Permalink
Added mc tweak movingPistonBlockSelectable
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 14, 2024
1 parent 476a25a commit a0c236c
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/document-en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,17 @@ The maximum height of the chat hud
- Maximum value: `1000`


### movingPistonBlockSelectable

Make the moving piston block (b36) selectable, so you can interact with it easily

The outline shape of a moving piston block will be set to a full cube

- Category: MC Tweaks
- Type: boolean (Generic)
- Default value: `false`


### multiplayerForcedEnabled

Make the multiplayer functionality of Minecraft forced enabled
Expand Down
11 changes: 11 additions & 0 deletions docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,17 @@ FOV覆盖的开关
- 最大值: `1000`


### 移动的活塞可被选择 (movingPistonBlockSelectable)

让移动的活塞(b36)可被选中,这样就可以方便地把它破坏掉了

移动的活塞的outline shape将被统一设置为完整方块

- 分类: MC修改
- 类型: 布尔值 (通用)
- 默认值: `false`


### 强制启用多人游戏 (multiplayerForcedEnabled)

令Minecraft的多人游戏功能始终可用
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import me.fallenbreath.tweakermore.impl.features.schematicProPlace.ProPlaceImpl;
import me.fallenbreath.tweakermore.impl.features.spectatorTeleportCommand.SpectatorTeleportCommand;
import me.fallenbreath.tweakermore.impl.mc_tweaks.flawlessFrames.FlawlessFramesHandler;
import me.fallenbreath.tweakermore.impl.mc_tweaks.movingPistonBlockSelectable.MovingPistonBlockSelectableHelper;
import me.fallenbreath.tweakermore.impl.mc_tweaks.particleLimit.ParticleLimitHelper;
import me.fallenbreath.tweakermore.impl.mc_tweaks.windowSize.WindowSizeHelper;
import me.fallenbreath.tweakermore.impl.mod_tweaks.eCraftMassCraftCompact.EasierCraftingRegistrar;
Expand Down Expand Up @@ -533,6 +534,9 @@ public class TweakerMoreConfigs
@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigInteger MAX_CHAT_HUD_HEIGHT = newConfigInteger("maxChatHudHeight", 160, 160, 1000);

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean MOVING_PISTON_BLOCK_SELECTABLE = newConfigBoolean("movingPistonBlockSelectable", false);

@Config(type = Config.Type.GENERIC, restriction = @Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = ">=1.16")), category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean MULTIPLAYER_FORCED_ENABLED = newConfigBoolean("multiplayerForcedEnabled", false);

Expand Down Expand Up @@ -951,6 +955,7 @@ public static void initConfigs()

CONTAINER_PROCESSOR_HINT.setCommentModifier(AutoContainerProcessorHintRenderer::modifyComment);
SCHEMATIC_PRO_PLACE.setCommentModifier(ProPlaceImpl::modifyComment);
MovingPistonBlockSelectableHelper.enabled = true;
}

private static void setHotkeyCallback(TweakerMoreConfigHotkey configHotkey, Runnable runnable, boolean cancelFurtherProcess)
Expand Down
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);
}
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);
}
}
}
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());
}
}
}
}
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);
}
}
}
5 changes: 5 additions & 0 deletions src/main/resources/assets/tweakermore/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ tweakermore:
maxChatHudHeight:
.: maxChatHudHeight
comment: The maximum height of the chat hud
movingPistonBlockSelectable:
.: movingPistonBlockSelectable
comment: |-
Make the moving piston block (b36) selectable, so you can interact with it easily
The outline shape of a moving piston block will be set to a full cube
multiplayerForcedEnabled:
.: multiplayerForcedEnabled
comment: |-
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/assets/tweakermore/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ tweakermore:
maxChatHudHeight:
.: 最大聊天界面高度
comment: 聊天界面高度的最大值
movingPistonBlockSelectable:
.: 移动的活塞可被选择
comment: |-
让移动的活塞(b36)可被选中,这样就可以方便地把它破坏掉了
移动的活塞的outline shape将被统一设置为完整方块
multiplayerForcedEnabled:
.: 强制启用多人游戏
comment: |-
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/tweakermore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@
"tweaks.mc_tweaks.disableTiltViewWhenHurt.GameRendererMixin",
"tweaks.mc_tweaks.disableVignetteDarkness.InGameHudMixin",
"tweaks.mc_tweaks.f3BEntityFacingVectorLength.EntityRenderDispatcherMixin",
"tweaks.mc_tweaks.f3GSimplify.ChunkBorderDebugRendererMixin",
"tweaks.mc_tweaks.f3IUseRelatedCoordinate.KeyboardMixin",
"tweaks.mc_tweaks.f3TextScale.DebugHudMixin",
"tweaks.mc_tweaks.fakeNightVision.GameRendererMixin",
"tweaks.mc_tweaks.fakeNightVision.LivingEntityMixin",
"tweaks.mc_tweaks.fixChestMirroring.ChestBlockMixin",
Expand All @@ -132,6 +134,9 @@
"tweaks.mc_tweaks.keepMessageHistoryOnReconfiguration.MinecraftClientMixin",
"tweaks.mc_tweaks.legacyF3NLogic.KeyboardMixin",
"tweaks.mc_tweaks.maxChatHudHeight.ChatHudMixin",
"tweaks.mc_tweaks.movingPistonBlockSelectable.GameRendererMixin",
"tweaks.mc_tweaks.movingPistonBlockSelectable.PistonExtensionBlockMixin",
"tweaks.mc_tweaks.movingPistonBlockSelectable.WorldRendererMixin",
"tweaks.mc_tweaks.multiplayerForcedEnabled.MinecraftClientMixin",
"tweaks.mc_tweaks.nameTagRenderStrategy.EntityRendererMixin",
"tweaks.mc_tweaks.netherPortalSoundChance.NetherPortalBlockMixin",
Expand Down Expand Up @@ -222,8 +227,6 @@
"util.render.TextHandlerAccessor"
],
"client": [
"tweaks.mc_tweaks.f3GSimplify.ChunkBorderDebugRendererMixin",
"tweaks.mc_tweaks.f3TextScale.DebugHudMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit a0c236c

Please sign in to comment.