Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Dec 29, 2024
1 parent 029409c commit 589dd49
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import reobf.proghatches.block.INameAndTooltips;
Expand All @@ -20,12 +24,45 @@ public BlockStockingCircuitRequestInterceptor() {
setBlockName("proghatches.circuit_interceptor");
setBlockTextureName("proghatches:circuit_interceptor");
}
@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX,
float subY, float subZ) {
if(worldIn.getBlockMetadata(x,y,z)==1){
if(!worldIn.isRemote){
TileStockingCircuitRequestInterceptor te=(TileStockingCircuitRequestInterceptor) worldIn.getTileEntity(x, y, z);
te.mark[0]=player.getCurrentEquippedItem();
if(te.mark[0]!=null)te.mark[0]=te.mark[0].copy();
}else{
if(player.getCurrentEquippedItem()==null)
player.addChatMessage(new ChatComponentTranslation("tile.proghatches.circuit_interceptor.change",
player.getCurrentEquippedItem().getDisplayName()
));
else{
player.addChatMessage(new ChatComponentTranslation("tile.proghatches.circuit_interceptor.change",
"None"
));


}

}


}

return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ);
}
@Override
public int damageDropped(int meta) {

return (meta);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {

return new TileStockingCircuitRequestInterceptor();
return new TileStockingCircuitRequestInterceptor(meta);
}


@Override
public void addInformation(ItemStack p_77624_1_, List l) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package reobf.proghatches.ae;

import appeng.api.storage.data.IAEStack;

public interface IIsExtractFromInvAllowed {
public boolean isAllowed();
public boolean isAllowed(IAEStack stack);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
package reobf.proghatches.ae;

import appeng.api.networking.GridFlags;
import appeng.api.storage.data.IAEStack;
import appeng.tile.grid.AENetworkTile;
import appeng.util.item.AEItemStack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import reobf.proghatches.main.MyMod;

public class TileStockingCircuitRequestInterceptor extends AENetworkTile {

public TileStockingCircuitRequestInterceptor() {
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
}

public TileStockingCircuitRequestInterceptor(int type) {
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.type=type;
}
int type;
public boolean isAllowed(IAEStack stack) {
if(stack==null)return true;
if(type==0)
return !(stack.isItem()&&
((AEItemStack)stack).getItem()==MyMod.progcircuit);


if(type==1&&mark[0]!=null){
return !stack.equals(mark[0]);
}


return true;
}

ItemStack[] mark=new ItemStack[1];






@Override
public void writeToNBT_AENetwork(NBTTagCompound data) {
data.setInteger("Interceptor_type", type);
super.writeToNBT_AENetwork(data);
}
@Override
public void readFromNBT_AENetwork(NBTTagCompound data) {
type=data.getInteger("Interceptor_type" );
super.readFromNBT_AENetwork(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ public void removePhantom() {
for (int i = 0; i < size; i++) {

if(a.getStackInSlot(i)!=null
&&a.getStackInSlot(i).stackSize>0
&&i!=index
)//
a.decrStackSize(i, 0);// remove 0-sized phantom item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ public UnlimitedWrapper() {

@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src) {
post();
try{
long l=input.getStackSize();
long compl=0;
Expand Down Expand Up @@ -413,7 +414,7 @@ public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionS


return null;}finally{

last=AEItemStack.create(mInventory[0]);
if(voidOverflow&&(mInventory[0]!=null&&
ItemStack.areItemStackTagsEqual(mInventory[0],input.getItemStack())&&
mInventory[0].getItem()==input.getItem()&&
Expand All @@ -425,7 +426,7 @@ public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionS

@Override
public IAEItemStack extractItems(IAEItemStack input, Actionable type, BaseActionSource src) {

try{post();
ItemStack in=input.getItemStack();
ItemStack thiz=mInventory[0];
if(thiz!=null&&!Platform.isSameItem(in, thiz))return null;
Expand All @@ -446,7 +447,10 @@ public IAEItemStack extractItems(IAEItemStack input, Actionable type, BaseAction
}


return null;
return null;}finally{

last=AEItemStack.create(mInventory[0]);
}
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
Expand Down Expand Up @@ -543,6 +547,8 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {

boolean active=this.getProxy().isActive();
if(!aBaseMetaTileEntity.getWorld().isRemote){
if(aTick%40==1){post();}

if(rep>0){rep--;update=true;}
if(this.getBaseMetaTileEntity().hasInventoryBeenModified()){
update=true;
Expand Down Expand Up @@ -917,13 +923,31 @@ public void setItemNBT(NBTTagCompound aNBT) {
tTag.setInteger("Count", tStack.stackSize);
tItemList.appendTag(tTag);
}
}
aNBT.setTag("Inventory", tItemList);
} aNBT.setTag("Inventory", tItemList);

aNBT.setInteger("piority", piority);
aNBT.setBoolean("sticky", sticky);
aNBT.setBoolean("autoUnlock",autoUnlock);
aNBT.setBoolean("suppressSticky",suppressSticky);
if(cachedFilter[0]!=null){
NBTTagCompound tag=new NBTTagCompound();
cachedFilter[0].writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}
aNBT.setBoolean("voidFull", voidFull);
aNBT.setBoolean("voidOverflow", voidOverflow);
if(capOverride!=0)aNBT.setInteger("capOverride", capOverride);
/* if(cachedFilter[0]!=null){
NBTTagCompound tag=new NBTTagCompound();
cachedFilter[0].writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}
if(piority!=0)aNBT.setInteger("piority", piority);
if(sticky)aNBT.setBoolean("sticky", sticky);
if(voidFull)aNBT.setBoolean("voidFull", voidFull);
if(voidOverflow)aNBT.setBoolean("voidOverflow", voidOverflow);
if(capOverride!=0)aNBT.setInteger("capOverride", capOverride);
if(capOverride!=0)aNBT.setInteger("capOverride", capOverride);*/
}
@Override
public boolean shouldDropItemAt(int index) {
Expand Down
36 changes: 33 additions & 3 deletions src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,22 +384,33 @@ public UnlimitedWrapper() {

@Override
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
post();
try{
int acc=content.fill(input.getFluidStack(), type==Actionable.MODULATE);
IAEFluidStack ret = input.copy();
ret.decStackSize(acc);
if(voidOverflow&&(content.getFluidAmount()>0&&content.getFluid().getFluid()==input.getFluid())
){return null;}
if(ret.getStackSize()==0)return null;
return ret;
}finally{
last=AEFluidStack.create(content.getFluid());
}

}

@Override
public IAEFluidStack extractItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
if(content.getFluid()!=null&&content.getFluid().getFluid()!=input.getFluid()
post();
try{
if(content.getFluid()!=null&&content.getFluid().getFluid()!=input.getFluid()
){return null;}
FluidStack suck= content.drain((int) Math.min(Integer.MAX_VALUE,input.getStackSize()), type==Actionable.MODULATE);
if(suck!=null&&suck.amount==0)return null;
return AEFluidStack.create(suck);
}finally{
last=AEFluidStack.create(content.getFluid());
}
}

@Override
Expand Down Expand Up @@ -577,7 +588,10 @@ int cap(){
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {

if(!aBaseMetaTileEntity.getWorld().isRemote)
{ if(rep>0){rep--;update=true;}
{
if(aTick%40==1){post();}

if(rep>0){rep--;update=true;}
if(this.getBaseMetaTileEntity().hasInventoryBeenModified()){
update=true;
rep=1;
Expand Down Expand Up @@ -973,11 +987,27 @@ public void saveNBTData(NBTTagCompound aNBT) {
@Override
public void setItemNBT(NBTTagCompound aNBT) {
content.writeToNBT(aNBT);
if(piority!=0)aNBT.setInteger("piority", piority);
/* if(piority!=0)aNBT.setInteger("piority", piority);
if(sticky)aNBT.setBoolean("sticky", sticky);
if(voidFull)aNBT.setBoolean("voidFull", voidFull);
if(voidOverflow)aNBT.setBoolean("voidOverflow", voidOverflow);
if(capOverride!=0)aNBT.setInteger("capOverride", capOverride);
if(autoUnlock)aNBT.setBoolean("autoUnlock",autoUnlock);
if(suppressSticky)aNBT.setBoolean("suppressSticky",suppressSticky);*/
aNBT.setInteger("piority", piority);
aNBT.setBoolean("sticky", sticky);
aNBT.setBoolean("autoUnlock",autoUnlock);
aNBT.setBoolean("suppressSticky",suppressSticky);
if(cachedFilter!=null){
NBTTagCompound tag=new NBTTagCompound();
cachedFilter.writeToNBT(tag);
aNBT.setTag("cahcedFilter", tag);
}

aNBT.setBoolean("voidFull", voidFull);
aNBT.setBoolean("voidOverflow", voidOverflow);

if(capOverride!=0)aNBT.setInteger("capOverride", capOverride);
}
@Override
public boolean shouldDropItemAt(int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.me.GridAccessException;
import appeng.util.item.AEFluidStack;
Expand Down Expand Up @@ -995,6 +997,15 @@ private boolean isAllMEOutputEmpty(){
} catch (Exception e) {
e.printStackTrace();
}}

private static <T extends IAEStack<?>> T verifyForRealExistance(T tocheck,IMEMonitor<T> tocheckfrom){

if(tocheck==null)return tocheck;

return tocheckfrom.extractItems(tocheck, Actionable.SIMULATE, fakeSource);

}

@SuppressWarnings({ "unchecked", "unused" })
private TransferCheckResult checkMEBus(MTEHatchOutputBusME bus,ItemStack check,int index){

Expand All @@ -1009,10 +1020,11 @@ private TransferCheckResult checkMEBus(MTEHatchOutputBusME bus,ItemStack check,i
return TransferCheckResult.ofFail("cache.diff.bus",index,cp(next),cp(check));
}
}
itr = bus.getProxy().getStorage().getItemInventory().getStorageList().iterator();
IMEMonitor<IAEItemStack> itemInventory = bus.getProxy().getStorage().getItemInventory();
itr = itemInventory.getStorageList().iterator();
//if(check!=null)
while(itr.hasNext()){IAEItemStack next;
if((next=itr.next()).isSameType(check)==false&&next.getStackSize()>0){
if((next=verifyForRealExistance(itr.next(),itemInventory)).isSameType(check)==false&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("net.diff.bus.null",index,cp(next));
return TransferCheckResult.ofFail("net.diff.bus",index,cp(next),cp(check));
Expand Down Expand Up @@ -1050,11 +1062,11 @@ private TransferCheckResult checkMEHatch(MTEHatchOutputME bus,FluidStack check,i
return TransferCheckResult.ofFail("cache.diff.hatch",index,cp(next),cp(check));
}
}
itr = bus.getProxy().getStorage().getFluidInventory().getStorageList().iterator();
IMEMonitor<IAEFluidStack> itemInventory = bus.getProxy().getStorage().getFluidInventory();
itr = itemInventory.getStorageList().iterator();
//if(check!=null)
while(itr.hasNext()){IAEFluidStack next;
if(!sameType(next=itr.next(),(check))&&next.getStackSize()>0){
if(!sameType(next=verifyForRealExistance(itr.next(),itemInventory),(check))&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next));
return TransferCheckResult.ofFail("net.diff.hatch",index,cp(next),cp(check));
Expand Down Expand Up @@ -1130,6 +1142,7 @@ private static boolean sameType(IAEFluidStack a,FluidStack b){

private boolean moveToOutpus(IDualInputInventory opt,boolean checkSpace) {
ItemStack[] i = opt.getItemInputs();
i=Arrays.stream(i).filter(s->s.stackSize>0).toArray(ItemStack[]::new);
FluidStack[] f = opt.getFluidInputs();
boolean anyDiff=false;
if(i.length>mOutputBusses.size()){
Expand Down
Loading

0 comments on commit 589dd49

Please sign in to comment.