diff options
author | Léa Gris <lea.gris@noiraude.net> | 2021-05-07 11:43:59 +0200 |
---|---|---|
committer | Léa Gris <lea.gris@noiraude.net> | 2021-05-21 13:38:37 +0200 |
commit | cbb32e9e40395bd7e5d25a5cf8d06997a2f69803 (patch) | |
tree | e6ca1451b5bd60196257e3f76487f50258d9d3a1 /src/main/java | |
parent | 8471435c448ef3b9176f30aedc5e3910b77de977 (diff) | |
download | GT5-Unofficial-cbb32e9e40395bd7e5d25a5cf8d06997a2f69803.tar.gz GT5-Unofficial-cbb32e9e40395bd7e5d25a5cf8d06997a2f69803.tar.bz2 GT5-Unofficial-cbb32e9e40395bd7e5d25a5cf8d06997a2f69803.zip |
feat(render): assembly line glow
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gregtech/api/enums/Textures.java | 2 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java | 195 |
2 files changed, 113 insertions, 84 deletions
diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index c019f4751d..be6fa3124a 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -951,7 +951,9 @@ public class Textures { OVERLAY_FRONT_DISTILLATION_TOWER_GLOW, OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE, + OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW, OVERLAY_FRONT_ASSEMBLY_LINE, + OVERLAY_FRONT_ASSEMBLY_LINE_GLOW, OVERLAY_FRONT_ORE_DRILL_ACTIVE, OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW, OVERLAY_FRONT_ORE_DRILL, diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index c13d537119..a8b9c63267 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -1,13 +1,10 @@ package gregtech.common.tileentities.machines.multi; -import java.util.ArrayList; - -import org.lwjgl.input.Keyboard; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -15,6 +12,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedGlowTexture; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -24,8 +22,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.lwjgl.input.Keyboard; + +import java.util.ArrayList; import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW; public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_MultiBlockBase { @@ -40,140 +45,157 @@ public class GT_MetaTileEntity_AssemblyLine super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_AssemblyLine(this.mName); } + @Override public String[] getDescription() { - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Assembling Line") - .addInfo("Controller block for the Assembling Line") - .addInfo("Used to make complex machine parts (LuV+)") - .addInfo("Does not make Assembler items") - .addSeparator() - .beginVariableStructureBlock(5, 15, 4, 4, 3, 3, false)//? - .addStructureInfo("From Bottom to Top, Left to Right") - .addStructureInfo("Layer 1 - Solid Steel Machine Casing, Input Bus (last is Output Bus), Solid Steel Machine Casing") - .addStructureInfo("Layer 2 - Reinforced Glass, Assembling Line Casing, Reinforced Glass") - .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") - .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") - .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes, aside from the last") - .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller") - .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller")//TT - - .addController("Either Grate on layer 3 of the first slice") - .addEnergyHatch("Any layer 4 casing") - .addMaintenanceHatch("Any layer 1 casing") - .addInputBus("As specified on layer 1") - .addInputHatch("Any layer 1 casing") - .addOutputBus("Replaces Input Bus on final slice") - .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Assembling Line") + .addInfo("Controller block for the Assembling Line") + .addInfo("Used to make complex machine parts (LuV+)") + .addInfo("Does not make Assembler items") + .addSeparator() + .beginVariableStructureBlock(5, 15, 4, 4, 3, 3, false)//? + .addStructureInfo("From Bottom to Top, Left to Right") + .addStructureInfo("Layer 1 - Solid Steel Machine Casing, Input Bus (last is Output Bus), Solid Steel Machine Casing") + .addStructureInfo("Layer 2 - Reinforced Glass, Assembling Line Casing, Reinforced Glass") + .addStructureInfo("Layer 3 - Grate Machine Casing, Assembler Machine Casing, Grate Machine Casing") + .addStructureInfo("Layer 4 - Empty, Solid Steel Machine Casing, Empty") + .addStructureInfo("Up to 16 repeating slices, each one allows for 1 more item in recipes, aside from the last") + .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller") + .addStructureInfo("Optional - Replace 1x Grate with (Advanced) Data Access Hatch next to the Controller")//TT + + .addController("Either Grate on layer 3 of the first slice") + .addEnergyHatch("Any layer 4 casing") + .addMaintenanceHatch("Any layer 1 casing") + .addInputBus("As specified on layer 1") + .addInputHatch("Any layer 1 casing") + .addOutputBus("Replaces Input Bus on final slice") + .toolTipFinisher("Gregtech"); + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + return tt.getStructureInformation(); + } else { + return tt.getInformation(); + } } + @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)}; + if (aActive) + return new ITexture[]{ + BlockIcons.casingTexturePages[0][16], + new GT_RenderedTexture(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE), + new GT_RenderedGlowTexture(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW)}; + return new ITexture[]{ + BlockIcons.casingTexturePages[0][16], + new GT_RenderedTexture(OVERLAY_FRONT_ASSEMBLY_LINE), + new GT_RenderedGlowTexture(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW)}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[0][16]}; } + @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "AssemblyLine.png"); } + @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { return null; } + @Override public boolean isCorrectMachinePart(ItemStack aStack) { return true; } + @Override public boolean isFacingValid(byte aFacing) { return aFacing > 1; } + @Override public boolean checkRecipe(ItemStack aStack) { - if(GT_Values.D1) + if (GT_Values.D1) GT_FML_LOGGER.info("Start ALine recipe check"); ArrayList<ItemStack> tDataStickList = getDataItems(2); - if (tDataStickList.size() == 0) return false; - if(GT_Values.D1) - GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); + if (tDataStickList.isEmpty()) return false; + if (GT_Values.D1) + GT_FML_LOGGER.info("Stick accepted, " + tDataStickList.size() + " Data Sticks found"); - ItemStack tStack[] = new ItemStack[15]; + ItemStack[] tStack = new ItemStack[15]; FluidStack[] tFluids = new FluidStack[4]; boolean findRecipe = false; - nextDS:for (ItemStack tDataStick : tDataStickList){ + nextDS: + for (ItemStack tDataStick : tDataStickList) { NBTTagCompound tTag = tDataStick.getTagCompound(); if (tTag == null) continue; for (int i = 0; i < 15; i++) { - int count = tTag.getInteger("a"+i); + int count = tTag.getInteger("a" + i); if (!tTag.hasKey("" + i) && count <= 0) continue; if (mInputBusses.get(i) == null) { continue nextDS; } - + ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0); boolean flag = true; if (count > 0) { - for (int j = 0; j < count; j++) { - tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); - if (tStack[i] == null) continue; - if(GT_Values.D1) - GT_FML_LOGGER.info("Item "+i+" : "+tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; - break; - } - } - } + for (int j = 0; j < count; j++) { + tStack[i] = GT_Utility.loadItem(tTag, "a" + i + ":" + j); + if (tStack[i] == null) continue; + if (GT_Values.D1) + GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + break; + } + } + } if (flag) { - tStack[i] = GT_Utility.loadItem(tTag, "" + i); - if (tStack[i] == null) { - flag = false; - continue; - } - if(GT_Values.D1) - GT_FML_LOGGER.info("Item "+i+" : "+tStack[i].getUnlocalizedName()); - if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { - flag = false; - } - } - if(GT_Values.D1) + tStack[i] = GT_Utility.loadItem(tTag, "" + i); + if (tStack[i] == null) { + flag = false; + continue; + } + if (GT_Values.D1) + GT_FML_LOGGER.info("Item " + i + " : " + tStack[i].getUnlocalizedName()); + if (GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) && tStack[i].stackSize <= stackInSlot.stackSize) { + flag = false; + } + } + if (GT_Values.D1) GT_FML_LOGGER.info(i + (flag ? " not accepted" : " accepted")); if (flag) continue nextDS; } - if(GT_Values.D1)GT_FML_LOGGER.info("All Items done, start fluid check"); + if (GT_Values.D1) GT_FML_LOGGER.info("All Items done, start fluid check"); for (int i = 0; i < 4; i++) { if (!tTag.hasKey("f" + i)) continue; tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i); if (tFluids[i] == null) continue; - if(GT_Values.D1) - GT_FML_LOGGER.info("Fluid "+i+" "+tFluids[i].getUnlocalizedName()); + if (GT_Values.D1) + GT_FML_LOGGER.info("Fluid " + i + " " + tFluids[i].getUnlocalizedName()); if (mInputHatches.get(i) == null) { continue nextDS; } FluidStack fluidInHatch = mInputHatches.get(i).mFluid; - if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { - if(GT_Values.D1) - GT_FML_LOGGER.info(i+" not accepted"); + if (!GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) { + if (GT_Values.D1) + GT_FML_LOGGER.info(i + " not accepted"); continue nextDS; } - if(GT_Values.D1) - GT_FML_LOGGER.info(i+" accepted"); + if (GT_Values.D1) + GT_FML_LOGGER.info(i + " accepted"); } - if(GT_Values.D1) + if (GT_Values.D1) GT_FML_LOGGER.info("Input accepted, check other values"); if (!tTag.hasKey("output")) continue; @@ -191,13 +213,13 @@ public class GT_MetaTileEntity_AssemblyLine continue; mEUt = tTag.getInteger("eu"); - if(GT_Values.D1)GT_FML_LOGGER.info("Find avaiable recipe"); - findRecipe = true; + if (GT_Values.D1) GT_FML_LOGGER.info("Find avaiable recipe"); + findRecipe = true; break; } if (!findRecipe) return false; - if(GT_Values.D1)GT_FML_LOGGER.info("All checked start consuming inputs"); + if (GT_Values.D1) GT_FML_LOGGER.info("All checked start consuming inputs"); for (int i = 0; i < 15; i++) { if (tStack[i] == null) continue; @@ -213,7 +235,7 @@ public class GT_MetaTileEntity_AssemblyLine mInputHatches.get(i).mFluid = null; } } - if(GT_Values.D1)GT_FML_LOGGER.info("Check overclock"); + if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); @@ -232,7 +254,7 @@ public class GT_MetaTileEntity_AssemblyLine } this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); updateSlots(); - if(GT_Values.D1) + if (GT_Values.D1) GT_FML_LOGGER.info("Recipe sucessfull"); return true; } @@ -245,6 +267,7 @@ public class GT_MetaTileEntity_AssemblyLine return super.onRunningTick(aStack); } + @Override public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { super.startSoundLoop(aIndex, aX, aY, aZ); if (aIndex == 20) { @@ -252,8 +275,9 @@ public class GT_MetaTileEntity_AssemblyLine } } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mDataAccessHatches.clear(); + mDataAccessHatches.clear(); int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; if (xDir != 0) { @@ -313,7 +337,7 @@ public class GT_MetaTileEntity_AssemblyLine } tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i); if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) { - return r > 0 && mEnergyHatches.size() > 0; + return r > 0 && !mEnergyHatches.isEmpty(); } } } else { @@ -373,7 +397,7 @@ public class GT_MetaTileEntity_AssemblyLine } tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir); if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) { - return r > 0 && mEnergyHatches.size() > 0; + return r > 0 && !mEnergyHatches.isEmpty(); } } } @@ -386,15 +410,14 @@ public class GT_MetaTileEntity_AssemblyLine private boolean isCorrectDataItem(ItemStack aStack, int state){ if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true; if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true; - if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true; - return false; + return (state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true); } /** * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb */ public ArrayList<ItemStack> getDataItems(int state) { - ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + ArrayList<ItemStack> rList = new ArrayList<>(); if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) { rList.add(mInventory[1]); } @@ -421,18 +444,22 @@ public class GT_MetaTileEntity_AssemblyLine return false; } + @Override public int getMaxEfficiency(ItemStack aStack) { return 10000; } + @Override public int getPollutionPerTick(ItemStack aStack) { return 0; } + @Override public int getDamageToComponent(ItemStack aStack) { return 0; } + @Override public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } |