-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
444 additions
and
19 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/reobf/proghatches/ae/BlockMolecularAssemblerInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package reobf.proghatches.ae; | ||
|
||
import appeng.tile.networking.TileController; | ||
import net.minecraft.block.BlockContainer; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.world.World; | ||
|
||
public class BlockMolecularAssemblerInterface extends BlockContainer{ | ||
|
||
public BlockMolecularAssemblerInterface( ) { | ||
super(Material.rock); | ||
setHardness(1); | ||
setHarvestLevel("pickaxe", 1); | ||
setBlockName("proghatch.ma_iface"); | ||
setBlockTextureName("proghatches:me_iface"); | ||
} | ||
|
||
@Override | ||
public TileMolecularAssemblerInterface createNewTileEntity(World worldIn, int meta) { | ||
|
||
return new TileMolecularAssemblerInterface(); | ||
} | ||
|
||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/reobf/proghatches/ae/BlockStockingCircuitRequestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package reobf.proghatches.ae; | ||
|
||
import net.minecraft.block.BlockContainer; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.world.World; | ||
|
||
public class BlockStockingCircuitRequestInterceptor extends BlockContainer{ | ||
|
||
public BlockStockingCircuitRequestInterceptor() { | ||
|
||
super(Material.rock); | ||
setHardness(1); | ||
setHarvestLevel("pickaxe", 1); | ||
setBlockName("proghatches.circuit_interceptor"); | ||
setBlockTextureName("proghatches:circuit_interceptor"); | ||
} | ||
|
||
@Override | ||
public TileEntity createNewTileEntity(World worldIn, int meta) { | ||
|
||
return new TileStockingCircuitRequestInterceptor(); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/reobf/proghatches/ae/IIsExtractFromInvAllowed.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package reobf.proghatches.ae; | ||
|
||
public interface IIsExtractFromInvAllowed { | ||
public boolean isAllowed(); | ||
} |
193 changes: 193 additions & 0 deletions
193
src/main/java/reobf/proghatches/ae/TileMolecularAssemblerInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
package reobf.proghatches.ae; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.stream.IntStream; | ||
|
||
import com.glodblock.github.common.item.ItemFluidPacket; | ||
|
||
import appeng.api.implementations.tiles.ICraftingMachine; | ||
import appeng.api.networking.crafting.ICraftingPatternDetails; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.inventory.ISidedInventory; | ||
import net.minecraft.inventory.InventoryCrafting; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.IFluidHandler; | ||
import reobf.proghatches.fmp.LayerCraftingMachine.StateHolder; | ||
|
||
public class TileMolecularAssemblerInterface extends TileEntity implements ICraftingMachine { | ||
|
||
@Override | ||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, | ||
ForgeDirection ejectionDirection) { | ||
|
||
TileEntity te = getTarget(ejectionDirection.getOpposite()); | ||
if(te ==null)return false; | ||
ArrayList<ItemStack> item = new ArrayList<>(table.getSizeInventory()); | ||
ArrayList<FluidStack> fluid = new ArrayList<>(1); | ||
|
||
for (int i = 0; i < table.getSizeInventory(); i++) { | ||
|
||
ItemStack is = table.getStackInSlot(i); | ||
if (is == null) { | ||
continue; | ||
} | ||
|
||
if (is.getItem() instanceof ItemFluidPacket) { | ||
FluidStack fs = ItemFluidPacket.getFluidStack(is); | ||
if (fs == null) { | ||
continue; | ||
} | ||
fluid.add(fs); | ||
} else { | ||
|
||
item.add(is); | ||
} | ||
|
||
} | ||
|
||
if(itemCheck(te, item, false)>=0)return false; | ||
if(fluidCheck(te, fluid, false)>=0)return false; | ||
|
||
itemCheck(te, item,true); | ||
fluidCheck(te, fluid,true); | ||
|
||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public boolean acceptsPlans() { | ||
/*ForgeDirection dir = StateHolder.state; | ||
TileEntity targ = getTarget(); | ||
if(targ==null)return false; | ||
*/ | ||
|
||
|
||
|
||
return true; | ||
} | ||
|
||
private TileEntity getTarget() { | ||
|
||
final TileEntity te = this.getWorldObj().getTileEntity(this.xCoord + this.getSide().offsetX, | ||
this.yCoord + this.getSide().offsetY, this.zCoord + this.getSide().offsetZ); | ||
|
||
return te; | ||
} | ||
private TileEntity getTarget(ForgeDirection d) { | ||
|
||
final TileEntity te = this.getWorldObj().getTileEntity(this.xCoord + d.offsetX, | ||
this.yCoord + d.offsetY, this.zCoord + d.offsetZ); | ||
|
||
return te; | ||
} | ||
interface ISideCheck { | ||
int[] getAccessibleSlotsFromSide(int p_94128_1_); | ||
|
||
boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_); | ||
|
||
public static ISideCheck ofInv(IInventory te) { | ||
|
||
if (te instanceof ISidedInventory) { | ||
ISidedInventory side = (ISidedInventory) te; | ||
return new ISideCheck() { | ||
|
||
@Override | ||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) { | ||
return side.getAccessibleSlotsFromSide(p_94128_1_); | ||
} | ||
|
||
@Override | ||
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { | ||
|
||
return side.canInsertItem(p_102007_1_, p_102007_2_, p_102007_3_); | ||
} | ||
}; | ||
} | ||
|
||
return new ISideCheck() { | ||
|
||
@Override | ||
public int[] getAccessibleSlotsFromSide(int p_94128_1_) { | ||
return IntStream.range(0, te.getSizeInventory()).toArray(); | ||
} | ||
|
||
@Override | ||
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { | ||
return true; | ||
} | ||
}; | ||
} | ||
} | ||
|
||
//-1 pass | ||
//>=0 first index in inputs that won't fit | ||
public int itemCheck( TileEntity t, ArrayList<ItemStack> item,boolean doInject) { | ||
if(t instanceof IInventory==false){return Integer.MAX_VALUE;} | ||
IInventory te=(IInventory) t; | ||
|
||
ForgeDirection dir=getSide(); | ||
ISideCheck checker=ISideCheck.ofInv(te); | ||
int cnt=0; | ||
next:for(int i=0;i<item.size();i++){ | ||
int[] slots=checker.getAccessibleSlotsFromSide(i); | ||
Arrays.sort(slots); | ||
while(true){ | ||
|
||
if(checker.canInsertItem(slots[cnt], item.get(i), dir.ordinal()) | ||
&& | ||
te.isItemValidForSlot(slots[cnt], item.get(i)) | ||
&& | ||
te.getInventoryStackLimit()>=item.get(i).stackSize | ||
&&item.get(i).stackSize<=item.get(i).getMaxStackSize() | ||
){ | ||
if(doInject){ | ||
te.setInventorySlotContents(slots[cnt], item.get(i)); | ||
} | ||
|
||
continue next; | ||
}; | ||
cnt++; | ||
if(slots.length<=cnt)return i; | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
return -1; | ||
} | ||
|
||
public int fluidCheck( TileEntity t, ArrayList<FluidStack> fluid,boolean doInject) { | ||
if(t instanceof IFluidHandler==false){return Integer.MAX_VALUE;} | ||
IFluidHandler f=(IFluidHandler) t; | ||
//SPECIAL CHECKS HERE | ||
if(fluid.size()>1){return 0;} | ||
for(int i=0;i<fluid.size();i++){ | ||
if(f.fill(getSide(), fluid.get(i), false)==fluid.get(i).amount)return i; | ||
if(doInject)f.fill(getSide(), fluid.get(i), true);//TODO:check ret val? | ||
|
||
} | ||
|
||
|
||
return -1; | ||
} | ||
|
||
int mode =0; | ||
ForgeDirection side=ForgeDirection.DOWN; | ||
|
||
private ForgeDirection getSide() { | ||
|
||
|
||
return side; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/reobf/proghatches/ae/TileStockingCircuitRequestInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package reobf.proghatches.ae; | ||
|
||
import appeng.api.networking.GridFlags; | ||
import appeng.tile.grid.AENetworkTile; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class TileStockingCircuitRequestInterceptor extends AENetworkTile { | ||
|
||
public TileStockingCircuitRequestInterceptor() { | ||
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/reobf/proghatches/ae/render/TESRMAInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package reobf.proghatches.ae.render; | ||
|
||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class TESRMAInterface extends TileEntitySpecialRenderer{ | ||
|
||
@Override | ||
public void renderTileEntityAt( | ||
TileEntity tile, double x, double y, double z, float timeSinceLastTick) { | ||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.