Skip to content

Commit b53b543

Browse files
committed
add some more features!
1 parent 2f3b4d4 commit b53b543

14 files changed

Lines changed: 261 additions & 12 deletions

File tree

src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
public class OldAnimations implements ClientModInitializer {
2929

3030
/*
31-
blocks item positions (rotations)
31+
blocks item positions (rotations) + trapdoors + pressure plates
32+
pressure plates look a bit different?? idk why THEYRE BIGGER THATS WHY
3233
third person item positions toggle?
33-
half blocks toggle?
34-
add fast grass
34+
old fence fate model
35+
move sprint keybind option in controls menu
3536
*/
3637

3738
public static final String MODID = "axolotlclient-oldanimations";

src/main/java/io/github/axolotlclient/oldanimations/config/OldAnimationsConfig.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,21 @@ public class OldAnimationsConfig {
104104
public final BooleanOption swordBlockThirdPerson = new BooleanOption("swordBlockThirdPerson", true);
105105
public final BooleanOption useAndMineDestroyVisual = new BooleanOption("useAndMineDestroyVisual", false);
106106
public final BooleanOption fastGrass = new BooleanOption("fastGrass", false);
107+
public final BooleanOption oldDoorTextures = new BooleanOption("oldDoorTextures", false);
108+
public final BooleanOption oldDifficultyButtonLogic = new BooleanOption("oldDifficultyButtonLogic", false);
109+
public final BooleanOption moveSprintKeybind = new BooleanOption("moveSprintKeybind", false);
107110

108111
private final Supplier<Boolean>[] suppliers = new Supplier[] {
112+
enabled::get,
109113
replaceSkullModel::get,
110-
fastGrass::get
114+
fastGrass::get,
115+
oldDoorTextures::get
111116
};
112117
private final boolean[] previousStates = {
118+
enabled.get(),
113119
replaceSkullModel.get(),
114-
fastGrass.get()
120+
fastGrass.get(),
121+
oldDoorTextures.get()
115122
};
116123

117124
public static boolean isEnabled() {
@@ -150,6 +157,7 @@ public void initConfig() {
150157
stopLineTranslateSneak,
151158
equipLogic,
152159
replaceSkullModel,
160+
oldDoorTextures,
153161
disableResourcePackItemTransformations,
154162
fixThirdPersonHeldItemSneakDeSync
155163
);
@@ -171,6 +179,8 @@ public void initConfig() {
171179
disableUnknownServerIcon,
172180
disableSkinCustomizationButton,
173181
oldMultiplayerSettingsPage,
182+
oldDifficultyButtonLogic,
183+
moveSprintKeybind,
174184
disableTitles
175185
);
176186
categoryGUI.add(categoryDebugOverlay);

src/main/java/io/github/axolotlclient/oldanimations/mixin/ClientPlayNetworkHandlerMixin.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@
1919
package io.github.axolotlclient.oldanimations.mixin;
2020

2121
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
22+
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
2223
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
24+
import net.minecraft.client.Minecraft;
2325
import net.minecraft.client.network.handler.ClientPlayNetworkHandler;
26+
import net.minecraft.client.options.GameOptions;
2427
import net.minecraft.network.packet.s2c.play.TitlesS2CPacket;
28+
import net.minecraft.world.Difficulty;
2529
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.Shadow;
2631
import org.spongepowered.asm.mixin.injection.At;
2732
import org.spongepowered.asm.mixin.injection.Inject;
2833
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2934

3035
@Mixin(ClientPlayNetworkHandler.class)
3136
public abstract class ClientPlayNetworkHandlerMixin {
3237

38+
@Shadow
39+
private Minecraft minecraft;
40+
3341
@ModifyExpressionValue(method = "handleAddXpOrb", at = @At(value = "CONSTANT", args = "doubleValue=32"))
3442
private double ornitheAnimations$oldOrbRendering(double original) {
3543
return original / (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.xpOrbPosition.get() ?
@@ -50,4 +58,10 @@ public abstract class ClientPlayNetworkHandlerMixin {
5058
ci.cancel();
5159
}
5260
}
61+
62+
@WrapWithCondition(method = "handleLogin", at = @At(value = "FIELD", target = "Lnet/minecraft/client/options/GameOptions;difficulty:Lnet/minecraft/world/Difficulty;"))
63+
private boolean axolotlclient$dontUsePacketDifficulty(GameOptions instance, Difficulty value) {
64+
/* we're going to set the options difficulty elsewhere, so let's remove this as it's not needed */
65+
return !OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.oldDifficultyButtonLogic.get();
66+
}
5367
}

src/main/java/io/github/axolotlclient/oldanimations/mixin/HeldItemLayerMixin.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import net.minecraft.item.Item;
3434
import net.minecraft.item.ItemStack;
3535
import net.minecraft.item.Items;
36+
import net.minecraft.text.LiteralText;
3637
import org.spongepowered.asm.mixin.Mixin;
3738
import org.spongepowered.asm.mixin.Unique;
3839
import org.spongepowered.asm.mixin.injection.*;
@@ -74,7 +75,8 @@ public abstract class HeldItemLayerMixin {
7475
@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getRenderType()I"))
7576
private int axolotlclient$disableBlockTypeCheck(Block instance, Operation<Integer> original) {
7677
/* we need to stop these transformations from applying */
77-
return areItemPositionsEnabled() ? 3 : original.call(instance);
78+
//TODO: Fix this
79+
return areItemPositionsEnabled() && OldAnimationsConfig.instance.disableResourcePackItemTransformations.get() ? 3 : original.call(instance);
7880
}
7981

8082
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/HeldItemRenderer;render(Lnet/minecraft/entity/living/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/block/ModelTransformations$Type;)V"))
@@ -92,6 +94,7 @@ public abstract class HeldItemLayerMixin {
9294
}
9395
if (OldAnimationsConfig.instance.itemPositions.get()) {
9496
if (item instanceof BlockItem && Minecraft.getInstance().getItemRenderer().isGui3d(itemStack)) {
97+
if (!OldAnimationsConfig.instance.disableResourcePackItemTransformations.get() && Block.byItem(item).getRenderType() == 2) return;
9598
var7 = 0.375F;
9699
GlStateManager.translatef(0.0F, 0.1875F, -0.3125F);
97100
GlStateManager.rotatef(20.0F, 1.0F, 0.0F, 0.0F);

src/main/java/io/github/axolotlclient/oldanimations/mixin/ItemRendererMixin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.mojang.blaze3d.platform.GlStateManager;
2626
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
2727
import io.github.axolotlclient.oldanimations.util.*;
28+
import net.minecraft.block.Block;
2829
import net.minecraft.client.Minecraft;
2930
import net.minecraft.client.render.item.ItemRenderer;
3031
import net.minecraft.client.render.model.block.ModelTransformations;
@@ -237,6 +238,7 @@ public abstract class ItemRendererMixin {
237238
/* fortnite, we need to talk... */
238239
Item item = itemStack.getItem();
239240
if (item instanceof BlockItem && Minecraft.getInstance().getItemRenderer().isGui3d(itemStack)) {
241+
if (Block.byItem(item).getRenderType() == 2) return;
240242
scale = 1.0F / 0.375F;
241243
GlStateManager.scalef(scale, scale, scale);
242244
GlStateManager.rotatef(-170.0F, 0.0F, 0.0F, 1.0F);
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 3 of the License, or (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU Lesser General Public License
13+
* along with this program; if not, write to the Free Software Foundation,
14+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15+
*
16+
* For more information, see the LICENSE file.
17+
*/
18+
19+
package io.github.axolotlclient.oldanimations.mixin;
20+
21+
import com.llamalad7.mixinextras.sugar.Local;
22+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
23+
import net.minecraft.client.options.KeyBinding;
24+
import org.spongepowered.asm.mixin.Mixin;
25+
import org.spongepowered.asm.mixin.injection.At;
26+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
27+
28+
@Mixin(KeyBinding.class)
29+
public class KeyBindingMixin {
30+
31+
@ModifyVariable(method = "<init>", at = @At(value = "LOAD", ordinal = 0), index = 3, argsOnly = true)
32+
private static String axolotlclient$changeKeyBindingCategory(
33+
String original,
34+
@Local(ordinal = 0, index = 1, argsOnly = true) String string,
35+
@Local(ordinal = 0, index = 2, argsOnly = true) int i
36+
) {
37+
/* honestly this is a very silly injection, but idk a better way */
38+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.moveSprintKeybind.get() &&
39+
"key.sprint".equals(string) && i == 29 && "key.categories.movement".equals(original)) {
40+
return "key.categories.gameplay";
41+
}
42+
return original;
43+
}
44+
}

src/main/java/io/github/axolotlclient/oldanimations/mixin/ModelBakeryMixin.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ public abstract class ModelBakeryMixin {
9191
}
9292
}
9393
}
94+
95+
//TODO: This could probably be rewritten
96+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDoorTextures.get()) {
97+
/* we just need to swap out the textures lmaooo */
98+
String path = identifier.getPath();
99+
if ("models/item/iron_door.json".equals(path)) {
100+
BlockModelAccessor model = (BlockModelAccessor) original;
101+
model.getTextures().put("layer0", "items/old_door_iron");
102+
}
103+
if ("models/item/oak_door.json".equals(path)) {
104+
BlockModelAccessor model = (BlockModelAccessor) original;
105+
model.getTextures().put("layer0", "items/old_door_wood");
106+
}
107+
}
94108
return original;
95109
}
96110
}

src/main/java/io/github/axolotlclient/oldanimations/mixin/OptionsScreenMixin.java

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,42 @@
1818

1919
package io.github.axolotlclient.oldanimations.mixin;
2020

21+
import com.llamalad7.mixinextras.expression.Expression;
2122
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
2223
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
24+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
25+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
2326
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
27+
import net.minecraft.client.gui.screen.Screen;
2428
import net.minecraft.client.gui.screen.options.OptionsScreen;
29+
import net.minecraft.client.gui.widget.ButtonWidget;
30+
import net.minecraft.client.options.GameOptions;
31+
import net.minecraft.client.resource.language.I18n;
32+
import net.minecraft.client.world.ClientWorld;
33+
import net.minecraft.world.Difficulty;
2534
import org.objectweb.asm.Opcodes;
35+
import org.spongepowered.asm.mixin.Final;
2636
import org.spongepowered.asm.mixin.Mixin;
37+
import org.spongepowered.asm.mixin.Shadow;
2738
import org.spongepowered.asm.mixin.injection.At;
39+
import org.spongepowered.asm.mixin.injection.Inject;
40+
import org.spongepowered.asm.mixin.injection.ModifyArg;
41+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2842

2943
import java.util.List;
3044

3145
@Mixin(OptionsScreen.class)
32-
public class OptionsScreenMixin {
46+
public abstract class OptionsScreenMixin extends Screen {
47+
48+
@Shadow
49+
@Final
50+
private GameOptions options;
51+
52+
@Shadow
53+
private ButtonWidget difficultyButton;
54+
55+
@Shadow
56+
public abstract String getButtonLabel(Difficulty difficulty);
3357

3458
@WrapWithCondition(method = "init", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 5))
3559
private <E> boolean axolotlclient$disableSkinCustomizationButton(List<?> instance, E e) {
@@ -43,9 +67,81 @@ public class OptionsScreenMixin {
4367
return OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldMultiplayerSettingsPage.get() ? "options.multiplayer.title" : original;
4468
}
4569

46-
@ModifyExpressionValue(method = "buttonClicked", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/gui/widget/ButtonWidget;id:I", ordinal = 4))
47-
private int axolotlclient$disableSkinCustomizationButton2(int original) {
48-
/* disables the functionality of the skin customization button */
49-
return OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.disableSkinCustomizationButton.get() ? -1 : original;
70+
@Inject(method = "buttonClicked", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/gui/widget/ButtonWidget;id:I", ordinal = 2))
71+
private void axolotlclient$onlySetIfInWorld(ButtonWidget buttonWidget, CallbackInfo ci) {
72+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.disableSkinCustomizationButton.get() && minecraft.world == null && buttonWidget.id == 108) {
73+
/* this is so silly... but the alternatives are not fun :p */
74+
options.difficulty = Difficulty.byId(options.difficulty.getId() + 1 & 3);
75+
difficultyButton.message = getButtonLabel(options.difficulty);
76+
}
77+
}
78+
79+
@ModifyExpressionValue(method = "buttonClicked", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/gui/widget/ButtonWidget;id:I", ordinal = 2))
80+
private int axolotlclient$onlySetIfInWorld(int original) {
81+
/* because we're going to be able to toggle this button while not in a world, we can avoid the game crashing by */
82+
/* checking if the world is valid before we set the difficulty */
83+
return OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.disableSkinCustomizationButton.get() && minecraft.world == null ? -1 : original;
84+
}
85+
86+
@ModifyArg(method = "buttonClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/Difficulty;byId(I)Lnet/minecraft/world/Difficulty;"), index = 0)
87+
private int axolotlclient$useOptionsDifficulty(int i) {
88+
/* use the options difficulty */
89+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get()) {
90+
return options.difficulty.getId() + 1 & 3;
91+
}
92+
return i;
93+
}
94+
95+
@Inject(method = "buttonClicked", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/options/OptionsScreen;getButtonLabel(Lnet/minecraft/world/Difficulty;)Ljava/lang/String;"))
96+
private void axolotlclient$updateOptionsDifficulty(ButtonWidget buttonWidget, CallbackInfo ci) {
97+
/* update the options difficulty */
98+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get()) {
99+
options.difficulty = Difficulty.byId(options.difficulty.getId() + 1 & 3);
100+
}
101+
}
102+
103+
@WrapOperation(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;getDifficulty()Lnet/minecraft/world/Difficulty;"))
104+
private Difficulty axolotlclient$tryNotToCrashGame(ClientWorld instance, Operation<Difficulty> original) {
105+
/* if we don't do this, our game will crash as no valid world is loaded */
106+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get()) {
107+
return options.difficulty;
108+
}
109+
return original.call(instance);
110+
}
111+
112+
@Expression("? != null")
113+
@ModifyExpressionValue(method = "init", at = @At(value = "MIXINEXTRAS:EXPRESSION", ordinal = 0))
114+
private boolean axolotlclient$skipRealmsNotificationButton(boolean original) {
115+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get()) {
116+
/* now, the realms notification button will never be rendered. */
117+
/* unfortunately, this was the only injection i could think of to get this feature out in a compatible manner */
118+
return true;
119+
}
120+
return original;
121+
}
122+
123+
@ModifyExpressionValue(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isInSingleplayer()Z"))
124+
private boolean axolotlclient$skipLockedDifficultyRendering(boolean original) {
125+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get()) {
126+
/* we might as well skip over this to reduce the amount of work needed to replicate the old difficulty button */
127+
return false;
128+
}
129+
return original;
130+
}
131+
132+
@WrapWithCondition(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;active:Z", ordinal = 1))
133+
private boolean axolotlclient$disableActiveState(ButtonWidget instance, boolean value) {
134+
/* you were a pawn */
135+
return !OldAnimationsConfig.isEnabled() || !OldAnimationsConfig.instance.oldDifficultyButtonLogic.get();
136+
}
137+
138+
@Inject(method = "init", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/widget/ButtonWidget;active:Z", ordinal = 1))
139+
private void axolotlclient$addHardcoreState(CallbackInfo ci) {
140+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get() &&
141+
minecraft.world != null && minecraft.world.getData().isHardcore()) {
142+
/* because we basically overwrote the original hardcore button code, we should add this :p */
143+
difficultyButton.active = false;
144+
difficultyButton.message = I18n.translate("options.difficulty") + ": " + I18n.translate("options.difficulty.hardcore");
145+
}
50146
}
51147
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or
3+
* modify it under the terms of the GNU Lesser General Public
4+
* License as published by the Free Software Foundation; either
5+
* version 3 of the License, or (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
* Lesser General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU Lesser General Public License
13+
* along with this program; if not, write to the Free Software Foundation,
14+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15+
*
16+
* For more information, see the LICENSE file.
17+
*/
18+
19+
package io.github.axolotlclient.oldanimations.mixin;
20+
21+
import com.mojang.authlib.GameProfile;
22+
import io.github.axolotlclient.oldanimations.config.OldAnimationsConfig;
23+
import net.minecraft.client.Minecraft;
24+
import net.minecraft.entity.living.player.PlayerEntity;
25+
import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket;
26+
import net.minecraft.server.MinecraftServer;
27+
import net.minecraft.server.entity.living.player.ServerPlayerEntity;
28+
import net.minecraft.world.World;
29+
import org.spongepowered.asm.mixin.Final;
30+
import org.spongepowered.asm.mixin.Mixin;
31+
import org.spongepowered.asm.mixin.Shadow;
32+
import org.spongepowered.asm.mixin.injection.At;
33+
import org.spongepowered.asm.mixin.injection.Inject;
34+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
35+
36+
@Mixin(ServerPlayerEntity.class)
37+
public abstract class ServerPlayerEntityMixin extends PlayerEntity {
38+
39+
@Shadow
40+
@Final
41+
public MinecraftServer server;
42+
43+
public ServerPlayerEntityMixin(World world, GameProfile gameProfile) {
44+
super(world, gameProfile);
45+
}
46+
47+
@Inject(method = "updateSettings", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/data/DataTracker;update(ILjava/lang/Object;)V"))
48+
private void axolotlclient$syncDifficulty(ClientSettingsC2SPacket clientSettingsC2SPacket, CallbackInfo ci) {
49+
if (OldAnimationsConfig.isEnabled() && OldAnimationsConfig.instance.oldDifficultyButtonLogic.get() &&
50+
server.isSingleplayer() && server.getUsername().equals(getName())) {
51+
/* every time a singleplayer world loads, the difficulty will be updated with the options difficulty */
52+
server.setDifficulty(Minecraft.getInstance().options.difficulty);
53+
}
54+
}
55+
}

src/main/java/io/github/axolotlclient/oldanimations/util/ItemUtil.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public final class ItemUtil {
3737
public static boolean isThinBlockItem(ItemStack stack) {
3838
if (stack != null) {
3939
final Block block = Block.byItem(stack.getItem());
40+
/* i fr thought pressure plates and trapdoors were affected by this.. i was wrong */
41+
//TODO: FIX THIS
4042
return block instanceof CarpetBlock ||
4143
block instanceof TrapdoorBlock || block instanceof PressurePlateBlock ||
4244
block instanceof SnowLayerBlock || block instanceof DaylightDetectorBlock;

0 commit comments

Comments
 (0)