mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7b65abfd8 | ||
|
|
19ae8891f6 | ||
|
|
03ac4a850a | ||
|
|
cfa2feab1c |
No files matched your search
@@ -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.sh
|
||||
.github/scripts/test-no-error-reports.sh
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
|
||||
secrets: inherit
|
||||
@@ -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
|
||||
@@ -20,6 +20,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
@@ -38,7 +39,6 @@ import forestry.core.EventHandlerCore;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
@@ -85,6 +85,7 @@ public class Forestry {
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
checkForCoFHLib();
|
||||
packetHandler = new PacketHandler();
|
||||
|
||||
// Register event handler
|
||||
@@ -158,4 +159,10 @@ public class Forestry {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkForCoFHLib() {
|
||||
if (!ModAPIManager.INSTANCE.hasAPI("CoFHAPI|energy")) {
|
||||
throw new RuntimeException("CoFHAPI|energy could not be found! This version of Forestry does not contain the RedstoneFlux API anymore, so you have to install either CoFHLib or CoFHCore.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,10 +110,37 @@ public abstract class RecipeUtil {
|
||||
// in place of the ones in the saved crafting inventory.
|
||||
// Check that the recipe it makes is the same as the currentRecipe.
|
||||
InventoryCraftingForestry crafting = new InventoryCraftingForestry();
|
||||
ItemStack[] stockCopy = ItemStackUtil.condenseStacks(availableItems);
|
||||
final ItemStack[] ingregients = RecipeUtil.getCraftIngredients(recipeItems, availableItems);
|
||||
|
||||
for (int slot = 0; slot < ingregients.length; slot++) {
|
||||
ItemStack recipeStack = ingregients[slot];
|
||||
|
||||
if (recipeStack == null && recipeItems[slot] != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (recipeStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
crafting.setInventorySlotContents(slot, recipeStack);
|
||||
}
|
||||
|
||||
List<ItemStack> outputs = findMatchingRecipes(crafting, world);
|
||||
if (!ItemStackUtil.containsItemStack(outputs, recipeOutput)) {
|
||||
return null;
|
||||
}
|
||||
return crafting;
|
||||
}
|
||||
|
||||
public static ItemStack[] getCraftIngredients(ItemStack[] recipeItems, ItemStack[] availableItems)
|
||||
{
|
||||
final ItemStack[] stockCopy = ItemStackUtil.condenseStacks(availableItems);
|
||||
final ItemStack[] ingredients = new ItemStack[recipeItems.length];
|
||||
|
||||
for (int slot = 0; slot < recipeItems.length; slot++) {
|
||||
ItemStack recipeStack = recipeItems[slot];
|
||||
|
||||
if (recipeStack == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -121,30 +148,26 @@ public abstract class RecipeUtil {
|
||||
// Use crafting equivalent (not oredict) items first
|
||||
for (ItemStack stockStack : stockCopy) {
|
||||
if (stockStack.stackSize > 0 && ItemStackUtil.isCraftingEquivalent(recipeStack, stockStack, false, false)) {
|
||||
ItemStack stack = ItemStackUtil.createSplitStack(stockStack, 1);
|
||||
ingredients[slot] = ItemStackUtil.createSplitStack(stockStack, 1);
|
||||
stockStack.stackSize--;
|
||||
crafting.setInventorySlotContents(slot, stack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Use oredict items if crafting equivalent items aren't available
|
||||
if (crafting.getStackInSlot(slot) == null) {
|
||||
if (ingredients[slot] == null) {
|
||||
for (ItemStack stockStack : stockCopy) {
|
||||
if (stockStack.stackSize > 0 && ItemStackUtil.isCraftingEquivalent(recipeStack, stockStack, true, true)) {
|
||||
ItemStack stack = ItemStackUtil.createSplitStack(stockStack, 1);
|
||||
ingredients[slot] = ItemStackUtil.createSplitStack(stockStack, 1);
|
||||
stockStack.stackSize--;
|
||||
crafting.setInventorySlotContents(slot, stack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
List<ItemStack> outputs = findMatchingRecipes(crafting, world);
|
||||
if (!ItemStackUtil.containsItemStack(outputs, recipeOutput)) {
|
||||
return null;
|
||||
}
|
||||
return crafting;
|
||||
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public static List<ItemStack> findMatchingRecipes(InventoryCrafting inventory, World world) {
|
||||
|
||||
@@ -12,18 +12,25 @@ package forestry.factory.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.buttons.GuiBetterButton;
|
||||
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.factory.gui.widgets.ClearWorktable;
|
||||
import forestry.factory.gui.widgets.MemorizedRecipeSlot;
|
||||
import forestry.factory.inventory.InventoryGhostCrafting;
|
||||
import forestry.factory.recipes.MemorizedRecipe;
|
||||
import forestry.factory.recipes.RecipeMemory;
|
||||
import forestry.factory.tiles.TileWorktable;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable> {
|
||||
private static final int SPACING = 18;
|
||||
private boolean hasRecipeConflict = false;
|
||||
@@ -62,6 +69,49 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float parTicks)
|
||||
{
|
||||
super.drawScreen(mouseX, mouseY, parTicks);
|
||||
|
||||
final Slot itemSlot = (Slot) inventorySlots.inventorySlots.get(54 + InventoryGhostCrafting.SLOT_CRAFTING_RESULT);
|
||||
|
||||
if (
|
||||
func_146978_c(itemSlot.xDisplayPosition, itemSlot.yDisplayPosition, 16, 16, mouseX, mouseY) &&
|
||||
!inventory.canTakeStack(InventoryGhostCrafting.SLOT_CRAFTING_RESULT)
|
||||
) {
|
||||
final MemorizedRecipe recipe = inventory.getCurrentRecipe();
|
||||
|
||||
if (recipe != null) {
|
||||
final ItemStack[] recipeItems = InventoryUtil.getStacks(recipe.getCraftMatrix());
|
||||
final ItemStack[] availableItems = InventoryUtil.getStacks(inventory);
|
||||
final ItemStack[] ingregients = RecipeUtil.getCraftIngredients(recipeItems, availableItems);
|
||||
|
||||
for (int slot = 0; slot < ingregients.length; slot++) {
|
||||
|
||||
if (ingregients[slot] == null && recipeItems[slot] != null) {
|
||||
renderSlotOverlay((Slot) inventorySlots.inventorySlots.get(54 + slot));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void renderSlotOverlay(final Slot slot) {
|
||||
final int left = guiLeft + slot.xDisplayPosition;
|
||||
final int top = guiTop + slot.yDisplayPosition;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(0, 0, 150);
|
||||
drawRect(left, top, left + 16, top + 16, 0x88ff0000);
|
||||
GL11.glTranslatef(0, 0, -150);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addButtons() {
|
||||
buttonList.add(new GuiBetterButton(0, guiLeft + 76, guiTop + 56, StandardButtonTextureSets.LEFT_BUTTON_SMALL));
|
||||
|
||||
Reference in new issue
Block a user