From 5cbe01c6b6785fa4da1965c4f59ebd4347abe694 Mon Sep 17 00:00:00 2001 From: Irgendwer01 <67506320+Irgendwer01@users.noreply.github.com> Date: Sun, 17 Dec 2023 15:52:33 +0100 Subject: [PATCH] Don't use deprecated stuff --- src/main/java/gregtech/api/GTValues.java | 4 +- .../integration/exnihilo/ExNihiloConfig.java | 3 +- .../integration/exnihilo/ExNihiloModule.java | 88 ++++++++++++------- .../exnihilo/items/ExNihiloPebble.java | 34 ++++--- .../metatileentities/MetaTileEntitySieve.java | 16 ++-- .../MetaTileEntitySteamSieve.java | 29 +++--- .../exnihilo/recipes/ExNihiloRecipes.java | 33 ++++--- .../exnihilo/recipes/MeshRecipes.java | 32 +++---- .../exnihilo/recipes/SieveDrops.java | 67 +++++++++----- .../SieveRecipeMap.java => ui/SieveUI.java} | 35 ++++---- 10 files changed, 204 insertions(+), 137 deletions(-) rename src/main/java/gregtech/integration/exnihilo/recipes/{recipemaps/SieveRecipeMap.java => ui/SieveUI.java} (51%) diff --git a/src/main/java/gregtech/api/GTValues.java b/src/main/java/gregtech/api/GTValues.java index d85bf34651e..4549dc6c075 100644 --- a/src/main/java/gregtech/api/GTValues.java +++ b/src/main/java/gregtech/api/GTValues.java @@ -156,11 +156,11 @@ public class GTValues { MODID_GENETICS = "genetics", MODID_BOP = "biomesoplenty", MODID_TCON = "tconstruct", - MODID_EN = "exnihilocreatio"; + MODID_EN = "exnihilocreatio", MODID_PROJRED_CORE = "projectred-core", MODID_RC = "railcraft", MODID_CHISEL = "chisel"; - + private static Boolean isClient; public static boolean isClientSide() { diff --git a/src/main/java/gregtech/integration/exnihilo/ExNihiloConfig.java b/src/main/java/gregtech/integration/exnihilo/ExNihiloConfig.java index 03fc9d68fd2..d3aa73fd494 100644 --- a/src/main/java/gregtech/integration/exnihilo/ExNihiloConfig.java +++ b/src/main/java/gregtech/integration/exnihilo/ExNihiloConfig.java @@ -1,11 +1,12 @@ package gregtech.integration.exnihilo; import gregtech.api.GTValues; + import net.minecraftforge.common.config.Config; import static net.minecraftforge.common.config.Config.Comment; -import static net.minecraftforge.common.config.Config.RequiresMcRestart; import static net.minecraftforge.common.config.Config.LangKey; +import static net.minecraftforge.common.config.Config.RequiresMcRestart; @LangKey("gregtech.config.ex_nihilo") @Config(modid = GTValues.MODID, name = GTValues.MODID + "/ex_nihilo", category = "Ex Nihilo") diff --git a/src/main/java/gregtech/integration/exnihilo/ExNihiloModule.java b/src/main/java/gregtech/integration/exnihilo/ExNihiloModule.java index f99425a3949..31cbe3f8ac6 100644 --- a/src/main/java/gregtech/integration/exnihilo/ExNihiloModule.java +++ b/src/main/java/gregtech/integration/exnihilo/ExNihiloModule.java @@ -1,11 +1,10 @@ package gregtech.integration.exnihilo; import gregtech.api.GTValues; -import gregtech.api.gui.GuiTextures; import gregtech.api.gui.resources.SteamTexture; -import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.modules.GregTechModule; import gregtech.api.recipes.RecipeMap; +import gregtech.api.recipes.RecipeMapBuilder; import gregtech.api.recipes.builders.SimpleRecipeBuilder; import gregtech.api.unification.material.event.MaterialEvent; import gregtech.api.unification.material.info.MaterialIconType; @@ -21,8 +20,9 @@ import gregtech.integration.exnihilo.recipes.ExNihiloRecipes; import gregtech.integration.exnihilo.recipes.MeshRecipes; import gregtech.integration.exnihilo.recipes.SieveDrops; -import gregtech.integration.exnihilo.recipes.recipemaps.SieveRecipeMap; +import gregtech.integration.exnihilo.recipes.ui.SieveUI; import gregtech.modules.GregTechModules; + import net.minecraft.init.SoundEvents; import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.ResourceLocation; @@ -33,7 +33,8 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; + import java.io.File; import java.util.Collections; import java.util.List; @@ -43,20 +44,24 @@ import static gregtech.common.metatileentities.MetaTileEntities.*; @GregTechModule( - moduleID = GregTechModules.MODULE_EN, - containerID = GTValues.MODID, - modDependencies = GTValues.MODID_EN, - name = "GregTech Ex Nihilo Creatio Integration", - description = "Ex Nihilo Integration Module") + moduleID = GregTechModules.MODULE_EN, + containerID = GTValues.MODID, + modDependencies = GTValues.MODID_EN, + name = "GregTech Ex Nihilo Creatio Integration", + description = "Ex Nihilo Integration Module") public class ExNihiloModule extends IntegrationSubmodule { // Items public static ExNihiloPebble GTPebbles; // Recipe maps - public static final RecipeMap SIEVE_RECIPES = new SieveRecipeMap("electric_sieve", 2, false, 36, true, 0, false, 0, false, new SimpleRecipeBuilder().duration(100).EUt(4), false) - .setProgressBar(GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED) - .setSound(SoundEvents.BLOCK_SAND_PLACE); + public static final RecipeMap SIEVE_RECIPES = new RecipeMapBuilder<>("electric_sieve", + new SimpleRecipeBuilder().duration(100).EUt(4)) + .itemInputs(2) + .itemOutputs(36) + .ui(SieveUI::new) + .sound(SoundEvents.BLOCK_SAND_PLACE) + .build(); // Machines public static MetaTileEntitySteamSieve STEAM_SIEVE_BRONZE; @@ -64,7 +69,8 @@ public class ExNihiloModule extends IntegrationSubmodule { public static MetaTileEntitySieve[] SIEVES = new MetaTileEntitySieve[GTValues.V.length - 1]; // Textures - public static final SteamTexture PROGRESS_BAR_SIFTER_STEAM = SteamTexture.fullImage("textures/gui/progress_bar/progress_bar_sift_%s.png"); + public static final SteamTexture PROGRESS_BAR_SIFTER_STEAM = SteamTexture + .fullImage("textures/gui/progress_bar/progress_bar_sift_%s.png"); // Ore prefixes public static OrePrefix oreChunk; @@ -76,7 +82,7 @@ public class ExNihiloModule extends IntegrationSubmodule { public static MaterialIconType oreEnderChunkIcon; public static MaterialIconType oreNetherChunkIcon; - @Nonnull + @NotNull @Override public List> getEventBusSubscribers() { return Collections.singletonList(ExNihiloModule.class); @@ -87,7 +93,8 @@ public void preInit(FMLPreInitializationEvent event) { getLogger().info("Registering Ex Nihilo Compat Items, Blocks, and Machines"); GTPebbles = new ExNihiloPebble(); registerMetaTileEntities(); - FileUtility.extractJarFiles(String.format("/assets/%s/%s", GTValues.MODID, "exnihilo"), new File(Loader.instance().getConfigDir(), "gregtech"), false); + FileUtility.extractJarFiles(String.format("/assets/%s/%s", GTValues.MODID, "exnihilo"), + new File(Loader.instance().getConfigDir(), "gregtech"), false); } @Override @@ -110,10 +117,10 @@ public static void registerMaterials(MaterialEvent event) { oreEnderChunkIcon = new MaterialIconType("oreEnderChunk"); oreNetherChunkIcon = new MaterialIconType("oreNetherChunk"); - oreChunk = new OrePrefix("oreChunk", -1, null, oreChunkIcon, ENABLE_UNIFICATION, hasOreProperty); oreEnderChunk = new OrePrefix("oreEnderChunk", -1, null, oreEnderChunkIcon, ENABLE_UNIFICATION, hasOreProperty); - oreNetherChunk = new OrePrefix("oreNetherChunk", -1, null, oreNetherChunkIcon, ENABLE_UNIFICATION, hasOreProperty); + oreNetherChunk = new OrePrefix("oreNetherChunk", -1, null, oreNetherChunkIcon, ENABLE_UNIFICATION, + hasOreProperty); oreChunk.setAlternativeOreName(OrePrefix.ore.name()); oreEnderChunk.setAlternativeOreName(OrePrefix.oreEndstone.name()); @@ -123,25 +130,40 @@ public static void registerMaterials(MaterialEvent event) { } private void registerMetaTileEntities() { - STEAM_SIEVE_BRONZE = MetaTileEntities.registerMetaTileEntity(4000, new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID ,"sieve.steam"), false)); - STEAM_SIEVE_STEEL = MetaTileEntities.registerMetaTileEntity(4001, new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "steam_sieve_steel"), true)); - - SIEVES[0] = MetaTileEntities.registerMetaTileEntity(4002, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.lv"), 1)); - SIEVES[1] = MetaTileEntities.registerMetaTileEntity(4003, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.mv"), 2)); - SIEVES[2] = MetaTileEntities.registerMetaTileEntity(4004, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.hv"), 3)); - SIEVES[3] = MetaTileEntities.registerMetaTileEntity(4005, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.ev"), 4)); - SIEVES[4] = MetaTileEntities.registerMetaTileEntity(4006, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.iv"), 5)); + STEAM_SIEVE_BRONZE = MetaTileEntities.registerMetaTileEntity(4000, + new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "sieve.steam"), false)); + STEAM_SIEVE_STEEL = MetaTileEntities.registerMetaTileEntity(4001, + new MetaTileEntitySteamSieve(new ResourceLocation(GTValues.MODID, "steam_sieve_steel"), true)); + + SIEVES[0] = MetaTileEntities.registerMetaTileEntity(4002, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.lv"), 1)); + SIEVES[1] = MetaTileEntities.registerMetaTileEntity(4003, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.mv"), 2)); + SIEVES[2] = MetaTileEntities.registerMetaTileEntity(4004, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.hv"), 3)); + SIEVES[3] = MetaTileEntities.registerMetaTileEntity(4005, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.ev"), 4)); + SIEVES[4] = MetaTileEntities.registerMetaTileEntity(4006, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.iv"), 5)); if (getMidTier("sieve")) { - SIEVES[5] = MetaTileEntities.registerMetaTileEntity(4007, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.luv"), 6)); - SIEVES[6] = MetaTileEntities.registerMetaTileEntity(4008, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.zpm"), 7)); - SIEVES[7] = MetaTileEntities.registerMetaTileEntity(4009, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uv"), 8)); + SIEVES[5] = MetaTileEntities.registerMetaTileEntity(4007, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.luv"), 6)); + SIEVES[6] = MetaTileEntities.registerMetaTileEntity(4008, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.zpm"), 7)); + SIEVES[7] = MetaTileEntities.registerMetaTileEntity(4009, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uv"), 8)); } if (getHighTier("sieve")) { - SIEVES[8] = MetaTileEntities.registerMetaTileEntity(4010, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uhv"), 9)); - SIEVES[9] = MetaTileEntities.registerMetaTileEntity(4011, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uev"), 10)); - SIEVES[10] = MetaTileEntities.registerMetaTileEntity(4012, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uiv"), 11)); - SIEVES[11] = MetaTileEntities.registerMetaTileEntity(4013, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uxv"), 12)); - SIEVES[12] = MetaTileEntities.registerMetaTileEntity(4014, new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.opv"), 13)); + SIEVES[8] = MetaTileEntities.registerMetaTileEntity(4010, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uhv"), 9)); + SIEVES[9] = MetaTileEntities.registerMetaTileEntity(4011, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uev"), 10)); + SIEVES[10] = MetaTileEntities.registerMetaTileEntity(4012, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uiv"), 11)); + SIEVES[11] = MetaTileEntities.registerMetaTileEntity(4013, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.uxv"), 12)); + SIEVES[12] = MetaTileEntities.registerMetaTileEntity(4014, + new MetaTileEntitySieve(new ResourceLocation(GTValues.MODID, "sieve.opv"), 13)); } } } diff --git a/src/main/java/gregtech/integration/exnihilo/items/ExNihiloPebble.java b/src/main/java/gregtech/integration/exnihilo/items/ExNihiloPebble.java index 7008dd74e7b..a4003dc35df 100644 --- a/src/main/java/gregtech/integration/exnihilo/items/ExNihiloPebble.java +++ b/src/main/java/gregtech/integration/exnihilo/items/ExNihiloPebble.java @@ -1,10 +1,7 @@ package gregtech.integration.exnihilo.items; -import exnihilocreatio.ExNihiloCreatio; -import exnihilocreatio.entities.ProjectileStone; -import exnihilocreatio.util.Data; -import exnihilocreatio.util.IHasModel; import gregtech.integration.exnihilo.ExNihiloModule; + import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; @@ -18,11 +15,16 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.jetbrains.annotations.Nullable; -import javax.annotation.Nonnull; +import exnihilocreatio.ExNihiloCreatio; +import exnihilocreatio.entities.ProjectileStone; +import exnihilocreatio.util.Data; +import exnihilocreatio.util.IHasModel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class ExNihiloPebble extends Item implements IHasModel { + public ExNihiloPebble() { setTranslationKey("gtPebble"); setRegistryName("gtPebble"); @@ -32,14 +34,14 @@ public ExNihiloPebble() { } @Override - @Nonnull - public String getTranslationKey(@Nonnull ItemStack stack) { + @NotNull + public String getTranslationKey(@NotNull ItemStack stack) { return String.format("%s.%s", getTranslationKey(), GTPebbles.VALUES[stack.getItemDamage()].getName()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList list) { + public void getSubItems(@Nullable CreativeTabs tab, @NotNull NonNullList list) { if (tab != null && isInCreativeTab(tab)) { for (GTPebbles pebble : GTPebbles.VALUES) { list.add(new ItemStack(ExNihiloModule.GTPebbles, 1, pebble.ordinal())); @@ -48,13 +50,15 @@ public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) { + @NotNull + public ActionResult onItemRightClick(@NotNull World world, @NotNull EntityPlayer player, + @NotNull EnumHand hand) { ItemStack stack = player.getHeldItem(hand); if (!stack.isEmpty()) { world.playSound(player, player.posX, player.posY, player.posZ, - SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, + 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!world.isRemote) { ItemStack thrown = stack.copy(); @@ -79,7 +83,8 @@ public ActionResult onItemRightClick(@Nonnull World world, @Nonnull E public void initModel(ModelRegistryEvent e) { ModelResourceLocation[] locations = new ModelResourceLocation[GTPebbles.VALUES.length]; for (GTPebbles pebble : GTPebbles.VALUES) { - locations[pebble.ordinal()] = new ModelResourceLocation(getRegistryName(), String.format("type=%s", pebble.getName())); + locations[pebble.ordinal()] = new ModelResourceLocation(getRegistryName(), + String.format("type=%s", pebble.getName())); } ModelBakery.registerItemVariants(this, locations); @@ -87,6 +92,7 @@ public void initModel(ModelRegistryEvent e) { } private enum GTPebbles implements IStringSerializable { + BASALT("basalt"), BLACK_GRANITE("black_granite"), MARBLE("marble"), @@ -100,7 +106,7 @@ private enum GTPebbles implements IStringSerializable { } @Override - @Nonnull + @NotNull public String getName() { return this.name; } diff --git a/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySieve.java b/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySieve.java index ea84b96da68..1818c0aaf6c 100644 --- a/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySieve.java +++ b/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySieve.java @@ -11,10 +11,11 @@ import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.client.renderer.texture.Textures; import gregtech.integration.exnihilo.ExNihiloModule; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; public class MetaTileEntitySieve extends SimpleMachineMetaTileEntity { @@ -28,13 +29,14 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity holder) { } @Override - protected ModularUI.Builder createGuiTemplate(@Nonnull EntityPlayer player) { + protected ModularUI.Builder createGuiTemplate(@NotNull EntityPlayer player) { ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND, 176, 192) .label(5, 5, this.getMetaFullName()) .slot(this.importItems, 0, 17, 25, GuiTextures.SLOT) .slot(this.importItems, 1, 35, 25, GuiTextures.SLOT) .progressBar(workable::getProgressPercent, 25, 50, 20, 20, - GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED, workable.getRecipeMap()) + GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED, + workable.getRecipeMap()) .widget(new ImageWidget(25, 69, 18, 18, GuiTextures.INDICATOR_NO_ENERGY).setIgnoreColor(true) .setPredicate(workable::isHasNotEnoughEnergy)) .bindPlayerInventory(player.inventory, GuiTextures.SLOT, 7, 109); @@ -47,13 +49,13 @@ protected ModularUI.Builder createGuiTemplate(@Nonnull EntityPlayer player) { builder.widget(new ToggleButtonWidget(7, 87, 18, 18, GuiTextures.BUTTON_ITEM_OUTPUT, this::isAutoOutputItems, this::setAutoOutputItems) - .setTooltipText("gregtech.gui.item_auto_output.tooltip") - .shouldUseBaseBackground()); + .setTooltipText("gregtech.gui.item_auto_output.tooltip") + .shouldUseBaseBackground()); builder.widget(new CycleButtonWidget(25, 87, 18, 18, workable.getAvailableOverclockingTiers(), workable::getOverclockTier, workable::setOverclockTier) - .setTooltipHoverString("gregtech.gui.overclock.description") - .setButtonTexture(GuiTextures.BUTTON_OVERCLOCK)); + .setTooltipHoverString("gregtech.gui.overclock.description") + .setButtonTexture(GuiTextures.BUTTON_OVERCLOCK)); return builder; } diff --git a/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySteamSieve.java b/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySteamSieve.java index 7984177657e..b901b63e2ec 100644 --- a/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySteamSieve.java +++ b/src/main/java/gregtech/integration/exnihilo/metatileentities/MetaTileEntitySteamSieve.java @@ -10,11 +10,12 @@ import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.client.renderer.texture.Textures; import gregtech.integration.exnihilo.ExNihiloModule; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.items.IItemHandlerModifiable; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; public class MetaTileEntitySteamSieve extends SteamMetaTileEntity { @@ -38,20 +39,24 @@ protected IItemHandlerModifiable createExportItemHandler() { } @Override - protected ModularUI createUI(@Nonnull EntityPlayer player) { - ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND_STEAM.get(this.isHighPressure), 176, 192) - .label(6, 6, this.getMetaFullName()).shouldColor(false) - .slot(this.importItems, 0, 17, 43, GuiTextures.SLOT_STEAM.get(isHighPressure)) - .slot(this.importItems, 1, 35, 43, GuiTextures.SLOT_STEAM.get(isHighPressure)) - .progressBar(workableHandler::getProgressPercent, 25, 68, 20, 20, - ExNihiloModule.PROGRESS_BAR_SIFTER_STEAM.get(isHighPressure), ProgressWidget.MoveType.VERTICAL_INVERTED, workableHandler.getRecipeMap()) - .widget((new ImageWidget(79, 77, 18, 18, GuiTextures.INDICATOR_NO_STEAM.get(this.isHighPressure))) - .setPredicate(() -> this.workableHandler.isHasNotEnoughEnergy())) - .bindPlayerInventory(player.inventory, GuiTextures.SLOT_STEAM.get(this.isHighPressure), 7, 109); + protected ModularUI createUI(@NotNull EntityPlayer player) { + ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND_STEAM.get(this.isHighPressure), 176, + 192) + .label(6, 6, this.getMetaFullName()).shouldColor(false) + .slot(this.importItems, 0, 17, 43, GuiTextures.SLOT_STEAM.get(isHighPressure)) + .slot(this.importItems, 1, 35, 43, GuiTextures.SLOT_STEAM.get(isHighPressure)) + .progressBar(workableHandler::getProgressPercent, 25, 68, 20, 20, + ExNihiloModule.PROGRESS_BAR_SIFTER_STEAM.get(isHighPressure), + ProgressWidget.MoveType.VERTICAL_INVERTED, workableHandler.getRecipeMap()) + .widget((new ImageWidget(79, 77, 18, 18, + GuiTextures.INDICATOR_NO_STEAM.get(this.isHighPressure))) + .setPredicate(() -> this.workableHandler.isHasNotEnoughEnergy())) + .bindPlayerInventory(player.inventory, GuiTextures.SLOT_STEAM.get(this.isHighPressure), 7, 109); for (int y = 0; y < 5; y++) { for (int x = 0; x < 6; x++) { - builder.slot(this.exportItems, y * 6 + x, 61 + x * 18, 15 + y * 18, true, false, GuiTextures.SLOT_STEAM.get(isHighPressure)); + builder.slot(this.exportItems, y * 6 + x, 61 + x * 18, 15 + y * 18, true, false, + GuiTextures.SLOT_STEAM.get(isHighPressure)); } } diff --git a/src/main/java/gregtech/integration/exnihilo/recipes/ExNihiloRecipes.java b/src/main/java/gregtech/integration/exnihilo/recipes/ExNihiloRecipes.java index 77345da27ea..ab7811a3905 100644 --- a/src/main/java/gregtech/integration/exnihilo/recipes/ExNihiloRecipes.java +++ b/src/main/java/gregtech/integration/exnihilo/recipes/ExNihiloRecipes.java @@ -1,11 +1,6 @@ package gregtech.integration.exnihilo.recipes; -import exnihilocreatio.ModBlocks; -import exnihilocreatio.compatibility.jei.sieve.SieveRecipe; -import exnihilocreatio.registries.manager.ExNihiloRegistryManager; -import exnihilocreatio.registries.types.Siftable; import gregtech.api.recipes.ModHandler; -import gregtech.api.recipes.Recipe; import gregtech.api.recipes.builders.SimpleRecipeBuilder; import gregtech.api.recipes.chance.output.ChancedOutputLogic; import gregtech.api.unification.OreDictUnifier; @@ -18,9 +13,15 @@ import gregtech.common.blocks.MetaBlocks; import gregtech.integration.exnihilo.ExNihiloModule; import gregtech.loaders.recipe.MetaTileEntityLoader; + import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import exnihilocreatio.ModBlocks; +import exnihilocreatio.compatibility.jei.sieve.SieveRecipe; +import exnihilocreatio.registries.manager.ExNihiloRegistryManager; +import exnihilocreatio.registries.types.Siftable; + import java.util.ArrayList; import java.util.Arrays; @@ -54,9 +55,16 @@ private static void processChunk(OrePrefix orePrefix, Material material, OreProp public static void registerGTRecipes() { // Machine Recipes - MetaTileEntityLoader.registerMachineRecipe(SIEVES, "CPC", "FMF", "OSO", 'M', HULL, 'C', CIRCUIT, 'O', CABLE, 'F', CONVEYOR, 'S', new ItemStack(ModBlocks.sieve), 'P', PISTON); - ModHandler.addShapedRecipe(true, "steam_sieve_bronze", STEAM_SIEVE_BRONZE.getStackForm(), "BPB", "BMB", "BSB", 'B', new UnificationEntry(OrePrefix.pipeSmallFluid, Materials.Bronze), 'M', MetaBlocks.STEAM_CASING.getItemVariant(BRONZE_HULL), 'S', new ItemStack(ModBlocks.sieve), 'P', Blocks.PISTON); - ModHandler.addShapedRecipe(true, "steam_sieve_steel", STEAM_SIEVE_STEEL.getStackForm(), "BPB", "WMW", "BBB", 'B', new UnificationEntry(OrePrefix.pipeSmallFluid, Materials.WroughtIron), 'M', STEAM_SIEVE_BRONZE.getStackForm(), 'W', new UnificationEntry(OrePrefix.plate, Materials.WroughtIron), 'P', new UnificationEntry(OrePrefix.plate, Materials.Steel)); + MetaTileEntityLoader.registerMachineRecipe(SIEVES, "CPC", "FMF", "OSO", 'M', HULL, 'C', CIRCUIT, 'O', CABLE, + 'F', CONVEYOR, 'S', new ItemStack(ModBlocks.sieve), 'P', PISTON); + ModHandler.addShapedRecipe(true, "steam_sieve_bronze", STEAM_SIEVE_BRONZE.getStackForm(), "BPB", "BMB", "BSB", + 'B', new UnificationEntry(OrePrefix.pipeSmallFluid, Materials.Bronze), 'M', + MetaBlocks.STEAM_CASING.getItemVariant(BRONZE_HULL), 'S', new ItemStack(ModBlocks.sieve), 'P', + Blocks.PISTON); + ModHandler.addShapedRecipe(true, "steam_sieve_steel", STEAM_SIEVE_STEEL.getStackForm(), "BPB", "WMW", "BBB", + 'B', new UnificationEntry(OrePrefix.pipeSmallFluid, Materials.WroughtIron), 'M', + STEAM_SIEVE_BRONZE.getStackForm(), 'W', new UnificationEntry(OrePrefix.plate, Materials.WroughtIron), + 'P', new UnificationEntry(OrePrefix.plate, Materials.Steel)); } // Has to be done in init phase because of ExNi registering outside the Registry event @@ -64,9 +72,11 @@ public static void registerExNihiloRecipes() { // Mirror Ex Nihilo Sifter recipes to Sifter RecipeMap for (SieveRecipe recipe : ExNihiloRegistryManager.SIEVE_REGISTRY.getRecipeList()) { for (ItemStack stack : recipe.getSievables()) { - if (SIEVE_RECIPES.findRecipe(4, Arrays.asList(stack, recipe.getMesh()), new ArrayList<>(), true) != null) + if (SIEVE_RECIPES.findRecipe(4, Arrays.asList(stack, recipe.getMesh()), new ArrayList<>(), true) != + null) continue; - SimpleRecipeBuilder builder = SIEVE_RECIPES.recipeBuilder().notConsumable(recipe.getMesh()).inputs(stack); + SimpleRecipeBuilder builder = SIEVE_RECIPES.recipeBuilder().notConsumable(recipe.getMesh()) + .inputs(stack); for (Siftable siftable : ExNihiloRegistryManager.SIEVE_REGISTRY.getDrops(stack)) { if (siftable.getDrop() == null) continue; @@ -75,7 +85,8 @@ public static void registerExNihiloRecipes() { if ((int) (siftable.getChance() * (float) maxChance) >= maxChance) { builder.outputs(siftable.getDrop().getItemStack()); } else { - builder.chancedOutput(siftable.getDrop().getItemStack(), (int) (siftable.getChance() * (float) maxChance), 200); + builder.chancedOutput(siftable.getDrop().getItemStack(), + (int) (siftable.getChance() * (float) maxChance), 200); } } } diff --git a/src/main/java/gregtech/integration/exnihilo/recipes/MeshRecipes.java b/src/main/java/gregtech/integration/exnihilo/recipes/MeshRecipes.java index 750efc9df54..b080dd2a9c0 100644 --- a/src/main/java/gregtech/integration/exnihilo/recipes/MeshRecipes.java +++ b/src/main/java/gregtech/integration/exnihilo/recipes/MeshRecipes.java @@ -1,49 +1,50 @@ package gregtech.integration.exnihilo.recipes; - -import exnihilocreatio.ModBlocks; -import exnihilocreatio.ModItems; import gregtech.api.recipes.ModHandler; import gregtech.api.unification.OreDictUnifier; import gregtech.api.unification.material.Materials; import gregtech.api.unification.stack.UnificationEntry; import gregtech.integration.exnihilo.ExNihiloConfig; import gregtech.integration.exnihilo.ExNihiloModule; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import exnihilocreatio.ModBlocks; +import exnihilocreatio.ModItems; + import static gregtech.api.recipes.RecipeMaps.*; import static gregtech.api.unification.material.Materials.*; import static gregtech.api.unification.ore.OrePrefix.*; -//TODO: Find a better name for this Class +// TODO: Find a better name for this Class public class MeshRecipes { - public static void init() { if (ExNihiloConfig.harderMeshes) { ModHandler.removeRecipeByName("exnihilocreatio:item_mesh_2"); ModHandler.addShapedRecipe("bronze_mesh", new ItemStack(ModItems.mesh, 1, 2), "TST", "STS", "TST", 'T', new UnificationEntry(stick, Materials.Bronze), - 'S', new ItemStack(Items.STRING) - ); + 'S', new ItemStack(Items.STRING)); ModHandler.removeRecipeByName("exnihilocreatio:item_mesh_3"); ModHandler.addShapedRecipe("steel_mesh", new ItemStack(ModItems.mesh, 1, 3), "TST", "STS", "TST", 'T', new UnificationEntry(stick, Steel), - 'S', new ItemStack(Items.STRING) - ); + 'S', new ItemStack(Items.STRING)); ModHandler.removeRecipeByName("exnihilocreatio:item_mesh_4"); ModHandler.addShapedRecipe("aluminium_mesh", new ItemStack(ModItems.mesh, 1, 4), "TST", "STS", "TST", 'T', new UnificationEntry(stick, Aluminium), - 'S', new ItemStack(Items.STRING) - ); + 'S', new ItemStack(Items.STRING)); } - ModHandler.addShapedRecipe("basalt", OreDictUnifier.get(stone, Basalt, 1), "PP", "PP", 'P', new ItemStack(ExNihiloModule.GTPebbles, 1, 0)); - ModHandler.addShapedRecipe("black_granite", OreDictUnifier.get(stone, GraniteBlack, 1), "PP", "PP", 'P', new ItemStack(ExNihiloModule.GTPebbles, 1, 1)); - ModHandler.addShapedRecipe("marble", OreDictUnifier.get(stone, Marble, 1), "PP", "PP", 'P', new ItemStack(ExNihiloModule.GTPebbles, 1, 2)); - ModHandler.addShapedRecipe("red_granite", OreDictUnifier.get(stone, GraniteRed, 1), "PP", "PP", 'P', new ItemStack(ExNihiloModule.GTPebbles, 1, 3)); + ModHandler.addShapedRecipe("basalt", OreDictUnifier.get(stone, Basalt, 1), "PP", "PP", 'P', + new ItemStack(ExNihiloModule.GTPebbles, 1, 0)); + ModHandler.addShapedRecipe("black_granite", OreDictUnifier.get(stone, GraniteBlack, 1), "PP", "PP", 'P', + new ItemStack(ExNihiloModule.GTPebbles, 1, 1)); + ModHandler.addShapedRecipe("marble", OreDictUnifier.get(stone, Marble, 1), "PP", "PP", 'P', + new ItemStack(ExNihiloModule.GTPebbles, 1, 2)); + ModHandler.addShapedRecipe("red_granite", OreDictUnifier.get(stone, GraniteRed, 1), "PP", "PP", 'P', + new ItemStack(ExNihiloModule.GTPebbles, 1, 3)); FORGE_HAMMER_RECIPES.recipeBuilder() .duration(10).EUt(16) @@ -134,6 +135,5 @@ public static void init() { .input(stone, Diorite) .fluidOutputs(Materials.Lava.getFluid(250)) .buildAndRegister(); - } } diff --git a/src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java b/src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java index 08652855c7b..e980ed46626 100644 --- a/src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java +++ b/src/main/java/gregtech/integration/exnihilo/recipes/SieveDrops.java @@ -1,12 +1,5 @@ package gregtech.integration.exnihilo.recipes; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import exnihilocreatio.ModBlocks; -import exnihilocreatio.blocks.BlockSieve; -import exnihilocreatio.registries.manager.ExNihiloRegistryManager; -import exnihilocreatio.registries.types.Siftable; -import exnihilocreatio.util.ItemInfo; import gregtech.api.GregTechAPI; import gregtech.api.unification.OreDictUnifier; import gregtech.api.util.FileUtility; @@ -14,6 +7,7 @@ import gregtech.integration.IntegrationModule; import gregtech.integration.exnihilo.ExNihiloConfig; import gregtech.integration.exnihilo.ExNihiloModule; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -22,6 +16,14 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.oredict.OreDictionary; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import exnihilocreatio.ModBlocks; +import exnihilocreatio.blocks.BlockSieve; +import exnihilocreatio.registries.manager.ExNihiloRegistryManager; +import exnihilocreatio.registries.types.Siftable; +import exnihilocreatio.util.ItemInfo; + import java.io.File; import static gregtech.integration.exnihilo.ExNihiloModule.*; @@ -43,6 +45,7 @@ private static boolean validateDrops(String material, int meshlevel, float chanc } return true; } + private static void processDrops(JsonElement element) { if (!element.isJsonObject()) { IntegrationModule.logger.error("Parsed JSONElement is not an JSON Object!"); @@ -72,20 +75,27 @@ private static void processDrops(JsonElement element) { m.entrySet().forEach(material -> { JsonObject values = material.getValue().getAsJsonObject(); ItemStack stack; - if (!validateDrops(material.getKey(), values.get("meshlevel").getAsInt(), values.get("chance").getAsFloat())) { + if (!validateDrops(material.getKey(), values.get("meshlevel").getAsInt(), + values.get("chance").getAsFloat())) { return; } if (oreDict != null || !(block == ModBlocks.netherrackCrushed || block == ModBlocks.endstoneCrushed)) { stack = OreDictUnifier.get(oreChunk, GregTechAPI.materialManager.getMaterial(material.getKey())); } else { - stack = block == ModBlocks.netherrackCrushed - ? OreDictUnifier.get(oreNetherChunk, GregTechAPI.materialManager.getMaterial(material.getKey())) - : OreDictUnifier.get(oreEnderChunk, GregTechAPI.materialManager.getMaterial(material.getKey())); + stack = block == ModBlocks.netherrackCrushed ? + OreDictUnifier.get(oreNetherChunk, + GregTechAPI.materialManager.getMaterial(material.getKey())) : + OreDictUnifier.get(oreEnderChunk, + GregTechAPI.materialManager.getMaterial(material.getKey())); } if (oreDict != null) { - ExNihiloRegistryManager.SIEVE_REGISTRY.register(oreDict, new ItemInfo(stack.getItem(), stack.getMetadata()), values.get("chance").getAsFloat(), values.get("meshlevel").getAsInt()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register(oreDict, + new ItemInfo(stack.getItem(), stack.getMetadata()), values.get("chance").getAsFloat(), + values.get("meshlevel").getAsInt()); } else { - ExNihiloRegistryManager.SIEVE_REGISTRY.register(block.getDefaultState(), new ItemInfo(stack.getItem(), stack.getMetadata()), values.get("chance").getAsFloat(), values.get("meshlevel").getAsInt()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register(block.getDefaultState(), + new ItemInfo(stack.getItem(), stack.getMetadata()), values.get("chance").getAsFloat(), + values.get("meshlevel").getAsInt()); } }); }); @@ -103,16 +113,27 @@ public static void registerRecipes() { return false; }); ExNihiloRegistryManager.SIEVE_REGISTRY.getRegistry().clear(); - ExNihiloRegistryManager.SIEVE_REGISTRY.getRegistry().put(Ingredient.fromStacks(new ItemStack(Blocks.DIRT)), siftable); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 3), 0.1f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles), 0.5f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles), 0.1f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 1), 0.5f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 1), 0.1f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 2), 0.5f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 2), 0.1f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 3), 0.5f, BlockSieve.MeshType.STRING.getID()); - ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(MetaBlocks.RUBBER_SAPLING.getBlockState().getBlock()), 0.1f, BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.getRegistry().put(Ingredient.fromStacks(new ItemStack(Blocks.DIRT)), + siftable); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 3), 0.1f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles), 0.5f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles), 0.1f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 1), 0.5f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 1), 0.1f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 2), 0.5f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 2), 0.1f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", new ItemInfo(ExNihiloModule.GTPebbles, 3), 0.5f, + BlockSieve.MeshType.STRING.getID()); + ExNihiloRegistryManager.SIEVE_REGISTRY.register("dirt", + new ItemInfo(MetaBlocks.RUBBER_SAPLING.getBlockState().getBlock()), 0.1f, + BlockSieve.MeshType.STRING.getID()); } } } diff --git a/src/main/java/gregtech/integration/exnihilo/recipes/recipemaps/SieveRecipeMap.java b/src/main/java/gregtech/integration/exnihilo/recipes/ui/SieveUI.java similarity index 51% rename from src/main/java/gregtech/integration/exnihilo/recipes/recipemaps/SieveRecipeMap.java rename to src/main/java/gregtech/integration/exnihilo/recipes/ui/SieveUI.java index c66d8175380..c880a1c7d7d 100644 --- a/src/main/java/gregtech/integration/exnihilo/recipes/recipemaps/SieveRecipeMap.java +++ b/src/main/java/gregtech/integration/exnihilo/recipes/ui/SieveUI.java @@ -1,36 +1,34 @@ -package gregtech.integration.exnihilo.recipes.recipemaps; +package gregtech.integration.exnihilo.recipes.ui; import gregtech.api.capability.impl.FluidTankList; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; +import gregtech.api.gui.widgets.ProgressWidget; import gregtech.api.gui.widgets.RecipeProgressWidget; import gregtech.api.recipes.RecipeMap; -import gregtech.api.recipes.builders.SimpleRecipeBuilder; -import net.minecraftforge.items.IItemHandlerModifiable; +import gregtech.api.recipes.ui.RecipeMapUI; -import javax.annotation.Nonnull; +import net.minecraftforge.items.IItemHandlerModifiable; +import org.jetbrains.annotations.NotNull; -public class SieveRecipeMap extends RecipeMap { +public class SieveUI> extends RecipeMapUI { - public SieveRecipeMap( String unlocalizedName, - int maxInputs, boolean modifyItemInputs, - int maxOutputs, boolean modifyItemOutputs, - int maxFluidInputs, boolean modifyFluidInputs, - int maxFluidOutputs, boolean modifyFluidOutputs, - SimpleRecipeBuilder defaultRecipeBuilder, - boolean isHidden) { - super(unlocalizedName, maxInputs, modifyItemInputs, maxOutputs, modifyItemOutputs, maxFluidInputs, modifyFluidInputs, maxFluidOutputs, modifyFluidOutputs, defaultRecipeBuilder, isHidden ); + public SieveUI(@NotNull R recipeMap) { + super(recipeMap, false, true, false, false); + setProgressBar(GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL_INVERTED); } @Override - @Nonnull - public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { + @NotNull + public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, + FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { ModularUI.Builder builder = new ModularUI.Builder(GuiTextures.BACKGROUND, 176, 192 + yOffset); - builder.widget(new RecipeProgressWidget(200, 25, 50 + yOffset, 20, 20, this.progressBarTexture, this.moveType, this)); + builder.widget(new RecipeProgressWidget(200, 25, 50 + yOffset, 20, 20, this.progressBarTexture(), + this.progressBarMoveType(), this.recipeMap())); this.addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); this.addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); - if (this.specialTexture != null && this.specialTexturePosition != null) { + if (this.specialTexture() != null && this.specialTexturePosition() != null) { this.addSpecialTexture(builder); } @@ -38,7 +36,8 @@ public ModularUI.Builder createJeiUITemplate(IItemHandlerModifiable importItems, } @Override - protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModifiable itemHandler, FluidTankList fluidHandler, boolean isOutputs, int yOffset) { + protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModifiable itemHandler, + FluidTankList fluidHandler, boolean isOutputs, int yOffset) { if (isOutputs) { for (int y = 0; y < 5; y++) { for (int x = 0; x < 6; x++) {