diff options
Diffstat (limited to 'src/main/java/gregtech/api')
34 files changed, 1144 insertions, 373 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index cb6e94f5ba..8830ab50a5 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1427,6 +1427,7 @@ public enum ItemList implements IItemContainer { Casing_Turbine2, Casing_Turbine3, Casing_EngineIntake, + Casing_ExtremeEngineIntake, Casing_Coil_Cupronickel, Casing_Coil_Kanthal, @@ -1474,6 +1475,7 @@ public enum ItemList implements IItemContainer { Block_TungstenSteelReinforced, Block_NaquadahPlate, Block_NeutroniumPlate, + Block_BedrockiumCompressed, Honeycomb, Charcoal_Pile, @@ -1569,6 +1571,7 @@ public enum ItemList implements IItemContainer { CuringOven, Machine_Multi_Assemblyline, Machine_Multi_DieselEngine, + Machine_Multi_ExtremeDieselEngine, QuantumEye, QuantumStar, Gravistar, diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 671679b835..b46d26e02d 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -734,7 +734,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Materials Nitrochlorobenzene = new MaterialBuilder(592, TextureSet.SET_FLUID , "2-Nitrochlorobenzene").addCell().addFluid().setRGB(143, 181, 26).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 6), new MaterialStack(Hydrogen, 4), new MaterialStack(Chlorine, 1), new MaterialStack(Nitrogen, 1), new MaterialStack(Oxygen, 2)).constructMaterial(); public static Materials Dimethylbenzene = new MaterialBuilder(593, TextureSet.SET_FLUID , "Dimethylbenzene").addCell().addFluid().setRGB(102, 156, 64).setColor(Dyes.dyeLime).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 10)).constructMaterial(); public static Materials Potassiumdichromate = new MaterialBuilder(594, TextureSet.SET_DULL , "Potassium Dichromate").setName("PotassiumDichromate").addDustItems().setRGB(255, 8, 127).setColor(Dyes.dyePink).setMaterialList(new MaterialStack(Potassium, 2), new MaterialStack(Chrome, 2), new MaterialStack(Oxygen, 7)).addElectrolyzerRecipe().constructMaterial(); - public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phtalic Acid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); + public static Materials PhthalicAcid = new MaterialBuilder(595, TextureSet.SET_FLUID , "Phthalic Acid").setName("phtalicacid").addCell().addFluid().setRGB(54, 133, 71).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 8), new MaterialStack(Hydrogen, 6), new MaterialStack(Oxygen, 4)).constructMaterial(); public static Materials Dichlorobenzidine = new MaterialBuilder(596, TextureSet.SET_FLUID , "3,3-Dichlorobenzidine").addCell().addFluid().setRGB(161, 222, 166).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 10), new MaterialStack(Nitrogen, 2), new MaterialStack(Chlorine, 2)).constructMaterial(); public static Materials Diaminobenzidin = new MaterialBuilder(597, TextureSet.SET_FLUID , "3,3-Diaminobenzidine").addCell().addFluid().setRGB(51, 125, 89).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 12),new MaterialStack(Hydrogen, 14),new MaterialStack(Nitrogen, 4)).constructMaterial(); public static Materials Diphenylisophthalate = new MaterialBuilder(598, TextureSet.SET_FLUID , "Diphenyl Isophtalate").addCell().addFluid().setRGB(36, 110, 87).setColor(Dyes.dyeOrange).setMaterialList(new MaterialStack(Carbon, 20),new MaterialStack(Hydrogen, 20),new MaterialStack(Oxygen, 4)).constructMaterial(); @@ -1778,6 +1778,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { Inolashite, Mercassium, MeteoricIron, + BloodInfusedIron, MeteoricSteel, Naquadah, diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 86c2812c5c..59c20d412b 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -731,7 +731,7 @@ public enum OrePrefixes { //Fine Wire if (!enableUnusedFineWires && !(aMaterial == Materials.Steel || aMaterial == Materials.AnnealedCopper || aMaterial == Materials.Platinum || aMaterial == Materials.Osmium || aMaterial == Materials.Tin || aMaterial == Materials.Lead || aMaterial == Materials.SolderingAlloy || aMaterial == Materials.Copper || aMaterial == Materials.Electrum || - aMaterial == Materials.Gold || aMaterial == Materials.RedAlloy || aMaterial == Materials.Graphene || aMaterial == Materials.NiobiumTitanium || aMaterial == Materials.YttriumBariumCuprate )) + aMaterial == Materials.Gold || aMaterial == Materials.RedAlloy || aMaterial == Materials.Graphene || aMaterial == Materials.NiobiumTitanium || aMaterial == Materials.YttriumBariumCuprate || aMaterial == Materials.BloodInfusedIron)) wireFine.mDisabledItems.add(aMaterial); //Gears if (!enableUnusedGears && !(aMaterial == Materials.Aluminium || aMaterial == Materials.Titanium || aMaterial == Materials.Iron || aMaterial == Materials.Copper || diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index a813eacd57..38001faebb 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -267,6 +267,7 @@ public class Textures { MACHINE_CASING_FIREBOX_STEEL, MACHINE_CASING_FIREBOX_TUNGSTENSTEEL, MACHINE_CASING_ENGINE_INTAKE, + MACHINE_CASING_EXTREME_ENGINE_INTAKE,//changed color in a terrible way MACHINE_CASING_CHEMICALLY_INERT, MACHINE_COIL_CUPRONICKEL, @@ -351,6 +352,7 @@ public class Textures { BLOCK_TITANIUMPREIN, BLOCK_NAQUADAHPREIN, BLOCK_NEUTRONIUMPREIN, + BLOCK_DEEP_DARK_RAW, BLOCK_IRREIN, BLOCK_PLASCRETE, BLOCK_TSREIN, @@ -853,6 +855,8 @@ public class Textures { OVERLAY_FRONT_OIL_DRILL, OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE, OVERLAY_FRONT_DIESEL_ENGINE, + OVERLAY_FRONT_EXTREME_DIESEL_ENGINE_ACTIVE, + OVERLAY_FRONT_EXTREME_DIESEL_ENGINE, OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE, OVERLAY_FRONT_PYROLYSE_OVEN, diff --git a/src/main/java/gregtech/api/gui/GT_GUICover.java b/src/main/java/gregtech/api/gui/GT_GUICover.java index 94346186a8..f1232c9432 100644 --- a/src/main/java/gregtech/api/gui/GT_GUICover.java +++ b/src/main/java/gregtech/api/gui/GT_GUICover.java @@ -157,8 +157,10 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender public void mouseClicked(int x, int y, int button) { for (GT_GuiIntegerTextBox tBox : textBoxes) { boolean hadFocus = tBox.isFocused(); - tBox.mouseClicked(x,y,button); - if (tBox.isFocused() && button == 1) //rightclick -> lcear it + if (tBox.isEnabled() || hadFocus) + tBox.mouseClicked(x,y,button); + + if (tBox.isFocused() && button == 1 && tBox.isEnabled()) //rightclick -> lcear it tBox.setText("0"); else if (hadFocus && !tBox.isFocused()) applyTextBox(tBox); @@ -193,6 +195,9 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender return; } } + if (textBoxes.size() > 0 ) + setFocusedTextBox(textBoxes.get(0)); + return; } if (focusedTextBox != null && focusedTextBox.textboxKeyTyped(c, key)){ @@ -239,7 +244,7 @@ public abstract class GT_GUICover extends GuiScreen implements GT_IToolTipRender */ private void setFocusedTextBox(GT_GuiIntegerTextBox boxToFocus) { for (GT_GuiIntegerTextBox textBox : textBoxes) { - textBox.setFocused(textBox.equals(boxToFocus)); + textBox.setFocused(textBox.equals(boxToFocus) && textBox.isEnabled()); } } public void applyTextBox(GT_GuiIntegerTextBox box) { diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java index 1c31462e62..41e851054d 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -18,6 +18,7 @@ public enum GT_GuiIcon { CROSS (0, 32*4, 32), WHITELIST (0, 32*5, 32), BLACKLIST (0, 32*6, 32), + PROGRESS (0, 32*7, 32), EXPORT (0, 0, 32*2), IMPORT (0, 32, 32*2), diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java index f68962f58f..e081c4227d 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java @@ -12,7 +12,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen protected GT_GuiIcon icon; private int x0, y0; - private IGuiScreen gui; + protected IGuiScreen gui; private String[] tooltipText; private GT_GuiTooltip tooltip; @@ -56,7 +56,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen int x = xPosition; int y = yPosition; if(!this.field_146123_n) { - GL11.glColor4f(200F/255F, 210F/255F, 1, 1); + // GL11.glColor4f(200F/255F, 210F/255F, 1, 1); } else GL11.glColor4f(1, 1, 1, 1); @@ -84,13 +84,17 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen return GT_GuiIcon.BUTTON_DISABLED; if (this.equals(this.gui.getSelectedButton())) return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; - else - return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; + + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; } public GT_GuiIcon getIcon() { return icon; } + public GT_GuiIconButton setIcon(GT_GuiIcon icon) { + this.icon = icon; + return this; + } public GT_GuiTooltip getTooltip() { return tooltip; diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java new file mode 100644 index 0000000000..4e6fd86f55 --- /dev/null +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java @@ -0,0 +1,31 @@ +package gregtech.api.gui.widgets; + +import gregtech.api.interfaces.IGuiScreen; + +public class GT_GuiIconCheckButton extends GT_GuiIconButton { + private GT_GuiIcon checkedIcon, normalIcon; + private boolean checked = false; + + public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon) { + super(gui, id, x, y, normalIcon); + this.checkedIcon = checkedIcon; + this.normalIcon = normalIcon; + } + + public GT_GuiIcon getButtonTexture(boolean mouseOver) { + if (!enabled) + return GT_GuiIcon.BUTTON_DISABLED; + if (this.equals(super.gui.getSelectedButton())) + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN; + return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL; + } + + public boolean isChecked() { + return checked; + } + + public void setChecked(boolean checked) { + super.setIcon(checked ? checkedIcon : normalIcon); + this.checked = checked; + } +} diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java index 3f6fe64e73..e2ba53e4c9 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java @@ -10,6 +10,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu private final int x0, y0; private final IGuiScreen gui; public final int id; + private boolean enabled; public GT_GuiIntegerTextBox(IGuiScreen gui, int id, int x, int y, int width, int height) { super(Minecraft.getMinecraft().fontRenderer, x, y, width, height); @@ -18,6 +19,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu x0 = x; y0 = y; this.gui = gui; + enabled = true; gui.addElement(this); } @@ -47,4 +49,14 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu } return false; } + + @Override + public void setEnabled(boolean p_146184_1_) { + super.setEnabled(p_146184_1_); + enabled = p_146184_1_; + } + + public boolean isEnabled() { + return enabled; + } } diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java new file mode 100644 index 0000000000..9306ef28f3 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMachineCallback.java @@ -0,0 +1,7 @@ +package gregtech.api.interfaces.metatileentity; + +public interface IMachineCallback<Machinetype extends IMetaTileEntity> { + Machinetype getCallbackBase(); + void setCallbackBase(Machinetype callback); + Class<Machinetype> getType(); +}
\ No newline at end of file diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 264c510701..edc60b45fc 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -514,11 +514,13 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci if (tFluid != null && maxDrain >= tFluid.amount) { ItemStack tStack = GT_Utility.getContainerItem(aStack, false); if (tStack == null) { - aStack.stackSize = 0; + if(doDrain) aStack.stackSize = 0; return tFluid; } - aStack.setItemDamage(tStack.getItemDamage()); - aStack.func_150996_a(tStack.getItem()); + if(doDrain) { + aStack.setItemDamage(tStack.getItemDamage()); + aStack.func_150996_a(tStack.getItem()); + } return tFluid; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index b9c8641a86..6025e7eb13 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -54,7 +54,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false; private boolean mCheckConnections = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; + private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; private short mID = 0; private long mTickTimer = 0; @@ -308,11 +308,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); } - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; + if (mNeedsBlockUpdate) { + updateNeighbours(mStrongRedstone, oStrongRedstone); + oStrongRedstone = mStrongRedstone; + mNeedsBlockUpdate = false; + } } - } default: tCode = -1; break; @@ -907,6 +908,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak"))); GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + issueBlockUpdate(); } doEnetUpdate(); return true; diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 63c88cfd0a..cfb34eb34e 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -62,7 +62,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private short mID = 0; public long mTickTimer = 0; @@ -447,11 +447,16 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (getRandomNumber(1000) == 0) { + int precipitationHeightAtSide2 = worldObj.getPrecipitationHeight(xCoord, zCoord - 1); + int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1); + int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord); + int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord); + if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) - || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { + || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1) + || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1) + || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1) + || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1)) { if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { if (getRandomNumber(10) == 0) { try{ @@ -496,15 +501,17 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { dischargeItem(mMetaTileEntity.mInventory[i]); - if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){ + if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){ if((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]))<getEUCapacity()){ increaseStoredEnergyUnits((long)ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]),false); mMetaTileEntity.mInventory[i].stackSize--; + mInventoryChanged = true; } } - if (mMetaTileEntity.mInventory[i].stackSize <= 0) + if (mMetaTileEntity.mInventory[i].stackSize <= 0) { mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; + mInventoryChanged = true; + } } } } @@ -516,9 +523,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { chargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) + if (mMetaTileEntity.mInventory[i].stackSize <= 0) { mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; + mInventoryChanged = true; + } } } } @@ -545,7 +553,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], - oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), + oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0) ), oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), @@ -556,7 +564,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); + byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)| (mWorks ? 64 : 0)); if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); tData = mMetaTileEntity.getUpdateData(); @@ -583,7 +591,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); + updateNeighbours(mStrongRedstone, oStrongRedstone); + oStrongRedstone = mStrongRedstone; mNeedsBlockUpdate = false; } } @@ -681,6 +690,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); //mLockUpgrade = ((aValue&32) != 0); + mWorks = ((aValue & 64) != 0); break; case 1: if (hasValidMetaTileEntity()) { @@ -1395,6 +1405,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak"))); GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); + issueBlockUpdate(); } doEnetUpdate(); return true; @@ -1724,15 +1735,19 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public long getAverageElectricInput() { long rEU = 0; - for (long tEU : mAverageEUInput) rEU += tEU; - return rEU / mAverageEUInput.length; + for (int i = 0; i < mAverageEUInput.length; ++i) + if (i != mAverageEUInputIndex) + rEU += mAverageEUInput[i]; + return rEU / (mAverageEUInput.length - 1); } @Override public long getAverageElectricOutput() { long rEU = 0; - for (long tEU : mAverageEUOutput) rEU += tEU; - return rEU / mAverageEUOutput.length; + for (int i = 0; i < mAverageEUOutput.length; ++i) + if (i != mAverageEUOutputIndex) + rEU += mAverageEUOutput[i]; + return rEU / (mAverageEUOutput.length - 1); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index f5ba784162..dcaa98f120 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -427,6 +427,28 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje clearNullMarkersFromTileEntityBuffer(); } + public void updateNeighbours(int mStrongRedstone, int oStrongRedstone) { + Block thisBlock = getBlockOffset(0, 0, 0); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ; + + if (worldObj.blockExists(x1, y1, z1)) { + worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); + + //update if it was / is strong powered. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { + int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet. + + for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { + int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; + if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2)) + worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock); + } + } + } + } + } + @Override public final void sendBlockEvent(byte aID, byte aValue) { NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index 3373b142c4..02d6752bdd 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -24,7 +24,6 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_SolarPanel; -import gregtech.loaders.postload.PartP2PGTPower; import ic2.api.energy.EnergyNet; import ic2.api.energy.tile.IEnergyEmitter; import ic2.api.energy.tile.IEnergySink; @@ -423,8 +422,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile // AE2-p2p Compat if (GT_Mod.gregtechproxy.mAE2Integration) { - if (tTileEntity instanceof IEnergySource && tTileEntity instanceof IPartHost && ((IPartHost)tTileEntity).getPart(tDir) instanceof PartP2PGTPower && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir)) - return true; if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir)) return true; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 0767bd0081..2afc996df2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -1,8 +1,12 @@ package gregtech.api.metatileentity.implementations; +import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -104,7 +108,13 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { {1, 0, 2, 3}, {1, 0, 2, 3} }; - if (aSide >= 0 && aSide < 6) for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + if (aSide >= 0 && aSide < 6) { + for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; + //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate + if (aSide == 5 || aSide == 2 || aSide == 0) + if (tMask > 3 && tMask < 12) + tMask = (byte) (tMask ^ 12); + } return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)}; } @@ -383,36 +393,46 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { - if (tTileEntity == null) return false; + if (tTileEntity == null) + return false; final byte tSide = (byte)ForgeDirection.getOrientation(aSide).getOpposite().ordinal(); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - if (baseMetaTile == null) return false; + if (baseMetaTile == null) + return false; final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide); final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; - if (coverBehavior instanceof GT_Cover_Drain) return true; - - // Tinker Construct Faucets return a null tank info, so check the class - if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true; + if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity))) + return true; final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null; if (fTileEntity != null) { FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); if (tInfo != null) { - if (tInfo.length > 0) return true; - - // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern - if (GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator) return true; - if (gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator) return true; + return tInfo.length > 0 + || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) + || gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator; } } return false; } + @Optional.Method(modid = "TConstruct") + private boolean isTConstructFaucet(TileEntity tTileEntity){ + // Tinker Construct Faucets return a null tank info, so check the class + return tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic; + } + + @Optional.Method(modid = "Translocator") + private boolean isTranslocator(TileEntity tTileEntity){ + // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern + return tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator; + } + @Override public boolean getGT6StyleConnection() { // Yes if GT6 pipes are enabled diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 650e9a031e..c73e95e95b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -270,7 +270,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) { if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { - return GT_Utility.moveOneItemStack(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1) > 0; + return GT_Utility.moveMultipleItemStacks(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,1) > 0; } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 1c5b90f7db..2c632c596b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -7,6 +7,7 @@ import gregtech.api.enums.Textures; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMachineCallback; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; @@ -15,6 +16,7 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -30,6 +32,7 @@ import java.util.Arrays; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.debugCleanroom; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -37,7 +40,8 @@ import static gregtech.api.enums.GT_Values.debugCleanroom; * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank { +public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements IMachineCallback<GT_MetaTileEntity_Cleanroom> { + /** * return values for checkRecipe() */ @@ -51,8 +55,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; public FluidStack mOutputFluid; - public String mGUIName = "", mNEIName = ""; - public GT_MetaTileEntity_MultiBlockBase mCleanroom; + public String mGUIName, mNEIName; + + + @Deprecated + public GT_MetaTileEntity_Cleanroom mCleanroom; /** * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ @@ -126,6 +133,21 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } @Override + public GT_MetaTileEntity_Cleanroom getCallbackBase() { + return this.mCleanroom; + } + + @Override + public void setCallbackBase(GT_MetaTileEntity_Cleanroom callback) { + this.mCleanroom = callback; + } + + @Override + public Class<GT_MetaTileEntity_Cleanroom> getType() { + return GT_MetaTileEntity_Cleanroom.class; + } + + @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[14][17][]; aTextures = Arrays.copyOf(aTextures, 14); @@ -449,7 +471,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + Arrays.fill(mOutputItems, null); mOutputFluid = null; mEUt = 0; mProgresstime = 0; @@ -489,10 +511,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } + long tStoredEnergy = aBaseMetaTileEntity.getUniversalEnergyStored(); + int tMaxStacks = (int)(tStoredEnergy/64l); + if (tMaxStacks > mOutputItems.length) + tMaxStacks = mOutputItems.length; + + int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); + aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true); +// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { +// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); +// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); +// } } if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; @@ -518,7 +547,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B startProcess(); } else { mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; + Arrays.fill(mOutputItems, null); mOutputFluid = null; } } @@ -584,7 +613,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B //Long EUt calculation long xEUt=aEUt; //Isnt too low EUt check? - long tempEUt = xEUt<V[1] ? V[1] : xEUt; + long tempEUt = Math.max(xEUt, V[1]); mMaxProgresstime = aDuration; @@ -652,7 +681,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B protected boolean isOutputEmpty() { boolean rIsEmpty = true; - for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; + for (ItemStack tOutputSlotContent : getAllOutputs()) + if (tOutputSlotContent != null) { + rIsEmpty = false; + break; + } return rIsEmpty; } @@ -816,7 +849,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B /** * * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... - * @return + * @return DID_NOT_FIND_RECIPE = 0, + * FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, + * FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; */ public int checkRecipe(boolean skipOC){ GT_Recipe_Map tMap = getRecipeList(); @@ -832,7 +867,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mOutputBlocked++; return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0)) + if (tRecipe.mSpecialValue == -200 && (getCallbackBase() == null || getCallbackBase().mEfficiency == 0)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -841,12 +876,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mOutputItems[i] = tRecipe.getOutput(i); if (tRecipe.mSpecialValue == -200 || tRecipe.mSpecialValue == -300) for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency) + if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > getCallbackBase().mEfficiency) { if (debugCleanroom) { GT_Log.out.println( "BasicMachine: Voiding output due to efficiency failure. mEfficiency = " + - mCleanroom.mEfficiency + getCallbackBase().mEfficiency ); } mOutputItems[i] = null; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 73ab28822a..8758ea1a02 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -8,11 +8,19 @@ import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = true; + private static final int OUTPUT_INDEX = 0; + private static final int ARROW_RIGHT_INDEX = 1; + private static final int ARROW_DOWN_INDEX = 2; + private static final int ARROW_LEFT_INDEX = 3; + private static final int ARROW_UP_INDEX = 4; + private static final int FRONT_INDEX = 5; + + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false; public int mSuccess = 0, mTargetStackSize = 0; public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -33,74 +41,85 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[6][17][]; - ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT), tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP), tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN), tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT), tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tRight, tIcon}; - rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tDown, tIcon}; - rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tLeft, tIcon}; - rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon}; - rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; + ITexture[][][] rTextures = new ITexture[ForgeDirection.VALID_DIRECTIONS.length][17][]; + ITexture tIcon = getOverlayIcon(); + ITexture tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT); + ITexture tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP); + ITexture tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN); + ITexture tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT); + ITexture tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); + for (int i = 0; i < rTextures[0].length; i++) { + rTextures[OUTPUT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tOut}; + rTextures[ARROW_RIGHT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tRight, tIcon}; + rTextures[ARROW_DOWN_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tDown, tIcon}; + rTextures[ARROW_LEFT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tLeft, tIcon}; + rTextures[ARROW_UP_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tUp, tIcon}; + rTextures[FRONT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tIcon}; } return rTextures; } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return mTextures[5][aColorIndex + 1]; - if (GT_Utility.getOppositeSide(aSide) == aFacing) return mTextures[0][aColorIndex + 1]; - switch (aFacing) { - case 0: - return mTextures[4][aColorIndex + 1]; - case 1: - return mTextures[2][aColorIndex + 1]; - case 2: - switch (aSide) { - case 0: - return mTextures[2][aColorIndex + 1]; - case 1: - return mTextures[2][aColorIndex + 1]; - case 4: - return mTextures[1][aColorIndex + 1]; - case 5: - return mTextures[3][aColorIndex + 1]; + int colorIndex = aColorIndex + 1; + ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[aSide]; + ForgeDirection facing = ForgeDirection.VALID_DIRECTIONS[aFacing]; + if (side == facing) return mTextures[FRONT_INDEX][colorIndex]; + if (ForgeDirection.OPPOSITES[aSide] == aFacing) return mTextures[OUTPUT_INDEX][colorIndex]; + switch (facing) { + case DOWN: + return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP + case UP: + return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN + case NORTH: + switch (side) { + case DOWN: + case UP: + return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN + case WEST: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + case EAST: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + default: } - case 3: - switch (aSide) { - case 0: - return mTextures[4][aColorIndex + 1]; - case 1: - return mTextures[4][aColorIndex + 1]; - case 4: - return mTextures[3][aColorIndex + 1]; - case 5: - return mTextures[1][aColorIndex + 1]; + break; + case SOUTH: + switch (side) { + case DOWN: + case UP: + return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP + case WEST: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + case EAST: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + default: } - case 4: - switch (aSide) { - case 0: - return mTextures[3][aColorIndex + 1]; - case 1: - return mTextures[1][aColorIndex + 1]; - case 2: - return mTextures[3][aColorIndex + 1]; - case 3: - return mTextures[1][aColorIndex + 1]; + break; + case WEST: + switch (side) { + case DOWN: + case UP: + case SOUTH: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + case NORTH: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + default: } - case 5: - switch (aSide) { - case 0: - return mTextures[1][aColorIndex + 1]; - case 1: - return mTextures[3][aColorIndex + 1]; - case 2: - return mTextures[1][aColorIndex + 1]; - case 3: - return mTextures[3][aColorIndex + 1]; + break; + case EAST: + switch (side) { + case DOWN: + case UP: + case SOUTH: + return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT + case NORTH: + return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT + default: } + break; + default: } - return mTextures[5][aColorIndex + 1]; + return mTextures[FRONT_INDEX][colorIndex]; } @Override @@ -257,18 +276,15 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if( bStockingMode ) { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } - } else { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } + int tCost; + if( bStockingMode ) + tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1,1); + else + tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize,1); + + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mSuccess = 50; + aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 8c36c2af65..f2f76dca4f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -13,10 +13,12 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public boolean disableSort; + public boolean disableFilter = false; public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ @@ -136,12 +138,14 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setBoolean("disableSort", disableSort); + aNBT.setBoolean("disableFilter", disableFilter); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); disableSort = aNBT.getBoolean("disableSort"); + disableFilter = aNBT.getBoolean("disableFilter"); } @Override @@ -151,6 +155,9 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { if (aPlayer.isSneaking()) { disableSort = !disableSort; GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled"))); + } else { + disableFilter = !disableFilter; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter."+disableFilter)); } } @@ -160,11 +167,11 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; + return aSide == getBaseMetaTileEntity().getFrontFacing(); } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); + return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index 9cadeaddc2..b3998b62e7 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.Arrays; + import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @@ -53,10 +55,23 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { return true; } + private int[] mFacings; + + /*private void init()*/ { + setInValidFacings(ForgeDirection.DOWN); + } + + public void setInValidFacings(ForgeDirection... aFacings) { + mFacings = Arrays.stream(aFacings).mapToInt(Enum::ordinal).toArray(); + } + @Override public boolean isFacingValid(byte aFacing) { - return aFacing != 0; - } + for (int x : mFacings) + if (x == aFacing) + return false; + return true; + } @Override public boolean isAccessAllowed(EntityPlayer aPlayer) { @@ -80,9 +95,9 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } return false; } - - public int calculatePollutionReduction(int aPollution){ - return (int) (aPollution *(Math.pow(0.85F, mTier - 1))); + + public int calculatePollutionReduction(int aPollution) { + return (int) (aPollution * (Math.pow(0.85F, mTier - 1))); } @Override @@ -98,51 +113,51 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if(aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) - pollutionParticles(this.getBaseMetaTileEntity().getWorld(),"largesmoke"); - } - - public void pollutionParticles(World aWorld,String name){ - boolean chk1,chk2,chk3; - float ran1=XSTR_INSTANCE.nextFloat(),ran2=0,ran3=0; - chk1=ran1*100<calculatePollutionReduction(100); - if(GT_Pollution.getPollution(getBaseMetaTileEntity())>= GT_Mod.gregtechproxy.mPollutionSmogLimit){ - ran2=XSTR_INSTANCE.nextFloat(); - ran3=XSTR_INSTANCE.nextFloat(); - chk2=ran2*100<calculatePollutionReduction(100); - chk3=ran3*100<calculatePollutionReduction(100); - if(!(chk1||chk2||chk3))return; - }else{ - if(!chk1)return; - chk2=chk3=false; + if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive()) + pollutionParticles(this.getBaseMetaTileEntity().getWorld(), "largesmoke"); + } + + public void pollutionParticles(World aWorld, String name) { + boolean chk1, chk2, chk3; + float ran1 = XSTR_INSTANCE.nextFloat(), ran2 = 0, ran3 = 0; + chk1 = ran1 * 100 < calculatePollutionReduction(100); + if (GT_Pollution.getPollution(getBaseMetaTileEntity()) >= GT_Mod.gregtechproxy.mPollutionSmogLimit) { + ran2 = XSTR_INSTANCE.nextFloat(); + ran3 = XSTR_INSTANCE.nextFloat(); + chk2 = ran2 * 100 < calculatePollutionReduction(100); + chk3 = ran3 * 100 < calculatePollutionReduction(100); + if (!(chk1 || chk2 || chk3)) return; + } else { + if (!chk1) return; + chk2 = chk3 = false; } - IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity(); - ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing()); - float xPos=aDir.offsetX*0.76F+aMuffler.getXCoord()+0.25F; - float yPos=aDir.offsetY*0.76F+aMuffler.getYCoord()+0.25F; - float zPos=aDir.offsetZ*0.76F+aMuffler.getZCoord()+0.25F; + IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity(); + ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing()); + float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F; + float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F; + float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F; - float ySpd=aDir.offsetY*0.1F+0.2F+0.1F*XSTR_INSTANCE.nextFloat(); + float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * XSTR_INSTANCE.nextFloat(); float xSpd; float zSpd; - if(aDir.offsetY==-1){ - float temp=XSTR_INSTANCE.nextFloat()*2*(float)Math.PI; - xSpd=(float)Math.sin(temp)*0.1F; - zSpd=(float)Math.cos(temp)*0.1F; - }else{ - xSpd=aDir.offsetX*(0.1F+0.2F*XSTR_INSTANCE.nextFloat()); - zSpd=aDir.offsetZ*(0.1F+0.2F*XSTR_INSTANCE.nextFloat()); + if (aDir.offsetY == -1) { + float temp = XSTR_INSTANCE.nextFloat() * 2 * (float) Math.PI; + xSpd = (float) Math.sin(temp) * 0.1F; + zSpd = (float) Math.cos(temp) * 0.1F; + } else { + xSpd = aDir.offsetX * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); + zSpd = aDir.offsetZ * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat()); } - if(chk1) - aWorld.spawnParticle(name, xPos + ran1*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk1) + aWorld.spawnParticle(name, xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); - if(chk2) - aWorld.spawnParticle(name, xPos + ran2*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk2) + aWorld.spawnParticle(name, xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); - if(chk3) - aWorld.spawnParticle(name, xPos + ran3*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd); + if (chk3) + aWorld.spawnParticle(name, xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index 6c56ac6a74..1dafbcce5a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -12,6 +12,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; +import static gregtech.api.util.GT_Utility.*; + public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Output for Multiblocks", @@ -112,10 +114,11 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) { IInventory tTileEntity =aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); if(tTileEntity!=null){ - for (ItemStack aMInventory : mInventory) - GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, - aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), - null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + moveMultipleItemStacks(aBaseMetaTileEntity,tTileEntity,aBaseMetaTileEntity.getFrontFacing(),aBaseMetaTileEntity.getBackFacing(),null,false,(byte)64,(byte)1,(byte)64,(byte)1,mInventory.length); + +// GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, +// aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), +// null, false, (byte) 64, (byte) 1, (byte)( 64 * aBaseMetaTileEntity.getSizeInventory()), (byte) 1); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 3efbe0d57b..202e542c88 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1,10 +1,5 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; - -import java.util.ArrayList; - import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -29,6 +24,11 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; + +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; + public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public static boolean disableMaintenance; @@ -538,13 +538,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aFirstVoltageFound = aVoltage; } else { - /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? - */ - //Long time calculation if (aFirstVoltageFound != aVoltage) { aFoundMixedDynamos = true; } @@ -559,13 +552,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } long leftToInject; - //Long EUt calculation long aVoltage; - //Isnt too low EUt check? int aAmpsToInject; int aRemainder; int ampsOnCurrentHatch; - //xEUt *= 4;//this is effect of everclocking for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { if (isValidMetaTileEntity(aDynamo)) { leftToInject = aEU - injected; @@ -594,51 +584,74 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } /** - * Calcualtes overclocked ness using long integers - * @param aEUt - recipe EUt - * @param aDuration - recipe Duration - * @param mAmperage - should be 1 ? + * Calcualtes the overclockedness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + * @param maxInputVoltage - Multiblock Max input voltage + * @param perfectOC - If the Multiblock OCs perfectly, i.e. the large Chemical Reactor */ - protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { - byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); - if(mTier==0){ + protected void calculateOverclockedNessMultiInternal(int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { + byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); + if(mTier == 0){ //Long time calculation long xMaxProgresstime = ((long)aDuration)<<1; - if(xMaxProgresstime>Integer.MAX_VALUE-1){ + if(xMaxProgresstime > Integer.MAX_VALUE - 1){ //make impossible if too long - mEUt=Integer.MAX_VALUE-1; - mMaxProgresstime=Integer.MAX_VALUE-1; + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; }else{ - mEUt=aEUt>>2; - mMaxProgresstime=(int)xMaxProgresstime; + mEUt = aEUt >> 2; + mMaxProgresstime= (int) xMaxProgresstime; } }else{ //Long EUt calculation - long xEUt=aEUt; + long xEUt = aEUt; //Isnt too low EUt check? - long tempEUt = xEUt<V[1] ? V[1] : xEUt; + long tempEUt = Math.max(xEUt, V[1]); mMaxProgresstime = aDuration; - while (tempEUt <= V[mTier -1] * mAmperage) { - tempEUt<<=2;//this actually controls overclocking + final int ocTimeShift = perfectOC ? 2 : 1; + + while (tempEUt <= V[mTier - 1] * mAmperage) { + tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking - mMaxProgresstime>>=1;//this is effect of overclocking - xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use less power + int oldTime = mMaxProgresstime; + mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking + if (mMaxProgresstime <1) + { + if(oldTime == 1) + break; + xEUt *= oldTime * (perfectOC ? 1:2); + break; + } + else + { + xEUt <<= 2; + } } - if(xEUt>Integer.MAX_VALUE-1){ - mEUt = Integer.MAX_VALUE-1; - mMaxProgresstime = Integer.MAX_VALUE-1; - }else{ - mEUt = (int)xEUt; - if(mEUt==0) + if(xEUt > Integer.MAX_VALUE - 1) { + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + mEUt = (int) xEUt; + if(mEUt == 0) mEUt = 1; - if(mMaxProgresstime==0) + if(mMaxProgresstime == 0) mMaxProgresstime = 1;//set time to 1 tick } } } + protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,false); + } + + protected void calculatePerfectOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,true); + } + public boolean drainEnergyInput(long aEU) { if (aEU <= 0) return true; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index f33b8aa3d9..711670db08 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -60,7 +60,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1]; + return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][aColorIndex + 1]; } @Override diff --git a/src/main/java/gregtech/api/net/GT_Packet_Pollution.java b/src/main/java/gregtech/api/net/GT_Packet_Pollution.java index 2c67d74150..7f717c1a47 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_Pollution.java +++ b/src/main/java/gregtech/api/net/GT_Packet_Pollution.java @@ -1,38 +1,47 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import gregtech.common.GT_Pollution; +import gregtech.common.GT_Client; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.IBlockAccess; +import java.nio.ByteBuffer; + public class GT_Packet_Pollution extends GT_Packet { - private int mPollution; + private ChunkCoordIntPair chunk; + private int pollution; public GT_Packet_Pollution() { super(true); } - public GT_Packet_Pollution(int aPollution) { + public GT_Packet_Pollution(ChunkCoordIntPair chunk, int pollution) { super(false); - mPollution = aPollution; + this.chunk = chunk; + this.pollution = pollution; } @Override public byte[] encode() { - ByteArrayDataOutput tOut = ByteStreams.newDataOutput(4); - tOut.writeInt(mPollution); - return tOut.toByteArray(); + return ByteBuffer + .allocate(12) + .putInt(chunk.chunkXPos) + .putInt(chunk.chunkZPos) + .putInt(pollution) + .array(); } @Override public GT_Packet decode(ByteArrayDataInput aData) { - return new GT_Packet_Pollution(aData.readInt()); + return new GT_Packet_Pollution( + new ChunkCoordIntPair(aData.readInt(), aData.readInt()), + aData.readInt() + ); } @Override public void process(IBlockAccess aWorld) { - GT_Pollution.mPlayerPollution = mPollution; + GT_Client.recieveChunkPollutionPacket(chunk, pollution); } @Override diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java index 70b71cf125..074cabf341 100644 --- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java @@ -37,94 +37,77 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer { @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tesselator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; } + @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tesselator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(255, 255, 255, 255); + tesselator.setColorRGBA(255, 255, 255, 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); - IIcon aIcon = mIconContainer.getIcon(); - - float d_16 = 16.0F; - float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - float d11 = aX + (float)aRenderer.renderMinX; - float d12 = aX + (float)aRenderer.renderMaxX; - float d13 = aY + (float)aRenderer.renderMinY; - float d14 = aZ + (float)aRenderer.renderMinZ; - float d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); - - if ((aIcon = mIconContainer.getOverlayIcon()) != null) { - Tessellator.instance.setColorRGBA(128, 128, 128, 255); - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; + aRenderer.flipTexture = true; + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + tesselator.setColorRGBA(128, 128, 128, 255); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; + aRenderer.flipTexture = false; } @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tesselator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } } @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tesselator = Tessellator.instance; + tesselator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); if (mIconContainer.getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tesselator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override diff --git a/src/main/java/gregtech/api/objects/GT_SidedTexture.java b/src/main/java/gregtech/api/objects/GT_SidedTexture.java index 2b4f144393..ab88225781 100644 --- a/src/main/java/gregtech/api/objects/GT_SidedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_SidedTexture.java @@ -7,7 +7,6 @@ import gregtech.api.interfaces.ITexture; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.IIcon; public class GT_SidedTexture implements ITexture, IColorModulationContainer { private final IIconContainer[] mIconContainer; @@ -45,115 +44,76 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer { @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getIcon()); if (mIconContainer[5].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tessellator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer[5].getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.6F), (int) (mRGBa[1] * 0.6F), (int) (mRGBa[2] * 0.6F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getIcon()); if (mIconContainer[4].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(153, 153, 153, 255); + tessellator.setColorRGBA(153, 153, 153, 255); aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer[4].getOverlayIcon()); } } @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 1.0F), (int) (mRGBa[1] * 1.0F), (int) (mRGBa[2] * 1.0F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getIcon()); if (mIconContainer[1].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(255, 255, 255, 255); + tessellator.setColorRGBA(255, 255, 255, 255); aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon()); } } @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); - IIcon aIcon = mIconContainer[0].getIcon(); - - float d_16 = 16.0F; - float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - float d11 = aX + (float)aRenderer.renderMinX; - float d12 = aX + (float)aRenderer.renderMaxX; - float d13 = aY + (float)aRenderer.renderMinY; - float d14 = aZ + (float)aRenderer.renderMinZ; - float d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); - - if ((aIcon = mIconContainer[0].getOverlayIcon()) != null) { - Tessellator.instance.setColorRGBA(128, 128, 128, 255); - - d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); - d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); - d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); - d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); - - if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { - d3 = aIcon.getMaxU(); - d4 = aIcon.getMinU(); - } - - if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { - d5 = aIcon.getMinV(); - d6 = aIcon.getMaxV(); - } - - d11 = aX + (float)aRenderer.renderMinX; - d12 = aX + (float)aRenderer.renderMaxX; - d13 = aY + (float)aRenderer.renderMinY; - d14 = aZ + (float)aRenderer.renderMinZ; - d15 = aZ + (float)aRenderer.renderMaxZ; - - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); - Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); - Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; + aRenderer.flipTexture = true; + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getIcon()); + if (mIconContainer[0].getOverlayIcon() != null) { + tessellator.setColorRGBA(128, 128, 128, 255); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer[1].getOverlayIcon()); } + aRenderer.field_152631_f = false; + aRenderer.flipTexture = false; } @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getIcon()); if (mIconContainer[3].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tessellator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer[3].getOverlayIcon()); } } @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + final Tessellator tessellator = Tessellator.instance; + tessellator.setColorRGBA((int) (mRGBa[0] * 0.8F), (int) (mRGBa[1] * 0.8F), (int) (mRGBa[2] * 0.8F), mAllowAlpha ? 255 - mRGBa[3] : 255); + aRenderer.field_152631_f = true; aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getIcon()); if (mIconContainer[2].getOverlayIcon() != null) { - Tessellator.instance.setColorRGBA(204, 204, 204, 255); + tessellator.setColorRGBA(204, 204, 204, 255); aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer[2].getOverlayIcon()); } + aRenderer.field_152631_f = false; } @Override diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 3d28a94de9..ee56a0b0c0 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -36,8 +36,27 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { this.z = aZ; } + public static boolean isEnabled() { + return isEnabled; + } + + public static void setEnabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = true; + } + + public static void setDisabled() { + GT_Runnable_MachineBlockUpdate.isEnabled = false; + } + + public static void setEnabled(boolean isEnabled) { + GT_Runnable_MachineBlockUpdate.isEnabled = isEnabled; + } + + private static boolean isEnabled = true; + public static void setMachineUpdateValues(World aWorld, int aX, int aY, int aZ) { - EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); + if (isEnabled) + EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aX, aY, aZ)); } public static void initExecutorService() { diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index b44b6ffa40..c87e0f7417 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -323,7 +323,7 @@ public class GT_LanguageManager { addStringLocalization("Interaction_DESCRIPTION_Index_214", "Connected"); addStringLocalization("Interaction_DESCRIPTION_Index_215", "Disconnected"); addStringLocalization("Interaction_DESCRIPTION_Index_216", "Deprecated Recipe"); - addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots."); + addStringLocalization("Interaction_DESCRIPTION_Index_217", "Stocking mode. Keeps this many items in destination input slots. This mode can be server unfriendly."); addStringLocalization("Interaction_DESCRIPTION_Index_218", "Transfer size mode. Add exactly this many items in destination input slots as long as there is room."); addStringLocalization("Interaction_DESCRIPTION_Index_500", "Fitting: Loose - More Flow"); addStringLocalization("Interaction_DESCRIPTION_Index_501", "Fitting: Tight - More Efficiency"); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index e195bf9b02..5cfcac0a89 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1,5 +1,7 @@ package gregtech.api.util; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GT_Mod; @@ -122,6 +124,7 @@ public class GT_ModHandler { public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<Integer>(50); public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<Integer>(50); public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<IRecipe>(1000); + private static Cache<GT_ItemStack, ItemStack> sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build(); static { sNativeRecipeClasses.add(ShapedRecipes.class.getName()); @@ -1565,8 +1568,14 @@ public class GT_ModHandler { * Used in my own Furnace. */ public static ItemStack getSmeltingOutput(ItemStack aInput, boolean aRemoveInput, ItemStack aOutputSlot) { - if (aInput == null || aInput.stackSize < 1) return null; - ItemStack rStack = GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput)); + if (aInput == null || aInput.stackSize < 1) + return null; + ItemStack rStack = null; + try { + rStack = sSmeltingRecipeCache.get(new GT_ItemStack(aInput), () -> GT_OreDictUnificator.get(FurnaceRecipes.smelting().getSmeltingResult(aInput))); + } catch (Exception ignored){ + } + if (rStack != null && (aOutputSlot == null || (GT_Utility.areStacksEqual(rStack, aOutputSlot) && rStack.stackSize + aOutputSlot.stackSize <= aOutputSlot.getMaxStackSize()))) { if (aRemoveInput) aInput.stackSize--; return rStack; @@ -1676,7 +1685,7 @@ public class GT_ModHandler { int tTier = ((ic2.api.item.IElectricItem) aStack.getItem()).getTier(aStack); if (tTier < 0 || tTier == aTier || aTier == Integer.MAX_VALUE) { if (!aIgnoreLimit && tTier >= 0) - aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))]); + aCharge = (int) Math.min(aCharge, V[Math.max(0, Math.min(V.length - 1, tTier))] + B[Math.max(0, Math.min(V.length - 1, tTier))]); if (aCharge > 0) { // int rCharge = Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, T, aSimulate)); int rCharge = (int) Math.max(0, ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge + (aCharge * 4 > aTier ? aTier : 0), tTier, true, !aIgnoreDischargability, aSimulate)); diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java new file mode 100644 index 0000000000..e30fe5d606 --- /dev/null +++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java @@ -0,0 +1,348 @@ +package gregtech.api.util; + +import java.util.LinkedList; +import java.util.List; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +/** + * This makes it easier to build multi tooltips, with a standardized format. <br> + * Info section order should be:<br> + * addMachineType<br> + * addInfo, for what it does, special notes, etc.<br> + * addSeparator, if you need it<br> + * addPollutionAmount<br> + * <br> + * Structure order should be:<br> + * beginStructureBlock<br> + * addController<br> + * addCasingInfo<br> + * addOtherStructurePart, for secondary structure block info (pipes, coils, etc)<br> + * addEnergyHatch/addDynamoHatch<br> + * addMaintenanceHatch<br> + * addMufflerHatch<br> + * addInputBus/addInputHatch/addOutputBus/addOutputHatch, in that order<br> + * Use addStructureInfo for any comments on nonstandard structure info wherever needed + * <br> + * toolTipFinisher goes at the very end<br> + * <br> + * Originally created by kekzdealer + */ +public class GT_Multiblock_Tooltip_Builder { + private static final String TAB = " "; + private static final String COLON = ": "; + + private final List<String> iLines; + private final List<String> sLines; + + private String[] iArray; + private String[] sArray; + + //Localized tooltips + private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType"); + private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions"); + private static final String TT_hollow = StatCollector.translateToLocal("GT5U.MBTT.Hollow"); + private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure"); + private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller"); + private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum"); + private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch"); + private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"); + private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch"); + private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch"); + private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus"); + private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch"); + private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus"); + private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch"); + private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes"); + private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS"); + private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold"); + private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display"); + private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod"); + + public GT_Multiblock_Tooltip_Builder() { + iLines = new LinkedList<>(); + sLines = new LinkedList<>(); + } + + /** + * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br> + * Machine Type: machine + * + * @param machine + * Name of the machine type + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMachineType(String machine) { + iLines.add(TT_machineType + COLON + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET); + return this; + } + + /** + * Add a basic line of information about this structure + * + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInfo(String info) { + iLines.add(info); + return this; + } + + /** + * Add a separator line like this:<br> + * ----------------------------------------- + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addSeparator() { + iLines.add("-----------------------------------------"); + return this; + } + + /** + * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br> + * Machine Type: machine + * + * @param machine + * Name of the machine type + * + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) { + iLines.add(TT_causes + COLON + EnumChatFormatting.DARK_PURPLE + pollution + " " + EnumChatFormatting.GRAY + TT_pps); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions + * and then inserting a "Structure:" line. + * + * @param w + * Structure width. + * @param h + * Structure height. + * @param l + * Structure depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL) " + TT_hollow); + } + else { + sLines.add(TT_dimensions + COLON + w + "x" + h + "x" + l + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; + } + + /** + * Begin adding structural information by adding a line about the structure's dimensions<br> + * and then inserting a "Structure:" line. Variable version displays min and max + * + * @param wmin + * Structure min width. + * @param wmax + * Structure max width. + * @param hmin + * Structure min height. + * @param hmax + * Structure max height. + * @param lmin + * Structure min depth/length. + * @param lmax + * Structure max depth/length. + * @param hollow + * T/F, adds a (hollow) comment if true + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder beginVariableStructureBlock(int wmin, int wmax, int hmin, int hmax, int lmin, int lmax, boolean hollow) { + if (hollow) { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL) " + TT_hollow); + } + else { + sLines.add(TT_dimensions + COLON + wmin + "-" + wmax + "x" + hmin + "-" + hmax + "x" + lmin + "-" + lmax + " (WxHxL)"); + } + sLines.add(TT_structure + COLON); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Controller: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addController(String info) { + sLines.add(TAB + TT_controller + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)minCountx casingName (minimum) + * @param casingName + * Name of the Casing. + * @param minCount + * Minimum needed for valid structure check. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) { + sLines.add(TAB + minCount +"x " + casingName + " " + TT_minimum); + return this; + } + + /** + * Use this method to add a structural part that isn't covered by the other methods.<br> + * (indent)name: info + * @param name + * Name of the hatch or other component. + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) { + sLines.add(TAB + name + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Maintenance Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) { + sLines.add(TAB + TT_maintenancehatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Muffler Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) { + sLines.add(TAB + TT_mufflerhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Energy Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) { + sLines.add(TAB + TT_energyhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Dynamo Hatch: info + * @param info + * Positional information. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) { + sLines.add(TAB + TT_dynamohatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputBus(String info) { + sLines.add(TAB + TT_inputbus + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Input Hatch: info + * @param info + * Location where the hatch goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addInputHatch(String info) { + sLines.add(TAB + TT_inputhatch + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Bus: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputBus(String info) { + sLines.add(TAB + TT_outputbus + COLON + info); + return this; + } + + /** + * Add a line of information about the structure:<br> + * (indent)Output Hatch: info + * @param info + * Location where the bus goes + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) { + sLines.add(TAB + TT_outputhatch + COLON + info); + return this; + } + + /** + * Use this method to add non-standard structural info.<br> + * (indent)info + * @param info + * The line to be added. + * @return Instance this method was called on. + */ + public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) { + sLines.add(TAB + info); + return this; + } + + /** + * Call at the very end.<br> + * Adds a final line with the mod name and information on how to display the structure guidelines.<br> + * Ends the building process. + * + * @param mod + * Name of the mod that adds this multiblock machine + */ + public void toolTipFinisher(String mod) { + iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay); + iLines.add(TT_mod + COLON + EnumChatFormatting.GREEN + mod + EnumChatFormatting.GRAY); + iArray = new String[iLines.size()]; + sArray = new String[sLines.size()]; + iLines.toArray(iArray); + sLines.toArray(sArray); + } + + public String[] getInformation() { + return iArray; + } + + public String[] getStructureInformation() { + return sArray; + } + +} diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 9d9b45cecf..188af9cfaa 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -156,6 +156,59 @@ public class GT_OreDictUnificator { return GT_Utility.copyAmount(aStack.stackSize, rStack); } + /** Doesn't copy the returned stack or set quantity. Be careful and do not mutate it; + * intended only to optimize comparisons */ + static ItemStack get_nocopy(boolean aUseBlackList, ItemStack aStack) { + if (GT_Utility.isStackInvalid(aStack)) return null; + ItemData tPrefixMaterial = getAssociation(aStack); + ItemStack rStack = null; + if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() || (aUseBlackList && tPrefixMaterial.mBlackListed)) + return aStack; + if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { + tPrefixMaterial.mBlackListed = true; + return aStack; + } + if (tPrefixMaterial.mUnificationTarget == null) + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + rStack = tPrefixMaterial.mUnificationTarget; + if (GT_Utility.isStackInvalid(rStack)) return aStack; + assert rStack != null; + rStack.setTagCompound(aStack.getTagCompound()); + return rStack; + } + + /** Compares the first argument against an already-unificated second argument as if + * aUseBlackList was both true and false. */ + public static boolean isInputStackEqual(ItemStack aStack, ItemStack unified_tStack) { + boolean alreadyCompared = false; + if (GT_Utility.isStackInvalid(aStack)) return false; + ItemData tPrefixMaterial = getAssociation(aStack); + ItemStack rStack = null; + if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData()) + return GT_Utility.areStacksEqual(aStack, unified_tStack, true); + else if(tPrefixMaterial.mBlackListed) { + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) + return true; + else + alreadyCompared = true; + } + if (!alreadyCompared && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { + tPrefixMaterial.mBlackListed = true; + if (GT_Utility.areStacksEqual(aStack, unified_tStack, true)) + return true; + else + alreadyCompared = true; + } + if (tPrefixMaterial.mUnificationTarget == null) + tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); + rStack = tPrefixMaterial.mUnificationTarget; + if (GT_Utility.isStackInvalid(rStack)) + return !alreadyCompared && GT_Utility.areStacksEqual(aStack, unified_tStack, true); + assert rStack != null; + rStack.setTagCompound(aStack.getTagCompound()); + return GT_Utility.areStacksEqual(rStack, unified_tStack, true); + } + public static List<ItemStack> getNonUnifiedStacks(Object obj) { synchronized (sUnificationTable) { if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index db8ecf73b6..537d92b365 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import static gregtech.api.enums.GT_Values.*; @@ -388,11 +389,12 @@ public class GT_Recipe implements Comparable<GT_Recipe> { if (mInputs.length > 0 && aInputs == null) return false; for (ItemStack tStack : mInputs) { - if (tStack != null) { + ItemStack unified_tStack = GT_OreDictUnificator.get_nocopy(true, tStack); + if (unified_tStack != null) { amt = tStack.stackSize; boolean temp = true; for (ItemStack aStack : aInputs) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (GT_OreDictUnificator.isInputStackEqual(aStack, unified_tStack)) { if (GTppRecipeHelper) {//remove once the fix is out if (GT_Utility.areStacksEqual(aStack, Ic2Items.FluidCell.copy(), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataStick.get(1L), true) || GT_Utility.areStacksEqual(aStack, ItemList.Tool_DataOrb.get(1L), true)) { if (!GT_Utility.areStacksEqual(aStack, tStack, false)) @@ -613,12 +615,13 @@ public class GT_Recipe implements Comparable<GT_Recipe> { public static final GT_Recipe_Map sHammerRecipes = new GT_Recipe_Map(new HashSet<>(3800), "gt.recipe.hammer", "Forge Hammer", null, RES_PATH_GUI + "basicmachines/Hammer", 1, 1, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sAmplifiers = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.uuamplifier", "Amplifabricator", null, RES_PATH_GUI + "basicmachines/Amplifabricator", 1, 0, 1, 0, 1, E, 1, E, true, true); public static final GT_Recipe_Map sMassFabFakeRecipes = new GT_Recipe_Map(new HashSet<>(2), "gt.recipe.massfab", "Mass Fabrication", null, RES_PATH_GUI + "basicmachines/Massfabricator", 1, 0, 1, 0, 10, E, 1, E, true, true); - public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Diesel Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.dieselgeneratorfuel", "Combustion Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sExtremeDieselFuels = new GT_Recipe_Map_Fuel(new HashSet<>(20), "gt.recipe.extremedieselgeneratorfuel", "Extreme Diesel Engine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sTurbineFuels = new GT_Recipe_Map_Fuel(new HashSet<>(25), "gt.recipe.gasturbinefuel", "Gas Turbine Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuel", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); + public static final GT_Recipe_Map_Fuel sHotFuels = new GT_Recipe_Map_Fuel(new HashSet<>(10), "gt.recipe.thermalgeneratorfuel", "Thermal Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, false); public static final GT_Recipe_Map_Fuel sDenseLiquidFuels = new GT_Recipe_Map_Fuel(new HashSet<>(15), "gt.recipe.semifluidboilerfuels", "Semifluid Boiler Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sPlasmaFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.plasmageneratorfuels", "Plasma Generator Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); - public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); + public static final GT_Recipe_Map_Fuel sMagicFuels = new GT_Recipe_Map_Fuel(new HashSet<>(100), "gt.recipe.magicfuels", "Magic Energy Absorber Fuels", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sSmallNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.smallnaquadahreactor", "Naquadah Reactor MkI", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sLargeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.largenaquadahreactor", "Naquadah Reactor MkII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); public static final GT_Recipe_Map_Fuel sHugeNaquadahReactorFuels = new GT_Recipe_Map_Fuel(new HashSet<>(1), "gt.recipe.fluidnaquadahreactor", "Naquadah Reactor MkIII", null, RES_PATH_GUI + "basicmachines/Default", 1, 1, 0, 0, 1, "Fuel Value: ", 1000, " EU", true, true); @@ -1838,15 +1841,19 @@ public class GT_Recipe implements Comparable<GT_Recipe> { } public GT_Recipe addFakeRecipe(boolean aCheckForCollisions, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecial, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + AtomicInteger ai = new AtomicInteger(); Optional.ofNullable(GT_OreDictUnificator.getAssociation(aOutputs[0])) .map(itemData -> itemData.mMaterial) .map(materialsStack -> materialsStack.mMaterial) .map(materials -> materials.mElement) .map(Element::getMass) .ifPresent(e -> - aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e) + { + aFluidInputs[0].amount = (int) GT_MetaTileEntity_Replicator.cubicFluidMultiplier(e); + ai.set(GT_Utility.safeInt(aFluidInputs[0].amount * 512L, 1)); + } ); - return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)); + return addFakeRecipe(aCheckForCollisions, new GT_Recipe(false, aInputs, aOutputs, aSpecial, null, aFluidInputs, aFluidOutputs, ai.get(), aEUt, aSpecialValue)); } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8584e849bb..05e0874e7a 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -65,6 +65,7 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; +import net.minecraftforge.oredict.OreDictionary; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -522,6 +523,109 @@ public class GT_Utility { } /** + * moves multiple stacks from Inv-Side to Inv-Side + * + * @return the Amount of moved Items + */ + + public static int moveMultipleItemStacks(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aStackAmount) { + if (aTileEntity1 instanceof IInventory) + return moveMultipleItemStacks((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,aStackAmount, true); + return 0; + } + + public static int moveMultipleItemStacks(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce,int aMaxStackTransfer, boolean aDoCheckChests) { + if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce || aMaxStackTransfer == 0) + return 0; + int tGrabInventorySize = aTileEntity1.getSizeInventory(); + if (aTileEntity2 instanceof IInventory) + { + IInventory tPutInventory = (IInventory) aTileEntity2; + int tPutInventorySize = tPutInventory.getSizeInventory(); + int tFirstsValidSlot = 0,tStacksMoved = 0,tTotalItemsMoved = 0; + for (int tGrabSlot = 0;tGrabSlot<tGrabInventorySize;tGrabSlot++) + { + //ItemStack tInventoryStack : mInventory + int tMovedItems; + do { + tMovedItems = 0; + ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlot); + if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter) && + (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlot, aGrabFrom, tGrabStack))) { + int tStackSize = tGrabStack.stackSize; + + for (int tPutSlot = tFirstsValidSlot; tPutSlot < tPutInventorySize; tPutSlot++) { + if (isAllowedToPutIntoSlot(tPutInventory, tPutSlot, aPutTo, tGrabStack, (byte) 64)) { + int tMoved = moveStackFromSlotAToSlotB(aTileEntity1, tPutInventory, tGrabSlot, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItems), aMinMoveAtOnce); + tTotalItemsMoved += tMoved; + tMovedItems += tMoved; + if (tMovedItems == tStackSize) + break; + } + } + if (tMovedItems > 0) { + if (++tStacksMoved >= aMaxStackTransfer) + return tTotalItemsMoved; + } + } + } while (tGrabInventorySize == 2 && tMovedItems > 0); //to suport draweres and barrels + } + if (aDoCheckChests && aTileEntity1 instanceof TileEntityChest) { + TileEntityChest tTileEntity1 = (TileEntityChest) aTileEntity1; + int tAmount = 0; + int maxStackTransfer = aMaxStackTransfer - tStacksMoved; + if (tTileEntity1.adjacentChestXNeg != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestZNeg != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZNeg, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestXPos != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestXPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity1.adjacentChestZPos != null) { + tAmount = moveMultipleItemStacks(tTileEntity1.adjacentChestZPos, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } + if (tAmount != 0) return tAmount+tTotalItemsMoved; + } + + if (aDoCheckChests && aTileEntity2 instanceof TileEntityChest) { + TileEntityChest tTileEntity2 = (TileEntityChest) aTileEntity2; + if (tTileEntity2.adjacentChestChecked) { + int tAmount = 0; + int maxStackTransfer = aMaxStackTransfer - tStacksMoved; + if (tTileEntity2.adjacentChestXNeg != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestZNeg != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestXPos != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } else if (tTileEntity2.adjacentChestZPos != null) { + tAmount = moveMultipleItemStacks(aTileEntity1, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce,maxStackTransfer, false); + } + if (tAmount != 0) return tAmount+tTotalItemsMoved; + } + } + + return tTotalItemsMoved; + + } + //there should be a function to transfer more then 1 stack in a pipe + //ut i dont see any ways to improve it too much work for what it is worth + int[] tGrabSlots = new int[tGrabInventorySize]; + for (int i = 0; i < tGrabInventorySize; i++) { + tGrabSlots[i] = i; + } + int tTotalItemsMoved = 0; + for (int i = 0; i < tGrabInventorySize; i++) { + int tMoved = moveStackIntoPipe(aTileEntity1, aTileEntity2, tGrabSlots, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); + if (tMoved == 0) + return tTotalItemsMoved; + else + tTotalItemsMoved += tMoved; + } + return 0; + } + + + /** * Moves Stack from Inv-Side to Inv-Side. * * @return the Amount of moved Items @@ -538,7 +642,7 @@ public class GT_Utility { private static byte moveOneItemStack(IInventory aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { if (aTileEntity1 == null || aMaxTargetStackSize <= 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) return 0; - + int[] tGrabSlots = null; if (aTileEntity1 instanceof ISidedInventory) tGrabSlots = ((ISidedInventory) aTileEntity1).getAccessibleSlotsFromSide(aGrabFrom); @@ -547,7 +651,7 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i; } - if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) { + if (aTileEntity2 instanceof IInventory) { int[] tPutSlots = null; if (aTileEntity2 instanceof ISidedInventory) tPutSlots = ((ISidedInventory) aTileEntity2).getAccessibleSlotsFromSide(aPutTo); @@ -559,15 +663,14 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) { byte tMovedItemCount = 0; - for (int j = 0; j < tPutSlots.length; j++) { - if (listContainsItem(aFilter, aTileEntity1.getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) { - if (isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, aTileEntity1.getStackInSlot(tGrabSlots[i]))) { - if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, aTileEntity1.getStackInSlot(tGrabSlots[i]), aMaxTargetStackSize)) { - tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); - if (tMovedItemCount >= aMaxMoveAtOnce) { + ItemStack tGrabStack = aTileEntity1.getStackInSlot(tGrabSlots[i]); + if (listContainsItem(aFilter, tGrabStack, true, aInvertFilter)) { + if (tGrabStack.stackSize >= aMinMoveAtOnce && isAllowedToTakeFromSlot(aTileEntity1, tGrabSlots[i], aGrabFrom, tGrabStack)) { + for (int j = 0; j < tPutSlots.length; j++) { + if (isAllowedToPutIntoSlot((IInventory) aTileEntity2, tPutSlots[j], aPutTo, tGrabStack, aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB(aTileEntity1, (IInventory) aTileEntity2, tGrabSlots[i], tPutSlots[j], aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); + if (tMovedItemCount >= aMaxMoveAtOnce ||(tMovedItemCount > 0 && aMaxTargetStackSize < 64)) return tMovedItemCount; - - } } } } @@ -665,6 +768,64 @@ public class GT_Utility { return 0; } + /** + * Moves Stack from Inv-Side to Inv-Slot. + * + * @return the Amount of moved Items + */ + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce, boolean aDoCheckChests) { + if (fromTile == null || aGrabFrom < 0 || aMinTargetStackSize <= 0 || aMaxMoveAtOnce <= 0 || aMinTargetStackSize > aMaxTargetStackSize || aMinMoveAtOnce > aMaxMoveAtOnce) + return 0; + + if (!listContainsItem(aFilter, fromTile.getStackInSlot(aGrabFrom), true, aInvertFilter) || + !isAllowedToTakeFromSlot(fromTile, aGrabFrom, (byte) 6, fromTile.getStackInSlot(aGrabFrom))) + return 0; + + if (toTile instanceof IInventory) { + int[] tPutSlots = null; + if (toTile instanceof ISidedInventory) + tPutSlots = ((ISidedInventory) toTile).getAccessibleSlotsFromSide(aPutTo); + + if (tPutSlots == null) { + tPutSlots = new int[((IInventory) toTile).getSizeInventory()]; + for (int i = 0; i < tPutSlots.length; i++) tPutSlots[i] = i; + } + + byte tMovedItemCount = 0; + for (int tPutSlot : tPutSlots) { + if (isAllowedToPutIntoSlot((IInventory) toTile, tPutSlot, aPutTo, fromTile.getStackInSlot(aGrabFrom), aMaxTargetStackSize)) { + tMovedItemCount += moveStackFromSlotAToSlotB(fromTile, (IInventory) toTile, aGrabFrom, tPutSlot, aMaxTargetStackSize, aMinTargetStackSize, (byte) (aMaxMoveAtOnce - tMovedItemCount), aMinMoveAtOnce); + if (tMovedItemCount >= aMaxMoveAtOnce) { + return tMovedItemCount; + + } + } + } + if (tMovedItemCount > 0) return tMovedItemCount; + + if (aDoCheckChests && toTile instanceof TileEntityChest) { + TileEntityChest tTileEntity2 = (TileEntityChest) toTile; + if (tTileEntity2.adjacentChestChecked) { + if (tTileEntity2.adjacentChestXNeg != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestZNeg != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZNeg, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestXPos != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestXPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } else if (tTileEntity2.adjacentChestZPos != null) { + tMovedItemCount = moveFromSlotToSide(fromTile, tTileEntity2.adjacentChestZPos, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, false); + } + if (tMovedItemCount > 0) return tMovedItemCount; + } + } + } + return moveStackIntoPipe(fromTile, toTile, new int[]{aGrabFrom}, (byte) 6, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, aDoCheckChests); + } + + public static byte moveFromSlotToSide(IInventory fromTile, Object toTile, int aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { + return moveFromSlotToSide(fromTile, toTile, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); + } + public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) { if (aStack == null || aStack.stackSize < 1) return false; if (aList == null) return aTIfListEmpty; @@ -2432,5 +2593,12 @@ public class GT_Utility { public static boolean isPartOfOrePrefix(ItemStack aStack, OrePrefixes aPrefix){ return GT_OreDictUnificator.getAssociation(aStack) != null ? GT_OreDictUnificator.getAssociation(aStack).mPrefix.equals(aPrefix) : false; } + public static boolean isOre(ItemStack aStack) { + for (int id: OreDictionary.getOreIDs(aStack)) { + if (OreDictionary.getOreName(id).startsWith("ore")) + return true; + } + return false; + } } |