Compare commits

..
3 Commits
2137 changed files with 789 additions and 1434 deletions

No files matched your search

-1
View File
@@ -32,7 +32,6 @@
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[pP][dD][nN] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
-17
View File
@@ -1,17 +0,0 @@
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
+1 -2
View File
@@ -28,7 +28,6 @@ whitelist.json
*.iws
src/main/resources/mixins.*([!.]).json
*.bat
*.sh
*.DS_Store
!gradlew.bat
.factorypath
@@ -36,4 +35,4 @@ addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
layout.json
Binary file not shown.

Before

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

+4 -4
View File
@@ -1,12 +1,12 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:ForestryMC:4.11.39:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.11.54:dev')
api('com.github.GTNewHorizons:ForestryMC:4.10.17:dev')
implementation('com.github.GTNewHorizons:GTNHLib:0.6.40:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.162-GTNH:dev')
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.91-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.64:api')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly("curse.maven:extrabiomesxl-60041:2273301")
}
+4 -41
View File
@@ -39,33 +39,9 @@ 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 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 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 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.
@@ -120,9 +96,7 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# 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.
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -186,11 +160,6 @@ modrinthRelations =
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# Comma-separated supported CurseForge environments: client, server (case-insensitive).
# Use client or server for mods that only support one environment. Defaults to client,server.
# These tags describe where the mod can run, not whether installation is required on both sides.
curseForgeEnvironments = client,server
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
@@ -203,12 +172,6 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
customArchiveBaseName = binnie-mods
# 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.
-12
View File
@@ -1,12 +0,0 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9064f22734b42ac03e85df04b632e167/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/4d0277c49991306ac78048580fe34bcf/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/539ea72837c6244075f8ee037babc29e/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/876dbbf00bf4ef6190f7da074cee903a/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/a9fa3b809e484a1e1ac4308a5dda661a/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/aa99913fa6d767d899ffc96082da01ca/redirect
toolchainVersion=25
Binary file not shown.
+1 -3
View File
@@ -1,9 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+8 -5
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
# Copyright © 2015-2021 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.
@@ -20,7 +20,7 @@
##############################################################################
#
# gradlew start up script for POSIX generated by Gradle.
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
@@ -29,7 +29,7 @@
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh gradlew
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
@@ -57,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/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,6 +114,7 @@ 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.
@@ -171,6 +172,7 @@ 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" )
@@ -210,7 +212,8 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
Vendored
+24 -12
View File
@@ -19,12 +19,12 @@
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem gradlew startup script for Windows
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables, and ensure extensions are enabled
setlocal EnableExtensions
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@@ -51,7 +51,7 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
@@ -65,18 +65,30 @@ echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
"%COMSPEC%" /c exit 1
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute gradlew
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
@rem which allows us to clear the local environment before executing the java command
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:exitWithErrorLevel
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
"%COMSPEC%" /c exit %ERRORLEVEL%
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1 -1
View File
@@ -17,5 +17,5 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.34'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
}
+2
View File
@@ -5,6 +5,7 @@ import java.util.List;
import binnie.core.ManagerBase;
import binnie.core.genetics.ManagerGenetics;
import binnie.core.item.ManagerItem;
import binnie.core.liquid.ManagerLiquid;
import binnie.core.machines.ManagerMachine;
import binnie.core.resource.ManagerResource;
@@ -15,5 +16,6 @@ public final class Binnie {
public static ManagerGenetics Genetics = new ManagerGenetics();
public static ManagerLiquid Liquid = new ManagerLiquid();
public static ManagerMachine Machine = new ManagerMachine();
public static ManagerItem Item = new ManagerItem();
public static ManagerResource Resource = new ManagerResource();
}
+15 -20
View File
@@ -64,37 +64,32 @@ public class Botany extends AbstractMod {
@SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
public static Proxy proxy;
// Genetics module
public static BlockFlower flower;
public static ItemFlower flowerItem;
public static Item pollen;
public static Item seed;
public static Item pollen;
public static ItemDictionary database;
// Gardening module
public static BlockPlant plant;
public static ItemTrowel trowelWood;
public static ItemTrowel trowelStone;
public static ItemTrowel trowelIron;
public static ItemTrowel trowelDiamond;
public static ItemTrowel trowelGold;
public static BlockSoil soil;
public static BlockSoil loam;
public static BlockSoil flowerbed;
public static BlockSoil soilNoWeed;
public static BlockSoil loamNoWeed;
public static BlockSoil flowerbedNoWeed;
public static BlockCeramic ceramic;
public static BlockStained stained;
public static BlockCeramicPatterned ceramicTile;
public static BlockCeramicBrick ceramicBrick;
public static ItemSoilMeter soilMeter;
public static ItemInsulatedTube insulatedTube;
public static ItemTrowel trowelWood;
public static ItemTrowel trowelStone;
public static ItemTrowel trowelIron;
public static ItemTrowel trowelDiamond;
public static ItemTrowel trowelGold;
public static ItemSoilMeter soilMeter;
public static ItemMisc misc;
public static ItemFlower flowerItem;
public static ItemPigment pigment;
public static ItemClay clay;
public static BlockCeramic ceramic;
public static BlockCeramicPatterned ceramicTile;
public static BlockStained stained;
public static BlockCeramicBrick ceramicBrick;
public Botany() {
Botany.instance = this;
@@ -271,7 +266,7 @@ public class Botany extends AbstractMod {
EnumSoilType type = soil.getType(event.world, event.x, y, event.z);
int next = Math
.min(type.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.VALUES[next])
if (soil.fertilise(event.world, event.x, y, event.z, EnumSoilType.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem = event.entityPlayer.getHeldItem();
heldItem.stackSize--;
@@ -284,7 +279,7 @@ public class Botany extends AbstractMod {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.max(pH.ordinal() - Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 0);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.VALUES[next])
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem2 = event.entityPlayer.getHeldItem();
heldItem2.stackSize--;
@@ -297,7 +292,7 @@ public class Botany extends AbstractMod {
EnumAcidity pH = soil.getPH(event.world, event.x, y, event.z);
int next = Math
.min(pH.ordinal() + Gardening.getFertiliserStrength(event.entityPlayer.getHeldItem()), 2);
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.VALUES[next])
if (soil.setPH(event.world, event.x, y, event.z, EnumAcidity.values()[next])
&& !event.entityPlayer.capabilities.isCreativeMode) {
ItemStack heldItem3 = event.entityPlayer.getHeldItem();
heldItem3.stackSize--;
@@ -6,11 +6,6 @@ public enum EnumAcidity {
NEUTRAL,
ALKALINE;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumAcidity[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
@@ -24,10 +24,6 @@ public enum EnumFlowerChromosome implements IChromosomeType {
SAPPINESS(IAlleleFloat.class),
STEM(IAlleleInteger.class);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumFlowerChromosome[] VALUES = values();
private final Class<? extends IAllele> cls;
EnumFlowerChromosome(Class<? extends IAllele> cls) {
@@ -6,11 +6,6 @@ public enum EnumMoisture {
NORMAL,
DAMP;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumMoisture[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
@@ -6,11 +6,6 @@ public enum EnumSoilType {
LOAM,
FLOWERBED;
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumSoilType[] VALUES = values();
public String getID() {
return name().toLowerCase();
}
@@ -93,7 +93,7 @@ public class BlockCeramic extends Block implements IBlockMetadata {
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@@ -102,12 +102,12 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
BlockType type = new BlockType(c, c, TileType.Tile);
itemList.add(TileEntityMetadata.getItemStack(this, type.ordinal()));
}
for (TileType type2 : TileType.VALUES) {
for (TileType type2 : TileType.values()) {
if (type2.canDouble()) {
itemList.add(new BlockType(EnumFlowerColor.BROWN, EnumFlowerColor.GOLD, type2).getStack(1));
}
@@ -130,13 +130,13 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
@Override
public IIcon getIcon(int side, int meta) {
return TileType.get(meta >>> 16 & 0xFF).icons[MultipassBlockRenderer.getLayer()];
return getType(meta).getIcon(MultipassBlockRenderer.getLayer());
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (TileType type : TileType.VALUES) {
for (TileType type : TileType.values()) {
for (int i = 0; i < 3; ++i) {
type.icons[i] = Botany.proxy.getIcon(register, "ceramic." + type.id + "." + i);
}
@@ -167,9 +167,6 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta) {
if (!MultipassBlockRenderer.isRendering()) {
return EnumFlowerColor.get(meta & 0xFF).getColor(false);
}
return colorMultiplier(meta);
}
@@ -180,14 +177,14 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
@Override
public int colorMultiplier(int meta) {
int layer = MultipassBlockRenderer.getLayer();
if (layer == 0) {
BlockType type = getType(meta);
if (MultipassBlockRenderer.getLayer() == 0) {
return 0xffffff;
}
if (layer == 1) {
return EnumFlowerColor.get(meta & 0xFF).getColor(false);
if (MultipassBlockRenderer.getLayer() == 1) {
return type.color1.getColor(false);
}
return EnumFlowerColor.get(meta >>> 8 & 0xFF).getColor(false);
return type.color2.getColor(false);
}
@Override
@@ -208,10 +205,6 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
VerticalStripeBrick("verticalbrickstripe", "verticalStripedCeramicBricks"),
VerticalLargeBrick("verticalbricklarge", "largeVerticalCeramicBricks");
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final TileType[] VALUES = values();
private final String id;
private final String name;
private final IIcon[] icons;
@@ -223,7 +216,7 @@ public class BlockCeramicBrick extends Block implements IBlockMetadata, IMultipa
}
public static TileType get(int id) {
return VALUES[id % VALUES.length];
return values()[id % values().length];
}
public boolean canDouble() {
@@ -124,7 +124,7 @@ public class BlockStained extends Block implements IBlockMetadata {
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
}
}
@@ -16,7 +16,7 @@ public class CeramicColor implements IDesignMaterial {
static {
CeramicColor.map = new LinkedHashMap<>();
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
CeramicColor.map.put(c, new CeramicColor(c));
}
}
@@ -74,7 +74,7 @@ public class CeramicDesignSystem implements IDesignSystem {
@Override
public void registerIcons(IIconRegister register) {
for (EnumPattern pattern : EnumPattern.VALUES) {
for (EnumPattern pattern : EnumPattern.values()) {
primary.put(
pattern.ordinal(),
BinnieCore.proxy.getIcon(
@@ -52,7 +52,7 @@ public class CeramicTileRecipe implements IRecipe {
}
}
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.VALUES) {
for (BlockCeramicBrick.TileType type : BlockCeramicBrick.TileType.values()) {
ItemStack stack2 = type.getRecipe(stacks);
if (stack2 != null) {
return stack2;
@@ -91,7 +91,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
}
};
List<IFlowerColor> colors = new ArrayList<>();
Collections.addAll(colors, EnumFlowerColor.VALUES);
Collections.addAll(colors, EnumFlowerColor.values());
listBox.setOptions(colors);
}
}
@@ -129,7 +129,7 @@ public class GardenLogic extends FarmLogic {
if (pH.ordinal() < acidity.ordinal()) {
ItemStack stack = getAvailableAlkaline();
if (stack != null && soil
.setPH(world, position.x, position.y, position.z, EnumAcidity.VALUES[pH.ordinal() + 1])) {
.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() + 1])) {
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
continue;
}
@@ -138,7 +138,7 @@ public class GardenLogic extends FarmLogic {
if (pH.ordinal() > acidity.ordinal()) {
ItemStack stack = getAvailableAcid();
if (stack != null && soil
.setPH(world, position.x, position.y, position.z, EnumAcidity.VALUES[pH.ordinal() - 1])) {
.setPH(world, position.x, position.y, position.z, EnumAcidity.values()[pH.ordinal() - 1])) {
housing.getFarmInventory().removeResources(new ItemStack[] { stack });
continue;
}
@@ -55,7 +55,7 @@ public class BlockFlower extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumFlowerType type : EnumFlowerType.VALUES) {
for (EnumFlowerType type : EnumFlowerType.values()) {
type.registerIcons(register);
}
}
@@ -1,7 +1,5 @@
package binnie.botany.flower;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.block.Block;
@@ -11,8 +9,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
@@ -21,25 +17,18 @@ import net.minecraft.world.World;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerColor;
import binnie.botany.api.IFlowerGenome;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.genetics.AlleleColor;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.genetics.EnumFlowerType;
import binnie.botany.genetics.Flower;
import binnie.botany.genetics.FlowerSpecies;
import binnie.core.BinnieCore;
import binnie.core.util.I18N;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Config;
@@ -50,8 +39,6 @@ public abstract class ItemBotany extends Item {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName(name);
hasSubtypes = true;
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -70,44 +57,12 @@ public abstract class ItemBotany extends Item {
return false;
}
static IAllele getRenderAllele(ItemStack stack, EnumFlowerChromosome chromosome, boolean active) {
if (stack == null || !stack.hasTagCompound()) return null;
NBTTagCompound genome = stack.getTagCompound().getCompoundTag("Genome");
NBTTagList chromosomes = genome.getTagList("Chromosomes", 10);
int slot = chromosome.ordinal();
NBTTagCompound chromosomeTag = null;
for (int index = chromosomes.tagCount() - 1; index >= 0; index--) {
NBTTagCompound candidate = chromosomes.getCompoundTagAt(index);
if (candidate.getByte("Slot") == slot) {
chromosomeTag = candidate;
break;
}
}
if (chromosomeTag == null) return null;
Class<? extends IAllele> alleleClass = chromosome.getAlleleClass();
IAllele primary = AlleleManager.alleleRegistry.getAllele(chromosomeTag.getString("UID0"));
if (!alleleClass.isInstance(primary)) return null;
IAllele secondary = AlleleManager.alleleRegistry.getAllele(chromosomeTag.getString("UID1"));
if (!alleleClass.isInstance(secondary)) return null;
if (!active) return primary;
if (primary.isDominant()) return primary;
return secondary.isDominant() ? secondary : primary;
}
@Override
public boolean hasEffect(ItemStack stack, int pass) {
if (!stack.hasTagCompound()) {
return false;
}
IAllele allele = getRenderAllele(stack, EnumFlowerChromosome.SPECIES, false);
if (allele instanceof IAlleleFlowerSpecies species) {
return species.hasEffect();
}
IIndividual individual = getIndividual(stack);
return individual != null && individual.getGenome() != null && individual.hasEffect();
}
@@ -193,17 +148,6 @@ public abstract class ItemBotany extends Item {
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
if (!itemstack.hasTagCompound()) {
return (renderPass == 0 ? EnumFlowerColor.GREEN : EnumFlowerColor.RED).getColor(false);
}
EnumFlowerChromosome chromosome = renderPass == 0 ? EnumFlowerChromosome.STEM
: renderPass == 1 ? EnumFlowerChromosome.PRIMARY : EnumFlowerChromosome.SECONDARY;
IAllele allele = getRenderAllele(itemstack, chromosome, true);
if (allele instanceof AlleleColor color) {
return color.getColor().getColor(itemstack.getTagCompound().getBoolean("Wilt"));
}
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null) {
return 0xffffff;
@@ -229,32 +173,19 @@ public abstract class ItemBotany extends Item {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) {
IAlleleFlowerSpecies species = FlowerSpecies.POPPY;
boolean flowered = false;
if (itemstack.hasTagCompound()) {
IAllele allele = getRenderAllele(itemstack, EnumFlowerChromosome.SPECIES, false);
if (allele instanceof IAlleleFlowerSpecies flowerSpecies) {
species = flowerSpecies;
flowered = itemstack.getTagCompound().getBoolean("Flowered");
} else {
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return EnumFlowerType.ALLIUM.getBlank();
}
species = flower.getGenome().getPrimary();
flowered = flower.hasFlowered();
}
IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return EnumFlowerType.ALLIUM.getBlank();
}
IFlowerType type = species.getType();
IFlowerType type = flower.getGenome().getPrimary().getType();
if (renderPass == 0) {
return type.getStem(getStage(), flowered, type.getSections() - 1);
return type.getStem(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
if (renderPass == 1) {
return type.getPetalIcon(getStage(), flowered, type.getSections() - 1);
return type.getPetalIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
return type.getVariantIcon(getStage(), flowered, type.getSections() - 1);
return type.getVariantIcon(getStage(), flower.hasFlowered(), type.getSections() - 1);
}
@Override
@@ -1,7 +1,5 @@
package binnie.botany.flower;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -27,8 +25,6 @@ public class ItemInsulatedTube extends Item {
setUnlocalizedName("insulatedTube");
setCreativeTab(CreativeTabBotany.instance);
setHasSubtypes(true);
registerItem(this, getUnlocalizedName().substring(5));
}
public static ItemStack getInsulateStack(ItemStack stack) {
@@ -38,8 +34,8 @@ public class ItemInsulatedTube extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Material mat : Material.VALUES) {
for (Insulate ins : Insulate.VALUES) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
list.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
}
}
@@ -97,8 +93,6 @@ public class ItemInsulatedTube extends Item {
Bronze(0xddc276, "bronze"),
Iron(0xd8d8d8, "iron");
public static final Material[] VALUES = values();
private final int color;
private final String name;
@@ -108,7 +102,7 @@ public class ItemInsulatedTube extends Item {
}
public static Material get(int i) {
return VALUES[i % VALUES.length];
return values()[i % values().length];
}
public int getColor() {
@@ -129,8 +123,6 @@ public class ItemInsulatedTube extends Item {
Stone(0x6d6d6d, "smoothStone"),
Sandstone(0xc1b989, "sandstone");
public static final Insulate[] VALUES = values();
private final int color;
private final String name;
@@ -140,7 +132,7 @@ public class ItemInsulatedTube extends Item {
}
public static Insulate get(int i) {
return VALUES[i / 128 % VALUES.length];
return values()[i / 128 % values().length];
}
public int getColor() {
@@ -48,7 +48,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (Type t : Type.VALUES) {
for (Type t : Type.values()) {
t.icon = Botany.proxy.getIcon(register, t.name().toLowerCase());
}
}
@@ -61,7 +61,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return Type.VALUES[meta % Type.VALUES.length].icon;
return Type.values()[meta % Type.values().length].icon;
}
@Override
@@ -72,7 +72,7 @@ public class BlockPlant extends BlockBush {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Type type : Type.VALUES) {
for (Type type : Type.values()) {
list.add(type.get());
}
}
@@ -135,7 +135,6 @@ public class BlockPlant extends BlockBush {
DeadFlower("deadFlower"),
DecayingFlower("decayingFlower");
public static final Type[] VALUES = values();
public IIcon icon;
private final String name;
@@ -145,7 +144,7 @@ public class BlockPlant extends BlockBush {
}
public static Type get(int id) {
return VALUES[id % VALUES.length];
return values()[id % values().length];
}
public ItemStack get() {
@@ -81,8 +81,8 @@ public class BlockSoil extends Block implements IBlockSoil {
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
for (EnumMoisture moisture : EnumMoisture.VALUES) {
for (EnumAcidity pH : EnumAcidity.VALUES) {
for (EnumMoisture moisture : EnumMoisture.values()) {
for (EnumAcidity pH : EnumAcidity.values()) {
int index = moisture.ordinal() + pH.ordinal() * 3;
String id = "soil/" + getType().getID() + "." + pH.getID() + "." + moisture.getID();
iconsTop[index] = Botany.proxy.getIcon(register, id + ".0");
@@ -104,8 +104,8 @@ public class BlockSoil extends Block implements IBlockSoil {
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
EnumMoisture moisture = EnumMoisture.VALUES[meta % 3];
EnumAcidity acidity = EnumAcidity.VALUES[meta / 3];
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z);
if (desiredMoisture.ordinal() > moisture.ordinal()) {
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
@@ -141,12 +141,12 @@ public class BlockSoil extends Block implements IBlockSoil {
@Override
public EnumAcidity getPH(World world, int x, int y, int z) {
return EnumAcidity.VALUES[world.getBlockMetadata(x, y, z) / 3];
return EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3];
}
@Override
public EnumMoisture getMoisture(World world, int x, int y, int z) {
return EnumMoisture.VALUES[world.getBlockMetadata(x, y, z) % 3];
return EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3];
}
@Override
@@ -233,8 +233,8 @@ public class Gardening {
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
return canTolerate(
flower,
EnumAcidity.VALUES[soilMeta / 3 % 3],
EnumMoisture.VALUES[soilMeta % 3],
EnumAcidity.values()[soilMeta / 3 % 3],
EnumMoisture.values()[soilMeta % 3],
EnumTemperature.getFromValue(biome.temperature));
}
@@ -33,8 +33,8 @@ public class ItemSoil extends ItemBlock {
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
super.addInformation(stack, player, tooltip, advanced);
EnumMoisture moisture = EnumMoisture.VALUES[stack.getItemDamage() % 3];
EnumAcidity acidity = EnumAcidity.VALUES[stack.getItemDamage() / 3];
EnumMoisture moisture = EnumMoisture.values()[stack.getItemDamage() % 3];
EnumAcidity acidity = EnumAcidity.values()[stack.getItemDamage() / 3];
String info = "";
if (moisture == EnumMoisture.DRY) {
@@ -1,7 +1,5 @@
package binnie.botany.gardening;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,8 +28,6 @@ public class ItemSoilMeter extends Item {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("soilMeter");
setMaxStackSize(1);
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -1,7 +1,5 @@
package binnie.botany.gardening;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,8 +28,6 @@ public class ItemTrowel extends Item {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("trowel" + material);
locName = "trowel" + material;
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -18,7 +18,7 @@ public class ItemWeed extends ItemBlock {
@Override
public String getItemStackDisplayName(ItemStack stack) {
return BlockPlant.Type.VALUES[stack.getItemDamage()].getName();
return BlockPlant.Type.values()[stack.getItemDamage()].getName();
}
@Override
@@ -12,6 +12,7 @@ import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
@@ -36,7 +37,6 @@ import binnie.core.block.ItemMetadata;
import binnie.core.block.ItemMetadataRenderer;
import binnie.core.block.MultipassItemRenderer;
import binnie.core.block.TileEntityMetadata;
import binnie.core.item.ItemMisc;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModuleGardening implements IInitializable {
@@ -75,7 +75,7 @@ public class ModuleGardening implements IInitializable {
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "Iron");
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.EMERALD, "Diamond");
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "Gold");
Botany.misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
Botany.misc = Binnie.Item.registerMiscItems(BotanyItems.values(), CreativeTabBotany.instance);
Botany.pigment = new ItemPigment();
Botany.clay = new ItemClay();
@@ -109,7 +109,7 @@ public class ModuleGardening implements IInitializable {
for (boolean manual : new boolean[] { true, false }) {
for (boolean fertilised : new boolean[] { true, false }) {
for (EnumMoisture moist : EnumMoisture.VALUES) {
for (EnumMoisture moist : EnumMoisture.values()) {
ItemStack icon = (moist == EnumMoisture.DRY) ? yellow
: ((moist == EnumMoisture.NORMAL) ? red : blue);
int insulate = 2 - moist.ordinal();
@@ -258,7 +258,7 @@ public class ModuleGardening implements IInitializable {
GameRegistry
.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.clay_ball, 'g', Blocks.gravel);
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
GameRegistry.addShapelessRecipe(clay, Items.clay_ball, Items.clay_ball, Items.clay_ball, pigment);
@@ -276,9 +276,9 @@ public class ModuleGardening implements IInitializable {
return null;
}
return new ItemStack(
Gardening.getSoilBlock(EnumSoilType.VALUES[type]),
Gardening.getSoilBlock(EnumSoilType.values()[type]),
1,
BlockSoil.getMeta(EnumAcidity.VALUES[pH], EnumMoisture.VALUES[moisture]));
BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
}
private void addAcidFertiliser(ItemStack stack, int strengthMax) {
@@ -92,10 +92,7 @@ public enum EnumFlowerColor implements IFlowerColor {
YELLOW("yellow", 0xffff00),
YELLOW_GREEN("yellowGreen", 0x9acd32);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumFlowerColor[] VALUES = values();
private static final EnumFlowerColor[] ALL_VALUES = values();
private final int color;
private final int colorDis;
private final String name;
@@ -2967,7 +2964,7 @@ public enum EnumFlowerColor implements IFlowerColor {
}
public static EnumFlowerColor get(int i) {
return VALUES[Math.max(0, i) % VALUES.length];
return ALL_VALUES[Math.max(0, i) % ALL_VALUES.length];
}
@Override
@@ -57,10 +57,6 @@ public enum EnumFlowerType implements IFlowerType {
DELPHINIUM(2),
HOLLYHOCK(2);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumFlowerType[] VALUES = values();
private final int sections;
private final IIcon[] stem;
private final IIcon[] petal;
@@ -232,7 +232,7 @@ public class FlowerHelper extends SpeciesRoot implements IFlowerRoot {
@Override
public IChromosomeType[] getKaryotype() {
return EnumFlowerChromosome.VALUES;
return EnumFlowerChromosome.values();
}
@Override
@@ -496,7 +496,7 @@ public enum FlowerSpecies implements IAlleleFlowerSpecies {
@Override
public EnumHumidity getHumidity() {
return EnumHumidity.VALUES[getMoisture().ordinal()];
return EnumHumidity.values()[getMoisture().ordinal()];
}
@Override
@@ -8,14 +8,8 @@ import forestry.core.genetics.alleles.EnumAllele;
public class FlowerTemplates {
private static IAllele[] defaultTemplate;
public static IAllele[] getDefaultTemplate() {
if (defaultTemplate != null) {
return defaultTemplate.clone();
}
IAllele[] alleles = new IAllele[EnumFlowerChromosome.VALUES.length];
IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
alleles[EnumFlowerChromosome.SPECIES.ordinal()] = FlowerSpecies.POPPY;
alleles[EnumFlowerChromosome.PRIMARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
alleles[EnumFlowerChromosome.SECONDARY.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.RED);
@@ -28,13 +22,6 @@ public class FlowerTemplates {
alleles[EnumFlowerChromosome.PH_TOLERANCE.ordinal()] = AlleleHelper.getAllele(EnumTolerance.NONE);
alleles[EnumFlowerChromosome.SAPPINESS.ordinal()] = AlleleHelper.getAllele(EnumAllele.Sappiness.AVERAGE);
alleles[EnumFlowerChromosome.STEM.ordinal()] = AlleleHelper.getAllele(EnumFlowerColor.GREEN);
for (IAllele allele : alleles) {
// Do not cache a partial template during registry initialization.
if (allele == null) return alleles;
}
defaultTemplate = alleles;
return defaultTemplate.clone();
return alleles;
}
}
@@ -1,7 +1,5 @@
package binnie.botany.genetics;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -27,8 +25,6 @@ public class ItemDictionary extends Item {
setCreativeTab(CreativeTabBotany.instance);
setUnlocalizedName("database");
setMaxStackSize(1);
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -42,7 +42,7 @@ public class ModuleGenetics implements IInitializable {
@Override
public void init() {
for (EnumFlowerColor color : EnumFlowerColor.VALUES) {
for (EnumFlowerColor color : EnumFlowerColor.values()) {
AlleleManager.alleleRegistry.registerAllele(color.getAllele());
}
@@ -1,7 +1,5 @@
package binnie.botany.items;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -24,8 +22,6 @@ public class ItemClay extends Item {
setUnlocalizedName("clay");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -49,7 +45,7 @@ public class ItemClay extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@@ -1,7 +1,5 @@
package binnie.botany.items;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -24,8 +22,6 @@ public class ItemPigment extends Item {
setUnlocalizedName("pigment");
setHasSubtypes(true);
setCreativeTab(CreativeTabBotany.instance);
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
@@ -49,7 +45,7 @@ public class ItemPigment extends Item {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (EnumFlowerColor c : EnumFlowerColor.VALUES) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
list.add(new ItemStack(this, 1, c.ordinal()));
}
}
@@ -39,10 +39,10 @@ public class MessageFlowerUpdate extends MessageCoordinates {
public void readData(ByteBuf data) throws IOException {
super.readData(data);
render = new TileEntityFlower.RenderInfo();
render.primary = EnumFlowerColor.get(data.readByte());
render.secondary = EnumFlowerColor.get(data.readByte());
render.stem = EnumFlowerColor.get(data.readByte());
render.type = EnumFlowerType.VALUES[data.readByte()];
render.primary = EnumFlowerColor.values()[data.readByte()];
render.secondary = EnumFlowerColor.values()[data.readByte()];
render.stem = EnumFlowerColor.values()[data.readByte()];
render.type = EnumFlowerType.values()[data.readByte()];
render.age = data.readByte();
render.section = data.readByte();
render.wilted = data.readBoolean();
@@ -1,9 +1,13 @@
package binnie.core;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import binnie.core.gui.IBinnieGUID;
import binnie.core.mod.parser.FieldParser;
import binnie.core.network.BinniePacketHandler;
import binnie.core.network.IPacketID;
import binnie.core.network.IPacketProvider;
@@ -16,9 +20,11 @@ import cpw.mods.fml.relauncher.Side;
public abstract class AbstractMod implements IPacketProvider, IInitializable {
private SimpleNetworkWrapper wrapper;
private final LinkedHashSet<Field> fields;
protected final List<IInitializable> modules;
public AbstractMod() {
fields = new LinkedHashSet<>();
modules = new ArrayList<>();
BinnieCore.registerMod(this);
}
@@ -59,6 +65,22 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
for (IInitializable module : modules) {
module.preInit();
}
// TODO what does it mean?
Collections.addAll(fields, getClass().getFields());
for (Class<?> cls : getClass().getClasses()) {
Collections.addAll(fields, getClass().getFields());
}
for (IInitializable module : modules) {
Collections.addAll(fields, module.getClass().getFields());
}
for (Field field4 : fields) {
try {
FieldParser.preInitParse(field4, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
@@ -74,6 +96,14 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
for (IInitializable module : modules) {
module.init();
}
for (Field field : fields) {
try {
FieldParser.initParse(field, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Override
@@ -86,6 +116,14 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
for (IInitializable module : modules) {
module.postInit();
}
for (Field field : fields) {
try {
FieldParser.postInitParse(field, this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
protected void addModule(IInitializable init) {
+4 -4
View File
@@ -12,7 +12,6 @@ import net.minecraftforge.common.MinecraftForge;
import binnie.Binnie;
import binnie.core.block.MultipassBlockRenderer;
import binnie.core.block.TileEntityMetadata;
import binnie.core.config.BCConfig;
import binnie.core.craftgui.minecraft.ModuleCraftGUI;
import binnie.core.gui.BinnieCoreGUI;
import binnie.core.gui.BinnieGUIHandler;
@@ -23,6 +22,8 @@ import binnie.core.liquid.FluidContainer;
import binnie.core.liquid.ItemFluidContainer;
import binnie.core.machines.MachineGroup;
import binnie.core.machines.storage.ModuleStorage;
import binnie.core.mod.parser.FieldParser;
import binnie.core.mod.parser.ItemParser;
import binnie.core.network.BinnieCorePacketID;
import binnie.core.network.BinniePacketHandler;
import binnie.core.network.IPacketID;
@@ -79,9 +80,7 @@ public class BinnieCore extends AbstractMod {
}
addModule(new ModuleCraftGUI());
if (!BCConfig.disableCompartments) {
addModule(new ModuleStorage());
}
addModule(new ModuleStorage());
addModule(new ModuleItems());
if (Loader.isModLoaded("BuildCraft|Silicon")) {
addModule(new ModuleTrigger());
@@ -111,6 +110,7 @@ public class BinnieCore extends AbstractMod {
Item item = new ItemFluidContainer(container);
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
}
FieldParser.parsers.add(new ItemParser());
super.preInit();
}
@@ -17,8 +17,6 @@ public class ItemMetadata extends ItemBlock {
public ItemMetadata(Block block) {
super(block);
setMaxDamage(0);
setHasSubtypes(true);
}
@Override
@@ -14,7 +14,6 @@ public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler {
public static MultipassBlockRenderer instance;
private static int layer = 0;
private static boolean rendering = false;
public MultipassBlockRenderer() {
MultipassBlockRenderer.instance = this;
@@ -24,49 +23,31 @@ public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler {
return MultipassBlockRenderer.layer;
}
public static boolean isRendering() {
return MultipassBlockRenderer.rendering;
}
@Override
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
IMultipassBlock multipassBlock = (IMultipassBlock) block;
int passes = multipassBlock.getNumberOfPasses();
block.setBlockBoundsForItemRender();
renderer.setRenderBoundsFromBlock(block);
GL11.glTranslatef(-0.5f, -0.5f, -0.5f);
MultipassBlockRenderer.rendering = true;
try {
for (int pass = 0; pass < passes; ++pass) {
MultipassBlockRenderer.layer = pass;
renderItem(block, multipassBlock, renderer, meta);
}
} finally {
MultipassBlockRenderer.layer = 0;
MultipassBlockRenderer.rendering = false;
MultipassBlockRenderer.layer = 0;
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
renderItem(block, renderer, meta);
MultipassBlockRenderer.layer++;
}
MultipassBlockRenderer.layer = 0;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
RenderBlocks renderer) {
IMultipassBlock multipassBlock = (IMultipassBlock) block;
int passes = multipassBlock.getNumberOfPasses();
boolean rendered = true;
MultipassBlockRenderer.rendering = true;
try {
for (int pass = 0; pass < passes; ++pass) {
MultipassBlockRenderer.layer = pass;
rendered = renderer.renderStandardBlock(block, x, y, z);
}
return rendered;
} finally {
MultipassBlockRenderer.layer = 0;
MultipassBlockRenderer.rendering = false;
boolean r = true;
MultipassBlockRenderer.layer = 0;
while (MultipassBlockRenderer.layer < ((IMultipassBlock) block).getNumberOfPasses()) {
r = renderer.renderStandardBlock(block, x, y, z);
MultipassBlockRenderer.layer++;
}
MultipassBlockRenderer.layer = 0;
return r;
}
@Override
@@ -79,8 +60,8 @@ public class MultipassBlockRenderer implements ISimpleBlockRenderingHandler {
return BinnieCore.multipassRenderID;
}
private void renderItem(Block block, IMultipassBlock multipassBlock, RenderBlocks renderer, int meta) {
setColor(multipassBlock.colorMultiplier(meta));
public void renderItem(Block block, RenderBlocks renderer, int meta) {
setColor(((IMultipassBlock) block).colorMultiplier(meta));
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setNormal(0.0f, -1.0f, 0.0f);
@@ -1,14 +0,0 @@
package binnie.core.config;
import com.gtnewhorizon.gtnhlib.config.Config;
import binnie.core.BinnieCore;
@Config(modid = BinnieCore.CORE_MODID)
public class BCConfig {
@Config.Comment("If true, disables all compartment storage machines (no blocks/recipes will be registered).")
@Config.DefaultBoolean(false)
@Config.RequiresMcRestart
public static boolean disableCompartments;
}
@@ -1,7 +1,10 @@
package binnie.core.craftgui;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.ListIterator;
import org.lwjgl.input.Mouse;
@@ -165,14 +168,17 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
}
public Deque<IWidget> calculateMousedOverWidgets() {
Deque<IWidget> widgets = new ArrayDeque<>();
addMousedOverWidgets(this, widgets);
return widgets;
Deque<IWidget> list = new ArrayDeque<>();
for (IWidget widget : getQueuedWidgets(this)) {
if (widget.calculateIsMouseOver()) {
list.addLast(widget);
}
}
return list;
}
private void addMousedOverWidgets(IWidget widget, Deque<IWidget> widgets) {
if (!widget.isVisible()) return;
private Collection<IWidget> getQueuedWidgets(IWidget widget) {
List<IWidget> widgets = new ArrayList<>();
boolean addChildren = true;
if (widget.isCroppedWidget()) {
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
@@ -182,12 +188,11 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
while (li.hasPrevious()) {
IWidget child = li.previous();
addMousedOverWidgets(child, widgets);
widgets.addAll(getQueuedWidgets(child));
}
}
if (widget.calculateIsMouseOver()) {
widgets.addLast(widget);
}
widgets.add(widget);
return widgets;
}
@Override
+6 -16
View File
@@ -194,7 +194,7 @@ public class Widget implements IWidget {
@Override
public void setOffset(IPoint offset) {
if (!offset.equals(this.offset)) {
if (offset != this.offset) {
this.offset = new IPoint(offset);
callEvent(new EventWidget.ChangeOffset(this));
}
@@ -285,10 +285,6 @@ public class Widget implements IWidget {
onRender(RenderStage.PreChildren);
for (IWidget widget : getWidgets()) {
if (!widget.isVisible()) {
continue;
}
widget.render();
CraftGUI.render.preRender(widget);
widget.onRender(RenderStage.PostSiblings);
@@ -310,22 +306,17 @@ public class Widget implements IWidget {
}
onUpdateClient();
List<IWidget> deletedWidgets = null;
List<IWidget> deletedWidgets = new ArrayList<>();
for (IWidget widget : getWidgets()) {
if (widget.hasAttribute(WidgetAttribute.NEEDS_DELETION)) {
if (deletedWidgets == null) {
deletedWidgets = new ArrayList<>();
}
deletedWidgets.add(widget);
} else {
widget.updateClient();
}
}
if (deletedWidgets != null) {
for (IWidget widget : deletedWidgets) {
deleteChild(widget);
}
for (IWidget widget : deletedWidgets) {
deleteChild(widget);
}
}
@@ -347,7 +338,7 @@ public class Widget implements IWidget {
@Override
public boolean isMouseOverWidget(IPoint relativeMouse) {
return contains(relativeMouse);
return getArea().contains(relativeMouse);
}
@Override
@@ -475,8 +466,7 @@ public class Widget implements IWidget {
@Override
public boolean contains(IPoint position) {
IPoint size = size();
return position.x() >= 0.0f && position.y() >= 0.0f && position.x() <= size.x() && position.y() <= size.y();
return getArea().contains(position);
}
@Override
@@ -188,9 +188,7 @@ public class WindowFieldKit extends Window {
glassOffsetX *= 1.0f - analyseProgress;
glassOffsetY += glassVY;
glassOffsetY *= 1.0f - analyseProgress;
if (GlassControl != null) {
GlassControl.setOffset(new IPoint(glassOffsetX, glassOffsetY));
}
GlassControl.setOffset(new IPoint(glassOffsetX, glassOffsetY));
}
private void refreshSpecies() {
@@ -1,8 +1,5 @@
package binnie.core.craftgui.controls.tab;
import java.util.IdentityHashMap;
import java.util.Map;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.ITooltip;
import binnie.core.craftgui.Tooltip;
@@ -24,7 +21,6 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
protected T value;
private final ControlTabBar<T> tabBar;
private final Map<Texture, Texture> croppedTextures = new IdentityHashMap<>();
public ControlTab(ControlTabBar<T> parent, float x, float y, float w, float h, T value) {
super(parent, x, y, w, h);
@@ -49,8 +45,9 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
texture = CraftGUITexture.Tab;
}
Texture lTexture = CraftGUI.render.getTexture(texture);
Position position = getTabPosition();
Texture iTexture = getCroppedTexture(texture);
Texture iTexture = lTexture.crop(position, 8.0f);
IArea area = getArea();
if (texture == CraftGUITexture.TabDisabled) {
if (position == Position.TOP || position == Position.LEFT) {
@@ -71,23 +68,14 @@ public class ControlTab<T> extends Control implements ITooltip, IControlValue<T>
}
if (icon.hasOutline()) {
iTexture = getCroppedTexture(CraftGUITexture.TabOutline);
iTexture = CraftGUI.render.getTexture(CraftGUITexture.TabOutline);
iTexture = iTexture.crop(position, 8.0f);
CraftGUI.render.color(icon.getOutlineColor());
CraftGUI.render.texture(iTexture, area.inset(2));
}
}
}
private Texture getCroppedTexture(Object key) {
Texture source = CraftGUI.render.getTexture(key);
Texture cropped = croppedTextures.get(source);
if (cropped == null) {
cropped = source.crop(getTabPosition(), 8.0f);
croppedTextures.put(source, cropped);
}
return cropped;
}
@Override
public void getTooltip(Tooltip tooltip) {
String name = getName();
@@ -4,7 +4,6 @@ import static net.minecraftforge.common.util.Constants.NBT.TAG_COMPOUND;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
@@ -38,8 +37,6 @@ import binnie.core.machines.power.TankInfo;
import binnie.core.machines.transfer.TransferRequest;
import binnie.core.network.packet.MessageContainerUpdate;
import cpw.mods.fml.relauncher.Side;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class ContainerCraftGUI extends Container {
@@ -83,7 +80,6 @@ public class ContainerCraftGUI extends Container {
private final Map<String, NBTTagCompound> syncedNBT = new HashMap<>();
private final Map<String, NBTTagCompound> sentNBT = new HashMap<>();
private final Map<Integer, TankInfo> syncedTanks = new HashMap<>();
private final Map<IInventory, Int2ObjectMap<CustomSlot>> slotsByInventory = new IdentityHashMap<>();
private PowerInfo syncedPower = new PowerInfo();
private ProcessInfo syncedProcess = new ProcessInfo();
private int errorType = 0;
@@ -113,17 +109,9 @@ public class ContainerCraftGUI extends Container {
@Override
protected Slot addSlotToContainer(Slot slot) {
indexSlot(slot);
return super.addSlotToContainer(slot);
}
private void indexSlot(Slot slot) {
if (slot instanceof CustomSlot customSlot) {
slotsByInventory.computeIfAbsent(customSlot.inventory, key -> new Int2ObjectOpenHashMap<>())
.putIfAbsent(customSlot.getSlotIndex(), customSlot);
}
}
private Side getSide() {
return window.isServer() ? Side.SERVER : Side.CLIENT;
}
@@ -213,22 +201,22 @@ public class ContainerCraftGUI extends Container {
Slot shiftClickedSlot = inventorySlots.get(index);
ItemStack itemstack = null;
if (shiftClickedSlot.getHasStack()) {
itemstack = shiftClickedSlot.getStack();
itemstack = shiftClickedSlot.getStack().copy();
}
IInventory playerInventory = player.inventory;
IInventory entityInventory = window.getInventory();
IInventory windowInventory = window.getWindowInventory();
IInventory fromPlayer = (entityInventory == null) ? windowInventory : entityInventory;
int[] target = new int[36];
for (int i = 0; i < target.length; ++i) {
target[i] = i;
}
TransferRequest request;
if (shiftClickedSlot.inventory == playerInventory) {
request = new TransferRequest(itemstack, fromPlayer).setOrigin(shiftClickedSlot.inventory);
} else {
int[] target = new int[36];
for (int i = 0; i < target.length; ++i) {
target[i] = i;
}
request = new TransferRequest(itemstack, playerInventory).setOrigin(shiftClickedSlot.inventory)
.setTargetSlots(target);
}
@@ -246,7 +234,7 @@ public class ContainerCraftGUI extends Container {
ItemStack heldItem = player.inventory.getItemStack().copy();
IInventory entityInventory = window.getInventory();
heldItem = new TransferRequest(heldItem, entityInventory).setOrigin(player.inventory).setTargetSlots(new int[0])
.setTargetTanks(new int[] { slotID }).dropOverflow(player).transfer(true);
.setTargetTanks(new int[] { slotID }).transfer(true);
player.inventory.setItemStack(heldItem);
@@ -258,14 +246,7 @@ public class ContainerCraftGUI extends Container {
}
public void handleNBT(Side side, EntityPlayer player, NBTTagCompound action) {
if (handleNBTAction(side, player, action)) {
sendContainerContents();
}
}
private boolean handleNBTAction(Side side, EntityPlayer player, NBTTagCompound action) {
final String actionType = action.getString(ACTION_TYPE);
boolean slotRegistered = false;
if (side == Side.SERVER) {
switch (actionType) {
@@ -275,7 +256,11 @@ public class ContainerCraftGUI extends Container {
final int slotIndex = action.getShort(SLOT_INDEX);
final int slotNumber = action.getShort(SLOT_NUMBER);
slotRegistered = createSlot(InventoryType.values()[slotType % 4], slotIndex, slotNumber);
createSlot(InventoryType.values()[slotType % 4], slotIndex, slotNumber);
for (ICrafting crafterObject : crafters) {
crafterObject.sendContainerAndContentsToPlayer(this, getInventory());
}
}
}
}
@@ -290,7 +275,6 @@ public class ContainerCraftGUI extends Container {
if (actionType.contains(TANK_UPDATE)) onTankUpdate(action);
}
}
return slotRegistered;
}
@Override
@@ -323,7 +307,8 @@ public class ContainerCraftGUI extends Container {
if (machineSync != null) machineSync.sendGuiNBT(syncedNBT);
NBTTagList actions = null;
Map<String, NBTTagCompound> sentThisTime = new HashMap<>();
NBTTagList actions = new NBTTagList();
for (Map.Entry<String, NBTTagCompound> entry : syncedNBT.entrySet()) {
final String actionType = entry.getKey();
@@ -332,18 +317,12 @@ public class ContainerCraftGUI extends Container {
action.setString(ACTION_TYPE, actionType);
if (action == actionPrev || action.equals(actionPrev)) continue;
if (action.equals(actionPrev)) continue;
if (actions == null) {
actions = new NBTTagList();
}
actions.appendTag(action);
sentNBT.put(actionType, action);
sentThisTime.put(actionType, action);
}
syncedNBT.clear();
if (actions == null) return;
NBTTagCompound actionsBatch = new NBTTagCompound();
actionsBatch.setString(ACTION_TYPE, ACTION_BATCH);
actionsBatch.setTag(ACTIONS, actions);
@@ -354,6 +333,9 @@ public class ContainerCraftGUI extends Container {
BinnieCore.proxy.sendToPlayer(packet, playerMP);
}
}
sentNBT.putAll(sentThisTime);
syncedNBT.clear();
}
private NBTTagCompound createErrorNBT(IErrorStateSource error) {
@@ -494,39 +476,29 @@ public class ContainerCraftGUI extends Container {
}
private CustomSlot getSlot(IInventory inventory, int id) {
Int2ObjectMap<CustomSlot> slots = slotsByInventory.get(inventory);
return (slots == null) ? null : slots.get(id);
for (Object o : inventorySlots) {
CustomSlot slot = (CustomSlot) o;
if (slot.inventory == inventory && slot.getSlotIndex() == id) {
return slot;
}
}
return null;
}
public void receiveNBT(Side side, EntityPlayer player, NBTTagCompound action) {
if (receiveNBTAction(side, player, action)) {
sendContainerContents();
}
}
private boolean receiveNBTAction(Side side, EntityPlayer player, NBTTagCompound action) {
String actionType = action.getString(ACTION_TYPE);
if (actionType.equals(ACTION_BATCH)) {
boolean slotRegistered = false;
NBTTagList actionsBatch = action.getTagList(ACTIONS, TAG_COMPOUND);
for (int i = 0; i < actionsBatch.tagCount(); i++) {
slotRegistered |= receiveNBTAction(side, player, actionsBatch.getCompoundTagAt(i));
receiveNBT(side, player, actionsBatch.getCompoundTagAt(i));
}
return slotRegistered;
return;
}
boolean slotRegistered = handleNBTAction(side, player, action);
handleNBT(side, player, action);
window.receiveGuiNBT(getSide(), player, actionType, action);
INetwork.ReceiveGuiNBT machine = Machine.getInterface(INetwork.ReceiveGuiNBT.class, window.getInventory());
if (machine != null) {
machine.receiveGuiNBT(getSide(), player, actionType, action);
}
return slotRegistered;
}
private void sendContainerContents() {
for (ICrafting crafter : crafters) {
crafter.sendContainerAndContentsToPlayer(this, getInventory());
}
if (machine == null) return;
machine.receiveGuiNBT(getSide(), player, actionType, action);
}
public Slot getOrCreateSlot(InventoryType inventoryType, int slotIndex) {
@@ -550,16 +522,13 @@ public class ContainerCraftGUI extends Container {
};
}
private boolean createSlot(InventoryType type, int index, int slotNumber) {
if (inventorySlots.get(slotNumber) != null) return false;
private void createSlot(InventoryType type, int index, int slotNumber) {
if (inventorySlots.get(slotNumber) != null) return;
IInventory inventory = getInventory(type);
Slot slot = new CustomSlot(inventory, index);
slot.slotNumber = slotNumber;
indexSlot(slot);
inventorySlots.add(slotNumber, slot);
ItemStack stack = slot.getStack();
inventoryItemStacks.add(slotNumber, stack == null ? null : stack.copy());
return true;
inventoryItemStacks.add(slotNumber, null);
}
}
@@ -11,9 +11,6 @@ import binnie.core.machines.inventory.InventorySlot;
public class CustomSlot extends Slot {
private InventorySlot inventorySlot;
private boolean inventorySlotResolved;
public CustomSlot(IInventory inventory, int index) {
super(inventory, index, 0, 0);
}
@@ -24,12 +21,11 @@ public class CustomSlot extends Slot {
}
public InventorySlot getInventorySlot() {
if (!inventorySlotResolved) {
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
inventorySlot = (slots == null) ? null : slots.getSlot(getSlotIndex());
inventorySlotResolved = true;
IInventorySlots slots = Machine.getInterface(IInventorySlots.class, inventory);
if (slots != null) {
return slots.getSlot(getSlotIndex());
}
return inventorySlot;
return null;
}
public boolean handleClick() {
@@ -20,10 +20,6 @@ public enum EnumColor {
Yellow("Yellow", 16777045, 'e'),
White("White", 16777215, 'f');
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final EnumColor[] VALUES = values();
private final int colour;
private final String name;
private final char code;
@@ -21,7 +21,6 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import binnie.core.BinnieCore;
import binnie.core.craftgui.IWidget;
@@ -84,31 +83,29 @@ public class GuiCraftGUI extends GuiContainer {
window.setMousePosition(mouseX - (int) window.getPosition().x(), mouseY - (int) window.getPosition().y());
drawDefaultBackground();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
zLevel = 10.0f;
GuiScreen.itemRender.zLevel = zLevel;
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
window.render();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
NEIHook.renderObjects(window, mouseX, mouseY);
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
InventoryPlayer playerInventory = mc.thePlayer.inventory;
draggedItem = playerInventory.getItemStack();
if (draggedItem != null) {
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
renderItem(new IPoint(mouseX - 8, mouseY - 8), draggedItem, false);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
@@ -119,6 +116,7 @@ public class GuiCraftGUI extends GuiContainer {
} else {
tooltip.setType(Tooltip.Type.STANDARD);
window.getTooltip(tooltip);
NEIHook.renderToolTips(mouseX, mouseY);
}
if (tooltip.exists()) {
@@ -135,7 +133,7 @@ public class GuiCraftGUI extends GuiContainer {
int mouseX = (int) mousePosition.x();
int mouseY = (int) mousePosition.y();
FontRenderer font = getFontRenderer();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glDisable(32826); // GL_RESCALE_NORMAL_EXT
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
@@ -226,7 +224,7 @@ public class GuiCraftGUI extends GuiContainer {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
}
@Override
@@ -242,16 +240,12 @@ public class GuiCraftGUI extends GuiContainer {
@Override
protected void keyTyped(char c, int key) {
boolean noFocusedWidget = window.getFocusedWidget() == null;
NEIHook.lastKeyTyped(key, c);
if (noFocusedWidget) {
NEIHook.lastKeyTyped(key, c);
}
if (key == 1 || (key == mc.gameSettings.keyBindInventory.getKeyCode() && noFocusedWidget)) {
if (key == 1 || (key == mc.gameSettings.keyBindInventory.getKeyCode() && window.getFocusedWidget() == null)) {
mc.thePlayer.closeScreen();
}
IWidget origin = noFocusedWidget ? window : window.getFocusedWidget();
IWidget origin = (window.getFocusedWidget() == null) ? window : window.getFocusedWidget();
window.callEvent(new EventKey.Down(origin, c, key));
}
@@ -426,9 +420,8 @@ public class GuiCraftGUI extends GuiContainer {
public void renderItem(IPoint pos, ItemStack item, boolean rotating) {
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT);
GL11.glPushAttrib(8256);
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
FontRenderer font = item.getItem().getFontRenderer(item);
if (font == null) {
@@ -451,7 +444,7 @@ public class GuiCraftGUI extends GuiContainer {
}
GuiScreen.itemRender.renderItemOverlayIntoGUI(font, mc.renderEngine, item, (int) pos.x(), (int) pos.y(), null);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glClear(256);
RenderHelper.disableStandardItemLighting();
GL11.glPopAttrib();
}
@@ -462,11 +455,11 @@ public class GuiCraftGUI extends GuiContainer {
}
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
BinnieCore.proxy.bindTexture(map);
GuiScreen.itemRender.zLevel = zLevel;
GuiScreen.itemRender.renderIcon((int) pos.x(), (int) pos.y(), icon, 16, 16);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(32826); // GL_RESCALE_NORMAL_EXT
GL11.glPopMatrix();
}
@@ -10,7 +10,6 @@ import java.util.Map;
class ListMap<T> implements List<T> {
private final LinkedHashMap<Integer, T> map;
private int size;
ListMap() {
map = new LinkedHashMap<>();
@@ -18,7 +17,13 @@ class ListMap<T> implements List<T> {
@Override
public int size() {
return size;
int i = -1;
for (int k : map.keySet()) {
if (k > i) {
i = k;
}
}
return i + 1;
}
@Override
@@ -88,7 +93,6 @@ class ListMap<T> implements List<T> {
@Override
public void clear() {
map.clear();
size = 0;
}
@Override
@@ -99,14 +103,12 @@ class ListMap<T> implements List<T> {
@Override
public T set(int index, T element) {
map.put(index, element);
size = Math.max(size, index + 1);
return element;
}
@Override
public void add(int index, T element) {
map.put(index, element);
size = Math.max(size, index + 1);
}
@Override
@@ -121,7 +123,7 @@ class ListMap<T> implements List<T> {
return entry.getKey();
}
}
return -1;
return 0;
}
@Override
@@ -1,5 +1,6 @@
package binnie.core.craftgui.minecraft;
import java.util.ArrayList;
import java.util.Deque;
import net.minecraft.entity.player.EntityPlayer;
@@ -46,14 +47,12 @@ import binnie.core.resource.BinnieResource;
import binnie.core.resource.ResourceType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
public abstract class Window extends TopLevelWidget implements INetwork.ReceiveGuiNBT {
protected float titleButtonLeft;
protected float titleButtonRight;
private GuiCraftGUI gui;
private Renderer renderer;
private final ContainerCraftGUI container;
private final WindowInventory windowInventory;
private ControlText title;
@@ -81,11 +80,11 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
setSize(new IPoint(width, height));
gui = new GuiCraftGUI(this);
for (EnumHighlighting h : EnumHighlighting.values()) {
ControlSlot.highlighting.put(h, new IntOpenHashSet());
ControlSlot.highlighting.put(h, new ArrayList<>());
}
renderer = new Renderer(gui);
renderer.stylesheet(StyleSheetManager.getDefault());
CraftGUI.render = new Renderer(gui);
CraftGUI.render.stylesheet(StyleSheetManager.getDefault());
titleButtonLeft = -14.0f;
if (showHelpButton()) {
@@ -196,9 +195,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
}
public void initGui() {
CraftGUI.render = renderer;
if (hasBeenInitialised) {
return;
}
@@ -271,9 +267,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
entityInventory = inventory;
}
public void onClose() {
CraftGUI.render = null;
}
public void onClose() {}
public boolean isServer() {
return !isClient();
@@ -57,10 +57,9 @@ public class ControlErrorState extends Control implements ITooltip {
ControlEnergyBar.isError = errorState.isPowerError();
if (errorState.isItemError()) {
CustomSlot[] customSlots = Window.get(this).getContainer().getCustomSlots();
for (int slot : errorState.getData()) {
int id = -1;
for (CustomSlot cslot : customSlots) {
for (CustomSlot cslot : Window.get(this).getContainer().getCustomSlots()) {
if (!(cslot.inventory instanceof InventoryPlayer) && cslot.getSlotIndex() == slot) {
id = cslot.slotNumber;
}
@@ -47,16 +47,16 @@ public class ControlItemDisplay extends Control implements ITooltip {
@Override
public void onRenderBackground() {
if (itemStack == null) {
return;
}
IPoint relativeToWindow = getAbsolutePosition().sub(getSuperParent().getPosition());
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f
|| relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) {
return;
}
if (itemStack == null) {
return;
}
if (getSize().x() != 16.0f) {
GL11.glPushMatrix();
float scale = getSize().x() / 16.0f;
@@ -8,7 +8,6 @@ import net.minecraft.nbt.NBTTagList;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.minecraft.InventoryType;
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.network.packet.MessageCraftGUI;
public class ControlPlayerInventory extends Control {
@@ -25,21 +24,19 @@ public class ControlPlayerInventory extends Control {
slots = new ArrayList<>();
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18)
.setSlotTexture(CraftGUITexture.SlotInventory);
ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
slots.add(slot);
}
}
if (wide) {
for (int i1 = 0; i1 < 9; ++i1) {
ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18)
.setSlotTexture(CraftGUITexture.SlotInventory);
ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
slots.add(slot2);
}
} else {
for (int i1 = 0; i1 < 9; ++i1) {
ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f).setSlotTexture(CraftGUITexture.SlotInventory);
ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f);
slots.add(slot2);
}
}
@@ -54,8 +51,7 @@ public class ControlPlayerInventory extends Control {
slots = new ArrayList<>();
for (int row = 0; row < 6; ++row) {
for (int column = 0; column < 6; ++column) {
ControlSlot slot = new ControlSlot(this, column * 18, row * 18)
.setSlotTexture(CraftGUITexture.SlotInventory);
ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
slots.add(slot);
}
}
@@ -7,7 +7,7 @@ import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_REG;
import static binnie.core.craftgui.minecraft.ContainerCraftGUI.SLOT_TYPE;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -20,13 +20,10 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import org.lwjgl.input.Mouse;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.Tooltip;
import binnie.core.craftgui.events.EventMouse;
import binnie.core.craftgui.events.EventWidget;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.minecraft.CustomSlot;
@@ -39,42 +36,43 @@ import binnie.core.machines.inventory.MachineSide;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.network.packet.MessageCraftGUI;
import binnie.core.util.I18N;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
public class ControlSlot extends ControlSlotBase {
public static Map<EnumHighlighting, IntSet> highlighting = new EnumMap<>(EnumHighlighting.class);
public static Map<EnumHighlighting, List<Integer>> highlighting = new HashMap<>();
public static boolean shiftClickActive = false;
static {
for (EnumHighlighting h : EnumHighlighting.values()) {
ControlSlot.highlighting.put(h, new IntOpenHashSet());
ControlSlot.highlighting.put(h, new ArrayList<>());
}
}
public Slot slot;
private CraftGUITexture slotTexture;
public ControlSlot(IWidget parent, float x, float y) {
super(parent, x, y);
slot = null;
slotTexture = CraftGUITexture.Slot;
addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(EventMouse.Down event) {
clickSlot(event.getButton());
}
});
addSelfEventHandler(new EventWidget.StartMouseOver.Handler() {
@Override
public void onEvent(EventWidget.StartMouseOver event) {
if (GuiScreen.isShiftKeyDown() && Mouse.isButtonDown(0)
&& Window.get(ControlSlot.this).getDraggedWidget() instanceof ControlSlot) {
clickSlot(0);
if (slot == null) {
return;
}
PlayerControllerMP playerController = ((Window) getSuperParent()).getGui()
.getMinecraft().playerController;
int windowId = ((Window) getSuperParent()).getContainer().windowId;
int slotNumber = slot.slotNumber;
int button = event.getButton();
Window.get(getWidget()).getGui();
playerController.windowClick(
windowId,
slotNumber,
button,
GuiScreen.isShiftKeyDown() ? 1 : 0,
((Window) getSuperParent()).getGui().getMinecraft().thePlayer);
}
});
}
@@ -82,30 +80,11 @@ public class ControlSlot extends ControlSlotBase {
public ControlSlot(IWidget parent, int x, int y, Slot slot) {
super(parent, x, y);
this.slot = slot;
slotTexture = CraftGUITexture.Slot;
}
public ControlSlot setSlotTexture(CraftGUITexture texture) {
slotTexture = texture == null ? CraftGUITexture.Slot : texture;
return this;
}
private void clickSlot(int button) {
if (slot == null) return;
Window window = (Window) getSuperParent();
PlayerControllerMP playerController = window.getGui().getMinecraft().playerController;
playerController.windowClick(
window.getContainer().windowId,
slot.slotNumber,
button,
GuiScreen.isShiftKeyDown() ? 1 : 0,
window.getGui().getMinecraft().thePlayer);
}
@Override
public void onRenderBackground() {
CraftGUI.render.texture(slotTexture, IPoint.ZERO);
CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO);
if (slot == null) {
return;
}
@@ -119,7 +98,7 @@ public class ControlSlot extends ControlSlotBase {
}
boolean highlighted = false;
for (Map.Entry<EnumHighlighting, IntSet> highlight : ControlSlot.highlighting.entrySet()) {
for (Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
if (highlight.getKey() == EnumHighlighting.SHIFT_CLICK && !ControlSlot.shiftClickActive) {
continue;
}
@@ -148,7 +127,7 @@ public class ControlSlot extends ControlSlotBase {
}
boolean highlighted = false;
for (Map.Entry<EnumHighlighting, IntSet> highlight : ControlSlot.highlighting.entrySet()) {
for (Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
if (highlight.getKey() == EnumHighlighting.SHIFT_CLICK && !ControlSlot.shiftClickActive) {
continue;
}
@@ -52,9 +52,9 @@ public abstract class ControlSlotBase extends Control implements ITooltip {
}
@Override
public void render() {
public void onUpdateClient() {
super.onUpdateClient();
itemDisplay.setItemStack(getItemStack());
super.render();
}
@Override
@@ -10,7 +10,6 @@ public enum CraftGUITexture {
Button("button"),
ButtonHighlighted("button.highlighted"),
Slot("slot"),
SlotInventory("slot.inventory"),
SlotBorder("slot.border"),
SlotOverlay("slot.overlay"),
SlotCharge("slot.charge"),
@@ -9,17 +9,15 @@ class ParsedTextureSheet implements IBinnieTexture {
private final String name;
private final String modid;
private final String path;
private final BinnieResource texture;
public ParsedTextureSheet(String name, String modid, String path) {
this.name = name;
this.modid = modid;
this.path = path;
texture = new BinnieResource(modid, ResourceType.GUI, path);
}
@Override
public BinnieResource getTexture() {
return texture;
return new BinnieResource(modid, ResourceType.GUI, path);
}
}
@@ -113,7 +113,7 @@ class FlowerBreedingSystem extends BreedingSystem {
case PRIMARY:
case SECONDARY:
case STEM:
for (EnumFlowerColor color : EnumFlowerColor.VALUES) {
for (EnumFlowerColor color : EnumFlowerColor.values()) {
alleles.add(color.getAllele());
}
break;
@@ -1,7 +1,5 @@
package binnie.core.item;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -27,8 +25,6 @@ public class ItemGenesis extends Item {
setCreativeTab(Tabs.tabApiculture);
setUnlocalizedName("genesis");
setMaxStackSize(1);
registerItem(this, getUnlocalizedName().substring(5));
}
@Override
+2 -6
View File
@@ -1,7 +1,5 @@
package binnie.core.item;
import static cpw.mods.fml.common.registry.GameRegistry.registerItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -18,13 +16,11 @@ public class ItemMisc extends Item {
private final IItemMisc[] items;
public ItemMisc(CreativeTabs tab, IItemMisc[] items) {
protected ItemMisc(CreativeTabs tab, IItemMisc[] items2) {
setCreativeTab(tab);
setHasSubtypes(true);
setUnlocalizedName("misc");
this.items = items;
registerItem(this, getUnlocalizedName().substring(5));
items = items2;
}
@Override
@@ -0,0 +1,10 @@
package binnie.core.item;
import net.minecraft.creativetab.CreativeTabs;
public class ManagerItem {
public ItemMisc registerMiscItems(IItemMisc[] items, CreativeTabs tab) {
return new ItemMisc(tab, items);
}
}
@@ -1,9 +1,7 @@
package binnie.core.liquid;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraftforge.fluids.Fluid;
@@ -11,62 +9,32 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.ManagerBase;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ManagerLiquid extends ManagerBase {
private static final Set<String> EXTERNAL_FLUIDS = new HashSet<>();
static {
EXTERNAL_FLUIDS.add("liquidnitrogen");
}
private static boolean isExternalFluid(String identifier) {
return EXTERNAL_FLUIDS.contains(identifier) && Loader.isModLoaded("gregtech_nh");
}
public Map<String, IFluidType> fluids;
private final Set<String> ownedFluids;
public ManagerLiquid() {
fluids = new LinkedHashMap<>();
ownedFluids = new HashSet<>();
}
public void createLiquids(IFluidType[] liquids, int startID) {
for (IFluidType liquid : liquids) {
String identifier = liquid.getIdentifier().toLowerCase();
Fluid fluid = createOrGetLiquid(liquid, startID++);
if (fluid == null && !isExternalFluid(identifier)) {
BinnieFluid fluid = createLiquid(liquid, startID++);
if (fluid == null) {
throw new RuntimeException("Liquid registered incorrectly - " + liquid.getIdentifier());
}
}
}
public BinnieFluid createLiquid(IFluidType fluid, int id) {
Fluid registeredFluid = createOrGetLiquid(fluid, id);
return (registeredFluid instanceof BinnieFluid) ? (BinnieFluid) registeredFluid : null;
}
private Fluid createOrGetLiquid(IFluidType fluid, int id) {
String identifier = fluid.getIdentifier().toLowerCase();
fluids.put(identifier, fluid);
Fluid registeredFluid = FluidRegistry.getFluid(identifier);
if (registeredFluid == null && !isExternalFluid(identifier)) {
BinnieFluid binnieFluid = new BinnieFluid(fluid);
FluidRegistry.registerFluid(binnieFluid);
registeredFluid = FluidRegistry.getFluid(identifier);
ownedFluids.add(identifier);
} else if (registeredFluid == null) {
FMLLog.warning(
"[Binnie] External liquid %s is not registered yet. Waiting for the owning mod to register it before postInit.",
identifier);
}
fluids.put(fluid.getIdentifier().toLowerCase(), fluid);
BinnieFluid binnieFluid = new BinnieFluid(fluid);
FluidRegistry.registerFluid(binnieFluid);
ItemFluidContainer.registerFluid(fluid, id);
return registeredFluid;
return binnieFluid;
}
public FluidStack getLiquidStack(String name, int amount) {
@@ -76,26 +44,18 @@ public class ManagerLiquid extends ManagerBase {
@SideOnly(Side.CLIENT)
public void reloadIcons(IIconRegister register) {
for (IFluidType type : fluids.values()) {
String identifier = type.getIdentifier().toLowerCase();
FluidStack stack = getLiquidStack(identifier, 1);
Fluid fluid = stack == null ? null : stack.getFluid();
Fluid fluid = getLiquidStack(type.getIdentifier(), 1).getFluid();
type.registerIcon(register);
if (fluid == null) {
throw new RuntimeException("[Binnie] Liquid not registered properly - " + type.getIdentifier());
}
if (ownedFluids.contains(identifier)) {
fluid.setIcons(type.getIcon());
}
fluid.setIcons(type.getIcon());
}
}
@Override
public void postInit() {
for (IFluidType fluid : fluids.values()) {
String identifier = fluid.getIdentifier().toLowerCase();
if (isExternalFluid(identifier) && FluidRegistry.getFluid(identifier) == null) {
throw new RuntimeException("[Binnie] External liquid not registered - " + identifier);
}
for (FluidContainer container : FluidContainer.values()) {
if (container.isActive() && fluid.canPlaceIn(container)) {
container.registerContainerData(fluid);
@@ -2,7 +2,6 @@ package binnie.core.machines;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -72,9 +71,8 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
@Override
public <T> T getInterface(Class<T> cls) {
List<MachineComponent> components = componentInterfaceMap.get(cls);
if (components != null && !components.isEmpty()) {
return cls.cast(components.get(0));
if (hasInterface(cls)) {
return getInterfaces(cls).get(0);
}
if (cls.isInstance(getPackage())) {
return cls.cast(getPackage());
@@ -90,13 +88,11 @@ public class Machine implements INetworkedEntity, INBTTagable, INetwork.TilePack
@Override
public <T> List<T> getInterfaces(Class<T> cls) {
List<MachineComponent> components = componentInterfaceMap.get(cls);
if (components == null) {
return Collections.emptyList();
ArrayList<T> interfaces = new ArrayList<>();
if (!hasInterface(cls)) {
return interfaces;
}
List<T> interfaces = new ArrayList<>(components.size());
for (MachineComponent component : components) {
for (MachineComponent component : componentInterfaceMap.get(cls)) {
interfaces.add(cls.cast(component));
}
return interfaces;
@@ -1,5 +1,6 @@
package binnie.core.machines;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import binnie.core.util.I18N;
@@ -27,21 +28,10 @@ public abstract class MachinePackage {
public abstract TileEntity createTileEntity();
/// Whether this machine's tile entity needs {@link net.minecraft.tileentity.TileEntity#updateEntity()}.
/// Override to false only when no component implements onUpdate, onInventoryUpdate or a client display tick.
public boolean isTickable() {
return true;
}
public String getDisplayName() {
return I18N.localise(group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID());
}
public String getGuiDisplayName() {
String guiKey = group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID() + ".title";
return I18N.canLocalise(guiKey) ? I18N.localise(guiKey) : getDisplayName();
}
public Integer getMetadata() {
return metadata;
}
@@ -58,7 +48,8 @@ public abstract class MachinePackage {
this.group = group;
}
public abstract void renderMachine(Machine machine, double x, double y, double z, float partialTick);
public abstract void renderMachine(Machine machine, double x, double y, double z, float partialTick,
RenderBlocks renderer);
public boolean isActive() {
return active;
@@ -1,13 +1,11 @@
package binnie.core.machines;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import binnie.Binnie;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
@@ -15,41 +13,30 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
// Hmm. It's used class
public class RendererMachine extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
private final Map<Block, Map<Integer, TileEntityMachine>> inventoryTiles = new HashMap<>();
RenderBlocks blockRenderer;
@Override
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float partialTick) {
renderTileEntity((TileEntityMachine) entity, x, y, z, partialTick);
renderTileEntity((TileEntityMachine) entity, x, y, z, partialTick, blockRenderer);
}
private void renderTileEntity(TileEntityMachine entity, double x, double y, double z, float partialTick) {
public void renderTileEntity(TileEntityMachine entity, double x, double y, double z, float partialTick,
RenderBlocks renderer) {
if (entity != null && entity.getMachine() != null) {
MachinePackage machinePackage = entity.getMachine().getPackage();
machinePackage.renderMachine(entity.getMachine(), x, y, z, partialTick);
machinePackage.renderMachine(entity.getMachine(), x, y, z, partialTick, renderer);
}
}
private void renderInvBlock(Block block, int i, int j) {
renderTileEntity(getInventoryTile(block, i), 0.0, -0.1, 0.0, 0.0625f);
}
private TileEntityMachine getInventoryTile(Block block, int metadata) {
Map<Integer, TileEntityMachine> tiles = inventoryTiles.computeIfAbsent(block, key -> new HashMap<>());
TileEntityMachine tile = tiles.get(metadata);
if (tile == null) {
if (!(block.createTileEntity(null, metadata) instanceof TileEntityMachine created)) {
return null;
}
tile = created;
tiles.put(metadata, tile);
}
return tile;
public void renderInvBlock(RenderBlocks renderblocks, Block block, int i, int j) {
TileEntity entity = block.createTileEntity(null, i);
renderTileEntity((TileEntityMachine) entity, 0.0, -0.1, 0.0, 0.0625f, renderblocks);
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
if (modelID == Binnie.Machine.getMachineRenderID()) {
renderInvBlock(block, metadata, modelID);
renderInvBlock(renderer, block, metadata, modelID);
}
}
@@ -61,7 +48,7 @@ public class RendererMachine extends TileEntitySpecialRenderer implements ISimpl
&& tile.getMachine().getPackage() != null
&& tile.getMachine().getPackage().getGroup() != null
&& !tile.getMachine().getPackage().getGroup().customRenderer) {
renderTileEntity(tile, x, y, z, 1.0f);
renderTileEntity(tile, x, y, z, 1.0f, renderer);
}
return true;
}
@@ -75,4 +62,9 @@ public class RendererMachine extends TileEntitySpecialRenderer implements ISimpl
public int getRenderId() {
return Binnie.Machine.getMachineRenderID();
}
@Override
public void func_147496_a(World par1World) {
blockRenderer = new RenderBlocks(par1World);
}
}
@@ -21,11 +21,6 @@ public class TileEntityMachine extends TileEntityMachineBase implements INetwork
}
}
@Override
public boolean canUpdate() {
return machine == null || machine.getPackage() == null || machine.getPackage().isTickable();
}
public TileEntityMachine(MachinePackage pack) {
setMachine(pack);
}
@@ -21,23 +21,19 @@ import cpw.mods.fml.common.Optional;
public class TileEntityMachineBase extends TileEntity implements IInventoryMachine, ITankMachine, IPoweredMachine {
private static final DefaultInventory DEFAULT_INVENTORY = new DefaultInventory();
private static final DefaultTankContainer DEFAULT_TANK_CONTAINER = new DefaultTankContainer();
private static final DefaultPower DEFAULT_POWER = new DefaultPower();
public IInventoryMachine getInventory() {
IInventoryMachine inv = Machine.getInterface(IInventoryMachine.class, this);
return (inv == null || inv == this) ? DEFAULT_INVENTORY : inv;
return (inv == null || inv == this) ? new DefaultInventory() : inv;
}
public ITankMachine getTankContainer() {
ITankMachine inv = Machine.getInterface(ITankMachine.class, this);
return (inv == null || inv == this) ? DEFAULT_TANK_CONTAINER : inv;
return (inv == null || inv == this) ? new DefaultTankContainer() : inv;
}
public IPoweredMachine getPower() {
IPoweredMachine inv = Machine.getInterface(IPoweredMachine.class, this);
return (inv == null || inv == this) ? DEFAULT_POWER : inv;
return (inv == null || inv == this) ? new DefaultPower() : inv;
}
@Override
@@ -1,6 +1,7 @@
package binnie.core.machines.inventory;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -15,13 +16,10 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import binnie.core.machines.IMachine;
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
public class ComponentInventorySlots extends ComponentInventory implements IInventoryMachine, IInventorySlots {
private final Int2ObjectLinkedOpenHashMap<InventorySlot> inventory = new Int2ObjectLinkedOpenHashMap<>();
private int cachedSize = 0;
private int[] cachedAccessibleSlots = null;
private final Map<Integer, InventorySlot> inventory = new LinkedHashMap<>();
public ComponentInventorySlots(IMachine machine) {
super(machine);
@@ -29,20 +27,25 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public int getSizeInventory() {
return cachedSize;
int size = 0;
for (Integer index : inventory.keySet()) {
size = Math.max(size, index + 1);
}
return size;
}
@Override
public ItemStack getStackInSlot(int index) {
InventorySlot slot = inventory.get(index);
return slot != null ? slot.getContent() : null;
if (inventory.containsKey(index)) {
return inventory.get(index).getContent();
}
return null;
}
@Override
public ItemStack decrStackSize(int index, int amount) {
InventorySlot slot = inventory.get(index);
if (slot != null) {
ItemStack stack = slot.decrStackSize(amount);
if (inventory.containsKey(index)) {
ItemStack stack = inventory.get(index).decrStackSize(amount);
markDirty();
return stack;
}
@@ -56,9 +59,8 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public void setInventorySlotContents(int index, ItemStack itemStack) {
InventorySlot slot = inventory.get(index);
if (slot != null && (itemStack == null || slot.isValid(itemStack))) {
slot.setContent(itemStack);
if (inventory.containsKey(index) && (itemStack == null || inventory.get(index).isValid(itemStack))) {
inventory.get(index).setContent(itemStack);
}
markDirty();
}
@@ -111,7 +113,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
NBTTagList inventoryNBT = new NBTTagList();
for (Map.Entry<Integer, InventorySlot> entry : inventory.int2ObjectEntrySet()) {
for (Map.Entry<Integer, InventorySlot> entry : inventory.entrySet()) {
NBTTagCompound slotNBT = new NBTTagCompound();
slotNBT.setInteger("id", entry.getKey());
entry.getValue().writeToNBT(slotNBT);
@@ -123,8 +125,6 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public InventorySlot addSlot(int index, String unlocalizedName) {
inventory.put(index, new InventorySlot(index, unlocalizedName));
cachedSize = Math.max(cachedSize, index + 1);
cachedAccessibleSlots = null;
return getSlot(index);
}
@@ -138,7 +138,10 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public InventorySlot getSlot(int index) {
return inventory.get(index);
if (inventory.containsKey(index)) {
return inventory.get(index);
}
return null;
}
@Override
@@ -148,7 +151,7 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public InventorySlot[] getSlots(int[] indexes) {
List<InventorySlot> list = new ArrayList<>(indexes.length);
List<InventorySlot> list = new ArrayList<>();
for (int i : indexes) {
if (getSlot(i) != null) {
list.add(getSlot(i));
@@ -210,20 +213,18 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
if (cachedAccessibleSlots == null) {
List<Integer> slots = new ArrayList<>();
for (InventorySlot slot : inventory.values()) {
if (slot.canInsert() || slot.canExtract()) {
slots.add(slot.getIndex());
}
}
cachedAccessibleSlots = new int[slots.size()];
for (int i = 0; i < slots.size(); ++i) {
cachedAccessibleSlots[i] = slots.get(i);
List<Integer> slots = new ArrayList<>();
for (InventorySlot slot : inventory.values()) {
if (slot.canInsert() || slot.canExtract()) {
slots.add(slot.getIndex());
}
}
return cachedAccessibleSlots;
int[] ids = new int[slots.size()];
for (int i = 0; i < slots.size(); ++i) {
ids[i] = slots.get(i);
}
return ids;
}
@Override
@@ -233,7 +234,6 @@ public class ComponentInventorySlots extends ComponentInventory implements IInve
@Override
public boolean canExtractItem(int slot, ItemStack itemstack, int direction) {
InventorySlot iSlot = getSlot(slot);
return iSlot != null && iSlot.canExtract(ForgeDirection.getOrientation(direction));
return getSlot(slot).canExtract(ForgeDirection.getOrientation(direction));
}
}
@@ -164,7 +164,7 @@ public class ComponentTankContainer extends MachineComponent implements ITankMac
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
int index = getTankIndexToDrain(from, resource);
int index = getTankIndexToDrain(from, null);
if (!tanks.containsKey(index)) {
return null;
}
@@ -5,7 +5,6 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
@@ -153,8 +152,7 @@ public class ComponentPowerReceptor extends MachineComponent
}
private void addToEnergyNet() {
World world = getMachine().getWorld();
if (world == null || world.isRemote) {
if (getMachine().getWorld() == null) {
return;
}
if (Mods.ic2.active()) {
@@ -163,8 +161,7 @@ public class ComponentPowerReceptor extends MachineComponent
}
private void removeFromEnergyNet() {
World world = getMachine().getWorld();
if (world == null || world.isRemote) {
if (getMachine().getWorld() == null) {
return;
}
if (Mods.ic2.active()) {
@@ -9,11 +9,4 @@ public interface IProcess extends IErrorStateSource {
boolean isInProgress();
ProcessInfo getInfo();
/***
* Returns true if the current target got worked on at least once.
*/
default boolean workedOnTarget() {
return false;
}
}
@@ -1,5 +1,6 @@
package binnie.core.machines.storage;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -50,12 +51,8 @@ enum Compartment implements IMachineType {
}
@Override
public boolean isTickable() {
return false;
}
@Override
public void renderMachine(Machine machine, double x, double y, double z, float partialTick) {
public void renderMachine(Machine machine, double x, double y, double z, float partialTick,
RenderBlocks renderer) {
MachineRendererCompartment.instance.renderMachine(machine, renderTexture, x, y, z);
}
}
@@ -25,7 +25,7 @@ class CompartmentTab implements INBTTagable {
public void readFromNBT(NBTTagCompound nbt) {
name = nbt.getString("name");
icon = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("icon"));
color = EnumColor.VALUES[nbt.getByte("color")];
color = EnumColor.values()[nbt.getByte("color")];
id = nbt.getByte("id");
}
@@ -17,7 +17,6 @@ class ComponentCompartmentInventory extends ComponentInventorySlots implements I
private final int numberOfTabs;
private final int slotsPerPage;
private final Map<Integer, CompartmentTab> tabs;
private NBTTagCompound cachedGuiNBT;
public ComponentCompartmentInventory(IMachine machine, int sections) {
this(machine, sections, 4);
@@ -52,24 +51,21 @@ class ComponentCompartmentInventory extends ComponentInventorySlots implements I
public CompartmentTab getTab(int i) {
if (!tabs.containsKey(i)) {
tabs.put(i, new CompartmentTab(i));
cachedGuiNBT = null;
}
return tabs.get(i);
}
@Override
public void sendGuiNBT(Map<String, NBTTagCompound> nbts) {
if (cachedGuiNBT == null) {
NBTTagList list = new NBTTagList();
for (int i = 0; i < numberOfTabs; ++i) {
NBTTagCompound tabNBT = new NBTTagCompound();
getTab(i).writeToNBT(tabNBT);
list.appendTag(tabNBT);
}
cachedGuiNBT = new NBTTagCompound();
cachedGuiNBT.setTag("tabs", list);
NBTTagList list = new NBTTagList();
for (int i = 0; i < numberOfTabs; ++i) {
NBTTagCompound nbt2 = new NBTTagCompound();
getTab(i).writeToNBT(nbt2);
list.appendTag(nbt2);
}
nbts.put("comp-tabs", cachedGuiNBT);
NBTTagCompound tag = new NBTTagCompound();
tag.setTag("tabs", list);
nbts.put("comp-tabs", tag);
}
@Override
@@ -82,13 +78,11 @@ class ComponentCompartmentInventory extends ComponentInventorySlots implements I
tab.readFromNBT(tag);
tabs.put(tab.getId(), tab);
}
cachedGuiNBT = null;
}
if (name.equals("comp-change-tab")) {
CompartmentTab tab2 = new CompartmentTab(0);
tab2.readFromNBT(nbt);
tabs.put(tab2.getId(), tab2);
cachedGuiNBT = null;
getMachine().getTileEntity().markDirty();
}
}
@@ -103,7 +97,6 @@ class ComponentCompartmentInventory extends ComponentInventorySlots implements I
tab.readFromNBT(tag);
tabs.put(tab.getId(), tab);
}
cachedGuiNBT = null;
}
@Override
@@ -37,7 +37,6 @@ import binnie.core.craftgui.events.EventMouse;
import binnie.core.craftgui.events.EventTextEdit;
import binnie.core.craftgui.events.EventValueChanged;
import binnie.core.craftgui.geometry.CraftGUIUtil;
import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IBorder;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.geometry.Position;
@@ -84,7 +83,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
@Override
public void initialiseClient() {
setTitle(Machine.getMachine(getInventory()).getPackage().getGuiDisplayName());
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
int x = 16;
int y = 32;
ComponentCompartmentInventory inv = Machine.getMachine(getInventory())
@@ -174,7 +173,6 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
}
CraftGUIUtil.linkWidgets(tab, compartmentPages);
int i = 0;
final NBTTagList actions = new NBTTagList();
for (int p2 = 0; p2 < inv.getTabNumber(); ++p2) {
ControlPage thisPage = page[p2];
Panel panel = new Panel(thisPage, 0.0f, 0.0f, thisPage.w(), thisPage.h(), MinecraftGUI.PanelType.Black) {
@@ -193,10 +191,11 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
slotsIDs[k] = i++;
}
final NBTTagList actions = new NBTTagList();
new ControlSlotArray(thisPage, 8, 8, inv.getPageSize() / 5, 5)
.create(actions, InventoryType.Machine, slotsIDs);
MessageCraftGUI.sendToServer(actions);
}
MessageCraftGUI.sendToServer(actions);
x += compartmentPageWidth;
if (tabs2.length > 0) {
ControlTabBar<Integer> tab2 = new ControlTabBar<Integer>(
@@ -257,8 +256,8 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
ControlSlide slide = new ControlSlide(this, 0.0f, 134.0f, 136.0f, 92.0f, Position.LEFT);
slide.setLabel(I18N.localise("binniecore.machine.storage.tab.properties"));
slide.setSlide(false);
slide.addHelp(I18N.localise("binniecore.machine.storage.tab.properties"));
slide.addHelp(I18N.localise("binniecore.machine.storage.tab.properties.desc"));
slide.addHelp(I18N.localise("binniecore.machine.storage.tooltip.properties"));
slide.addHelp(I18N.localise("binniecore.machine.storage.tooltip.properties.desc"));
Panel tabPropertyPanel = new Panel(slide, 16.0f, 8.0f, 112.0f, 76.0f, MinecraftGUI.PanelType.Gray);
int y2 = 4;
new ControlText(tabPropertyPanel, new IPoint(4.0f, y2), I18N.localise("binniecore.machine.storage.tab.name"));
@@ -321,7 +320,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
1 + cw * (cc / 8),
cw,
cw,
EnumColor.VALUES[cc]);
EnumColor.values()[cc]);
color.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
@@ -373,20 +372,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
.texture(CraftGUITexture.Outline, getArea().inset(new IBorder(0.0f, 6.0f, 0.0f, 0.0f)));
}
};
slotGrid = new Control(scroll, 1.0f, 1.0f, 108.0f, 18.0f) {
@Override
public boolean isChildVisible(IWidget child) {
IArea visible = getCroppedZone();
if (visible == null) {
return true;
}
float top = -getOffset().y();
float childTop = child.getOriginalPosition().y() + child.getOffset().y();
return childTop + child.getSize().y() > top && childTop < top + visible.h();
}
};
slotGrid = new Control(scroll, 1.0f, 1.0f, 108.0f, 18.0f);
scroll.setScrollableContent(slotGrid);
new ControlPlayerInventory(this, true).createAndRegister();
new ControlTextEdit(this, 16.0f, 16.0f, 100.0f, 14.0f).addEventHandler(new EventTextEdit.Handler() {
@@ -3,7 +3,6 @@ package binnie.core.machines.transfer;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
@@ -26,20 +25,23 @@ public class TransferRequest {
private int[] targetTanks;
private boolean transferLiquids;
private boolean ignoreReadOnly;
private EntityPlayer overflowPlayer;
private List<TransferSlot> insertedSlots;
private List<Integer> insertedTanks;
private final List<TransferSlot> insertedSlots;
private final List<Integer> insertedTanks;
public TransferRequest(ItemStack toTransfer, IInventory destination) {
itemToTransfer = null;
returnItem = null;
targetSlots = null;
targetSlots = new int[0];
targetTanks = new int[0];
transferLiquids = true;
ignoreReadOnly = false;
overflowPlayer = null;
insertedSlots = null;
insertedTanks = null;
insertedSlots = new ArrayList<>();
insertedTanks = new ArrayList<>();
int[] target = new int[destination.getSizeInventory()];
for (int i = 0; i < target.length; ++i) {
target[i] = i;
}
int[] targetTanks = new int[0];
if (destination instanceof ITankMachine) {
@@ -56,6 +58,7 @@ public class TransferRequest {
setOrigin(null);
setDestination(destination);
setTargetSlots(target);
setTargetTanks(targetTanks);
transferLiquids = true;
}
@@ -92,71 +95,59 @@ public class TransferRequest {
return this;
}
public TransferRequest dropOverflow(EntityPlayer player) {
overflowPlayer = player;
return this;
}
public ItemStack getReturnItem() {
return returnItem;
}
public ItemStack transfer(boolean doAdd) {
ItemStack item = doAdd || returnItem == null ? returnItem : returnItem.copy();
ItemStack item = returnItem;
if (item == null || destination == null) {
return null;
}
if (transferLiquids && destination instanceof ITankMachine) {
for (int tankID : targetTanks) {
ItemStack itemBeforeTransfer = item.copy();
item = transferToTank(item, origin, (ITankMachine) destination, tankID, doAdd);
if (item == null || !ItemStack.areItemStacksEqual(item, itemBeforeTransfer)) {
break;
}
item = transferFromTank(item, origin, (ITankMachine) destination, tankID, doAdd);
if (item == null || !ItemStack.areItemStacksEqual(item, itemBeforeTransfer)) {
break;
if (item != null) {
item = transferFromTank(item, origin, (ITankMachine) destination, tankID, doAdd);
}
}
}
// TODO simplify
if (item != null) {
int[] slots = getTargetSlots();
for (int slot : slots) {
for (int slot : targetSlots) {
if (destination.isItemValidForSlot(slot, item) || ignoreReadOnly) {
if (!(destination instanceof IInventorySlots)
|| ((IInventorySlots) destination).getSlot(slot) == null
|| !((IInventorySlots) destination).getSlot(slot).isRecipe()) {
ItemStack merged = destination.getStackInSlot(slot);
if (merged != null && item.isStackable()
&& destination.getInventoryStackLimit() > 1
&& areItemsEqual(item, merged)) {
int amount = Math.min(item.stackSize, merged.getMaxStackSize() - merged.stackSize);
if (amount > 0) {
getInsertedSlots().add(new TransferSlot(slot, destination));
if (doAdd) {
ItemStack newStack = merged.copy();
newStack.stackSize += amount;
destination.setInventorySlotContents(slot, newStack);
if (destination.getStackInSlot(slot) != null) {
if (item.isStackable() && destination.getInventoryStackLimit() > 1) {
ItemStack merged = destination.getStackInSlot(slot).copy();
ItemStack[] newStacks = mergeStacks(item.copy(), merged.copy());
item = newStacks[0];
if (!areItemsEqual(merged, newStacks[1])) {
insertedSlots.add(new TransferSlot(slot, destination));
}
if (doAdd) {
destination.setInventorySlotContents(slot, newStacks[1]);
}
if (item == null) {
return null;
}
item.stackSize -= amount;
if (item.stackSize <= 0) return null;
}
}
}
}
}
for (int slot : slots) {
for (int slot : targetSlots) {
if (destination.isItemValidForSlot(slot, item) || ignoreReadOnly) {
if (!(destination instanceof IInventorySlots)
|| ((IInventorySlots) destination).getSlot(slot) == null
|| !((IInventorySlots) destination).getSlot(slot).isRecipe()) {
if (destination.getStackInSlot(slot) == null) {
getInsertedSlots().add(new TransferSlot(slot, destination));
insertedSlots.add(new TransferSlot(slot, destination));
if (doAdd) {
ItemStack movedStack = item.copy();
if (movedStack.stackSize > destination.getInventoryStackLimit()) {
@@ -209,13 +200,11 @@ public class TransferRequest {
private ItemStack transferToTankUsingFluidContainer(ItemStack item, IInventory origin, ITankMachine destination,
int tankID, boolean doAdd) {
if (item == null || origin == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
if (item == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
return item;
}
ItemStack singleContainer = item.copy();
singleContainer.stackSize = 1;
FluidStack fluid = fluidContainer.getFluid(singleContainer);
FluidStack fluid = fluidContainer.getFluid(item);
if (fluid == null) {
return item;
}
@@ -227,22 +216,11 @@ public class TransferRequest {
}
int maxFill = tank.fill(fluid, false);
FluidStack toTake = fluidContainer.drain(singleContainer, maxFill, true);
if (toTake == null || toTake.amount <= 0) {
return item;
}
TransferRequest containerDump = createContainerDump(singleContainer, origin);
boolean dropContainer = containerDump.transfer(false) != null;
if (dropContainer && overflowPlayer == null) {
return item;
}
FluidStack toTake = fluidContainer.drain(item, maxFill, true);
if (doAdd) {
tank.fill(toTake, true);
dumpContainer(singleContainer, containerDump, dropContainer);
}
return removeSingleContainer(item);
return item;
}
private ItemStack transferToTankUsingContainerData(ItemStack item, IInventory origin, ITankMachine destination,
@@ -327,69 +305,24 @@ public class TransferRequest {
private ItemStack transferFromTankUsingFluidContainer(ItemStack item, IInventory origin, ITankMachine destination,
int tankID, boolean doAdd) {
if (item == null || origin == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
if (item == null || !(item.getItem() instanceof IFluidContainerItem fluidContainer)) {
return item;
}
ItemStack singleContainer = item.copy();
singleContainer.stackSize = 1;
IFluidTank tank = destination.getTanks()[tankID];
FluidStack fluid = tank.getFluid();
if (fluid == null) {
return item;
}
int amount = fluidContainer.fill(singleContainer, fluid, false);
FluidStack drained = tank.drain(amount, false);
if (drained == null || drained.amount <= 0) {
int amount = fluidContainer.fill(item, fluid, false);
amount = Math.min(amount, (tank.drain(amount, false) == null) ? 0 : tank.drain(amount, false).amount);
if (amount <= 0) {
return item;
}
int amountFilled = fluidContainer.fill(singleContainer, drained, true);
if (amountFilled <= 0) {
return item;
}
TransferRequest containerDump = createContainerDump(singleContainer, origin);
boolean dropContainer = containerDump.transfer(false) != null;
if (dropContainer && overflowPlayer == null) {
return item;
}
if (doAdd) {
tank.drain(amountFilled, true);
dumpContainer(singleContainer, containerDump, dropContainer);
}
return removeSingleContainer(item);
}
private TransferRequest createContainerDump(ItemStack container, IInventory origin) {
TransferRequest containerDump = new TransferRequest(container, origin).setTargetTanks(new int[0]);
if (overflowPlayer != null && origin == overflowPlayer.inventory) {
int[] mainInventorySlots = new int[overflowPlayer.inventory.mainInventory.length];
for (int i = 0; i < mainInventorySlots.length; ++i) {
mainInventorySlots[i] = i;
}
containerDump.setTargetSlots(mainInventorySlots);
}
return containerDump;
}
private void dumpContainer(ItemStack container, TransferRequest containerDump, boolean dropContainer) {
if (dropContainer) {
overflowPlayer.dropPlayerItemWithRandomChoice(container.copy(), false);
} else {
containerDump.transfer(true);
}
}
private static ItemStack removeSingleContainer(ItemStack item) {
if (item.stackSize <= 1) {
return null;
}
ItemStack leftover = item.copy();
--leftover.stackSize;
return leftover;
fluidContainer.fill(item, tank.drain(amount, doAdd), doAdd);
return item;
}
private ItemStack transferFromTankUsingContainerData(ItemStack item, IInventory origin, ITankMachine destination,
@@ -466,16 +399,10 @@ public class TransferRequest {
}
public List<TransferSlot> getInsertedSlots() {
if (insertedSlots == null) {
insertedSlots = new ArrayList<>();
}
return insertedSlots;
}
public List<Integer> getInsertedTanks() {
if (insertedTanks == null) {
insertedTanks = new ArrayList<>();
}
return insertedTanks;
}
@@ -492,12 +419,6 @@ public class TransferRequest {
}
public int[] getTargetSlots() {
if (targetSlots == null) {
targetSlots = new int[destination.getSizeInventory()];
for (int i = 0; i < targetSlots.length; ++i) {
targetSlots[i] = i;
}
}
return targetSlots;
}
@@ -0,0 +1,52 @@
package binnie.core.mod.parser;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import binnie.core.AbstractMod;
public abstract class FieldParser {
public static Collection<FieldParser> parsers = new ArrayList<>();
public abstract boolean isHandled(Field field, AbstractMod mod);
public void preInit(Field field, AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
// ignored
}
public void init(Field field, AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
// ignored
}
public void postInit(Field field, AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
// ignored
}
public static void preInitParse(Field field, AbstractMod mod)
throws IllegalArgumentException, IllegalAccessException {
for (FieldParser parser : FieldParser.parsers) {
if (parser.isHandled(field, mod)) {
parser.preInit(field, mod);
}
}
}
public static void initParse(Field field, AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
for (FieldParser parser : FieldParser.parsers) {
if (parser.isHandled(field, mod)) {
parser.init(field, mod);
}
}
}
public static void postInitParse(Field field, AbstractMod mod)
throws IllegalArgumentException, IllegalAccessException {
for (FieldParser parser : FieldParser.parsers) {
if (parser.isHandled(field, mod)) {
parser.postInit(field, mod);
}
}
}
}
@@ -0,0 +1,24 @@
package binnie.core.mod.parser;
import java.lang.reflect.Field;
import net.minecraft.item.Item;
import binnie.core.AbstractMod;
import cpw.mods.fml.common.registry.GameRegistry;
public class ItemParser extends FieldParser {
@Override
public boolean isHandled(Field field, AbstractMod mod) {
return Item.class.isAssignableFrom(field.getType());
}
@Override
public void preInit(Field field, AbstractMod mod) throws IllegalArgumentException, IllegalAccessException {
Item item = (Item) field.get(null);
if (item != null) {
GameRegistry.registerItem(item, item.getUnlocalizedName().substring(5));
}
}
}
@@ -9,8 +9,6 @@ public class BinnieResource {
String mod;
private final ResourceType type;
String path;
private final String shortPath;
private final ResourceLocation resourceLocation;
public BinnieResource(AbstractMod mod, ResourceType type, String path) {
this(mod.getModID(), type, path);
@@ -20,15 +18,13 @@ public class BinnieResource {
mod = modid;
this.type = type;
this.path = path;
shortPath = "textures/" + type + "/" + path;
resourceLocation = new ResourceLocation(modid, shortPath);
}
public ResourceLocation getResourceLocation() {
return resourceLocation;
return new ResourceLocation(mod, "textures/" + type.toString() + "/" + path);
}
public String getShortPath() {
return shortPath;
return "textures/" + type.toString() + "/" + path;
}
}
+6 -10
View File
@@ -2,6 +2,7 @@ package binnie.extrabees;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
@@ -10,7 +11,6 @@ import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.core.Tags;
import binnie.core.gui.IBinnieGUID;
import binnie.core.item.ItemMisc;
import binnie.core.network.BinniePacketHandler;
import binnie.core.proxy.IProxyCore;
import binnie.extrabees.apiary.ModuleApiary;
@@ -18,11 +18,7 @@ import binnie.extrabees.config.EBConfig;
import binnie.extrabees.core.ExtraBeeGUID;
import binnie.extrabees.core.ModuleCore;
import binnie.extrabees.genetics.ModuleGenetics;
import binnie.extrabees.genetics.items.ItemDictionary;
import binnie.extrabees.liquids.ModuleLiquids;
import binnie.extrabees.products.ItemHoneyComb;
import binnie.extrabees.products.ItemHoneyDrop;
import binnie.extrabees.products.ItemPropolis;
import binnie.extrabees.products.ModuleProducts;
import binnie.extrabees.proxy.ExtraBeesProxy;
import binnie.extrabees.worldgen.ModuleGeneration;
@@ -62,11 +58,11 @@ public class ExtraBees extends AbstractMod {
public static Block hive;
public static Material materialBeehive;
public static Block ectoplasm;
public static ItemHoneyComb comb;
public static ItemPropolis propolis;
public static ItemHoneyDrop honeyDrop;
public static ItemDictionary dictionary;
public static ItemMisc itemMisc;
public static Item comb;
public static Item propolis;
public static Item honeyDrop;
public static Item dictionary;
public static Item itemMisc;
public ExtraBees() {
ExtraBees.instance = this;
@@ -6,23 +6,14 @@ import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import com.mojang.authlib.GameProfile;
import binnie.core.machines.TileEntityMachine;
import binnie.extrabees.apiary.machine.AlvearyMachine;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeHousingInventory;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorLogic;
import forestry.api.genetics.IIndividual;
import forestry.api.multiblock.IAlvearyComponent;
import forestry.api.multiblock.IMultiblockComponent;
@@ -30,7 +21,7 @@ import forestry.api.multiblock.IMultiblockController;
import forestry.api.multiblock.IMultiblockLogicAlveary;
import forestry.api.multiblock.MultiblockManager;
public class TileExtraBeeAlveary extends TileEntityMachine implements IBeeHousing, IAlvearyComponent.Active,
public class TileExtraBeeAlveary extends TileEntityMachine implements IAlvearyComponent.Active,
IAlvearyComponent.BeeModifier, IAlvearyComponent.BeeListener, IBeeListener, IBeeModifier {
protected IMultiblockLogicAlveary structureLogic;
@@ -51,51 +42,11 @@ public class TileExtraBeeAlveary extends TileEntityMachine implements IBeeHousin
return new ChunkCoordinates(xCoord, yCoord, zCoord);
}
@Override
public Iterable<IBeeModifier> getBeeModifiers() {
return getMultiblockLogic().getController().getBeeModifiers();
}
@Override
public Iterable<IBeeListener> getBeeListeners() {
return getMultiblockLogic().getController().getBeeListeners();
}
@Override
public IBeeHousingInventory getBeeInventory() {
return getMultiblockLogic().getController().getBeeInventory();
}
@Override
public IBeekeepingLogic getBeekeepingLogic() {
return getMultiblockLogic().getController().getBeekeepingLogic();
}
@Override
public int getBlockLightValue() {
return getMultiblockLogic().getController().getBlockLightValue();
}
@Override
public boolean canBlockSeeTheSky() {
return getMultiblockLogic().getController().canBlockSeeTheSky();
}
@Override
public World getWorld() {
return null;
}
@Override
public GameProfile getOwner() {
return getMachine().getOwner();
}
@Override
public Vec3 getBeeFXCoordinates() {
return getMultiblockLogic().getController().getBeeFXCoordinates();
}
public List<TileEntity> getAlvearyBlocks() {
LinkedList<TileEntity> tiles = new LinkedList<>();
if (min == null || max == null) {
@@ -275,26 +226,6 @@ public class TileExtraBeeAlveary extends TileEntityMachine implements IBeeHousin
}
}
@Override
public BiomeGenBase getBiome() {
return getMultiblockLogic().getController().getBiome();
}
@Override
public EnumTemperature getTemperature() {
return getMultiblockLogic().getController().getTemperature();
}
@Override
public EnumHumidity getHumidity() {
return getMultiblockLogic().getController().getHumidity();
}
@Override
public IErrorLogic getErrorLogic() {
return getMultiblockLogic().getController().getErrorLogic();
}
// TODO why its commented?
// boolean init;
// //IStructureLogic structureLogic;
@@ -1,5 +1,6 @@
package binnie.extrabees.apiary.machine;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -65,7 +66,8 @@ public enum AlvearyMachine implements IMachineType {
}
@Override
public void renderMachine(Machine machine, double x, double y, double z, float partialTick) {
public void renderMachine(Machine machine, double x, double y, double z, float partialTick,
RenderBlocks renderer) {
MachineRendererBlock.instance.renderMachine(machineTexture, x, y, z, partialTick);
}
}
Loaded 100 of 2137 files, more files were not shown because too many files have changed in this diff. Show more