Compare commits

..
9 Commits
Author SHA1 Message Date
Martin Robertz f70615c5cf Merge pull request #20 from GTNewHorizons/craft-amount
Port GuiCraftAmount features from AE2
2022-07-30 22:58:08 +07:00
miozune 9f39b6bd16 assign 2022-07-30 23:26:24 +09:00
miozune 0ea8f5fb41 spotlessApply 2022-07-30 20:26:00 +09:00
miozune 0a78cf9e0f extract common code 2022-07-30 20:22:49 +09:00
miozune b1f4b996be forgot these... 2022-07-29 23:45:06 +09:00
miozune ecd019b999 Port GuiCraftAmount features from AE2 2022-07-29 23:43:34 +09:00
Martin Robertz d38b4ff271 Merge pull request #19 from GTNewHorizons/feature/BoosterCheck
null check
2022-07-28 17:54:35 +07:00
repo_alt 69fffdcf00 null check 2022-07-28 14:19:36 +04:00
Jason Mitchell aeb9b6e35a [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:52:14 -07:00
5 changed files with 51 additions and 151 deletions

No files matched your search

+2 -34
View File
@@ -1,5 +1,3 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test
@@ -11,35 +9,5 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1.5 minutes
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
- name: Test no errors reported during server run
run: |
chmod +x .github/scripts/test_no_error_reports
.github/scripts/test_no_error_reports
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+7 -44
View File
@@ -1,51 +1,14 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build
on:
push:
tags:
- '*'
tags: [ '*' ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
- name: Publish to Maven
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+1 -1
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev")
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-91-GTNH:dev")
compile("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
compile("curse.maven:cofh-core-69162:2388751")
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev")
@@ -4,11 +4,13 @@ import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.helpers.Reflected;
import appeng.util.calculators.ArithHelper;
import appeng.util.calculators.Calculator;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
@@ -22,7 +24,7 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class GuiCraftAmount extends WCTBaseGui {
private GuiNumberBox amountToCraft;
private GuiTextField amountToCraft;
private GuiTabButton originalGuiBtn;
private GuiButton next;
@@ -84,19 +86,15 @@ public class GuiCraftAmount extends WCTBaseGui {
this.guiLeft + 154, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToCraft = new GuiNumberBox(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT,
Integer.class);
this.amountToCraft = new GuiTextField(
this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible(true);
this.amountToCraft.setFocused(true);
this.amountToCraft.setText("1");
this.amountToCraft.setSelectionPos(0);
}
@Override
@@ -112,8 +110,13 @@ public class GuiCraftAmount extends WCTBaseGui {
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
try {
Long.parseLong(this.amountToCraft.getText());
this.next.enabled = this.amountToCraft.getText().length() > 0;
String out = this.amountToCraft.getText();
double resultD = Calculator.conversion(out);
int resultI = roundDouble(resultD);
this.next.enabled = resultI > 0;
} catch (final NumberFormatException e) {
this.next.enabled = false;
}
@@ -127,40 +130,8 @@ public class GuiCraftAmount extends WCTBaseGui {
if (key == 28) {
this.actionPerformed(this.next);
}
if ((key == 211
|| key == 205
|| key == 203
|| key == 14
|| character == '-'
|| Character.isDigit(character))
&& this.amountToCraft.textboxKeyTyped(character, key)) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if (fixed) {
this.amountToCraft.setText(out);
}
if (out.isEmpty()) {
out = "0";
}
final long result = Long.parseLong(out);
if (result < 0) {
this.amountToCraft.setText("1");
}
} catch (final NumberFormatException e) {
// :P
}
} else {
super.keyTyped(character, key);
}
this.amountToCraft.textboxKeyTyped(character, key);
super.keyTyped(character, key);
}
}
@@ -174,9 +145,12 @@ public class GuiCraftAmount extends WCTBaseGui {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
}
if (btn == this.next) {
NetworkHandler.instance.sendToServer(
new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
if (btn == this.next && btn.enabled) {
double resultD = Calculator.conversion(this.amountToCraft.getText());
int resultI = roundDouble(resultD);
NetworkHandler.instance.sendToServer(new PacketCraftRequest(resultI, isShiftKeyDown()));
}
} catch (final NumberFormatException e) {
// nope..
@@ -196,33 +170,20 @@ public class GuiCraftAmount extends WCTBaseGui {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
double resultD = Calculator.conversion(out);
int resultI = roundDouble(resultD);
if (resultI == 1 && i > 1) {
resultI = 0;
}
if (fixed) {
this.amountToCraft.setText(out);
resultI += i;
if (resultI < 1) {
resultI = 1;
}
if (out.isEmpty()) {
out = "0";
}
long result = Integer.parseInt(out);
if (result == 1 && i > 1) {
result = 0;
}
result += i;
if (result < 1) {
result = 1;
}
out = Long.toString(result);
Integer.parseInt(out);
out = Integer.toString(resultI);
this.amountToCraft.setText(out);
} catch (final NumberFormatException e) {
// :P
@@ -232,4 +193,12 @@ public class GuiCraftAmount extends WCTBaseGui {
protected String getBackground() {
return "guis/craftAmt.png";
}
private int roundDouble(double num) {
if (num <= 0 || Double.isNaN(num)) {
return 0;
} else {
return (int) ArithHelper.round(num, 0);
}
}
}
@@ -262,7 +262,7 @@ public class WirelessTerminalGuiObject implements IActionHost, IPortableCell, II
// return this.getTargetGrid().getPivot();
return this.myWap.getActionableNode();
} else {
if (ignoreRange) {
if (ignoreRange && this.getTargetGrid() != null) {
return this.getTargetGrid().getPivot();
}
}