Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Sep 14, 2024
1 parent c8e858d commit 831278a
Show file tree
Hide file tree
Showing 17 changed files with 681 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.18p23'
String versionOverride = '0.0.18p24'
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
20 changes: 20 additions & 0 deletions src/main/java/reobf/proghatches/block/BlockReactorSyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@

import java.util.Random;

import com.gtnewhorizons.modularui.api.UIInfos;
import com.gtnewhorizons.modularui.common.internal.network.NetworkUtils;

import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;

public class BlockReactorSyncer extends BlockContainer{

Expand Down Expand Up @@ -88,6 +96,18 @@ public IIcon getIcon(int side, int meta) {
return Blocks.iron_block.getIcon(0, 0);
}

@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX,
float subY, float subZ) {


b: {
if (NetworkUtils.isClient())
break b;
UIInfos.TILE_MODULAR_UI.open(player, worldIn, x, y, z);
}

return true;
}

}
192 changes: 186 additions & 6 deletions src/main/java/reobf/proghatches/block/TileReactorSyncer.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
package reobf.proghatches.block;

import java.util.Arrays;
import java.util.function.Supplier;

import com.gtnewhorizons.modularui.api.ModularUITextures;
import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture;
import com.gtnewhorizons.modularui.api.drawable.IDrawable;
import com.gtnewhorizons.modularui.api.drawable.UITexture;
import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable;
import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget;
import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget;
import com.gtnewhorizons.modularui.common.widget.Scrollable;
import com.gtnewhorizons.modularui.common.widget.SlotGroup;
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
import com.gtnewhorizons.modularui.common.widget.TextWidget;
import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget;

import gregtech.api.gui.modularui.GT_UITextures;
import gregtech.api.gui.modularui.GUITextureSet;
import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric;
import ic2.core.block.reactor.tileentity.TileEntityReactorAccessHatch;
import ic2.core.block.reactor.tileentity.TileEntityReactorChamberElectric;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import reobf.proghatches.block.TileIOHub.UIFactory;
import reobf.proghatches.gt.metatileentity.util.MappingItemHandler;
import reobf.proghatches.main.MyMod;

public class TileReactorSyncer extends TileEntity{
public class TileReactorSyncer extends TileEntity implements ITileWithModularUI{


private boolean isDead;
Expand All @@ -22,13 +48,12 @@ public void validate() {
public void pretick(){
if((!isDead)&&(!isInvalid())){
TileEntityNuclearReactorElectric reactor=findTarget();
if(reactor!=null) tick=reactor.updateTicker%20;

//int new_power=(tick>5&&tick<15)?15:0;
int new_power=(tick!=0)?15:0;
if(reactor!=null)
tick=reactor.updateTicker%20;else tick=-1;

int new_power=tick!=-1?values[tick]:0;
if(power!=new_power){

//worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType);

worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, getBlockType()
, 0);
Expand Down Expand Up @@ -73,4 +98,159 @@ public void updateEntity() {
super.updateEntity();
isDead = false;
}


@Override
public ModularWindow createWindow(UIBuildContext buildContext) {
return new UIFactory(buildContext).createWindow();

}protected class UIFactory {

private final UIBuildContext uiBuildContext;

public UIFactory(UIBuildContext buildContext) {
this.uiBuildContext = buildContext;
}

public ModularWindow createWindow() {
ModularWindow.Builder builder = ModularWindow.builder(getGUIWidth(), getGUIHeight());
builder.setBackground(ModularUITextures.VANILLA_BACKGROUND);
// builder.setGuiTint(getUIBuildContext().getGuiColorization());
if (doesBindPlayerInventory())
builder.bindPlayerInventory(getUIBuildContext().getPlayer());

addTitleToUI(builder);
addUIWidgets(builder);

return builder.build();
}

/**
* Override this to add widgets for your UI.
*/

// IItemHandlerModifiable fakeInv=new ItemHandlerModifiable();

/**
* @param builderx
*/
/**
* @param builderx
*/
protected void addUIWidgets(ModularWindow.Builder builderx) {
Scrollable builder=new Scrollable().setHorizontalScroll();
for(int i=0;i<20;i++){



final int fi=i;
builder.widget(new TextFieldWidget()
.setGetterInt(()->values[fi])
.setSetterInt(s->{values[fi]=
Math.max(Math.min(s, 15),0);markDirty();
}

)

.setSynced(true,true)
.setPos(20*fi, 0)
.setSize(20,20)
.setBackground(GT_UITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)
));

builder.widget(new ButtonWidget()
.setOnClick((a,b)->{values[fi]=15;markDirty();})
.setBackground(GT_UITextures.BUTTON_STANDARD,GT_UITextures.OVERLAY_BUTTON_ARROW_GREEN_UP)
.setPos(20*fi, 40)
.setSize(20,20)
);
builder.widget(new ButtonWidget()
.setOnClick((a,b)->{values[fi]=0;markDirty();})
.setBackground(GT_UITextures.BUTTON_STANDARD,GT_UITextures.OVERLAY_BUTTON_ARROW_GREEN_DOWN)
.setPos(20*fi, 60)
.setSize(20,20)
);
builder.widget(new DrawableWidget().setDrawable(GT_UITextures.PICTURE_RADIATION_WARNING)
.setPos(0, 20)
.setSize(20,20)
);

builder.widget(new TextWidget(fi+"").setPos(20*fi+3, 60+20));




}

builder.setPos(3+20+20, 3)
.setSize(getGUIWidth()-6-40,80+10);
builderx
.widget(builder);
builderx.widget(TextWidget.localised("tile.reactor_syncer.info.rs").setPos(3, 3+10));
builderx.widget(TextWidget.localised("tile.reactor_syncer.info.update").setPos(3, 3+10+20));

builderx.widget(TextWidget.localised("tile.reactor_syncer.info.max").setPos(3, 3+10+40));
builderx.widget(TextWidget.localised("tile.reactor_syncer.info.min").setPos(3, 3+10+60));

}

public UIBuildContext getUIBuildContext() {
return uiBuildContext;
}

/*
* public boolean isCoverValid() { return !getUIBuildContext().getTile()
* .isDead() && getUIBuildContext().getTile()
* .getCoverBehaviorAtSideNew(getUIBuildContext().getCoverSide()) !=
* GregTech_API.sNoBehavior; }
*/

protected void addTitleToUI(ModularWindow.Builder builder) {
/*
* ItemStack coverItem =
* GT_Utility.intToStack(getUIBuildContext().getCoverID()); if
* (coverItem != null) { builder.widget( new
* ItemDrawable(coverItem).asWidget() .setPos(5, 5) .setSize(16,
* 16)) .widget( new
* TextWidget(coverItem.getDisplayName()).setDefaultColor(
* COLOR_TITLE.get()) .setPos(25, 9)); }
*/
}

protected int getGUIWidth() {
return 176;
}

protected int getGUIHeight() {
return 107 + 18 * 3 + 18;
}

protected boolean doesBindPlayerInventory() {
return true;
}

protected int getTextColorOrDefault(String textType, int defaultColor) {
return defaultColor;
}

protected final Supplier<Integer> COLOR_TITLE = () -> getTextColorOrDefault("title", 0x222222);
protected final Supplier<Integer> COLOR_TEXT_GRAY = () -> getTextColorOrDefault("text_gray", 0x555555);
protected final Supplier<Integer> COLOR_TEXT_WARN = () -> getTextColorOrDefault("text_warn", 0xff0000);
}
int[] values=new int[20];

@Override
public void writeToNBT(NBTTagCompound compound) {
for(int i=0;i<20;i++){
compound.setInteger("##"+i, values[i]);
}
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
for(int i=0;i<20;i++){
values[i]=compound.getInteger("##"+i );
}
super.readFromNBT(compound);
}
}
9 changes: 5 additions & 4 deletions src/main/java/reobf/proghatches/eucrafting/AECover.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import gregtech.api.util.GT_CoverBehaviorBase;
import gregtech.api.util.ISerializableObject;
import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_AssemblyLine;
import gregtech.crossmod.waila.GregtechWailaDataProvider;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -222,7 +223,7 @@ public TileEntity fakeTile() {
return null;
}
}
static int h0="gregtech.crossmod.waila.GregtechWailaDataProvider".hashCode();
static int h0=GregtechWailaDataProvider.class.getName().hashCode();
public static interface Data extends ISerializableObject, IGridProxyable {


Expand All @@ -242,11 +243,11 @@ default public boolean isWailaCall(){
return getNBTData;
}else{
String s=StackTraceUtil.getCallerMethod(6);
if (s.hashCode()==h0&&s.equals("gregtech.crossmod.waila.GregtechWailaDataProvider")) {
if (s.hashCode()==h0&&s.equals(GregtechWailaDataProvider.class.getName())) {
return true;
}
s=StackTraceUtil.getCallerMethod(5);
if (s.hashCode()==h0&&s.equals("gregtech.crossmod.waila.GregtechWailaDataProvider")) {
if (s.hashCode()==h0&&s.equals(GregtechWailaDataProvider.class.getName())) {
return true;
}
}
Expand Down Expand Up @@ -594,7 +595,7 @@ public Data createDataObject() {
if(getWailaBody){ return new DummyData();}
}else{
String s=StackTraceUtil.getCallerMethod(6);
if(s.hashCode()==h0&&s.equals("gregtech.crossmod.waila.GregtechWailaDataProvider")){
if(s.hashCode()==h0&&s.equals(GregtechWailaDataProvider.class.getName())){

// do not actually load cover data on client side
// or there'll be some performance issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class PatternDualInputHatchInventoryMappingSlave<T extends DualInputHatch
public PatternDualInputHatchInventoryMappingSlave(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 0,

Config.get("DIHIMS", ImmutableMap.of()));
Config.get("PDIHIMS", ImmutableMap.of()));
Registration.items.add(new ItemStack(GregTech_API.sBlockMachines, 1, aID));
}

Expand Down Expand Up @@ -952,6 +952,14 @@ public int getGUIHeight() {

return super.getGUIHeight() + 20;
}

@Override
public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer,
float aX, float aY, float aZ) {
additionalConnection = !additionalConnection;
updateValidGridProxySides();
aPlayer.addChatComponentMessage(
new ChatComponentTranslation("GT5U.hatch.additionalConnection." + additionalConnection));
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,21 @@ public ItemStack getCrafterIcon() {
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
tag.setBoolean("disabled", disabled);
for(int i=0;i<((IInventory)tile).getSizeInventory();i++)
{ItemStack is = ((IInventory)tile).getStackInSlot(i);
if(is!=null)
tag.setTag("#"+i,is.writeToNBT(new NBTTagCompound()) );;
}
super.getWailaNBTData(player, tile, tag, world, x, y, z);
}

@Override
public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {

for(int i=0;i<((IInventory) accessor.getTileEntity()).getSizeInventory();i++)
currenttip.add(StatCollector.translateToLocal("proghatches.provider.waila")
+ Optional.ofNullable(((IInventory) accessor.getTileEntity()).getStackInSlot(i))
+ Optional.ofNullable(ItemStack.loadItemStackFromNBT(accessor.getNBTData().getCompoundTag("#"+i)))
.map(s -> s.getDisplayName() + "@" + s.getItemDamage()).orElse("<empty>")

);
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/reobf/proghatches/main/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,19 @@ public static void get(GT_Multiblock_Tooltip_Builder obj, String key, boolean de
String func = str.substring(0, a0);
String args = str.substring(a0 + 1, a1);
String type = str.substring(a1 + 1 + 2, str.length());


MethodType tp = MethodType.fromMethodDescriptorString(

type + (func.equals("toolTipFinisher") ? "V"
: "Lgregtech/api/util/GT_Multiblock_Tooltip_Builder;")
: "L"+GT_Multiblock_Tooltip_Builder.class.getName().replace(".", "/")+";")

, Config.class.getClassLoader());
call(obj, args, MethodHandles.lookup().findVirtual(GT_Multiblock_Tooltip_Builder.class, func, tp), tp);





}

} catch (Exception e) {
Expand Down
Loading

0 comments on commit 831278a

Please sign in to comment.