Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Sep 26, 2024
1 parent e746be4 commit b395fec
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 12 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.19p2'
String versionOverride = '0.0.19p3'
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
75 changes: 71 additions & 4 deletions src/main/java/reobf/proghatches/block/TileReactorSyncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
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.forge.PlayerMainInvWrapper;
import com.gtnewhorizons.modularui.api.math.Pos2d;
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.internal.wrapper.BaseSlot;
import com.gtnewhorizons.modularui.common.widget.ButtonWidget;
import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget;
import com.gtnewhorizons.modularui.common.widget.DrawableWidget;
import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget;
import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget;
Expand All @@ -23,14 +27,17 @@

import gregtech.api.gui.modularui.GT_UITextures;
import gregtech.api.gui.modularui.GUITextureSet;
import gregtech.common.gui.modularui.widget.CoverCycleButtonWidget;
import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric;
import ic2.core.block.reactor.tileentity.TileEntityReactorAccessHatch;
import ic2.core.block.reactor.tileentity.TileEntityReactorChamberElectric;
import net.minecraft.entity.player.EntityPlayer;
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.lang.LangManager;
import reobf.proghatches.main.MyMod;

public class TileReactorSyncer extends TileEntity implements ITileWithModularUI{
Expand All @@ -44,14 +51,19 @@ public void validate() {
MyMod.callbacks.put(this,this::pretick);
}


boolean skipCycleZero;
public void pretick(){
if((!isDead)&&(!isInvalid())){
TileEntityNuclearReactorElectric reactor=findTarget();

if(reactor!=null)
tick=reactor.updateTicker%20;else tick=-1;

int new_power=tick!=-1?values[tick]:0;
if(cycles==0&&skipCycleZero){
new_power=0;
}
if(tick==0)cycles++;
if(power!=new_power){


Expand All @@ -61,6 +73,7 @@ public void pretick(){
}

power=new_power;

}
}

Expand All @@ -86,9 +99,15 @@ public TileEntityNuclearReactorElectric findTarget(){
return null;
}

int cycles;
@Override
public void invalidate() {
cycles=0;
super.invalidate();
}
@Override
public void onChunkUnload() {
cycles=0;
super.onChunkUnload();
isDead = true;
}
Expand All @@ -99,7 +118,30 @@ public void updateEntity() {
isDead = false;
}

public static SlotGroup playerHotBarGroup(EntityPlayer player, IDrawable background) {
PlayerMainInvWrapper wrapper = new PlayerMainInvWrapper(player.inventory);
SlotGroup slotGroup = new SlotGroup();

/* for (int row = 0; row < 3; row++) {
for (int col = 0; col < 9; col++) {
SlotWidget slot = new SlotWidget(new BaseSlot(wrapper, col + (row + 1) * 9))
.setPos(new Pos2d(col * 18, row * 18));
slotGroup.addSlot(slot);
if (background != null) {
slot.setBackground(background);
}
}
}*/

for (int i = 0; i < 9; i++) {
SlotWidget slot = new SlotWidget(new BaseSlot(wrapper, i)).setPos(new Pos2d(i * 18, 0));
slotGroup.addSlot(slot);
if (background != null) {
slot.setBackground(background);
}
}
return slotGroup;
}
@Override
public ModularWindow createWindow(UIBuildContext buildContext) {
return new UIFactory(buildContext).createWindow();
Expand All @@ -117,7 +159,12 @@ public ModularWindow createWindow() {
builder.setBackground(ModularUITextures.VANILLA_BACKGROUND);
// builder.setGuiTint(getUIBuildContext().getGuiColorization());
if (doesBindPlayerInventory())
builder.bindPlayerInventory(getUIBuildContext().getPlayer());
{
builder.widget(playerHotBarGroup(uiBuildContext.getPlayer(), null)
.setPos(new Pos2d(3, getGUIHeight()-18-3)));
// builder.bindPlayerInventory(null)

}

addTitleToUI(builder);
addUIWidgets(builder);
Expand All @@ -138,6 +185,24 @@ public ModularWindow createWindow() {
* @param builderx
*/
protected void addUIWidgets(ModularWindow.Builder builderx) {

builderx.widget(((CycleButtonWidget) new CoverCycleButtonWidget().setSynced(false, true))
.setGetter(() -> skipCycleZero ? 1 : 0).setSetter(s ->skipCycleZero = s == 1).setLength(2)
.setTextureGetter(i -> {
if (i == 1)
return GT_UITextures.OVERLAY_BUTTON_EXPORT;
return GT_UITextures.OVERLAY_BUTTON_IMPORT;
})

.addTooltip(1, LangManager.translateToLocal("tile.reactor_syncer.skip.true"))
.addTooltip(0, LangManager.translateToLocal("tile.reactor_syncer.skip.false"))
.addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.0"))
.addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.1"))
.addTooltip( LangManager.translateToLocal("tile.reactor_syncer.skip.2"))
.setPos(3, getGUIHeight()-60)

);

Scrollable builder=new Scrollable().setHorizontalScroll();
for(int i=0;i<20;i++){

Expand Down Expand Up @@ -244,13 +309,15 @@ public void writeToNBT(NBTTagCompound compound) {
for(int i=0;i<20;i++){
compound.setInteger("##"+i, values[i]);
}
compound.setBoolean("skipCycleZero",skipCycleZero);
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
for(int i=0;i<20;i++){
values[i]=compound.getInteger("##"+i );
}
skipCycleZero=compound.getBoolean("skipCycleZero");
super.readFromNBT(compound);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus,
Iterator<IAEItemStack> itr = itemCache.iterator();
//if(check!=null)
while(itr.hasNext()){IAEItemStack next;
if((next=itr.next()).isSameType(check)==false){
if((next=itr.next()).isSameType(check)==false&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("cache.diff.bus.null",index,cp(next));
return TransferCheckResult.ofFail("cache.diff.bus",index,cp(next),cp(check));
Expand All @@ -749,7 +749,7 @@ private TransferCheckResult checkMEBus(GT_MetaTileEntity_Hatch_OutputBus_ME bus,
itr = bus.getProxy().getStorage().getItemInventory().getStorageList().iterator();
//if(check!=null)
while(itr.hasNext()){IAEItemStack next;
if((next=itr.next()).isSameType(check)==false){
if((next=itr.next()).isSameType(check)==false&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("net.diff.bus.null",index,cp(next));
return TransferCheckResult.ofFail("net.diff.bus",index,cp(next),cp(check));
Expand Down Expand Up @@ -787,7 +787,7 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F
Iterator<IAEFluidStack> itr = itemCache.iterator();
//if(check!=null)
while(itr.hasNext()){IAEFluidStack next;
if(!sameType(next=itr.next(),(check))){
if(!sameType(next=itr.next(),(check))&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next));
return TransferCheckResult.ofFail("cache.diff.hatch",index,cp(next),cp(check));
Expand All @@ -797,7 +797,7 @@ private TransferCheckResult checkMEHatch(GT_MetaTileEntity_Hatch_Output_ME bus,F
itr = bus.getProxy().getStorage().getFluidInventory().getStorageList().iterator();
//if(check!=null)
while(itr.hasNext()){IAEFluidStack next;
if(!sameType(next=itr.next(),(check))){
if(!sameType(next=itr.next(),(check))&&next.getStackSize()>0){
if(check==null)
return TransferCheckResult.ofFail("net.diff.hatch.null",index,cp(next));
return TransferCheckResult.ofFail("net.diff.hatch",index,cp(next),cp(check));
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/reobf/proghatches/main/MyMod.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package reobf.proghatches.main;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.net.Proxy;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.function.BiConsumer;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -54,6 +62,8 @@
import com.glodblock.github.crossmod.opencomputers.DriverLevelMaintainer;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.gtnewhorizon.structurelib.alignment.constructable.IMultiblockInfoContainer;

import appeng.api.AEApi;
Expand Down Expand Up @@ -86,6 +96,7 @@
import appeng.util.item.AEItemStack;
import appeng.util.item.ItemList;
import codechicken.multipart.MultipartGenerator;
import codechicken.nei.recipe.StackInfo;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
Expand Down Expand Up @@ -150,6 +161,7 @@
import reobf.proghatches.oc.ItemGTRedstoneCard;
import reobf.proghatches.oc.WirelessPeripheralManager;
import reobf.proghatches.util.ProghatchesUtil;

import tconstruct.armor.player.TPlayerStats;
import thaumcraft.common.entities.golems.ItemGolemCore;

Expand Down Expand Up @@ -249,10 +261,16 @@ public void preInit(FMLPreInitializationEvent event) {

public static Map<Object, Class> OCApi = new HashMap<>();

/**
* @param event
*/
@Mod.EventHandler

public void init(FMLInitializationEvent event) {
proxy.init(event);



AEApi.instance().partHelper().registerNewLayer("reobf.proghatches.fmp.LazerLayer",
"reobf.proghatches.eucrafting.ILazer");

Expand Down Expand Up @@ -348,6 +366,8 @@ public void join(PlayerLoggedInEvent e) {

public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);


// Api.INSTANCE.registries().p2pTunnel().addNewAttunement(null, null);
// ShutDownReasonRegistry.register(ACCESS_LOOP);
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public List<String> getMixins() {
retLate.add("MixinStorageChangeEvent");
retLate.add("MixinOptimize");
retLate.add("part2.MixinIsWailaCall");
retLate.add("part2.MixinPresetsInject");
retLate.add("part2.MixinOC");
retLate.add("part2.MixinRecursiveSlotClickProtection");
retLate.add("part2.MixinMultiPattern");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.CoverableTileEntity;
import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;

@Mixin(value=BaseMetaPipeEntity.class,remap=false,priority=999)
public class MixinFixPipeCoverBug {
public class MixinFixPipeCoverBug{


ForgeDirection realSide;

@Inject(remap=false,method="onRightclick",at=@At(value="INVOKE",target =
"onPlayerAttach"))
public void onRightclick0(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ,CallbackInfoReturnable<Boolean> cc) {

realSide=side;
if(((CoverableTileEntity)(Object)this).getCoverIDAtSide(side) == 0)
realSide=GT_Utility.determineWrenchingSide(side, aX, aY, aZ);

}
Expand Down
Loading

0 comments on commit b395fec

Please sign in to comment.