Skip to content

Commit

Permalink
Adds Flexibility to ShellEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 committed Dec 20, 2023
1 parent c6cfcd6 commit f2da41e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package whocraft.tardis_refined.client.model.blockentity.shell;

import whocraft.tardis_refined.client.model.blockentity.door.interior.ShellDoorModel;
import whocraft.tardis_refined.patterns.ShellPattern;

public class ShellEntry {

Expand All @@ -12,19 +13,12 @@ public ShellEntry(ShellModel shellModel, ShellDoorModel shellDoorModel) {
this.shellDoorModel = shellDoorModel;
}

public ShellModel getShellModel() {
public ShellModel getShellModel(ShellPattern shellPattern) {
return shellModel;
}

public void setShellModel(ShellModel shellModel) {
this.shellModel = shellModel;
}

public ShellDoorModel getShellDoorModel() {
public ShellDoorModel getShellDoorModel(ShellPattern shellPattern) {
return shellDoorModel;
}

public void setShellDoorModel(ShellDoorModel shellDoorModel) {
this.shellDoorModel = shellDoorModel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public static void registerShellEntry(ShellTheme theme, ShellModel shellModel, S
SHELL_MODELS.put(ShellTheme.getKey(theme), new ShellEntry(shellModel, shellDoorModel));
}

public static void registerShellEntry(ShellTheme theme, ShellEntry shellEntry){
SHELL_MODELS.put(ShellTheme.getKey(theme), shellEntry);
}

/**
* Get the associated shell model from a shell theme.
* @param themeId The Shell theme Id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity
TardisClientData reactions = TardisClientData.getInstance(blockEntity.getLevel().dimension());
ResourceLocation shellTheme = reactions.getShellTheme();
ResourceLocation shellPattern = reactions.getShellPattern();
ShellPattern pattern = ShellPatterns.getPatternOrDefault(shellTheme, shellPattern);

var model = ShellModelCollection.getInstance().getShellEntry(shellTheme).getShellModel();
var model = ShellModelCollection.getInstance().getShellEntry(shellTheme).getShellModel(pattern);
model.setDoorPosition(false);

poseStack.mulPose(Axis.ZP.rotationDegrees(180F));
Expand All @@ -81,7 +82,6 @@ private void renderHoloShell(Vec3 offset, int rotation, GlobalConsoleBlockEntity
ShellSelectionScreen.generateDummyGlobalShell();
}

ShellPattern pattern = ShellPatterns.getPatternOrDefault(shellTheme, shellPattern);
model.renderShell(ShellSelectionScreen.globalShellBlockEntity, false, true, poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(pattern.exteriorDoorTexture().texture())), packedLight, OverlayTexture.NO_OVERLAY, (float) color.x, (float) color.y, (float) color.z, 0.25f);
poseStack.popPose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void render(GlobalDoorBlockEntity blockEntity, float partialTick, PoseSta

// Render slightly off the wall to prevent z-fighting.
poseStack.translate(0, 0, -0.01);
currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellDoorModel();
currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellDoorModel(blockEntity.pattern());

if(theme == ShellTheme.POLICE_BOX.getId()){
poseStack.scale(1.05f, 1.05f, 1.05f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public void render(GlobalShellBlockEntity blockEntity, float partialTick, PoseSt
}
}

var currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellModel();
ShellPattern pattern = blockEntity.pattern();

var currentModel = ShellModelCollection.getInstance().getShellEntry(theme).getShellModel(pattern);

currentModel.renderShell(blockEntity, isOpen, true, poseStack, bufferSource.getBuffer(RenderType.entityTranslucent(currentModel.getShellTexture(pattern, false))), packedLight, OverlayTexture.NO_OVERLAY, 1f, 1f, 1f, 1f);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) {
}

private void renderShell(GuiGraphics guiGraphics, int x, int y, float scale) {
ShellModel model = ShellModelCollection.getInstance().getShellEntry(this.currentShellTheme).getShellModel();
ShellModel model = ShellModelCollection.getInstance().getShellEntry(this.currentShellTheme).getShellModel(pattern);
model.setDoorPosition(false);
Lighting.setupForEntityInInventory();
PoseStack pose = guiGraphics.pose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public ResourceLocation interiorTextureLocation(ResourceLocation themeId) {
}

protected Path getPath(ResourceLocation themeId) {
return generator.getPackOutput().getOutputFolder().resolve("data/" + modid + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json");
return generator.getPackOutput().getOutputFolder().resolve("data/" + TardisRefined.MODID + "/" + modid + "/patterns/shell/" + themeId.getPath() + ".json");
}

@Override
Expand Down

0 comments on commit f2da41e

Please sign in to comment.