Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Feb 16, 2024
1 parent be465d8 commit efd08e9
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 18 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -451,7 +454,8 @@ public void firstClassify(ListeningFluidTank[] fin, ItemStack[] iin) {
.orElse(null);
iin[ix] = null;
}
justHadNewItems = true;
justHadNewItems = true;
onClassify();
programLocal();
}

Expand Down Expand Up @@ -521,6 +525,7 @@ public void classify(ListeningFluidTank[] fin, ItemStack[] iin) {
iin[ix] = null;
}
justHadNewItems = true;
onClassify();
if (program) programLocal();

}
Expand Down Expand Up @@ -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);
Expand All @@ -654,7 +660,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {

inv0.clearRecipeIfNeeded();
}

prevdirty=dirty;
dirty=false;
}

Expand Down Expand Up @@ -796,7 +802,8 @@ private Function<BaseSlot, SlotWidget> get() {

@Override
public void detectAndSendChanges(boolean init) {
getContext().syncSlotContent(this.getMcSlot());

//getContext().syncSlotContent(this.getMcSlot());
super.detectAndSendChanges(init);

/*
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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);
Expand All @@ -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;}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1309,7 +1333,7 @@ public void getWailaBody(ItemStack itemStack, List<String> 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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/reobf/proghatches/main/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void preInit(FMLPreInitializationEvent event) {
@SubscribeEvent
public void handle(TextureStitchEvent.Pre e){

System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxx");

}
}
13 changes: 12 additions & 1 deletion src/main/java/reobf/proghatches/main/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -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("?"),
Expand Down Expand Up @@ -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);
Expand All @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/reobf/proghatches/main/mixin/MixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void acceptTargets(Set<String> myTargets, Set<String> 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
Expand Down Expand Up @@ -95,12 +95,16 @@ public List<String> 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<String> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}



}
48 changes: 48 additions & 0 deletions src/main/java/reobf/proghatches/oc/TileCoprocessor.java
Original file line number Diff line number Diff line change
@@ -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) {


}

}

0 comments on commit efd08e9

Please sign in to comment.