Skip to content

Commit

Permalink
improved old Chest rendering
Browse files Browse the repository at this point in the history
added Beta Hud for <= beta 1.7.3
fixed ViaAprilFools implementation
  • Loading branch information
FlorianMichael committed Mar 5, 2023
1 parent 54494b4 commit dc23ac5
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 174 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.19.3+build.5
loader_version=0.14.14

# viafabricplus
mod_version=1.7.1
mod_version=1.7.2
maven_group=de.florianmichael
archives_base_name=viafabricplus

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes;

import de.florianmichael.viafabricplus.settings.groups.VisualSettings;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.JumpingMount;
import net.minecraft.entity.LivingEntity;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
public abstract class MixinInGameHud {

@Shadow
protected abstract int getHeartCount(LivingEntity entity);

@Shadow
private int scaledWidth;

@Shadow private int scaledHeight;

// Removing newer elements

@Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true)
public void removeExperienceBar(MatrixStack matrices, int x, CallbackInfo ci) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) ci.cancel();
}

@Inject(method = "renderMountJumpBar", at = @At("HEAD"), cancellable = true)
public void removeMountJumpBar(JumpingMount mount, MatrixStack matrices, int x, CallbackInfo ci) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) ci.cancel();
}

@Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true)
public void removeMountHealth(MatrixStack matrices, CallbackInfo ci) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) ci.cancel();
}

@Redirect(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;getHeartCount(Lnet/minecraft/entity/LivingEntity;)I"))
private int removeHungerBar(InGameHud instance, LivingEntity entity) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) return 1;
return getHeartCount(entity);
}

// Moving down all remaining elements

@Redirect(method = "renderStatusBars", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/hud/InGameHud;scaledHeight:I", opcode = Opcodes.GETFIELD))
private int moveHealthDown(InGameHud instance) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) return scaledHeight + 6;
return scaledHeight;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 1)
private int moveArmor(int old) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) return scaledWidth - old - 9;
return old;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 2)
private int moveArmorDown(int old) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) return scaledWidth - 39 + 6;
return old;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/InGameHud;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIIIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 2),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1)
private int moveAir(int old) {
if (VisualSettings.getClassWrapper().removeNewerHudElements.getValue()) return scaledWidth - old - 9;
return old;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import net.minecraft.world.BlockView;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
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;

import java.util.function.Supplier;

Expand All @@ -23,17 +20,11 @@ protected MixinChestBlock(Settings settings, Supplier<BlockEntityType<? extends
super(settings, blockEntityTypeSupplier);
}

@Inject(method = "getOutlineShape", at = @At("HEAD"), cancellable = true)
public void changeShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.r1_4_2)) {
cir.setReturnValue(VoxelShapes.fullCube());
}
}

@Inject(method = "getRenderType", at = @At("HEAD"), cancellable = true)
public void changeRenderType(BlockState state, CallbackInfoReturnable<BlockRenderType> cir) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
cir.setReturnValue(BlockRenderType.MODEL);
return VoxelShapes.fullCube();
}
return super.getCollisionShape(state, world, pos, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -33,9 +34,17 @@ private void injectOnUse(CallbackInfoReturnable<ActionResult> ci) {

@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThan(LegacyProtocolVersion.r1_0_0tor1_0_1)) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
return viafabricplus_fence_shape_b1_8_1;
}
return super.getCollisionShape(state, world, pos, context);
}

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
if (ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
return VoxelShapes.fullCube();
}
return super.getOutlineShape(state, world, pos, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class VisualSettings extends SettingGroup {
// r1_0_0tor1_0_1 -> b1_8tob1_8_1
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, "Replace hurt sound with OOF sound", ProtocolRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1));

// b1_8tob1_8_1 -> b1_7tob1_7_3
public final ProtocolSyncBooleanSetting removeNewerHudElements = new ProtocolSyncBooleanSetting(this, "Remove newer HUD elements", ProtocolRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3));

// a1_0_15 -> c0_28toc0_30
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, "Replace creative inventory", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, "Old walking animation", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
Expand Down
55 changes: 0 additions & 55 deletions src/main/resources/assets/minecraft/blockstates/chest.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 5 additions & 8 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,13 @@
"bridge.MixinConnectScreen",
"bridge.MixinDownloadingTerrainScreen",
"bridge.MixinOptionsScreen",
"fixes.MixinChestBlockEntityRenderer",
"fixes.screen.MixinChatScreen",
"fixes.MixinBipedEntityModel",
"fixes.screen.hud.MixinChatHud",
"fixes.visual.MixinChatScreen",
"fixes.visual.MixinClientPlayerEntity",
"fixes.visual.MixinClientPlayNetworkHandler",
"fixes.MixinInGameHud",
"fixes.MixinItemRenderer",
"fixes.screen.MixinChatScreen",
"fixes.screen.MixinCommandBlockScreen",
"fixes.screen.MixinCreativeInventoryScreen",
"fixes.MixinItemRenderer",
"fixes.screen.MixinJigsawBlockScreen"
"fixes.screen.MixinJigsawBlockScreen",
"fixes.screen.hud.MixinChatHud"
]
}

0 comments on commit dc23ac5

Please sign in to comment.