From 7d326102203de761d8a2d4a47642d86268461286 Mon Sep 17 00:00:00 2001 From: Dream-MasterXXL Date: Tue, 11 Dec 2018 09:54:53 +0100 Subject: Cehrry pick d1e010d53f2cd90ac5855ec6673a393731bc20f9 Better NC panel input/output format and additional book recipe (#1501) * Update src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java * Update src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java --- .../implementations/GT_MetaTileEntity_BasicBatteryBuffer.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index c35690b868..5835a6c9ab 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -269,7 +269,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier } return false; } - + @Override public int getInventoryStackLimit() { return 1; @@ -320,8 +320,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier EnumChatFormatting.BLUE+getLocalName()+EnumChatFormatting.RESET, "Stored Items:", EnumChatFormatting.GREEN+GT_Utility.formatNumbers(mStored) +EnumChatFormatting.RESET+ " EU / "+ - EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU" - }; + EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU", + "Average input:", + GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricInput())+" EU/t", + "Average output:", + GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricOutput())+" EU/t"}; } @Override -- cgit From f9e85bd77f471c2cba2ed33937a8f74f05cc6f65 Mon Sep 17 00:00:00 2001 From: Dimach Date: Wed, 12 Dec 2018 09:25:36 +0200 Subject: Add disable sort option for input bus. Default behavior will stay same --- .../GT_MetaTileEntity_Hatch_InputBus.java | 53 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 d053bc658e..8c36c2af65 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 @@ -6,24 +6,29 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; + public boolean disableSort; public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Input for Multiblocks", - "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")}); + super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{ + "Item Input for Multiblocks", + "Shift + right click with screwdriver to turn Sort mode on/off", + "Capacity: " + getSlots(aTier) + " stack" + (getSlots(aTier) >= 2 ? "s" : "")}); } public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); } - + public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16, aDescription, aTextures); } @@ -114,11 +119,43 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { } protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } + if (disableSort) { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } else { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("disableSort", disableSort); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + disableSort = aNBT.getBoolean("disableSort"); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) + return; + if (aPlayer.isSneaking()) { + disableSort = !disableSort; + GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled"))); + } + } + + public String trans(String aKey, String aEnglish) { + return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_" + aKey, aEnglish, false); } @Override -- cgit From 7e533440f4a250c8bdfbcf5c646e5c0e80c75b52 Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 16 Jan 2019 21:49:02 +0100 Subject: Change fuel requirements --- .../GT_MetaTileEntity_BasicGenerator.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index c20b8ad3a8..56eee6802a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -205,7 +205,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); } } else { - int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); + long tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK @@ -216,7 +216,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } } if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { - int tFuelValue = getFuelValue(mInventory[getInputSlot()]); + long tFuelValue = getFuelValue(mInventory[getInputSlot()]); if (tFuelValue > 0) { ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { @@ -248,15 +248,26 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity Collection tRecipeList = getRecipes().mRecipeList; if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) - if (aLiquid.isFluidEqual(tLiquid)) - return (int) (((long) tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); + if (aLiquid.isFluidEqual(tLiquid)){ + long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid) / 100; + if(val> Integer.MAX_VALUE){ + throw new ArithmeticException("Integer LOOPBACK!"); + } + return (int) val; + } return 0; } public int getFuelValue(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return (int) ((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); + if (tFuel != null){ + long val=(long)tFuel.mSpecialValue * 10L /*<- 1000mb/100 */ * getEfficiency(); + if(val> Integer.MAX_VALUE){ + throw new ArithmeticException("Integer LOOPBACK!"); + } + return (int) val; + } return 0; } -- cgit From a0730d751f4ca89ce47a379140f5a53a77ad4f9c Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Tue, 22 Jan 2019 08:35:28 -0600 Subject: Fix problem with genertor leaving 1L and IC2 universal fluid cells providing random EU. --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 56eee6802a..863bc15827 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -202,11 +202,11 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } else { if (mInventory[getStackDisplaySlot()] == null) mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); } } else { long tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); - if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { + if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount >= tConsumed) { long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { @@ -215,8 +215,9 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } } } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) { long tFuelValue = getFuelValue(mInventory[getInputSlot()]); + //System.out.println(" tFuelValue : " + tFuelValue ); if (tFuelValue > 0) { ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { @@ -243,6 +244,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } public int getFuelValue(FluidStack aLiquid) { + //System.out.println("Fluid stack check"); if (aLiquid == null || getRecipes() == null) return 0; FluidStack tLiquid; Collection tRecipeList = getRecipes().mRecipeList; @@ -259,6 +261,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } public int getFuelValue(ItemStack aStack) { + //System.out.println("Item stack check"); if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); if (tFuel != null){ -- cgit From 422886a0b721cda0153504a4833de32a4427eb4d Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Wed, 23 Jan 2019 20:58:44 -0600 Subject: Re-enable filling containers from generators. --- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 863bc15827..da1fd9170e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -153,8 +153,8 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean doesFillContainers() { - //return getBaseMetaTileEntity().isAllowedToWork(); - return false; + return getBaseMetaTileEntity().isAllowedToWork(); + //return false; } @Override -- cgit From ee9b263815abe1e158b057996ce76f33dbf82f1e Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 18 Feb 2019 22:37:09 +0100 Subject: several fixes: -removeal of Axe for base entites -streamlined single block NaquadahReactor -fixed basegenerator for naquadagen Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 2 +- .../metatileentity/implementations/GT_MetaPipeEntity_Frame.java | 2 +- .../metatileentity/implementations/GT_MetaPipeEntity_Item.java | 2 +- .../implementations/GT_MetaTileEntity_BasicGenerator.java | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 e128c8c842..6388c7044c 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 @@ -83,7 +83,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public byte getTileEntityBaseType() { - return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java index fd04893ec7..9db9ad910e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java @@ -33,7 +33,7 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { @Override public byte getTileEntityBaseType() { - return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); } @Override 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 bba105c95f..650e9a031e 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 @@ -64,7 +64,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public byte getTileEntityBaseType() { - return mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index da1fd9170e..5c48b2569a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -1,8 +1,11 @@ package gregtech.api.metatileentity.implementations; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +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; @@ -215,7 +218,10 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } } } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) { + + boolean naqOverride = GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]) != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cell && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cellMolten && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cellPlasma && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial.mMaterial.equals(Materials.NaquadahEnriched) || GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial.mMaterial.equals(Materials.Naquadria); + + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || naqOverride)) { long tFuelValue = getFuelValue(mInventory[getInputSlot()]); //System.out.println(" tFuelValue : " + tFuelValue ); if (tFuelValue > 0) { -- cgit From 6cc3eefe3c238ecaa3f13c45a37afe2e77ec84e8 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 19 Feb 2019 12:30:37 +0100 Subject: redid the naquadah override to an universal solid fuel function --- .../GT_MetaTileEntity_BasicGenerator.java | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 5c48b2569a..ccc0fc0af4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -1,10 +1,11 @@ package gregtech.api.metatileentity.implementations; -import gregtech.api.enums.Materials; +import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.ItemData; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; @@ -14,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; import java.util.Collection; @@ -219,9 +222,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } } - boolean naqOverride = GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]) != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cell && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cellMolten && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mPrefix != OrePrefixes.cellPlasma && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial != null && GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial.mMaterial.equals(Materials.NaquadahEnriched) || GT_OreDictUnificator.getAssociation(mInventory[getInputSlot()]).mMaterial.mMaterial.equals(Materials.Naquadria); - - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || naqOverride)) { + if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || solidFuelOverride(mInventory[getInputSlot()]))) { long tFuelValue = getFuelValue(mInventory[getInputSlot()]); //System.out.println(" tFuelValue : " + tFuelValue ); if (tFuelValue > 0) { @@ -238,7 +239,26 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); } - + + /** + * @param stack the fuel stack + * @return if the stack is a solid fuel + */ + public boolean solidFuelOverride(ItemStack stack) { + //this could be used for a coal generator for example aswell... + ItemData association = GT_OreDictUnificator.getAssociation(stack); + //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK, cell, motlen cell or plasma cell, else do vanilla checks + return association != null ? !OrePrefixes.cell.equals(association.mPrefix) && + !OrePrefixes.cellMolten.equals(association.mPrefix) && + !OrePrefixes.cellPlasma.equals(association.mPrefix) && + !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true) : + stack != null && //when the stack is null its not a solid + stack.getItem() != null && //when the item in the stack is null its not a solid + !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... + !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... + !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + } + public abstract int getPollution(); public abstract GT_Recipe_Map getRecipes(); -- cgit From ce2e11bd8040df5a45e362aa847db7051286de1c Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Fri, 1 Mar 2019 23:05:17 -0600 Subject: Fix for pipes left with 1L when splitting. --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 6388c7044c..f77c419c0e 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 @@ -330,7 +330,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { // Now distribute for (MutableTriple tEntry: tTanks) { - if (availableCapacity > tAmount) tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity); + if (availableCapacity > tAmount) tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity); // Distribue fluids based on percentage available space at destination + if (tEntry.right == 0) tEntry.right = (int)Math.min(1, tAmount); // If the percent is not enough to give at least 1L, try to give 1L if (tEntry.right <= 0) continue; int tFilledAmount = tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false); -- cgit From 75404252d7a3040e0e9d4d00d78bb74d3c2b53e1 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Mon, 11 Mar 2019 22:29:02 -0500 Subject: Cherry pick multiamp dynamo support for multiblock generators. Removed local explosion checks from large turbine and plasma turbine. Large turbs now support buffered 4A dynamos. --- .../GT_MetaTileEntity_MultiBlockBase.java | 71 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 ad5b94266c..2da97a1939 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 @@ -515,15 +515,74 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) return true; - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { - return true; + if (aEU <= 0) { + return true; + } + if (mDynamoHatches.size() > 0) { + return addEnergyOutputMultipleDynamos(aEU, true); + } + return false; + } + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { + int injected = 0; + long totalOutput = 0; + long aFirstVoltageFound = -1; + boolean aFoundMixedDynamos = false; + for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { + if( aDynamo == null ) { + return false; + } + if (isValidMetaTileEntity(aDynamo)) { + long aVoltage = aDynamo.maxEUOutput(); + long aTotal = aDynamo.maxAmperesOut() * aVoltage; + // Check against voltage to check when hatch mixing + if (aFirstVoltageFound == -1) { + 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; + } + } + totalOutput += aTotal; } } - return false; + + if (totalOutput < aEU || (aFoundMixedDynamos && !aAllowMixedVoltageDynamos)) { + explodeMultiblock(); + return false; + } + + long leftToInject; + //Long EUt calculation + long aVoltage; + //Isnt too low EUt check? + int aAmpsToInject; + int aRemainder; + + //xEUt *= 4;//this is effect of everclocking + for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { + if (isValidMetaTileEntity(aDynamo)) { + leftToInject = aEU - injected; + aVoltage = aDynamo.maxEUOutput(); + aAmpsToInject = (int) (leftToInject / aVoltage); + aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); + long powerGain; + for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject > 0 ? aAmpsToInject : 1); i++) { + powerGain = aAmpsToInject > 0 ? aVoltage : aRemainder; + aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false); + injected += powerGain; + } + } + } + return injected > 0; } public long getMaxInputVoltage() { -- cgit From 9b71ae54da263e6c5d0e808f847f8ba8fe6c891a Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 9 Apr 2019 17:55:01 +0200 Subject: fixes +refractored code, +restored compability to vanilla ore gen, +moved GC and Forrestry code to own classes to prevent crashes inDev +implemented equals and hashcode on NearbySeeds class +added an information line to the Implosion Compressor tooltip --- .../implementations/GT_MetaPipeEntity_Cable.java | 39 ++++++---------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 5d672547d8..267287c430 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 @@ -2,6 +2,7 @@ package gregtech.api.metatileentity.implementations; import cofh.api.energy.IEnergyReceiver; import com.google.common.collect.Sets; +import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Dyes; @@ -17,6 +18,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_GC_Compat; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -29,12 +31,7 @@ import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySource; import ic2.api.energy.tile.IEnergyTile; import ic2.api.reactor.IReactorChamber; -import micdoodle8.mods.galacticraft.api.power.EnergySource; -import micdoodle8.mods.galacticraft.api.power.EnergySource.EnergySourceAdjacent; -import micdoodle8.mods.galacticraft.api.power.IEnergyHandlerGC; -import micdoodle8.mods.galacticraft.api.transmission.NetworkType; -import micdoodle8.mods.galacticraft.api.transmission.tile.IConnector; -import micdoodle8.mods.galacticraft.core.energy.EnergyConfigHandler; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -242,6 +239,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile return rUsedAmperes; } + + private long insertEnergyInto(TileEntity tTileEntity, byte tSide, long aVoltage, long aAmperage) { if (aAmperage == 0 || tTileEntity == null) return 0; @@ -264,26 +263,10 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile return 0; } - // GC Compat - if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC) { - if (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDirection, NetworkType.POWER)) { - EnergySource eSource = new EnergySourceAdjacent(tDirection); - - float tSizeToReceive = aVoltage * EnergyConfigHandler.IC2_RATIO, tStored = ((IEnergyHandlerGC)tTileEntity).getEnergyStoredGC(eSource); - if (tSizeToReceive >= tStored || tSizeToReceive <= ((IEnergyHandlerGC)tTileEntity).getMaxEnergyStoredGC(eSource) - tStored) { - float tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); - if (tReceived > 0) { - tSizeToReceive -= tReceived; - while (tSizeToReceive > 0) { - tReceived = ((IEnergyHandlerGC)tTileEntity).receiveEnergyGC(eSource, tSizeToReceive, false); - if (tReceived < 1) break; - tSizeToReceive -= tReceived; - } - return 1; - } - } - } - return 0; + if (Loader.isModLoaded("GalacticraftCore")) { + long gc = GT_GC_Compat.insertEnergyInto(tTileEntity, aVoltage, tDirection); + if (gc != 2) + return gc; } // IC2 Compat @@ -464,9 +447,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (coverBehavior instanceof GT_Cover_SolarPanel) return true; // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) --> Not needed - - // GC Compat - if (GregTech_API.mGalacticraft && tTileEntity instanceof IEnergyHandlerGC && (!(tTileEntity instanceof IConnector) || ((IConnector)tTileEntity).canConnect(tDir, NetworkType.POWER))) + if (Loader.isModLoaded("GalacticraftCore") && GT_GC_Compat.canConnect(tTileEntity,tDir)) return true; // AE2-p2p Compat -- cgit From 30808128b24c828b6d64e12d116d172dac31a3a7 Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Fri, 17 May 2019 03:03:19 +0200 Subject: duct taped import of circuits in assemblers Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index bf6293baae..72105f2074 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -18,6 +18,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; import java.util.Locale; import java.util.Random; @@ -657,8 +658,18 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), new ItemStack[]{aStack}); case 2: return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0) != null && getInputAt(1) != null) || (getInputAt(0) == null && getInputAt(1) == null ? getRecipeList().containsInput(aStack) : (getRecipeList().containsInput(aStack) && null != getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[]{aStack, getInputAt(1)} : new ItemStack[]{getInputAt(0), aStack}))))); - default: + default:{ + int tID = getBaseMetaTileEntity().getMetaTileID(); + if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) {//assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev + if (GT_Utility.isStackValid(aStack)) + for (int oreID : OreDictionary.getOreIDs(aStack)) { + if (OreDictionary.getOreName(oreID).contains("circuit")) + return true; + } + } return getRecipeList().containsInput(aStack); + } + } } -- cgit From c1810a711262fa45069b923e75cfb9289a0d8c2c Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Mon, 17 Jun 2019 07:04:19 +0200 Subject: fixed broken lag message Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> --- .../java/gregtech/api/metatileentity/BaseMetaPipeEntity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 599d8879e4..c03ea8d981 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -303,7 +303,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING*1000000) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) - GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [%s,%s,%s] in Dimension %s with %s ns caused by an instance of %s", xCoord, yCoord, zCoord, worldObj.provider.dimensionId, tTime, getMetaTileEntity().getClass()); + GT_FML_LOGGER.warn("WARNING: Possible Lag Source at ["+xCoord+","+yCoord+","+zCoord+"] in Dimension "+worldObj.provider.dimensionId+" with "+tTime+" ns caused by an instance of "+getMetaTileEntity().getClass()); } mWorkUpdate = mInventoryChanged = false; @@ -1204,7 +1204,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)) return true; - if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()),aFluid, this)) return true; @@ -1241,17 +1241,17 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluid, false)) + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluid, false)) return mMetaTileEntity.canDrain(aSide, aFluid); return false; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() + if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) + && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) // Doesn't need to be connected to get Tank Info -- otherwise things can't connect ) -- cgit From 141051a88b1a0563e12e020f25d192068bde2cfd Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Thu, 20 Jun 2019 00:19:32 -0500 Subject: #4727 Modified code to skip to the next cardinal direction pair when doing power delivery instead of always doing a 0-5 search. This should help simple "straight cables with machines attached" prefer to power the closer machines first, especially for NS runs. --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') 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 267287c430..5b75b89d23 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 @@ -205,9 +205,10 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile long rUsedAmperes = 0; final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - + byte i = (byte)((((aSide/2)*2)+2)%6); //this bit of trickery makes sure a direction goes to the next cardinal pair. IE, NS goes to E, EW goes to U, UD goes to N. It's a lame way to make sure locally connected machines on a wire get EU first. aVoltage -= mCableLossPerMeter; - if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) + + if (aVoltage > 0) for (byte j = 0; j < 6 && aAmperage > rUsedAmperes; j++, i=(byte)((i+1)%6) ) if (i != aSide && isConnectedAtSide(i) && baseMetaTile.getCoverBehaviorAtSide(i).letsEnergyOut(i, baseMetaTile.getCoverIDAtSide(i), baseMetaTile.getCoverDataAtSide(i), baseMetaTile)) { final TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(i); -- cgit From 2c28dec775bb63c92ffeb8fe417b9fc39be29c7a Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Sat, 22 Jun 2019 14:41:31 -0700 Subject: fluid shenanigans --- .../api/metatileentity/BaseMetaPipeEntity.java | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index c03ea8d981..d2ac134dbe 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -20,6 +20,7 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.common.covers.GT_Cover_Fluidfilter; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; @@ -34,6 +35,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; @@ -76,6 +78,18 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE aNBT.setByte("mColor", mColor); aNBT.setByte("mStrongRedstone", mStrongRedstone); aNBT.setBoolean("mWorks", !mWorks); + + for(int i=0;i < mCoverData.length; i++) { + if (GregTech_API.getCoverBehavior(mCoverSides[i]) instanceof GT_Cover_Fluidfilter) { + final int fluidId = mCoverData[i] >>> 3; + final Fluid fluid = FluidRegistry.getFluid(fluidId); + if(fluid != null) { + final String fluidName = FluidRegistry.getFluidName(fluid); + aNBT.setString(String.format("fluidFilter%d", i), fluidName); + } + } + } + } catch (Throwable e) { GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); @@ -134,7 +148,16 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; if (mSidedRedstone.length != 6) mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + for (byte i = 0; i < 6; i++) { + mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + if(mCoverBehaviors[i] instanceof GT_Cover_Fluidfilter) { + final String filterKey = String.format("fluidFilter%d", i); + if (aNBT.hasKey(filterKey)) { + mCoverData[i] = (mCoverData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3); + } + } + } + if (mID != 0 && createNewMetatileEntity(mID)) { NBTTagList tItemList = aNBT.getTagList("Inventory", 10); -- cgit From 1128055939679579b4f260a7eb19bd2c48663253 Mon Sep 17 00:00:00 2001 From: Technus Date: Sat, 13 Jul 2019 22:08:55 +0200 Subject: Upgrade transformer logic --- .../implementations/GT_MetaTileEntity_Transformer.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/main/java/gregtech/api/metatileentity') 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 fd183d9e79..72b24182df 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 @@ -6,14 +6,18 @@ import cofh.api.energy.IEnergyStorage; import crazypants.enderio.machine.capbank.TileCapBank; import crazypants.enderio.machine.capbank.network.ICapBankNetwork; import crazypants.enderio.power.IPowerContainer; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Proxy; import ic2.api.energy.tile.IEnergySource; +import ic2.api.reactor.IReactor; import ic2.api.reactor.IReactorChamber; +import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -151,6 +155,9 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi if (tTileEntity instanceof IReactorChamber) { tTileEntity = (TileEntity) ((IReactorChamber) tTileEntity).getReactor(); } + if(tTileEntity instanceof IReactor && !GT_Mod.gregtechproxy.reactorsDone.add((IReactor) tTileEntity)){ + continue; + } if (tTileEntity instanceof IEnergySource && !(tTileEntity instanceof IPartHost) && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) aBaseMetaTileEntity, ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)))) { long tEU = Math.min(maxEUInput(), (long) ((IEnergySource) tTileEntity).getOfferedEnergy()); ((IEnergySource) tTileEntity).drawEnergy(tEU); -- cgit From 1b7d5e176ec01d7b8fec464371b3e79144fffa8a Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 15 Jul 2019 19:47:31 -0700 Subject: IC2 ENet compat for GT transformers & GT cables * Fixes every face of ic2 nuclear reactors giving full energy * Should reduce performance concerns from previous ic2 energy compat * Removes Tec's workaround --- .../api/metatileentity/BaseMetaPipeEntity.java | 11 +- .../api/metatileentity/BaseMetaTileEntity.java | 10 +- .../api/metatileentity/BaseTileEntity.java | 53 +++++++++ .../api/metatileentity/MetaPipeEntity.java | 4 +- .../api/metatileentity/MetaTileEntity.java | 8 +- .../api/metatileentity/TileIC2EnergySink.java | 131 +++++++++++++++++++++ .../implementations/GT_MetaPipeEntity_Cable.java | 49 +++----- .../GT_MetaTileEntity_Transformer.java | 30 ++--- 8 files changed, 237 insertions(+), 59 deletions(-) create mode 100644 src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index d2ac134dbe..6d9ce47ef2 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -273,6 +273,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); issueBlockUpdate(); + joinEnet(); } if (xCoord != oX || yCoord != oY || zCoord != oZ) { @@ -433,6 +434,9 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); } + if(joinedIc2Enet) + tList.add("Joined IC2 ENet"); + return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -498,7 +502,9 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } @Override - public void setFrontFacing(byte aFacing) {/*Do nothing*/} + public void setFrontFacing(byte aFacing) { + doEnetUpdate(); + } @Override public int getSizeInventory() { @@ -556,6 +562,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mMetaTileEntity.onRemoval(); mMetaTileEntity.setBaseMetaTileEntity(null); } + leaveEnet(); super.invalidate(); } @@ -864,6 +871,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE //logic handled internally GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); } + doEnetUpdate(); return true; } @@ -876,6 +884,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE 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); } + doEnetUpdate(); return true; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 75b34fa73f..1da2dffca9 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -378,6 +378,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE oRedstone = mRedstone; issueBlockUpdate(); } + if(mTickTimer == 10) joinEnet(); if (xCoord != oX || yCoord != oY || zCoord != oZ) { oX = xCoord; @@ -417,6 +418,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } + if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); if (tUsableAmperage > 0) { @@ -746,6 +748,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (!mHasEnoughEnergy) tList.add(EnumChatFormatting.RED+"ATTENTION: This Device needs more power."+EnumChatFormatting.RESET); } + if(joinedIc2Enet) + tList.add("Joined IC2 ENet"); return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -816,6 +820,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mFacing = aFacing; mMetaTileEntity.onFacingChange(); onMachineBlockUpdate(); + doEnetUpdate(); } } @@ -875,6 +880,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public void invalidate() { tileEntityInvalid = false; + leaveEnet(); if (canAccessData()) { mMetaTileEntity.onRemoval(); mMetaTileEntity.setBaseMetaTileEntity(null); @@ -1355,7 +1361,8 @@ 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); - } + } + doEnetUpdate(); return true; } @@ -1365,6 +1372,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE //logic handled internally GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); } + doEnetUpdate(); return true; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 66d1ade42d..eb18ef0d0c 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -1,10 +1,14 @@ package gregtech.api.metatileentity; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.net.GT_Packet_Block_Event; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -13,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; @@ -398,12 +403,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje @Override public void invalidate() { + leaveEnet(); clearNullMarkersFromTileEntityBuffer(); super.invalidate(); } @Override public void onChunkUnload() { + leaveEnet(); clearNullMarkersFromTileEntityBuffer(); super.onChunkUnload(); isDead = true; @@ -442,4 +449,50 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje public String trans(String aKey, String aEnglish){ return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); } + + /* + * IC2 Energy Compat + */ + protected TileIC2EnergySink ic2EnergySink = null; + protected boolean joinedIc2Enet = false; + + public IMetaTileEntity getMetaTileEntity() { return null; } + + protected void createIc2Sink() { + if(ic2EnergySink == null && FMLCommonHandler.instance().getEffectiveSide().isServer() && shouldJoinIc2Enet()) { + ic2EnergySink = new TileIC2EnergySink((IGregTechTileEntity)this); + ic2EnergySink.xCoord = xCoord; + ic2EnergySink.yCoord = yCoord; + ic2EnergySink.zCoord = zCoord; + ic2EnergySink.setWorldObj(worldObj); + } + } + + public void doEnetUpdate() { + leaveEnet(); + joinEnet(); + } + + protected void joinEnet() { + if (joinedIc2Enet || !shouldJoinIc2Enet()) return; + + if(ic2EnergySink == null) createIc2Sink(); + + if (ic2EnergySink != null) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(ic2EnergySink)); + joinedIc2Enet = true; + } + } + + protected void leaveEnet() { +