Skip to content

Commit

Permalink
compat mc1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 5, 2024
1 parent cebddc6 commit 85f9467
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 25 deletions.
5 changes: 4 additions & 1 deletion docs/document-en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ So the block state can be restored when you place blocks with the picked item
- Category: Features
- Type: hotkey with switch (Hotkey)
- Default value: `LEFT_ALT`
- Mod restrictions:
- Required mods:
- Minecraft (`minecraft`) `<1.21.4`


### fireworkRocketThrottler
Expand Down Expand Up @@ -1147,7 +1150,7 @@ Make the following client-side entity targeting stuffs being able to select all

2. Client-side command suggestion with target entity UUID

3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks
3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks (MC < 1.21.4)

Example use cases:

Expand Down
5 changes: 4 additions & 1 deletion docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ TweakerMore提供的新功能
- 分类: 功能
- 类型: 带开关热键 (热键)
- 默认值: `LEFT_ALT`
- 模组约束:
- 依赖模组:
- Minecraft (`minecraft`) `<1.21.4`


### 烟花火箭限速器 (fireworkRocketThrottler)
Expand Down Expand Up @@ -1143,7 +1146,7 @@ schematicBlockPlacement的严格模式

2. 客户端指令补全中的实体UUID选项

3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体
3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体 (MC < 1.21.4)

用法举例:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public class TweakerMoreConfigs
@Config(type = Config.Type.HOTKEY, category = Config.Category.FEATURES)
public static final TweakerMoreConfigHotkey COPY_SIGN_TEXT_TO_CLIPBOARD = newConfigHotKey("copySignTextToClipBoard", "");

@Config(type = Config.Type.HOTKEY, category = Config.Category.FEATURES)
@Config(type = Config.Type.HOTKEY, restriction = @Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = "<1.21.4")), category = Config.Category.FEATURES)
public static final TweakerMoreConfigHotkeyWithSwitch CREATIVE_PICK_BLOCK_WITH_STATE = newConfigHotKeyWithSwitch("creativePickBlockWithState", false, "LEFT_ALT", KeybindSettings.MODIFIER_INGAME);

@Config(type = Config.Type.TWEAK, category = Config.Category.FEATURES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
package me.fallenbreath.tweakermore.mixins.tweaks.features.creativePickBlockWithState;

import fi.dy.masa.malilib.util.InfoUtils;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.util.ModIds;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
Expand All @@ -44,6 +47,7 @@
//$$ import java.util.Map;
//#endif

@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = "<1.21.4"))
@Mixin(MinecraftClient.class)
public abstract class MinecraftClientMixin
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private HitResult clientEntityTargetingSelectAll_hackPickItem_replaceHitResult(H
return crosshairTarget;
}

//#if MC >= 11700
//#if MC >= 12104
//$$ // now it's done on the serverside, we can't perform any tweak on this anymore :(
//#elseif MC >= 11700
//$$ @ModifyExpressionValue(
//$$ method = "doItemPick",
//$$ at = @At(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.disableSignTextLengthLimit;
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import me.fallenbreath.tweakermore.util.ModIds;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.ModifyArg;

//#if MC >= 12104
//$$ import net.minecraft.client.render.block.entity.AbstractSignBlockEntityRenderer;
//#else
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
//#endif

//#if MC < 11500
//$$ import me.fallenbreath.tweakermore.impl.mc_tweaks.disableSignTextLengthLimit.SignOverflowHintDrawer;
Expand All @@ -28,23 +42,20 @@
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//$$ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
//#endif
import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import me.fallenbreath.tweakermore.util.ModIds;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Restriction(conflict = {
@Condition(value = ModIds.caxton, versionPredicates = "<0.3.0-beta.2")
//#if MC < 11500
//$$ , @Condition(ModIds.optifine)
//#endif
})
@Mixin(SignBlockEntityRenderer.class)
@Mixin(
//#if MC >= 12104
//$$ AbstractSignBlockEntityRenderer.class
//#else
SignBlockEntityRenderer.class
//#endif
)
public abstract class SignBlockEntityRendererMixin
{
@SuppressWarnings("UnresolvedMixinReference")
Expand All @@ -55,9 +66,11 @@ public abstract class SignBlockEntityRendererMixin
// render (MC < 11903)
// renderText (MC >= 11903)

//#if MC >= 11903
// TODO: update optifine name in mc1.19.3+
//#if MC >= 12104
//$$ "method_65819", // vanilla
//#elseif MC >= 11903
//$$ "method_45799", // vanilla
//$$ "lambda$render$2" // after being polluted by optifine (TODO fix the method name in optifine environment)
//#elseif MC >= 11700
//$$ "method_32159", // vanilla
//$$ "lambda$render$2" // after being polluted by optifine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

/**
* < mc1.21.3: subproject 1.15.2 (main project) <--------
* >= mc1.21.4: subproject 1.21.4
*/
@Mixin(PlayerSkinTexture.class)
public abstract class PlayerSkinTextureMixin
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@
public abstract class ItemEntityRendererMixin
{
@ModifyExpressionValue(
//#if MC >= 12006
//#if MC >= 12104
//$$ method = "renderStack",
//#elseif MC >= 12006
//$$ method = "renderStack(Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/BakedModel;ZLnet/minecraft/util/math/random/Random;)V",
//#elseif MC >= 11500
method = "render(Lnet/minecraft/entity/ItemEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
//#else
//$$ method = "method_3997",
//#endif
at = @At(
//#if MC >= 12104
//$$ value = "FIELD",
//$$ target = "Lnet/minecraft/client/render/entity/state/ItemStackEntityRenderState;renderedAmount:I"
//#else
value = "INVOKE",
//#if MC >= 12006
//$$ target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;getRenderedAmount(I)I"
//#else
target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;getRenderedAmount(Lnet/minecraft/item/ItemStack;)I"
//#endif
//#endif // if MC >= 12104
)
)
private
Expand Down Expand Up @@ -193,7 +200,9 @@ private float preciseItemEntityModel_tweakItemEntityRotation(
//#endif
at = @At(
value = "INVOKE",
//#if MC >= 12006
//#if MC >= 12104
//$$ target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;renderStack(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/ItemStackEntityRenderState;Lnet/minecraft/util/math/random/Random;)V"
//#elseif MC >= 12006
//$$ target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;renderStack(Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/BakedModel;ZLnet/minecraft/util/math/random/Random;)V"
//#elseif MC >= 11904
//$$ target = "Lnet/minecraft/client/render/item/ItemRenderer;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V"
Expand Down Expand Up @@ -222,7 +231,9 @@ private void preciseItemEntityModel_transformOverrideOn(CallbackInfo ci)
//#endif
at = @At(
value = "INVOKE",
//#if MC >= 12006
//#if MC >= 12104
//$$ target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;renderStack(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/ItemStackEntityRenderState;Lnet/minecraft/util/math/random/Random;)V",
//#elseif MC >= 12006
//$$ target = "Lnet/minecraft/client/render/entity/ItemEntityRenderer;renderStack(Lnet/minecraft/client/render/item/ItemRenderer;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/BakedModel;ZLnet/minecraft/util/math/random/Random;)V",
//#elseif MC >= 11904
//$$ target = "Lnet/minecraft/client/render/item/ItemRenderer;renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,30 @@
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import me.fallenbreath.tweakermore.impl.mc_tweaks.preciseItemEntityModel.PreciseItemEntityModelUtils;
import me.fallenbreath.tweakermore.util.ModIds;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.json.Transformation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

//#if MC >= 12104
//$$ import net.minecraft.client.render.item.ItemRenderState;
//#else
import net.minecraft.client.render.item.ItemRenderer;
//#endif

@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = ">=1.15"))
@Mixin(ItemRenderer.class)
@Mixin(
//#if MC >= 12104
//$$ ItemRenderState.LayerRenderState.class
//#else
ItemRenderer.class
//#endif
)
public abstract class ItemRendererMixin
{
@ModifyExpressionValue(
//#if MC >= 12103
//#if MC >= 12104
//$$ method = "render",
//#elseif MC >= 12103
//$$ method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;ZF)V",
//#elseif MC >= 11904
//$$ method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V",
Expand All @@ -46,7 +59,9 @@ public abstract class ItemRendererMixin
//#endif
at = @At(
value = "INVOKE",
//#if MC >= 12103
//#if MC >= 12104
//$$ target = "Lnet/minecraft/client/render/item/ItemRenderState$LayerRenderState;getTransformation()Lnet/minecraft/client/render/model/json/Transformation;"
//#elseif MC >= 12103
//$$ target = "Lnet/minecraft/client/render/model/json/ModelTransformation;getTransformation(Lnet/minecraft/item/ModelTransformationMode;)Lnet/minecraft/client/render/model/json/Transformation;"
//#elseif MC >= 11904
//$$ target = "Lnet/minecraft/client/render/model/json/ModelTransformation;getTransformation(Lnet/minecraft/client/render/model/json/ModelTransformationMode;)Lnet/minecraft/client/render/model/json/Transformation;"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/tweakermore/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ tweakermore:
Make the following client-side entity targeting stuffs being able to select all types of entities:
1. F3 + I entity data querying
2. Client-side command suggestion with target entity UUID
3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks
3. Mouse middle-click item picking. Supports picking items, xp orbs and falling blocks (MC < 1.21.4)
Example use cases:
1. Get a /summon command for an item entity (F3 + I)
2. Enter /kill and tab-suggested a projectile entity (UUID suggestion)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/tweakermore/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ tweakermore:
令下述客户端实体选择的功能可以选中所有类型的实体:
1. F3 + I 实体数据查询
2. 客户端指令补全中的实体UUID选项
3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体
3. 鼠标中键物品提取。支持提取物品实体、经验球实体和重力方块实体 (MC < 1.21.4)
用法举例:
1. 获取一个物品实体对应的/summon指令 (F3 + I)
2. 输入/kill然后tab补全面前的投掷物实体(UUID补全)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 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.features.creativePickBlockWithState;

import me.fallenbreath.conditionalmixin.api.annotation.Condition;
import me.fallenbreath.conditionalmixin.api.annotation.Restriction;
import me.fallenbreath.tweakermore.util.ModIds;
import me.fallenbreath.tweakermore.util.mixin.DummyClass;
import org.spongepowered.asm.mixin.Mixin;

/**
* Does not work in mc1.21.4+ anymore, since now the pick block action is done on the server-side, not the client-side
*/
@Restriction(require = @Condition(value = ModIds.minecraft, versionPredicates = "<1.21.4"))
@Mixin(DummyClass.class)
public abstract class MinecraftClientMixin
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.playerSkinBlockingLoading;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import me.fallenbreath.tweakermore.impl.mc_tweaks.playerSkinBlockingLoading.TaskSynchronizer;
import net.minecraft.client.texture.PlayerSkinTextureDownloader;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import java.util.concurrent.CompletableFuture;

/**
* < mc1.21.3: subproject 1.15.2 (main project)
* >= mc1.21.4: subproject 1.21.4 <--------
*/
@Mixin(PlayerSkinTextureDownloader.class)
public abstract class PlayerSkinTextureMixin
{
@ModifyExpressionValue(
method = "downloadAndRegisterTexture",
at = @At(
value = "INVOKE",
target = "Ljava/util/concurrent/CompletableFuture;supplyAsync(Ljava/util/function/Supplier;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;"
)
)
private static CompletableFuture<Identifier> playerSkinBlockingLoading_blockingTextureDownloading(CompletableFuture<Identifier> future)
{
if (TweakerMoreConfigs.PLAYER_SKIN_BLOCKING_LOADING.getBooleanValue())
{
future = TaskSynchronizer.createSyncedFuture(future);
}
return future;
}
}

0 comments on commit 85f9467

Please sign in to comment.