diff --git a/src/main/java/gregtech/api/gui/GuiTextures.java b/src/main/java/gregtech/api/gui/GuiTextures.java index a5cf1ed47e8..ce68f9baecb 100644 --- a/src/main/java/gregtech/api/gui/GuiTextures.java +++ b/src/main/java/gregtech/api/gui/GuiTextures.java @@ -223,4 +223,13 @@ public class GuiTextures { public final static TextureArea ICON_CALCULATOR = TextureArea.fullImage("textures/gui/terminal/icon/other/calculator_hover.png"); public final static TextureArea UI_FRAME_SIDE_UP = TextureArea.fullImage("textures/gui/terminal/frame_side_up.png"); public final static TextureArea UI_FRAME_SIDE_DOWN = TextureArea.fullImage("textures/gui/terminal/frame_side_down.png"); + + // Texture Areas + public static final TextureArea BUTTON_FLUID = TextureArea.fullImage("textures/blocks/cover/cover_interface_fluid_button.png"); + public static final TextureArea BUTTON_ITEM = TextureArea.fullImage("textures/blocks/cover/cover_interface_item_button.png"); + public static final TextureArea BUTTON_ENERGY = TextureArea.fullImage("textures/blocks/cover/cover_interface_energy_button.png"); + public static final TextureArea BUTTON_MACHINE = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_button.png"); + public static final TextureArea BUTTON_INTERFACE = TextureArea.fullImage("textures/blocks/cover/cover_interface_computer_button.png"); + public static final TextureArea COVER_INTERFACE_MACHINE_ON_PROXY = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_on_proxy.png"); + public static final TextureArea COVER_INTERFACE_MACHINE_OFF_PROXY = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_off_proxy.png"); } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java index 5c115501550..a6757910c4a 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java @@ -9,40 +9,41 @@ import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.items.IItemHandlerModifiable; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; @SuppressWarnings("InstantiationOfUtilityClass") public class MultiblockAbility { + public static final Map> NAME_REGISTRY = new HashMap<>(); + public static final Map, List> REGISTRY = new Object2ObjectOpenHashMap<>(); - public static final MultiblockAbility EXPORT_ITEMS = new MultiblockAbility<>(); - public static final MultiblockAbility IMPORT_ITEMS = new MultiblockAbility<>(); + public static final MultiblockAbility EXPORT_ITEMS = new MultiblockAbility<>("export_items"); + public static final MultiblockAbility IMPORT_ITEMS = new MultiblockAbility<>("import_items"); - public static final MultiblockAbility EXPORT_FLUIDS = new MultiblockAbility<>(); - public static final MultiblockAbility IMPORT_FLUIDS = new MultiblockAbility<>(); + public static final MultiblockAbility EXPORT_FLUIDS = new MultiblockAbility<>("export_fluids"); + public static final MultiblockAbility IMPORT_FLUIDS = new MultiblockAbility<>("import_fluids"); - public static final MultiblockAbility INPUT_ENERGY = new MultiblockAbility<>(); - public static final MultiblockAbility OUTPUT_ENERGY = new MultiblockAbility<>(); + public static final MultiblockAbility INPUT_ENERGY = new MultiblockAbility<>("input_energy"); + public static final MultiblockAbility OUTPUT_ENERGY = new MultiblockAbility<>("output_energy"); - public static final MultiblockAbility ABILITY_ROTOR_HOLDER = new MultiblockAbility<>(); + public static final MultiblockAbility ABILITY_ROTOR_HOLDER = new MultiblockAbility<>("ability_rotor_holder"); - public static final MultiblockAbility PUMP_FLUID_HATCH = new MultiblockAbility<>(); + public static final MultiblockAbility PUMP_FLUID_HATCH = new MultiblockAbility<>("pump_fluid_hatch"); - public static final MultiblockAbility STEAM = new MultiblockAbility<>(); - public static final MultiblockAbility STEAM_IMPORT_ITEMS = new MultiblockAbility<>(); - public static final MultiblockAbility STEAM_EXPORT_ITEMS = new MultiblockAbility<>(); + public static final MultiblockAbility STEAM = new MultiblockAbility<>("steam"); + public static final MultiblockAbility STEAM_IMPORT_ITEMS = new MultiblockAbility<>("steam_import_items"); + public static final MultiblockAbility STEAM_EXPORT_ITEMS = new MultiblockAbility<>("steam_export_items"); - public static final MultiblockAbility MAINTENANCE_HATCH = new MultiblockAbility<>(); - public static final MultiblockAbility MUFFLER_HATCH = new MultiblockAbility<>(); - - public static final Map, List> REGISTER = new Object2ObjectOpenHashMap<>(); + public static final MultiblockAbility MAINTENANCE_HATCH = new MultiblockAbility<>("maintenance_hatch"); + public static final MultiblockAbility MUFFLER_HATCH = new MultiblockAbility<>("muffler_hatch"); public static void registerMultiblockAbility(MultiblockAbility ability, MetaTileEntity part) { - if (!REGISTER.containsKey(ability)) { - REGISTER.put(ability, new ArrayList<>()); + if (!REGISTRY.containsKey(ability)) { + REGISTRY.put(ability, new ArrayList<>()); } - REGISTER.get(ability).add(part); + REGISTRY.get(ability).add(part); + } + + public MultiblockAbility(String name){ + NAME_REGISTRY.put(name.toLowerCase(), this); } } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockControllerBase.java b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockControllerBase.java index 59a8b5972de..7fa18eb990c 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockControllerBase.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockControllerBase.java @@ -5,7 +5,6 @@ import codechicken.lib.render.pipeline.IVertexOperation; import codechicken.lib.vec.Matrix4; import gregtech.api.capability.GregtechCapabilities; -import gregtech.api.capability.IMaintenanceHatch; import gregtech.api.capability.IMultiblockController; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.MetaTileEntityHolder; @@ -15,13 +14,11 @@ import gregtech.api.pattern.TraceabilityPredicate; import gregtech.api.render.ICubeRenderer; import gregtech.api.render.OrientedOverlayRenderer; -import gregtech.api.render.SimpleOverlayRenderer; import gregtech.api.render.Textures; import gregtech.api.util.BlockInfo; import gregtech.api.util.GTUtility; import gregtech.common.blocks.MetaBlocks; import gregtech.common.blocks.VariantActiveBlock; -import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityRotorHolder; import gregtech.api.pattern.MultiblockShapeInfo; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -163,7 +160,7 @@ private static Supplier getCandidates(IBlockState... allowedStates) public static TraceabilityPredicate abilities(MultiblockAbility... allowedAbilities) { return tilePredicate((state, tile) -> tile instanceof IMultiblockAbilityPart && ArrayUtils.contains(allowedAbilities, ((IMultiblockAbilityPart) tile).getAbility()), - getCandidates(Arrays.stream(allowedAbilities).flatMap(ability -> MultiblockAbility.REGISTER.get(ability).stream()).toArray(MetaTileEntity[]::new))); + getCandidates(Arrays.stream(allowedAbilities).flatMap(ability -> MultiblockAbility.REGISTRY.get(ability).stream()).toArray(MetaTileEntity[]::new))); } public static TraceabilityPredicate states(IBlockState... allowedStates) { diff --git a/src/main/java/gregtech/api/render/IOverlayRenderer.java b/src/main/java/gregtech/api/render/IOverlayRenderer.java new file mode 100644 index 00000000000..a80f63ba60d --- /dev/null +++ b/src/main/java/gregtech/api/render/IOverlayRenderer.java @@ -0,0 +1,22 @@ +package gregtech.api.render; + +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Matrix4; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IOverlayRenderer { + + @SideOnly(Side.CLIENT) + default void renderSided(EnumFacing side, CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { + renderSided(side, Cuboid6.full, renderState, pipeline, translation); + } + + @SideOnly(Side.CLIENT) + void renderSided(EnumFacing side, Cuboid6 bounds, CCRenderState renderState, IVertexOperation[] pipeline, Matrix4 translation); + +} diff --git a/src/main/java/gregtech/api/render/SimpleCubeRenderer.java b/src/main/java/gregtech/api/render/SimpleCubeRenderer.java index eb6619f4889..2caf7c5f525 100644 --- a/src/main/java/gregtech/api/render/SimpleCubeRenderer.java +++ b/src/main/java/gregtech/api/render/SimpleCubeRenderer.java @@ -31,6 +31,7 @@ public class SimpleCubeRenderer implements ICubeRenderer, IIconRegister { public SimpleCubeRenderer(String basePath) { this.basePath = basePath; + Textures.CUBE_RENDERER_REGISTRY.put(basePath, this); Textures.iconRegisters.add(this); } diff --git a/src/main/java/gregtech/api/render/SimpleOverlayRenderer.java b/src/main/java/gregtech/api/render/SimpleOverlayRenderer.java index 56ae720360f..962a9d7da3e 100644 --- a/src/main/java/gregtech/api/render/SimpleOverlayRenderer.java +++ b/src/main/java/gregtech/api/render/SimpleOverlayRenderer.java @@ -18,7 +18,7 @@ import javax.annotation.Nullable; -public class SimpleOverlayRenderer implements IIconRegister { +public class SimpleOverlayRenderer implements IOverlayRenderer, IIconRegister { private final String basePath; @@ -31,6 +31,7 @@ public class SimpleOverlayRenderer implements IIconRegister { public SimpleOverlayRenderer(String basePath) { this.basePath = basePath; + Textures.CUBE_SIDE_RENDERER_REGISTRY.put(basePath, this); Textures.iconRegisters.add(this); } diff --git a/src/main/java/gregtech/api/render/SimpleSidedCubeRenderer.java b/src/main/java/gregtech/api/render/SimpleSidedCubeRenderer.java index 220b73db4bf..276ff02a966 100644 --- a/src/main/java/gregtech/api/render/SimpleSidedCubeRenderer.java +++ b/src/main/java/gregtech/api/render/SimpleSidedCubeRenderer.java @@ -43,6 +43,7 @@ public static RenderSide bySide(EnumFacing side) { public SimpleSidedCubeRenderer(String basePath) { this.basePath = basePath; + Textures.CUBE_RENDERER_REGISTRY.put(basePath, this); Textures.iconRegisters.add(this); } diff --git a/src/main/java/gregtech/api/render/Textures.java b/src/main/java/gregtech/api/render/Textures.java index d3d3ccf249a..fee5eb73a6d 100644 --- a/src/main/java/gregtech/api/render/Textures.java +++ b/src/main/java/gregtech/api/render/Textures.java @@ -10,11 +10,10 @@ import codechicken.lib.vec.uv.IconTransformation; import codechicken.lib.vec.uv.UVTransformationList; import gregtech.api.GTValues; -import gregtech.api.gui.resources.TextureArea; import gregtech.api.util.GTLog; -import gregtech.core.hooks.BloomRenderLayerHooks; import gregtech.common.render.CrateRenderer; import gregtech.common.render.DrumRenderer; +import gregtech.core.hooks.BloomRenderLayerHooks; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.EnumFacing; @@ -23,12 +22,17 @@ import org.apache.commons.lang3.ArrayUtils; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static gregtech.api.render.OrientedOverlayRenderer.OverlayFace.*; public class Textures { + public static final Map CUBE_RENDERER_REGISTRY = new HashMap<>(); + public static final Map CUBE_SIDE_RENDERER_REGISTRY = new HashMap<>(); + private static final ThreadLocal blockFaces = ThreadLocal.withInitial(BlockFace::new); public static final List iconRegisters = new ArrayList<>(); @@ -226,15 +230,6 @@ public class Textures { public static final SimpleOverlayRenderer COVER_INTERFACE_PROXY = new SimpleOverlayRenderer("cover/cover_interface_proxy"); public static final SimpleOverlayRenderer COVER_INTERFACE_WIRELESS = new SimpleOverlayRenderer("cover/cover_interface_wireless"); - // Texture Areas - public static final TextureArea BUTTON_FLUID = TextureArea.fullImage("textures/blocks/cover/cover_interface_fluid_button.png"); - public static final TextureArea BUTTON_ITEM = TextureArea.fullImage("textures/blocks/cover/cover_interface_item_button.png"); - public static final TextureArea BUTTON_ENERGY = TextureArea.fullImage("textures/blocks/cover/cover_interface_energy_button.png"); - public static final TextureArea BUTTON_MACHINE = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_button.png"); - public static final TextureArea BUTTON_INTERFACE = TextureArea.fullImage("textures/blocks/cover/cover_interface_computer_button.png"); - public static final TextureArea COVER_INTERFACE_MACHINE_ON_PROXY = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_on_proxy.png"); - public static final TextureArea COVER_INTERFACE_MACHINE_OFF_PROXY = TextureArea.fullImage("textures/blocks/cover/cover_interface_machine_off_proxy.png"); - static { for (int i = 0; i < VOLTAGE_CASINGS.length; i++) { diff --git a/src/main/java/gregtech/common/covers/CoverDigitalInterface.java b/src/main/java/gregtech/common/covers/CoverDigitalInterface.java index 7e283897f06..31d496afa8f 100644 --- a/src/main/java/gregtech/common/covers/CoverDigitalInterface.java +++ b/src/main/java/gregtech/common/covers/CoverDigitalInterface.java @@ -431,19 +431,19 @@ public ModularUI createUI(EntityPlayer player) { WidgetGroup primaryGroup = new WidgetGroup(new Position(0, 10)); primaryGroup.addWidget(new LabelWidget(10, 5, "metaitem.cover.digital.name", 0)); ToggleButtonWidget[] buttons = new ToggleButtonWidget[5]; - buttons[0] = new ToggleButtonWidget(40, 20, 20, 20, Textures.BUTTON_FLUID, () -> this.mode == MODE.FLUID, (pressed) -> { + buttons[0] = new ToggleButtonWidget(40, 20, 20, 20, GuiTextures.BUTTON_FLUID, () -> this.mode == MODE.FLUID, (pressed) -> { if (pressed) setMode(MODE.FLUID); }).setTooltipText("metaitem.cover.digital.mode.fluid"); - buttons[1] = new ToggleButtonWidget(60, 20, 20, 20, Textures.BUTTON_ITEM, () -> this.mode == MODE.ITEM, (pressed) -> { + buttons[1] = new ToggleButtonWidget(60, 20, 20, 20, GuiTextures.BUTTON_ITEM, () -> this.mode == MODE.ITEM, (pressed) -> { if (pressed) setMode(MODE.ITEM); }).setTooltipText("metaitem.cover.digital.mode.item"); - buttons[2] = new ToggleButtonWidget(80, 20, 20, 20, Textures.BUTTON_ENERGY, () -> this.mode == MODE.ENERGY, (pressed) -> { + buttons[2] = new ToggleButtonWidget(80, 20, 20, 20, GuiTextures.BUTTON_ENERGY, () -> this.mode == MODE.ENERGY, (pressed) -> { if (pressed) setMode(MODE.ENERGY); }).setTooltipText("metaitem.cover.digital.mode.energy"); - buttons[3] = new ToggleButtonWidget(100, 20, 20, 20, Textures.BUTTON_MACHINE, () -> this.mode == MODE.MACHINE, (pressed) -> { + buttons[3] = new ToggleButtonWidget(100, 20, 20, 20, GuiTextures.BUTTON_MACHINE, () -> this.mode == MODE.MACHINE, (pressed) -> { if (pressed) setMode(MODE.MACHINE); }).setTooltipText("metaitem.cover.digital.mode.machine"); - buttons[4] = new ToggleButtonWidget(140, 20, 20, 20, Textures.BUTTON_INTERFACE, () -> this.mode == MODE.PROXY, (pressed) -> { + buttons[4] = new ToggleButtonWidget(140, 20, 20, 20, GuiTextures.BUTTON_INTERFACE, () -> this.mode == MODE.PROXY, (pressed) -> { if (pressed) setMode(MODE.PROXY); }).setTooltipText("metaitem.cover.digital.mode.proxy"); primaryGroup.addWidget(new LabelWidget(10, 25, "metaitem.cover.digital.title.mode", 0)); @@ -966,9 +966,9 @@ private void renderMachineMode(float partialTicks) { } if (this.isProxy()) { if (isWorkingEnabled) { - RenderUtil.renderTextureArea(Textures.COVER_INTERFACE_MACHINE_ON_PROXY, -7f / 16, 1f / 16, 14f / 16, 3f / 16, 0.002f); + RenderUtil.renderTextureArea(GuiTextures.COVER_INTERFACE_MACHINE_ON_PROXY, -7f / 16, 1f / 16, 14f / 16, 3f / 16, 0.002f); } else { - RenderUtil.renderTextureArea(Textures.COVER_INTERFACE_MACHINE_OFF_PROXY, -7f / 16, -1f / 16, 14f / 16, 5f / 16, 0.002f); + RenderUtil.renderTextureArea(GuiTextures.COVER_INTERFACE_MACHINE_OFF_PROXY, -7f / 16, -1f / 16, 14f / 16, 5f / 16, 0.002f); } } } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityDistillationTower.java b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityDistillationTower.java index 8530a1b3433..896ac0be4c4 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityDistillationTower.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityDistillationTower.java @@ -15,7 +15,6 @@ import gregtech.common.blocks.MetaBlocks; import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityMultiFluidHatch; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; @@ -68,7 +67,7 @@ protected BlockPattern createStructurePattern() { .or(abilities(MultiblockAbility.EXPORT_ITEMS).setMinGlobalLimited(1)) .or(abilities(MultiblockAbility.INPUT_ENERGY).setMinGlobalLimited(1))) .where('X', states(getCasingState()) - .or(metaTileEntities(MultiblockAbility.REGISTER.get(MultiblockAbility.EXPORT_FLUIDS).stream() + .or(metaTileEntities(MultiblockAbility.REGISTRY.get(MultiblockAbility.EXPORT_FLUIDS).stream() .filter(mte->!(mte instanceof MetaTileEntityMultiFluidHatch)) .toArray(MetaTileEntity[]::new)) .setMinLayerLimited(1).setMaxLayerLimited(1)) diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/centralmonitor/MetaTileEntityMonitorScreen.java b/src/main/java/gregtech/common/metatileentities/multi/electric/centralmonitor/MetaTileEntityMonitorScreen.java index 3da79f25057..4b0712c90ab 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/centralmonitor/MetaTileEntityMonitorScreen.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/centralmonitor/MetaTileEntityMonitorScreen.java @@ -469,19 +469,19 @@ protected ModularUI createUI(EntityPlayer entityPlayer) { int width = 330; int height = 260; ToggleButtonWidget[] buttons = new ToggleButtonWidget[5]; - buttons[0] = new ToggleButtonWidget(width - 135, 25, 20, 20, Textures.BUTTON_FLUID, () -> this.mode == CoverDigitalInterface.MODE.FLUID, (isPressed) -> { + buttons[0] = new ToggleButtonWidget(width - 135, 25, 20, 20, GuiTextures.BUTTON_FLUID, () -> this.mode == CoverDigitalInterface.MODE.FLUID, (isPressed) -> { if (isPressed) setMode(CoverDigitalInterface.MODE.FLUID); }).setTooltipText("metaitem.cover.digital.mode.fluid"); - buttons[1] = new ToggleButtonWidget(width - 115, 25, 20, 20, Textures.BUTTON_ITEM, () -> this.mode == CoverDigitalInterface.MODE.ITEM, (isPressed) -> { + buttons[1] = new ToggleButtonWidget(width - 115, 25, 20, 20, GuiTextures.BUTTON_ITEM, () -> this.mode == CoverDigitalInterface.MODE.ITEM, (isPressed) -> { if (isPressed) setMode(CoverDigitalInterface.MODE.ITEM); }).setTooltipText("metaitem.cover.digital.mode.item"); - buttons[2] = new ToggleButtonWidget(width - 95, 25, 20, 20, Textures.BUTTON_ENERGY, () -> this.mode == CoverDigitalInterface.MODE.ENERGY, (isPressed) -> { + buttons[2] = new ToggleButtonWidget(width - 95, 25, 20, 20, GuiTextures.BUTTON_ENERGY, () -> this.mode == CoverDigitalInterface.MODE.ENERGY, (isPressed) -> { if (isPressed) setMode(CoverDigitalInterface.MODE.ENERGY); }).setTooltipText("metaitem.cover.digital.mode.energy"); - buttons[3] = new ToggleButtonWidget(width - 75, 25, 20, 20, Textures.BUTTON_MACHINE, () -> this.mode == CoverDigitalInterface.MODE.MACHINE, (isPressed) -> { + buttons[3] = new ToggleButtonWidget(width - 75, 25, 20, 20, GuiTextures.BUTTON_MACHINE, () -> this.mode == CoverDigitalInterface.MODE.MACHINE, (isPressed) -> { if (isPressed) setMode(CoverDigitalInterface.MODE.MACHINE); }).setTooltipText("metaitem.cover.digital.mode.machine"); - buttons[4] = new ToggleButtonWidget(width - 35, 25, 20, 20, Textures.BUTTON_INTERFACE, () -> this.mode == CoverDigitalInterface.MODE.PROXY, (isPressed) -> { + buttons[4] = new ToggleButtonWidget(width - 35, 25, 20, 20, GuiTextures.BUTTON_INTERFACE, () -> this.mode == CoverDigitalInterface.MODE.PROXY, (isPressed) -> { if (isPressed) setMode(CoverDigitalInterface.MODE.PROXY); }).setTooltipText("metaitem.cover.digital.mode.proxy"); List covers = new ArrayList<>();