Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/minecraft/1.20' into minecraft/1.20
Browse files Browse the repository at this point in the history
# Conflicts:
#	forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8
  • Loading branch information
50ap5ud5 committed Dec 20, 2023
2 parents c6eb5b3 + 9019ec0 commit b8a9fda
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 35 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 @@ -38,11 +38,8 @@ public class Upgrades {
public static final RegistrySupplier<Upgrade> DEFENSE_SYSTEM = UPGRADE_DEFERRED_REGISTRY.register("defense_system", () -> new Upgrade(Items.DIAMOND_SWORD::getDefaultInstance, TARDIS_XP, RegistryHelper.makeKey("defense_system"), Upgrade.UpgradeType.MAIN_UPGRADE)
.setSkillPointsRequired(50).setPosition(0, 1));

public static final RegistrySupplier<Upgrade> HOSTILE_DISPLACEMENT = UPGRADE_DEFERRED_REGISTRY.register("hostile_displacement", () -> new Upgrade(Items.ZOMBIE_HEAD::getDefaultInstance, DEFENSE_SYSTEM, RegistryHelper.makeKey("hostile_displacement"), Upgrade.UpgradeType.SUB_UPGRADE)
.setSkillPointsRequired(50).setPosition(1, 1));

public static final RegistrySupplier<Upgrade> MATERIALIZE_AROUND = UPGRADE_DEFERRED_REGISTRY.register("materialize_around", () -> new Upgrade(Items.GLASS_PANE::getDefaultInstance, DEFENSE_SYSTEM, RegistryHelper.makeKey("materialize_around"), Upgrade.UpgradeType.SUB_UPGRADE)
.setSkillPointsRequired(50).setPosition(2, 1));
.setSkillPointsRequired(50).setPosition(1, 1));

// Navigation Upgrades
public static final RegistrySupplier<Upgrade> NAVIGATION_SYSTEM = UPGRADE_DEFERRED_REGISTRY.register("navigation_system", () -> new Upgrade(Items.COMPASS::getDefaultInstance, TARDIS_XP, RegistryHelper.makeKey("navigation_system"), Upgrade.UpgradeType.MAIN_UPGRADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@
"upgrade.tardis_refined.explorer_ii.description": "x2500 Increment",
"upgrade.tardis_refined.explorer_iii": "Explorer III",
"upgrade.tardis_refined.explorer_iii.description": "x5000 Increment",
"upgrade.tardis_refined.hostile_displacement": "Hostile Action Displacement",
"upgrade.tardis_refined.hostile_displacement.description": "Enables the displacement of the TARDIS when attacked",
"upgrade.tardis_refined.inside_architecture": "Desktop Reconfiguration",
"upgrade.tardis_refined.inside_architecture.description": "Allows the Pilot to change the appearance of the TARDIS Desktop",
"upgrade.tardis_refined.landing_pad": "Landing Pad",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ protected void addTranslations() {
addUpgrade(Upgrades.COORDINATE_INPUT.get(), "Coordinate Input", "Allows the Pilot to input coordinates with the monitor");
addUpgrade(Upgrades.CHAMELEON_CIRCUIT_SYSTEM.get(), "Chameleon Circuit", "Allows the TARDIS to change it's shape");
addUpgrade(Upgrades.DEFENSE_SYSTEM.get(), "Defense System", "Enables Defense Protocols");
addUpgrade(Upgrades.HOSTILE_DISPLACEMENT.get(), "Hostile Action Displacement", "Enables the displacement of the TARDIS when attacked");
addUpgrade(Upgrades.WAYPOINTS.get(), "Waypoints", "Allows the Pilot to create saved locations");
addUpgrade(Upgrades.NAVIGATION_SYSTEM.get(), "Navigation System", "Allows upgrades to the TARDIS Navigation System");
addUpgrade(Upgrades.TARDIS_XP.get(), "System Upgrades", "Allows upgrades to the TARDIS");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceLocation;
import whocraft.tardis_refined.TardisRefined;
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
import whocraft.tardis_refined.patterns.ShellPattern;
import whocraft.tardis_refined.patterns.ShellPatternCollection;
import whocraft.tardis_refined.patterns.ShellPatterns;
Expand All @@ -22,15 +21,17 @@ public class ShellPatternProvider implements DataProvider {
protected final DataGenerator generator;
private final boolean addDefaults;
protected Map<ResourceLocation, ShellPatternCollection> data = new HashMap<>();
private final String modid;

public ShellPatternProvider(DataGenerator generator) {
this(generator, true);
public ShellPatternProvider(DataGenerator generator, String modid) {
this(generator, modid, true);
}

public ShellPatternProvider(DataGenerator generator, boolean addDefaults) {
public ShellPatternProvider(DataGenerator generator, String modid, boolean addDefaults) {
Preconditions.checkNotNull(generator);
this.generator = generator;
this.addDefaults = addDefaults;
this.modid = modid;
}

/**
Expand All @@ -53,30 +54,28 @@ public CompletableFuture<?> run(CachedOutput arg) {
this.addPatterns();

if (!data.isEmpty()) {
data.entrySet().forEach(entry -> {
data.forEach((key, patternCollection) -> {
try {
ShellPatternCollection patternCollection = entry.getValue();
JsonObject currentPatternCollection = ShellPatternCollection.CODEC.encodeStart(JsonOps.INSTANCE, patternCollection).get()
.ifRight(right -> {
TardisRefined.LOGGER.error(right.message());
}).orThrow().getAsJsonObject();
Path output = getPath(patternCollection.themeId());
futures.add(DataProvider.saveStable(arg, currentPatternCollection, output));
} catch (Exception exception) {
TardisRefined.LOGGER.debug("Issue writing ShellPatternCollection {}! Error: {}", entry.getValue().themeId(), exception.getMessage());
TardisRefined.LOGGER.debug("Issue writing ShellPatternCollection {}! Error: {}", patternCollection.themeId(), exception.getMessage());
}
});
}
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
}

protected ShellPattern addPatternToDatagen(ResourceLocation themeId, ShellPattern shellPattern) {
public ShellPattern addPattern(ResourceLocation themeId, ShellPattern shellPattern) {
ShellPattern pattern = (ShellPattern) shellPattern.setThemeId(themeId);
ShellPatternCollection collection;
if (this.data.containsKey(themeId)) {
collection = this.data.get(themeId);
List<ShellPattern> currentList = new ArrayList<>();
currentList.addAll(collection.patterns());
List<ShellPattern> currentList = new ArrayList<>(collection.patterns());
currentList.add(pattern);
collection.setPatterns(currentList);
this.data.replace(themeId, collection);
Expand All @@ -88,16 +87,16 @@ protected ShellPattern addPatternToDatagen(ResourceLocation themeId, ShellPatter
return pattern;
}

protected ResourceLocation exteriorTextureLocation(ResourceLocation themeId) {
public ResourceLocation exteriorTextureLocation(ResourceLocation themeId) {
return new ResourceLocation(themeId.getNamespace(), "textures/blockentity/shell/" + themeId.getPath() + "/" + themeId.getPath() + ".png");
}

protected ResourceLocation interiorTextureLocation(ResourceLocation themeId) {
public ResourceLocation interiorTextureLocation(ResourceLocation themeId) {
return new ResourceLocation(themeId.getNamespace(), "textures/blockentity/shell/" + themeId.getPath() + "/" + themeId.getPath() + "_interior.png");
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onGatherData(GatherDataEvent e) {
generator.addProvider(e.includeServer(), new RecipeProvider(generator, e.getLookupProvider()));
generator.addProvider(e.includeServer(), new ConsolePatternProvider(generator));
generator.addProvider(e.includeServer(), new DesktopProvider(generator));
generator.addProvider(e.includeServer(), new ShellPatternProvider(generator));
generator.addProvider(e.includeServer(), new ShellPatternProvider(generator, TardisRefined.MODID));

//Tags
generator.addProvider(e.includeServer(), new TRBiomeTagsProvider(generator.getPackOutput(), e.getLookupProvider(), e.getExistingFileHelper()));
Expand Down

0 comments on commit b8a9fda

Please sign in to comment.