Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Jul 12, 2024
1 parent 879e754 commit d19962e
Show file tree
Hide file tree
Showing 21 changed files with 992 additions and 238 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ catch (Exception ignored) {

// Pulls version first from the VERSION env and then git tag
String identifiedVersion = null
String versionOverride = '0.0.17p6'
String versionOverride = '0.0.17p7'
try {
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
if (versionOverride == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reobf/proghatches/eucrafting/IEUManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public default long inject(long a, long v) {
};

public UUID getUUID();

public void refund(long amp);

public long doInject(long a, long v);
Expand Down
159 changes: 114 additions & 45 deletions src/main/java/reobf/proghatches/eucrafting/PartEUP2PInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import net.minecraft.block.Block;
Expand All @@ -21,6 +23,7 @@
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
Expand Down Expand Up @@ -86,6 +89,7 @@
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.container.ContainerNull;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
Expand Down Expand Up @@ -121,7 +125,7 @@
//modified from PartFluidP2PInterface
public class PartEUP2PInterface extends PartP2PTunnelStatic<PartEUP2PInterface> implements IGridTickable,
IStorageMonitorable, IInventoryDestination, IDualHost, ISidedInventory, IAEAppEngInventory,
ITileStorageMonitorable, IPriorityHost, IInterfaceHost, IPartGT5Power, IGuiProvidingPart, IDrain {
ITileStorageMonitorable, IPriorityHost, IInterfaceHost, IPartGT5Power, IGuiProvidingPart, IDrain ,IInstantCompletable{
public static class WailaDataProvider extends BasePartWailaDataProvider {

@Override
Expand Down Expand Up @@ -158,25 +162,25 @@ public NBTTagCompound getNBTData(EntityPlayerMP player, IPart part, TileEntity t
tag.setInteger("succs", pt.succs);
tag.setInteger("fails", pt.fails);
tag.setBoolean("validtile", pt.getTargetTile()!=null);
tag.setBoolean("pass", pt.pass);
tag.setInteger("pass", pt.pass);

PartEUP2PInterface iface=pt.getInput();
if(iface!=null){
boolean[] suc=new boolean[1];
boolean[] suc=new boolean[]{true};
StringBuilder s=new StringBuilder();
if(iface.getTargetTile()==null)
s.append("---");
else{
s.append(""+iface.pass);
suc[0]&=iface.pass;
suc[0]&=iface.pass>0;
}
try {
iface.getOutputs().forEach(ss->{
if(ss.getTargetTile()==null)
s.append("|---");
else{
s.append("|"+ss.pass);
suc[0]&=iface.pass;
suc[0]&=iface.pass>0;
}

});
Expand Down Expand Up @@ -254,18 +258,18 @@ public List<String> getWailaBody(IPart part, List<String> currentToolTip, IWaila


if(validtile){
currentToolTip.add(StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.halt_count",
/*currentToolTip.add(StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.halt_count",
accessor.getNBTData().getInteger("succs")));
currentToolTip.add(StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.fail_count",
accessor.getNBTData().getInteger("fails")));

*/
currentToolTip.add(StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.pass",
accessor.getNBTData().getInteger("pass")));
}
if(accessor.getNBTData().hasKey("io_pass"))
{currentToolTip.add(
StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.pass.p2p")+
accessor.getNBTData().getString("io_pass"));
StatCollector.translateToLocalFormatted("proghatches.eu.interface.waila.pass.p2p",
accessor.getNBTData().getString("io_pass")));
}

return super.getWailaBody(part, currentToolTip, accessor, config);
Expand Down Expand Up @@ -502,6 +506,24 @@ public boolean refund(IMEInventory<IAEItemStack> inv, IMEInventory<IAEItemStack>
}

boolean prevPower;
public TileEntity getTargetInv(){
TileEntity te;
if(data!=null){
DimensionalCoord pos = data.getPos();
te= data.getTile().getWorldObj().getTileEntity(pos.x,pos.y,pos.z);
}else{
int x=this.host.getTile().xCoord;
int y=this.host.getTile().yCoord;
int z=this.host.getTile().zCoord;
ForgeDirection fd = this.getSide();
te=this.host.getTile().getWorldObj().getTileEntity(
x+fd.offsetX,y+fd.offsetY,z+fd.offsetZ);
}

return te;


}
public IMetaTileEntity getTargetTile(){

TileEntity te;
Expand Down Expand Up @@ -529,43 +551,71 @@ public IMetaTileEntity getTargetTile(){

}
int fails;
boolean pass;
int pass=-2;

private void resetIdleCheckStatus(boolean check) {

fails=0;
succs=0;
pass=false;
pass=-1;
passReason=0;
if(MinecraftServer.getServer()!=null)
pushtick=getTick();
}
private static int getTick(){
if(MinecraftServer.getServer()!=null)
return MinecraftServer.getServer().getTickCounter();
return 0;
}
long pushtick;
int passReason;
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {

returnItems();
duality.tickingRequest(node, ticksSinceLastCall);
dualityFluid.tickingRequest(node, ticksSinceLastCall);
boolean ok = false;
/* if (!this.isOutput()) {

boolean red = this.redstone();
ArrayList<PartEUP2PInterface> all = new ArrayList<>();

if (!this.isOutput()) {
HashSet<PartEUP2PInterface> dummy = new HashSet<>();
all.add(this);
try {
for (PartEUP2PInterface o : this.getOutputs()) {
red = red | o.redstone();
this.getOutputs().forEach(all::add);
} catch (GridAccessException e) {}
//phase0
for(PartEUP2PInterface part:all){
boolean order=part.pushtick==getTick();
if(part.pass==-1&&!order){
part.pass=0;
}
} catch (GridAccessException e) {
e.printStackTrace();
}
if (prevPower == true && red == false) {
ok = true;

if(part.pass==0){
IMetaTileEntity t = part.getTargetTile();
if(t!=null&&t instanceof IIdleStateProvider){
if(((IIdleStateProvider) t).failThisTick()){
if(part.fails++==0){part.pass=1;if(part.passReason==0)part.passReason=2;};//fail 1 time, assume no valid inputs, just pass it
}
}else{
dummy.add(part);
}
}
}
//phase1
boolean allok=all.stream().filter(s->!dummy.contains(s)).map(s->s.pass==1).reduce(Boolean::logicalAnd).orElse(false);
if(allok){
ok=true;
all.forEach(s->s.pass=2);
}
prevPower = red;

}

*/ArrayList<PartEUP2PInterface> all = new ArrayList<>();
if (!this.isOutput()) {

/*if (!this.isOutput()) {
boolean[] hasFail=new boolean[1];
Expand All @@ -577,11 +627,9 @@ public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall)
IMetaTileEntity t = s.getTargetTile();
if(t!=null&&t instanceof IIdleStateProvider){
if(((IIdleStateProvider) t).getIdle()==1){
s.pass=true;
}
if(((IIdleStateProvider) t).failThisTick()){
if(s.fails++==2){s.pass=true;};//fail 2 times, so assume no valid inputs, just pass it
if(s.fails++==0){s.pass=true;};//fail 2 times, so assume no valid inputs, just pass it
}
//if(!(!prev_pass&&pass))
if(!pass)
Expand All @@ -593,15 +641,15 @@ public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall)
if(!hasFail[0]&&amp>0){ok=true;}
}

*/







if (ok || all.stream().map(s->s.redstoneticks>0).findAny().isPresent()) {
if (ok || all.stream().filter(s->s.redstoneticks>0).findAny().isPresent()) {
//all.forEach(s->s.resetIdleCheckStatus(false));
try {

Expand Down Expand Up @@ -981,29 +1029,31 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf
return true;
}
if (patternDetails instanceof WrappedPatternDetail) {

WrappedPatternDetail p = (WrappedPatternDetail) patternDetails;
InventoryCrafting neo =new InventoryCrafting(new ContainerNull(), table.getSizeInventory(), 1);
int[] count = new int[1];
int size = table.getSizeInventory();
for (int i = 0; i < size; i++) {
ItemStack is = table.getStackInSlot(i);
if (is != null && is.getItem() == MyMod.eu_token && is.stackSize > 0) {
count[0] += is.stackSize;
is=is.copy();
is.stackSize = 0;
table.setInventorySlotContents(i, is);

break;
}
neo.setInventorySlotContents(i, is);
}else
neo.setInventorySlotContents(i, is);
;
}
PartEUP2PInterface face = this;
if (isP2POut()) {
face = this.getInput();
}
boolean succ = duality.pushPattern(p.original, table);
boolean succ = duality.pushPattern(p.original, neo);
if (succ) {
if (face != null){
face.amp = Math.max(face.amp, count[0]);
//face.amp = Math.max(face.amp, count[0]);

face.resetIdleCheckStatus(true);
try {
Expand All @@ -1025,7 +1075,7 @@ public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCraf

@Override
public boolean isBusy() {
return duality.isBusy();
return duality.isBusy()||getTargetInv()==null;
}

@Override
Expand Down Expand Up @@ -1066,7 +1116,8 @@ public void readFromNBT(NBTTagCompound data) {
redstoneOverride = data.getBoolean("redstoneOverride");
fails=data.getInteger("fails");
succs=data.getInteger("succs");
pass=data.getBoolean("pass");
pass=data.getInteger("pass");
passReason=data.getInteger("passReason");
is.clear();
IntStream.range(0, data.getInteger("pending_size")).forEach(s -> {

Expand Down Expand Up @@ -1096,10 +1147,10 @@ public void writeToNBT(NBTTagCompound data) {
data.setLong("expectedamp", expectedamp);
data.setBoolean("redstoneOverride", redstoneOverride);
data.setInteger("fails", fails);
data.setBoolean("pass", pass);
data.setInteger("pass", pass);

data.setInteger("succs", succs);

data.setInteger("passReason",passReason);
for (int i = 0; i < is.size(); i++) {
data.setTag("pending_" + i, is.get(i).writeToNBT(new NBTTagCompound()));
}
Expand Down Expand Up @@ -1655,4 +1706,22 @@ public ItemStack getSelfRep() {
return new ItemStack(MyMod.euinterface_p2p);
}

@Override
public int rows() {
// TODO Auto-generated method stub
return 0;
}

@Override
public int rowSize() {
// TODO Auto-generated method stub
return 0;
}

@Override
public void complete() {
returnItems();

}

}
Loading

0 comments on commit d19962e

Please sign in to comment.