Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Oct 10, 2024
1 parent 6adca22 commit d0d157f
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl


final int WIDTH = 78;
final int HEIGHT = 80+18+18;
final int HEIGHT = parent.getSize().height+18+18+3;
final int PARENT_WIDTH = getGUIWidth();
final int PARENT_HEIGHT = getGUIHeight();
ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT);
Expand All @@ -250,7 +250,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl
.add(WIDTH - 3, 0)));
builder.widget(
TextWidget.localised("proghatches.priority.filter")
.setPos(3, 80)
.setPos(3, parent.getSize().height)
.setSize(74, 18))
.widget(
new NumericWidget().setSetter(val -> filter = (int) val)
Expand All @@ -260,7 +260,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl
.setTextAlignment(Alignment.Center)
.setTextColor(Color.WHITE.normal)
.setSize(70, 18)
.setPos(3, 80+18)
.setPos(3, parent.getSize().height+18)
.setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));


Expand Down Expand Up @@ -329,6 +329,16 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont

}

@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setInteger("filter", filter);
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
filter =aNBT.getInteger("filter" );
super.loadNBTData(aNBT);
}
@Override
public NBTTagCompound getCopiedData(EntityPlayer player) {
return IDataCopyablePlaceHolderSuper.super.getCopiedData(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl


final int WIDTH = 78;
final int HEIGHT = 80+18+18;
final int HEIGHT = parent.getSize().height+18+18+3;
final int PARENT_WIDTH = getGUIWidth();
final int PARENT_HEIGHT = getGUIHeight();
ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT);
Expand All @@ -251,7 +251,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl
.add(WIDTH - 3, 0)));
builder.widget(
TextWidget.localised("proghatches.priority.filter")
.setPos(3, 80)
.setPos(3, parent.getSize().height)
.setSize(74, 18))
.widget(
new NumericWidget().setSetter(val -> filter = (int) val)
Expand All @@ -261,7 +261,7 @@ protected ModularWindow createStackSizeConfigurationWindow(final EntityPlayer pl
.setTextAlignment(Alignment.Center)
.setTextColor(Color.WHITE.normal)
.setSize(70, 18)
.setPos(3, 80+18)
.setPos(3, parent.getSize().height+18)
.setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD));


Expand Down Expand Up @@ -328,7 +328,16 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont

super.addUIWidgets(builder, buildContext);

}
} @Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setInteger("filter", filter);
super.saveNBTData(aNBT);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
filter =aNBT.getInteger("filter" );
super.loadNBTData(aNBT);
}
@Override
public NBTTagCompound getCopiedData(EntityPlayer player) {
return IDataCopyablePlaceHolderSuper.super.getCopiedData(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
Expand Down Expand Up @@ -48,6 +49,7 @@
import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
import com.gtnewhorizons.modularui.api.drawable.Text;
import com.gtnewhorizons.modularui.api.drawable.UITexture;
import com.gtnewhorizons.modularui.api.math.Alignment;
import com.gtnewhorizons.modularui.api.math.Color;
import com.gtnewhorizons.modularui.api.math.Pos2d;
Expand Down Expand Up @@ -139,9 +141,91 @@ public String[] getDescription() {
static private int _mDescriptionArray_offset;
static private int _mDescription_offset;

static Field f1,f2,f3;


static{
try {
f1=GT_MetaTileEntity_Hatch_InputBus_ME.class.getDeclaredField("shadowInventory");
f2=GT_MetaTileEntity_Hatch_InputBus_ME.class.getDeclaredField("savedStackSizes");
f3=GT_MetaTileEntity_Hatch_InputBus_ME.class.getDeclaredField("processingRecipe");
f1.
setAccessible(true);
f2.
setAccessible(true);
f3.setAccessible(true);
} catch (Exception e) {
e.printStackTrace();
}



}
public ItemStack[] shadowInventory(){
try {
return (ItemStack[]) f1.get(this);
} catch (Exception e) {
e.printStackTrace();
return null;
}

}
public int[] savedStackSizes(){
try {
return (int[]) f2.get(this);
} catch (Exception e) {
e.printStackTrace();
return null;
}

}
public boolean processingRecipe(){
try {
return (boolean) f3.get(this);
} catch (Exception e) {
e.printStackTrace();
return false;
}


}

@Override
public ItemStack getStackInSlot(int aIndex) {

ItemStack s= super.getStackInSlot(aIndex);
if(!processingRecipe()){return s;}
if(s==null)return null;
if(aIndex==getCircuitSlot())return s;
s=s.copy();
if(s!=null&&s.stackSize>restrict){
s.stackSize=restrict;
}
if(s!=null&&s.stackSize<restrict_lowbound){
s=null;
}
if(s!=null&&restrict_lowbound>0&&multiples==1){
s.stackSize=(s.stackSize/restrict_lowbound)*restrict_lowbound;
}
if(s!=null&&restrict_lowbound>0&&multiples==2){
// s.stackSize=(s.stackSize/restrict_lowbound)*restrict_lowbound;
s.stackSize=1<<(31-Integer.numberOfLeadingZeros(s.stackSize/restrict_lowbound));
s.stackSize*=restrict_lowbound;
}

//if(s.stackSize<0)s=null;

if(s!=null){
this.shadowInventory()[aIndex] = s;
this.savedStackSizes()[aIndex] = this.shadowInventory()[aIndex].stackSize;
this.setInventorySlotContents(aIndex + SLOT_COUNT, this.shadowInventory()[aIndex]);
return this.shadowInventory()[aIndex];
}else{
this.setInventorySlotContents(aIndex + SLOT_COUNT, null);

}
return s;
}


public ItemStack updateInformationSlot(int aIndex, ItemStack aStack) {
Expand Down Expand Up @@ -329,6 +413,7 @@ Widget createMultiplesModeButton(IWidgetBuilder<?> builder,int HEIGHT) {

Widget button = new CycleButtonWidget()
.setLength(3)
.setTextureGetter((I)->UITexture.EMPTY)
.addTooltip(
0,LangManager.translateToLocal("proghatches.restricted.multiples.exact"))
.addTooltip(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/proghatches/lang/en_US/SH.lang
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Programming Cover function integrated
Buffer: 1
For each buffer:
Capacity: 100,000,000L x24 types of fluid
16 Slots
4 Slots
Slot maximum stacksize:64
2 changes: 1 addition & 1 deletion src/main/resources/assets/proghatches/lang/zh_CN/SH.lang
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
自带编程覆盖板功能
缓冲数量: 1
缓冲容量: 100,000,000L x24种流体
16
4
每格堆叠限制:64

0 comments on commit d0d157f

Please sign in to comment.