Skip to content

Commit c8731a8

Browse files
committed
sync 1.21.4-0.23.3, update mafglib, update NeoForge version to 21.4.136
1 parent a8cb2cf commit c8731a8

40 files changed

Lines changed: 2717 additions & 0 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package fi.dy.masa.tweakeroo.mixin.entity;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Inject;
6+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
7+
import net.minecraft.client.MinecraftClient;
8+
import net.minecraft.entity.player.PlayerAbilities;
9+
import net.minecraft.entity.player.PlayerEntity;
10+
import fi.dy.masa.tweakeroo.config.Configs;
11+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
12+
13+
@Mixin(PlayerAbilities.class)
14+
public abstract class MixinPlayerAbilities
15+
{
16+
@Inject(method = "getFlySpeed", at = @At("HEAD"), cancellable = true)
17+
private void overrideFlySpeed(CallbackInfoReturnable<Float> cir)
18+
{
19+
PlayerEntity player = MinecraftClient.getInstance().player;
20+
21+
if (FeatureToggle.TWEAK_FLY_SPEED.getBooleanValue() &&
22+
player != null && player.getAbilities().allowFlying)
23+
{
24+
cir.setReturnValue((float) Configs.getActiveFlySpeedConfig().getDoubleValue());
25+
}
26+
}
27+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Inject;
6+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
7+
8+
import net.minecraft.client.gui.DrawContext;
9+
import net.minecraft.client.gui.hud.BossBarHud;
10+
11+
import fi.dy.masa.tweakeroo.config.Configs;
12+
13+
@Mixin(BossBarHud.class)
14+
public abstract class MixinBossBarHud
15+
{
16+
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
17+
private void tweakeroo_disableBossBarRendering(DrawContext drawContext, CallbackInfo ci)
18+
{
19+
if (Configs.Disable.DISABLE_BOSS_BAR.getBooleanValue())
20+
{
21+
ci.cancel();
22+
}
23+
}
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import net.minecraft.client.gui.hud.MessageIndicator;
4+
import net.minecraft.network.message.MessageSignatureData;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
8+
import org.spongepowered.asm.mixin.injection.Redirect;
9+
10+
import net.minecraft.client.gui.DrawContext;
11+
import net.minecraft.client.gui.hud.ChatHud;
12+
import net.minecraft.text.MutableText;
13+
import net.minecraft.text.Text;
14+
15+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
16+
import fi.dy.masa.tweakeroo.util.MiscUtils;
17+
18+
@Mixin(value = ChatHud.class, priority = 1100)
19+
public abstract class MixinChatHud
20+
{
21+
@ModifyVariable(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V",
22+
at = @At("HEAD"), argsOnly = true)
23+
private Text tweakeroo_addMessageTimestamp(Text componentIn, Text parameterMessage, MessageSignatureData data, MessageIndicator indicator)
24+
{
25+
if (FeatureToggle.TWEAK_CHAT_TIMESTAMP.getBooleanValue())
26+
{
27+
MutableText newComponent = Text.literal(MiscUtils.getChatTimestamp() + " ");
28+
newComponent.append(componentIn);
29+
return newComponent;
30+
}
31+
32+
return componentIn;
33+
}
34+
35+
@Redirect(method = "render", at = @At(value = "INVOKE",
36+
target = "Lnet/minecraft/client/gui/DrawContext;fill(IIIII)V", ordinal = 0))
37+
private void overrideChatBackgroundColor(DrawContext drawableHelper, int left, int top, int right, int bottom, int color)
38+
{
39+
if (FeatureToggle.TWEAK_CHAT_BACKGROUND_COLOR.getBooleanValue())
40+
{
41+
color = MiscUtils.getChatBackgroundColor(color);
42+
}
43+
44+
drawableHelper.fill(left, top, right, bottom, color);
45+
}
46+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import java.util.UUID;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import net.minecraft.client.gui.hud.ClientBossBar;
6+
import net.minecraft.entity.boss.BossBar;
7+
import net.minecraft.text.Text;
8+
import fi.dy.masa.tweakeroo.config.Configs;
9+
10+
@Mixin(ClientBossBar.class)
11+
public abstract class MixinClientBossBar extends BossBar
12+
{
13+
public MixinClientBossBar(UUID uniqueIdIn, Text nameIn, BossBar.Color colorIn, BossBar.Style styleIn)
14+
{
15+
super(uniqueIdIn, nameIn, colorIn, styleIn);
16+
}
17+
18+
@Override
19+
public boolean shouldThickenFog()
20+
{
21+
if (Configs.Disable.DISABLE_BOSS_FOG.getBooleanValue())
22+
{
23+
return false;
24+
}
25+
26+
return super.shouldThickenFog();
27+
}
28+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import org.spongepowered.asm.mixin.Final;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.Shadow;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
10+
import net.minecraft.client.MinecraftClient;
11+
import net.minecraft.client.gui.DrawContext;
12+
import net.minecraft.client.gui.hud.InGameHud;
13+
import net.minecraft.client.gui.hud.PlayerListHud;
14+
import net.minecraft.client.render.RenderTickCounter;
15+
import net.minecraft.entity.player.PlayerEntity;
16+
import net.minecraft.scoreboard.Scoreboard;
17+
import net.minecraft.scoreboard.ScoreboardDisplaySlot;
18+
import net.minecraft.scoreboard.ScoreboardObjective;
19+
import fi.dy.masa.tweakeroo.config.Configs;
20+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
21+
import fi.dy.masa.tweakeroo.renderer.RenderUtils;
22+
23+
@Mixin(value = InGameHud.class, priority = 1005)
24+
public abstract class MixinInGameHud
25+
{
26+
@Shadow @Final private PlayerListHud playerListHud;
27+
@Shadow @Final private MinecraftClient client;
28+
29+
@Inject(method = "getCameraPlayer", at = @At("HEAD"), cancellable = true)
30+
private void overridePlayerForRendering(CallbackInfoReturnable<PlayerEntity> cir)
31+
{
32+
// Fix the hotbar rendering in the Free Camera mode by using the actual player
33+
if (FeatureToggle.TWEAK_FREE_CAMERA.getBooleanValue() && this.client.player != null)
34+
{
35+
cir.setReturnValue(this.client.player);
36+
}
37+
}
38+
39+
@Inject(method = "renderCrosshair", at = @At(value = "INVOKE",
40+
target = "Lnet/minecraft/client/gui/hud/DebugHud;shouldShowDebugHud()Z", ordinal = 0), cancellable = true)
41+
private void overrideCursorRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci)
42+
{
43+
if (FeatureToggle.TWEAK_F3_CURSOR.getBooleanValue())
44+
{
45+
RenderUtils.renderDirectionsCursor(context);
46+
ci.cancel();
47+
}
48+
}
49+
50+
@Inject(method = "renderPlayerList",
51+
at = @At(value = "INVOKE",
52+
target = "Lnet/minecraft/client/gui/hud/PlayerListHud;setVisible(Z)V",
53+
ordinal = 1, shift = At.Shift.AFTER))
54+
private void alwaysRenderPlayerList(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci)
55+
{
56+
if (FeatureToggle.TWEAK_PLAYER_LIST_ALWAYS_ON.getBooleanValue())
57+
{
58+
Scoreboard scoreboard = this.client.world.getScoreboard();
59+
ScoreboardObjective objective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.LIST);
60+
61+
this.playerListHud.setVisible(true);
62+
this.playerListHud.render(context, context.getScaledWindowWidth(), scoreboard, objective);
63+
}
64+
}
65+
66+
@Inject(method = "renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/scoreboard/ScoreboardObjective;)V",
67+
at = @At("HEAD"), cancellable = true)
68+
private void disableScoreboardRendering(CallbackInfo ci)
69+
{
70+
if (Configs.Disable.DISABLE_SCOREBOARD_RENDERING.getBooleanValue())
71+
{
72+
ci.cancel();
73+
}
74+
}
75+
76+
@Inject(method = "renderStatusEffectOverlay", at = @At("HEAD"), cancellable = true)
77+
private void disableStatusEffectHudRendering(CallbackInfo ci)
78+
{
79+
if (Configs.Disable.DISABLE_STATUS_EFFECT_HUD.getBooleanValue())
80+
{
81+
ci.cancel();
82+
}
83+
}
84+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import net.minecraft.client.gui.DrawContext;
4+
import net.minecraft.client.gui.screen.ingame.StatusEffectsDisplay;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9+
10+
import fi.dy.masa.tweakeroo.config.Configs;
11+
12+
@Mixin(StatusEffectsDisplay.class)
13+
public abstract class MixinStatusEffectsDisplay
14+
{
15+
private MixinStatusEffectsDisplay()
16+
{
17+
super();
18+
}
19+
20+
@Inject(method = "drawStatusEffects(Lnet/minecraft/client/gui/DrawContext;II)V", at = @At("HEAD"), cancellable = true)
21+
private void disableStatusEffectRendering(DrawContext context, int mouseX, int mouseY, CallbackInfo ci)
22+
{
23+
if (Configs.Disable.DISABLE_INVENTORY_EFFECTS.getBooleanValue())
24+
{
25+
ci.cancel();
26+
}
27+
}
28+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package fi.dy.masa.tweakeroo.mixin.hud;
2+
3+
import java.util.Collection;
4+
import java.util.Comparator;
5+
import java.util.List;
6+
import org.spongepowered.asm.mixin.Final;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Mutable;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
13+
import net.minecraft.client.gui.hud.spectator.SpectatorMenuCommand;
14+
import net.minecraft.client.gui.hud.spectator.TeleportSpectatorMenu;
15+
import net.minecraft.client.gui.hud.spectator.TeleportToSpecificPlayerSpectatorCommand;
16+
import net.minecraft.client.network.PlayerListEntry;
17+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
18+
19+
@Mixin(TeleportSpectatorMenu.class)
20+
public abstract class MixinTeleportSpectatorMenu
21+
{
22+
@Shadow @Final private static Comparator<PlayerListEntry> ORDERING;
23+
@Shadow @Final @Mutable private List<SpectatorMenuCommand> elements;
24+
25+
@Inject(method = "<init>(Ljava/util/Collection;)V", at = @At("RETURN"))
26+
private void allowSpectatorTeleport(Collection<PlayerListEntry> profiles, CallbackInfo ci)
27+
{
28+
if (FeatureToggle.TWEAK_SPECTATOR_TELEPORT.getBooleanValue())
29+
{
30+
this.elements = profiles.stream().sorted(ORDERING).map(
31+
entry -> (SpectatorMenuCommand) new TeleportToSpecificPlayerSpectatorCommand(entry.getProfile())).toList();
32+
}
33+
}
34+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package fi.dy.masa.tweakeroo.mixin.input;
2+
3+
import java.util.Collection;
4+
import java.util.Collections;
5+
import java.util.Locale;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Unique;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.Inject;
10+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11+
import net.minecraft.client.MinecraftClient;
12+
import net.minecraft.client.network.ClientCommandSource;
13+
import net.minecraft.command.CommandSource;
14+
import net.minecraft.util.hit.HitResult;
15+
import net.minecraft.util.math.BlockPos;
16+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
17+
18+
@Mixin(ClientCommandSource.class)
19+
public abstract class MixinClientCommandSource
20+
{
21+
@Inject(method = "getBlockPositionSuggestions", at = @At("HEAD"), cancellable = true)
22+
private void onGetBlockPositionSuggestions(CallbackInfoReturnable<Collection<CommandSource.RelativePosition>> cir)
23+
{
24+
MinecraftClient mc = MinecraftClient.getInstance();
25+
26+
if (FeatureToggle.TWEAK_TAB_COMPLETE_COORDINATE.getBooleanValue() &&
27+
mc.player != null && (mc.crosshairTarget == null || mc.crosshairTarget.getType() == HitResult.Type.MISS))
28+
{
29+
BlockPos pos = fi.dy.masa.malilib.util.PositionUtils.getEntityBlockPos(mc.player);
30+
cir.setReturnValue(Collections.singleton(new CommandSource.RelativePosition(formatInt(pos.getX()), formatInt(pos.getY()), formatInt(pos.getZ()))));
31+
}
32+
}
33+
34+
@Inject(method = "getPositionSuggestions", at = @At("HEAD"), cancellable = true)
35+
private void onGetPositionSuggestions(CallbackInfoReturnable<Collection<CommandSource.RelativePosition>> cir)
36+
{
37+
MinecraftClient mc = MinecraftClient.getInstance();
38+
39+
if (FeatureToggle.TWEAK_TAB_COMPLETE_COORDINATE.getBooleanValue() &&
40+
mc.player != null && (mc.crosshairTarget == null || mc.crosshairTarget.getType() == HitResult.Type.MISS))
41+
{
42+
cir.setReturnValue(Collections.singleton(new CommandSource.RelativePosition(formatDouble(mc.player.getX()), formatDouble(mc.player.getY()), formatDouble(mc.player.getZ()))));
43+
}
44+
}
45+
46+
@Unique
47+
private static String formatDouble(double val)
48+
{
49+
return String.format(Locale.ROOT, "%.2f", val);
50+
}
51+
52+
@Unique
53+
private static String formatInt(int val)
54+
{
55+
return Integer.toString(val);
56+
}
57+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fi.dy.masa.tweakeroo.mixin.input;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Redirect;
6+
7+
import net.minecraft.server.command.CloneCommand;
8+
import net.minecraft.world.GameRules;
9+
import net.minecraft.world.GameRules.IntRule;
10+
import net.minecraft.world.GameRules.Key;
11+
12+
import fi.dy.masa.tweakeroo.config.Configs;
13+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
14+
15+
@Mixin(value = CloneCommand.class, priority = 999)
16+
public abstract class MixinCloneCommand
17+
{
18+
@Redirect(method = "execute", require = 0,
19+
at = @At(value = "INVOKE",
20+
target = "Lnet/minecraft/world/GameRules;getInt(Lnet/minecraft/world/GameRules$Key;)I"))
21+
private static int tweakeroo_overrideBlockLimit(GameRules instance, Key<IntRule> rule)
22+
{
23+
if (FeatureToggle.TWEAK_FILL_CLONE_LIMIT.getBooleanValue())
24+
{
25+
return Configs.Generic.FILL_CLONE_LIMIT.getIntegerValue();
26+
}
27+
28+
return instance.getInt(rule);
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package fi.dy.masa.tweakeroo.mixin.input;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
import org.spongepowered.asm.mixin.injection.At;
5+
import org.spongepowered.asm.mixin.injection.Redirect;
6+
7+
import net.minecraft.server.command.FillCommand;
8+
import net.minecraft.world.GameRules;
9+
import net.minecraft.world.GameRules.IntRule;
10+
import net.minecraft.world.GameRules.Key;
11+
12+
import fi.dy.masa.tweakeroo.config.Configs;
13+
import fi.dy.masa.tweakeroo.config.FeatureToggle;
14+
15+
@Mixin(value = FillCommand.class, priority = 1001)
16+
public abstract class MixinFillCommand
17+
{
18+
@Redirect(method = "execute", require = 0,
19+
at = @At(value = "INVOKE",
20+
target = "Lnet/minecraft/world/GameRules;getInt(Lnet/minecraft/world/GameRules$Key;)I"))
21+
private static int tweakeroo_overrideBlockLimit(GameRules instance, Key<IntRule> rule)
22+
{
23+
if (FeatureToggle.TWEAK_FILL_CLONE_LIMIT.getBooleanValue())
24+
{
25+
return Configs.Generic.FILL_CLONE_LIMIT.getIntegerValue();
26+
}
27+
28+
return instance.getInt(rule);
29+
}
30+
}

0 commit comments

Comments
 (0)