diff --git a/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java b/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java index d96ad1f..4be9df3 100644 --- a/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java +++ b/src/main/java/reobf/proghatches/eucrafting/InterfaceData.java @@ -236,7 +236,7 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf @Override public boolean isBusy() { - // TODO Auto-generated method stub + return this.duality.isBusy(); } diff --git a/src/main/java/reobf/proghatches/gt/cover/LevelControlCover.java b/src/main/java/reobf/proghatches/gt/cover/LevelControlCover.java new file mode 100644 index 0000000..c057a9e --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/cover/LevelControlCover.java @@ -0,0 +1,446 @@ +package reobf.proghatches.gt.cover; + +import java.io.IOException; +import java.util.Arrays; + +import com.google.common.io.ByteArrayDataInput; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.Widget.ClickData; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import appeng.api.networking.security.IActionHost; +import appeng.api.networking.security.MachineSource; +import appeng.api.storage.data.IAEFluidStack; +import appeng.api.storage.data.IAEItemStack; +import appeng.me.GridAccessException; +import appeng.me.helpers.AENetworkProxy; +import appeng.me.helpers.IGridProxyable; +import appeng.parts.p2p.PartP2PTunnel; +import appeng.util.item.AEFluidStack; +import appeng.util.item.AEItemStack; +import gregtech.api.gui.modularui.GT_CoverUIBuildContext; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.covers.IControlsWorkCover; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.util.GT_CoverBehaviorBase; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.ISerializableObject; + +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTSizeTracker; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import reobf.proghatches.eucrafting.AECover; +import reobf.proghatches.eucrafting.AECover.Data; +import reobf.proghatches.gt.metatileentity.util.polyfill.NumericWidget; + +public class LevelControlCover extends GT_CoverBehaviorBase{ + public LevelControlCover() { + super(Data.class); + + } + @Override + public boolean hasCoverGUI() { + // TODO Auto-generated method stub + return true; + } + @Override + public boolean useModularUI() { + // TODO Auto-generated method stub + return true; + } + @Override + protected boolean onCoverShiftRightClickImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onCoverShiftRightClickImpl(side, aCoverID, aCoverVariable, aTileEntity, aPlayer); + } + @Override + protected boolean onCoverRightClickImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + return super.onCoverRightClickImpl(side, aCoverID, aCoverVariable, aTileEntity, aPlayer, aX, aY, aZ); + } +@Override +public ModularWindow createWindow(GT_CoverUIBuildContext buildContext) { + + return new UIFactory(buildContext){ + private ItemStack tryConvertToFluid(ItemStack is){ + + FluidStack fs = GT_Utility.getFluidForFilledItem(is, true); + if(fs!=null){ + return GT_Utility.getFluidDisplayStack(fs, false); + } + + return null; + } + + protected void addUIWidgets(ModularWindow.Builder builder) { + + + + builder.widget(TextWidget.dynamicString(()->{ + + ICoverable te = getUIBuildContext().getTile(); + if(te instanceof IMachineProgress){ + return "Working: "+((IMachineProgress) te).isAllowedToWork()+""; + + + }return "Machine not valid."; + + + }).setPos(3, 60)); + + + + ItemStackHandler iss=new ItemStackHandler(getCoverData().filter); + builder.widget( new SlotWidget(new BaseSlot(iss, 0,true)){ + @Override + protected void phantomClick(ClickData clickData, ItemStack cursorStack) { + if(cursorStack==null){ + getCoverData().filter[0]=null; + + }else{ + ItemStack fis = getCoverData().mode==0?null:tryConvertToFluid(cursorStack); + + getCoverData().filter[0]=fis==null?cursorStack:fis; + getCoverData().filter[0]=getCoverData().filter[0].copy(); + getCoverData().filter[0].stackSize=1; + } + + } + + + }.setPos(3, 3+20).addTooltip(StatCollector.translateToLocal("proghatches.amountmaintainer.phantomslot"))); + + + builder.widget(new CycleButtonWidget().setGetter(()->getCoverData().invert?1:0) + .setSetter(s->getCoverData().invert=s==1).setLength(2) + .setTextureGetter(s->{ + if(s==0)return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ITEM; + if(s==1)return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_FLUID; + return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ALL; + }) + //.addTooltip(0, StatCollector.translateToLocal("proghatches.amountmaintainer.phantomclick.mode.0")) + //.addTooltip(1, StatCollector.translateToLocal("proghatches.amountmaintainer.phantomclick.mode.1")) + .setBackground(() -> { + { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + }; + } + }) + + .setSize(18, 18) + .setPos(3+20, 3+20)); + builder.widget(new CycleButtonWidget().setGetter(()->getCoverData().mode) + .setSetter(s->getCoverData().mode=s).setLength(2) + .setTextureGetter(s->{ + if(s==0)return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ITEM; + if(s==1)return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_FLUID; + return GT_UITextures.OVERLAY_BUTTON_VOID_EXCESS_ALL; + }) + .addTooltip(0, StatCollector.translateToLocal("proghatches.amountmaintainer.phantomclick.mode.0")) + .addTooltip(1, StatCollector.translateToLocal("proghatches.amountmaintainer.phantomclick.mode.1")) + .setBackground(() -> { + { + return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, + }; + } + }) + + .setSize(18, 18) + .setPos(3+20, 3+40)); + builder.widget( + new NumericWidget().setSetter(val -> getCoverData().amount = (long) val) + .setGetter(() -> getCoverData().amount) + .setBounds(0, 9_007_199_254_740_991D) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(60, 18) + .setPos(60+18, 3+20) + .setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD) + .addTooltips(Arrays.asList( + + + ) + )); + } + + + + + + + }.createWindow(); +} + public static class Data implements ISerializableObject { + public AEFluidStack maybeFluid(){ + if(filter[0]==null)return null; + FluidStack fs = GT_Utility.getFluidFromDisplayStack(filter[0]); + if(fs!=null){ + AEFluidStack is=AEFluidStack.create(fs); + is.setStackSize(Long.MAX_VALUE); + return is; + } + return null; + } + public AEItemStack maybeItem(){ + if(filter[0]==null)return null; + + FluidStack fs = GT_Utility.getFluidFromDisplayStack(filter[0]); + if(fs==null){ + AEItemStack is=AEItemStack.create(filter[0]); + is.setStackSize(Long.MAX_VALUE); + return is; + } + return null; + }protected int mode; + ItemStack filter[]=new ItemStack[1]; + long amount=1; + boolean invert; + public Data(ItemStack filter2, long amount2, boolean invert2) { + this.filter[0]=filter2; + amount=amount2; + invert=invert2; + } + public Data(){} + @Override + public ISerializableObject copy() { + + return new Data(filter[0],amount,invert); + } + + @Override + public NBTBase saveDataToNBT() { + NBTTagCompound tag=new NBTTagCompound(); + if(filter[0]!=null){ + filter[0].writeToNBT(tag); + } + tag.setLong("a", amount); + tag.setInteger("m", mode); + tag.setBoolean("i", invert); + return tag; + } + + @Override + public void writeToByteBuf(ByteBuf aBuf) { + + try { + byte[] b=CompressedStreamTools.compress((NBTTagCompound) saveDataToNBT()); + aBuf.writeInt(b.length); + aBuf.writeBytes(b); + } catch (IOException e) { + aBuf.writeByte(0); + e.printStackTrace(); + } + + + + + } + + @Override + public void loadDataFromNBT(NBTBase aNBT) { + + NBTTagCompound tag=(NBTTagCompound) aNBT; + amount=tag.getLong("a" ); + invert=tag.getBoolean("i" ); + filter[0]=null; + filter[0]=ItemStack.loadItemStackFromNBT(tag); + mode =tag.getInteger("m" ); + + + + } + + @Override + public ISerializableObject readFromPacket(ByteArrayDataInput aBuf, EntityPlayerMP aPlayer) { + Data d=new Data(); + try { + byte b[]=new byte[aBuf.readInt()]; + aBuf.readFully(b); + + d.loadDataFromNBT( + CompressedStreamTools.func_152457_a(b, new NBTSizeTracker(Long.MAX_VALUE))); + + } catch (IOException e) { + e.printStackTrace(); + } + + return d; + } + + + + } + + + + + @Override + public Data createDataObject(int aLegacyData) { + + throw new UnsupportedOperationException(); + } + + @Override + public Data createDataObject() { + + return new Data(); + } + + + @Override + protected int getTickRateImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, ICoverable aTileEntity) { + + return 10; + } + @Override + protected Data doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity, long aTimer) { + + long amount=0; + if(aTileEntity instanceof IGregTechTileEntity/*&&aTileEntity instanceof IActionHost*/){ + IMetaTileEntity mte = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); + AENetworkProxy grid=null; + + if(aTileEntity instanceof IGridProxyable){ + grid=((IGridProxyable) aTileEntity).getProxy(); + } + if(grid==null){ + for(ForgeDirection fd:ForgeDirection.VALID_DIRECTIONS){ + ISerializableObject dat = aTileEntity.getComplexCoverDataAtSide(fd); + if(dat instanceof AECover.Data){ + AECover.Data ae=(reobf.proghatches.eucrafting.AECover.Data) dat; + grid=ae.getProxy(); + if(grid!=null)break; + } + + + } + + } + + + + if(grid!=null) + try { + + IAEFluidStack avf = grid.getStorage().getFluidInventory().getAvailableItem( + aCoverVariable.maybeFluid() + ); + amount=avf==null?0:avf.getStackSize(); + + if(amount==0){ + IAEItemStack av = grid.getStorage().getItemInventory().getAvailableItem( + aCoverVariable.maybeItem() + ); + amount=av==null?0:av.getStackSize(); + } + + + + } catch (GridAccessException e) {} + + + + //new MachineSource((IActionHost) aTileEntity); + + + + + + + + + + + } + + boolean ok= + ( + aCoverVariable.invert? + amount<=aCoverVariable.amount + : + amount>=aCoverVariable.amount + ) + ; + + if(aTileEntity instanceof IMachineProgress){ + ((IMachineProgress) aTileEntity).setAllowedToWork(ok); + + + } + return aCoverVariable; + } + + @Override + protected boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsEnergyOutImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsFluidInImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsFluidOutImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsItemsInImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsItemsOutImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsRedstoneGoInImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity) { + return true; + } + + @Override + protected boolean letsRedstoneGoOutImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, + ICoverable aTileEntity) { + return true; + } + + + +} diff --git a/src/main/java/reobf/proghatches/gt/cover/WirelessControlCover.java b/src/main/java/reobf/proghatches/gt/cover/WirelessControlCover.java index ddf88da..e99158a 100644 --- a/src/main/java/reobf/proghatches/gt/cover/WirelessControlCover.java +++ b/src/main/java/reobf/proghatches/gt/cover/WirelessControlCover.java @@ -73,8 +73,8 @@ public Data doCoverThingsImpl(ForgeDirection side, byte aInputRedstone, int aCov if (d.invert) aInputRedstone = (byte) (15 - aInputRedstone); - if (!makeSureOnlyOne(side, aTileEntity)) - return d; + /*if (!makeSureOnlyOne(side, aTileEntity)) + return d;*/ if (aTileEntity instanceof IMachineProgress) { IMachineProgress machine = (IMachineProgress) aTileEntity; if (d.safe == false && d.crashed == false) { @@ -236,9 +236,9 @@ public Data createDataObject() { return new Data(0, false, null); } - private boolean makeSureOnlyOne(ForgeDirection side, ICoverable aTileEntity) { + /*private boolean makeSureOnlyOne(ForgeDirection side, ICoverable aTileEntity) { return IControlsWorkCover.makeSureOnlyOne(side, aTileEntity); - } + }*/ @Override public boolean letsEnergyInImpl(ForgeDirection side, int aCoverID, Data aCoverVariable, ICoverable aTileEntity) { diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index 3802260..f507f09 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -33,6 +33,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; +import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -54,6 +55,7 @@ import net.minecraftforge.fluids.IFluidTank; import net.minecraftforge.oredict.OreDictionary; +import com.glodblock.github.common.item.ItemFluidPacket; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -88,6 +90,7 @@ import com.gtnewhorizons.modularui.common.widget.SyncedWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; +import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.me.storage.DriveWatcher; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; @@ -110,6 +113,7 @@ import mcp.mobius.waila.api.IWailaDataAccessor; import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched; import reobf.proghatches.gt.metatileentity.util.FirstObjectHolder; +import reobf.proghatches.gt.metatileentity.util.ICraftingV2; import reobf.proghatches.gt.metatileentity.util.IInputStateProvider; import reobf.proghatches.gt.metatileentity.util.IRecipeProcessingAwareDualHatch; import reobf.proghatches.gt.metatileentity.util.ListeningFluidTank; @@ -120,7 +124,10 @@ import reobf.proghatches.main.MyMod; import reobf.proghatches.util.ProghatchesUtil; -public class BufferedDualInputHatch extends DualInputHatch implements IRecipeProcessingAwareDualHatch,IInputStateProvider { +public class BufferedDualInputHatch extends DualInputHatch implements IRecipeProcessingAwareDualHatch,IInputStateProvider +,ICraftingV2 + +{ public Deque scheduled=new LinkedList<>();//no randomaccess, LinkedList will work fine @@ -1937,7 +1944,7 @@ protected ModularWindow createWindowEx(final EntityPlayer player) { .setGTTooltip(() -> mTooltipCache.getData("programmable_hatches.gt.forcecheck")) ); - builder.widget(new CycleButtonWidget().setToggle(() ->!trunOffEnsure , (s) -> { + /*builder.widget(new CycleButtonWidget().setToggle(() ->!trunOffEnsure , (s) -> { trunOffEnsure =! s; }).setStaticTexture(GT_UITextures.OVERLAY_BUTTON_CHECKMARK) @@ -1948,7 +1955,152 @@ protected ModularWindow createWindowEx(final EntityPlayer player) { .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.ensureintmax.2")) .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.ensureintmax.3")) ); + */ + builder.widget(new CycleButtonWidget().setToggle(() ->CMMode , (s) -> { + CMMode = s; + + }).setStaticTexture(GT_UITextures.OVERLAY_BUTTON_CHECKMARK) + .setVariableBackground(GT_UITextures.BUTTON_STANDARD_TOGGLE).setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(3 + 18 * 1, 3 + 18 * 0).setSize(18, 18) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.0")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.1")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.2")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.3")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.4")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.5")) + .addTooltip(StatCollector.translateToLocal("programmable_hatches.gt.cmmode.6")) + ); + + + return builder.build(); } + public boolean isInputEmpty(BufferedDualInputHatch master) { + + for (FluidTank f : master.mStoredFluid) { + if (f.getFluidAmount() > 0) { + return false; + } + } + for (ItemStack i : master.mInventory) { + + if (i != null && i.stackSize > 0) { + return false; + } + } + return true; + } + + public void clearInv(BufferedDualInputHatch master) { + + for (FluidTank f : master.mStoredFluid) { + f.setFluid(null); + } + for (int i = 0; i < master.mInventory.length; i++) { + + if (master.isValidSlot(i)) { + master.mInventory[i] = null; + } + } + + } + boolean CMMode=false; + @Override + public boolean pushPatternCM(ICraftingPatternDetails patternDetails, InventoryCrafting table, + ForgeDirection ejectionDirection) { + BufferedDualInputHatch master = this; + if (this instanceof PatternDualInputHatch) { + PatternDualInputHatch dih = ((PatternDualInputHatch) this); + try{ + dih.skipActiveCheck=true; + return dih.pushPattern(patternDetails, table); + }finally{dih.skipActiveCheck=false;} + } + if (master != null) { + if (!isInputEmpty(master)) { + return false; + } + + int i = 0; + int f = 0; + int ilimit = master.getInventoryStackLimit(); + int flimit = master.getInventoryFluidLimit(); + boolean isplit = master.disableLimited; + boolean fsplit = master.fluidLimit==0; + for (int index = 0; index < table.getSizeInventory(); index++) { + ItemStack is = (table.getStackInSlot(index)); + if (is == null) + continue; + is = is.copy(); + if (is.getItem() instanceof ItemFluidPacket) { + FluidStack fs = ItemFluidPacket.getFluidStack(is); + if (fs == null) { + continue; + } + while (fs.amount > 0) { + if (f >= master.mStoredFluid.length) { + clearInv(master); + return false; + } + int tosplit = Math.min(fs.amount, flimit); + fs.amount -= tosplit; + if ((!fsplit) && fs.amount > 0) { + clearInv(master); + return false; + } + FluidStack splitted = new FluidStack(fs.getFluid(), tosplit); + master.mStoredFluid[f].setFluidDirect(splitted); + f++; + } + + } else { + while (is.stackSize > 0) { + if (master.isValidSlot(i) == false) { + clearInv(master); + return false; + } + ItemStack splitted = is.splitStack(Math.min(is.stackSize, ilimit)); + if ((!isplit) && is.stackSize > 0) { + clearInv(master); + return false; + } + master.mInventory[i] = splitted; + i++; + } + } + + } + if(master instanceof BufferedDualInputHatch){ + ((BufferedDualInputHatch) master).classifyForce(); + } + return true;// hoo ray + } + + return false; + } + @Override + public boolean acceptsPlansCM() { + + return CMMode; + } + @Override + public boolean enableCM() { + + return CMMode; + } + + + /*@Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if(CMMode)return EMPTY_TK; + return super.getTankInfo(from); + } + private FluidTankInfo[] EMPTY_TK=new FluidTankInfo[0]; + private int[] EMPTY_INT=new int[0]; + @Override + public int[] getAccessibleSlotsFromSide(int ordinalSide) { + if(CMMode)return EMPTY_INT; + return super.getAccessibleSlotsFromSide(ordinalSide); + }*/ } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java index d4a6227..2642471 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/DecoyInputBusME.java @@ -424,7 +424,7 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont } boolean reserveFirst; - private BaseActionSource requestSource; + //private BaseActionSource requestSource; @Override public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { @@ -443,14 +443,11 @@ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase co // TODO Auto-generated method stub return super.endRecipeProcessing(controller); } - private BaseActionSource getRequestSource() { - if (requestSource == null) requestSource = new MachineSource((IActionHost) getBaseMetaTileEntity()); - return requestSource; - } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - try { + /*try { System.out.println(overridedExtract( ((IStorageGrid) this.getProxy().getNode().getGrid().getCache(IStorageGrid.class)).getItemInventory(), @@ -460,7 +457,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye } catch (Exception e) { e.printStackTrace(); - } + }*/ return super.onRightclick(aBaseMetaTileEntity, aPlayer); } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java index d0545ab..00ecc12 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatch.java @@ -3,11 +3,15 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.EnumSet; +import java.util.List; import java.util.Optional; import java.util.function.Consumer; +import org.lwjgl.input.Keyboard; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; @@ -69,6 +73,8 @@ import appeng.me.helpers.IGridProxyable; import appeng.tile.misc.TileInterface; import appeng.util.Platform; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures.BlockIcons; @@ -85,6 +91,8 @@ import li.cil.oc.api.network.Node; import li.cil.oc.api.network.SidedEnvironment; import li.cil.oc.api.network.Visibility; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; public class PatternDualInputHatch extends BufferedDualInputHatch @@ -986,14 +994,33 @@ public int pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryCra - + saved+=suc; justHadNewItems = true; return suc; } + long saved; + @SideOnly(Side.CLIENT) + @Override + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)){ + currenttip.add("Saved pushPattern calls since chunk load:"+ + + accessor.getNBTData().getLong("saved")); + } + + } + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + super.getWailaNBTData(player, tile, tag, world, x, y, z); + tag.setLong("saved", saved); + } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java index 75f2969..eefc6b7 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/PatternDualInputHatchInventoryMappingSlave.java @@ -1078,10 +1078,13 @@ public int pushPatternMulti(ICraftingPatternDetails patternDetails, InventoryCra - + if(master instanceof BufferedDualInputHatch){ + ((BufferedDualInputHatch)master).justHadNewItems=true; + } } + return suc; diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputBus.java b/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputBus.java index 1c9ad39..35ac159 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputBus.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputBus.java @@ -7,9 +7,11 @@ import java.util.Optional; import java.util.function.Predicate; +import org.lwjgl.opengl.GL11; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; +import com.google.common.primitives.SignedBytes; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; @@ -26,19 +28,36 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.common.GT_Client; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import reobf.proghatches.gt.metatileentity.VoidOutputHatch.EntityDropParticleFX; +import reobf.proghatches.main.MyMod; import reobf.proghatches.main.registration.Registration; +import reobf.proghatches.net.VoidFXMessage; import reobf.proghatches.util.ProghatchesUtil; public class VoidOutputBus extends GT_MetaTileEntity_Hatch_OutputBus { public VoidOutputBus(String mName, byte mTier, String[] mDescriptionArray, ITexture[][][] mTextures ) { - super(mName, mTier,4, mDescriptionArray, mTextures); + super(mName, mTier,0, mDescriptionArray, mTextures); } ItemStack[] filter=new ItemStack[16]; @@ -91,12 +110,12 @@ public ItemStack getStack() { public boolean isEnabled() { return mChannel != null; }*/ - }).build().setPos(7, 24)); + }).build().setPos(3, 3)); } public VoidOutputBus(int aID, String aName, String aNameRegional, int tier) { - super(aID, aName, aNameRegional, tier, reobf.proghatches.main.Config.get("FOB", - ImmutableMap.of()),4 + super(aID, aName, aNameRegional, tier, reobf.proghatches.main.Config.get("VOB", + ImmutableMap.of()),0 ); @@ -132,7 +151,7 @@ public void loadNBTData(NBTTagCompound compound) { } NBTTagList nbttaglist0 = compound.getTagList("Fluids", 10); - + rebuildFilter(); } @Override @@ -158,9 +177,285 @@ public void saveNBTData(NBTTagCompound compound) { } public boolean dump(ItemStack aStack) { - return filterPredicate.test(aStack); + boolean b= filterPredicate.test(aStack); + if(b)MyMod.net.sendToDimension(new VoidFXMessage( + this.getBaseMetaTileEntity(), aStack + ),this.getBaseMetaTileEntity().getWorld().provider.dimensionId); + return b; + } + @SideOnly(Side.CLIENT) + long remainticks; + @SideOnly(Side.CLIENT) + LinkedList types; + @SideOnly(Side.CLIENT) + public void addVisual(ItemStack f){ + if(types==null)types=new LinkedList<>(); + remainticks=40;//(f.amount); + types.add(f); + if(types.size()>20)types.removeLast(); + } + + @Override@SideOnly(Side.CLIENT) + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(types==null)types=new LinkedList<>(); + /*MyMod.net.sendToDimension(new VoidFXMessage( + this.getBaseMetaTileEntity(), new FluidStack(FluidRegistry.LAVA, 1000) + ),this.getBaseMetaTileEntity().getWorld().provider.dimensionId); + + try{ + MyMod.net.sendToDimension(new VoidFXMessage( + this.getBaseMetaTileEntity(), new FluidStack(FluidRegistry.getFluid("liquid_drillingfluid"), 1000) + ),this.getBaseMetaTileEntity().getWorld().provider.dimensionId); + }catch(Exception e){} + */ + if(remainticks>0&&aBaseMetaTileEntity.getWorld().isRemote){ + //System.out.println("ss"); + remainticks--; + if(remainticks==0){types.clear();return;}; + /*for(long k=1;kk*100){ + remainticks-=k; + }*/ + + ItemStack f=types.get((int) (types.size()*Math.random())); + + ForgeDirection fc = aBaseMetaTileEntity.getFrontFacing(); + EntityDropParticleFX fx=new EntityDropParticleFX(Minecraft.getMinecraft().theWorld, + + aBaseMetaTileEntity.getXCoord()+0.5D+(fc.offsetX)*0.51f, + aBaseMetaTileEntity.getYCoord()+0.5D+(fc.offsetY)*0.51f, + aBaseMetaTileEntity.getZCoord()+0.5D+(fc.offsetZ)*0.51f, + f); + fx.motionX=(fc.offsetX)*0.3+(Math.random()-Math.random())*0.1; + fx.motionY=(fc.offsetY)*0.3+(Math.random()-Math.random())*0.1; + fx.motionZ=(fc.offsetZ)*0.3+(Math.random()-Math.random())*0.1; + + + + Minecraft.getMinecraft().effectRenderer.addEffect((EntityFX)fx); + + + + } + + + + super.onPreTick(aBaseMetaTileEntity, aTick); } + + @SideOnly(Side.CLIENT) + public class EntityDropParticleFX extends EntityFX + {private Render itemRenderer; + + + {itemRenderer = new RenderItem() { + + @Override + public byte getMiniBlockCount(ItemStack stack, byte original) { + return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1); + } + + @Override + public byte getMiniItemCount(ItemStack stack, byte original) { + return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1); + } + + @Override + public boolean shouldBob() { + return false; + } + + @Override + public boolean shouldSpreadItems() { + return false; + } + }; + itemRenderer.setRenderManager(RenderManager.instance);} + /** the material type for dropped items/blocks */ + private Material materialType; + /** The height of the current bob */ + private int bobTimer; + //private static final String __OBFID = "CL_00000901"; + ItemStack is; + public EntityDropParticleFX(World worldIn, double p_i1203_2_, double p_i1203_4_, double p_i1203_6_, ItemStack f) + { + super(worldIn, p_i1203_2_, p_i1203_4_, p_i1203_6_, 0.0D, 0.0D, 0.0D); + this.motionX = this.motionY = this.motionZ = 0.0D; +is=f; + + + + this.particleBlue=0xFF; + this.particleGreen=0xFF; + this.particleRed=0xFF; + + setParticleIcon(f.getItem().getIcon(f, + (int) (f.getItem().getRenderPasses(f.getItemDamage())*Math.random())) + + + ); + + // this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + //this.materialType = p_i1203_8_; + this.bobTimer = 00; + this.particleMaxAge = (int)(64.0D / (Math.random() * 0.8D + 0.2D)); + this.motionX = this.motionY = this.motionZ = 0.0D; + particleMaxAge=100; + } + @Override + public int getFXLayer() { + return 1; + } + public int getBrightnessForRender(float p_70070_1_) + { + return this.materialType == Material.water ? super.getBrightnessForRender(p_70070_1_) : 257; + } + + /** + * Gets how bright this entity is. + */ + public float getBrightness(float p_70013_1_) + { + return this.materialType == Material.water ? super.getBrightness(p_70013_1_) : 1.0F; + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + /* if (this.materialType == Material.water) + { + this.particleRed = 0.2F; + this.particleGreen = 0.3F; + this.particleBlue = 1.0F; + } + else + { + this.particleRed = 1.0F; + this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16); + this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8); + } + */ + this.motionY -= (double)this.particleGravity; + + if (this.bobTimer-- > 0) + { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + //this.setParticleTextureIndex(113); + // this.setParticleTextureIndex(19 + this.rand.nextInt(4)); + } + else + { + // this.setParticleTextureIndex(113); + //this.setParticleTextureIndex(19 + this.rand.nextInt(4)); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + + if (this.onGround) + {this.c=0; + this.a=90; + this.a1=0; + this.c1=0; + this.b1*=0.8; + //this.setDead(); + + /*if (this.materialType == Material.water) + { + + else + { + this.setParticleTextureIndex(114); + } + */ + // + //this.worldObj.spawnParticle("splash", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) + { + double d0 = (double)((float)(MathHelper.floor_double(this.posY) + 1) - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + + if (this.posY < d0) + { + this.setDead(); + } + } + } + double a=Math.random()*360; + double b=Math.random()*360; + double c=Math.random()*360; + double a1=Math.random()*360; + double b1=Math.random()*360; + double c1=Math.random()*360; + + + @Override + public void renderParticle(Tessellator tessellator, float timeStep, float rotationX, float rotationXZ, float rotationZ, + float rotationYZ, float rotationXY) { + tessellator.draw(); + + GL11.glPushMatrix(); + EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer; + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)timeStep); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)timeStep ); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)timeStep ); + float f21 = (float)(p.prevPosX + (p.posX - p.prevPosX) * (double)timeStep); + float f22 = (float)(p.prevPosY + (p.posY - p.prevPosY) * (double)timeStep ); + float f23 = (float)(p.prevPosZ + (p.posZ - p.prevPosZ) * (double)timeStep ); + GL11.glTranslated( + f11-f21 + , f12-f22 + , f13-f23 + + + + ); + + GL11.glRotated(a, 1, 0, 0); + GL11.glRotated(b, 0, 1, 0); + GL11.glRotated(c, 0, 0, 1); + a+=(a1-b1)/100; + b+=(b1-c1)/100; + c+=(c1-a1)/100; + + EntityItem customitem = new EntityItem(Minecraft.getMinecraft().theWorld); + customitem.hoverStart = 0f; + customitem.setEntityItemStack(is); + itemRenderer.doRender(customitem, 0, 0, 0, 0, 0); + + GL11.glPopMatrix(); + + tessellator.startDrawingQuads(); + } + + + } + + } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputHatch.java index 46236ee..0b35a4c 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/VoidOutputHatch.java @@ -97,7 +97,7 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { final int i=ii; builder.widget(FluidSlotWidget.phantom(new MappingFluidTank(s->{filter[i]=s==null?null:s.copy();rebuildFilter();}, ()->filter[i]), false - ).setPos(3+(i%9)*4, 3+(i/9)*4)); + ).setPos(3+(i%4)*16, 3+(i/4)*16)); ;} @@ -119,10 +119,10 @@ public ItemStack getStack() { public VoidOutputHatch(int aID, String aName, String aNameRegional, int tier) { super(aID, aName, aNameRegional, tier, - new String[0] - /*reobf.proghatches.main.Config.get("FOB", + + reobf.proghatches.main.Config.get("VOH", ImmutableMap.of()) - */ + ,0 @@ -246,7 +246,7 @@ public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(remainticks>0&&aBaseMetaTileEntity.getWorld().isRemote){ //System.out.println("ss"); remainticks--; - if(remainticks==0)types.clear(); + if(remainticks==0){types.clear();return;} /*for(long k=1;kk*100){ remainticks-=k; @@ -408,7 +408,79 @@ public void onUpdate() this.setDead(); } } - }} + } + + @Override + public void renderParticle(Tessellator tess, float timeStep, float rotationX, float rotationXZ, float rotationZ, + float rotationYZ, float rotationXY) { + double x = (this.prevPosX + (this.posX - this.prevPosX) * timeStep - interpPosX); + double y = (this.prevPosY + (this.posY - this.prevPosY) * timeStep - interpPosY); + double z = (this.prevPosZ + (this.posZ - this.prevPosZ) * timeStep - interpPosZ); + + float minU = this.particleTextureIndexX / 16.0F; + float maxU = minU + 0.0624375F; + float minV = this.particleTextureIndexY / 16.0F; + float maxV = minV + 0.0624375F; + float scale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + tess.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + + for (int i = 0; i < 5; i++) { + renderParticle( + tess, + x, + y, + z, + rotationX, + rotationXZ, + rotationZ, + rotationYZ, + rotationXY, + minU, + maxU, + minV, + maxV, + scale); + } + } + + private void renderParticle(Tessellator tess, double x, double y, double z, float rotationX, + float rotationXZ, float rotationZ, float rotationYZ, float rotationXY, float minU, float maxU, float minV, + float maxV, float scale) { + tess.addVertexWithUV( + (x - rotationX * scale - rotationYZ * scale), + (y - rotationXZ * scale), + (z - rotationZ * scale - rotationXY * scale), + maxU, + maxV); + tess.addVertexWithUV( + (x - rotationX * scale + rotationYZ * scale), + (y + rotationXZ * scale), + (z - rotationZ * scale + rotationXY * scale), + maxU, + minV); + tess.addVertexWithUV( + (x + rotationX * scale + rotationYZ * scale), + (y + rotationXZ * scale), + (z + rotationZ * scale + rotationXY * scale), + minU, + minV); + tess.addVertexWithUV( + (x + rotationX * scale - rotationYZ * scale), + (y - rotationXZ * scale), + (z + rotationZ * scale - rotationXY * scale), + minU, + maxV); + } + +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/ICraftingV2.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/ICraftingV2.java new file mode 100644 index 0000000..879ba97 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/ICraftingV2.java @@ -0,0 +1,14 @@ +package reobf.proghatches.gt.metatileentity.util; + +import appeng.api.networking.crafting.ICraftingPatternDetails; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraftforge.common.util.ForgeDirection; + +public interface ICraftingV2 { + + boolean pushPatternCM(ICraftingPatternDetails patternDetails, InventoryCrafting table, + ForgeDirection ejectionDirection); + + boolean acceptsPlansCM(); + boolean enableCM(); +} diff --git a/src/main/java/reobf/proghatches/item/ItemDedicatedCover.java b/src/main/java/reobf/proghatches/item/ItemDedicatedCover.java index d6b7590..9cb87bc 100644 --- a/src/main/java/reobf/proghatches/item/ItemDedicatedCover.java +++ b/src/main/java/reobf/proghatches/item/ItemDedicatedCover.java @@ -22,7 +22,7 @@ public class ItemDedicatedCover extends Item { - public static IIcon[] icons = new IIcon[64]; + public static IIcon[] icons = new IIcon[200]; public ItemDedicatedCover() { this.setCreativeTab(CommonProxy.tab); @@ -68,7 +68,7 @@ public void registerIcons(IIconRegister register) { icons[mark(35)] = register.registerIcon("proghatches:cover35"); icons[mark(36)] = register.registerIcon("proghatches:cover36"); icons[mark(37)] = register.registerIcon("proghatches:cover37"); - + icons[mark(100)] = register.registerIcon("proghatches:cover37"); } @SuppressWarnings({ "unchecked", "rawtypes" }) diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index 3bbaba2..6fefcd0 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -205,6 +205,7 @@ public List getMixins() { retLate.add("part2.MixinMEBusOverride"); retLate.add("part2.MixinCraftingCondender"); retLate.add("part2.MixinVoidingHatch"); + retLate.add("part2.MixinCraftingV2"); if (FMLLaunchHandler.side().isClient()) { if (!"true".equals(pp.get("noAEItemSortMixins"))) if(ff)retLate.add("MixinAEItemStackCompare"); diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinCraftingV2.java b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinCraftingV2.java new file mode 100644 index 0000000..f6115e5 --- /dev/null +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinCraftingV2.java @@ -0,0 +1,51 @@ +package reobf.proghatches.main.mixin.mixins.part2; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +import appeng.api.implementations.tiles.ICraftingMachine; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.CommonMetaTileEntity; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraftforge.common.util.ForgeDirection; +import reobf.proghatches.gt.metatileentity.util.ICraftingV2; + +@Mixin(value=BaseMetaTileEntity.class,remap=false) +public abstract class MixinCraftingV2 extends CommonMetaTileEntity implements ICraftingMachine{ + + @Override + public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, + ForgeDirection ejectionDirection) { + if(notV2)return false; + IMetaTileEntity mte; + if((mte=getMetaTileEntity()) instanceof ICraftingV2){ + if(((ICraftingV2) mte).enableCM()==false){return false;} + return ((ICraftingV2) mte).pushPatternCM(patternDetails,table,ejectionDirection); + }/*else{ + if(mte!=null){ + + } + }*/ + + return false; + } + @Unique boolean notV2; + @Override + public boolean acceptsPlans() { + if(notV2)return false; + IMetaTileEntity mte; + if((mte=getMetaTileEntity()) instanceof ICraftingV2){ + if(((ICraftingV2) mte).enableCM()==false){return false;} + return ((ICraftingV2) mte).acceptsPlansCM(); + }else{ + if(mte!=null){ + notV2=true; + } + } + + return false; + } + +} diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMultiPattern.java b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMultiPattern.java index 47aae93..684e2a2 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMultiPattern.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/part2/MixinMultiPattern.java @@ -163,17 +163,21 @@ public void b(IEnergyGrid eg, CraftingGridCache cc, CallbackInfo ci) { } long num = MixinCallback.getter.apply(e.getValue()); - + final long max = getMaxSkips(); int maxtry = Math.min(Math.min( - (int) (num > (Integer.MAX_VALUE - 1) ? (Integer.MAX_VALUE - 1) : num) - 1, remainingOperations), + (int) (num > (Integer.MAX_VALUE - 1) ? (Integer.MAX_VALUE - 1) : num) - 1, (int)(remainingOperations+max)), best); if (maxtry <= 0) { return; } + used = ((IMultiplePatternPushable) medium).pushPatternMulti(detail, inv, maxtry); - + + + if(max!=Integer.MAX_VALUE) + remainingOperations-=Math.max(used-max,0); MixinCallback.setter.accept(e.getValue(), num - used); if (used > 0) { @@ -199,7 +203,7 @@ public void b(IEnergyGrid eg, CraftingGridCache cc, CallbackInfo ci) { if(getMaxSkips()<=0)return; //int now = temp1.getOrDefault(detail, 0); final long max = getMaxSkips(); - for (int i = 0; i < max; i=(i { @Override public VoidFXMessage onMessage(VoidFXMessage message, MessageContext ctx) { - + if(message.id!=-1) try{ ((VoidOutputHatch) ((IGregTechTileEntity)Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) ).getMetaTileEntity()).addVisual( - - new FluidStack(FluidRegistry.getFluid(message.id), message.amount) - - - ); ; }catch(Exception e){e.printStackTrace();} + else + try{ + ((VoidOutputBus) + ((IGregTechTileEntity)Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z) + ).getMetaTileEntity()).addVisual( + message.is + ); + + ; + }catch(Exception e){e.printStackTrace();} + + + + + return null; } } @@ -55,9 +78,20 @@ public void fromBytes(ByteBuf buf) { x=buf.readInt(); y=buf.readInt(); z=buf.readInt(); - id=buf.readInt(); - amount=buf.readInt(); + id=buf.readInt(); + amount=buf.readInt(); + int len=buf.readInt(); + byte[] b=new byte[len]; + buf.readBytes(b); + if(id==-1) + try {is=ItemStack.loadItemStackFromNBT( + CompressedStreamTools.func_152457_a(b, new NBTSizeTracker(Long.MAX_VALUE))); + } catch (IOException e) { + e.printStackTrace(); + } + + } @Override public void toBytes(ByteBuf buf) { @@ -67,5 +101,17 @@ public void toBytes(ByteBuf buf) { buf.writeInt(z); buf.writeInt(id); buf.writeInt(amount); + if(is!=null) + try { + byte[] b=CompressedStreamTools.compress( + is.writeToNBT(new NBTTagCompound())); + buf.writeInt(b.length); + buf.writeBytes(b); + } catch (Exception e) { + buf.writeInt(0); + e.printStackTrace(); + }else buf.writeInt(0); + + } } diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 2f377d5..ff4a9c8 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -637,3 +637,19 @@ tile.proghatches.craftingdumper.5.name=1024x Speed Crafting Dumper tile.proghatches.craftingdumper.6.name=4096x Speed Crafting Dumper tile.proghatches.craftingdumper.7.name=16384x Speed Crafting Dumper tile.proghatches.craftingdumper.8.name=Superluminal Crafting Dumper +ph.hatch.void.name=Void Output Hatch +ph.bus.void.name=Void Output Bus +item.proghatch.cover.dedicated.tooltips.100=4 +item.proghatch.cover.dedicated.tooltips.100.0=Control the machine depends on the level of ME Storage. +item.proghatch.cover.dedicated.tooltips.100.1=If machine itself connects to ME network, check the network it connects. +item.proghatch.cover.dedicated.tooltips.100.2=Or else try to find ME Cover and check its network. +item.proghatch.cover.dedicated.tooltips.100.3=Does not require channels, neither does it carry one. +item.proghatch.cover.dedicated.100=Level Control Cover +programmable_hatches.gt.cmmode.0=MA Mode +programmable_hatches.gt.cmmode.1=Molcular Assembler Mode, directly accepts materials from patterns, pypassing the inventory interaction. +programmable_hatches.gt.cmmode.2=Just like MA, you don't need to turn Blocking Mode on. +programmable_hatches.gt.cmmode.3=Do not use Dual Interface, even if your pattern contains fluid. +programmable_hatches.gt.cmmode.4=Does not accept items from cache of Interface(just like Molcular Assembler). +programmable_hatches.gt.cmmode.5=So do not place unexpected TEs around, or Interface will be tricked into pushing materials into cache! +programmable_hatches.gt.cmmode.6=This happens even it TE has no inventory in some version, or just use Interface in panel form. + diff --git a/src/main/resources/assets/proghatches/lang/en_US/VOB.lang b/src/main/resources/assets/proghatches/lang/en_US/VOB.lang new file mode 100644 index 0000000..1611869 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/en_US/VOB.lang @@ -0,0 +1,4 @@ +Specify up to 16 types of item to void. +Have highest priority than any other output buses. +Only voids item, has no inventory. +Thus do not affect void protection. \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/en_US/VOH.lang b/src/main/resources/assets/proghatches/lang/en_US/VOH.lang new file mode 100644 index 0000000..97cd9ef --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/en_US/VOH.lang @@ -0,0 +1,4 @@ +Specify up to 16 types of fluid to void. +Have highest priority than any other output hatches. +Only voids fluid, has 0 tank capacity. +Thus do not affect void protection. \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 95b99b6..61ec42d 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -635,3 +635,18 @@ tile.proghatches.craftingdumper.5.name=1024倍速合成转储器 tile.proghatches.craftingdumper.6.name=4096倍速合成转储器 tile.proghatches.craftingdumper.7.name=16384倍速合成转储器 tile.proghatches.craftingdumper.8.name=超光速合成转储器 +ph.hatch.void.name=销毁输出仓 +ph.bus.void.name=销毁输出总线 +item.proghatch.cover.dedicated.tooltips.100=4 +item.proghatch.cover.dedicated.tooltips.100.0=基于ME存储数量开关机器 +item.proghatch.cover.dedicated.tooltips.100.1=如果机器自身连入ME网络,检测所连的网络 +item.proghatch.cover.dedicated.tooltips.100.2=否则试图检测ME覆盖版(若有)的网络 +item.proghatch.cover.dedicated.tooltips.100.3=不消耗频道 也不传递频道 +item.proghatch.cover.dedicated.100=发信控制覆盖版 +programmable_hatches.gt.cmmode.0=MA模式 +programmable_hatches.gt.cmmode.1=分子装配室(Molcular Assembler)模式,直接从ME接口的样板提取材料,跳过物流交互 +programmable_hatches.gt.cmmode.2=就像分子装配室一样,不用打开阻挡模式(开了也没区别) +programmable_hatches.gt.cmmode.3=不要用二合一接口,即使样板含有流体 +programmable_hatches.gt.cmmode.4=就像分子装配室一样,无法从接口的缓存中接受物品 +programmable_hatches.gt.cmmode.5=所以不要在周围放TE方块,否则接口会试图向它输送物品,失败后放入缓存卡死合成! +programmable_hatches.gt.cmmode.6=某些版本中即使TE没有物品栏也被认为是容器!或者使用面板形式的接口避免这个问题 diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/VOB.lang b/src/main/resources/assets/proghatches/lang/zh_CN/VOB.lang new file mode 100644 index 0000000..bb83ce1 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/zh_CN/VOB.lang @@ -0,0 +1,4 @@ +指定16种物品以销毁 +拥有高于其它总线的优先级 +只从输出中移除物品,没有真正的输出空间 +因此不影响溢出保护判断 \ No newline at end of file diff --git a/src/main/resources/assets/proghatches/lang/zh_CN/VOH.lang b/src/main/resources/assets/proghatches/lang/zh_CN/VOH.lang new file mode 100644 index 0000000..65bf397 --- /dev/null +++ b/src/main/resources/assets/proghatches/lang/zh_CN/VOH.lang @@ -0,0 +1,4 @@ +指定16种流体以销毁 +拥有高于其它仓的优先级 +只从输出中移除流体,没有真正的输出空间 +因此不影响溢出保护判断 \ No newline at end of file