Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Jul 14, 2024
1 parent d19962e commit 3296a0c
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 13 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.17p7'
String versionOverride = '0.0.17p8'
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
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) {
}

public Optional<TileEntity> getTile() {
if (this.getBaseMetaTileEntity().getWorld().getChunkProvider().chunkExists(x >> 4, z >> 4) == false) {
try{
if (this.getBaseMetaTileEntity().getWorld().getChunkProvider().chunkExists(x >> 4, z >> 4) == false) {
return Optional.empty();
}
return Optional.ofNullable(this.getBaseMetaTileEntity().getWorld().getTileEntity(x, y, z));
}
}catch(Exception e){ return Optional.empty();}
}

public List<ItemStack> filterTakable(TileEntity e) {
if (e == null || (e instanceof IInventory == false))
Expand Down Expand Up @@ -546,17 +548,36 @@ public void updateSlots() {
}// no we don't

public void removePhantom() {

try{
getTile().filter(s -> s instanceof IInventory).ifPresent(s -> {

int index=-1;
TileEntity gt = s;
if (gt != null && gt instanceof IGregTechTileEntity) {
IMetaTileEntity meta = ((IGregTechTileEntity) gt).getMetaTileEntity();
if (meta != null && (meta instanceof IConfigurationCircuitSupport)) {
index=((IConfigurationCircuitSupport)meta).getCircuitSlot();
}
}

IInventory a = ((IInventory) s);
int size = a.getSizeInventory();
for (int i = 0; i < size; i++) {

if(a.getStackInSlot(i)!=null
&&i!=index
)//
a.decrStackSize(i, 0);// remove 0-sized phantom item
}

});


}catch(RuntimeException e){
e.printStackTrace();
//??????????

}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.recipe.check.CheckRecipeResultRegistry;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GT_Utility;
import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch;
import reobf.proghatches.gt.metatileentity.util.RecursiveLinkExcpetion;
import reobf.proghatches.lang.LangManager;
Expand Down Expand Up @@ -353,10 +354,12 @@ public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) {
}

public Optional<TileEntity> getTile() {
try{
if (this.getBaseMetaTileEntity().getWorld().getChunkProvider().chunkExists(x >> 4, z >> 4) == false) {
return Optional.empty();
}
return Optional.ofNullable(this.getBaseMetaTileEntity().getWorld().getTileEntity(x, y, z));
}catch(Exception e){return Optional.empty();}
}
@Override
public FluidStack getFluid(int aSlot) {
Expand Down Expand Up @@ -398,7 +401,7 @@ public FluidStack getFillableStack() {

return getTile().map(this::filterTakable)
.filter(s->s.size()>=1)
.orElseGet(()->ImmutableList.of(null)).get(0);
.map(s->s.get(0)).orElse(null);
}
catch (RecursiveLinkExcpetion e) {
return null;
Expand All @@ -415,6 +418,15 @@ public List<FluidStack> filterTakable(TileEntity e) {

if (processingRecipe == false)
return new ArrayList<FluidStack>();

try{
if(tmp!=null)
endRecipeProcessing(null);
//this means this method is called twice during recipe check?
//remove consumed fluid
}catch(Exception ex){ex.printStackTrace();}
processingRecipe=true;

if (e == null || (e instanceof IFluidHandler == false))
return new ArrayList<FluidStack>();
IFluidHandler inv = (IFluidHandler) e;
Expand Down Expand Up @@ -628,5 +640,51 @@ public CheckRecipeResult endRecipeProcessing(GT_MetaTileEntity_MultiBlockBase co
tmp = null;
return CheckRecipeResultRegistry.SUCCESSFUL;
}
@Override
public FluidStack getFluid() {
FluidStack FS=getFillableStack();

return FS;
}
@Override
public FluidStack getDrainableStack() {

return getFillableStack();
}


@Override
public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) {
try(AutoCloseable o=mark()){
Optional<TileEntity> opt = getTile();
if (opt.isPresent() && checkBlackList(opt)) {
this.linked = false;
}
List<FluidStack> all= filterTakable(getTile().orElse(null));
// this is an ME input hatch. allowing draining via logistics would be very wrong (and against
// canTankBeEmptied()) but we do need to support draining from controller, which uses the UNKNOWN direction.
if (side != ForgeDirection.UNKNOWN) return null;
// FluidStack stored = getMatchingFluidStack(aFluid);
FluidStack stored = all.stream().filter(s->s.getFluid()==aFluid.getFluid())
.findAny().orElse(null);


if (stored == null) return null;
FluidStack drained = GT_Utility.copyAmount(Math.min(stored.amount, aFluid.amount), stored);
if (doDrain) {
stored.amount -= drained.amount;
}
return drained;
}catch (Exception e) {
e.printStackTrace();
return null;
}
}

/*private FluidStack getMatchingFluidStack(FluidStack aFluid) {
if(tmp==null)return null;
return tmp.stream().filter(s->s.getFluid()==aFluid.getFluid())
.findAny().orElse(null);
}*/

}
8 changes: 5 additions & 3 deletions src/main/java/reobf/proghatches/main/MyMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import gregtech.api.util.shutdown.SimpleShutDownReason;
import gregtech.common.blocks.GT_Block_Machines;
import gregtech.common.covers.CoverInfo;
import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_HeatExchanger;
import reobf.proghatches.Tags;
import reobf.proghatches.eucrafting.BlockEUInterface;
import reobf.proghatches.eucrafting.AECover;
Expand Down Expand Up @@ -116,7 +117,7 @@
)
public class MyMod {
public static MyMod instance;
{
{GT_MetaTileEntity_HeatExchanger.class.getDeclaredFields();
// BaseMetaPipeEntity.class.getDeclaredFields();
instance = this;
}
Expand Down Expand Up @@ -321,9 +322,10 @@ public static ItemStack tutorial(Item it, String key) {

ArrayList<String> pages = new ArrayList<>();
int size = Integer.valueOf(LangManager.translateToLocalFormatted(key + ".pages"));
for (int i = 0; i < size; i++)
for (int i = 0; i < size; i++){
//System.out.println(LangManager.translateToLocalFormatted(key + ".pages." + i));
pages.add(LangManager.translateToLocalFormatted(key + ".pages." + i).replace("\\n", "\n"));

}
ItemStack is = ProghatchesUtil.getWrittenBook(it, "ProgrammableHatchesTutorial", key, "programmable_hatches",
pages.toArray(new String[0]));
is.stackTagCompound.setString("proghatchesSpecialTag", "true");
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public List<String> getMixins() {
ArrayList<String> ret = new ArrayList<>();
retLate.add("eucrafting." + "MixinWailaProvider");
retLate.add("eucrafting." + "MixinInstantComplete");



if (!"true".equals(pp.get("noFixRecursiveCraft")))
retLate.add("eucrafting." + "MixinCraftingRecursiveWorkaround");
if (!"true".equals(pp.get("noEUCraftingMixins"))) {
Expand Down
27 changes: 25 additions & 2 deletions src/main/resources/assets/proghatches/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,31 @@ item.proghatches.oc.api.tooltip=2
programmable_hatches.cover.smart.probe=Probe Test
programmable_hatches.cover.smart.probe.move=Move the §4probe
programmable_hatches.tutorial=How to master Programmable Hatches in 30 minutes
programmable_hatches.tutorial.pages.0=Not yet completed
programmable_hatches.tutorial.pages=1
programmable_hatches.tutorial.pages.0=Programming Circuit&Programming Cover\n\nProgramming Circuit is to Programming Cover is what Fluid Packet is to Fluid Packet Decoder. Programming Circuit records an Item, Programming Cover writes the recorded Item to the virtual circuit slot.
programmable_hatches.tutorial.pages.1=Especially if a P-Circuit is empty, P-Cover will clear all virtual circuit slots.
programmable_hatches.tutorial.pages.2=This mod aims to help you to handle AE automation of recipes with NC(Not Consumed) Items as inputs in this way.
programmable_hatches.tutorial.pages.3=You might place P-Cover on single-block machines or input buses. Some advanced hatches intergrates P-Cover inside. What you need to do is to encode P-Circuit(instead of ignoring NC Items) into pattern inputs, and watch the P-Cover do the trick.
programmable_hatches.tutorial.pages.4=By the way, besides nomal NC Items like Programmed Circuits(GT5U,Bartworks or GT++), Lens,Molds,Catalysts and Shapes can also be written to virtual circuit slot using P-Cover & P-Circuit.
programmable_hatches.tutorial.pages.5=Programming Circuit Provider\n\nUses 1 ME channel. Provides crafting of P-Circuit. Put Items in its inventory to specify the target item of the P-Circuit. Costs 10AE for each P-Circuit(almost free!) and the crafting is completed instantly.
programmable_hatches.tutorial.pages.6=One single P-Circuit Provider can only provide limited types of P-Circuit. You might want many of those. \nNote: you have to put real items into thr provider to make it running, NEI Bookmarks will NOT work!
programmable_hatches.tutorial.pages.7=Programming Toolkit MK.II\n\nCarry this Item in inventory, and use the '+' button to encode patterns on ME Encoding Terminal. This toolkit will covert NC Items to corresponding P-Circuit, instead of removing it.
programmable_hatches.tutorial.pages.8=Right click to open its inventory, you can generate P-Circuit manually for testing purpose.
programmable_hatches.tutorial.pages.9=DO NOT carry multiple toolkits, this will mess things up. Shift+RMB to switch mode. Mode 1(default) is off, Mode 2 is nomal. In Mode 3, if recipe has no NC Items as inputs, it will append an extra Empty P-Circuit(a.k.a. Reseting P-Circuit).
programmable_hatches.tutorial.pages.10=Programmable Dual Input Hatch\n\nYou may call it Programmable Input Buffer if you want to.\nP-Cover is intergrated and Input Seperation Mode is forced on. Just put an ME Interface with Blocking Mode on next to it.
programmable_hatches.tutorial.pages.11=Use Encoded Patterns encoded with toolkit. ME Interface will insert Items, Fluid and P-Cicruit into the Hatch. P-Cicruit will be consumed to configure the virtual slot.
programmable_hatches.tutorial.pages.12=You will never have to worry if the recipe will be messed, just remember to turn Bloking Mode ON!
programmable_hatches.tutorial.pages.13=Buffered Programmable Dual Input Hatch\n\nIf you don't care about how it works, just treat it exactly like the non-buffered one(yes, you still have to keep Bloking Mode ON). This up-graded version will make better advantage of parallels of the Multiblock.
programmable_hatches.tutorial.pages.14=Buffered Hatch can accept almost infinity input ingredients(limited by its cap and amount of Crafting Accelerators) from ME Interface within 2 ticks, with Bloking Mode on!
programmable_hatches.tutorial.pages.15=Here is how it works, you can skip it if not interested.
programmable_hatches.tutorial.pages.16=For a Buffered Programmable Dual Input Hatch(be short for 'BPDI Hatch'), its main inventoty is called 'Input Area'. And it has several sub-inventoties called 'Buffer Area'. The Multiblock can only access 'Buffer Area'. Pipes & hoppers can only access 'Input Area'.
programmable_hatches.tutorial.pages.17=When 'Buffer Area' is empty, it does nothing. ME Interface will only inject recipe ingredients to 'Input Area' once(because Blocking Mode is on). When the gametick ends, 'Buffer Area' will scan the 'Input Area' and lock the recipe.
programmable_hatches.tutorial.pages.18=When 'Buffer Area' locks a recipe, and if 'Input Area' exactly matches the locked recipe, it will be transfered to 'Buffer Area' instantly. It's so instant that ME Interface's Blocking Mode is not triggered.
programmable_hatches.tutorial.pages.19=That's why it takes 2 tick to transfer. One tick to lock and the second tick to tranfer.
programmable_hatches.tutorial.pages.20=Some BPDI Hatch has multiple 'buffer areas', they are seperated with each other.
programmable_hatches.tutorial.pages.21=Each 'Buffer Area' has 4 virtual slots in case recipe has multiple NC Items. 'Input Area' has a virtual slot not writable by P-Circuit, it's normally used as GT++ Large Processing Factory's mode-selecting circuit.
programmable_hatches.tutorial.pages.22=A 'Buffer Area' has a capacity limit. This is not a hard limit, 'Buffer Area' may exceed the limit. That is to say, a recipe is guaranteed not to be torn. But it will refuse to accept more ingredients then.
programmable_hatches.tutorial.pages.23=The 'Power Switch' can disable the recipe recording process temporarily.
programmable_hatches.tutorial.pages=24
item.prog_toolkit.name.tooltip.emptyinput=For automation, use Programming Circuit Provider instead.
item.proghatch.cover.dedicated.tooltips.1.0=Redstone Receiver(Internal) with Safe Mode
item.proghatch.cover.dedicated.tooltips.1=1
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/assets/proghatches/lang/zh_CN.lang
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ programmable_hatches.tutorial.pages.8=缓存版本的编程二合一输入仓,
programmable_hatches.tutorial.pages.9=这样,即使开启阻挡模式,AE发配完一组原料后,不会因为阻挡模式停止发配。因此只需要2tick就能将原料全部发配给机器待用(如果AE有足够多并行)。每个缓存区(进阶版的有多个)内部附带编程器覆盖板功能,且有4个额外的虚拟槽,用于处理含多个不消耗物品的配方。每个缓存区也是互相输入隔离的。
programmable_hatches.tutorial.pages.10=注意,缓存编程二合一输入仓的输入区没有编程覆盖板功能(即使手动贴覆盖板也一样),输入区的虚拟电路板是方便九合一加工厂指定类型用的,被每个缓存区共享。缓存区的容量会在tooltips中标注,允许超出容量,但超出后该缓存区会停止工作。
programmable_hatches.tutorial.pages.11=右上角的“电源”按钮控制机器是否向“缓存区”转移材料,你可以关掉它,然后手动塞入一份材料再打开,这样缓冲区才能正确记录你的配方。
programmable_hatches.tutorial.pages.12=无线控制覆盖板&智能机械臂&GT高级无线红石卡\n\n这些物品所访问的都是GT高级无线红石系统,是的,它们不兼容基础版的GT无线红石。
programmable_hatches.tutorial.pages=13
programmable_hatches.tutorial.pages=12
item.proghatch.cover.dedicated.tooltips.1.0=带有安全模式的红石接收覆盖板(内)
item.proghatch.cover.dedicated.tooltips.1=1
item.proghatch.cover.dedicated.tooltips.0=0
Expand Down

0 comments on commit 3296a0c

Please sign in to comment.