improved old Chest rendering

added Beta Hud for <= beta 1.7.3
fixed ViaAprilFools implementation
This commit is contained in:
FlorianMichael 2023-03-05 22:17:53 +01:00
parent 54494b4362
commit dc23ac56eb
18 changed files with 102 additions and 174 deletions

View File

@ -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

View File

@ -1,25 +0,0 @@
package de.florianmichael.viafabricplus.injection.mixin.fixes;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.LidOpenable;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.ChestBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
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.CallbackInfo;
// Copyright Gaming32 - LICENSE_GENERAL_MIT file
@Mixin(ChestBlockEntityRenderer.class)
public class MixinChestBlockEntityRenderer<T extends BlockEntity & LidOpenable> {
@Inject(method = "render(Lnet/minecraft/block/entity/BlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At("HEAD"), cancellable = true)
public void dontRender(T entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, CallbackInfo ci) {
if (tickDelta != 0 && ViaLoadingBase.getClassWrapper().getTargetVersion().isOlderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
ci.cancel();
}
}
}

View File

@ -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;
}
}

View File

@ -10,9 +10,6 @@ import net.minecraft.util.shape.VoxelShapes;
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;
@ -23,17 +20,11 @@ public abstract class MixinChestBlock extends AbstractChestBlock<ChestBlockEntit
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);
}
}

View File

@ -6,6 +6,7 @@ import net.minecraft.block.*;
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;
@ -33,9 +34,17 @@ public class MixinFenceBlock extends HorizontalConnectingBlock {
@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);
}
}

View File

@ -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));

View File

@ -1,55 +0,0 @@
{
"variants": {
"type=single": {
"model": "viafabricplus:block/chest_single"
},
"type=left,facing=south": {
"model": "viafabricplus:block/chest_right",
"rotation": {
"y": -90
}
},
"type=left,facing=east": {
"model": "viafabricplus:block/chest_right",
"rotation": {
"y": -90
}
},
"type=left,facing=north": {
"model": "viafabricplus:block/chest_right",
"rotation": {
"y": 180
}
},
"type=left,facing=west": {
"model": "viafabricplus:block/chest_right",
"rotation": {
"y": 90
}
},
"type=right,facing=south": {
"model": "viafabricplus:block/chest_left",
"rotation": {
"y": -90
}
},
"type=right,facing=east": {
"model": "viafabricplus:block/chest_left",
"rotation": {
"y": -90
}
},
"type=right,facing=north": {
"model": "viafabricplus:block/chest_left",
"rotation": {
"y": 180
}
},
"type=right,facing=west": {
"model": "viafabricplus:block/chest_left",
"rotation": {
"y": 90
}
}
}
}

View File

@ -1,24 +0,0 @@
{
"credit": "Gaming32",
"textures": {
"0": "viafabricplus:block/chest_end",
"1": "viafabricplus:block/chest_left_front",
"2": "viafabricplus:block/chest_single_side",
"3": "viafabricplus:block/chest_left_back",
"particle": "viafabricplus:block/chest_end"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#3"},
"east": {"uv": [0, 0, 16, 16], "texture": "#missing"},
"south": {"uv": [0, 0, 16, 16], "texture": "#1"},
"west": {"uv": [0, 0, 16, 16], "texture": "#2"},
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]
}

View File

@ -1,24 +0,0 @@
{
"credit": "Gaming32",
"textures": {
"0": "viafabricplus:block/chest_right_front",
"1": "viafabricplus:block/chest_end",
"2": "viafabricplus:block/chest_single_side",
"3": "viafabricplus:block/chest_right_back",
"particle": "viafabricplus:block/chest_end"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#3"},
"east": {"uv": [0, 0, 16, 16], "texture": "#2"},
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#missing"},
"up": {"uv": [0, 0, 16, 16], "texture": "#1"},
"down": {"uv": [0, 0, 16, 16], "texture": "#1"}
}
}
]
}

View File

@ -1,23 +0,0 @@
{
"credit": "Gaming32",
"textures": {
"0": "viafabricplus:block/chest_end",
"1": "viafabricplus:block/chest_single_front",
"2": "viafabricplus:block/chest_single_side",
"particle": "viafabricplus:block/chest_end"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#2"},
"east": {"uv": [0, 0, 16, 16], "texture": "#2"},
"south": {"uv": [0, 0, 16, 16], "texture": "#1"},
"west": {"uv": [0, 0, 16, 16], "texture": "#2"},
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

View File

@ -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"
]
}