diff --git a/build.gradle b/build.gradle index b9b9796..acc0f98 100644 --- a/build.gradle +++ b/build.gradle @@ -371,8 +371,8 @@ catch (Exception ignored) { } // Pulls version first from the VERSION env and then git tag -String identifiedVersion = '0.0.1' -String versionOverride = '0.0.1' +String identifiedVersion = null +String versionOverride = '0.0.2' 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) { @@ -402,7 +402,7 @@ catch (Exception ignored) { 'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' + 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)' ) - versionOverride = '0.0.1' + //versionOverride = '0.0.1' identifiedVersion = versionOverride } version = identifiedVersion diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index fd84968..2560bb2 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -23,6 +23,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTException; @@ -33,6 +34,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; @@ -61,6 +63,7 @@ import com.gtnewhorizons.modularui.common.widget.SyncedWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.SoundResource; @@ -451,7 +454,8 @@ public void firstClassify(ListeningFluidTank[] fin, ItemStack[] iin) { .orElse(null); iin[ix] = null; } - justHadNewItems = true; + justHadNewItems = true; + onClassify(); programLocal(); } @@ -521,6 +525,7 @@ public void classify(ListeningFluidTank[] fin, ItemStack[] iin) { iin[ix] = null; } justHadNewItems = true; + onClassify(); if (program) programLocal(); } @@ -630,6 +635,7 @@ public static class CallerCheck { } } public boolean highEfficiencyMode(){return false;} +public boolean prevdirty; @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); @@ -654,7 +660,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { inv0.clearRecipeIfNeeded(); } - + prevdirty=dirty; dirty=false; } @@ -796,7 +802,8 @@ private Function get() { @Override public void detectAndSendChanges(boolean init) { - getContext().syncSlotContent(this.getMcSlot()); + + //getContext().syncSlotContent(this.getMcSlot()); super.detectAndSendChanges(init); /* @@ -1054,8 +1061,19 @@ public void addUIWidgets(Builder builder, UIBuildContext buildContext) { builder.widget(createPowerSwitchButton(builder)); builder.widget(new SyncedWidget(){ - //player operation is more complicated, always set to true when GUI open - public void detectAndSendChanges(boolean init) {BufferedDualInputHatch.this.dirty=true;}; + + @SuppressWarnings("unchecked") + public void detectAndSendChanges(boolean init) { + //player operation is more complicated, always set to true when GUI open + BufferedDualInputHatch.this.dirty=true; + + //flush changes to client + //sometimes vanilla detection will fail so sync it manually + if(last+1>=getBaseMetaTileEntity().getTimer()) + getWindow().getContext().getContainer().inventorySlots + .forEach(s->((Slot)s).onSlotChanged()); + + }; @Override public void readOnClient(int id, PacketBuffer buf) throws IOException {} @Override public void readOnServer(int id, PacketBuffer buf) throws IOException {}}); ProghatchesUtil.attachZeroSizedStackRemover(builder,buildContext); @@ -1068,7 +1086,11 @@ public int moveButtons() { return 0; } - + public void onClassify(){ + last=getBaseMetaTileEntity().getTimer(); + } + private long last; + @Override public void loadNBTData(NBTTagCompound aNBT) { dirty=aNBT.getBoolean("dirty"); @@ -1200,8 +1222,9 @@ class RecipeTracker{ boolean broken; int times; boolean first=true; + boolean onceCompared; public void track(ItemStack recipe,ItemStack storage){ - if(recipe.getItem() instanceof ItemProgrammingCircuit){return;} + if(recipe.getItem() instanceof ItemProgrammingCircuit){onceCompared=true;return;} int a=recipe.stackSize; int b=Optional.ofNullable(storage).map(s->s.stackSize).orElse(0); track(a,b); @@ -1218,6 +1241,7 @@ public void track(int a,int b){ if(b%a!=0){broken=true;return;} t=b/a; if(t!=times){ + onceCompared=true; if(first){first=false;times=t;return;} else {broken=true;return;} } @@ -1248,7 +1272,7 @@ public void track(int a,int b){ ); - sub.setInteger("possibleCopies", rt.broken?-1:rt.times); + sub.setInteger("possibleCopies", (rt.broken||(!rt.onceCompared&&!inv.isEmpty()))?-1:rt.times); }); super.getWailaNBTData(player, tile, tag, world, x, y, z); @@ -1309,7 +1333,7 @@ public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDat private Boolean isRemote; public boolean isRemote(){ - if(isRemote==null)isRemote=this.getBaseMetaTileEntity().getWorld().isRemote; + if(isRemote==null)isRemote=FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT;//this.getBaseMetaTileEntity().getWorld().isRemote; return isRemote; } @Override diff --git a/src/main/java/reobf/proghatches/main/ClientProxy.java b/src/main/java/reobf/proghatches/main/ClientProxy.java index c18712e..bc74952 100644 --- a/src/main/java/reobf/proghatches/main/ClientProxy.java +++ b/src/main/java/reobf/proghatches/main/ClientProxy.java @@ -23,7 +23,7 @@ public void preInit(FMLPreInitializationEvent event) { @SubscribeEvent public void handle(TextureStitchEvent.Pre e){ - System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + //System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx"); } } diff --git a/src/main/java/reobf/proghatches/main/CommonProxy.java b/src/main/java/reobf/proghatches/main/CommonProxy.java index 367d68e..959323b 100644 --- a/src/main/java/reobf/proghatches/main/CommonProxy.java +++ b/src/main/java/reobf/proghatches/main/CommonProxy.java @@ -7,6 +7,7 @@ import com.google.common.base.Optional; +import appeng.api.AEApi; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; @@ -17,6 +18,7 @@ import mcp.mobius.waila.api.IWailaRegistrar; import reobf.proghatches.Tags; import reobf.proghatches.block.BlockIOHub; + import reobf.proghatches.block.ItemBlockIOHub; import reobf.proghatches.block.TileIOHub; import reobf.proghatches.gt.metatileentity.ProgrammingCircuitProvider; @@ -30,6 +32,7 @@ import reobf.proghatches.oc.ItemAPICard; import reobf.proghatches.oc.ItemGTRedstoneCard; import reobf.proghatches.oc.ItemWirelessPeripheralCard; +import reobf.proghatches.oc.TileCoprocessor; import reobf.proghatches.oc.TileWirelessPeripheralStation; public class CommonProxy { @@ -45,6 +48,9 @@ public void preInit(FMLPreInitializationEvent event) { GameRegistry.registerTileEntity(TileIOHub.class, "proghatches.iohub"); GameRegistry.registerTileEntity(TileWirelessPeripheralStation.class, "proghatches.peripheral_station"); + GameRegistry.registerTileEntity(TileCoprocessor.class, "proghatches.coprocessor"); + + GameRegistry.registerItem( MyMod.progcircuit = new ItemProgrammingCircuit().setUnlocalizedName("prog_circuit") .setTextureName("?"), @@ -85,6 +91,8 @@ public void preInit(FMLPreInitializationEvent event) { MyMod.pstation =GameRegistry.registerBlock( new TileWirelessPeripheralStation.Block(),TileWirelessPeripheralStation.ItemBlock.class,"proghatches.peripheral_station"); + + li.cil.oc.server.driver.Registry.add((li.cil.oc.api.driver.Item) MyMod.oc_redstone); li.cil.oc.server.driver.Registry.add((li.cil.oc.api.driver.Item) MyMod.oc_api); li.cil.oc.server.driver.Registry.add((li.cil.oc.api.driver.Item) MyMod.pitem); @@ -98,8 +106,11 @@ public void preInit(FMLPreInitializationEvent event) { // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) public void init(FMLInitializationEvent event) { tab = new ProgHatchCreativeTab("proghatches"); + + //AEApi.instance().registries().gridCache().registerGridCache(null, null);; + // AEApi.instance().registries().interfaceTerminal().register(TileFluidInterface.class); new Registration().run(); - + } // postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) diff --git a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java index 65c5525..ec9b61d 100644 --- a/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java +++ b/src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java @@ -59,8 +59,8 @@ public void acceptTargets(Set myTargets, Set otherTargets) { "#set to true to disable those optional mixins if it breaks someting"+System.lineSeparator()+ "noPatternEncodingMixin=false"+System.lineSeparator()+ "noFixTossBug=false"+System.lineSeparator()+ -"noRecipeFilterForDualHatch=false"+System.lineSeparator() - +"noRecipeFilterForDualHatch=false"+System.lineSeparator()+ +"noRemoveUnusedCacheInModularUIContainer=fasle"+System.lineSeparator() ; @SuppressWarnings("unused") @Override @@ -95,12 +95,16 @@ public List getMixins() { System.out.println(pp); System.out.println("ccccccccccccccccccccccccccc"); - // NEE is neither coremod nor mixinmod so add it to path or mixin will fail + // NEE is neither coremod nor mixinmod thus it's not in URL path, so add it to path or mixin will fail loadJarOf(MixinPlugin::hasTrait,"NotEnoughEnergistics"); - // GregTech5RecipeProcessor.class.getDeclaredFields(); + ArrayList ret = new ArrayList<>(); + + if(!"true".equals(pp.get("noRemoveUnusedCacheInModularUIContainer"))) + ret.add("MixinRemoveUnunsedItemStackCache"); + if(!"true".equals(pp.get("noRecipeFilterForDualHatch"))){ ret.add("MixinGTRecipeFilter"); // GT Multiblock will not set recipe filter of DualInputHatch, set it via mixin diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinRemoveUnunsedItemStackCache.java b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinRemoveUnunsedItemStackCache.java new file mode 100644 index 0000000..8f0a41d --- /dev/null +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinRemoveUnunsedItemStackCache.java @@ -0,0 +1,45 @@ +package reobf.proghatches.main.mixin.mixins; + +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; + +import io.netty.buffer.ByteBuf; +import net.minecraft.inventory.Container; + +@Mixin(value = ModularUIContainer.class, remap = false) +public abstract class MixinRemoveUnunsedItemStackCache extends Container{ + + + /* + addSlotToContainer() in Container.java will add to both inventorySlots and inventoryItemStacks + removeSlot() in ModularUIContainer.java only remove inventorySlots + that means open and close a child window with slotwidgets will lengthen inventoryItemStacks + this mixin will fix this potential leak + */ + + private int length; + @Inject(method = "removeSlot", at = @At(value = "HEAD"), require = 1, cancellable = false) + private void removeSlot0(net.minecraft.inventory.Slot slot, CallbackInfo c) + { + length=this.inventoryItemStacks.size(); + } + + @Inject(method = "removeSlot", at = @At(value = "TAIL"), require = 1, cancellable = false) + + private void removeSlot1(net.minecraft.inventory.Slot slot, CallbackInfo c) + { + if(length!=this.inventoryItemStacks.size())return;//just in case it's fixed in future version + this.inventoryItemStacks.remove(slot.slotNumber); + // System.out.println( this.inventoryItemStacks); + } + + + +} diff --git a/src/main/java/reobf/proghatches/oc/TileCoprocessor.java b/src/main/java/reobf/proghatches/oc/TileCoprocessor.java new file mode 100644 index 0000000..8c9bd44 --- /dev/null +++ b/src/main/java/reobf/proghatches/oc/TileCoprocessor.java @@ -0,0 +1,48 @@ +package reobf.proghatches.oc; + +import java.util.Optional; + +import li.cil.oc.api.network.Message; +import li.cil.oc.api.network.Node; +import li.cil.oc.api.network.Visibility; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class TileCoprocessor extends TileEntity implements li.cil.oc.api.network.Environment{ + Node node_ = li.cil.oc.api.Network.newNode(this, Visibility.Network) + .withComponent("coprocessor") + .create(); + @Override + public Node node() { + + return node_; + } +@Override +public void writeToNBT(NBTTagCompound compound) { + Optional.ofNullable(node_).ifPresent(s->s.save(compound)); + super.writeToNBT(compound); +} +@Override +public void readFromNBT(NBTTagCompound compound) { + Optional.ofNullable(node_).ifPresent(s->s.load(compound)); + super.readFromNBT(compound); +} + @Override + public void onConnect(Node node) { + + + } + + @Override + public void onDisconnect(Node node) { + + + } + + @Override + public void onMessage(Message message) { + + + } + +}