diff --git a/build.gradle b/build.gradle index d1f5825..e4bde4d 100644 --- a/build.gradle +++ b/build.gradle @@ -373,7 +373,7 @@ catch (Exception ignored) { // Pulls version first from the VERSION env and then git tag String identifiedVersion = null -String versionOverride = '0.0.18p25' +String versionOverride = '0.0.18p26' try { // Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty if (versionOverride == null) { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index 7e480c0..5a7c06c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -345,8 +345,9 @@ public void fromTag(NBTTagCompound tag) { } } } - + if(i==0) if(tag.getInteger("i")>0)i = tag.getInteger("i"); + if(f==0) if(tag.getInteger("f")>0)f = tag.getInteger("f"); recipeLocked = tag.getBoolean("recipeLocked"); lock = tag.getBoolean("lock"); diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java index ea6beb2..cb9bd35 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatch.java @@ -124,6 +124,7 @@ import reobf.proghatches.eucrafting.AECover; import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched; import reobf.proghatches.gt.metatileentity.util.IMultiCircuitSupport; +import reobf.proghatches.gt.metatileentity.util.IOnFillCallback; import reobf.proghatches.gt.metatileentity.util.IProgrammingCoverBlacklisted; import reobf.proghatches.gt.metatileentity.util.IRecipeProcessingAwareDualHatch; import reobf.proghatches.gt.metatileentity.util.ISkipStackSizeCheck; @@ -137,7 +138,7 @@ public class DualInputHatch extends GT_MetaTileEntity_Hatch_InputBus implements IConfigurationCircuitSupport, IAddGregtechLogo, IAddUIWidgets, IDualInputHatch, - IProgrammingCoverBlacklisted, IRecipeProcessingAwareDualHatch,ISkipStackSizeCheck/*,IMultiCircuitSupport*/ { + IProgrammingCoverBlacklisted, IRecipeProcessingAwareDualHatch,ISkipStackSizeCheck,IOnFillCallback/*,IMultiCircuitSupport*/ { static java.text.DecimalFormat format = new java.text.DecimalFormat("#,###"); public boolean mMultiFluid; @@ -1610,7 +1611,7 @@ public void add4by4Slots(ModularWindow.Builder builder, IDrawable... background) } //insertion -protected static final int INSERTION = 2001; +public static final int INSERTION = 2001; protected ModularWindow createInsertionWindow(UIBuildContext buildContext) { int len = (int) Math.round(Math.sqrt(mInventory.length-1)); final int WIDTH = 18 * len + 6; diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatchSlaveBus.java b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatchSlaveBus.java new file mode 100644 index 0000000..bd77147 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DualInputHatchSlaveBus.java @@ -0,0 +1,368 @@ +package reobf.proghatches.gt.metatileentity; + +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_CRAFTING_INPUT_SLAVE; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; + +import com.google.common.collect.ImmutableMap; + +import appeng.api.networking.crafting.ICraftingMedium; +import appeng.api.networking.crafting.ICraftingProvider; +import appeng.api.util.IInterfaceViewable; +import appeng.helpers.ICustomNameObject; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_CraftingInput_ME; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gregtech.common.tileentities.machines.IDualInputInventory; +import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; +import reobf.proghatches.gt.metatileentity.util.IRecipeProcessingAwareDualHatch; +import reobf.proghatches.main.registration.Registration; + +public class DualInputHatchSlaveBus extends GT_MetaTileEntity_Hatch_InputBus + implements IRecipeProcessingAwareHatch { + + private T master; // use getMaster() to access + private int masterX, masterY, masterZ; + private boolean masterSet = false; // indicate if values of masterX, + private boolean recipe; + // masterY, masterZ are valid + + public DualInputHatchSlaveBus(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 6, 0, reobf.proghatches.main.Config.get("DHS", ImmutableMap.of()) + + ); + Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, aID)); + disableSort = true; + } + + public DualInputHatchSlaveBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + disableSort = true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new DualInputHatchSlaveBus<>(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return getTexturesInactive(aBaseTexture); + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_CRAFTING_INPUT_SLAVE) }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + super.onPostTick(aBaseMetaTileEntity, aTimer); + if (aTimer % 100 == 0 && masterSet && getMaster() == null) { + trySetMasterFromCoord(masterX, masterY, masterZ); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if(aNBT.hasKey("x")==false)return; + super.loadNBTData(aNBT); + + if (aNBT.hasKey("master")) { + NBTTagCompound masterNBT = aNBT.getCompoundTag("master"); + masterX = masterNBT.getInteger("x"); + masterY = masterNBT.getInteger("y"); + masterZ = masterNBT.getInteger("z"); + masterSet = true; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (masterSet) { + NBTTagCompound masterNBT = new NBTTagCompound(); + masterNBT.setInteger("x", masterX); + masterNBT.setInteger("y", masterY); + masterNBT.setInteger("z", masterZ); + aNBT.setTag("master", masterNBT); + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + ArrayList ret = new ArrayList(); + if (getMaster() != null) { + ret.add("This bus is linked to the Crafting Input Buffer at " + masterX + ", " + masterY + ", " + masterZ + + "."); + ret.addAll(Arrays.asList(getMaster().getInfoData())); + } else + ret.add("This bus is not linked to any Buffered Dual Inputhatch."); + return ret.toArray(new String[0]); + } + + public T getMaster() { + if (master == null) + return null; + if (((IMetaTileEntity) master).getBaseMetaTileEntity() == null) { // master + // disappeared + master = null; + } + return master; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + +/* @Override + public Iterator inventories() { + return getMaster() != null ? getMaster().inventories() : Collections.emptyIterator(); + } + + @Override + public Optional getFirstNonEmptyInventory() { + return getMaster() != null ? getMaster().getFirstNonEmptyInventory() : Optional.empty(); + }*/ +/* + @Override + public boolean supportsFluids() { + return getMaster() != null && getMaster().supportsFluids(); + } + + @Override + public boolean justUpdated() { + return getMaster() != null && getMaster().justUpdated(); + } +*/ + @SuppressWarnings("unchecked") + public IDualInputHatch trySetMasterFromCoord(int x, int y, int z) { + TileEntity tileEntity = getBaseMetaTileEntity().getWorld().getTileEntity(x, y, z); + if (tileEntity == null) + return null; + if (!(tileEntity instanceof IGregTechTileEntity)) + return null; + IMetaTileEntity metaTileEntity = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + if (!(metaTileEntity instanceof IDualInputHatch)) + return null; + + if (!(metaTileEntity instanceof reobf.proghatches.gt.metatileentity.DualInputHatch)) + return null; + + masterX = x; + masterY = y; + masterZ = z; + masterSet = true; + master = (T) metaTileEntity; + return master; + } + + private boolean tryLinkDataStick(EntityPlayer aPlayer) { + ItemStack dataStick = aPlayer.inventory.getCurrentItem(); + + if (!ItemList.Tool_DataStick.isStackEqual(dataStick, false, true)) { + return false; + } + if (dataStick.hasTagCompound()&&dataStick.stackTagCompound.getString("type") + .equals("CraftingInputBuffer")) { + aPlayer.addChatMessage(new ChatComponentTranslation("programmable_hatches.gt.slave.compat")); + return false; + } + if (!dataStick.hasTagCompound() + || !dataStick.stackTagCompound.getString("type").equals("ProgHatchesDualInput")) { + return false; + } + + NBTTagCompound nbt = dataStick.stackTagCompound; + int x = nbt.getInteger("x"); + int y = nbt.getInteger("y"); + int z = nbt.getInteger("z"); + if (trySetMasterFromCoord(x, y, z) != null) { + aPlayer.addChatMessage(new ChatComponentText("Link successful")); + return true; + } + aPlayer.addChatMessage(new ChatComponentText("Link failed")); + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!(aPlayer instanceof EntityPlayerMP)) { + return false; + } + if (tryLinkDataStick(aPlayer)) { + return true; + } + IDualInputHatch master = getMaster(); + if (master != null) { + return ((MetaTileEntity) master).onRightclick(((IMetaTileEntity) master).getBaseMetaTileEntity(), aPlayer); + } + return false; + } + + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + NBTTagCompound tag = accessor.getNBTData(); + currenttip.add((tag.getBoolean("linked") ? "Linked" : "Not linked")); + + if (tag.hasKey("masterX")) { + currenttip.add("Bound to " + tag.getInteger("masterX") + ", " + tag.getInteger("masterY") + ", " + + tag.getInteger("masterZ")); + } + + + if (tag.hasKey("masterName")) { + currenttip.add(EnumChatFormatting.GOLD + tag.getString("masterName") + + EnumChatFormatting.RESET); } + + + super.getWailaBody(itemStack, currenttip, accessor, config); + } + + public String getNameOf(T tg) { + + if(tg instanceof ICustomNameObject){ + ICustomNameObject iv=(ICustomNameObject) tg; + if(iv.hasCustomName()) + return iv.getCustomName(); + + } + + StringBuilder name = new StringBuilder(); + if (tg instanceof ICraftingMedium &&((ICraftingMedium)tg).getCrafterIcon() != null) { + name.append(((ICraftingMedium)tg).getCrafterIcon().getDisplayName()); + } else { + name.append(tg.getLocalName()); + } + + + return name.toString(); + } + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + + tag.setBoolean("linked", getMaster() != null); + if (masterSet) { + tag.setInteger("masterX", masterX); + tag.setInteger("masterY", masterY); + tag.setInteger("masterZ", masterZ); + } + if (getMaster() != null) tag.setString("masterName", getNameOf(getMaster())); + /* + * if (getMaster() != null) tag.setString("masterName", + * getMaster().getnam); + */ + + super.getWailaNBTData(player, tile, tag, world, x, y, z); + } + + @Override + public void startRecipeProcessing() { + recipe=true; + if(getMaster() != null) + if(getMaster() instanceof IRecipeProcessingAwareDualHatch) + ((IRecipeProcessingAwareDualHatch)getMaster()).startRecipeProcessing(); + + } + IDualInputInventory tmpinv; + public IDualInputInventory getDual(){ + if(tmpinv!=null){return tmpinv;} + if(getMaster() != null){ + + Optional opt = getMaster().getFirstNonEmptyInventory(); + if(opt.isPresent())tmpinv=opt.get(); + } + if(tmpinv==null){tmpinv=new IDualInputInventory() { + + @Override + public ItemStack[] getItemInputs() { + + return new ItemStack[0]; + } + + @Override + public FluidStack[] getFluidInputs() { + + return new FluidStack[0]; + }}; + + } + return tmpinv; + } + ItemStack[] tmpi; + @Override + public int getSizeInventory() { + if(recipe){ + if(tmpi==null){tmpi=tmpinv.getItemInputs();} + return tmpi .length; + + } + return 0; + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + + if(recipe){ + if(tmpi==null){tmpi=tmpinv.getItemInputs();} + return getDual().getItemInputs()[aIndex]; + + } + return null; + } + @Override + public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase controller) { + recipe=false;tmpinv=null;tmpi=null; + if(getMaster() != null) + if(getMaster() instanceof IRecipeProcessingAwareDualHatch) + return ((IRecipeProcessingAwareDualHatch)getMaster()).endRecipeProcessing(controller); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + @Override + public List getItemsForHoloGlasses() { + return getMaster() != null ? getMaster().getItemsForHoloGlasses() : null; + } +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java index c10dade..9ff2ae7 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java @@ -248,7 +248,7 @@ public PatternDualInputHatch(int id, String name, String nameRegional, int tier, .get("PDIH"+(sf?"":"B"), ImmutableMap .of("bufferNum", bufferNum, - "fluidSlots", fluidSlots(tier),/* "cap", + "fluidSlots", 16/*fluidSlots()*/,/* "cap", format.format((int) (4000 * Math.pow(4, tier) / (mMultiFluid ? 4 : 1))),*/ "mMultiFluid", mMultiFluid, "slots", diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/IOnFillCallback.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/IOnFillCallback.java new file mode 100644 index 0000000..75392ac --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/IOnFillCallback.java @@ -0,0 +1,5 @@ +package reobf.proghatches.gt.metatileentity.util; + +public interface IOnFillCallback { +void onFill(); +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java index cae7bd3..b5843ae 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/ListeningFluidTank.java @@ -10,17 +10,17 @@ public class ListeningFluidTank extends FluidTank { - public ListeningFluidTank(int capacity, DualInputHatch thiz) { + public ListeningFluidTank(int capacity, IOnFillCallback thiz) { super(capacity); addListener(thiz::onFill); } - public ListeningFluidTank(FluidStack stack, int capacity, DualInputHatch thiz) { + public ListeningFluidTank(FluidStack stack, int capacity, IOnFillCallback thiz) { super(stack, capacity); addListener(thiz::onFill); } - public ListeningFluidTank(Fluid fluid, int amount, int capacity, DualInputHatch thiz) { + public ListeningFluidTank(Fluid fluid, int amount, int capacity, IOnFillCallback thiz) { super(fluid, amount, capacity); addListener(thiz::onFill); } diff --git a/src/main/java/reobf/proghatches/main/MyMod.java b/src/main/java/reobf/proghatches/main/MyMod.java index 19d7a0d..77f60da 100644 --- a/src/main/java/reobf/proghatches/main/MyMod.java +++ b/src/main/java/reobf/proghatches/main/MyMod.java @@ -54,6 +54,7 @@ import com.glodblock.github.crossmod.opencomputers.DriverLevelMaintainer; import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor; import com.glodblock.github.loader.ItemAndBlockHolder; +import com.gtnewhorizon.structurelib.alignment.constructable.IMultiblockInfoContainer; import appeng.api.AEApi; import appeng.api.config.FuzzyMode; @@ -379,7 +380,7 @@ public void postInit(FMLPostInitializationEvent event) { e.printStackTrace(); } - + //IMultiblockInfoContainer.MULTIBLOCK_MAP.put(GET_PROGHATCHBOOK, null) // ItemList list=new ItemList(); // list.add(AEItemStack.create(ItemProgrammingCircuit.wrap(new // ItemStack(Blocks.cactus)))); diff --git a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java index 1f792b6..65325f2 100644 --- a/src/main/java/reobf/proghatches/main/registration/PHRecipes.java +++ b/src/main/java/reobf/proghatches/main/registration/PHRecipes.java @@ -51,6 +51,7 @@ import reobf.proghatches.item.ItemProgrammingCircuit; import reobf.proghatches.main.Config; import reobf.proghatches.main.MyMod; +import tconstruct.smeltery.TinkerSmeltery; import thaumcraft.api.ThaumcraftApi; import thaumcraft.common.config.ConfigItems; //spotless:off @@ -1066,7 +1067,7 @@ public void run() { GT_Values.RA.stdBuilder() .itemInputs( - new ItemStack( GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration.SlaveOffset), + new ItemStack(GregTech_API.sBlockMachines,0,Config.metaTileEntityOffset+Registration.SlaveOffset), new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) @@ -1077,30 +1078,32 @@ public void run() { .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); - GT_Values.RA.stdBuilder() + + GT_Values.RA.stdBuilder() + .metadata(RESEARCH_ITEM, new ItemStack( GregTech_API.sBlockMachines, + 1,Config.metaTileEntityOffset+Registration.MappingSlaveOffset)) + .metadata(RESEARCH_TIME, 1 * HOURS) .itemInputs( - Hatch_CraftingInput_Bus_ME.get(1), + new ItemStack( GregTech_API.sBlockMachines, + 1, + Config.metaTileEntityOffset+Registration.MappingSlaveOffset), + new ItemStack( ItemAndBlockHolder.INTERFACE), + new ItemStack( ItemAndBlockHolder.INTERFACE), + new ItemStack( ItemAndBlockHolder.INTERFACE), new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) ) - .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, - 1, - Config.metaTileEntityOffset+Registration.PatternMappingSlaveOffset)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs( - new ItemStack( GregTech_API.sBlockMachines,1,Config.metaTileEntityOffset+Registration.PatternOffset), - - new ItemStack(GameRegistry.findItem("RIO", "tile.remote_interface")), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 0), - new ItemStack(GameRegistry.findItem("RIO", "item.chip.transfer"), 1, 1) + .fluidInputs( + new FluidStack(TinkerSmeltery.moltenEnderFluid,1000), + Enderium.getMolten(1000), + HeeEndium.getMolten(1000), + FluidRegistry.getFluid("endergoo")==null?Water.getFluid(1): new FluidStack(FluidRegistry.getFluid("endergoo"),1000) ) .itemOutputs(new ItemStack( GregTech_API.sBlockMachines, 1, Config.metaTileEntityOffset+Registration.PatternMappingSlaveOffset)) - .duration(20 * SECONDS).eut(GT_Values.VP[3]).addTo(RecipeMaps.assemblerRecipes); + .duration(2000000 * SECONDS).eut(GT_Values.VP[1]).addTo(GT_RecipeConstants.AssemblyLine); GT_Values.RA.stdBuilder()