Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Dec 31, 2024
1 parent 589dd49 commit 06695ea
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import java.util.List;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.function.Predicate;
import java.util.function.Supplier;

import javax.naming.OperationNotSupportedException;
Expand Down Expand Up @@ -82,6 +84,7 @@
import reobf.proghatches.gt.metatileentity.util.IDataCopyablePlaceHolder;
import reobf.proghatches.gt.metatileentity.util.IDataCopyablePlaceHolderSuper;
import reobf.proghatches.gt.metatileentity.util.IMEHatchOverrided;
import reobf.proghatches.main.MyMod;
import reobf.proghatches.main.registration.Registration;

public class DecoyInputBusME extends MTEHatchInputBusME implements IMEHatchOverrided,IDataCopyablePlaceHolderSuper {
Expand Down Expand Up @@ -135,7 +138,7 @@ private static Set<ICellProvider> get(GridStorageCache thiz) {
}
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
@Override
public void overridedBehoviour(int minPull) {
AENetworkProxy proxy = getProxy();
Expand Down Expand Up @@ -174,7 +177,9 @@ public void overridedBehoviour(int minPull) {
if(reserveFirst&&orderMap.isEmpty()==false)
{
if(orderMap.get(orderMap.keySet().first()).stream()
.filter(s->s.getAvailableItems(StorageChannel.ITEMS.createList()).getFirstItem()!=null)
.filter(s->s.getAvailableItems(StorageChannel.ITEMS.createList(),
appeng.util.IterationCounter.fetchNewId()
).getFirstItem()!=null)
.findAny().isPresent()==false
){
keepFirstEmpty=true;
Expand All @@ -196,6 +201,7 @@ public void add(final IAEItemStack option) {
final IAEItemStack st = this.records.get(option);

if (st != null) {
if(st.getStackSize()==0){added.add(option.copy());}
st.add(option);
return;
}
Expand Down Expand Up @@ -232,7 +238,8 @@ public void addStorage(final IAEItemStack option) {
if(option.getItem()instanceof ItemFluidDrop){return;}
final IAEItemStack st = this.records.get(option);

if (st != null) {
if (st != null) {
if(st.getStackSize()==0){added.add(option.copy());}
st.incStackSize(option.getStackSize());
return;
}
Expand All @@ -250,7 +257,7 @@ public void addStorage(final IAEItemStack option) {

@Override
public void addCrafting(final IAEItemStack option) {
if (option == null) {
return;/*if (option == null) {
return;
}
Expand All @@ -265,12 +272,12 @@ public void addCrafting(final IAEItemStack option) {
opt.setStackSize(0);
opt.setCraftable(true);
this.putItemRecord(opt);
this.putItemRecord(opt);*/
}

@Override
public void addRequestable(final IAEItemStack option) {
if (option == null) {
return;/*if (option == null) {
return;
}
Expand All @@ -289,7 +296,7 @@ public void addRequestable(final IAEItemStack option) {
opt.setCountRequestable(option.getCountRequestable());
opt.setCountRequestableCrafts(option.getCountRequestableCrafts());
this.putItemRecord(opt);
this.putItemRecord(opt);*/
}

@Override
Expand Down Expand Up @@ -333,7 +340,7 @@ private Collection<IAEItemStack> findFuzzyDamage(final AEItemStack filter, final
};

for (Entry<Integer, IMEInventoryHandler<IAEItemStack>> ent : orderMap.entries()) {
ent.getValue().getAvailableItems(all);
ent.getValue().getAvailableItems(all,appeng.util.IterationCounter.fetchNewId());
if (added.size() > 16) {
break;
}
Expand Down Expand Up @@ -452,7 +459,7 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye
((IStorageGrid) this.getProxy().getNode().getGrid().getCache(IStorageGrid.class)).getItemInventory(),
AEItemStack.create(new ItemStack(net.minecraft.init.Items.apple,10)),Actionable.MODULATE,
requestSource
new MachineSource((IActionHost)this.getBaseMetaTileEntity())
));
} catch (Exception e) {
Expand All @@ -463,9 +470,20 @@ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlaye
}


/**
* @param thiz
* @param request
* @param mode
* @param src
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) {

if(mode==Actionable.SIMULATE)
return thiz.extractItems(request, mode, src);

long requested = request.getStackSize();
long num = request.getStackSize();
try {
Expand Down Expand Up @@ -505,7 +523,11 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m
}
}
if (most_ == -1)
break done;
{



break done;}


most.sort((a,b)->a.getPriority()-b.getPriority());
Expand Down Expand Up @@ -544,9 +566,55 @@ public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable m

}

if(num!=0)try{
MyMod.LOG.fatal("[Decoy Bus]:Fail to extract!");
MyMod.LOG.fatal("Expected:"+request.toString());
MyMod.LOG.fatal("Left:"+num);
MyMod.LOG.fatal("Auto-pull");
for(ItemStack item:mInventory){
MyMod.LOG.fatal(Objects.toString(item));
}
MyMod.LOG.fatal("shadowInventory");
try {
Field f=MTEHatchInputBusME.class.getDeclaredField("shadowInventory");
f.setAccessible(true);
ItemStack[] get=(ItemStack[]) f.get(this);
for(ItemStack item:get){
MyMod.LOG.fatal(Objects.toString(item));
}
} catch (Exception e) {
e.printStackTrace();
}
MyMod.LOG.fatal("savedStackSizes");
try {
Field f=MTEHatchInputBusME.class.getDeclaredField("savedStackSizes");
f.setAccessible(true);
int[] get=(int[]) f.get(this);
for(int item:get){
MyMod.LOG.fatal(Objects.toString(item));
}
} catch (Exception e) {
e.printStackTrace();
}


MyMod.LOG.fatal("But not found from:");
for(IMEInventoryHandler xo:ordered){
MyMod.LOG.fatal(xo+":");
xo.getAvailableItems(StorageChannel.ITEMS.createList(),
appeng.util.IterationCounter.fetchNewId()).forEach((s)->{
MyMod.LOG.fatal(s);
});
}
}catch(Exception e){e.printStackTrace();}


} catch (GridAccessException e) {
MyMod.LOG.fatal("[Decoy Bus]:GridAccessException");
e.printStackTrace();

}

if(requested==num)return null;
return request.copy().setStackSize(requested-num);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void add(final IAEFluidStack option) {

final IAEFluidStack st = this.records.get(option);

if (st != null) {
if (st != null) {if(st.getStackSize()==0){added.add(option.copy());}
st.add(option);
return;
}
Expand Down Expand Up @@ -209,6 +209,7 @@ public void addStorage(final IAEFluidStack option) {
final IAEFluidStack st = this.records.get(option);

if (st != null) {
if(st.getStackSize()==0){added.add(option.copy());}
st.incStackSize(option.getStackSize());
return;
}
Expand Down Expand Up @@ -442,6 +443,8 @@ public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, f
super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ);
}@Override
public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) {
if(mode==Actionable.SIMULATE)
return thiz.extractItems(request, mode, src);

long requested = request.getStackSize();
long num = request.getStackSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,21 @@ public void overridedBehoviour(int minPull) {


}

boolean onlyFromSameP=true;

@SuppressWarnings("unchecked")
@Override
public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) {
lab:if(mode==Actionable.SIMULATE){
if(onlyFromSameP){

break lab;
}
return thiz.extractItems(request, mode, src);
}


AENetworkProxy proxy = getProxy();
long size=request.getStackSize();
request=request.copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,18 @@ public void overridedBehoviour(int minPull) {


}
boolean onlyFromSameP;
@SuppressWarnings("unchecked")
@Override
public IAEStack overridedExtract(IMEMonitor thiz, IAEStack request, Actionable mode, BaseActionSource src) {
lab:if(mode==Actionable.SIMULATE){
if(onlyFromSameP){

break lab;
}
return thiz.extractItems(request, mode, src);
}

AENetworkProxy proxy = getProxy();
long size=request.getStackSize();
request=request.copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void refreshItemList(CallbackInfo ci) {

}

@Redirect( require = 1,method="endRecipeProcessing"
@Redirect( require = 1,method="/^\\w/"//"endRecipeProcessing"
,

at = @At(value="INVOKE",
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/reobf/proghatches/main/registration/PHRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.glodblock.github.loader.ItemAndBlockHolder;

import appeng.core.Api;
import appeng.integration.modules.Chisel;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.ironchest.IronChest;
import crazypants.enderio.EnderIOTab;
Expand All @@ -55,6 +56,7 @@
import reobf.proghatches.main.Config;
import reobf.proghatches.main.MyMod;
import tconstruct.smeltery.TinkerSmeltery;
import team.chisel.init.ChiselBlocks;
import tectech.recipe.TTRecipeAdder;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.common.config.ConfigItems;
Expand Down Expand Up @@ -1863,7 +1865,24 @@ bb,new ItemStack(MyMod.smartarm, 4,i+5)
}



/*GTRecipeBuilder.builder()
.metadata(RESEARCH_ITEM, new ItemStack(ChiselBlocks.present,1,16))
.metadata(RESEARCH_TIME, 1 )
.itemInputs(
new ItemStack(ChiselBlocks.present,1,0),
new ItemStack(ChiselBlocks.present,1,1),
new ItemStack(ChiselBlocks.present,1,2),
new ItemStack(ChiselBlocks.present,1,0)
)
.fluidInputs(new FluidStack(FluidRegistry.WATER,1)
)
.itemOutputs( new ItemStack(ChiselBlocks.present,1,15))
.eut(TierEU.RECIPE_LV)
.duration(10)
.addTo( GTRecipeConstants.AssemblyLine);*/

}

Expand Down

0 comments on commit 06695ea

Please sign in to comment.