Skip to content

Commit

Permalink
make it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueWeabo committed Dec 27, 2023
1 parent a32ee83 commit bfb06f3
Show file tree
Hide file tree
Showing 11 changed files with 550 additions and 214 deletions.
23 changes: 22 additions & 1 deletion src/main/java/gregtech/api/gui/GUIHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;

import net.minecraft.item.ItemStack;

public interface GUIHost extends ITileWithModularUI {

@Nonnull
Expand All @@ -27,10 +29,29 @@ default int getWidth() {
}

default int getHeight() {
return 100;
return 192;
}

@Nonnull
GUIProvider<?> getGUI(@Nonnull UIBuildContext uiContext);

ItemStack getAsItem();

String getMachineName();

default boolean hasItemInput() {
return true;
}

default boolean hasItemOutput() {
return true;
}

default boolean hasFluidInput() {
return true;
}

default boolean hasFluidOutput() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public interface IMachineProgress extends IHasWorldObjectAndCoords {
*/
boolean isAllowedToWork();

default void setAllowedToWork(Boolean allowedToWork) {
if (allowedToWork) {
enableWorking();
} else {
disableWorking();
}
}

/**
* used to control Machines via Redstone Signal Strength by special Covers In case of 0 the Machine is very likely
* doing nothing, or is just not being controlled at all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,40 @@ public interface ProcessingLogicHost<P extends MuTEProcessingLogic<P>>

boolean isInputSeparated();

void setInputSeparation(Boolean inputSeparation);

default boolean supportsInputSeparation() {
return true;
}

default boolean getDefaultInputSeparationMode() {
return false;
}

boolean isRecipeLockingEnabled();

void setRecipeLocking(Boolean recipeLocked);

default boolean supportsSingleRecipeLocking() {
return true;
}

default boolean getDefaultRecipeLockingMode() {
return false;
}

default boolean supportsBatchMode() {
return true;
}

void setBatchMode(Boolean batchMode);

boolean isBatchModeEnabled();

default boolean getDefaultBatchMode() {
return false;
}

/**
* Get what the machine can void or not
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,19 +656,19 @@ public void setBooleans(int booleans) {
setActive((booleans & ACTIVE) == ACTIVE);
}

protected boolean hasItemInput() {
public boolean hasItemInput() {
return true;
}

protected boolean hasItemOutput() {
public boolean hasItemOutput() {
return true;
}

protected boolean hasFluidInput() {
public boolean hasFluidInput() {
return true;
}

protected boolean hasFluidOutput() {
public boolean hasFluidOutput() {
return true;
}

Expand Down Expand Up @@ -789,4 +789,16 @@ protected GUIProvider<?> createGUIProvider() {
public GUIProvider<?> getGUI(@Nonnull UIBuildContext uiContext) {
return guiProvider;
}

@Override
public ItemStack getAsItem() {
return MultiTileEntityRegistry.getRegistry(getMultiTileEntityRegistryID()).getItem(getMultiTileEntityID());
}

@Override
public String getMachineName() {
return StatCollector.translateToLocal(getAsItem().getUnlocalizedName());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
*/
public abstract class Controller<C extends Controller<C, P>, P extends MuTEProcessingLogic<P>>
extends MultiTileBasicMachine<P> implements IAlignment, IMultiBlockController, IDescribable,
IMTE_AddToolTips, ISurvivalConstructable, ControllerWithOptionalFeatures {
IMTE_AddToolTips, ISurvivalConstructable {

public static final String ALL_INVENTORIES_NAME = "all";
protected static final int AUTO_OUTPUT_FREQUENCY_TICK = 20;
Expand Down Expand Up @@ -915,171 +915,6 @@ protected void addTitleTextStyle(ModularWindow.Builder builder, String title) {
// leave empty
}

@Override
public int getGUIHeight() {
return 192;
}

protected Widget getGregTechLogo() {
return new DrawableWidget().setDrawable(getGUITextureSet().getGregTechLogo())
.setSize(17, 17);
}

@Override
public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
if (isServerSide()) {
for (UpgradeCasing tPart : upgradeCasings) {
if (!(tPart instanceof Inventory)) continue;
tPart.issueClientUpdate();
}
}
int page = 0;
TabContainer tabs = new TabContainer().setButtonSize(20, 24);
tabs.addTabButton(
new TabButton(page++)
.setBackground(
false,
ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0, 1f, 0.5f),
new ItemDrawable(getStackForm(1)).withFixedSize(16, 16)
.withOffset(2, 4))
.setBackground(
true,
ModularUITextures.VANILLA_TAB_TOP_START.getSubArea(0, 0.5f, 1f, 1f),
new ItemDrawable(getStackForm(1)).withFixedSize(16, 16)
.withOffset(2, 4))
.addTooltip(getLocalName())
.setPos(20 * (page - 1), -20))
.addPage(createMainPage(builder).setSize(getGUIWidth(), getGUIHeight()));
if (hasItemInput()) {
tabs.addTabButton(
new TabButton(page++)
.setBackground(
false,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f),
GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16)
.withOffset(2, 4))
.setBackground(
true,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f),
GT_UITextures.PICTURE_ITEM_IN.withFixedSize(16, 16)
.withOffset(2, 4))
.addTooltip("Item Input Inventory")
.setPos(20 * (page - 1), -20))
.addPage(
new MultiChildWidget().addChild(
controllerItemInput.getAllInventoryLogics()
.getGuiPart()
.setSize(18 * 4 + 4, 18 * 5)
.setPos(52, 7))
.addChild(getGregTechLogo().setPos(147, 86))
.setSize(getGUIWidth(), getGUIHeight()));
}

if (hasItemOutput()) {
tabs.addTabButton(
new TabButton(page++)
.setBackground(
false,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f),
GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16)
.withOffset(2, 4))
.setBackground(
true,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f),
GT_UITextures.PICTURE_ITEM_OUT.withFixedSize(16, 16)
.withOffset(2, 4))
.addTooltip("Item Output Inventory")
.setPos(20 * (page - 1), -20))
.addPage(
new MultiChildWidget().addChild(
controllerItemOutput.getAllInventoryLogics()
.getGuiPart()
.setSize(18 * 4 + 4, 18 * 5)
.setPos(52, 7))
.addChild(getGregTechLogo().setPos(147, 86))
.setSize(getGUIWidth(), getGUIHeight()));
}

if (hasFluidInput()) {
tabs.addTabButton(
new TabButton(page++)
.setBackground(
false,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f),
GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16)
.withOffset(2, 4))
.setBackground(
true,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f),
GT_UITextures.PICTURE_FLUID_IN.withFixedSize(16, 16)
.withOffset(2, 4))
.addTooltip("Fluid Input Tanks")
.setPos(20 * (page - 1), -20))
.addPage(
new MultiChildWidget().addChild(
controllerFluidInput.getAllInventoryLogics()
.getGuiPart()
.setSize(18 * 4 + 4, 18 * 5)
.setPos(52, 7))
.addChild(getGregTechLogo().setPos(147, 86))
.setSize(getGUIWidth(), getGUIHeight()));
}

if (hasFluidOutput()) {
tabs.addTabButton(
new TabButton(page++)
.setBackground(
false,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0, 1f, 0.5f),
GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16)
.withOffset(2, 4))
.setBackground(
true,
ModularUITextures.VANILLA_TAB_TOP_MIDDLE.getSubArea(0, 0.5f, 1f, 1f),
GT_UITextures.PICTURE_FLUID_OUT.withFixedSize(16, 16)
.withOffset(2, 4))
.addTooltip("Fluid Output Tanks")
.setPos(20 * (page - 1), -20))
.addPage(
new MultiChildWidget().addChild(
controllerFluidOutput.getAllInventoryLogics()
.getGuiPart()
.setSize(18 * 4 + 4, 18 * 5)
.setPos(52, 7))
.addChild(getGregTechLogo().setPos(147, 86))
.setSize(getGUIWidth(), getGUIHeight()));
}
builder.widget(tabs);
}

protected MultiChildWidget createMainPage(IWidgetBuilder<?> builder) {
MultiChildWidget page = new MultiChildWidget();
page.addChild(
new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK)
.setPos(7, 4)
.setSize(160, 75))
.addChild(createButtons(builder));
return page;
}

protected MultiChildWidget createButtons(IWidgetBuilder<?> builder) {
MultiChildWidget buttons = new MultiChildWidget();
buttons.setSize(16, 167)
.setPos(7, 86);
buttons.addChild(createPowerSwitchButton(builder))
.addChild(createVoidExcessButton(builder))
.addChild(createInputSeparationButton(builder))
.addChild(createBatchModeButton(builder))
.addChild(createLockToSingleRecipeButton(builder));

return buttons;
}

@Override
public Pos2d getPowerSwitchButtonPos() {
return new Pos2d(144, 0);
}

@Override
public boolean supportsVoidProtection() {
return true;
Expand All @@ -1105,31 +940,21 @@ public boolean canDumpFluidToME() {
return false;
}

@Override
public Pos2d getVoidingModeButtonPos() {
return new Pos2d(54, 0);
}

@Override
public boolean supportsInputSeparation() {
return true;
}

@Override
public boolean isInputSeparationEnabled() {
public boolean isInputSeparated() {
return separateInputs;
}

@Override
public void setInputSeparation(boolean enabled) {
public void setInputSeparation(Boolean enabled) {
this.separateInputs = enabled;
}

@Override
public Pos2d getInputSeparationButtonPos() {
return new Pos2d(36, 0);
}

@Override
public boolean supportsBatchMode() {
return true;
Expand All @@ -1141,15 +966,10 @@ public boolean isBatchModeEnabled() {
}

@Override
public void setBatchMode(boolean mode) {
public void setBatchMode(Boolean mode) {
this.batchMode = mode;
}

@Override
public Pos2d getBatchModeButtonPos() {
return new Pos2d(18, 0);
}

@Override
public boolean supportsSingleRecipeLocking() {
return false;
Expand All @@ -1161,20 +981,10 @@ public boolean isRecipeLockingEnabled() {
}

@Override
public void setRecipeLocking(boolean enabled) {
public void setRecipeLocking(Boolean enabled) {
this.recipeLock = enabled;
}

@Override
public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return null;
}

@Override
public Pos2d getRecipeLockingButtonPos() {
return new Pos2d(0, 0);
}

@Override
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
Expand Down
Loading

0 comments on commit bfb06f3

Please sign in to comment.