Compare commits

..
7 Commits
Author SHA1 Message Date
glowredman c7b65abfd8 Cofh dep (#24)
* Revert "Make CoFHCore required (#23)"

This reverts commit 03ac4a850a.

* throw exception if CoFHAPI|energy could not be found

* spaces -> tabs
2022-07-31 09:48:07 +02:00
Jason Mitchell 19ae8891f6 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:48:13 -07:00
Jakub 03ac4a850a Make CoFHCore required (#23) 2022-07-15 23:12:07 +01:00
slprime cfa2feab1c Highlight missing item in worktable (#22)
* highlight missing item in worktable

* fix crash without recipe
2022-06-29 22:59:03 +02:00
DianeXD 06baad945a Add overlay identifier (#21)
* Add overlay identifier

* Use recipeID
2022-06-03 13:37:08 +02:00
Jakub Szewczyk 14f61b5917 Fix planting in wrong dimension (#20)
* Update buildscript

* Pass the world object directly to avoid using the wrong dimension
2022-04-27 11:21:57 +02:00
Glease b58e4c57c7 Drastically reduce getBlock calls in orchard mode (#19)
* Drastically reduce getBlock calls in orchard mode

* improve caching
2022-03-26 15:55:35 +01:00
21 changed files with 254 additions and 191 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.sh
.github/scripts/test-no-error-reports.sh
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
+46 -30
View File
@@ -1,4 +1,4 @@
//version: 1644612407
//version: 1650343995
/*
DO NOT CHANGE THIS FILE!
@@ -6,12 +6,11 @@ Also, you may replace this file at any time if there is an update available.
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import org.gradle.internal.logging.text.StyledTextOutput
import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.gradle.internal.logging.text.StyledTextOutput.Style
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.internal.logging.text.StyledTextOutput.Style
import org.gradle.internal.logging.text.StyledTextOutputFactory
import java.util.concurrent.TimeUnit
@@ -51,7 +50,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
}
if (project.file('.git/HEAD').isFile()) {
@@ -104,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
@@ -175,7 +175,7 @@ configurations.all {
try {
'git config core.fileMode false'.execute()
}
catch (Exception e) {
catch (Exception ignored) {
out.style(Style.Failure).println("git isn't installed at all")
}
@@ -185,7 +185,7 @@ String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception e) {
catch (Exception ignored) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
@@ -199,7 +199,7 @@ ext {
modVersion = identifiedVersion
}
if( identifiedVersion.equals(versionOverride) ) {
if(identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
@@ -214,13 +214,17 @@ else {
def arguments = []
def jvmArguments = []
if(usesMixins.toBoolean()) {
if (usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
jvmArguments += [
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
if (usesMixinDebug.toBoolean()) {
jvmArguments += [
"-Dmixin.debug.countInjections=true",
"-Dmixin.debug.verbose=true",
"-Dmixin.debug.export=true"
]
}
}
minecraft {
@@ -312,18 +316,23 @@ def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfig
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
if (usesMixins.toBoolean()) {
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
if (!mixinConfigFile.exists()) {
mixinConfigFile.text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
"""
}
}
}
@@ -439,7 +448,7 @@ processResources {
def getManifestAttributes() {
def manifestAttributes = [:]
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
@@ -455,14 +464,14 @@ def getManifestAttributes() {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (sourceSets.main.allSource)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
@@ -517,7 +526,7 @@ task devJar(type: Jar) {
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
from (sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
@@ -548,6 +557,9 @@ tasks.withType(GenerateModuleMetadata) {
enabled = false
}
// workaround variable hiding in pom processing
def projectConfigs = project.configurations
publishing {
publications {
maven(MavenPublication) {
@@ -556,7 +568,7 @@ publishing {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
@@ -568,16 +580,20 @@ publishing {
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
// remove extra garbage from who knows where
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang',
'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents',
'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava',
'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j',
'org.lwjgl.lwjgl', 'tv.twitch', 'org.jetbrains.kotlin', '']
def badArtifacts = [:].withDefault {[] as Set<String>}
for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) {
for (dependency in configuration.allDependencies) {
badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
}
}
// example for specifying extra stuff to ignore
// badArtifacts["org.example.group"] += "artifactName"
Node pomNode = asNode()
pomNode.dependencies.'*'.findAll() {
badPomGroup.contains(it.groupId.text())
badArtifacts[it.groupId.text()].contains(it.artifactId.text())
}.each() {
it.parent().remove(it)
}
@@ -721,7 +737,7 @@ def deobf(String sourceURL, String fileName) {
// Helper methods
def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
if (!project.hasProperty(propertyName)) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
+8 -1
View File
@@ -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.");
}
}
}
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright 2022, glee8e
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.farming;
import net.minecraft.block.Block;
import net.minecraft.world.World;
/**
* A basic form of {@link IFarmable}. It adds one more variant of isSapling, allowing much better runtime performance than otherwise.
*/
public interface IFarmableBasic extends IFarmable {
/**
* @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
*/
default boolean isSaplingAt(World world, int x, int y, int z) {
return world.blockExists(x, y, z) && isSapling(world.getBlock(x, y, z), isMetadataAware() ? world.getBlockMetadata(x, y, z) : 0);
}
/**
* @return true if given block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop.
*/
boolean isSapling(Block block, int meta);
default boolean isMetadataAware() {
return false;
}
}
@@ -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) {
@@ -226,4 +226,9 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
}
}
@Override
public String getOverlayIdentifier() {
return this.getRecipeID();
}
}
@@ -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));
@@ -17,6 +17,6 @@ import forestry.api.farming.IFarmHousing;
public class FarmLogicIC2Crops extends FarmLogicOrchard {
public FarmLogicIC2Crops(IFarmHousing housing) {
super(housing);
this.farmables = Farmables.farmables.get(FarmableReference.IC2Crops.get());
this.setFarmables(Farmables.farmables.get(FarmableReference.IC2Crops.get()));
}
}
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Set;
import java.util.Stack;
import forestry.api.farming.*;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -31,11 +32,6 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.Farmables;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmHousing;
import forestry.api.farming.IFarmable;
import forestry.api.genetics.IFruitBearer;
import forestry.core.utils.vect.Vect;
import forestry.core.utils.vect.VectUtil;
@@ -48,9 +44,12 @@ public class FarmLogicOrchard extends FarmLogic {
protected final HashMap<Vect, Integer> lastExtents = new HashMap<>();
protected final ImmutableList<Block> traversalBlocks;
protected boolean precalcBlockType;
protected boolean precalcBlockMeta;
public FarmLogicOrchard(IFarmHousing housing) {
super(housing);
this.farmables = Farmables.farmables.get(FarmableReference.Orchard.get());
this.setFarmables(Farmables.farmables.get(FarmableReference.Orchard.get()));
ImmutableList.Builder<Block> traversalBlocksBuilder = ImmutableList.builder();
if (PluginManager.Module.AGRICRAFT.isEnabled() || PluginManager.Module.INDUSTRIALCRAFT.isEnabled()) {
@@ -217,8 +216,14 @@ public class FarmLogicOrchard extends FarmLogic {
return true;
}
Block block = precalcBlockType ? world.getBlock(position.x, position.y, position.z) : null;
int meta = precalcBlockMeta ? world.getBlockMetadata(position.x, position.y, position.z) : -1;
for (IFarmable farmable : farmables) {
if (farmable.isSaplingAt(world, position.x, position.y, position.z)) {
if (farmable instanceof IFarmableBasic) {
if (((IFarmableBasic) farmable).isSapling(block, meta))
return true;
} else if (farmable.isSaplingAt(world, position.x, position.y, position.z)) {
return true;
}
}
@@ -257,4 +262,16 @@ public class FarmLogicOrchard extends FarmLogic {
return null;
}
protected void setFarmables(Collection<IFarmable> farmables) {
this.farmables = farmables;
for (IFarmable farmable : farmables) {
if (farmable instanceof IFarmableBasic) {
precalcBlockType = true;
if (((IFarmableBasic) farmable).isMetadataAware()) {
precalcBlockMeta = true;
return;
}
}
}
}
}
@@ -16,12 +16,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.config.Constants;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableBasicAgricraft implements IFarmable {
public class FarmableBasicAgricraft implements IFarmableBasic {
private final Block block;
private final int matureMeta;
@@ -32,8 +32,8 @@ public class FarmableBasicAgricraft implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSapling(Block block, int meta) {
return this.block == block;
}
@Override
@@ -16,12 +16,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.config.Constants;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableBasicFruit implements IFarmable {
public class FarmableBasicFruit implements IFarmableBasic {
private final Block block;
private final int matureMeta;
@@ -32,8 +32,8 @@ public class FarmableBasicFruit implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSapling(Block block, int meta) {
return this.block == block;
}
@Override
@@ -16,12 +16,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.config.Constants;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableBasicGrowthCraft implements IFarmable {
public class FarmableBasicGrowthCraft implements IFarmableBasic {
private final Block block;
private final int matureMeta;
@@ -36,8 +36,8 @@ public class FarmableBasicGrowthCraft implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSapling(Block block, int meta) {
return this.block == block;
}
@Override
@@ -19,19 +19,19 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.utils.BlockUtil;
import forestry.core.utils.vect.Vect;
public class FarmableCocoa implements IFarmable {
public class FarmableCocoa implements IFarmableBasic {
private static final Block COCOA_PLANT = Blocks.cocoa;
public static final Item COCOA_SEED = Items.dye;
public static final int COCOA_META = 3;
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == COCOA_PLANT;
public boolean isSapling(Block block, int meta) {
return block == COCOA_PLANT;
}
@Override
@@ -17,21 +17,14 @@ import net.minecraft.world.World;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.arboriculture.genetics.TreeGenome;
import forestry.core.utils.vect.Vect;
import forestry.plugins.PluginArboriculture;
public class FarmableGE implements IFarmable {
public class FarmableGE implements IFarmableBasic {
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) {
return false;
}
Block block = world.getBlock(x, y, z);
public boolean isSapling(Block block, int meta) {
return PluginArboriculture.blocks.saplingGE == block;
}
@@ -16,10 +16,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.utils.vect.Vect;
public class FarmableGenericCrop implements IFarmable {
public class FarmableGenericCrop implements IFarmableBasic {
private final ItemStack seed;
private final Block block;
@@ -34,8 +34,8 @@ public class FarmableGenericCrop implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSapling(Block block, int meta) {
return this.block == block;
}
@Override
@@ -16,11 +16,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableGenericSapling implements IFarmable {
public class FarmableGenericSapling implements IFarmableBasic {
protected final Block sapling;
private final int saplingMeta;
@@ -33,22 +33,13 @@ public class FarmableGenericSapling implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) {
return false;
}
if (world.getBlock(x, y, z) == sapling) {
return true;
}
if (saplingMeta >= 0) {
return world.getBlockMetadata(x, y, z) == saplingMeta;
} else {
return true;
}
public boolean isSapling(Block block, int meta) {
return block == sapling && (saplingMeta < 0 || meta == saplingMeta);
}
@Override
public boolean isMetadataAware() {
return saplingMeta >= 0;
}
@Override
@@ -10,17 +10,18 @@
******************************************************************************/
package forestry.farming.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.config.Constants;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableGourd implements IFarmable {
public class FarmableGourd implements IFarmableBasic {
private final ItemStack seed;
private final ItemStack stem;
@@ -33,12 +34,8 @@ public class FarmableGourd implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) {
return false;
}
return ItemStackUtil.equals(world.getBlock(x, y, z), stem);
public boolean isSapling(Block block, int meta) {
return ItemStackUtil.equals(block, stem);
}
@Override
@@ -16,12 +16,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import forestry.api.farming.IFarmableBasic;
import forestry.core.config.Constants;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.vect.Vect;
public class FarmableStacked implements IFarmable {
public class FarmableStacked implements IFarmableBasic {
private final Block block;
private final int matureHeight;
@@ -34,8 +34,8 @@ public class FarmableStacked implements IFarmable {
}
@Override
public boolean isSaplingAt(World world, int x, int y, int z) {
return world.getBlock(x, y, z) == block;
public boolean isSapling(Block block, int meta) {
return this.block == block;
}
@Override
@@ -789,7 +789,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
@Override
public boolean plantGermling(IFarmable germling, World world, int x, int y, int z) {
EntityPlayer player = PlayerUtil.getPlayer(world, getAccessHandler().getOwner());
return inventory.plantGermling(germling, player, x, y, z);
return inventory.plantGermling(germling, player, world, x, y, z);
}
@Override
@@ -17,6 +17,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import forestry.api.farming.FarmDirection;
@@ -170,14 +171,14 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
FluidHelper.drainContainers(tankManager, this, SLOT_CAN);
}
public boolean plantGermling(IFarmable germling, EntityPlayer player, int x, int y, int z) {
public boolean plantGermling(IFarmable germling, EntityPlayer player, World world, int x, int y, int z) {
for (int i = 0; i < germlingsInventory.getSizeInventory(); i++) {
ItemStack germlingStack = germlingsInventory.getStackInSlot(i);
if (germlingStack == null || !germling.isGermling(germlingStack)) {
continue;
}
if (germling.plantSaplingAt(player, germlingStack, player.worldObj, x, y, z)) {
if (germling.plantSaplingAt(player, germlingStack, world, x, y, z)) {
germlingsInventory.decrStackSize(i, 1);
return true;
}