diff --git a/common/src/main/java/com/unlikepaladin/pfm/client/screens/PFMConfigScreen.java b/common/src/main/java/com/unlikepaladin/pfm/client/screens/PFMConfigScreen.java index e0d73c7bc..d2fd4ef3d 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/client/screens/PFMConfigScreen.java +++ b/common/src/main/java/com/unlikepaladin/pfm/client/screens/PFMConfigScreen.java @@ -6,6 +6,7 @@ import com.unlikepaladin.pfm.config.option.Side; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.ConfirmScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.util.math.MatrixStack; @@ -36,17 +37,36 @@ public PFMConfigScreen(MinecraftClient client, Screen parent) { this.options = PaladinFurnitureMod.getPFMConfig().options; } - + @Override + public boolean keyPressed(int keyCode, int scanCode, int modifiers) { + if (keyCode == 256 && !optionListWidget.hasChanges.isEmpty()) { + client.setScreen(new ConfirmScreen(t -> { + if (t){ + this.optionListWidget.save(); + try { + PaladinFurnitureMod.getPFMConfig().save(); + } catch (IOException e) { + PaladinFurnitureMod.GENERAL_LOGGER.error("Failed to save config options!"); + throw new RuntimeException(e); + } + } + MinecraftClient.getInstance().setScreen(parent); + }, Text.translatable("gui.pfm.changesMightNotBeSaved").setStyle(Style.EMPTY.withColor(0xf77f34).withBold(true)), Text.translatable("gui.pfm.saveChanges"))); + return true; + } + return super.keyPressed(keyCode, scanCode, modifiers); + } @Override public void close() { + this.optionListWidget.save(); + MinecraftClient.getInstance().setScreen(parent); try { PaladinFurnitureMod.getPFMConfig().save(); } catch (IOException e) { PaladinFurnitureMod.GENERAL_LOGGER.error("Failed to save config options!"); throw new RuntimeException(e); } - this.client.setScreen(parent); } @Override @@ -57,13 +77,24 @@ protected void init() { this.resetButton = this.addDrawableChild(ButtonWidget.builder(Text.translatable("pfm.option.resetAll"), button -> { options.forEach((title, option) -> { if (option.getSide() == Side.CLIENT){ - option.setValue(option.getDefaultValue()); + if (option.getType() == Boolean.class) { + if (option.getDefaultValue() != this.optionListWidget.newConfigValues.get(option)) { + this.optionListWidget.hasChanges.set(this.optionListWidget.configOptionToIndexForHasChanges.get(option), true); + } + this.optionListWidget.newConfigValues.put(option, (Boolean) option.getDefaultValue()); + } } else if (!isOnServer && option.getSide() == Side.SERVER) { - option.setValue(option.getDefaultValue()); + if (option.getType() == Boolean.class) { + if (option.getDefaultValue() != this.optionListWidget.newConfigValues.get(option)) { + this.optionListWidget.hasChanges.set(this.optionListWidget.configOptionToIndexForHasChanges.get(option), true); + } + this.optionListWidget.newConfigValues.put(option, (Boolean) option.getDefaultValue()); + } } }); }).dimensions(this.width/2 - 155, this.height -29, 150, 20).build()); this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> { + this.optionListWidget.save(); this.client.setScreen(this.parent); try { PaladinFurnitureMod.getPFMConfig().save(); @@ -81,8 +112,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) { context.drawCenteredTextWithShadow(this.textRenderer, TITLE.setStyle(Style.EMPTY.withColor(0xf77f34).withBold(true)), this.width / 2, 8, 0xFFFFFF); boolean bl = false; - for (Map.Entry optionEntry : options.entrySet()) { - if (optionEntry.getValue().isDefault()) continue; + for (Map.Entry optionEntry : optionListWidget.newConfigValues.entrySet()) { + if (optionEntry.getValue() == optionEntry.getKey().getDefaultValue()) continue; bl = true; break; } diff --git a/common/src/main/java/com/unlikepaladin/pfm/client/screens/widget/PFMOptionListWidget.java b/common/src/main/java/com/unlikepaladin/pfm/client/screens/widget/PFMOptionListWidget.java index 11e75035f..4f9085944 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/client/screens/widget/PFMOptionListWidget.java +++ b/common/src/main/java/com/unlikepaladin/pfm/client/screens/widget/PFMOptionListWidget.java @@ -23,20 +23,24 @@ import net.minecraft.screen.ScreenTexts; import net.minecraft.text.*; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Consumer; import java.util.function.Supplier; public class PFMOptionListWidget extends ElementListWidget { final PFMConfigScreen parent; int maxKeyNameLength; - + public BitSet hasChanges; + public Map newConfigValues; + public Map configOptionToIndexForHasChanges; public PFMOptionListWidget(PFMConfigScreen parent, MinecraftClient client) { super(client, parent.width + 125, parent.height, 43, parent.height - 32, 20); this.parent = parent; String string = null; + int index = 0; + hasChanges = new BitSet(PaladinFurnitureMod.getPFMConfig().options.size()); + newConfigValues = new HashMap<>(PaladinFurnitureMod.getPFMConfig().options.size()); + configOptionToIndexForHasChanges = new HashMap<>(PaladinFurnitureMod.getPFMConfig().options.size()); for(Map.Entry configOptionEntry : PaladinFurnitureMod.getPFMConfig().options.entrySet()) { Text text; int i; @@ -49,10 +53,13 @@ public PFMOptionListWidget(PFMConfigScreen parent, MinecraftClient client) { this.maxKeyNameLength = i; } if (configOptionEntry.getValue().getType() == Boolean.class) { - this.addEntry(new BooleanEntry((BooleanConfigOption)configOptionEntry.getValue(), text)); + PFMOptionListWidget.this.newConfigValues.put(configOptionEntry.getValue(), (Boolean) configOptionEntry.getValue().getValue()); + this.addEntry(new BooleanEntry((BooleanConfigOption)configOptionEntry.getValue(), text, index)); } else { PaladinFurnitureMod.GENERAL_LOGGER.warn("Unsupported Config Type!"); } + configOptionToIndexForHasChanges.put(configOptionEntry.getValue(), index); + index++; } this.addEntry(new CategoryEntry(Text.literal(""))); this.addEntry(new ButtonEntry(Side.CLIENT, Text.translatable("pfm.option.regenAssets"), Text.translatable("pfm.config.regen"), Text.translatable("pfm.option.regenAssets.tooltip"), button -> { @@ -64,6 +71,13 @@ public PFMOptionListWidget(PFMConfigScreen parent, MinecraftClient client) { })); } + public void save() { + for (Map.Entry entry : newConfigValues.entrySet()) { + if (entry.getKey().getType() == Boolean.class) + entry.getKey().setValue(entry.getValue()); + } + } + @Override protected int getScrollbarPositionX() { return super.getScrollbarPositionX() + 15; @@ -125,10 +139,12 @@ public class BooleanEntry private final ButtonWidget resetButton; private final Supplier supplier; - - BooleanEntry(final BooleanConfigOption configOption, final Text optionName) { + int index; + boolean hasChanges = false; + BooleanEntry(final BooleanConfigOption configOption, final Text optionName, int index) { this.configOption = configOption; this.optionName = optionName; + this.index = index; this.supplier = () -> { final MutableText sideText = configOption.getSide() == Side.CLIENT ? Text.translatable("pfm.option.client").setStyle(Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34)) : Text.translatable("pfm.option.server").setStyle((Style.EMPTY.withItalic(false).withBold(true).withColor(0xf77f34))); final MutableText styledTooltip = ((MutableText)configOption.getToolTip()).setStyle(Style.EMPTY.withItalic(true)); @@ -136,11 +152,15 @@ public class BooleanEntry }; this.valueButton = ButtonWidget.builder(optionName, button -> { PFMOptionListWidget.this.parent.focusedConfigOption = configOption; - configOption.setValue(!configOption.getValue()); + PFMOptionListWidget.this.newConfigValues.put(configOption, !PFMOptionListWidget.this.newConfigValues.get(configOption)); + hasChanges = !hasChanges; + PFMOptionListWidget.this.hasChanges.set(index, hasChanges); }).dimensions(0,0,75,20).narrationSupplier(textSupplier -> this.supplier.get()).build(); this.resetButton = ButtonWidget.builder(Text.translatable("controls.reset"), button -> { - configOption.setValue(configOption.getDefaultValue()); + PFMOptionListWidget.this.newConfigValues.put(configOption, configOption.getDefaultValue()); + hasChanges = true; + PFMOptionListWidget.this.hasChanges.set(index, true); }).dimensions(0,0,50,20).narrationSupplier(textSupplier -> Text.translatable("narrator.controls.reset", optionName)).build(); } @@ -149,11 +169,11 @@ public void render(DrawContext context, int index, int y, int x, int entryWidth, context.drawText(PFMOptionListWidget.this.client.textRenderer, this.optionName, (x + 90 - PFMOptionListWidget.this.maxKeyNameLength), (y + entryHeight / 2 - PFMOptionListWidget.this.client.textRenderer.fontHeight / 2), 0xFFFFFF, false); this.resetButton.setX(x + 190); this.resetButton.setY(y); - this.resetButton.active = this.configOption.getSide() == Side.SERVER ? !PFMConfigScreen.isOnServer && !this.configOption.isDefault() : !this.configOption.isDefault();; + this.resetButton.active = this.configOption.getSide() == Side.SERVER ? !PFMConfigScreen.isOnServer && !(this.configOption.getDefaultValue() == PFMOptionListWidget.this.newConfigValues.get(configOption)) : !(this.configOption.getDefaultValue() == PFMOptionListWidget.this.newConfigValues.get(configOption));; this.resetButton.render(context, mouseX, mouseY, tickDelta); this.valueButton.setX(x + 105); this.valueButton.setY(y); - this.valueButton.setMessage(this.configOption.getValue() ? ScreenTexts.YES : ScreenTexts.NO); + this.valueButton.setMessage(PFMOptionListWidget.this.newConfigValues.get(configOption) ? ScreenTexts.YES : ScreenTexts.NO); this.valueButton.active = this.configOption.getSide() != Side.SERVER || !PFMConfigScreen.isOnServer; this.valueButton.render(context, mouseX, mouseY, tickDelta); } diff --git a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java index fbc5c2673..67961fd32 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java +++ b/common/src/main/java/com/unlikepaladin/pfm/data/materials/WoodVariantRegistry.java @@ -58,7 +58,7 @@ public Optional getVariantFromBlock(Block baseBlock, Identifier blo } String namespace = blockId.getNamespace(); if (name != null && !namespace.equals("securitycraft") && - !namespace.equals("absentbydesign") && !(namespace.equals("terrestria") && path.contains("sakura")) && !(namespace.equals("betternether") && path.contains("nether_mushroom"))) { + !namespace.equals("absentbydesign") && !(namespace.equals("terrestria") && path.contains("sakura")) && !(namespace.equals("betternether") && path.contains("nether_mushroom")) && !namespace.equals("chipped")) { BlockState state = baseBlock.getDefaultState(); //can't check if the block is a full one, so I do this. Adding some checks here diff --git a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java index e9c4e9efc..dcb158dd8 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java +++ b/common/src/main/java/com/unlikepaladin/pfm/runtime/assets/PFMLangProvider.java @@ -226,12 +226,13 @@ public void generateTranslationForLampBlock(BufferedWriter writer) { } public String getTranslatedVariantName(VariantBase variant) { AtomicReference variantName = new AtomicReference<>(translate(variant.getSecondaryBlock().getTranslationKey())); - String oakVariantName = translate(variant != WoodVariantRegistry.getVariantFromVanillaWoodType(BoatEntity.Type.JUNGLE) ? WoodVariantRegistry.getVariantFromVanillaWoodType(BoatEntity.Type.JUNGLE).getSecondaryBlock().getTranslationKey() : WoodVariantRegistry.OAK.getSecondaryBlock().getTranslationKey()); - List common = findCommonWords(variantName.get(), oakVariantName); + String baseBlockName = translate(variant.getBaseBlock().getTranslationKey()); + List common = findCommonWords(variantName.get(), baseBlockName); + variantName.set(""); if (variant == WoodVariantRegistry.getVariantFromVanillaWoodType(BoatEntity.Type.BAMBOO)) { variantName.set(variantName.get().replace("Block of", "")); } - common.forEach(s -> variantName.set(variantName.get().replace(s, "").trim())); + common.forEach(s -> variantName.set(String.join(!variantName.get().isEmpty() ? variantName.get() + " " : variantName.get(), s))); return variantName.get(); } diff --git a/common/src/main/resources/assets/pfm/lang/en_us.json b/common/src/main/resources/assets/pfm/lang/en_us.json index 159beced5..11c4c35f7 100644 --- a/common/src/main/resources/assets/pfm/lang/en_us.json +++ b/common/src/main/resources/assets/pfm/lang/en_us.json @@ -1303,6 +1303,8 @@ "pfm.option.regenAssets": "Recreate Assets", "pfm.config.regen": "Recreate", "pfm.option.regenAssets.tooltip": "Re-creates mod assets and triggers a resource reload, leaving and entering the world may be necessary for some changes to take effect.", + "gui.pfm.saveChanges": "Do you wish to save your changes?", + "gui.pfm.changesMightNotBeSaved": "Closing without Saving Changes!", "block.type.stripped": "Stripped", "block.type.raw": "Raw", diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/EntityRenderRegistryImpl.java b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/EntityRenderRegistryImpl.java index 94cce319a..0cf5ab1b8 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/EntityRenderRegistryImpl.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/EntityRenderRegistryImpl.java @@ -2,6 +2,7 @@ import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.PFMCookingForBlockHeadsCompat; +import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.client.PFMCookingForBlockheadsClient; import com.unlikepaladin.pfm.entity.render.StoveBlockEntityRenderer; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; @@ -28,7 +29,7 @@ public static void registerModelLayer(EntityModelLayer entityType, TexturedModel public static BlockEntityRendererFactory getStoveBlockEntityRenderer() { if (PaladinFurnitureMod.getModList().contains("cookingforblockheads")) { - return PFMCookingForBlockHeadsCompat.getStoveRenderer(); + return PFMCookingForBlockheadsClient.getStoveRenderer(); } else { return StoveBlockEntityRenderer::new; } diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/ScreenRegistryImpl.java b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/ScreenRegistryImpl.java index 388585f17..7a5cc82e6 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/ScreenRegistryImpl.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/ScreenRegistryImpl.java @@ -3,6 +3,7 @@ import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.client.screens.StoveScreen; import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.PFMCookingForBlockHeadsCompat; +import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.client.PFMCookingForBlockheadsClient; import com.unlikepaladin.pfm.menus.StoveScreenHandler; import com.unlikepaladin.pfm.registry.TriFunc; import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry; @@ -20,7 +21,7 @@ public static > TriFunc getStoveFactory() { if (PaladinFurnitureMod.getModList().contains("cookingforblockheads")) { - return PFMCookingForBlockHeadsCompat.getStoveScreen(); + return PFMCookingForBlockheadsClient.getStoveScreen(); } else { return (t, playerInventory, text) -> (J) new StoveScreen((StoveScreenHandler) t, playerInventory, text); } diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/PFMCookingForBlockHeadsCompat.java b/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/PFMCookingForBlockHeadsCompat.java index 0a01e6e3b..70481a7bf 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/PFMCookingForBlockHeadsCompat.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/PFMCookingForBlockHeadsCompat.java @@ -6,8 +6,6 @@ import com.unlikepaladin.pfm.blocks.KitchenWallCounterBlock; import com.unlikepaladin.pfm.blocks.StoveBlock; import com.unlikepaladin.pfm.blocks.fabric.StoveBlockImpl; -import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveBlockEntityRendererBalm; -import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveScreenBalm; import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveScreenHandlerBalm; import com.unlikepaladin.pfm.registry.BlockEntities; import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; @@ -22,16 +20,12 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; -import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.screen.ScreenHandler; import net.minecraft.state.property.Properties; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -56,14 +50,6 @@ public static TriFunc> TriFunc getStoveScreen() { - return (t, playerInventory, text) -> (J) new StoveScreenBalm((StoveScreenHandlerBalm) t, playerInventory, text); - } - - public static BlockEntityRendererFactory getStoveRenderer() { - return StoveBlockEntityRendererBalm::new; - } - public static void openMenuScreen(World world, BlockPos pos, PlayerEntity player) { StoveBlockEntityBalm stove = (StoveBlockEntityBalm)world.getBlockEntity(pos); if (!world.isClient) { diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/client/PFMCookingForBlockheadsClient.java b/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/client/PFMCookingForBlockheadsClient.java new file mode 100644 index 000000000..eb2ec773f --- /dev/null +++ b/fabric/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/fabric/client/PFMCookingForBlockheadsClient.java @@ -0,0 +1,36 @@ +package com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.client; + +import com.unlikepaladin.pfm.compat.PFMClientModCompatibility; +import com.unlikepaladin.pfm.compat.PFMModCompatibility; +import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveBlockEntityRendererBalm; +import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveScreenBalm; +import com.unlikepaladin.pfm.compat.cookingforblockheads.fabric.menu.StoveScreenHandlerBalm; +import com.unlikepaladin.pfm.registry.TriFunc; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; +import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.text.Text; + +public class PFMCookingForBlockheadsClient implements PFMClientModCompatibility { + private final PFMModCompatibility parent; + + public PFMCookingForBlockheadsClient(PFMModCompatibility parent) { + this.parent = parent; + } + + @Override + public PFMModCompatibility getCompatiblity() { + return parent; + } + + public static > TriFunc getStoveScreen() { + return (t, playerInventory, text) -> (J) new StoveScreenBalm((StoveScreenHandlerBalm) t, playerInventory, text); + } + + public static BlockEntityRendererFactory getStoveRenderer() { + return StoveBlockEntityRendererBalm::new; + } + +} diff --git a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/EntityRenderRegistryImpl.java b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/EntityRenderRegistryImpl.java index e215db36c..5a5251bbe 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/EntityRenderRegistryImpl.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/EntityRenderRegistryImpl.java @@ -2,6 +2,7 @@ import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.PFMCookingForBlockHeadsCompat; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.client.PFMCookingForBlockheadsClient; import com.unlikepaladin.pfm.entity.render.StoveBlockEntityRenderer; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.client.model.TexturedModelData; @@ -32,7 +33,7 @@ public static void registerModelLayer(EntityModelLayer entityType, TexturedModel public static BlockEntityRendererFactory getStoveBlockEntityRenderer() { if (PaladinFurnitureMod.getModList().contains("cookingforblockheads")) { - return PFMCookingForBlockHeadsCompat.getStoveRenderer(); + return PFMCookingForBlockheadsClient.getStoveRenderer(); } else { return StoveBlockEntityRenderer::new; } diff --git a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/ScreenRegistryImpl.java b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/ScreenRegistryImpl.java index 866db7b56..c67f626e8 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/client/forge/ScreenRegistryImpl.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/client/forge/ScreenRegistryImpl.java @@ -2,7 +2,9 @@ import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.client.screens.StoveScreen; +import com.unlikepaladin.pfm.compat.cookingforblockheads.PFMCookingForBlockheads; import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.PFMCookingForBlockHeadsCompat; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.client.PFMCookingForBlockheadsClient; import com.unlikepaladin.pfm.menus.StoveScreenHandler; import com.unlikepaladin.pfm.registry.TriFunc; import net.minecraft.client.gui.screen.Screen; @@ -20,7 +22,7 @@ public static > TriFunc getStoveFactory() { if (PaladinFurnitureMod.getModList().contains("cookingforblockheads")) { - return PFMCookingForBlockHeadsCompat.getStoveScreen(); + return PFMCookingForBlockheadsClient.getStoveScreen(); } else { return (t, playerInventory, text) -> (J) new StoveScreen((StoveScreenHandler) t, playerInventory, text); } diff --git a/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockHeadsCompat.java b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockHeadsCompat.java index d17b6737e..863f0bb12 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockHeadsCompat.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockHeadsCompat.java @@ -6,9 +6,7 @@ import com.unlikepaladin.pfm.blocks.KitchenWallCounterBlock; import com.unlikepaladin.pfm.blocks.StoveBlock; import com.unlikepaladin.pfm.blocks.forge.StoveBlockImpl; -import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveBlockEntityRendererBalm; import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveScreenHandlerBalm; -import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveScreenBalm; import com.unlikepaladin.pfm.registry.BlockEntities; import com.unlikepaladin.pfm.registry.TriFunc; import net.blay09.mods.balm.api.Balm; @@ -20,16 +18,12 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; -import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.screen.ScreenHandler; import net.minecraft.state.property.Properties; -import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -54,14 +48,6 @@ public static TriFunc> TriFunc getStoveScreen() { - return (t, playerInventory, text) -> (J) new StoveScreenBalm((StoveScreenHandlerBalm) t, playerInventory, text); - } - - public static BlockEntityRendererFactory getStoveRenderer() { - return StoveBlockEntityRendererBalm::new; - } - public static void openMenuScreen(World world, BlockPos pos, PlayerEntity player) { StoveBlockEntityBalm stove = (StoveBlockEntityBalm)world.getBlockEntity(pos); if (!world.isClient) { diff --git a/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockheadsImpl.java b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockheadsImpl.java index 085e9e6db..583b0c69c 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockheadsImpl.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/PFMCookingForBlockheadsImpl.java @@ -1,7 +1,9 @@ package com.unlikepaladin.pfm.compat.cookingforblockheads.forge; import com.unlikepaladin.pfm.PaladinFurnitureMod; +import com.unlikepaladin.pfm.compat.PFMClientModCompatibility; import com.unlikepaladin.pfm.compat.cookingforblockheads.PFMCookingForBlockheads; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.client.PFMCookingForBlockheadsClient; import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.runtime.data.FurnitureRecipeJsonFactory; import com.unlikepaladin.pfm.runtime.data.PFMRecipeProvider; @@ -14,6 +16,12 @@ import java.util.function.Consumer; public class PFMCookingForBlockheadsImpl extends PFMCookingForBlockheads { + private final PFMClientModCompatibility clientModCompatibility; + + public PFMCookingForBlockheadsImpl() { + clientModCompatibility = new PFMCookingForBlockheadsClient(this); + } + @Override public void generateRecipes(Consumer exporter) { FurnitureRecipeJsonFactory.create(PFMCookingForBlockHeadsCompat.COOKING_TABLE_BLOCK, 4).group("kitchen").criterion(PFMRecipeProvider.getCriterionNameFromOutput(PFMCookingForBlockHeadsCompat.COOKING_TABLE_BLOCK), PFMRecipeProvider.conditionsFromItem(ModItems.recipeBook)).input(ModItems.recipeBook).input(Blocks.WHITE_CONCRETE, 2).input(Blocks.GRAY_CONCRETE).offerTo(exporter, new Identifier("pfm", PFMCookingForBlockHeadsCompat.COOKING_TABLE_BLOCK.asItem().getTranslationKey().replace("block.pfm.", ""))); diff --git a/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/client/PFMCookingForBlockheadsClient.java b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/client/PFMCookingForBlockheadsClient.java new file mode 100644 index 000000000..60b892ad1 --- /dev/null +++ b/forge/src/main/java/com/unlikepaladin/pfm/compat/cookingforblockheads/forge/client/PFMCookingForBlockheadsClient.java @@ -0,0 +1,36 @@ +package com.unlikepaladin.pfm.compat.cookingforblockheads.forge.client; + +import com.unlikepaladin.pfm.compat.PFMClientModCompatibility; +import com.unlikepaladin.pfm.compat.PFMModCompatibility; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveBlockEntityRendererBalm; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveScreenBalm; +import com.unlikepaladin.pfm.compat.cookingforblockheads.forge.menu.StoveScreenHandlerBalm; +import com.unlikepaladin.pfm.registry.TriFunc; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider; +import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.screen.ScreenHandler; +import net.minecraft.text.Text; + +public class PFMCookingForBlockheadsClient implements PFMClientModCompatibility { + private final PFMModCompatibility parent; + + public PFMCookingForBlockheadsClient(PFMModCompatibility parent) { + this.parent = parent; + } + + @Override + public PFMModCompatibility getCompatiblity() { + return parent; + } + + public static > TriFunc getStoveScreen() { + return (t, playerInventory, text) -> (J) new StoveScreenBalm((StoveScreenHandlerBalm) t, playerInventory, text); + } + + public static BlockEntityRendererFactory getStoveRenderer() { + return StoveBlockEntityRendererBalm::new; + } + +}