Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Nov 19, 2024
1 parent ba7616b commit ba54ca9
Show file tree
Hide file tree
Showing 25 changed files with 444 additions and 19 deletions.
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();
}


}
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();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package reobf.proghatches.ae;

public interface IIsExtractFromInvAllowed {
public boolean isAllowed();
}
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;
}

}
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 src/main/java/reobf/proghatches/ae/render/TESRMAInterface.java
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) {


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Client;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
Expand All @@ -38,11 +39,13 @@
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
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.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
Expand Down Expand Up @@ -152,6 +155,8 @@ public void loadNBTData(NBTTagCompound compound) {

NBTTagList nbttaglist0 = compound.getTagList("Fluids", 10);
rebuildFilter();
if(compound.hasKey("fx"))
fx=compound.getBoolean("fx");
}

@Override
Expand All @@ -173,12 +178,12 @@ public void saveNBTData(NBTTagCompound compound) {
compound.setTag("Items", nbttaglist);
nbttaglist = new NBTTagList();


compound.setBoolean("fx", fx);
}

public boolean dump(ItemStack aStack) {
boolean b= filterPredicate.test(aStack);
if(b)MyMod.net.sendToDimension(new VoidFXMessage(
if(b&&fx)MyMod.net.sendToDimension(new VoidFXMessage(
this.getBaseMetaTileEntity(), aStack
),this.getBaseMetaTileEntity().getWorld().provider.dimensionId);
return b;
Expand Down Expand Up @@ -455,7 +460,20 @@ public void renderParticle(Tessellator tessellator, float timeStep, float rotati


}

boolean fx=true;
@Override
public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ,
ItemStack aTool) {

if (!getBaseMetaTileEntity().getCoverInfoAtSide(side)
.isGUIClickable()) return;
fx=!fx;
GT_Utility.sendChatToPlayer(
aPlayer,
StatCollector.translateToLocal("proghatches.gt.void.fx."+fx)
);

}

}

Loading

0 comments on commit ba54ca9

Please sign in to comment.