Skip to content

Commit 9c5215b

Browse files
committed
- Added use_internal_shaders client config
- Added render_vortex_in_door client config - Bug fix: Potentially fixed interior door messing up on AMD cards!
1 parent be5a120 commit 9c5215b

File tree

13 files changed

+142
-128
lines changed

13 files changed

+142
-128
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
- Bug fix: Fixed issue where End Dragon fight would not be checked correctly
1313
- Bug fix: Potentially fixed interior door messing up on AMD cards!
1414

15+
#### Config
16+
- Added use_internal_shaders client config
17+
- Added render_vortex_in_door client config
18+
1519
#### Interiors
1620
- Added Panamax Interior
1721

common/src/main/java/whocraft/tardis_refined/TRConfig.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,25 @@ public class TRConfig {
3737
public static class Client {
3838
public final ForgeConfigSpec.BooleanValue CONTROL_NAMES;
3939
public final ForgeConfigSpec.BooleanValue PLAY_CONSOLE_IDLE_ANIMATIONS;
40-
public final ForgeConfigSpec.BooleanValue SKIP_FANCY_RENDERING;
40+
public final ForgeConfigSpec.BooleanValue RENDER_VORTEX_IN_DOOR;
41+
public final ForgeConfigSpec.BooleanValue USE_INTERNAL_SHADERS;
4142

4243
public Client(ForgeConfigSpec.Builder builder) {
4344
builder.push("rendering");
4445
CONTROL_NAMES = builder.comment("Toggle control name rendering").translation(ModMessages.CONFIG_CONTROL_NAMES).define("control_name_rendering", true);
4546
PLAY_CONSOLE_IDLE_ANIMATIONS = builder.comment("Play idle console animations").translation(ModMessages.CONFIG_IDLE_CONSOLE_ANIMS).define("console_idle_animations", true);
46-
SKIP_FANCY_RENDERING = builder.comment("Skip fancy rendering (Use on Macs with horrible OpenGL support)").translation(ModMessages.DISABLE_FANCY_RENDERING).define("disable_fancy_rendering", false);
47+
RENDER_VORTEX_IN_DOOR = builder.comment("Skip Vortex rendering").translation(ModMessages.CONFIG_RENDER_VORTEX_IN_DOOR).define("render_vortex_in_door", true);
48+
USE_INTERNAL_SHADERS = builder.comment("Use Custom Internal Shaders").translation(ModMessages.CONFIG_CUSTOM_SHADERS).define("use_internal_shaders", true);
4749
builder.pop();
4850
}
49-
5051
}
5152

5253
public static class Common {
5354
public final ForgeConfigSpec.BooleanValue COMPATIBILITY_IP;
5455

5556
public Common(ForgeConfigSpec.Builder builder) {
5657
builder.push("compatibility");
57-
COMPATIBILITY_IP = builder.comment("Toggle Immersive Portals compatibility (TR 2.0+). 2.0 has limited support and does not recommend enabling this.").translation(ModMessages.CONFIG_IP_COMPAT).define("immersive_portals_support", true);
58+
COMPATIBILITY_IP = builder.comment("Toggle Immersive Portals compatibility (TR 2.0+). 2.0 has limited support").translation(ModMessages.CONFIG_IP_COMPAT).define("immersive_portals_support", true);
5859
builder.pop();
5960
}
6061

common/src/main/java/whocraft/tardis_refined/client/TRShaders.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package whocraft.tardis_refined.client;
22

33
import com.google.common.collect.ImmutableList;
4+
import com.mojang.blaze3d.platform.GlUtil;
45
import com.mojang.blaze3d.vertex.VertexFormat;
5-
import net.minecraft.client.Minecraft;
6+
import net.fabricmc.api.EnvType;
7+
import net.fabricmc.api.Environment;
68
import net.minecraft.client.renderer.RenderStateShard;
79
import net.minecraft.client.renderer.RenderType;
810
import net.minecraft.client.renderer.ShaderInstance;
911
import net.minecraft.resources.ResourceLocation;
10-
import net.minecraft.world.phys.Vec3;
1112
import org.apache.commons.lang3.tuple.Triple;
13+
import whocraft.tardis_refined.TRConfig;
1214

13-
import java.util.List;
1415
import java.util.Objects;
1516

1617
import static com.mojang.blaze3d.vertex.DefaultVertexFormat.NEW_ENTITY;
@@ -20,9 +21,22 @@ public class TRShaders {
2021
public static ShaderInstance GLOW_SHADER;
2122
public static ShaderInstance SNOW_SHADER;
2223

24+
25+
@Environment(EnvType.CLIENT)
26+
public static boolean shouldUseCompatMode() {
27+
return !GlUtil.getVendor().toLowerCase().contains("nvidia");
28+
}
29+
30+
2331
public static RenderType translucentWithSnow(ResourceLocation texture, boolean show) {
2432
ResourceLocation snowTexture = new ResourceLocation("minecraft", "textures/block/snow.png");
2533

34+
35+
// Has to be separate, using java OR operator would allow the snow to render even if the user has internal shaders turned off
36+
if(!TRConfig.CLIENT.USE_INTERNAL_SHADERS.get()){
37+
return RenderType.entityTranslucent(texture);
38+
}
39+
2640
if (!show) return RenderType.entityTranslucent(texture);
2741

2842
// Create an ImmutableList of Triple for the textures

common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/FactoryConsoleModel.java

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,52 +52,60 @@ public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, i
5252
@Override
5353
public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level level, PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
5454
root().getAllParts().forEach(ModelPart::resetPose);
55-
TardisClientData reactions = TardisClientData.getInstance(level.dimension());
56-
if (globalConsoleBlock == null) return;
57-
if (globalConsoleBlock.getBlockState() == null) return;
55+
56+
if (globalConsoleBlock == null || globalConsoleBlock.getBlockState() == null) return;
5857

5958
Boolean powered = globalConsoleBlock.getBlockState() == null ? true : globalConsoleBlock.getBlockState().getValue(GlobalConsoleBlock.POWERED);
6059

6160

61+
// Store tick count for later use
62+
int tickCount = Minecraft.getInstance().player.tickCount;
63+
64+
TardisClientData reactions = TardisClientData.getInstance(level.dimension());
65+
66+
// Booting logic
6267
if (powered) {
63-
if (!globalConsoleBlock.powerOn.isStarted()) {
64-
globalConsoleBlock.powerOff.stop();
65-
globalConsoleBlock.powerOn.start(Minecraft.getInstance().player.tickCount);
68+
69+
if(globalConsoleBlock.getTicksBooting() > 0) {
70+
if (!globalConsoleBlock.powerOn.isStarted()) {
71+
globalConsoleBlock.powerOff.stop();
72+
globalConsoleBlock.powerOn.start(tickCount);
73+
}
74+
this.animate(globalConsoleBlock.powerOn, POWER_ON, tickCount);
6675
}
67-
this.animate(globalConsoleBlock.powerOn, POWER_ON, Minecraft.getInstance().player.tickCount);
68-
69-
if (reactions.isCrashing()) {
70-
// Handle crashing animation
71-
this.animate(reactions.CRASHING_ANIMATION, CRASH, Minecraft.getInstance().player.tickCount);
72-
} else if (reactions.isFlying()) {
73-
// Handle flying animation
74-
this.animate(reactions.ROTOR_ANIMATION, FLIGHT, Minecraft.getInstance().player.tickCount);
76+
77+
// Handle animations based on the current state (with flying first)
78+
if (reactions.isFlying()) {
79+
this.animate(reactions.ROTOR_ANIMATION, FLIGHT, tickCount);
80+
} else if (reactions.isCrashing()) {
81+
this.animate(reactions.CRASHING_ANIMATION, CRASH, tickCount);
7582
} else {
76-
// Handle idle animation
77-
if (TRConfig.CLIENT.PLAY_CONSOLE_IDLE_ANIMATIONS.get() && globalConsoleBlock != null) {
78-
this.animate(globalConsoleBlock.liveliness, IDLE, Minecraft.getInstance().player.tickCount);
83+
if (TRConfig.CLIENT.PLAY_CONSOLE_IDLE_ANIMATIONS.get()) {
84+
this.animate(globalConsoleBlock.liveliness, IDLE, tickCount);
7985
}
8086
}
8187

8288
} else {
83-
if (globalConsoleBlock != null) {
84-
if (!globalConsoleBlock.powerOff.isStarted()) {
85-
globalConsoleBlock.powerOn.stop();
86-
globalConsoleBlock.powerOff.start(Minecraft.getInstance().player.tickCount);
87-
}
88-
this.animate(globalConsoleBlock.powerOff, POWER_OFF, Minecraft.getInstance().player.tickCount);
89+
// Power off animation if not booting
90+
if (!globalConsoleBlock.powerOff.isStarted()) {
91+
globalConsoleBlock.powerOn.stop();
92+
globalConsoleBlock.powerOff.start(tickCount);
8993
}
94+
this.animate(globalConsoleBlock.powerOff, POWER_OFF, tickCount);
9095
}
9196

92-
float rot = -125 - (30 * ((float) reactions.getThrottleStage() / TardisPilotingManager.MAX_THROTTLE_STAGE));
93-
this.throttleLever.xRot = rot;
94-
97+
// Throttle and handbrake controls
98+
this.throttleLever.xRot = -125 - (30 * ((float) reactions.getThrottleStage() / TardisPilotingManager.MAX_THROTTLE_STAGE));
9599
this.handbrake.xRot = reactions.isHandbrakeEngaged() ? -155f : -125f;
100+
101+
// Final render call
96102
root().render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
97103
}
98104

99105

100106

107+
108+
101109
@Override
102110
public ModelPart root() {
103111
return root;

common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/VictorianConsoleModel.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,38 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev
6868
Boolean powered = globalConsoleBlock.getBlockState() == null ? true : globalConsoleBlock.getBlockState().getValue(GlobalConsoleBlock.POWERED);
6969

7070

71+
// Store tick count for later use
72+
int tickCount = Minecraft.getInstance().player.tickCount;
73+
74+
// Booting logic
7175
if (powered) {
72-
if (!globalConsoleBlock.powerOn.isStarted()) {
73-
globalConsoleBlock.powerOff.stop();
74-
globalConsoleBlock.powerOn.start(Minecraft.getInstance().player.tickCount);
76+
77+
if(globalConsoleBlock.getTicksBooting() > 0) {
78+
if (!globalConsoleBlock.powerOn.isStarted()) {
79+
globalConsoleBlock.powerOff.stop();
80+
globalConsoleBlock.powerOn.start(tickCount);
81+
}
82+
this.animate(globalConsoleBlock.powerOn, POWER_ON, tickCount);
7583
}
76-
this.animate(globalConsoleBlock.powerOn, POWER_ON, Minecraft.getInstance().player.tickCount);
77-
78-
if (reactions.isCrashing()) {
79-
// Handle crashing animation
80-
this.animate(reactions.CRASHING_ANIMATION, CRASH, Minecraft.getInstance().player.tickCount);
81-
} else if (reactions.isFlying()) {
82-
// Handle flying animation
83-
this.animate(reactions.ROTOR_ANIMATION, FLIGHT, Minecraft.getInstance().player.tickCount);
84+
85+
// Handle animations based on the current state (with flying first)
86+
if (reactions.isFlying()) {
87+
this.animate(reactions.ROTOR_ANIMATION, FLIGHT, tickCount);
88+
} else if (reactions.isCrashing()) {
89+
this.animate(reactions.CRASHING_ANIMATION, CRASH, tickCount);
8490
} else {
85-
// Handle idle animation
86-
if (TRConfig.CLIENT.PLAY_CONSOLE_IDLE_ANIMATIONS.get() && globalConsoleBlock != null) {
87-
this.animate(globalConsoleBlock.liveliness, IDLE, Minecraft.getInstance().player.tickCount);
91+
if (TRConfig.CLIENT.PLAY_CONSOLE_IDLE_ANIMATIONS.get()) {
92+
this.animate(globalConsoleBlock.liveliness, IDLE, tickCount);
8893
}
8994
}
9095

9196
} else {
92-
if (globalConsoleBlock != null) {
93-
if (!globalConsoleBlock.powerOff.isStarted()) {
94-
globalConsoleBlock.powerOn.stop();
95-
globalConsoleBlock.powerOff.start(Minecraft.getInstance().player.tickCount);
96-
}
97-
this.animate(globalConsoleBlock.powerOff, POWER_OFF, Minecraft.getInstance().player.tickCount);
97+
// Power off animation if not booting
98+
if (!globalConsoleBlock.powerOff.isStarted()) {
99+
globalConsoleBlock.powerOn.stop();
100+
globalConsoleBlock.powerOff.start(tickCount);
98101
}
102+
this.animate(globalConsoleBlock.powerOff, POWER_OFF, tickCount);
99103
}
100104

101105

0 commit comments

Comments
 (0)