mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b364a93db | ||
|
|
a217884480 | ||
|
|
90f7c36a1e | ||
|
|
974e44f5cd | ||
|
|
bbb374cd5e | ||
|
|
3470c6c7d1 | ||
|
|
b1377d5642 | ||
|
|
b50910496e | ||
|
|
cc4b16e2a5 | ||
|
|
3b63133790 | ||
|
|
6d8d7110e1 | ||
|
|
98fa57844e | ||
|
|
adbb300523 | ||
|
|
839882b783 | ||
|
|
2635d036aa | ||
|
|
cf8f2f54c5 | ||
|
|
4844bc937b | ||
|
|
88f50d91e1 | ||
|
|
3bc6720dec | ||
|
|
1083f52a30 | ||
|
|
3fb58ad6a5 | ||
|
|
7e1398438d | ||
|
|
a02df943ed | ||
|
|
f88742e7ab | ||
|
|
fb2ff8aef3 | ||
|
|
3f41c5e8f8 | ||
|
|
81b1de6925 | ||
|
|
278d091b08 | ||
|
|
1552ad1b68 | ||
|
|
bf94b22345 | ||
|
|
c89b61682a | ||
|
|
43fc136fe3 | ||
|
|
ea52fa0d55 | ||
|
|
725d556718 | ||
|
|
d88c007fbb | ||
|
|
485333c6aa | ||
|
|
240802082e | ||
|
|
6f182e932d | ||
|
|
d08b42f18c | ||
|
|
57cc915a1e | ||
|
|
d7c5940596 |
No files matched your search
@@ -0,0 +1,17 @@
|
||||
name: Optimize images
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
jobs:
|
||||
optimize-images:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
||||
secrets: inherit
|
||||
+5
-3
@@ -1,11 +1,13 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
|
||||
api('curse.maven:cofh-lib-220333:2388748')
|
||||
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta42:api')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.44-GTNH:dev')
|
||||
compileOnlyApi('com.github.GTNewHorizons:Angelica:2.1.19:api')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.107-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:inventory-tweaks:1.7.1:api')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.42:api')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
||||
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
|
||||
}
|
||||
+41
-6
@@ -39,9 +39,33 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
|
||||
# See https://github.com/bsideup/jabel for details on how this works.
|
||||
enableModernJavaSyntax = true
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = jabel
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
||||
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
# jvmDowngraderStubsProvider =
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -80,7 +104,7 @@ apiPackage = api
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a space-separated list.
|
||||
# Example value: mymodid_at.cfg nei_at.cfg
|
||||
accessTransformersFile =
|
||||
accessTransformersFile = forestry_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = false
|
||||
@@ -96,7 +120,9 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
mixinsPackage =
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -151,7 +177,7 @@ modrinthProjectId =
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
modrinthRelations =
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
@@ -172,6 +198,12 @@ curseForgeRelations =
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
@@ -201,3 +233,6 @@ curseForgeRelations =
|
||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
||||
# ideaCheckSpotlessOnBuild = true
|
||||
|
||||
# Non-GTNH properties
|
||||
org.gradle.configuration-cache = true
|
||||
org.gradle.parallel = true
|
||||
@@ -0,0 +1,12 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
|
||||
toolchainVersion=25
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -172,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Add any additional repositiroes for your dependencies here
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,8 @@ import forestry.plugins.PluginManager;
|
||||
name = Constants.MOD,
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
dependencies = "required-after:Forge@[10.13.4.1566,);" + "after:Buildcraft|Core@[6.1.7,);"
|
||||
dependencies = "required-after:Forge@[10.13.4.1566,);" + "required-after:gtnhlib@[0.9.41,);"
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2@[2.0.140,);"
|
||||
|
||||
@@ -84,7 +84,12 @@ public enum EnumBeeChromosome implements IChromosomeType {
|
||||
*/
|
||||
EFFECT(IAlleleBeeEffect.class);
|
||||
|
||||
Class<? extends IAllele> clss;
|
||||
final Class<? extends IAllele> clss;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumBeeChromosome[] VALUES = values();
|
||||
|
||||
EnumBeeChromosome(Class<? extends IAllele> clss) {
|
||||
this.clss = clss;
|
||||
|
||||
@@ -17,9 +17,12 @@ public enum EnumBeeType implements ISpeciesType {
|
||||
LARVAE,
|
||||
NONE;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumBeeType[] VALUES = values();
|
||||
|
||||
String name;
|
||||
private final String name;
|
||||
|
||||
EnumBeeType() {
|
||||
this.name = this.toString().toLowerCase(Locale.ENGLISH);
|
||||
@@ -28,4 +31,8 @@ public enum EnumBeeType implements ISpeciesType {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static EnumBeeType fromOrdinal(int ordinal) {
|
||||
return VALUES[ordinal];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IArmorApiaristMulti extends IArmorApiarist {
|
||||
|
||||
/**
|
||||
* Called to determine how many pieces an armor "counts for". For instance, if this returns 4, the single piece will
|
||||
* act as full protection.
|
||||
*
|
||||
* @param entity Entity being attacked
|
||||
* @param armor Armor item
|
||||
* @param cause Optional cause of attack, such as a bee effect identifier
|
||||
* @return Amount of effective protected slots
|
||||
*/
|
||||
default int getProtectionCount(EntityLivingBase entity, ItemStack armor, String cause) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -73,9 +73,14 @@ public enum EnumTreeChromosome implements IChromosomeType {
|
||||
/**
|
||||
* Determines if the tree can burn.
|
||||
*/
|
||||
FIREPROOF(IAlleleBoolean.class),;
|
||||
FIREPROOF(IAlleleBoolean.class);
|
||||
|
||||
Class<? extends IAllele> clss;
|
||||
final Class<? extends IAllele> clss;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumTreeChromosome[] VALUES = values();
|
||||
|
||||
EnumTreeChromosome(Class<? extends IAllele> clss) {
|
||||
this.clss = clss;
|
||||
|
||||
@@ -17,9 +17,14 @@ public enum EnumHumidity {
|
||||
NORMAL("Normal"),
|
||||
DAMP("Damp");
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumHumidity[] VALUES = values();
|
||||
|
||||
public final String name;
|
||||
|
||||
private EnumHumidity(String name) {
|
||||
EnumHumidity(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,15 @@ public enum EnumTemperature {
|
||||
HOT("Hot", "habitats/desert"),
|
||||
HELLISH("Hellish", "habitats/nether");
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumTemperature[] VALUES = values();
|
||||
|
||||
public final String name;
|
||||
public final String iconIndex;
|
||||
|
||||
private EnumTemperature(String name, String iconIndex) {
|
||||
EnumTemperature(String name, String iconIndex) {
|
||||
this.name = name;
|
||||
this.iconIndex = iconIndex;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ public enum FarmDirection {
|
||||
|
||||
private final ForgeDirection forgeDirection;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final FarmDirection[] VALUES = values();
|
||||
|
||||
FarmDirection(ForgeDirection forgeDirection) {
|
||||
this.forgeDirection = forgeDirection;
|
||||
}
|
||||
@@ -25,17 +30,16 @@ public enum FarmDirection {
|
||||
}
|
||||
|
||||
public static FarmDirection getFarmDirection(ForgeDirection forgeDirection) {
|
||||
switch (forgeDirection) {
|
||||
case NORTH:
|
||||
return NORTH;
|
||||
case EAST:
|
||||
return EAST;
|
||||
case SOUTH:
|
||||
return SOUTH;
|
||||
case WEST:
|
||||
return WEST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (forgeDirection) {
|
||||
case NORTH -> NORTH;
|
||||
case EAST -> EAST;
|
||||
case SOUTH -> SOUTH;
|
||||
case WEST -> WEST;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static FarmDirection fromOrdinal(int ordinal) {
|
||||
return VALUES[ordinal];
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,12 @@ public enum EnumButterflyChromosome implements IChromosomeType {
|
||||
*/
|
||||
TERRITORY(IAlleleArea.class),;
|
||||
|
||||
Class<? extends IAllele> clss;
|
||||
final Class<? extends IAllele> clss;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumButterflyChromosome[] VALUES = values();
|
||||
|
||||
EnumButterflyChromosome(Class<? extends IAllele> clss) {
|
||||
this.clss = clss;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IFarmFertilizerRegistry {
|
||||
|
||||
/**
|
||||
* Gets a list of all fertilizer stacks in the registry.
|
||||
*
|
||||
* @return The current fertilizer registry.
|
||||
*/
|
||||
Collection<ItemStack> getFertilizers();
|
||||
|
||||
/**
|
||||
* Adds a new fertilizer to the registry.
|
||||
*
|
||||
* @apiNote The stack size doesn't matter it always consumes 1.
|
||||
* @apiNote You can use OreDictionary.WILDCARD_VALUE to specific that any meta of the item will be ok.
|
||||
*
|
||||
* @param itemstack The item to add to the registry.
|
||||
*/
|
||||
void addFertilizer(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* Removes a fertilizer from the fretilizer registry.
|
||||
*
|
||||
* @param itemstack The item to remove from the registry.
|
||||
*/
|
||||
void removeFertilizer(ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* Checks if an item is a usable multi-farm fertilizer.
|
||||
*
|
||||
* @param itemstack - The stack to check with.
|
||||
* @return True if the item is a fertilizer item.
|
||||
*/
|
||||
boolean isFertilizer(ItemStack itemstack);
|
||||
}
|
||||
@@ -8,4 +8,6 @@ package forestry.api.multiblock;
|
||||
public class MultiblockManager {
|
||||
|
||||
public static IMultiblockLogicFactory logicFactory;
|
||||
|
||||
public static IFarmFertilizerRegistry farmFertilizerRegistry;
|
||||
}
|
||||
@@ -15,26 +15,20 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.apiculture.IArmorApiaristHelper;
|
||||
import forestry.api.apiculture.IArmorApiaristMulti;
|
||||
|
||||
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
|
||||
@Override
|
||||
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = stack.getItem();
|
||||
if (!(item instanceof IArmorApiarist)) {
|
||||
return false;
|
||||
}
|
||||
if (stack == null || !(stack.getItem() instanceof IArmorApiarist armor)) return false;
|
||||
|
||||
IArmorApiarist armorApiarist = (IArmorApiarist) item;
|
||||
try {
|
||||
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
|
||||
return armor.protectEntity(entity, stack, cause, doProtect);
|
||||
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
|
||||
if (entity instanceof EntityPlayer) {
|
||||
return armorApiarist.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
|
||||
return armor.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
|
||||
} else {
|
||||
return true; // fallback on assuming IArmorApiarist will protect the entity
|
||||
}
|
||||
@@ -48,11 +42,13 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
||||
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
||||
count++;
|
||||
Item item = armorItem.getItem();
|
||||
if (item instanceof IArmorApiaristMulti am) count += am.getProtectionCount(entity, armorItem, cause);
|
||||
else count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
return Math.min(count, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
@@ -73,4 +76,27 @@ public class InventoryBeeHousing extends InventoryAdapterRestricted implements I
|
||||
public final boolean addProduct(ItemStack product, boolean all) {
|
||||
return InventoryUtil.tryAddStack(this, product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
|
||||
}
|
||||
|
||||
public void dumpInventoryIntoWorld(World world, ChunkCoordinates coordinates) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < SLOT_PRODUCT_COUNT; i++) {
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
setInventorySlotContents(i, null);
|
||||
|
||||
EntityItem entityitem = new EntityItem(
|
||||
world,
|
||||
coordinates.posX + 0.5,
|
||||
coordinates.posY + 0.5,
|
||||
coordinates.posZ + 0.5,
|
||||
stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class CommandBeeGive extends SubCommand {
|
||||
setPermLevel(PermLevel.ADMIN);
|
||||
|
||||
List<String> beeTypeStrings = new ArrayList<>();
|
||||
for (EnumBeeType type : EnumBeeType.values()) {
|
||||
for (EnumBeeType type : EnumBeeType.VALUES) {
|
||||
if (type == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class CommandBeeGive extends SubCommand {
|
||||
}
|
||||
|
||||
private static EnumBeeType getBeeType(String beeTypeName) {
|
||||
for (EnumBeeType beeType : EnumBeeType.values()) {
|
||||
for (EnumBeeType beeType : EnumBeeType.VALUES) {
|
||||
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
|
||||
return beeType;
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
|
||||
|
||||
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers,
|
||||
World world, int x, int y, int z) {
|
||||
if (!world.blockExists(x, y, z)) return false;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
final int meta;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual,
|
||||
int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
if (!world.blockExists(x, y, z) || !world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
|
||||
}
|
||||
|
||||
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
|
||||
if (!world.blockExists(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityFlowerPot)) {
|
||||
return false;
|
||||
|
||||
@@ -573,7 +573,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
// / Secondary Products
|
||||
for (Map.Entry<ItemStack, Float> entry : secondary.getProductChances().entrySet()) {
|
||||
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2, speed, prodModifier, 1f)) {
|
||||
if (housing.getWorld().rand.nextFloat() < getFinalChance(entry.getValue() / 2f, speed, prodModifier, 1f)) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
@@ -773,6 +773,9 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect blockPos = Vect.add(housingPos, randomPos, offset);
|
||||
if (!world.blockExists(blockPos.x, blockPos.y, blockPos.z)) {
|
||||
continue;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
|
||||
|
||||
if (tile instanceof IPollinatable) {
|
||||
|
||||
@@ -148,7 +148,7 @@ public enum BeeBranchDefinition implements IBranchDefinition {
|
||||
|
||||
private static IAllele[] getDefaultTemplate() {
|
||||
if (defaultTemplate == null) {
|
||||
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
|
||||
defaultTemplate = new IAllele[EnumBeeChromosome.VALUES.length];
|
||||
|
||||
AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.SPEED, EnumAllele.Speed.SLOWEST);
|
||||
AlleleHelper.instance.set(defaultTemplate, EnumBeeChromosome.LIFESPAN, EnumAllele.Lifespan.SHORTER);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
IBee bee = (IBee) individual;
|
||||
|
||||
Item beeItem;
|
||||
switch (EnumBeeType.VALUES[type]) {
|
||||
switch (EnumBeeType.fromOrdinal(type)) {
|
||||
case QUEEN:
|
||||
beeItem = PluginApiculture.items.beeQueenGE;
|
||||
// ensure a queen is always mated
|
||||
@@ -353,7 +353,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IChromosomeType[] getKaryotype() {
|
||||
return EnumBeeChromosome.values();
|
||||
return EnumBeeChromosome.VALUES;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
@@ -22,24 +20,23 @@ import forestry.core.render.TextureManager;
|
||||
public class DefaultBeeIconProvider implements IBeeIconProvider {
|
||||
|
||||
public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider();
|
||||
private static final IIcon[][] icons = new IIcon[EnumBeeType.VALUES.length][3];
|
||||
|
||||
private DefaultBeeIconProvider() {}
|
||||
|
||||
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
String beeIconDir = "bees/default/";
|
||||
IIcon body1 = TextureManager.registerTex(register, beeIconDir + "body1");
|
||||
|
||||
for (int i = 0; i < EnumBeeType.values().length; i++) {
|
||||
EnumBeeType beeType = EnumBeeType.values()[i];
|
||||
for (int i = 0; i < EnumBeeType.VALUES.length; i++) {
|
||||
EnumBeeType beeType = EnumBeeType.VALUES[i];
|
||||
if (beeType == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
|
||||
String beeTypeNameBase = beeIconDir + beeType.getName();
|
||||
|
||||
icons[i][0] = TextureManager.registerTex(register, beeTypeNameBase + ".outline");
|
||||
if (beeType == EnumBeeType.LARVAE) {
|
||||
|
||||
@@ -27,6 +27,10 @@ public abstract class AlleleEffectThrottled extends AlleleEffect {
|
||||
this.requiresWorkingQueen = requiresWorking;
|
||||
}
|
||||
|
||||
public int getThrottle() {
|
||||
return throttle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCombinable() {
|
||||
return isCombinable;
|
||||
|
||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.GuiBeealyzer;
|
||||
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
|
||||
public class ItemBeealyzer extends ItemWithGui {
|
||||
@@ -24,13 +25,13 @@ public class ItemBeealyzer extends ItemWithGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||
return new GuiBeealyzer(player, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||
return new ContainerAlyzer(inventory, player);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import forestry.apiculture.gui.ContainerHabitatLocator;
|
||||
import forestry.apiculture.gui.GuiHabitatLocator;
|
||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@@ -81,12 +82,12 @@ public class ItemHabitatLocator extends ItemWithGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.gui.GuiImprinter;
|
||||
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
|
||||
public class ItemImprinter extends ItemWithGui {
|
||||
@@ -24,12 +25,12 @@ public class ItemImprinter extends ItemWithGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -159,6 +159,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
activeComponents.remove(oldPart);
|
||||
}
|
||||
}
|
||||
|
||||
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,8 +250,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
|
||||
private float applyChange(float base, float currentChange, float extraChange, float boundaryDown,
|
||||
float boundaryUp) {
|
||||
float boundedNewChange = Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp))
|
||||
- base;
|
||||
float boundedNewChange = Math.round(
|
||||
(Math.max(boundaryDown, Math.min(base + currentChange + (extraChange * 20), boundaryUp)) - base) * 100)
|
||||
/ 100.0f;
|
||||
if (extraChange > 0) {
|
||||
return Math.max(currentChange, boundedNewChange);
|
||||
} else {
|
||||
@@ -353,12 +356,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
ChunkCoordinates coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange;
|
||||
return Math.round((getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange) * 100)
|
||||
/ 100.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return getBiome().rainfall + humidChange;
|
||||
return Math.round((getBiome().rainfall + humidChange) * 100) / 100.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
package forestry.arboriculture;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/** Based on vanilla leaf decay, but accepts leaves that are connected further from a trunk */
|
||||
public abstract class LeafDecayHelper {
|
||||
|
||||
private static final short SUSTAINS_LEAVES = 0;
|
||||
private static final short NOT_SUSTAINS_LEAVES = -1;
|
||||
private static final short IS_LEAVES = -2;
|
||||
private static int[] leafDecayValues;
|
||||
|
||||
public static void leafDecay(BlockLeaves leaves, World world, int x, int y, int z) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
int leafMeta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if ((leafMeta & 8) != 0 && (leafMeta & 4) == 0) {
|
||||
byte radius = 4;
|
||||
byte yArrayMult = 32;
|
||||
int xArrayMult = yArrayMult * yArrayMult;
|
||||
int arrayOffset = yArrayMult / 2;
|
||||
|
||||
if (leafDecayValues == null) {
|
||||
leafDecayValues = new int[yArrayMult * yArrayMult * yArrayMult];
|
||||
}
|
||||
|
||||
int radius1 = radius + 1;
|
||||
if (world.checkChunksExist(x - radius1, y - radius1, z - radius1, x + radius1, y + radius1, z + radius1)) {
|
||||
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
|
||||
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
|
||||
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
|
||||
Block block = world.getBlock(x + xOffset, y + yOffset, z + zOffset);
|
||||
|
||||
if (!block.canSustainLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
|
||||
if (block.isLeaves(world, x + xOffset, y + yOffset, z + zOffset)) {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = IS_LEAVES;
|
||||
} else {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = NOT_SUSTAINS_LEAVES;
|
||||
}
|
||||
} else {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = SUSTAINS_LEAVES;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int sustainedValue = 1; sustainedValue <= 8; ++sustainedValue) {
|
||||
for (int xOffset = -radius; xOffset <= radius; ++xOffset) {
|
||||
for (int yOffset = -radius; yOffset <= radius; ++yOffset) {
|
||||
for (int zOffset = -radius; zOffset <= radius; ++zOffset) {
|
||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] == sustainedValue - 1) {
|
||||
if (leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset - 1) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = sustainedValue;
|
||||
}
|
||||
|
||||
if (leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset + 1) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = sustainedValue;
|
||||
}
|
||||
|
||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset - 1) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset - 1) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = sustainedValue;
|
||||
}
|
||||
|
||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset + 1) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset + 1) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset] = sustainedValue;
|
||||
}
|
||||
|
||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ (zOffset + arrayOffset - 1)] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ (zOffset + arrayOffset - 1)] = sustainedValue;
|
||||
}
|
||||
|
||||
if (leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset
|
||||
+ 1] == IS_LEAVES) {
|
||||
leafDecayValues[(xOffset + arrayOffset) * xArrayMult
|
||||
+ (yOffset + arrayOffset) * yArrayMult
|
||||
+ zOffset
|
||||
+ arrayOffset
|
||||
+ 1] = sustainedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int sustainValue = leafDecayValues[(arrayOffset * xArrayMult) + (arrayOffset * yArrayMult) + arrayOffset];
|
||||
|
||||
if (sustainValue >= 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, leafMeta & -9, 4); // stop trying to decay
|
||||
} else {
|
||||
leaves.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blocks.util.BFSLeafDecay;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -48,7 +49,6 @@ import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.arboriculture.LeafDecayHelper;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.items.ItemBlockLeaves;
|
||||
import forestry.arboriculture.render.TextureLeaves;
|
||||
@@ -230,7 +230,12 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
|
||||
return;
|
||||
}
|
||||
|
||||
LeafDecayHelper.leafDecay(this, world, x, y, z);
|
||||
if (!world.isRemote) {
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
if ((meta & 8) != 0 && (meta & 4) == 0) {
|
||||
BFSLeafDecay.handleDecayChecked(this, world, x, y, z, meta, 4);
|
||||
}
|
||||
}
|
||||
|
||||
// check leaves tile again because they can decay in super.updateTick
|
||||
if (tileLeaves.isInvalid()) {
|
||||
|
||||
@@ -36,29 +36,29 @@ public class BlockFruitPod extends BlockCocoa {
|
||||
}
|
||||
|
||||
public static TileFruitPod getPodTile(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileFruitPod)) {
|
||||
return null;
|
||||
final TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileFruitPod) {
|
||||
return (TileFruitPod) tile;
|
||||
}
|
||||
|
||||
return (TileFruitPod) tile;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
if (!world.checkChunksExist(x - 1, y, z - 1, x + 1, y, z + 1)) {
|
||||
return;
|
||||
}
|
||||
if (!canBlockStay(world, x, y, z)) {
|
||||
dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
TileFruitPod tile = getPodTile(world, x, y, z);
|
||||
if (tile == null) {
|
||||
return;
|
||||
final TileFruitPod tile = getPodTile(world, x, y, z);
|
||||
if (tile != null) {
|
||||
tile.onBlockTick();
|
||||
}
|
||||
|
||||
tile.onBlockTick();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -82,7 +82,7 @@ public enum TreeBranchDefinition implements IBranchDefinition {
|
||||
@Override
|
||||
public IAllele[] getTemplate() {
|
||||
if (defaultTemplate == null) {
|
||||
defaultTemplate = new IAllele[EnumTreeChromosome.values().length];
|
||||
defaultTemplate = new IAllele[EnumTreeChromosome.VALUES.length];
|
||||
|
||||
AlleleHelper.instance.set(defaultTemplate, EnumTreeChromosome.FRUITS, AlleleFruit.fruitNone);
|
||||
AlleleHelper.instance.set(defaultTemplate, EnumTreeChromosome.GROWTH, AlleleGrowth.growthLightLevel);
|
||||
|
||||
@@ -1148,6 +1148,14 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
|
||||
return species.getUID();
|
||||
}
|
||||
|
||||
public EnumWoodType getWoodType() {
|
||||
return woodType;
|
||||
}
|
||||
|
||||
public ItemStack getVanillaWood() {
|
||||
return vanillaWood;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITreeGenome getGenome() {
|
||||
return genome;
|
||||
|
||||
@@ -389,7 +389,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
|
||||
@Override
|
||||
public IChromosomeType[] getKaryotype() {
|
||||
return EnumTreeChromosome.values();
|
||||
return EnumTreeChromosome.VALUES;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ public class ItemRegistryArboriculture extends ItemRegistry {
|
||||
OreDictionary.registerOre("treeSapling", sapling.getWildcard());
|
||||
|
||||
pollenFertile = registerItem(new ItemGermlingGE(EnumGermlingType.POLLEN), "pollenFertile");
|
||||
OreDictionary.registerOre("itemPollenFertile", pollenFertile.getWildcard());
|
||||
treealyzer = registerItem(new ItemTreealyzer(), "treealyzer");
|
||||
grafter = registerItem(new ItemGrafter(4), "grafter");
|
||||
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
||||
|
||||
@@ -15,6 +15,7 @@ import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.gui.GuiTreealyzer;
|
||||
import forestry.arboriculture.inventory.ItemInventoryTreealyzer;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
|
||||
public class ItemTreealyzer extends ItemWithGui {
|
||||
@@ -24,12 +25,12 @@ public class ItemTreealyzer extends ItemWithGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new GuiTreealyzer(player, new ItemInventoryTreealyzer(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new ContainerAlyzer(new ItemInventoryTreealyzer(player, heldItem), player);
|
||||
}
|
||||
}
|
||||
@@ -95,8 +95,7 @@ public class TileWood extends TileEntity implements IStreamable {
|
||||
EnumWoodType woodType = wood.getWoodType();
|
||||
|
||||
int amount = 1;
|
||||
if (block instanceof BlockSlab) {
|
||||
BlockSlab blockSlab = (BlockSlab) block;
|
||||
if (block instanceof BlockSlab blockSlab) {
|
||||
if (blockSlab.isDoubleSlab()) {
|
||||
amount = 2;
|
||||
block = PluginArboriculture.blocks.slabs;
|
||||
@@ -104,6 +103,7 @@ public class TileWood extends TileEntity implements IStreamable {
|
||||
}
|
||||
|
||||
ItemStack itemStack = new ItemStack(block, amount);
|
||||
if (itemStack.getItem() == null) return null;
|
||||
ItemBlockWood.saveToItemStack(woodType, itemStack);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@@ -113,11 +113,7 @@ public final class AccessHandler implements IAccessHandler {
|
||||
if (!isOwner(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int ordinal = (access.ordinal() + 1) % EnumAccess.values().length;
|
||||
EnumAccess newAccess = EnumAccess.values()[ordinal];
|
||||
setAccess(player.worldObj, newAccess);
|
||||
|
||||
setAccess(player.worldObj, access.next());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -156,7 +152,7 @@ public final class AccessHandler implements IAccessHandler {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
byte accessOrdinal = data.readByte();
|
||||
if (accessOrdinal >= 0) {
|
||||
access = EnumAccess.values()[accessOrdinal];
|
||||
access = EnumAccess.fromOrdinal(accessOrdinal);
|
||||
GameProfile owner = new GameProfile(new UUID(data.readLong(), data.readLong()), data.readUTF());
|
||||
setOwner(owner);
|
||||
}
|
||||
@@ -164,8 +160,7 @@ public final class AccessHandler implements IAccessHandler {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
access = EnumAccess.values()[data.getInteger("Access")];
|
||||
|
||||
access = EnumAccess.fromOrdinal(data.getInteger("Access"));
|
||||
if (data.hasKey("owner")) {
|
||||
owner = NBTUtil.func_152459_a(data.getCompoundTag("owner"));
|
||||
}
|
||||
|
||||
@@ -8,22 +8,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.access;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public enum EnumAccess {
|
||||
|
||||
SHARED("gui.rule.shared"),
|
||||
VIEWABLE("gui.rule.restricted"),
|
||||
PRIVATE("gui.rule.private");
|
||||
|
||||
private static final EnumAccess[] VALUES = values();
|
||||
private final String name;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon icon;
|
||||
|
||||
EnumAccess(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -31,4 +24,13 @@ public enum EnumAccess {
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public EnumAccess next() {
|
||||
int ordinal = (this.ordinal() + 1) % VALUES.length;
|
||||
return VALUES[ordinal];
|
||||
}
|
||||
|
||||
public static EnumAccess fromOrdinal(int ordinal) {
|
||||
return VALUES[ordinal];
|
||||
}
|
||||
}
|
||||
@@ -84,31 +84,26 @@ public class BlockSoil extends Block implements IItemTyped {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int i, int j, int k, Random random) {
|
||||
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
SoilType type = getTypeFromMeta(meta);
|
||||
|
||||
if (type == SoilType.HUMUS) {
|
||||
updateTickHumus(world, i, j, k);
|
||||
if (world.checkChunksExist(x - 1, y + 1, z - 1, x + 1, y + 1, z + 1)) {
|
||||
if (isEnrooted(world, x, y, z)) {
|
||||
degradeSoil(world, x, y, z);
|
||||
}
|
||||
}
|
||||
} else if (type == SoilType.BOG_EARTH) {
|
||||
updateTickBogEarth(world, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateTickHumus(World world, int i, int j, int k) {
|
||||
if (isEnrooted(world, i, j, k)) {
|
||||
degradeSoil(world, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateTickBogEarth(World world, int i, int j, int k) {
|
||||
if (isMoistened(world, i, j, k)) {
|
||||
matureBog(world, i, j, k);
|
||||
if (world.checkChunksExist(x - 2, y, z - 2, x + 2, y, z + 2)) {
|
||||
if (isMoistened(world, x, y, z)) {
|
||||
matureBog(world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +117,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -156,7 +150,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
||||
}
|
||||
|
||||
private static boolean isMoistened(World world, int x, int y, int z) {
|
||||
|
||||
for (int i = -2; i < 3; i++) {
|
||||
for (int j = -2; j < 3; j++) {
|
||||
Block block = world.getBlock(x + i, y, z + j);
|
||||
@@ -165,7 +158,6 @@ public class BlockSoil extends Block implements IItemTyped {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
type = EnumCircuitBoardType.values()[nbttagcompound.getShort("T")];
|
||||
type = EnumCircuitBoardType.VALUES[nbttagcompound.getShort("T")];
|
||||
|
||||
// Layout
|
||||
if (nbttagcompound.hasKey("LY")) {
|
||||
|
||||
@@ -15,6 +15,11 @@ public enum EnumCircuitBoardType {
|
||||
REFINED((short) 3, 0x191919, 0xc9c9c9),
|
||||
INTRICATE((short) 4, 0x191919, 0xe2cb6b);
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumCircuitBoardType[] VALUES = values();
|
||||
|
||||
private final short sockets;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, ItemIn
|
||||
try {
|
||||
ICircuitSocketType socketType = layout.getSocketType();
|
||||
if (CircuitSocketType.FARM.equals(socketType)) {
|
||||
FarmDirection farmDirection = FarmDirection.values()[i];
|
||||
FarmDirection farmDirection = FarmDirection.fromOrdinal(i);
|
||||
String farmDirectionString = farmDirection.toString().toLowerCase(Locale.ENGLISH);
|
||||
String localizedDirection = StringUtil.localize("gui.solder." + farmDirectionString);
|
||||
fontRendererObj.drawString(
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ItemCircuitBoard extends ItemForestryMultiPass {
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int pass) {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[itemstack.getItemDamage()];
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[itemstack.getItemDamage()];
|
||||
if (pass == 0) {
|
||||
return type.getPrimaryColor();
|
||||
} else {
|
||||
@@ -60,7 +60,7 @@ public class ItemCircuitBoard extends ItemForestryMultiPass {
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[stack.getItemDamage()];
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[stack.getItemDamage()];
|
||||
return "item.for.circuitboard." + type.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ public class Config {
|
||||
public static boolean enableHints = true;
|
||||
public static final LinkedListMultimap<String, String> hints = LinkedListMultimap.create();
|
||||
public static boolean enableEnergyStat = true;
|
||||
public static boolean showBackpackDurability = true;
|
||||
|
||||
public static boolean isStructureEnabled(String uid) {
|
||||
return !Config.disabledStructures.contains(uid);
|
||||
@@ -301,6 +302,9 @@ public class Config {
|
||||
configCommon.moveProperty("tweaks.gui", "mail.alert", "tweaks.gui.mail.alert");
|
||||
configCommon.renameProperty("tweaks.gui.mail.alert", "mail.alert", "enabled");
|
||||
|
||||
showBackpackDurability = configCommon
|
||||
.getBooleanLocalized("tweaks.gui", "showBackpackDurability", showBackpackDurability);
|
||||
|
||||
mailAlertEnabled = configCommon.getBooleanLocalized("tweaks.gui.mail.alert", "enabled", mailAlertEnabled);
|
||||
mailAlertXPosition = configCommon.getEnumLocalized(
|
||||
"tweaks.gui.mail.alert",
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||
@@ -29,6 +28,7 @@ import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IGuiHandlerEntity;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.tiles.ITitled;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public abstract class EntityMinecartForestry extends EntityMinecart
|
||||
implements ITitled, IRestrictedAccess, IHintSource, IGuiHandlerEntity {
|
||||
@@ -111,7 +111,7 @@ public abstract class EntityMinecartForestry extends EntityMinecart
|
||||
|
||||
@Override
|
||||
public String getCommandSenderName() {
|
||||
return StatCollector.translateToLocal(getUnlocalizedTitle());
|
||||
return StringUtil.localizeGuiTitle(getUnlocalizedTitle());
|
||||
}
|
||||
|
||||
/* ITitled */
|
||||
|
||||
@@ -193,7 +193,7 @@ public class BlockForestryFluid extends BlockFluidClassic {
|
||||
super.updateTick(world, x, y, z, rand);
|
||||
|
||||
// Start fires if the fluid is lava-like
|
||||
if (getMaterial() == Material.lava) {
|
||||
if (getMaterial() == Material.lava && world.checkChunksExist(x - 4, y, z - 4, x + 4, y, z + 4)) {
|
||||
int rangeUp = rand.nextInt(3);
|
||||
|
||||
for (int i = 0; i < rangeUp; ++i) {
|
||||
|
||||
@@ -176,4 +176,8 @@ public abstract class Mutation implements IMutationCustom {
|
||||
public boolean isSecret() {
|
||||
return isSecret;
|
||||
}
|
||||
|
||||
public List<IMutationCondition> getMutationConditions() {
|
||||
return mutationConditions;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +36,7 @@ public abstract class ContainerForestry extends Container {
|
||||
// Player inventory
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
addSlotToContainer(
|
||||
new Slot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18));
|
||||
addNormalSlot(playerInventory, column + row * 9 + 9, xInv + column * 18, yInv + row * 18);
|
||||
}
|
||||
}
|
||||
// Player hotbar
|
||||
@@ -46,6 +45,10 @@ public abstract class ContainerForestry extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||
}
|
||||
|
||||
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,17 @@ public abstract class ContainerItemInventory<I extends ItemInventory> extends Co
|
||||
addPlayerInventory(playerInventory, xInv, yInv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addNormalSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
|
||||
|
||||
if (inventory.isParentItemInventory(stackInSlot)) {
|
||||
addSlotToContainer(new SlotLocked(playerInventory, slot, x, y));
|
||||
} else {
|
||||
addSlotToContainer(new Slot(playerInventory, slot, x, y));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addHotbarSlot(InventoryPlayer playerInventory, int slot, int x, int y) {
|
||||
ItemStack stackInSlot = playerInventory.getStackInSlot(slot);
|
||||
|
||||
@@ -10,9 +10,9 @@ package forestry.core.gui;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import forestry.core.tiles.ITitled;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public abstract class GuiForestryTitled<C extends Container, I extends ITitled & IInventory> extends GuiForestry<C, I> {
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class GuiForestryTitled<C extends Container, I extends ITitled &
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
String name = StatCollector.translateToLocal(inventory.getUnlocalizedTitle());
|
||||
String name = StringUtil.localizeGuiTitle(inventory.getUnlocalizedTitle());
|
||||
textLayout.line = 6;
|
||||
textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title"));
|
||||
bindTexture(textureFile);
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import static forestry.core.inventory.ItemLocation.Type.PLAYER_INVENTORY;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -18,6 +22,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
@@ -39,6 +44,20 @@ public class GuiHandler implements IGuiHandler {
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens gui for item placed in player's inventory.
|
||||
*
|
||||
* @param entityPlayer Player.
|
||||
* @param guiHandler GUI handler for item.
|
||||
* @param data Data for item.
|
||||
* @param invSlotIdx Index or slot in player inventory should be in range [0, 40).
|
||||
*/
|
||||
public static void openGui(EntityPlayer entityPlayer, IGuiHandlerItem guiHandler, short data, int invSlotIdx) {
|
||||
assert invSlotIdx >= 0 && invSlotIdx < 40 : "Incorrect inventory index is used: " + invSlotIdx;
|
||||
int guiData = encodeGuiData(guiHandler, data, invSlotIdx);
|
||||
entityPlayer.openGui(ForestryAPI.instance, guiData, entityPlayer.worldObj, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler) {
|
||||
openGui(entityplayer, guiHandler, (short) 0);
|
||||
}
|
||||
@@ -56,8 +75,32 @@ public class GuiHandler implements IGuiHandler {
|
||||
}
|
||||
|
||||
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data) {
|
||||
return encodeGuiData(guiHandler, data, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes data required for GUI handler to function properly. Because of minecraft implementation we are limited to
|
||||
* 32 bits.
|
||||
*
|
||||
* @param guiHandler GUI handler.
|
||||
* @param data High bits which were encoded by GUI handler.
|
||||
* @param invSlotIdx Slot index in the player's inventory should be in range [0,40).
|
||||
* @return Encoded data.
|
||||
*/
|
||||
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data, int invSlotIdx) {
|
||||
// inventory slot idx will be encoded in third byte
|
||||
// player inventory has 40 slots which means that we need 6 bits to encode all values.
|
||||
// first 2 bits are reserved for type currently values 0(heldItem) and 1(item inventory) have meaning,
|
||||
// 2 and 3 are reserved for possible extension.
|
||||
if (invSlotIdx < -1 || invSlotIdx >= 40) {
|
||||
throw new IllegalArgumentException("Inventory slot index should be in range [-1, 40)");
|
||||
}
|
||||
|
||||
int invData = invSlotIdx == -1 ? 0 : (0x40 | invSlotIdx);
|
||||
|
||||
GuiId guiId = GuiIdRegistry.getGuiIdForGuiHandler(guiHandler);
|
||||
return data << 16 | guiId.getId();
|
||||
|
||||
return data << 16 | invData << 8 | guiId.getId();
|
||||
}
|
||||
|
||||
private static GuiId decodeGuiID(int guiData) {
|
||||
@@ -69,8 +112,24 @@ public class GuiHandler implements IGuiHandler {
|
||||
return (short) (guiId >> 16);
|
||||
}
|
||||
|
||||
private static int decodeInvSlotIdx(int guiData) {
|
||||
boolean invEncoded = (0x00_00_40_00 & guiData) != 0;
|
||||
|
||||
return invEncoded ? (guiData & 0x00_00_3F_00) >> 8 : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return getGuiElement(false, guiData, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return getGuiElement(true, guiData, player, world, x, y, z);
|
||||
}
|
||||
|
||||
private @Nullable Object getGuiElement(boolean isServerSide, int guiData, EntityPlayer player, World world, int x,
|
||||
int y, int z) {
|
||||
GuiId guiId = decodeGuiID(guiData);
|
||||
if (guiId == null) {
|
||||
return null;
|
||||
@@ -79,11 +138,25 @@ public class GuiHandler implements IGuiHandler {
|
||||
|
||||
switch (guiId.getGuiType()) {
|
||||
case Item: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
int slotIdx = decodeInvSlotIdx(guiData);
|
||||
ItemStack heldItem;
|
||||
ItemLocation loc;
|
||||
if (slotIdx == -1) {
|
||||
heldItem = player.getCurrentEquippedItem();
|
||||
loc = ItemLocation.HELD_BY_PLAYER;
|
||||
} else {
|
||||
heldItem = player.inventory.getStackInSlot(slotIdx);
|
||||
loc = new ItemLocation(PLAYER_INVENTORY, slotIdx);
|
||||
}
|
||||
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
||||
return ((IGuiHandlerItem) item).getGui(player, heldItem, data);
|
||||
if (isServerSide) {
|
||||
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data, loc);
|
||||
}
|
||||
|
||||
return ((IGuiHandlerItem) item).getGui(player, heldItem, data, loc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -91,6 +164,9 @@ public class GuiHandler implements IGuiHandler {
|
||||
case Tile: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
||||
if (isServerSide) {
|
||||
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
||||
}
|
||||
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
|
||||
}
|
||||
break;
|
||||
@@ -98,6 +174,9 @@ public class GuiHandler implements IGuiHandler {
|
||||
case Entity: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
||||
if (isServerSide) {
|
||||
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
||||
}
|
||||
return ((IGuiHandlerEntity) entity).getGui(player, data);
|
||||
}
|
||||
break;
|
||||
@@ -105,41 +184,4 @@ public class GuiHandler implements IGuiHandler {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||
GuiId guiId = decodeGuiID(guiData);
|
||||
if (guiId == null) {
|
||||
return null;
|
||||
}
|
||||
short data = decodeGuiData(guiData);
|
||||
|
||||
switch (guiId.getGuiType()) {
|
||||
case Item: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
||||
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Tile: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
||||
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Entity: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
||||
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -119,6 +119,13 @@ public class GuiIdRegistry {
|
||||
classMap.put(tileGuiHandlerClass, guiId);
|
||||
idMap.put(guiId.getId(), guiId);
|
||||
}
|
||||
|
||||
if (idMap.size() > 256) {
|
||||
// see {@link GuiHandler.encodeGuiData(forestry.core.gui.IGuiHandlerForestry, short, int)}
|
||||
throw new IllegalStateException(
|
||||
"Current implementation can't have more than different 256 GUI handlers "
|
||||
+ "because its id is coded by 8 bits");
|
||||
}
|
||||
}
|
||||
|
||||
public static GuiId getGuiIdForGuiHandler(IGuiHandlerForestry guiHandler) {
|
||||
|
||||
@@ -11,9 +11,11 @@ package forestry.core.gui;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
|
||||
public interface IGuiHandlerItem extends IGuiHandlerForestry {
|
||||
|
||||
Object getGui(EntityPlayer player, ItemStack heldItem, int data);
|
||||
Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
|
||||
|
||||
Object getContainer(EntityPlayer player, ItemStack heldItem, int data);
|
||||
Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc);
|
||||
}
|
||||
@@ -28,11 +28,17 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
private final EntityPlayer player;
|
||||
private final ItemStack parent;
|
||||
private final ItemStack[] inventoryStacks;
|
||||
private final ItemLocation location;
|
||||
|
||||
public ItemInventory(EntityPlayer player, int size, ItemStack parent) {
|
||||
this(player, size, parent, ItemLocation.UNKNOWN);
|
||||
}
|
||||
|
||||
public ItemInventory(EntityPlayer player, int size, ItemStack parent, ItemLocation loc) {
|
||||
this.player = player;
|
||||
this.parent = parent;
|
||||
this.inventoryStacks = new ItemStack[size];
|
||||
this.location = loc;
|
||||
|
||||
setUID(); // Set a uid to identify the itemstack on SMP
|
||||
|
||||
@@ -79,7 +85,10 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
}
|
||||
|
||||
public boolean isParentItemEquipped() {
|
||||
return isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
||||
return switch (location.type()) {
|
||||
case HELD_BY_PLAYER, UNKNOWN -> isSameItemInventory(player.getCurrentEquippedItem(), parent);
|
||||
case PLAYER_INVENTORY -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
@@ -92,7 +101,11 @@ public abstract class ItemInventory implements IInventory, IFilterSlotDelegate {
|
||||
}
|
||||
|
||||
protected ItemStack getParent() {
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
ItemStack equipped = switch (location.type()) {
|
||||
case HELD_BY_PLAYER, UNKNOWN -> player.getCurrentEquippedItem();
|
||||
case PLAYER_INVENTORY -> player.inventory.getStackInSlot(location.slotIdx());
|
||||
};
|
||||
|
||||
if (isSameItemInventory(equipped, parent)) {
|
||||
return equipped;
|
||||
}
|
||||
|
||||
@@ -121,11 +121,11 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
|
||||
}
|
||||
|
||||
// Illegal type
|
||||
if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.values().length) {
|
||||
if (blank.getItemDamage() < 0 || blank.getItemDamage() >= EnumCircuitBoardType.VALUES.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()];
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[blank.getItemDamage()];
|
||||
if (getCircuitCount() != type.getSockets()) {
|
||||
return;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
|
||||
if (blankCircuitBoard == null) {
|
||||
errorStates.add(EnumErrorCode.NO_CIRCUIT_BOARD);
|
||||
} else {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blankCircuitBoard.getItemDamage()];
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.VALUES[blankCircuitBoard.getItemDamage()];
|
||||
|
||||
int circuitCount = 0;
|
||||
for (short i = 0; i < type.getSockets(); i++) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package forestry.core.inventory;
|
||||
|
||||
/**
|
||||
* Location of items in inventory.
|
||||
*/
|
||||
public class ItemLocation {
|
||||
|
||||
public enum Type {
|
||||
UNKNOWN,
|
||||
HELD_BY_PLAYER,
|
||||
PLAYER_INVENTORY
|
||||
}
|
||||
|
||||
public static final ItemLocation UNKNOWN = new ItemLocation(Type.UNKNOWN, -1);
|
||||
public static final ItemLocation HELD_BY_PLAYER = new ItemLocation(Type.HELD_BY_PLAYER, -1);
|
||||
|
||||
private final Type type;
|
||||
private final int slotIdx;
|
||||
|
||||
public ItemLocation(Type type, int slotIdx) {
|
||||
this.type = type;
|
||||
this.slotIdx = slotIdx;
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int slotIdx() {
|
||||
return slotIdx;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class ItemForestryTool extends ItemForestry {
|
||||
setMaxDamage(200);
|
||||
this.remnants = remnants;
|
||||
if (remnants != null) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,20 +53,6 @@ public class ItemForestryTool extends ItemForestry {
|
||||
return ForgeHooks.canToolHarvestBlock(block, 0, stack);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDestroyCurrentItem(PlayerDestroyItemEvent event) {
|
||||
if (event.original == null || event.original.getItem() != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
World world = player.worldObj;
|
||||
|
||||
if (!world.isRemote && remnants != null) {
|
||||
ItemStackUtil.dropItemStackAsEntity(remnants.copy(), world, player.posX, player.posY, player.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z,
|
||||
EntityLivingBase entityliving) {
|
||||
@@ -80,4 +66,21 @@ public class ItemForestryTool extends ItemForestry {
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDestroyCurrentItem(PlayerDestroyItemEvent event) {
|
||||
if (event.original == null || event.original.getItem() != ItemForestryTool.this) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
World world = player.worldObj;
|
||||
|
||||
if (!world.isRemote && remnants != null) {
|
||||
ItemStackUtil.dropItemStackAsEntity(remnants.copy(), world, player.posX, player.posY, player.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,9 @@ public class ItemFruit extends ItemForestryFood {
|
||||
DATES("cropDate"),
|
||||
PAPAYA("cropPapaya"); // , COCONUT("cropCoconut");
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumFruit[] VALUES = values();
|
||||
|
||||
private final String oreDict;
|
||||
@@ -94,13 +97,13 @@ public class ItemFruit extends ItemForestryFood {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return EnumFruit.values()[meta].getIcon();
|
||||
return EnumFruit.VALUES[meta].getIcon();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
for (int i = 0; i < EnumFruit.values().length; i++) {
|
||||
for (int i = 0; i < EnumFruit.VALUES.length; i++) {
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class ItemRegistryCore extends ItemRegistry {
|
||||
|
||||
// FRUITS
|
||||
fruits = registerItem(new ItemFruit(), "fruits");
|
||||
for (ItemFruit.EnumFruit def : ItemFruit.EnumFruit.values()) {
|
||||
for (ItemFruit.EnumFruit def : ItemFruit.EnumFruit.VALUES) {
|
||||
ItemStack fruit = new ItemStack(fruits, 1, def.ordinal());
|
||||
OreDictionary.registerOre(def.getOreDict(), fruit);
|
||||
}
|
||||
|
||||
@@ -15,16 +15,17 @@ import forestry.core.circuits.ContainerSolderingIron;
|
||||
import forestry.core.circuits.GuiSolderingIron;
|
||||
import forestry.core.circuits.ISolderingIron;
|
||||
import forestry.core.inventory.ItemInventorySolderingIron;
|
||||
import forestry.core.inventory.ItemLocation;
|
||||
|
||||
public class ItemSolderingIron extends ItemWithGui implements ISolderingIron {
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new GuiSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data, ItemLocation loc) {
|
||||
return new ContainerSolderingIron(player, new ItemInventorySolderingIron(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public enum PacketIdServer implements IPacketId {
|
||||
BEE_LOGIC_ACTIVE_ENTITY_REQUEST,
|
||||
|
||||
// Factory
|
||||
WORKTABLE_NEI_SELECT,
|
||||
NEI_SELECT,
|
||||
|
||||
// Mail
|
||||
LETTER_INFO_REQUEST,
|
||||
|
||||
@@ -23,7 +23,7 @@ import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.api.IStackPositioner;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.factory.network.packets.PacketWorktableNEISelect;
|
||||
import forestry.factory.network.packets.PacketNEISelect;
|
||||
|
||||
/**
|
||||
* @author bdew
|
||||
@@ -40,9 +40,25 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
||||
this.forceShift = forceShift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireShiftForOverlayRecipe() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer cont, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
List<PositionedStack> ingr = recipe.getIngredientStacks(recipeIndex);
|
||||
int offsetX = 25;
|
||||
int offsetY = 6;
|
||||
int gridSpacing = 18;
|
||||
List<PositionedStack> ingr;
|
||||
if (recipe instanceof IGridRecipeHandler gridHandler) {
|
||||
offsetX = gridHandler.getGridStartX();
|
||||
offsetY = gridHandler.getGridStartY();
|
||||
gridSpacing = gridHandler.getGridSpacing();
|
||||
ingr = gridHandler.getGridStacks(recipeIndex);
|
||||
} else {
|
||||
ingr = recipe.getIngredientStacks(recipeIndex);
|
||||
}
|
||||
|
||||
if (shift || forceShift) {
|
||||
NBTTagList stacksnbt = new NBTTagList();
|
||||
@@ -50,8 +66,8 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
||||
for (PositionedStack pstack : ingr) {
|
||||
if (pstack != null) {
|
||||
// This is back-asswards but i don't see a better way :(
|
||||
int x = (pstack.relx - 25) / 18;
|
||||
int y = (pstack.rely - 6) / 18;
|
||||
int x = (pstack.relx - offsetX) / gridSpacing;
|
||||
int y = (pstack.rely - offsetY) / gridSpacing;
|
||||
|
||||
ItemStack stack = pstack.item;
|
||||
NBTTagCompound stacknbt = stack.writeToNBT(new NBTTagCompound());
|
||||
@@ -68,7 +84,7 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setTag("stacks", stacksnbt);
|
||||
|
||||
Proxies.net.sendToServer(new PacketWorktableNEISelect(data));
|
||||
Proxies.net.sendToServer(new PacketNEISelect(data));
|
||||
} else {
|
||||
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
|
||||
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package forestry.core.recipes.nei;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
|
||||
public interface IGridRecipeHandler {
|
||||
|
||||
int getGridStartX();
|
||||
|
||||
int getGridStartY();
|
||||
|
||||
int getGridSpacing();
|
||||
|
||||
List<PositionedStack> getGridStacks(int recipeIndex);
|
||||
|
||||
}
|
||||
@@ -19,6 +19,8 @@ import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.factory.gui.GuiCarpenter;
|
||||
import forestry.factory.gui.GuiFabricator;
|
||||
import forestry.factory.gui.GuiWorktable;
|
||||
import forestry.factory.recipes.nei.NEIHandlerBottler;
|
||||
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
|
||||
@@ -46,6 +48,8 @@ public class NEIIntegrationConfig implements IConfigureNEI {
|
||||
|
||||
CustomOverlayHandler handler = new CustomOverlayHandler(-14, 14, true);
|
||||
API.registerGuiOverlayHandler(GuiWorktable.class, handler, "crafting");
|
||||
API.registerGuiOverlayHandler(GuiCarpenter.class, handler, "forestry.carpenter");
|
||||
API.registerGuiOverlayHandler(GuiFabricator.class, handler, "forestry.fabricator");
|
||||
|
||||
API.addSubset(
|
||||
"Forestry.Bees.Princesses",
|
||||
|
||||
@@ -112,18 +112,12 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
public List<String> handleTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, int recipe) {
|
||||
super.handleTooltip(guiRecipe, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
|
||||
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
|
||||
|
||||
if (recipeIndex >= 0) {
|
||||
Point offset = guiRecipe.getRecipePosition(recipeIndex);
|
||||
Point relMouse = new Point(
|
||||
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
|
||||
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
|
||||
}
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
currenttip = this.provideTooltip(guiRecipe, currenttip, crecipe, relMouse);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
@@ -135,18 +129,10 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
int recipeIndex = guiRecipe.getRecipeIndices().indexOf(recipe);
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
|
||||
if (recipeIndex >= 0) {
|
||||
Point offset = guiRecipe.getRecipePosition(recipeIndex);
|
||||
Point relMouse = new Point(
|
||||
mouse.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mouse.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
|
||||
currenttip = this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
|
||||
}
|
||||
|
||||
return currenttip;
|
||||
return this.provideItemTooltip(guiRecipe, itemStack, currenttip, crecipe, relMouse);
|
||||
}
|
||||
|
||||
public List<String> provideTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe,
|
||||
@@ -210,11 +196,9 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler implements
|
||||
|
||||
protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean usage) {
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mousepos = GuiDraw.getMousePosition();
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
Point offset = guiRecipe.getRecipePosition(recipe);
|
||||
Point relMouse = new Point(
|
||||
mousepos.x - (guiRecipe.width - 176) / 2 - offset.x,
|
||||
mousepos.y - (guiRecipe.height - 166) / 2 - offset.y);
|
||||
Point relMouse = new Point(mouse.x - guiRecipe.guiLeft - offset.x, mouse.y - guiRecipe.guiTop - offset.y);
|
||||
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
|
||||
|
||||
@@ -23,18 +23,19 @@ import net.minecraft.nbt.NBTTagList;
|
||||
*/
|
||||
public class SetRecipeCommandHandler {
|
||||
|
||||
private final Class<? extends Container> containerClass;
|
||||
private final Class<? extends Container>[] containerClasses;
|
||||
private final Class<? extends Slot> slotClass;
|
||||
|
||||
public SetRecipeCommandHandler(Class<? extends Container> containerClass, Class<? extends Slot> slotClass) {
|
||||
this.containerClass = containerClass;
|
||||
public SetRecipeCommandHandler(Class<? extends Container>[] containerClasses, Class<? extends Slot> slotClass) {
|
||||
this.containerClasses = containerClasses;
|
||||
this.slotClass = slotClass;
|
||||
}
|
||||
|
||||
public void handle(NBTTagCompound data, EntityPlayerMP player) {
|
||||
NBTTagList stacks = data.getTagList("stacks", 10);
|
||||
Container cont = player.openContainer;
|
||||
if (!containerClass.isInstance(cont)) {
|
||||
|
||||
if (!isContainerClassCorrect(cont)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,17 +44,20 @@ public class SetRecipeCommandHandler {
|
||||
NBTTagCompound itemdata = stacks.getCompoundTagAt(i);
|
||||
stmap.put(itemdata.getInteger("slot"), ItemStack.loadItemStackFromNBT(itemdata));
|
||||
}
|
||||
for (Object slotobj : cont.inventorySlots) {
|
||||
if (!slotClass.isInstance(slotobj)) {
|
||||
for (Slot slot : cont.inventorySlots) {
|
||||
if (!slotClass.isInstance(slot)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Slot slot = (Slot) slotobj;
|
||||
if (stmap.containsKey(slot.getSlotIndex())) {
|
||||
slot.putStack(stmap.get(slot.getSlotIndex()));
|
||||
} else {
|
||||
slot.putStack(null);
|
||||
}
|
||||
slot.putStack(stmap.getOrDefault(slot.getSlotIndex(), null));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isContainerClassCorrect(Container cont) {
|
||||
for (Class<? extends Container> containerClass : containerClasses) {
|
||||
if (containerClass.isInstance(cont)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -8,15 +8,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.render;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FontColour {
|
||||
|
||||
// private static final ResourceLocation colourDefinitions = new
|
||||
// ForestryResource("/config/forestry/colour.properties");
|
||||
private static final ResourceLocation colourDefinitions = new ForestryResource("config/colour.properties");
|
||||
private static final String defaultColourDefinitions = "/assets/forestry/config/colour.properties";
|
||||
|
||||
private final Properties defaultMappings = new Properties();
|
||||
private final Properties mappings = new Properties();
|
||||
@@ -30,17 +34,30 @@ public class FontColour {
|
||||
}
|
||||
|
||||
public void load(IResourceManager texturepack) {
|
||||
try {
|
||||
// InputStream fontStream = texturepack.func_110536_a(colourDefinitions).func_110527_b();
|
||||
InputStream defaultFontStream = FontColour.class.getResourceAsStream("/config/forestry/colour.properties");
|
||||
// mappings.load((fontStream == null) ? defaultFontStream : fontStream);
|
||||
mappings.load(defaultFontStream);
|
||||
defaultMappings.load(defaultFontStream);
|
||||
mappings.clear();
|
||||
defaultMappings.clear();
|
||||
|
||||
// if (fontStream != null)
|
||||
// fontStream.close();
|
||||
defaultFontStream.close();
|
||||
} catch (Exception e) {
|
||||
try (InputStream defaultFontStream = FontColour.class.getResourceAsStream(defaultColourDefinitions)) {
|
||||
if (defaultFontStream != null) {
|
||||
defaultMappings.load(defaultFontStream);
|
||||
mappings.putAll(defaultMappings);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (texturepack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
IResource resource = texturepack.getResource(colourDefinitions);
|
||||
try (InputStream fontStream = resource.getInputStream()) {
|
||||
mappings.load(fontStream);
|
||||
}
|
||||
} catch (FileNotFoundException ignored) {
|
||||
// Resource pack does not provide an override.
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,6 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockR
|
||||
|
||||
private void render(ItemStack itemstack, World world, ForgeDirection orientation, double x, double y, double z) {
|
||||
|
||||
dummyEntityItem.worldObj = world;
|
||||
|
||||
model.render(orientation, (float) x, (float) y, (float) z);
|
||||
if (itemstack == null) {
|
||||
return;
|
||||
@@ -72,13 +70,18 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer implements IBlockR
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
GL11.glTranslatef(0.5f, 0.2f, 0.5f);
|
||||
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||
dummyEntityItem.setEntityItemStack(itemstack);
|
||||
|
||||
if (world.getTotalWorldTime() != lastTick) {
|
||||
lastTick = world.getTotalWorldTime();
|
||||
dummyEntityItem.onUpdate();
|
||||
try {
|
||||
dummyEntityItem.worldObj = world;
|
||||
dummyEntityItem.setEntityItemStack(itemstack);
|
||||
if (world.getTotalWorldTime() != lastTick) {
|
||||
lastTick = world.getTotalWorldTime();
|
||||
dummyEntityItem.onUpdate();
|
||||
}
|
||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
} finally {
|
||||
dummyEntityItem.worldObj = null;
|
||||
}
|
||||
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,6 @@ import forestry.core.tiles.TileMill;
|
||||
|
||||
public class RenderMill extends TileEntitySpecialRenderer implements IBlockRenderer {
|
||||
|
||||
private final ModelBase model = new ModelBase() {};
|
||||
|
||||
private enum Textures {
|
||||
PEDESTAL,
|
||||
EXTENSION,
|
||||
@@ -41,6 +39,7 @@ public class RenderMill extends TileEntitySpecialRenderer implements IBlockRende
|
||||
private final ModelRenderer blade2;
|
||||
|
||||
public RenderMill() {
|
||||
ModelBase model = new ModelBase() {};
|
||||
pedestal = new ModelRenderer(model, 0, 0);
|
||||
pedestal.addBox(-8F, -8F, -8F, 16, 1, 16);
|
||||
pedestal.rotationPointX = 8;
|
||||
|
||||
@@ -235,7 +235,7 @@ public abstract class BlockUtil {
|
||||
private static Class<? extends Block> GTBlockMachines_Class;
|
||||
private static Block GTBlockMachines;
|
||||
private static final boolean bw = Loader.isModLoaded("bartworks");
|
||||
private static final boolean gt = Loader.isModLoaded("gregtech");
|
||||
private static final boolean gt = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
|
||||
|
||||
static {
|
||||
if (bw) try {
|
||||
@@ -268,11 +268,13 @@ public abstract class BlockUtil {
|
||||
} while (stillInside.test(tile));
|
||||
block = world.getBlock(x, y - depth, z);
|
||||
|
||||
if (bw && BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
|
||||
if (bw && BW_MetaGenerated_WerkstoffBlocksClass != null
|
||||
&& BWBlocks != null
|
||||
&& BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
|
||||
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
if (gt && GTBlockMachines_Class.isInstance(block)) {
|
||||
if (gt && GTBlockMachines_Class != null && GTBlockMachines != null && GTBlockMachines_Class.isInstance(block)) {
|
||||
return new ItemStack(GTBlockMachines, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,18 +45,18 @@ public class ClimateUtil implements IClimateHelper {
|
||||
case BOTH_4:
|
||||
case BOTH_3:
|
||||
case BOTH_2:
|
||||
if (prefered.ordinal() + 2 < EnumHumidity.values().length) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]);
|
||||
if (prefered.ordinal() + 2 < EnumHumidity.VALUES.length) {
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() + 2]);
|
||||
}
|
||||
if (prefered.ordinal() - 2 >= 0) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]);
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() - 2]);
|
||||
}
|
||||
case BOTH_1:
|
||||
if (prefered.ordinal() + 1 < EnumHumidity.values().length) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]);
|
||||
if (prefered.ordinal() + 1 < EnumHumidity.VALUES.length) {
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() + 1]);
|
||||
}
|
||||
if (prefered.ordinal() - 1 >= 0) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]);
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() - 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
@@ -64,12 +64,12 @@ public class ClimateUtil implements IClimateHelper {
|
||||
case UP_4:
|
||||
case UP_3:
|
||||
case UP_2:
|
||||
if (prefered.ordinal() + 2 < EnumHumidity.values().length) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() + 2]);
|
||||
if (prefered.ordinal() + 2 < EnumHumidity.VALUES.length) {
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() + 2]);
|
||||
}
|
||||
case UP_1:
|
||||
if (prefered.ordinal() + 1 < EnumHumidity.values().length) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() + 1]);
|
||||
if (prefered.ordinal() + 1 < EnumHumidity.VALUES.length) {
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() + 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
@@ -78,11 +78,11 @@ public class ClimateUtil implements IClimateHelper {
|
||||
case DOWN_3:
|
||||
case DOWN_2:
|
||||
if (prefered.ordinal() - 2 >= 0) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() - 2]);
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() - 2]);
|
||||
}
|
||||
case DOWN_1:
|
||||
if (prefered.ordinal() - 1 >= 0) {
|
||||
tolerated.add(EnumHumidity.values()[prefered.ordinal() - 1]);
|
||||
tolerated.add(EnumHumidity.VALUES[prefered.ordinal() - 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
@@ -96,85 +96,86 @@ public class ClimateUtil implements IClimateHelper {
|
||||
ArrayList<EnumTemperature> tolerated = new ArrayList<>();
|
||||
tolerated.add(prefered);
|
||||
|
||||
final EnumTemperature[] TEMP_VALUES = EnumTemperature.VALUES;
|
||||
switch (tolerance) {
|
||||
case BOTH_5:
|
||||
if (prefered.ordinal() + 5 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]);
|
||||
if (prefered.ordinal() + 5 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 5]);
|
||||
}
|
||||
if (prefered.ordinal() - 5 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 5]);
|
||||
}
|
||||
case BOTH_4:
|
||||
if (prefered.ordinal() + 4 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]);
|
||||
if (prefered.ordinal() + 4 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 4]);
|
||||
}
|
||||
if (prefered.ordinal() - 4 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 4]);
|
||||
}
|
||||
case BOTH_3:
|
||||
if (prefered.ordinal() + 3 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]);
|
||||
if (prefered.ordinal() + 3 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 3]);
|
||||
}
|
||||
if (prefered.ordinal() - 3 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 3]);
|
||||
}
|
||||
case BOTH_2:
|
||||
if (prefered.ordinal() + 2 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]);
|
||||
if (prefered.ordinal() + 2 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 2]);
|
||||
}
|
||||
if (prefered.ordinal() - 2 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 2]);
|
||||
}
|
||||
case BOTH_1:
|
||||
if (prefered.ordinal() + 1 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]);
|
||||
if (prefered.ordinal() + 1 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 1]);
|
||||
}
|
||||
if (prefered.ordinal() - 1 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
case UP_5:
|
||||
if (prefered.ordinal() + 5 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 5]);
|
||||
if (prefered.ordinal() + 5 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 5]);
|
||||
}
|
||||
case UP_4:
|
||||
if (prefered.ordinal() + 4 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 4]);
|
||||
if (prefered.ordinal() + 4 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 4]);
|
||||
}
|
||||
case UP_3:
|
||||
if (prefered.ordinal() + 3 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 3]);
|
||||
if (prefered.ordinal() + 3 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 3]);
|
||||
}
|
||||
case UP_2:
|
||||
if (prefered.ordinal() + 2 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 2]);
|
||||
if (prefered.ordinal() + 2 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 2]);
|
||||
}
|
||||
case UP_1:
|
||||
if (prefered.ordinal() + 1 < EnumTemperature.values().length) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() + 1]);
|
||||
if (prefered.ordinal() + 1 < TEMP_VALUES.length) {
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() + 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
case DOWN_5:
|
||||
if (prefered.ordinal() - 5 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 5]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 5]);
|
||||
}
|
||||
case DOWN_4:
|
||||
if (prefered.ordinal() - 4 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 4]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 4]);
|
||||
}
|
||||
case DOWN_3:
|
||||
if (prefered.ordinal() - 3 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 3]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 3]);
|
||||
}
|
||||
case DOWN_2:
|
||||
if (prefered.ordinal() - 2 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 2]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 2]);
|
||||
}
|
||||
case DOWN_1:
|
||||
if (prefered.ordinal() - 1 >= 0) {
|
||||
tolerated.add(EnumTemperature.values()[prefered.ordinal() - 1]);
|
||||
tolerated.add(TEMP_VALUES[prefered.ordinal() - 1]);
|
||||
}
|
||||
return tolerated;
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ public class GeneticsUtil {
|
||||
* altering the world by changing vanilla leaves to forestry ones.
|
||||
*/
|
||||
public static ICheckPollinatable getCheckPollinatable(World world, final int x, final int y, final int z) {
|
||||
if (!world.blockExists(x, y, z)) return null;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof IPollinatable) {
|
||||
|
||||
@@ -38,6 +38,17 @@ public class StringUtil {
|
||||
.replace("\\%", "@");
|
||||
}
|
||||
|
||||
public static String localizeGuiTitle(String unlocalizedKey) {
|
||||
String titleKey = unlocalizedKey + ".title";
|
||||
String translated;
|
||||
if (StatCollector.canTranslate(titleKey)) {
|
||||
translated = StatCollector.translateToLocal(titleKey);
|
||||
} else {
|
||||
translated = StatCollector.translateToLocal(unlocalizedKey);
|
||||
}
|
||||
return translated.replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
|
||||
}
|
||||
|
||||
public static String localizeAndFormat(String key, Object... args) {
|
||||
return localizeAndFormatRaw("for." + key, args);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glTranslatef(0, 0, 150);
|
||||
drawRect(left, top, left + 16, top + 16, 0x88ff0000);
|
||||
drawRect(left, top, left + 16, top + 16, 0x88000000 | getFontColor().get("gui.worktable.missing"));
|
||||
GL11.glTranslatef(0, 0, -150);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
package forestry.factory.network;
|
||||
|
||||
import forestry.core.network.PacketRegistry;
|
||||
import forestry.factory.network.packets.PacketNEISelect;
|
||||
import forestry.factory.network.packets.PacketWorktableMemoryUpdate;
|
||||
import forestry.factory.network.packets.PacketWorktableNEISelect;
|
||||
import forestry.factory.network.packets.PacketWorktableRecipeUpdate;
|
||||
|
||||
public class PacketRegistryFactory extends PacketRegistry {
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerServerPacket(new PacketWorktableNEISelect());
|
||||
registerServerPacket(new PacketNEISelect());
|
||||
|
||||
registerClientPacket(new PacketWorktableMemoryUpdate());
|
||||
registerClientPacket(new PacketWorktableRecipeUpdate());
|
||||
|
||||
+9
-7
@@ -19,27 +19,29 @@ import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.packets.PacketNBT;
|
||||
import forestry.core.recipes.nei.SetRecipeCommandHandler;
|
||||
import forestry.factory.gui.ContainerCarpenter;
|
||||
import forestry.factory.gui.ContainerFabricator;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
|
||||
public class PacketWorktableNEISelect extends PacketNBT implements IForestryPacketServer {
|
||||
public class PacketNEISelect extends PacketNBT implements IForestryPacketServer {
|
||||
|
||||
private static final SetRecipeCommandHandler worktableNEISelectHandler = new SetRecipeCommandHandler(
|
||||
ContainerWorktable.class,
|
||||
private static final SetRecipeCommandHandler neiSelectHandler = new SetRecipeCommandHandler(
|
||||
new Class[] { ContainerWorktable.class, ContainerCarpenter.class, ContainerFabricator.class },
|
||||
SlotCraftMatrix.class);
|
||||
|
||||
public PacketWorktableNEISelect() {}
|
||||
public PacketNEISelect() {}
|
||||
|
||||
public PacketWorktableNEISelect(NBTTagCompound nbttagcompound) {
|
||||
public PacketNEISelect(NBTTagCompound nbttagcompound) {
|
||||
super(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
worktableNEISelectHandler.handle(getTagCompound(), player);
|
||||
neiSelectHandler.handle(getTagCompound(), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketIdServer getPacketId() {
|
||||
return PacketIdServer.WORKTABLE_NEI_SELECT;
|
||||
return PacketIdServer.NEI_SELECT;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -26,6 +25,7 @@ import codechicken.nei.PositionedStack;
|
||||
import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiBottler;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class NEIHandlerBottler extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.0.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.0.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,11 +11,11 @@ package forestry.factory.recipes.nei;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
@@ -25,12 +25,14 @@ import codechicken.nei.api.API;
|
||||
import forestry.api.recipes.ICarpenterRecipe;
|
||||
import forestry.api.recipes.IDescriptiveRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.recipes.nei.IGridRecipeHandler;
|
||||
import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiCarpenter;
|
||||
|
||||
public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
||||
public class NEIHandlerCarpenter extends RecipeHandlerBase implements IGridRecipeHandler {
|
||||
|
||||
private static Class<? extends GuiContainer> guiClass;
|
||||
|
||||
@@ -40,11 +42,35 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
||||
API.setGuiOffset(guiClass, 5, 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGridStartX() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGridStartY() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGridSpacing() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getGridStacks(int recipeIndex) {
|
||||
if (arecipes.get(recipeIndex) instanceof CachedCarpenterRecipe recipe) {
|
||||
return recipe.inputs.subList(0, recipe.ingredientCount);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public class CachedCarpenterRecipe extends CachedBaseRecipe {
|
||||
|
||||
public List<PositionedStack> inputs = new ArrayList<>();
|
||||
public PositionedFluidTank tank;
|
||||
public PositionedStack output;
|
||||
public int ingredientCount;
|
||||
|
||||
public CachedCarpenterRecipe(ICarpenterRecipe recipe, boolean genPerms) {
|
||||
IDescriptiveRecipe irecipe = recipe.getCraftingGridRecipe();
|
||||
@@ -78,6 +104,7 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items) {
|
||||
ingredientCount = 0;
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
Object item = items[y * width + x];
|
||||
@@ -89,9 +116,14 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
||||
continue;
|
||||
}
|
||||
|
||||
PositionedStack stack = new PositionedStack(item, 5 + x * 18, 6 + y * 18, false);
|
||||
PositionedStack stack = new PositionedStack(
|
||||
item,
|
||||
getGridStartX() + x * getGridSpacing(),
|
||||
getGridStartY() + y * getGridSpacing(),
|
||||
false);
|
||||
stack.setMaxSize(1);
|
||||
this.inputs.add(stack);
|
||||
ingredientCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,7 +157,7 @@ public class NEIHandlerCarpenter extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.1.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.1.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
@@ -26,6 +25,7 @@ import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.recipes.nei.PositionedStackAdv;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiCentrifuge;
|
||||
|
||||
public class NEIHandlerCentrifuge extends RecipeHandlerBase {
|
||||
@@ -109,7 +109,7 @@ public class NEIHandlerCentrifuge extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.2.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.2.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ package forestry.factory.recipes.nei;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -18,7 +19,6 @@ import java.util.Map;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -28,13 +28,38 @@ import codechicken.nei.recipe.GuiRecipe;
|
||||
import forestry.api.recipes.IFabricatorRecipe;
|
||||
import forestry.api.recipes.IFabricatorSmeltingRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.recipes.nei.IGridRecipeHandler;
|
||||
import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiFabricator;
|
||||
import forestry.factory.recipes.FabricatorSmeltingRecipeManager;
|
||||
|
||||
public class NEIHandlerFabricator extends RecipeHandlerBase {
|
||||
public class NEIHandlerFabricator extends RecipeHandlerBase implements IGridRecipeHandler {
|
||||
|
||||
@Override
|
||||
public int getGridStartX() {
|
||||
return 62;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGridStartY() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGridSpacing() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PositionedStack> getGridStacks(int recipeIndex) {
|
||||
if (arecipes.get(recipeIndex) instanceof CachedFabricatorRecipe recipe) {
|
||||
return recipe.inputs.subList(0, recipe.ingredientCount);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public class CachedFabricatorRecipe extends CachedBaseRecipe {
|
||||
|
||||
@@ -42,6 +67,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
||||
public PositionedFluidTank tank;
|
||||
public List<PositionedStack> inputs = new ArrayList<>();
|
||||
public PositionedStack output;
|
||||
public int ingredientCount;
|
||||
|
||||
public CachedFabricatorRecipe(IFabricatorRecipe recipe, boolean genPerms) {
|
||||
if (recipe.getLiquid() != null) {
|
||||
@@ -78,6 +104,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
||||
}
|
||||
|
||||
public void setIngredients(int width, int height, Object[] items) {
|
||||
ingredientCount = 0;
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
Object item = items[y * width + x];
|
||||
@@ -89,9 +116,14 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
||||
continue;
|
||||
}
|
||||
|
||||
PositionedStack stack = new PositionedStack(item, 62 + x * 18, 6 + y * 18, false);
|
||||
PositionedStack stack = new PositionedStack(
|
||||
item,
|
||||
getGridStartX() + x * getGridSpacing(),
|
||||
getGridStartY() + y * getGridSpacing(),
|
||||
false);
|
||||
stack.setMaxSize(1);
|
||||
this.inputs.add(stack);
|
||||
ingredientCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +172,7 @@ public class NEIHandlerFabricator extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory2.0.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory2.0.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
@@ -32,6 +31,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiFermenter;
|
||||
|
||||
public class NEIHandlerFermenter extends RecipeHandlerBase {
|
||||
@@ -118,7 +118,7 @@ public class NEIHandlerFermenter extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.3.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.3.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -27,6 +26,7 @@ import forestry.api.recipes.IMoistenerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiMoistener;
|
||||
|
||||
public class NEIHandlerMoistener extends RecipeHandlerBase {
|
||||
@@ -88,7 +88,7 @@ public class NEIHandlerMoistener extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.4.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.4.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.nei.NEIServerUtils;
|
||||
@@ -30,6 +29,7 @@ import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.PositionedStackAdv;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiSqueezer;
|
||||
import forestry.factory.recipes.ISqueezerContainerRecipe;
|
||||
import forestry.factory.recipes.SqueezerRecipeManager;
|
||||
@@ -165,7 +165,7 @@ public class NEIHandlerSqueezer extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.5.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.5.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
@@ -24,6 +23,7 @@ import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.recipes.nei.NEIUtils;
|
||||
import forestry.core.recipes.nei.PositionedFluidTank;
|
||||
import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.factory.gui.GuiStill;
|
||||
|
||||
public class NEIHandlerStill extends RecipeHandlerBase {
|
||||
@@ -71,7 +71,7 @@ public class NEIHandlerStill extends RecipeHandlerBase {
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return StatCollector.translateToLocal("tile.for.factory.6.name");
|
||||
return StringUtil.localizeGuiTitle("tile.for.factory.6.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class BlockFarm extends BlockStructure {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (EnumFarmBlockTexture block : EnumFarmBlockTexture.values()) {
|
||||
for (EnumFarmBlockTexture block : EnumFarmBlockTexture.VALUES) {
|
||||
ItemStack stack = new ItemStack(item, 1, i);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
block.saveToCompound(compound);
|
||||
|
||||
@@ -72,51 +72,54 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int i, int j, int k, Random random) {
|
||||
|
||||
public void updateTick(World world, int x, int y, int z, Random random) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
int meta = world.getBlockMetadata(i, j, k);
|
||||
MushroomType type = getTypeFromMeta(meta);
|
||||
int maturity = meta >> 2;
|
||||
final int meta = world.getBlockMetadata(x, y, z);
|
||||
final MushroomType type = getTypeFromMeta(meta);
|
||||
final int maturity = meta >> 2;
|
||||
|
||||
tickGermling(world, i, j, k, random, type, maturity);
|
||||
tickGermling(world, x, y, z, random, type, maturity);
|
||||
}
|
||||
|
||||
private void tickGermling(World world, int i, int j, int k, Random random, MushroomType type, int maturity) {
|
||||
|
||||
int lightvalue = world.getBlockLightValue(i, j + 1, k);
|
||||
|
||||
private void tickGermling(World world, int x, int y, int z, Random random, MushroomType type, int maturity) {
|
||||
if (random.nextInt(2) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (maturity != 3) {
|
||||
maturity = 3;
|
||||
int matX = maturity << 2;
|
||||
int meta = (matX | type.ordinal());
|
||||
world.setBlockMetadataWithNotify(i, j, k, meta, Constants.FLAG_BLOCK_SYNCH);
|
||||
} else if (lightvalue <= 7) {
|
||||
func_149878_d(world, i, j, k, random);
|
||||
final int matX = maturity << 2;
|
||||
final int meta = (matX | type.ordinal());
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Constants.FLAG_BLOCK_SYNCH);
|
||||
} else {
|
||||
if (world.checkChunksExist(x - 1, y, z - 1, x + 1, y, z + 1)) {
|
||||
final int lightvalue = world.getBlockLightValue(x, y + 1, z);
|
||||
if (lightvalue <= 7) {
|
||||
func_149878_d(world, x, y, z, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_149878_d(World world, int i, int j, int k, Random random) {
|
||||
MushroomType type = getTypeFromMeta(world.getBlockMetadata(i, j, k));
|
||||
public void func_149878_d(World world, int x, int y, int z, Random random) {
|
||||
MushroomType type = getTypeFromMeta(world.getBlockMetadata(x, y, z));
|
||||
|
||||
world.setBlockToAir(i, j, k);
|
||||
if (!generators[type.ordinal()].generate(world, random, i, j, k)) {
|
||||
world.setBlock(i, j, k, this, type.ordinal(), 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (!generators[type.ordinal()].generate(world, random, x, y, z)) {
|
||||
world.setBlock(x, y, z, this, type.ordinal(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MushroomType getTypeFromMeta(int meta) {
|
||||
meta %= MushroomType.values().length;
|
||||
return MushroomType.values()[meta];
|
||||
return switch (meta % 2) {
|
||||
case 0 -> MushroomType.BROWN;
|
||||
case 1 -> MushroomType.RED;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
};
|
||||
}
|
||||
|
||||
/* ICONS */
|
||||
@@ -135,15 +138,10 @@ public class BlockMushroom extends BlockSapling implements IItemTyped {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
MushroomType type = getTypeFromMeta(meta);
|
||||
|
||||
switch (type) {
|
||||
case BROWN:
|
||||
return Blocks.brown_mushroom.getIcon(side, meta);
|
||||
case RED:
|
||||
return Blocks.red_mushroom.getIcon(side, meta);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
final MushroomType type = getTypeFromMeta(meta);
|
||||
return switch (type) {
|
||||
case BROWN -> Blocks.brown_mushroom.getIcon(side, meta);
|
||||
case RED -> Blocks.red_mushroom.getIcon(side, meta);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class CircuitFarmLogic extends Circuit {
|
||||
} catch (Throwable e) {
|
||||
// uses older version of the API that doesn't implement setManual
|
||||
}
|
||||
housing.setFarmLogic(FarmDirection.values()[slot], logic);
|
||||
housing.setFarmLogic(FarmDirection.fromOrdinal(slot), logic);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,8 +75,7 @@ public class CircuitFarmLogic extends Circuit {
|
||||
if (farmHousing == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
farmHousing.resetFarmLogic(FarmDirection.values()[slot]);
|
||||
farmHousing.resetFarmLogic(FarmDirection.fromOrdinal(slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -372,7 +372,7 @@ public class FarmController extends RectangularMultiblockControllerBase
|
||||
}
|
||||
|
||||
private void refreshFarmLogics() {
|
||||
for (FarmDirection direction : FarmDirection.values()) {
|
||||
for (FarmDirection direction : FarmDirection.VALUES) {
|
||||
resetFarmLogic(direction);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ public class FarmController extends RectangularMultiblockControllerBase
|
||||
// Cultivation and collection
|
||||
FarmWorkStatus farmWorkStatus = new FarmWorkStatus();
|
||||
|
||||
for (FarmDirection farmSide : FarmDirection.values()) {
|
||||
for (FarmDirection farmSide : FarmDirection.VALUES) {
|
||||
|
||||
IFarmLogic logic = getFarmLogic(farmSide);
|
||||
if (logic == null) {
|
||||
@@ -541,7 +541,7 @@ public class FarmController extends RectangularMultiblockControllerBase
|
||||
private static void createTargets(World world, Map<FarmDirection, List<FarmTarget>> targets, Vect targetStart,
|
||||
final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest) {
|
||||
|
||||
for (FarmDirection farmSide : FarmDirection.values()) {
|
||||
for (FarmDirection farmSide : FarmDirection.VALUES) {
|
||||
|
||||
final int farmWidth;
|
||||
if (farmSide == FarmDirection.NORTH || farmSide == FarmDirection.SOUTH) {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package forestry.farming.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.multiblock.IFarmFertilizerRegistry;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class FarmFertilizerRegistry implements IFarmFertilizerRegistry {
|
||||
|
||||
// the current list isn't big enough to require a hash map, and is faster as a list.
|
||||
private final List<ItemStack> fertilizers = new ArrayList<>(5);
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getFertilizers() {
|
||||
return fertilizers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFertilizer(ItemStack itemstack) {
|
||||
// maybe throw warn? but could also be nice to leave as no warn for easier/cleaner optional mod dependencies
|
||||
if (itemstack == null || itemstack.getItem() == null || itemstack.stackSize <= 0) return;
|
||||
fertilizers.add(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFertilizer(ItemStack itemstack) {
|
||||
// maybe throw warn? but could also be nice to leave as no warn for easier/cleaner optional mod dependencies
|
||||
if (itemstack == null || itemstack.getItem() == null) return;
|
||||
fertilizers.removeIf(fert -> {
|
||||
// in stack first so it wild card can be used for a wild-card clear.
|
||||
return ItemStackUtil.isIdenticalItem(itemstack, fert);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFertilizer(ItemStack itemstack) {
|
||||
if (itemstack == null) return false;
|
||||
for (ItemStack fert : this.fertilizers) {
|
||||
// fert first to allow for wild card checks
|
||||
if (ItemStackUtil.isIdenticalItem(fert, itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import java.util.Deque;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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;
|
||||
@@ -21,6 +20,7 @@ import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.multiblock.MultiblockManager;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.inventory.InventoryAdapterRestricted;
|
||||
@@ -28,9 +28,6 @@ import forestry.core.inventory.wrappers.InventoryMapper;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.plugins.PluginCore;
|
||||
import forestry.plugins.PluginManager;
|
||||
import ic2.api.item.IC2Items;
|
||||
|
||||
public class InventoryFarm extends InventoryAdapterRestricted implements IFarmInventory {
|
||||
|
||||
@@ -106,7 +103,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
return false;
|
||||
}
|
||||
|
||||
for (FarmDirection farmDirection : FarmDirection.values()) {
|
||||
for (FarmDirection farmDirection : FarmDirection.VALUES) {
|
||||
IFarmLogic logic = farmController.getFarmLogic(farmDirection);
|
||||
if (logic.isAcceptedGermling(itemstack)) {
|
||||
return true;
|
||||
@@ -122,7 +119,7 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
return false;
|
||||
}
|
||||
|
||||
for (FarmDirection farmDirection : FarmDirection.values()) {
|
||||
for (FarmDirection farmDirection : FarmDirection.VALUES) {
|
||||
IFarmLogic logic = farmController.getFarmLogic(farmDirection);
|
||||
if (logic.isAcceptedResource(itemstack)) {
|
||||
return true;
|
||||
@@ -134,18 +131,8 @@ public class InventoryFarm extends InventoryAdapterRestricted implements IFarmIn
|
||||
|
||||
@Override
|
||||
public boolean acceptsAsFertilizer(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return false;
|
||||
}
|
||||
Item item = itemstack.getItem();
|
||||
if (PluginManager.Module.INDUSTRIALCRAFT.isEnabled()) {
|
||||
Item ic2fert = IC2Items.getItem("fertilizer").getItem();
|
||||
if (ic2fert == item) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return PluginCore.items.fertilizerCompound == item;
|
||||
// check if it's a fertilizer
|
||||
return MultiblockManager.farmFertilizerRegistry.isFertilizer(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,8 +45,17 @@ public enum EnumFarmBlockTexture {
|
||||
private static final int TYPE_VALVE = 6;
|
||||
private static final int TYPE_CONTROL = 7;
|
||||
|
||||
/**
|
||||
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
|
||||
*/
|
||||
public static final EnumFarmBlockTexture[] VALUES = values();
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static List<IIcon> icons;
|
||||
private final ItemStack base;
|
||||
|
||||
EnumFarmBlockTexture(ItemStack base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerIcons(IIconRegister register) {
|
||||
@@ -61,12 +70,6 @@ public enum EnumFarmBlockTexture {
|
||||
TextureManager.registerTex(register, "farm/control"));
|
||||
}
|
||||
|
||||
private final ItemStack base;
|
||||
|
||||
EnumFarmBlockTexture(ItemStack base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IIcon getIcon(BlockFarmType type, int side) {
|
||||
switch (type) {
|
||||
@@ -109,11 +112,10 @@ public enum EnumFarmBlockTexture {
|
||||
public static EnumFarmBlockTexture getFromCompound(NBTTagCompound compound) {
|
||||
if (compound != null) {
|
||||
int farmBlockOrdinal = compound.getInteger("FarmBlock");
|
||||
if (farmBlockOrdinal < EnumFarmBlockTexture.values().length) {
|
||||
return EnumFarmBlockTexture.values()[farmBlockOrdinal];
|
||||
if (farmBlockOrdinal < EnumFarmBlockTexture.VALUES.length) {
|
||||
return EnumFarmBlockTexture.VALUES[farmBlockOrdinal];
|
||||
}
|
||||
}
|
||||
|
||||
return EnumFarmBlockTexture.BRICK_STONE;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 297 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user