Compare commits

..
33 Commits
Author SHA1 Message Date
Alexdoru 503a6e7a76 Cache frequent Enum#values() calls (#223) 2026-03-03 19:46:41 +00:00
danyadev ff0e85142d less FluidStack copying in conduits & less HashMap lookups in reservoirs (#221) 2026-02-18 15:33:45 -05:00
Martin Robertz 94bd521739 Update Angelica dependency version in dependencies.gradle 2026-02-07 19:10:46 +01:00
e66c50bc24 Improve tooltip capacitor and farming station efficiency (#215)
Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Ruling-0 <[email protected]>
2026-02-07 19:07:42 +01:00
Martin Robertz d9df657f35 Update dependencies.gradle (#220) 2026-02-07 19:07:23 +01:00
Martin Robertz 08553f8af2 fix 2026-02-07 19:02:37 +01:00
Martin Robertz 0fe564d007 fix 2026-02-07 18:55:57 +01:00
Martin Robertz 53ba0383fb Merge remote-tracking branch 'origin/master' 2026-02-07 18:46:30 +01:00
Martin Robertz 2c5664ce08 update 2026-02-07 18:46:22 +01:00
Jason Mitchell da70f52b0d Reduce allocation spam on fluid flow in fluid conduits (#219) 2026-02-07 08:32:58 -08:00
SwingURM 46644bc889 Optimize FluidStack copying in EnderLiquidConduitNetwork.doFill (#218) 2026-02-07 15:52:50 +01:00
danyadev f615df5010 compat with WailaPlugins own fluid handler (#217) 2026-01-13 11:27:35 +01:00
PLASMAchicken 73891d20ff Fix Client Crash when breaking Wirelesscharger on Server (#216) 2025-12-26 21:14:36 -05:00
Alexdoru e21793245f [Memory-opti:fix leak] Fix World leak in WirelessChargerController (#212) 2025-12-16 13:41:45 -06:00
Worive ffe4296ef6 Improve NetworkedInventory robustness (#210) 2025-12-10 09:27:33 +01:00
Alexdoru 5083fb2a60 Delete brute forcing of items to generate Thaumcraft aspects (#213) 2025-11-30 07:45:12 +01:00
Alexdoru 05ee12955d Fix World leak in ConduitNetworkTickHandler (#211) 2025-11-22 00:56:09 +01:00
Martin Robertz a7acc7e224 update 2025-10-19 20:30:47 +02:00
Martin Robertz a59bb21e59 update 2025-10-12 20:30:55 +02:00
chochem 5b6c13ff0a Dont register several duplicate items in case of GTNH (#209) 2025-10-12 01:14:36 +01:00
Martin Robertz 6f8b6e2a9c update 2025-10-04 14:26:40 +02:00
TheYoingLadandMartin Robertz 479c8328b4 Added the ability for the farming station to plant Pam's nether seeds (#208)
Co-authored-by: Martin Robertz <[email protected]>
2025-10-04 12:24:54 +00:00
Wilhelm Schuster 0c23f4937d Handle mouse button keybinds (#204) 2025-09-25 19:55:57 +02:00
Wilhelm Schusterandgithub-actions[bot] cde2e4fa60 Fix crash when breaking Painted Glowstone placed by Better Builders Wand (#206)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-25 19:35:30 +02:00
Ranzu abbb6dc151 Update bauble slot background in capacitor ui (#203) 2025-09-25 15:20:59 +02:00
Martin Robertz b3def82cde update 2025-09-24 16:49:42 +02:00
EmperorSuper 8b4e7f7ec3 Cap the length of the baubles inventory (#202) 2025-09-24 11:10:22 +02:00
Alexdoru d69d77ecae fix NPE in BlockConduitBundle#onPlaySound (#201) 2025-07-25 08:21:32 +07:00
Dream Master a233f6ba30 update 2025-07-18 09:47:57 +07:00
boubou19andAlexdoru 581150178f Speed up forge event registration (#200)
Co-authored-by: Alexdoru <[email protected]>
2025-07-17 22:37:03 +00:00
Dream Master 313a243bf5 update 2025-07-17 22:29:13 +07:00
Dream Master d5f1008b08 update 2025-07-17 22:28:51 +07:00
koolkrafter5 e1e1f06dc6 Break Dependency Chain (#199) 2025-07-17 02:40:36 +00:00
112 changed files with 1187 additions and 827 deletions

No files matched your search

+1
View File
@@ -28,3 +28,4 @@ whitelist.json
src/main/resources/mixins.*.json
*.bat
layout.json
.DS_Store
+18 -16
View File
@@ -1,24 +1,25 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:EnderCore:0.4.8:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.10.11:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.7.52-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.6.31:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.43:dev')
api('com.github.GTNewHorizons:EnderCore:0.5.7:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.4:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.8.60-GTNH:dev')
api("com.github.GTNewHorizons:GTNHLib:0.9.10:dev")
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.55:dev')
api('curse.maven:cofh-lib-220333:2388748') // https://www.curseforge.com/minecraft/mc-mods/cofh-lib/files/2388748
shadowImplementation('cglib:cglib-nodep:3.3.0')
api("com.github.GTNewHorizons:TinkersConstruct:1.13.35-GTNH:dev")
api("com.github.GTNewHorizons:TinkersConstruct:1.14.27-GTNH:dev")
compileOnly('com.github.GTNewHorizons:waila:1.8.7:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-632-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles:1.0.4:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.339:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.2.15-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.16.30:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.2-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.16.4-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.11.16-GTNH:api') {transitive = false}
devOnlyNonPublishable('com.github.GTNewHorizons:waila:1.19.22:dev') {transitive = false}
runtimeOnlyNonPublishable('com.github.GTNewHorizons:WAILAPlugins:0.7.2:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-812-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.6-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.261:dev') {transitive = false}
compileOnly("com.github.GTNewHorizons:ModularUI2:2.3.37-1.7.10:dev") {transitive = false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.17.17:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.2.9-GTNH:api') {transitive = false}
compileOnly('com.github.GTNewHorizons:Chisel:2.17.14-GTNH:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.16-GTNH:api') {transitive = false}
compileOnly('curse.maven:minefactory-reloaded-66672:2366150') // https://www.curseforge.com/minecraft/mc-mods/minefactory-reloaded/files/2366150
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('curse.maven:ee3-65509:2305023') // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
@@ -26,5 +27,6 @@ dependencies {
compileOnly(rfg.deobf('curse.maven:mekanism-268560:2475797')) // https://www.curseforge.com/minecraft/mc-mods/mekanism/files/2475797
compileOnly(rfg.deobf('maven.modrinth:immibis-microblocks:59.1.2')) // https://modrinth.com/mod/immibis-microblocks/version/59.1.2
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta46:api') {transitive = false}
compileOnlyApi('com.github.GTNewHorizons:Angelica:1.0.0-beta66a:api') {transitive = false}
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.58:dev")
}
+40 -5
View File
@@ -39,9 +39,33 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = true
# Enables modern Java syntax support. Valid values:
# - false: No modern syntax, Java 8 only
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
# - modern: Native modern Java bytecode, no downgrading
enableModernJavaSyntax = jabel
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
# and should *not* be used in most situations. -1 disables this.
# forceToolchainVersion = -1
# Target JVM version for JVM Downgrader bytecode downgrading.
# Only used when enableModernJavaSyntax = jvmDowngrader
# downgradeTargetVersion = 8
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
# Classes will be available in META-INF/versions/N/ for each version N in this list.
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
# jvmDowngraderMultiReleaseVersions = 21,25
# Specifies how JVM Downgrader API stubs are provided. Options:
# - shade: Shade minimized stubs into the jar
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
# - external: Another dependency provides stubs (no constraint, no warning)
# - (empty): Warning reminding you to configure stubs
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
# jvmDowngraderStubsProvider =
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
@@ -96,7 +120,9 @@ usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
@@ -151,7 +177,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
@@ -172,6 +198,12 @@ curseForgeRelations =
# projects. New projects should not use this parameter.
# customArchiveBaseName =
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
# runClientWorkingDirectory = run/client
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
# runServerWorkingDirectory = run/server
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
@@ -201,3 +233,6 @@ curseForgeRelations =
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
# Non-GTNH properties
org.gradle.configuration-cache = true
org.gradle.parallel = true
+12
View File
@@ -0,0 +1,12 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect
toolchainVersion=25
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -5
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -172,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+1 -2
View File
@@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.19'
}
@@ -1,7 +1,5 @@
package crazypants.enderio;
import java.text.DecimalFormat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -9,20 +7,27 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.render.ConduitRenderer;
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
import crazypants.enderio.machine.transceiver.ServerChannelRegister;
import crazypants.enderio.machine.wireless.WirelessChargerController;
public class CommonProxy {
private static final DecimalFormat FORMAT = new DecimalFormat("########0.000");
protected long serverTickCount = 0;
protected long clientTickCount = 0;
protected final TickTimer tickTimer = new TickTimer();
public ConduitNetworkTickHandler conduitNetworkTickHandler = null;
public WirelessChargerController wirelessChargerController = null;
public CommonProxy() {}
@@ -44,7 +49,7 @@ public class CommonProxy {
}
public void loadIcons() {
;
}
public void load() {
@@ -76,6 +81,26 @@ public class CommonProxy {
return new ResourceLocation(EnderIO.DOMAIN + TEXTURE_PATH + name + TEXTURE_EXT);
}
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
conduitNetworkTickHandler = new ConduitNetworkTickHandler();
FMLCommonHandler.instance().bus().register(conduitNetworkTickHandler);
wirelessChargerController = new WirelessChargerController();
FMLCommonHandler.instance().bus().register(wirelessChargerController);
}
public void onServerStarted(FMLServerStartedEvent event) {
HyperCubeRegister.load();
ServerChannelRegister.load();
}
public void onServerStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
FMLCommonHandler.instance().bus().unregister(conduitNetworkTickHandler);
conduitNetworkTickHandler = null;
FMLCommonHandler.instance().bus().unregister(wirelessChargerController);
wirelessChargerController = null;
}
public final class TickTimer {
@SubscribeEvent
+26 -17
View File
@@ -38,6 +38,7 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -111,7 +112,6 @@ import crazypants.enderio.machine.generator.zombie.BlockZombieGenerator.BlockEnd
import crazypants.enderio.machine.generator.zombie.BlockZombieGenerator.BlockFrankenZombieGenerator;
import crazypants.enderio.machine.generator.zombie.PacketNutrientTank;
import crazypants.enderio.machine.hypercube.BlockHyperCube;
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
import crazypants.enderio.machine.invpanel.BlockInventoryPanel;
import crazypants.enderio.machine.killera.BlockKillerJoe;
import crazypants.enderio.machine.light.BlockElectricLight;
@@ -190,7 +190,6 @@ import crazypants.util.EE3Util;
after:Waila@[1.5.8,);\
after:Thaumcraft;\
after:appliedenergistics2@[rv2-beta-8,);\
after:chisel;\
after:Railcraft@[9.16.7,)\
""", guiFactory = "crazypants.enderio.config.ConfigFactoryEIO")
public class EnderIO {
@@ -214,6 +213,8 @@ public class EnderIO {
public static final boolean hasLwjgl3 = Loader.isModLoaded("lwjgl3ify");
public static final boolean hasGT5 = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
public static final boolean hasHP = Loader.isModLoaded("hodgepodge");
public static final boolean hasWailaPlugins = Loader.isModLoaded("wailaplugins");
// Materials
public static ItemCapacitor itemBasicCapacitor;
@@ -487,7 +488,9 @@ public class EnderIO {
itemGrindingBall = ItemGrindingBall.create();
itemAlloyEndergy = ItemAlloyEndergy.create();
itemGrindingBallEndergy = ItemGrindingBallEndergy.create();
itemPowderIngot = ItemPowderIngot.create();
if (!hasGT5) {
itemPowderIngot = ItemPowderIngot.create();
}
registerFluids();
@@ -727,7 +730,9 @@ public class EnderIO {
SkeletonHandler.registerSkeleton(this);
}
MaterialRecipes.registerDependantOresInDictionary();
if (!hasGT5) {
MaterialRecipes.registerDependantOresInDictionary();
}
EnderfaceRecipes.addRecipes();
MaterialRecipes.addRecipes();
@@ -890,22 +895,18 @@ public class EnderIO {
}
@EventHandler
public void serverStarted(FMLServerStartedEvent event) {
HyperCubeRegister.load();
ServerChannelRegister.load();
}
@SubscribeEvent
public void worldSaved(WorldEvent.Save event) {
// Only save together with the overworld, because this gets called for every dimension separately
if (event.world.provider != null && event.world.provider.dimensionId == 0) {
ServerChannelRegister.store();
}
public void onServerAboutToStart(FMLServerAboutToStartEvent event) {
proxy.onServerAboutToStart(event);
}
@EventHandler
public void serverStopped(FMLServerStoppedEvent event) {
HyperCubeRegister.unload();
public void onServerStarted(FMLServerStartedEvent event) {
proxy.onServerStarted(event);
}
@EventHandler
public void onServerStopped(FMLServerStoppedEvent event) {
proxy.onServerStopped(event);
}
@EventHandler
@@ -917,4 +918,12 @@ public class EnderIO {
}
}
}
@SubscribeEvent
public void worldSaved(WorldEvent.Save event) {
// Only save together with the overworld, because this gets called for every dimension separately
if (event.world.provider != null && event.world.provider.dimensionId == 0) {
ServerChannelRegister.store();
}
}
}
@@ -47,6 +47,7 @@ import crazypants.enderio.conduit.power.IPowerConduit;
import crazypants.enderio.conduit.power.PowerConduitNetwork;
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
import crazypants.enderio.conduit.redstone.RedstoneConduitNetwork;
import crazypants.util.ForgeDirections;
import mods.immibis.microblocks.api.EnumPartClass;
import mods.immibis.microblocks.api.EnumPosition;
import mods.immibis.microblocks.api.IMicroblockCoverSystem;
@@ -118,7 +119,7 @@ public abstract class AbstractConduit implements IConduit {
return false;
}
if (dataRoot.hasKey("connectionMode")) {
ConnectionMode mode = ConnectionMode.values()[dataRoot.getShort("connectionMode")];
ConnectionMode mode = ConnectionMode.VALUES[dataRoot.getShort("connectionMode")];
setConnectionMode(dir, mode);
}
readTypeSettings(dir, dataRoot);
@@ -382,13 +383,13 @@ public abstract class AbstractConduit implements IConduit {
conduitConnections.clear();
int[] dirs = nbtRoot.getIntArray("connections");
for (int i = 0; i < dirs.length; i++) {
conduitConnections.add(ForgeDirection.values()[dirs[i]]);
conduitConnections.add(ForgeDirections.DIRECTIONS[dirs[i]]);
}
externalConnections.clear();
dirs = nbtRoot.getIntArray("externalConnections");
for (int i = 0; i < dirs.length; i++) {
externalConnections.add(ForgeDirection.values()[dirs[i]]);
externalConnections.add(ForgeDirections.DIRECTIONS[dirs[i]]);
}
active = nbtRoot.getBoolean("signalActive");
@@ -397,7 +398,7 @@ public abstract class AbstractConduit implements IConduit {
if (modes != null && modes.length == 6) {
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
conectionModes.put(dir, ConnectionMode.values()[modes[i]]);
conectionModes.put(dir, ConnectionMode.VALUES[modes[i]]);
i++;
}
}
@@ -7,6 +7,8 @@ import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import crazypants.enderio.EnderIO;
// I=base type, I is the base class of the implementations accepted by the network
public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
@@ -64,7 +66,7 @@ public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
public void addConduit(I con) {
if (!conduits.contains(con)) {
if (conduits.isEmpty()) {
ConduitNetworkTickHandler.instance.registerNetwork(this);
EnderIO.proxy.conduitNetworkTickHandler.registerNetwork(this);
}
conduits.add(con);
}
@@ -75,7 +77,7 @@ public abstract class AbstractConduitNetwork<T extends IConduit, I extends T> {
con.setNetwork(null);
}
conduits.clear();
ConduitNetworkTickHandler.instance.unregisterNetwork(this);
EnderIO.proxy.conduitNetworkTickHandler.unregisterNetwork(this);
}
public List<I> getConduits() {
@@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.util.ForgeDirections;
import mods.immibis.microblocks.api.IMicroblockCoverSystem;
import mods.immibis.microblocks.api.IMicroblockSupporterTile;
import mods.immibis.microblocks.api.MicroblockAPIUtils;
@@ -84,7 +85,7 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem {
}
return true;
} else {
ForgeDirection dir = ForgeDirection.values()[side];
ForgeDirection dir = ForgeDirections.DIRECTIONS[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
@@ -32,7 +32,6 @@ import com.enderio.core.client.render.BoundingBox;
import com.enderio.core.common.util.BlockCoord;
import com.enderio.core.common.util.Util;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -72,6 +71,7 @@ import crazypants.enderio.item.ItemConduitProbe;
import crazypants.enderio.machine.painter.PainterUtil;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.tool.ToolUtil;
import crazypants.util.ForgeDirections;
import crazypants.util.IFacade;
import mods.immibis.core.api.multipart.IMultipartRenderingBlockMarker;
import mods.immibis.core.api.multipart.IMultipartSystem;
@@ -93,9 +93,6 @@ public class BlockConduitBundle extends BlockEio
public static BlockConduitBundle create() {
MinecraftForge.EVENT_BUS.register(ConduitNetworkTickHandler.instance);
FMLCommonHandler.instance().bus().register(ConduitNetworkTickHandler.instance);
PacketHandler.INSTANCE
.registerMessage(PacketFluidLevel.class, PacketFluidLevel.class, PacketHandler.nextID(), Side.CLIENT);
PacketHandler.INSTANCE
@@ -160,7 +157,6 @@ public class BlockConduitBundle extends BlockEio
BlockConduitBundle result = new BlockConduitBundle();
result.init();
MinecraftForge.EVENT_BUS.register(result);
return result;
}
@@ -292,41 +288,6 @@ public class BlockConduitBundle extends BlockEio
effectRenderer.addEffect(digFX);
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySound(PlaySoundSourceEvent event) {
String path = event.sound.getPositionedSoundLocation().getResourcePath();
if ("silence.step".equals(path)) {
ISound snd = event.sound;
World world = EnderIO.proxy.getClientWorld();
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playHitSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
String path = event.name;
World world = event.entity.worldObj;
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playStepSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@Override
protected void init() {
super.init();
@@ -334,6 +295,7 @@ public class BlockConduitBundle extends BlockEio
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + dir.ordinal(), this);
}
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_EXTERNAL_CONNECTION_SELECTOR, this);
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -473,24 +435,6 @@ public class BlockConduitBundle extends BlockEio
: resist;
}
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
if (event.block == this) {
ItemStack held = event.entityPlayer.getCurrentEquippedItem();
if (held == null || held.getItem().getHarvestLevel(held, "pickaxe") == -1) {
event.newSpeed += 2;
}
IConduitBundle te = (IConduitBundle) event.entity.worldObj.getTileEntity(event.x, event.y, event.z);
if (te != null && te.getFacadeType() == FacadeType.HARDENED) {
if (!ConduitUtil.isSolidFacadeRendered(te, event.entityPlayer)) {
event.newSpeed *= 6;
} else {
event.newSpeed *= 2;
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
@@ -876,7 +820,7 @@ public class BlockConduitBundle extends BlockEio
return new ExternalConnectionContainer(
player.inventory,
(IConduitBundle) te,
ForgeDirection.values()[id - GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE]);
ForgeDirections.DIRECTIONS[id - GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE]);
}
return null;
}
@@ -891,7 +835,7 @@ public class BlockConduitBundle extends BlockEio
return new GuiExternalConnection(
player.inventory,
(IConduitBundle) te,
ForgeDirection.values()[id - GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE]);
ForgeDirections.DIRECTIONS[id - GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE]);
}
return null;
}
@@ -1274,4 +1218,61 @@ public class BlockConduitBundle extends BlockEio
private boolean hasMicroblocks(IConduitBundle bundle) {
return !bundle.getCoverSystem().getAllParts().isEmpty();
}
public class EventHandler {
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySound(PlaySoundSourceEvent event) {
String path = event.sound.getPositionedSoundLocation().getResourcePath();
if ("silence.step".equals(path)) {
ISound snd = event.sound;
World world = EnderIO.proxy.getClientWorld();
if (world == null) return;
BlockCoord bc = new BlockCoord(snd.getXPosF(), snd.getYPosF(), snd.getZPosF());
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playHitSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playHitSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
String path = event.name;
World world = event.entity.worldObj;
if ("EnderIO:silence.step".equals(path) && world.isRemote) {
BlockCoord bc = new BlockCoord(event.entity.posX, event.entity.posY - 2, event.entity.posZ);
TileEntity te = bc.getTileEntity(world);
if (te instanceof TileConduitBundle && ((TileConduitBundle) te).hasFacade()) {
Block facade = getFacade(world, bc.x, bc.y, bc.z, -1);
ConduitUtil.playStepSound(facade.stepSound, world, bc.x, bc.y, bc.z);
} else {
ConduitUtil.playStepSound(Block.soundTypeMetal, world, bc.x, bc.y, bc.z);
}
}
}
@SubscribeEvent
public void onBreakSpeed(BreakSpeed event) {
if (event.block == BlockConduitBundle.this) {
ItemStack held = event.entityPlayer.getCurrentEquippedItem();
if (held == null || held.getItem().getHarvestLevel(held, "pickaxe") == -1) {
event.newSpeed += 2;
}
IConduitBundle te = (IConduitBundle) event.entity.worldObj.getTileEntity(event.x, event.y, event.z);
if (te != null && te.getFacadeType() == FacadeType.HARDENED) {
if (!ConduitUtil.isSolidFacadeRendered(te, event.entityPlayer)) {
event.newSpeed *= 6;
} else {
event.newSpeed *= 2;
}
}
}
}
}
}
@@ -10,18 +10,15 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
public class ConduitNetworkTickHandler {
public static final ConduitNetworkTickHandler instance = new ConduitNetworkTickHandler();
public interface TickListener {
public static interface TickListener {
void tickStart(TickEvent.ServerTickEvent evt);
public void tickStart(TickEvent.ServerTickEvent evt);
public void tickEnd(TickEvent.ServerTickEvent evt);
void tickEnd(TickEvent.ServerTickEvent evt);
}
private final List<TickListener> listeners = new ArrayList<TickListener>();
private final IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean> networks = new IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean>();
private final List<TickListener> listeners = new ArrayList<>();
private final IdentityHashMap<AbstractConduitNetwork<?, ?>, Boolean> networks = new IdentityHashMap<>();
public void addListener(TickListener listener) {
listeners.add(listener);
@@ -10,6 +10,10 @@ public enum ConnectionMode {
DISABLED("gui.conduit.ioMode.disabled"),
NOT_SET("gui.conduit.ioMode.notSet");
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final ConnectionMode[] VALUES = values();
private final String unlocalisedName;
ConnectionMode(String unlocalisedName) {
@@ -22,19 +26,19 @@ public enum ConnectionMode {
public static ConnectionMode getNext(ConnectionMode mode) {
int ord = mode.ordinal() + 1;
if (ord >= ConnectionMode.values().length) {
if (ord >= ConnectionMode.VALUES.length) {
ord = 0;
}
return ConnectionMode.values()[ord];
return ConnectionMode.VALUES[ord];
}
public static ConnectionMode getPrevious(ConnectionMode mode) {
int ord = mode.ordinal() - 1;
if (ord < 0) {
ord = ConnectionMode.values().length - 1;
ord = ConnectionMode.VALUES.length - 1;
}
return ConnectionMode.values()[ord];
return ConnectionMode.VALUES[ord];
}
public boolean acceptsInput() {
@@ -51,6 +51,7 @@ import crazypants.enderio.conduit.power.IPowerConduit;
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
import crazypants.enderio.config.Config;
import crazypants.util.ForgeDirections;
import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import mekanism.api.gas.Gas;
@@ -412,7 +413,7 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
}
// If you're wondering why I am not using conduit.writeToNBT, it is because there is some data that should not
// persist, some of which causes crashes with energy conduits.
NBTTagCompound[] originalData = new NBTTagCompound[ForgeDirection.values().length];
NBTTagCompound[] originalData = new NBTTagCompound[ForgeDirections.DIRECTIONS.length];
for (ForgeDirection conduitConnection : original.getExternalConnections()) {
NBTTagCompound tag = new NBTTagCompound();
original.writeConnectionSettingsToNBT(conduitConnection, tag);
@@ -423,7 +424,7 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
for (int i = 0; i < originalData.length; i++) {
NBTTagCompound nbt = originalData[i];
if (nbt != null) {
replacement.readConduitSettingsFromNBT(ForgeDirection.values()[i], nbt);
replacement.readConduitSettingsFromNBT(ForgeDirections.DIRECTIONS[i], nbt);
}
}
}
@@ -32,10 +32,11 @@ import crazypants.enderio.machine.painter.BasicPainterTemplate;
import crazypants.enderio.machine.painter.IPaintedBlock;
import crazypants.enderio.machine.painter.PaintSourceValidator;
import crazypants.enderio.machine.painter.PainterUtil;
import crazypants.util.ForgeDirections;
public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider, IResourceTooltipProvider {
public static enum FacadeType {
public enum FacadeType {
BASIC,
HARDENED;
@@ -115,7 +116,7 @@ public class ItemConduitFacade extends Item implements IAdvancedTooltipProvider,
return true;
}
ForgeDirection dir = ForgeDirection.values()[side];
ForgeDirection dir = ForgeDirections.DIRECTIONS[side];
int placeX = x + dir.offsetX;
int placeY = y + dir.offsetY;
int placeZ = z + dir.offsetZ;
@@ -193,8 +193,8 @@ public abstract class AbstractGasConduit extends AbstractConduit implements IGas
key = "extSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
extractionColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
extractionColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
@@ -72,7 +72,7 @@ public class GasSettings extends BaseSettingsPanel {
public void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON) {
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.values()[colorB.getColorIndex()]);
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.VALUES[colorB.getColorIndex()]);
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(conduit, gui.getDir()));
}
}
@@ -23,6 +23,7 @@ import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.enderio.network.PacketHandler;
import crazypants.util.ForgeDirections;
public class GuiExternalConnectionSelector extends GuiScreen {
@@ -51,7 +52,7 @@ public class GuiExternalConnectionSelector extends GuiScreen {
@Override
protected void actionPerformed(GuiButton b) {
ForgeDirection dir = ForgeDirection.values()[b.id];
ForgeDirection dir = ForgeDirections.DIRECTIONS[b.id];
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
BlockCoord loc = cb.getLocation();
PacketHandler.INSTANCE.sendToServer(new PacketOpenConduitUI(cb.getEntity(), dir));
@@ -172,7 +172,7 @@ public class LiquidSettings extends BaseSettingsPanel {
public void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON) {
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.values()[colorB.getColorIndex()]);
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.VALUES[colorB.getColorIndex()]);
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(conduit, gui.getDir()));
} else if (guiButton.id == ID_INSERT_WHITELIST || guiButton.id == ID_EXTRACT_WHITELIST) {
toggleBlacklist(guiButton.id == ID_EXTRACT_WHITELIST);
@@ -180,7 +180,7 @@ public class LiquidSettings extends BaseSettingsPanel {
ColorButton btn = (ColorButton) guiButton;
if (isEnder) {
DyeColor col = DyeColor.values()[btn.getColorIndex()];
DyeColor col = DyeColor.VALUES[btn.getColorIndex()];
boolean isInput = guiButton.id == ID_EXTRACT_CHANNEL;
if (isInput) {
@@ -42,7 +42,7 @@ public class OCSettings extends BaseSettingsPanel {
public void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON && cb != null) {
occon.setSignalColor(gui.getDir(), DyeColor.values()[cb.getColorIndex()]);
occon.setSignalColor(gui.getDir(), DyeColor.VALUES[cb.getColorIndex()]);
PacketHandler.INSTANCE.sendToServer(new PacketOCConduitSignalColor(occon, gui.getDir()));
}
}
@@ -11,6 +11,7 @@ import crazypants.enderio.conduit.liquid.AbstractEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.ILiquidConduit;
import crazypants.enderio.conduit.packet.AbstractConduitPacket;
import crazypants.enderio.conduit.packet.ConTypeEnum;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketFluidChannel extends AbstractConduitPacket<ILiquidConduit>
@@ -42,9 +43,9 @@ public class PacketFluidChannel extends AbstractConduitPacket<ILiquidConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
isInput = buf.readBoolean();
channel = DyeColor.values()[buf.readShort()];
channel = DyeColor.VALUES[buf.readShort()];
}
@Override
@@ -12,6 +12,7 @@ import crazypants.enderio.conduit.liquid.FluidFilter;
import crazypants.enderio.conduit.liquid.ILiquidConduit;
import crazypants.enderio.conduit.packet.AbstractConduitPacket;
import crazypants.enderio.conduit.packet.ConTypeEnum;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketFluidFilter extends AbstractConduitPacket<ILiquidConduit>
@@ -44,7 +45,7 @@ public class PacketFluidFilter extends AbstractConduitPacket<ILiquidConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
isInput = buf.readBoolean();
NBTTagCompound tag = ByteBufUtils.readTag(buf);
filter = new FluidFilter();
@@ -11,6 +11,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.EnderIO;
import crazypants.enderio.GuiHandler;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketOpenConduitUI extends MessageTileEntity<TileEntity>
@@ -34,7 +35,7 @@ public class PacketOpenConduitUI extends MessageTileEntity<TileEntity>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
}
public IMessage onMessage(PacketOpenConduitUI message, MessageContext ctx) {
@@ -59,7 +59,7 @@ public class PowerSettings extends BaseSettingsPanel {
public void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON) {
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.values()[colorB.getColorIndex()]);
conduit.setExtractionSignalColor(gui.getDir(), DyeColor.VALUES[colorB.getColorIndex()]);
PacketHandler.INSTANCE.sendToServer(new PacketExtractMode(conduit, gui.getDir()));
}
}
@@ -61,7 +61,7 @@ public class RedstoneSettings extends BaseSettingsPanel {
public void actionPerformed(GuiButton guiButton) {
super.actionPerformed(guiButton);
if (guiButton.id == ID_COLOR_BUTTON && cb != null) {
insCon.setSignalColor(gui.getDir(), DyeColor.values()[cb.getColorIndex()]);
insCon.setSignalColor(gui.getDir(), DyeColor.VALUES[cb.getColorIndex()]);
PacketHandler.INSTANCE.sendToServer(new PacketRedstoneConduitSignalColor(insCon, gui.getDir()));
} else if (guiButton.id == ID_STRONG_BUTTON && strongCB != null) {
insCon.setOutputStrength(gui.getDir(), strongCB.isSelected());
@@ -14,17 +14,25 @@ import crazypants.enderio.conduit.item.NetworkedInventory;
import crazypants.enderio.conduit.item.filter.ExistingItemFilter;
import crazypants.enderio.conduit.packet.AbstractConduitPacket;
import crazypants.enderio.conduit.packet.ConTypeEnum;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketExistingItemFilterSnapshot extends AbstractConduitPacket<IItemConduit>
implements IMessageHandler<PacketExistingItemFilterSnapshot, IMessage> {
public static enum Opcode {
public enum Opcode {
CLEAR,
SET,
MERGE,
SET_BLACK,
UNSET_BLACK
UNSET_BLACK;
private static final Opcode[] VALUES = values();
public static Opcode fromOrdinal(int ordinal) {
return VALUES[ordinal];
}
}
private ForgeDirection dir;
@@ -43,9 +51,9 @@ public class PacketExistingItemFilterSnapshot extends AbstractConduitPacket<IIte
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
isInput = buf.readBoolean();
opcode = Opcode.values()[buf.readByte() & 255];
opcode = Opcode.fromOrdinal(buf.readByte() & 255);
}
@Override
@@ -10,6 +10,7 @@ import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.filter.ModItemFilter;
import crazypants.enderio.conduit.packet.AbstractConduitPacket;
import crazypants.enderio.conduit.packet.ConTypeEnum;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketModItemFilter extends AbstractConduitPacket<IItemConduit>
@@ -33,7 +34,7 @@ public class PacketModItemFilter extends AbstractConduitPacket<IItemConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
isInput = buf.readBoolean();
index = buf.readInt();
boolean isNull = buf.readBoolean();
@@ -164,10 +164,10 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
@Override
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
setExtractionSignalColor(dir, DyeColor.values()[dataRoot.getShort("extractionSignalColor")]);
setExtractionSignalColor(dir, DyeColor.VALUES[dataRoot.getShort("extractionSignalColor")]);
setExtractionRedstoneMode(RedstoneControlMode.values()[dataRoot.getShort("extractionRedstoneMode")], dir);
setInputColor(dir, DyeColor.values()[dataRoot.getShort("inputColor")]);
setOutputColor(dir, DyeColor.values()[dataRoot.getShort("outputColor")]);
setInputColor(dir, DyeColor.VALUES[dataRoot.getShort("inputColor")]);
setOutputColor(dir, DyeColor.VALUES[dataRoot.getShort("outputColor")]);
setSelfFeedEnabled(dir, dataRoot.getBoolean("selfFeed"));
setRoundRobinEnabled(dir, dataRoot.getBoolean("roundRobin"));
setOutputPriority(dir, dataRoot.getInteger("outputPriority"));
@@ -857,8 +857,8 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
key = "extSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
extractionColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
extractionColors.put(dir, DyeColor.VALUES[ord]);
}
}
key = "selfFeed." + dir.name();
@@ -882,16 +882,16 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
key = "inSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
inputColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
inputColors.put(dir, DyeColor.VALUES[ord]);
}
}
key = "outSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
outputColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
outputColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
@@ -10,7 +10,6 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -25,6 +24,7 @@ import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.enderio.conduit.item.filter.ItemFilterLimited;
import crazypants.enderio.config.Config;
import crazypants.enderio.machine.invpanel.TileInventoryPanel;
import crazypants.util.ForgeDirections;
public class NetworkedInventory {
@@ -41,8 +41,8 @@ public class NetworkedInventory {
int tickDeficit;
// work around for a vanilla chest changing into a double chest without doing unneeded checks all the time
boolean recheckInv = false;
private TileEntity connectedTileEntity;
// Hack for TiC crafting station not working correctly when setting output slot to null
boolean ticHack = false;
@@ -61,19 +61,13 @@ public class NetworkedInventory {
this.location = location;
world = con.getBundle().getWorld();
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (te.getClass().getName().contains("cpw.mods.ironchest")) {
recheckInv = true;
} else if (te instanceof TileEntityChest) {
recheckInv = true;
} else if (te instanceof TileInventoryPanel) {
inventoryPanel = true;
}
updateInventory();
}
public boolean isInvalid() {
return connectedTileEntity == null || connectedTileEntity.isInvalid();
}
public boolean hasTarget(IItemConduit conduit, ForgeDirection dir) {
for (Target t : sendPriority) {
if (t.inv.con == conduit && t.inv.conDir == dir) {
@@ -110,6 +104,13 @@ public class NetworkedInventory {
}
public void onTick() {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return;
}
}
if (tickDeficit > 0 || !canExtract() || !con.isExtractionRedstoneConditionMet(conDir)) {
// do nothing
} else {
@@ -144,11 +145,6 @@ public class NetworkedInventory {
}
private boolean transferItems() {
if (recheckInv) {
updateInventory();
}
int[] slotIndices = getInventory().getAccessibleSlotsFromSide(inventorySide);
if (slotIndices == null) {
return false;
@@ -257,9 +253,6 @@ public class NetworkedInventory {
matchedStickyInput = of != null && of.isValid() && of.doesItemPassFilter(this, toExtract);
}
if (target.stickyInput || !matchedStickyInput) {
if (target.inv.recheckInv) {
target.inv.updateInventory();
}
int inserted = target.inv.insertItem(toExtract);
if (inserted > 0) {
toExtract.stackSize -= inserted;
@@ -281,15 +274,38 @@ public class NetworkedInventory {
}
public final void updateInventory() {
TileEntity te = world.getTileEntity(location.x, location.y, location.z);
if (te instanceof ISidedInventory) {
inv = (ISidedInventory) te;
} else if (te instanceof IInventory) {
inv = new InventoryWrapper((IInventory) te);
TileEntity newTe = world.getTileEntity(location.x, location.y, location.z);
if (newTe != connectedTileEntity) {
connectedTileEntity = newTe;
ticHack = false;
inventoryPanel = false;
if (connectedTileEntity != null) {
if (connectedTileEntity.getClass().getName().equals("tconstruct.tools.logic.CraftingStationLogic")) {
ticHack = true;
} else if (connectedTileEntity instanceof TileInventoryPanel) {
inventoryPanel = true;
}
}
network.routesChanged();
}
if (connectedTileEntity instanceof ISidedInventory) {
inv = (ISidedInventory) connectedTileEntity;
} else if (connectedTileEntity instanceof IInventory) {
inv = new InventoryWrapper((IInventory) connectedTileEntity);
} else {
inv = null;
}
}
private int insertItem(ItemStack item) {
if (isInvalid()) {
updateInventory();
if (isInvalid()) {
return 0;
}
}
if (!canInsert() || item == null) {
return 0;
}
@@ -312,7 +328,7 @@ public class NetworkedInventory {
return 0;
}
}
return ItemUtil.doInsertItem(getInventory(), item, ForgeDirection.values()[inventorySide]);
return ItemUtil.doInsertItem(getInventory(), item, ForgeDirections.DIRECTIONS[inventorySide]);
}
void updateInsertOrder() {
@@ -410,7 +426,7 @@ public class NetworkedInventory {
}
public ISidedInventory getInventoryRecheck() {
if (recheckInv) {
if (isInvalid()) {
updateInventory();
}
return inv;
@@ -7,7 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Supplier;
import java.util.function.IntSupplier;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -89,20 +89,20 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
STELLAR(() -> Config.stellarEnderFluidConduitExtractRate, () -> Config.stellarEnderFluidConduitMaxIoRate);
private final Supplier<Integer> getMaxExtractPerTick;
private final Supplier<Integer> getMaxIoPerTick;
private final IntSupplier getMaxExtractPerTick;
private final IntSupplier getMaxIoPerTick;
Type(Supplier<Integer> getMaxExtractPerTick, Supplier<Integer> getMaxIoPerTick) {
Type(IntSupplier getMaxExtractPerTick, IntSupplier getMaxIoPerTick) {
this.getMaxExtractPerTick = getMaxExtractPerTick;
this.getMaxIoPerTick = getMaxIoPerTick;
}
public int getMaxExtractPerTick() {
return getMaxExtractPerTick.get();
return getMaxExtractPerTick.getAsInt();
}
public int getMaxIoPerTick() {
return getMaxIoPerTick.get();
return getMaxIoPerTick.getAsInt();
}
}
@@ -424,10 +424,10 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
super.readTypeSettings(dir, dataRoot);
if (dataRoot.hasKey("inputColor")) {
setInputColor(dir, DyeColor.values()[dataRoot.getShort("inputColor")]);
setInputColor(dir, DyeColor.VALUES[dataRoot.getShort("inputColor")]);
}
if (dataRoot.hasKey("outputColor")) {
setOutputColor(dir, DyeColor.values()[dataRoot.getShort("outputColor")]);
setOutputColor(dir, DyeColor.VALUES[dataRoot.getShort("outputColor")]);
}
if (dataRoot.hasKey("roundRobin")) {
@@ -542,16 +542,16 @@ public abstract class AbstractEnderLiquidConduit extends AbstractLiquidConduit {
key = "inSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
inputColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
inputColors.put(dir, DyeColor.VALUES[ord]);
}
}
key = "outSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
outputColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
outputColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
@@ -204,7 +204,7 @@ public abstract class AbstractLiquidConduit extends AbstractConduit implements I
@Override
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
setExtractionSignalColor(dir, DyeColor.values()[dataRoot.getShort("extractionSignalColor")]);
setExtractionSignalColor(dir, DyeColor.VALUES[dataRoot.getShort("extractionSignalColor")]);
setExtractionRedstoneMode(RedstoneControlMode.values()[dataRoot.getShort("extractionRedstoneMode")], dir);
}
@@ -248,8 +248,8 @@ public abstract class AbstractLiquidConduit extends AbstractConduit implements I
key = "extSC." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
extractionColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
extractionColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
@@ -85,11 +85,13 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
return false;
}
if (tank.externalTank.getTankInfo(conDir.getOpposite()) != null) {
for (FluidTankInfo tankInfo : tank.externalTank.getTankInfo(conDir.getOpposite())) {
FluidTankInfo[] tankInfos = tank.externalTank.getTankInfo(conDir.getOpposite());
if (tankInfos != null) {
for (FluidTankInfo tankInfo : tankInfos) {
if (tankInfo == null || tankInfo.fluid == null) {
continue;
}
FluidStack tryDrain = tankInfo.fluid.copy();
tryDrain.amount = type.getMaxExtractPerTick();
FluidStack drained = tank.externalTank.drain(conDir.getOpposite(), tryDrain, false);
@@ -98,10 +100,12 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
|| !tryDrain.isFluidEqual(drained)) {
continue;
}
int amountAccepted = fillFrom(tank, drained.copy(), true);
int amountAccepted = fillFrom(tank, drained, true);
if (amountAccepted <= 0) {
continue;
}
tryDrain.amount = amountAccepted;
drained = tank.externalTank.drain(conDir.getOpposite(), tryDrain, true);
if (drained == null || drained.amount <= 0) {
@@ -115,7 +119,7 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
if (drained == null || drained.amount <= 0 || !matchedFilter(drained, con, conDir, true)) {
return false;
}
int amountAccepted = fillFrom(tank, drained.copy(), true);
int amountAccepted = fillFrom(tank, drained, true);
if (amountAccepted <= 0) {
return false;
}
@@ -147,7 +151,6 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
resource = resource.copy();
resource.amount = Math.min(resource.amount, type.getMaxIoPerTick());
int filled = 0;
int remaining = resource.amount;
// TODO: Only change starting pos of iterator is doFill is true so a false then true returns the same
TankIterator iterator;
@@ -158,13 +161,13 @@ public class EnderLiquidConduitNetwork extends AbstractConduitNetwork<ILiquidCon
&& target.acceptsOuput
&& target.isValid()
&& matchedFilter(resource, target.con, target.conDir, false)) {
int vol = target.externalTank.fill(target.tankDir, resource.copy(), doFill);
remaining -= vol;
// Use reused FluidStack instead of copying each iteration
int vol = target.externalTank.fill(target.tankDir, resource, doFill);
resource.amount -= vol;
filled += vol;
if (remaining <= 0) {
if (resource.amount <= 0) {
break;
}
resource.amount = remaining;
}
}
if (!tank.con.isRoundRobin(tank.conDir)) iterator.rewind();
@@ -86,7 +86,7 @@ public class OCConduit extends AbstractConduit implements IOCConduit {
@Override
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
setSignalColor(dir, DyeColor.values()[dataRoot.getShort("signalColor")]);
setSignalColor(dir, DyeColor.VALUES[dataRoot.getShort("signalColor")]);
}
@Override
@@ -148,7 +148,7 @@ public class OCConduit extends AbstractConduit implements IOCConduit {
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (cols[i] >= 0) {
signalColors.put(dir, DyeColor.values()[cols[i]]);
signalColors.put(dir, DyeColor.VALUES[cols[i]]);
}
i++;
}
@@ -274,7 +274,7 @@ public class OCConduit extends AbstractConduit implements IOCConduit {
BlockCoord bc = getLocation();
if (network != null) {
boolean noconnections = true;
for (DyeColor color : DyeColor.values()) {
for (DyeColor color : DyeColor.VALUES) {
if (node(color).neighbors().iterator().hasNext()) {
noconnections = false;
ChatComponentText coltxt = new ChatComponentText(color.getLocalisedName());
@@ -350,7 +350,7 @@ public class OCConduit extends AbstractConduit implements IOCConduit {
if (loc != null && network != null) {
World world = getBundle().getWorld();
EnumSet<ForgeDirection> conns = getConnections();
for (DyeColor color : DyeColor.values()) {
for (DyeColor color : DyeColor.VALUES) {
Set<Node> should = new HashSet<Node>();
for (ForgeDirection direction : conns) {
if (getSignalColor(direction) == color) {
@@ -16,11 +16,11 @@ import li.cil.oc.api.network.Visibility;
@Interface(iface = "li.cil.oc.api.network.ManagedEnvironment", modid = "OpenComputersAPI|Network")
public class OCConduitNetwork extends AbstractConduitNetwork<IOCConduit, IOCConduit> implements ManagedEnvironment {
private Node[] node = new Node[DyeColor.values().length];
private final Node[] node = new Node[DyeColor.VALUES.length];
public OCConduitNetwork() {
super(IOCConduit.class, IOCConduit.class);
for (DyeColor dyeColor : DyeColor.values()) {
for (DyeColor dyeColor : DyeColor.VALUES) {
node[dyeColor.ordinal()] = Network.newNode(this, Visibility.Network).create();
Network.joinNewNetwork(node[dyeColor.ordinal()]);
}
@@ -68,7 +68,7 @@ public class OCConduitNetwork extends AbstractConduitNetwork<IOCConduit, IOCCond
@Override
public void destroyNetwork() {
for (DyeColor dyeColor : DyeColor.values()) {
for (DyeColor dyeColor : DyeColor.VALUES) {
node[dyeColor.ordinal()].remove();
}
super.destroyNetwork();
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketConnectionMode extends AbstractConduitPacket<IConduit>
@@ -34,8 +35,8 @@ public class PacketConnectionMode extends AbstractConduitPacket<IConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
mode = ConnectionMode.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
mode = ConnectionMode.VALUES[buf.readShort()];
}
@Override
@@ -9,6 +9,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.IExtractor;
import crazypants.enderio.machine.RedstoneControlMode;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketExtractMode extends AbstractConduitPacket<IExtractor>
@@ -38,9 +39,9 @@ public class PacketExtractMode extends AbstractConduitPacket<IExtractor>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
mode = RedstoneControlMode.values()[buf.readShort()];
color = DyeColor.values()[buf.readShort()];
color = DyeColor.VALUES[buf.readShort()];
}
@Override
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.item.FilterRegister;
import crazypants.enderio.conduit.item.IItemConduit;
import crazypants.enderio.conduit.item.filter.IItemFilter;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
@@ -56,12 +57,12 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
loopMode = buf.readBoolean();
roundRobin = buf.readBoolean();
priority = buf.readInt();
colIn = DyeColor.values()[buf.readShort()];
colOut = DyeColor.values()[buf.readShort()];
colIn = DyeColor.VALUES[buf.readShort()];
colOut = DyeColor.VALUES[buf.readShort()];
inputFilter = FilterRegister.readFilter(buf);
outputFilter = FilterRegister.readFilter(buf);
}
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.oc.IOCConduit;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketOCConduitSignalColor extends AbstractConduitPacket<IOCConduit>
@@ -34,8 +35,8 @@ public class PacketOCConduitSignalColor extends AbstractConduitPacket<IOCConduit
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
col = DyeColor.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
col = DyeColor.VALUES[buf.readShort()];
}
@Override
@@ -6,6 +6,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketRedstoneConduitOutputStrength extends AbstractConduitPacket<IInsulatedRedstoneConduit>
@@ -32,7 +33,7 @@ public class PacketRedstoneConduitOutputStrength extends AbstractConduitPacket<I
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
isStrong = buf.readBoolean();
}
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketRedstoneConduitSignalColor extends AbstractConduitPacket<IInsulatedRedstoneConduit>
@@ -34,8 +35,8 @@ public class PacketRedstoneConduitSignalColor extends AbstractConduitPacket<IIns
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
col = DyeColor.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
col = DyeColor.VALUES[buf.readShort()];
}
@Override
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.liquid.AbstractEnderLiquidConduit;
import crazypants.enderio.conduit.liquid.ILiquidConduit;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketRoundRobinMode extends AbstractConduitPacket<ILiquidConduit>
@@ -33,7 +34,7 @@ public class PacketRoundRobinMode extends AbstractConduitPacket<ILiquidConduit>
@Override
public void fromBytes(ByteBuf buf) {
super.fromBytes(buf);
dir = ForgeDirection.values()[buf.readShort()];
dir = ForgeDirections.DIRECTIONS[buf.readShort()];
roundRobin = buf.readBoolean();
}
@@ -210,7 +210,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
@Override
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
setExtractionSignalColor(dir, DyeColor.values()[dataRoot.getShort("extractionSignalColor")]);
setExtractionSignalColor(dir, DyeColor.VALUES[dataRoot.getShort("extractionSignalColor")]);
setExtractionRedstoneMode(RedstoneControlMode.values()[dataRoot.getShort("extractionRedstoneMode")], dir);
}
@@ -262,8 +262,8 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
key = "pRsCol." + dir.name();
if (nbtRoot.hasKey(key)) {
short ord = nbtRoot.getShort(key);
if (ord >= 0 && ord < DyeColor.values().length) {
rsColors.put(dir, DyeColor.values()[ord]);
if (ord >= 0 && ord < DyeColor.VALUES.length) {
rsColors.put(dir, DyeColor.VALUES[ord]);
}
}
}
@@ -242,7 +242,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
@Override
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
setSignalColor(dir, DyeColor.values()[dataRoot.getShort("signalColor")]);
setSignalColor(dir, DyeColor.VALUES[dataRoot.getShort("signalColor")]);
setOutputStrength(dir, dataRoot.getBoolean("signalStrong"));
}
@@ -583,7 +583,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (modes[i] >= 0) {
forcedConnections.put(dir, ConnectionMode.values()[modes[i]]);
forcedConnections.put(dir, ConnectionMode.VALUES[modes[i]]);
}
i++;
}
@@ -595,7 +595,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (cols[i] >= 0) {
signalColors.put(dir, DyeColor.values()[cols[i]]);
signalColors.put(dir, DyeColor.VALUES[cols[i]]);
}
i++;
}
@@ -81,7 +81,7 @@ public class SignalSource {
for (int i = 0; i < enc.length; i += 5) {
// Signal sig = new Signal(enc[i], enc[i + 1], enc[i + 2], enc[i + 3], ForgeDirection.UNKNOWN,14,
// SignalColor.values()[enc[i + 4]]);
// result.add(new SignalSource(sig, ForgeDirection.values()[enc[i + 4]]));
// result.add(new SignalSource(sig, ForgeDirections.DIRECTIONS[enc[i + 4]]));
}
return result;
}
@@ -310,7 +310,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
if (colorIdx < 0 || colorIdx > 15) {
return null;
}
return DyeColor.values()[15 - colorIdx];
return DyeColor.VALUES[15 - colorIdx];
}
private float getHealthFromStack(ItemStack item) {
@@ -11,12 +11,14 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import com.enderio.core.common.util.ChatUtil;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import cpw.mods.fml.common.gameevent.InputEvent.MouseInputEvent;
import crazypants.enderio.EnderIO;
import crazypants.enderio.api.teleport.IItemOfTravel;
import crazypants.enderio.api.tool.IConduitControl;
@@ -134,6 +136,18 @@ public class KeyTracker {
@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
handleInput();
}
// mouse button presses arrive on a separate event
@SubscribeEvent
public void onMouseInput(MouseInputEvent event) {
if (Mouse.getEventButton() >= 0) {
handleInput();
}
}
private void handleInput() {
handleGlide();
handleSoundDetector();
handleNightVision();
@@ -67,7 +67,6 @@ public class ItemDarkSteelAxe extends ItemAxe
public static ItemDarkSteelAxe create() {
ItemDarkSteelAxe res = new ItemDarkSteelAxe();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
@@ -188,18 +187,6 @@ public class ItemDarkSteelAxe extends ItemAxe
return usedPower;
}
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.entityPlayer.isSneaking()
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelAxePowerUsePerDamagePointMultiHarvest)
&& isLog(evt.block, evt.metadata)) {
evt.newSpeed = evt.originalSpeed / Config.darkSteelAxeSpeedPenaltyMultiHarvest;
}
if (isEquipped(evt.entityPlayer) && evt.block.getMaterial() == Material.leaves) {
evt.newSpeed = 6;
}
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side,
float par8, float par9, float par10) {
@@ -258,6 +245,7 @@ public class ItemDarkSteelAxe extends ItemAxe
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -336,4 +324,19 @@ public class ItemDarkSteelAxe extends ItemAxe
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
}
public class EventHandler {
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.entityPlayer.isSneaking()
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelAxePowerUsePerDamagePointMultiHarvest)
&& isLog(evt.block, evt.metadata)) {
evt.newSpeed = evt.originalSpeed / Config.darkSteelAxeSpeedPenaltyMultiHarvest;
}
if (isEquipped(evt.entityPlayer) && evt.block.getMaterial() == Material.leaves) {
evt.newSpeed = 6;
}
}
}
}
@@ -16,7 +16,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import com.enderio.core.api.client.gui.IAdvancedTooltipProvider;
import com.enderio.core.common.util.ItemUtil;
@@ -61,7 +60,6 @@ public class ItemDarkSteelPickaxe extends ItemPickaxe
public static ItemDarkSteelPickaxe create() {
ItemDarkSteelPickaxe res = new ItemDarkSteelPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -62,13 +62,12 @@ public class ItemDarkSteelShears extends ItemShears
public static ItemDarkSteelShears create() {
ItemDarkSteelShears res = new ItemDarkSteelShears();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
protected final MultiHarvestComparator harvestComparator = new MultiHarvestComparator();
protected final EntityComparator entityComparator = new EntityComparator();
private final MultiHarvestComparator harvestComparator = new MultiHarvestComparator();
private final EntityComparator entityComparator = new EntityComparator();
protected String name;
protected ItemDarkSteelShears(String name) {
@@ -202,14 +201,6 @@ public class ItemDarkSteelShears extends ItemShears
return false;
}
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.originalSpeed > 2.0
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelShearsPowerUsePerDamagePoint)) {
evt.newSpeed = evt.originalSpeed * Config.darkSteelShearsEffeciencyBoostWhenPowered;
}
}
@Override
public void setDamage(ItemStack stack, int newDamage) {
int oldDamage = getDamage(stack);
@@ -231,6 +222,7 @@ public class ItemDarkSteelShears extends ItemShears
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -330,4 +322,15 @@ public class ItemDarkSteelShears extends ItemShears
return 0;
}
}
public static class EventHandler {
@SubscribeEvent
public void onBreakSpeedEvent(PlayerEvent.BreakSpeed evt) {
if (evt.originalSpeed > 2.0
&& isEquippedAndPowered(evt.entityPlayer, Config.darkSteelShearsPowerUsePerDamagePoint)) {
evt.newSpeed = evt.originalSpeed * Config.darkSteelShearsEffeciencyBoostWhenPowered;
}
}
}
}
@@ -72,7 +72,6 @@ public class ItemDarkSteelSword extends ItemSword
public static ItemDarkSteelSword create() {
ItemDarkSteelSword res = new ItemDarkSteelSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -117,71 +116,6 @@ public class ItemDarkSteelSword extends ItemSword
return false;
}
@SubscribeEvent
public void onEnderTeleport(EnderTeleportEvent evt) {
if (evt.entityLiving.getEntityData().getBoolean("hitByDarkSteelSword")) {
evt.setCanceled(true);
}
}
// Set priorty to lowest in the hope any other mod adding head drops will have already added them
// by the time this is called to prevent multiple head drops
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityDrop(LivingDropsEvent evt) {
if (!(evt.source.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) evt.source.getEntity();
// Handle TiC weapons with beheading differently
if (handleBeheadingWeapons(player, evt)) {
return;
}
double skullDropChance = getSkullDropChance(player, evt);
if (player instanceof FakePlayer) {
skullDropChance *= Config.fakePlayerSkullChance;
}
if (Math.random() <= skullDropChance) {
dropSkull(evt, player);
}
// Special handling for ender pear drops
if (isEquipped(player)) {
String name = EntityList.getEntityString(evt.entityLiving);
if (evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
int numPearls = 0;
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChance) {
numPearls++;
}
for (int i = 0; i < evt.lootingLevel; i++) {
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) {
numPearls++;
}
}
int existing = 0;
for (EntityItem stack : evt.drops) {
if (stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) {
existing += stack.getEntityItem().stackSize;
}
}
int toDrop = numPearls - existing;
if (toDrop > 0) {
evt.drops.add(
Util.createDrop(
player.worldObj,
new ItemStack(Items.ender_pearl, toDrop, 0),
evt.entityLiving.posX,
evt.entityLiving.posY,
evt.entityLiving.posZ,
false));
}
}
}
}
protected void dropSkull(LivingDropsEvent evt, EntityPlayer player) {
ItemStack skull = getSkullForEntity(evt.entityLiving);
if (skull != null && !containsDrop(evt, skull)) {
@@ -292,6 +226,7 @@ public class ItemDarkSteelSword extends ItemSword
protected void init() {
GameRegistry.registerItem(this, getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
@@ -437,4 +372,73 @@ public class ItemDarkSteelSword extends ItemSword
return super.onItemRightClick(stack, world, player);
}
public class EventHandler {
@SubscribeEvent
public void onEnderTeleport(EnderTeleportEvent evt) {
if (evt.entityLiving.getEntityData().getBoolean("hitByDarkSteelSword")) {
evt.setCanceled(true);
}
}
// Set priorty to lowest in the hope any other mod adding head drops will have already added them
// by the time this is called to prevent multiple head drops
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEntityDrop(LivingDropsEvent evt) {
if (!(evt.source.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) evt.source.getEntity();
// Handle TiC weapons with beheading differently
if (handleBeheadingWeapons(player, evt)) {
return;
}
double skullDropChance = getSkullDropChance(player, evt);
if (player instanceof FakePlayer) {
skullDropChance *= Config.fakePlayerSkullChance;
}
if (Math.random() <= skullDropChance) {
dropSkull(evt, player);
}
// Special handling for ender pear drops
if (isEquipped(player)) {
String name = EntityList.getEntityString(evt.entityLiving);
if (evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) {
int numPearls = 0;
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChance) {
numPearls++;
}
for (int i = 0; i < evt.lootingLevel; i++) {
if (Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) {
numPearls++;
}
}
int existing = 0;
for (EntityItem stack : evt.drops) {
if (stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) {
existing += stack.getEntityItem().stackSize;
}
}
int toDrop = numPearls - existing;
if (toDrop > 0) {
evt.drops.add(
Util.createDrop(
player.worldObj,
new ItemStack(Items.ender_pearl, toDrop, 0),
evt.entityLiving.posX,
evt.entityLiving.posY,
evt.entityLiving.posZ,
false));
}
}
}
}
}
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemEndSteelAxe extends ItemDarkSteelAxe implements IEndSteelItem {
public static ItemEndSteelAxe create() {
ItemEndSteelAxe res = new ItemEndSteelAxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemEndSteelPickaxe extends ItemDarkSteelPickaxe implements IEndSte
public static ItemEndSteelPickaxe create() {
ItemEndSteelPickaxe res = new ItemEndSteelPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.relauncher.Side;
@@ -35,7 +34,6 @@ public class ItemEndSteelSword extends ItemDarkSteelSword implements IEndSteelIt
public static ItemEndSteelSword create() {
ItemEndSteelSword res = new ItemEndSteelSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -62,7 +62,7 @@ public class ItemGliderWing extends Item implements IResourceTooltipProvider {
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Capacitors.values().length - 1);
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Capacitors.VALUES.length - 1);
if (i == 0) {
return super.getUnlocalizedName();
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemStellarAxe extends ItemDarkSteelAxe implements IStellarItem {
public static ItemStellarAxe create() {
ItemStellarAxe res = new ItemStellarAxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -30,7 +29,6 @@ public class ItemStellarPickaxe extends ItemDarkSteelPickaxe implements IStellar
public static ItemStellarPickaxe create() {
ItemStellarPickaxe res = new ItemStellarPickaxe();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -6,7 +6,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.relauncher.Side;
@@ -35,7 +34,6 @@ public class ItemStellarSword extends ItemDarkSteelSword implements IStellarItem
public static ItemStellarSword create() {
ItemStellarSword res = new ItemStellarSword();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return res;
}
@@ -169,7 +169,7 @@ public abstract class AbstractPoweredMachineEntity extends AbstractMachineEntity
if (contents == null || contents.getItem() != EnderIO.itemBasicCapacitor) {
setCapacitor(Capacitors.BASIC_CAPACITOR);
} else {
setCapacitor(Capacitors.values()[contents.getItemDamage()]);
setCapacitor(Capacitors.VALUES[contents.getItemDamage()]);
}
}
@@ -181,7 +181,7 @@ public abstract class AbstractPoweredMachineEntity extends AbstractMachineEntity
@Override
public void readCommon(NBTTagCompound nbtRoot) {
super.readCommon(nbtRoot);
setCapacitor(Capacitors.values()[nbtRoot.getShort("capacitorType")]);
setCapacitor(Capacitors.VALUES[nbtRoot.getShort("capacitorType")]);
int energy;
if (nbtRoot.hasKey("storedEnergy")) {
float storedEnergyMJ = nbtRoot.getFloat("storedEnergy");
@@ -25,19 +25,19 @@ public enum IoMode {
public static ConnectionMode getNext(ConnectionMode mode) {
int ord = mode.ordinal() + 1;
if (ord >= ConnectionMode.values().length) {
if (ord >= ConnectionMode.VALUES.length) {
ord = 0;
}
return ConnectionMode.values()[ord];
return ConnectionMode.VALUES[ord];
}
public static ConnectionMode getPrevious(ConnectionMode mode) {
int ord = mode.ordinal() - 1;
if (ord < 0) {
ord = ConnectionMode.values().length - 1;
ord = ConnectionMode.VALUES.length - 1;
}
return ConnectionMode.values()[ord];
return ConnectionMode.VALUES[ord];
}
public boolean pulls() {
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.network.PacketUtil;
import crazypants.util.ForgeDirections;
import io.netty.buffer.ByteBuf;
public class PacketIoMode implements IMessage, IMessageHandler<PacketIoMode, IMessage> {
@@ -55,7 +56,7 @@ public class PacketIoMode implements IMessage, IMessageHandler<PacketIoMode, IMe
y = buf.readInt();
z = buf.readInt();
mode = IoMode.values()[buf.readShort()];
face = ForgeDirection.values()[buf.readShort()];
face = ForgeDirections.DIRECTIONS[buf.readShort()];
}
@Override
@@ -54,6 +54,7 @@ import crazypants.enderio.power.PowerDisplayUtil;
import crazypants.enderio.power.PowerHandlerUtil;
import crazypants.enderio.tool.ToolUtil;
import crazypants.enderio.waila.IWailaInfoProvider;
import crazypants.util.ForgeDirections;
public class BlockCapBank extends BlockEio
implements IGuiHandler, IAdvancedTooltipProvider, IWailaInfoProvider, IRedstoneConnectable {
@@ -345,7 +346,7 @@ public class BlockCapBank extends BlockEio
// }
TileCapBank cb = (TileCapBank) te;
ForgeDirection face = ForgeDirection.values()[side];
ForgeDirection face = ForgeDirections.DIRECTIONS[side];
int meta = ba.getBlockMetadata(x, y, z);
meta = MathHelper.clamp_int(meta, 0, CapBankType.types().size() - 1);
@@ -452,14 +453,14 @@ public class BlockCapBank extends BlockEio
protected ForgeDirection getDirForHeading(int heading) {
switch (heading) {
case 0:
return ForgeDirection.values()[2];
return ForgeDirections.DIRECTIONS[2];
case 1:
return ForgeDirection.values()[5];
return ForgeDirections.DIRECTIONS[5];
case 2:
return ForgeDirection.values()[3];
return ForgeDirections.DIRECTIONS[3];
case 3:
default:
return ForgeDirection.values()[4];
return ForgeDirections.DIRECTIONS[4];
}
}
@@ -89,7 +89,9 @@ public class ContainerCapBank extends ContainerEnderTileEntity<TileCapBank> {
}
if (hasBaublesSlots()) {
for (int i = 0; i < baubles.getSizeInventory(); i++) {
// for (int i = 0; i < baubles.getSizeInventory(); i++) {
// Capped since the sprite only has 4 slots
for (int i = 0; i < Math.min(baubles.getSizeInventory(), 4); i++) {
addSlotToContainer(new Slot(baubles, i, -15 + armorOffset, 84 + i * 18) {
@Override
@@ -122,7 +124,9 @@ public class ContainerCapBank extends ContainerEnderTileEntity<TileCapBank> {
int startHotBarSlot = endPlayerSlot + 1;
int endHotBarSlot = startHotBarSlot + 9;
int startBaublesSlot = endHotBarSlot + 1;
int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + baubles.getSizeInventory();
// int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + baubles.getSizeInventory();
// Capped since the sprite only has 4 slots
int endBaublesSlot = baubles == null ? 0 : startBaublesSlot + Math.min(baubles.getSizeInventory(), 4);
ItemStack copystack = null;
Slot slot = (Slot) inventorySlots.get(slotIndex);
@@ -16,7 +16,7 @@ import com.enderio.core.common.util.RoundRobinIterator;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import crazypants.enderio.conduit.ConduitNetworkTickHandler;
import crazypants.enderio.EnderIO;
import crazypants.enderio.conduit.ConduitNetworkTickHandler.TickListener;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.power.IPowerConduit;
@@ -212,7 +212,7 @@ public class CapBankNetwork implements ICapBankNetwork {
long curTime = world.getTotalWorldTime();
if (curTime != timeAtLastApply) {
timeAtLastApply = curTime;
ConduitNetworkTickHandler.instance.addListener(tickListener);
EnderIO.proxy.conduitNetworkTickHandler.addListener(tickListener);
}
}
@@ -13,6 +13,7 @@ import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.enderio.network.PacketHandler;
import crazypants.util.ForgeDirections;
public class BlockCrusher extends AbstractMachineBlock<TileCrusher> {
@@ -70,7 +71,7 @@ public class BlockCrusher extends AbstractMachineBlock<TileCrusher> {
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
TileCrusher te = (TileCrusher) world.getTileEntity(x, y, z);
if (te != null && te.isActive()) {
ForgeDirection front = ForgeDirection.values()[te.facing];
ForgeDirection front = ForgeDirections.DIRECTIONS[te.facing];
for (int i = 0; i < 3; i++) {
double px = x + 0.5 + front.offsetX * 0.51;
@@ -1,19 +1,21 @@
package crazypants.enderio.machine.farm;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemShears;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.EnumSkyBlock;
@@ -31,7 +33,6 @@ import crazypants.enderio.ModObject;
import crazypants.enderio.config.Config;
import crazypants.enderio.machine.AbstractPoweredTaskEntity;
import crazypants.enderio.machine.ContinuousTask;
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
import crazypants.enderio.machine.IPoweredTask;
import crazypants.enderio.machine.SlotDefinition;
import crazypants.enderio.machine.farm.farmers.FarmersCommune;
@@ -48,6 +49,8 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
private static final int TICKS_PER_WORK = 20;
private boolean showingRange;
private final List<ItemStack> harvestBuffer = new ArrayList<>();
@Override
public World getWorld() {
return worldObj;
@@ -424,6 +427,38 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
wasActive = isActive();
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
}
tryMoveFromBuffer();
}
private void tryMoveFromBuffer() {
if (harvestBuffer.isEmpty() || worldObj.isRemote) {
return;
}
List<ItemStack> toRemove = new ArrayList<>();
for (ItemStack stack : harvestBuffer) {
if (stack == null || stack.stackSize <= 0) {
toRemove.add(stack);
continue;
}
ItemStack remaining = tryInsertToInputSlots(stack);
if (remaining != null && remaining.stackSize > 0) {
remaining = tryInsertToOutputSlots(remaining);
}
if (remaining == null || remaining.stackSize == 0) {
toRemove.add(stack);
} else {
stack.stackSize = remaining.stackSize;
}
}
harvestBuffer.removeAll(toRemove);
if (!toRemove.isEmpty()) {
markDirty();
}
}
@Override
@@ -445,9 +480,18 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
setNotification("noPower");
return false;
}
if (isBufferNotEmpty() || isOutputFull()) {
setNotification("outputFull");
return false;
}
return true;
}
private boolean isBufferNotEmpty() {
return !harvestBuffer.isEmpty();
}
protected void doTick() {
if (sendNotification && shouldDoWorkThisTick(TICKS_PER_WORK)) {
@@ -488,7 +532,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
block = worldObj.getBlock(bc.x, bc.y, bc.z);
}
if (isOutputFull()) {
if (isOutputFull() || isBufferNotEmpty()) {
setNotification("outputFull");
return;
}
@@ -507,10 +551,8 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
new TargetPoint(worldObj.provider.dimensionId, bc.x, bc.y, bc.z, Config.farmParticlesMaxRange));
for (EntityItem ei : harvest.getDrops()) {
if (ei != null) {
insertHarvestDrop(ei, bc);
if (!ei.isDead) {
worldObj.spawnEntityInWorld(ei);
}
addToBuffer(ei.getEntityItem().copy());
ei.setDead();
}
}
return;
@@ -552,6 +594,99 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
}
}
private void addToBuffer(ItemStack stack) {
if (stack == null || stack.stackSize <= 0) {
return;
}
for (ItemStack bufStack : harvestBuffer) {
if (bufStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(bufStack, stack)) {
int canAdd = bufStack.stackSize;
if (canAdd > 0) {
int addAmount = Math.min(canAdd, stack.stackSize);
bufStack.stackSize += addAmount;
stack.stackSize -= addAmount;
if (stack.stackSize <= 0) {
markDirty();
return;
}
}
}
}
harvestBuffer.add(stack.copy());
markDirty();
}
private ItemStack tryInsertToInputSlots(ItemStack stack) {
if (stack == null || stack.stackSize <= 0) {
return null;
}
for (int i = minSupSlot; i <= maxSupSlot; i++) {
if (stack.stackSize <= 0) {
break;
}
ItemStack slotStack = inventory[i];
int stackLimit = getInventoryStackLimit(i);
if (isItemValidForSlot(i, stack)) {
if (slotStack == null) {
if (!isSlotLocked(i)) {
int amount = Math.min(stack.stackSize, stackLimit);
inventory[i] = stack.copy();
inventory[i].stackSize = amount;
stack.stackSize -= amount;
markDirty();
}
} else if (slotStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(slotStack, stack)) {
int canAdd = Math.min(stackLimit - slotStack.stackSize, stack.stackSize);
if (canAdd > 0) {
slotStack.stackSize += canAdd;
stack.stackSize -= canAdd;
markDirty();
}
}
}
}
return stack.stackSize > 0 ? stack : null;
}
private ItemStack tryInsertToOutputSlots(ItemStack stack) {
if (stack == null || stack.stackSize <= 0) {
return null;
}
for (int i = slotDefinition.minOutputSlot; i <= slotDefinition.maxOutputSlot; i++) {
if (stack.stackSize <= 0) {
break;
}
ItemStack slotStack = inventory[i];
int stackLimit = 64;
if (slotStack == null) {
int amount = Math.min(stack.stackSize, stackLimit);
inventory[i] = stack.copy();
inventory[i].stackSize = amount;
stack.stackSize -= amount;
markDirty();
} else if (slotStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(slotStack, stack)) {
int canAdd = Math.min(stackLimit - slotStack.stackSize, stack.stackSize);
if (canAdd > 0) {
slotStack.stackSize += canAdd;
stack.stackSize -= canAdd;
markDirty();
}
}
}
return stack.stackSize > 0 ? stack : null;
}
private int bonemealCooldown = 5; // no need to persist this
private boolean hasBonemeal() {
@@ -652,68 +787,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
return minSupSlot + 3;
}
private void insertHarvestDrop(Entity entity, BlockCoord bc) {
if (!worldObj.isRemote) {
if (entity instanceof EntityItem && !entity.isDead) {
EntityItem item = (EntityItem) entity;
ItemStack stack = item.getEntityItem().copy();
int numInserted = insertResult(stack, bc);
stack.stackSize -= numInserted;
item.setEntityItemStack(stack);
if (stack.stackSize == 0) {
item.setDead();
}
}
}
}
private int insertResult(ItemStack stack, BlockCoord bc) {
int slot = bc != null ? getSupplySlotForCoord(bc) : minSupSlot;
int[] slots = new int[NUM_SUPPLY_SLOTS];
int k = 0;
for (int j = slot; j <= maxSupSlot; j++) {
slots[k++] = j;
}
for (int j = minSupSlot; j < slot; j++) {
slots[k++] = j;
}
int origSize = stack.stackSize;
stack = stack.copy();
int inserted = 0;
for (int j = 0; j < slots.length && inserted < stack.stackSize; j++) {
int i = slots[j];
ItemStack curStack = inventory[i];
int inventoryStackLimit = getInventoryStackLimit(i);
if (isItemValidForSlot(i, stack) && (curStack == null || curStack.stackSize < inventoryStackLimit)) {
if (curStack == null) {
if (stack.stackSize < inventoryStackLimit) {
inventory[i] = stack.copy();
inserted = stack.stackSize;
} else {
inventory[i] = stack.copy();
inserted = inventoryStackLimit;
inventory[i].stackSize = inserted;
}
} else if (curStack.isItemEqual(stack)) {
inserted = Math.min(inventoryStackLimit - curStack.stackSize, stack.stackSize);
inventory[i].stackSize += inserted;
}
}
}
stack.stackSize -= inserted;
if (inserted >= origSize) {
return origSize;
}
ResultStack[] in = new ResultStack[] { new ResultStack(stack) };
mergeResults(in);
return origSize - (in[0].item == null ? 0 : in[0].item.stackSize);
}
private @Nonnull BlockCoord getNextCoord() {
int size = getFarmSize();
@@ -752,11 +825,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
return EnderIO.blockFarmStation.getLocalizedName();
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public String getMachineName() {
return ModObject.blockFarmStation.unlocalisedName;
@@ -811,6 +879,17 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
} else if (slotLayoutVersion == 2) {
inventory = (new ArrayMappingTool<ItemStack>("TTTSSSSOOOOOOC", "TTTBBSSSSOOOOOOC")).map(inventory);
}
if (nbtRoot.hasKey("HarvestBuffer")) {
NBTTagList bufferList = nbtRoot.getTagList("HarvestBuffer", 10);
for (int i = 0; i < bufferList.tagCount(); i++) {
NBTTagCompound itemTag = bufferList.getCompoundTagAt(i);
ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag);
if (stack != null && stack.stackSize > 0) {
harvestBuffer.add(stack);
}
}
}
}
IPoweredTask createTask() {
@@ -834,6 +913,18 @@ public class TileFarmStation extends AbstractPoweredTaskEntity implements IRange
nbtRoot.setIntArray("lockedSlots", locked);
}
nbtRoot.setInteger("slotLayoutVersion", 3);
if (!harvestBuffer.isEmpty()) {
NBTTagList bufferList = new NBTTagList();
for (ItemStack stack : harvestBuffer) {
if (stack != null && stack.stackSize > 0) {
NBTTagCompound itemTag = new NBTTagCompound();
stack.writeToNBT(itemTag);
bufferList.appendTag(itemTag);
}
}
nbtRoot.setTag("HarvestBuffer", bufferList);
}
}
@Override
@@ -17,7 +17,9 @@ import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.common.util.BlockCoord;
import com.mitchej123.hodgepodge.mixins.interfaces.INetherSeed;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.farm.TileFarmStation;
public class PlantableFarmer implements IFarmerJoe {
@@ -109,7 +111,13 @@ public class PlantableFarmer implements IFarmerJoe {
protected boolean plant(TileFarmStation farm, World worldObj, BlockCoord bc, IPlantable plantable) {
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
Block target = plantable.getPlant(null, 0, 0, 0);
Block target;
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
target = netherSeed.hodgepodge$getPlant(null, 0, 0, 0);
} else {
target = plantable.getPlant(null, 0, 0, 0);
}
int meta = plantable.getPlantMetadata(null, 0, 0, 0);
worldObj.setBlock(bc.x, bc.y, bc.z, target, meta, 1 | 2);
farm.actionPerformed(false);
@@ -117,7 +125,13 @@ public class PlantableFarmer implements IFarmerJoe {
}
protected boolean canPlant(World worldObj, BlockCoord bc, IPlantable plantable) {
Block target = plantable.getPlant(null, 0, 0, 0);
Block target;
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
target = netherSeed.hodgepodge$getPlant(null, 0, 0, 0);
} else {
target = plantable.getPlant(null, 0, 0, 0);
}
Block ground = worldObj.getBlock(bc.x, bc.y - 1, bc.z);
if (target != null && target.canPlaceBlockAt(worldObj, bc.x, bc.y, bc.z)
&& target.canBlockStay(worldObj, bc.x, bc.y, bc.z)
@@ -182,10 +196,14 @@ public class PlantableFarmer implements IFarmerJoe {
}
private boolean isPlantableForBlock(ItemStack stack, Block block) {
if (!(stack.getItem() instanceof IPlantable)) {
return false;
if (stack.getItem() instanceof IPlantable plantable) {
// needed for Pam's nether seeds
if (EnderIO.hasHP && plantable instanceof INetherSeed netherSeed) {
return netherSeed.hodgepodge$getPlant(null, 0, 0, 0) == block;
} else {
return plantable.getPlant(null, 0, 0, 0) == block;
}
}
IPlantable plantable = (IPlantable) stack.getItem();
return plantable.getPlant(null, 0, 0, 0) == block;
return false;
}
}
@@ -12,6 +12,7 @@ import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.enderio.network.PacketHandler;
import crazypants.util.ForgeDirections;
public class BlockStirlingGenerator extends AbstractMachineBlock<TileEntityStirlingGenerator> {
@@ -59,7 +60,7 @@ public class BlockStirlingGenerator extends AbstractMachineBlock<TileEntityStirl
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
TileEntityStirlingGenerator te = (TileEntityStirlingGenerator) world.getTileEntity(x, y, z);
if (te != null && te.isActive()) {
ForgeDirection front = ForgeDirection.values()[te.facing];
ForgeDirection front = ForgeDirections.DIRECTIONS[te.facing];
for (int i = 0; i < 2; i++) {
double px = x + 0.5 + front.offsetX * 0.6;
@@ -159,10 +159,13 @@ public class BlockZombieGenerator extends AbstractMachineBlock<TileZombieGenerat
@Override
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileZombieGenerator) {
if (EnderIO.hasWailaPlugins) {
return;
}
if (world.getTileEntity(x, y, z) instanceof TileZombieGenerator generator) {
tooltip.add(
((TileZombieGenerator) te).getFluidStored(ForgeDirection.UNKNOWN) + " "
generator.getFluidStored(ForgeDirection.UNKNOWN) + " "
+ EnderIO.lang.localize("fluid.millibucket.abr"));
}
}
@@ -23,6 +23,7 @@ import com.enderio.core.common.vecmath.Vector3d;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.util.ForgeDirections;
import crazypants.util.RenderPassHelper;
@SideOnly(Side.CLIENT)
@@ -64,7 +65,7 @@ public class ZombieGeneratorRenderer extends TileEntitySpecialRenderer implement
Tessellator tes = Tessellator.instance;
tes.startDrawingQuads();
ForgeDirection facingDir = ForgeDirection.values()[gen.facing];
ForgeDirection facingDir = ForgeDirections.DIRECTIONS[gen.facing];
double facingOffset = 0.075;
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.96, 0.85);
@@ -28,9 +28,7 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
.registerMessage(PacketSwing.class, PacketSwing.class, PacketHandler.nextID(), Side.CLIENT);
PacketGivePlayerXP.register();
PacketExperianceContainer.register();
BlockKillerJoe res = new BlockKillerJoe();
MinecraftForge.EVENT_BUS.register(res);
res.init();
return res;
}
@@ -40,19 +38,18 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
setStepSound(Block.soundTypeGlass);
}
@Override
protected void init() {
super.init();
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX,
double explosionY, double explosionZ) {
return 2000;
}
@SubscribeEvent
public void getKillDisplayName(PlayerEvent.NameFormat nameEvt) {
if (nameEvt.username != null && nameEvt.username.startsWith(USERNAME)) {
nameEvt.displayname = getLocalizedName();
}
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerKillerJoe(player.inventory, (TileKillerJoe) world.getTileEntity(x, y, z));
@@ -101,4 +98,14 @@ public class BlockKillerJoe extends AbstractMachineBlock<TileKillerJoe> {
return 5;
}
}
public class EventHandler {
@SubscribeEvent
public void getKillDisplayName(PlayerEvent.NameFormat nameEvt) {
if (nameEvt.username != null && nameEvt.username.startsWith(USERNAME)) {
nameEvt.displayname = getLocalizedName();
}
}
}
}
@@ -26,6 +26,7 @@ import com.enderio.core.common.vecmath.Vector3d;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.machine.generator.zombie.ModelZombieJar;
import crazypants.util.ForgeDirections;
@SideOnly(Side.CLIENT)
public class KillerJoeRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
@@ -130,7 +131,7 @@ public class KillerJoeRenderer extends TileEntitySpecialRenderer implements IIte
bb = bb.scale(1, 0.85 * fullness, 1);
float ty = -(0.85f - (bb.maxY - bb.minY)) / 2;
Vector3d offset = ForgeDirectionOffsets.offsetScaled(ForgeDirection.values()[gen.facing], -0.075);
Vector3d offset = ForgeDirectionOffsets.offsetScaled(ForgeDirections.DIRECTIONS[gen.facing], -0.075);
bb = bb.translate((float) offset.x, ty, (float) offset.z);
int brightness;
@@ -18,6 +18,7 @@ import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.util.ForgeDirections;
public class BlockItemElectricLight extends ItemBlockWithMetadata implements IResourceTooltipProvider {
@@ -70,7 +71,7 @@ public class BlockItemElectricLight extends ItemBlockWithMetadata implements IRe
return false;
}
if (world.getBlock(x, y, z) == field_150939_a) {
ForgeDirection onFace = ForgeDirection.values()[side].getOpposite();
ForgeDirection onFace = ForgeDirections.DIRECTIONS[side].getOpposite();
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileElectricLight) {
TileElectricLight el = ((TileElectricLight) te);
@@ -22,6 +22,7 @@ import crazypants.enderio.machine.wireless.WirelessChargedLocation;
import crazypants.enderio.power.Capacitors;
import crazypants.enderio.power.IInternalPowerReceiver;
import crazypants.enderio.power.PowerHandlerUtil;
import crazypants.util.ForgeDirections;
public class TileElectricLight extends TileEntityEio implements IInternalPowerReceiver {
@@ -334,7 +335,7 @@ public class TileElectricLight extends TileEntityEio implements IInternalPowerRe
@Override
public void readCustomNBT(NBTTagCompound root) {
face = ForgeDirection.values()[root.getShort("face")];
face = ForgeDirections.DIRECTIONS[root.getShort("face")];
isInvereted = root.getBoolean("isInverted");
requiresPower = root.getBoolean("requiresPower");
setWireless(root.getBoolean("isWireless"));
@@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import com.enderio.core.common.util.DyeColor;
@@ -14,6 +13,7 @@ import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.enderio.machine.ContainerNoInv;
import crazypants.enderio.network.PacketHandler;
import crazypants.util.ForgeDirections;
public class BlockPowerMonitor extends AbstractMachineBlock<TilePowerMonitor> {
@@ -74,7 +74,8 @@ public class BlockPowerMonitor extends AbstractMachineBlock<TilePowerMonitor> {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TilePowerMonitor) {
return ((TilePowerMonitor) te).getRednetOutputValue(ForgeDirection.values()[side], DyeColor.RED.ordinal());
return ((TilePowerMonitor) te)
.getRednetOutputValue(ForgeDirections.DIRECTIONS[side], DyeColor.RED.ordinal());
}
return 0;
}
@@ -53,8 +53,8 @@ public class TilePowerMonitor extends AbstractPowerConsumerEntity implements IIn
if (currentlyEmmittedSignal == null) {
return new int[16];
}
int[] res = new int[DyeColor.values().length];
for (DyeColor col : DyeColor.values()) {
int[] res = new int[DyeColor.VALUES.length];
for (DyeColor col : DyeColor.VALUES) {
res[col.ordinal()] = currentlyEmmittedSignal.color == col ? 15 : 0;
}
return res;
@@ -25,7 +25,6 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
public static BlockInhibitorObelisk create() {
BlockInhibitorObelisk res = new BlockInhibitorObelisk();
res.init();
MinecraftForge.EVENT_BUS.register(res);
return instance = res;
}
@@ -33,6 +32,12 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
super(ModObject.blockInhibitorObelisk, TileInhibitorObelisk.class);
}
@Override
protected void init() {
super.init();
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return ID == getGuiId()
@@ -58,15 +63,18 @@ public class BlockInhibitorObelisk extends BlockObeliskAbstract<TileInhibitorObe
public Map<BlockCoord, Float> activeInhibitors = Maps.newHashMap();
@SubscribeEvent
public void onTeleport(TeleportEntityEvent event) {
for (Entry<BlockCoord, Float> e : activeInhibitors.entrySet()) {
BlockCoord bc = e.getKey();
int dist = bc.getDist(new BlockCoord(event.targetX, event.targetY, event.targetZ));
if (dist < e.getValue()) {
TileEntity te = bc.getTileEntity(event.entity.worldObj);
if (te instanceof TileInhibitorObelisk && ((TileInhibitorObelisk) te).isActive()) {
event.setCanceled(true);
public class EventHandler {
@SubscribeEvent
public void onTeleport(TeleportEntityEvent event) {
for (Entry<BlockCoord, Float> e : activeInhibitors.entrySet()) {
BlockCoord bc = e.getKey();
int dist = bc.getDist(new BlockCoord(event.targetX, event.targetY, event.targetZ));
if (dist < e.getValue()) {
TileEntity te = bc.getTileEntity(event.entity.worldObj);
if (te instanceof TileInhibitorObelisk && ((TileInhibitorObelisk) te).isActive()) {
event.setCanceled(true);
}
}
}
}
@@ -199,7 +199,7 @@ public class BlockPaintedGlowstone extends BlockEio
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister IIconRegister) {
blockIcon = IIconRegister.registerIcon("enderio:conduitConnector");
blockIcon = IIconRegister.registerIcon("glowstone");
}
@Override
@@ -231,10 +231,12 @@ public class BlockPaintedGlowstone extends BlockEio
@Override
protected void processDrop(World world, int x, int y, int z, TileEntityEnder te, ItemStack drop) {
TileEntityPaintedBlock tef = (TileEntityPaintedBlock) te;
if (tef != null) {
if (te instanceof TileEntityPaintedBlock tef) {
ItemStack itemStack = createItemStackForSourceBlock(tef.getSourceBlock(), tef.getSourceBlockMetadata());
drop.stackTagCompound = (NBTTagCompound) itemStack.stackTagCompound.copy();
NBTTagCompound tag = itemStack.stackTagCompound;
if (tag != null) {
drop.stackTagCompound = (NBTTagCompound) tag.copy();
}
}
}
@@ -63,7 +63,8 @@ public final class PainterUtil {
sourceName = is.getDisplayName();
}
}
return EnderIO.lang.localize("blockPainter.paintedWith") + " " + sourceName;
return EnderIO.lang.localize("blockPainter.paintedWith") + " "
+ (sourceName.isEmpty() ? EnderIO.lang.localize("blockPainter.paintedWith.none") : sourceName);
}
public static void setSourceBlock(ItemStack item, Block source, int meta) {
@@ -58,7 +58,7 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
}
}
static final FluidStack WATER_BUCKET = FluidRegistry.getFluidStack("water", BUCKET_VOLUME);
static final FluidStack WATER_BUCKET = new FluidStack(FluidRegistry.WATER, BUCKET_VOLUME);
BlockCoord[] multiblock = null;
@@ -156,7 +156,7 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
if (tank.getFluid() == null) {
return true;
}
if (fluid != null && fluid.getID() == tank.getFluid().getFluidID()) {
if (fluid != null && fluid == tank.getFluid().getFluid()) {
return true;
}
return false;
@@ -167,7 +167,7 @@ public class TileReservoir extends TileEntityEio implements IFluidHandler, ITank
if (tank.getFluid() == null || fluid == null) {
return false;
}
return tank.getFluid().getFluid().getID() == fluid.getID();
return tank.getFluid().getFluid() == fluid;
}
@Override
@@ -14,6 +14,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.util.ForgeDirections;
public class BlockSliceAndSplice extends AbstractMachineBlock<TileSliceAndSplice> {
@@ -84,7 +85,7 @@ public class BlockSliceAndSplice extends AbstractMachineBlock<TileSliceAndSplice
TileSliceAndSplice te = (TileSliceAndSplice) world.getTileEntity(x, y, z);
if (isActive(world, x, y, z) && te != null) {
ForgeDirection front = ForgeDirection.values()[te.facing];
ForgeDirection front = ForgeDirections.DIRECTIONS[te.facing];
for (int i = 0; i < 2; i++) {
double px = x + 0.5 + front.offsetX * 0.6;
@@ -19,6 +19,7 @@ import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import crazypants.enderio.ClientProxy;
import crazypants.enderio.EnderIO;
import crazypants.util.ForgeDirections;
@ThreadSafeISBRH(perThread = true)
public class SoulBinderRenderer implements ISimpleBlockRenderingHandler {
@@ -97,7 +98,7 @@ public class SoulBinderRenderer implements ISimpleBlockRenderingHandler {
}
private ForgeDirection forFacing(ForgeDirection side, int facing) {
return ForgeDirection.values()[ClientProxy.sideAndFacingToSpriteOffset[side.ordinal()][facing]];
return ForgeDirections.DIRECTIONS[ClientProxy.sideAndFacingToSpriteOffset[side.ordinal()][facing]];
}
private void renderSkull(ForgeDirection face, IIcon soulariumIcon, IIcon faceIcon) {
@@ -89,8 +89,6 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
PoweredSpawnerConfig.getInstance();
BlockPoweredSpawner res = new BlockPoweredSpawner();
MinecraftForge.EVENT_BUS.register(res);
FMLCommonHandler.instance().bus().register(res);
res.init();
return res;
}
@@ -115,144 +113,16 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
}
}
@Override
protected void init() {
super.init();
EventHandler handler = new EventHandler();
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(handler);
}
private final Map<BlockCoord, ItemStack> dropCache = new HashMap<BlockCoord, ItemStack>();
@SubscribeEvent
public void onBreakEvent(BlockEvent.BreakEvent evt) {
if (evt.block instanceof BlockMobSpawner) {
if (evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode
&& !evt.getPlayer().worldObj.isRemote
&& !evt.isCanceled()) {
TileEntity tile = evt.getPlayer().worldObj.getTileEntity(evt.x, evt.y, evt.z);
if (tile instanceof TileEntityMobSpawner) {
if (Math.random() > Config.brokenSpawnerDropChance) {
return;
}
ItemStack equipped = evt.getPlayer().getCurrentEquippedItem();
if (equipped != null) {
for (UniqueIdentifier uid : toolBlackList) {
Item blackListItem = GameRegistry.findItem(uid.modId, uid.name);
if (blackListItem == equipped.getItem()) {
return;
}
}
}
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile;
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), drop);
for (int i = (int) (Math.random() * 7); i > 0; i--) {
logic.spawnDelay = 0;
logic.updateSpawner();
}
}
}
}
} else {
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), null);
}
}
}
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
if (!evt.isCanceled() && evt.block instanceof BlockMobSpawner) {
BlockCoord bc = new BlockCoord(evt.x, evt.y, evt.z);
if (dropCache.containsKey(bc)) {
ItemStack stack = dropCache.get(bc);
if (stack != null) {
evt.drops.add(stack);
}
} else {
// A spawner was broken---but not by a player. The TE has been
// invalidated already, but we might be able to recover it.
try {
for (Object object : evt.world.loadedTileEntityList) {
if (object instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
if (spawner.getWorldObj() == evt.world && spawner.xCoord == evt.x
&& spawner.yCoord == evt.y
&& spawner.zCoord == evt.z) {
// Bingo!
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
evt.drops.add(ItemBrokenSpawner.createStackForMobType(name));
}
}
}
}
}
} catch (Exception e) {
// Risky recovery failed. Happens.
}
}
}
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dropCache.clear();
}
}
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
if (evt.left == null || evt.left.stackSize != 1
|| evt.left.getItem() != Item.getItemFromBlock(EnderIO.blockPoweredSpawner)
|| evt.right == null
|| ItemBrokenSpawner.getMobTypeFromStack(evt.right) == null) {
return;
}
String spawnerType = ItemBrokenSpawner.getMobTypeFromStack(evt.right);
if (isBlackListed(spawnerType)) {
return;
}
evt.cost = Config.powerSpawnerAddSpawnerCost;
evt.output = evt.left.copy();
if (evt.output.stackTagCompound == null) {
evt.output.stackTagCompound = new NBTTagCompound();
}
evt.output.stackTagCompound.setBoolean("eio.abstractMachine", true);
writeMobTypeToNBT(evt.output.stackTagCompound, spawnerType);
}
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent livingUpdate) {
Entity ent = livingUpdate.entityLiving;
if (!ent.getEntityData().hasKey(KEY_SPAWNED_BY_POWERED_SPAWNER)) {
return;
}
if (fieldpersistenceRequired == null) {
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
return;
}
long spawnTime = ent.getEntityData().getLong(KEY_SPAWNED_BY_POWERED_SPAWNER);
long livedFor = livingUpdate.entity.worldObj.getTotalWorldTime() - spawnTime;
if (livedFor > Config.poweredSpawnerDespawnTimeSeconds * 20) {
try {
fieldpersistenceRequired.setBoolean(livingUpdate.entityLiving, false);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
} catch (Exception e) {
Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
}
}
}
public boolean isBlackListed(String entityId) {
return PoweredSpawnerConfig.getInstance().isBlackListed(entityId);
}
@@ -362,4 +232,144 @@ public class BlockPoweredSpawner extends AbstractMachineBlock<TilePoweredSpawner
Util.dropItems(evt.getPlayer().worldObj, drop, evt.x, evt.y, evt.z, true);
}
}
public class EventHandler {
@SubscribeEvent
public void onBreakEvent(BlockEvent.BreakEvent evt) {
if (evt.block instanceof BlockMobSpawner) {
if (evt.getPlayer() != null && !evt.getPlayer().capabilities.isCreativeMode
&& !evt.getPlayer().worldObj.isRemote
&& !evt.isCanceled()) {
TileEntity tile = evt.getPlayer().worldObj.getTileEntity(evt.x, evt.y, evt.z);
if (tile instanceof TileEntityMobSpawner) {
if (Math.random() > Config.brokenSpawnerDropChance) {
return;
}
ItemStack equipped = evt.getPlayer().getCurrentEquippedItem();
if (equipped != null) {
for (UniqueIdentifier uid : toolBlackList) {
Item blackListItem = GameRegistry.findItem(uid.modId, uid.name);
if (blackListItem == equipped.getItem()) {
return;
}
}
}
TileEntityMobSpawner spawner = (TileEntityMobSpawner) tile;
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
ItemStack drop = ItemBrokenSpawner.createStackForMobType(name);
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), drop);
for (int i = (int) (Math.random() * 7); i > 0; i--) {
logic.spawnDelay = 0;
logic.updateSpawner();
}
}
}
}
} else {
dropCache.put(new BlockCoord(evt.x, evt.y, evt.z), null);
}
}
}
@SubscribeEvent
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent evt) {
if (!evt.isCanceled() && evt.block instanceof BlockMobSpawner) {
BlockCoord bc = new BlockCoord(evt.x, evt.y, evt.z);
if (dropCache.containsKey(bc)) {
ItemStack stack = dropCache.get(bc);
if (stack != null) {
evt.drops.add(stack);
}
} else {
// A spawner was broken---but not by a player. The TE has been
// invalidated already, but we might be able to recover it.
try {
for (Object object : evt.world.loadedTileEntityList) {
if (object instanceof TileEntityMobSpawner) {
TileEntityMobSpawner spawner = (TileEntityMobSpawner) object;
if (spawner.getWorldObj() == evt.world && spawner.xCoord == evt.x
&& spawner.yCoord == evt.y
&& spawner.zCoord == evt.z) {
// Bingo!
MobSpawnerBaseLogic logic = spawner.func_145881_a();
if (logic != null) {
String name = logic.getEntityNameToSpawn();
if (name != null && !isBlackListed(name)) {
evt.drops.add(ItemBrokenSpawner.createStackForMobType(name));
}
}
}
}
}
} catch (Exception e) {
// Risky recovery failed. Happens.
}
}
}
}
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
dropCache.clear();
}
}
@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
if (evt.left == null || evt.left.stackSize != 1
|| evt.left.getItem() != Item.getItemFromBlock(EnderIO.blockPoweredSpawner)
|| evt.right == null
|| ItemBrokenSpawner.getMobTypeFromStack(evt.right) == null) {
return;
}
String spawnerType = ItemBrokenSpawner.getMobTypeFromStack(evt.right);
if (isBlackListed(spawnerType)) {
return;
}
evt.cost = Config.powerSpawnerAddSpawnerCost;
evt.output = evt.left.copy();
if (evt.output.stackTagCompound == null) {
evt.output.stackTagCompound = new NBTTagCompound();
}
evt.output.stackTagCompound.setBoolean("eio.abstractMachine", true);
writeMobTypeToNBT(evt.output.stackTagCompound, spawnerType);
}
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent livingUpdate) {
Entity ent = livingUpdate.entityLiving;
if (!ent.getEntityData().hasKey(KEY_SPAWNED_BY_POWERED_SPAWNER)) {
return;
}
if (fieldpersistenceRequired == null) {
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
return;
}
long spawnTime = ent.getEntityData().getLong(KEY_SPAWNED_BY_POWERED_SPAWNER);
long livedFor = livingUpdate.entity.worldObj.getTotalWorldTime() - spawnTime;
if (livedFor > Config.poweredSpawnerDespawnTimeSeconds * 20) {
try {
fieldpersistenceRequired.setBoolean(livingUpdate.entityLiving, false);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
} catch (Exception e) {
Log.warn("BlockPoweredSpawner.onLivingUpdate: Error occured allowing entity to despawn: " + e);
ent.getEntityData().removeTag(KEY_SPAWNED_BY_POWERED_SPAWNER);
}
}
}
}
}
@@ -187,6 +187,10 @@ public class BlockTank extends AbstractMachineBlock<TileTank> implements IAdvanc
@Override
@SideOnly(Side.CLIENT)
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag) {
if (EnderIO.hasWailaPlugins) {
return;
}
if (itemstack.stackTagCompound != null && itemstack.stackTagCompound.hasKey("tankContents")) {
FluidStack fl = FluidStack
.loadFluidStackFromNBT((NBTTagCompound) itemstack.stackTagCompound.getTag("tankContents"));
@@ -219,9 +223,11 @@ public class BlockTank extends AbstractMachineBlock<TileTank> implements IAdvanc
@Override
public void getWailaInfo(List<String> tooltip, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileTank) {
TileTank tank = (TileTank) te;
if (EnderIO.hasWailaPlugins) {
return;
}
if (world.getTileEntity(x, y, z) instanceof TileTank tank) {
FluidStack stored = tank.tank.getFluid();
String fluid = stored == null ? EnderIO.lang.localize("tooltip.none")
: stored.getFluid().getLocalizedName(stored);
@@ -6,6 +6,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyContainerItem;
import crazypants.enderio.EnderIO;
import crazypants.enderio.TileEntityEio;
import crazypants.enderio.network.PacketHandler;
import crazypants.enderio.power.IInternalPowerReceiver;
@@ -28,7 +29,12 @@ public class TileWirelessCharger extends TileEntityEio implements IInternalPower
@Override
public void invalidate() {
super.invalidate();
WirelessChargerController.instance.deregisterCharger(this);
if (worldObj.isRemote) {
return;
}
EnderIO.proxy.wirelessChargerController.deregisterCharger(this);
registered = false;
}
@@ -40,7 +46,7 @@ public class TileWirelessCharger extends TileEntityEio implements IInternalPower
}
if (!registered) {
WirelessChargerController.instance.registerCharger(this);
EnderIO.proxy.wirelessChargerController.registerCharger(this);
registered = true;
}
@@ -1,8 +1,6 @@
package crazypants.enderio.machine.wireless;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import net.minecraft.item.ItemStack;
@@ -10,6 +8,8 @@ import net.minecraft.tileentity.TileEntity;
import com.enderio.core.common.util.BlockCoord;
import crazypants.enderio.EnderIO;
public class WirelessChargedLocation {
private final TileEntity te;
@@ -18,34 +18,30 @@ public class WirelessChargedLocation {
public WirelessChargedLocation(TileEntity te) {
this.te = te;
this.chargers = new ArrayList<IWirelessCharger>();
this.chargers = new ArrayList<>();
/*
* Set lastChangeCount to one less than the current change count so that the charger list is updated on first
* use (unless ~4B changes happen in between). Do this instead directly updating so that WirelessChargedLocation
* can be used while the TileEntity is still in construction (or loading).
*/
this.lastChangeCount = WirelessChargerController.instance.getChangeCount() - 1;
this.lastChangeCount = EnderIO.proxy.wirelessChargerController.getChangeCount() - 1;
}
private void updateChargers() {
WirelessChargerController wcc = WirelessChargerController.instance;
WirelessChargerController wcc = EnderIO.proxy.wirelessChargerController;
chargers.clear();
lastChangeCount = wcc.getChangeCount();
final BlockCoord bc = new BlockCoord(te);
wcc.getChargers(te.getWorldObj(), bc, chargers);
Collections.sort(chargers, new Comparator<IWirelessCharger>() {
@Override
public int compare(IWirelessCharger o1, IWirelessCharger o2) {
int dist1 = o1.getLocation().getDistSq(bc);
int dist2 = o2.getLocation().getDistSq(bc);
return dist1 - dist2;
}
chargers.sort((o1, o2) -> {
int dist1 = o1.getLocation().getDistSq(bc);
int dist2 = o2.getLocation().getDistSq(bc);
return dist1 - dist2;
});
}
private void checkChangeCount() {
if (lastChangeCount != WirelessChargerController.instance.getChangeCount()) {
if (lastChangeCount != EnderIO.proxy.wirelessChargerController.getChangeCount()) {
updateChargers();
}
}
@@ -8,11 +8,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import com.enderio.core.common.util.BlockCoord;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
@@ -21,20 +19,17 @@ import crazypants.util.BaublesUtil;
public class WirelessChargerController {
public static WirelessChargerController instance = new WirelessChargerController();
public static final int RANGE = Config.wirelessChargerRange;
public static final int RANGE_SQ = RANGE * RANGE;
static {
FMLCommonHandler.instance().bus().register(WirelessChargerController.instance);
MinecraftForge.EVENT_BUS.register(WirelessChargerController.instance);
}
private static final int RANGE = Config.wirelessChargerRange;
private static final int RANGE_SQ = RANGE * RANGE;
private final Map<Integer, Map<BlockCoord, IWirelessCharger>> perWorldChargers = new HashMap<Integer, Map<BlockCoord, IWirelessCharger>>();
private int changeCount;
private WirelessChargerController() {}
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.side != Side.CLIENT && event.phase == TickEvent.Phase.END) {
chargePlayersItems(event.player);
}
}
public void registerCharger(IWirelessCharger charger) {
if (charger == null) {
@@ -54,28 +49,7 @@ public class WirelessChargerController {
changeCount++;
}
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.side == Side.CLIENT || event.phase != TickEvent.Phase.END) {
return;
}
chargePlayersItems(event.player);
}
public int getChangeCount() {
return changeCount;
}
public void getChargers(World world, BlockCoord bc, Collection<IWirelessCharger> res) {
Map<BlockCoord, IWirelessCharger> chargers = getChargersForWorld(world);
for (IWirelessCharger wc : chargers.values()) {
if (wc.getLocation().getDistSq(bc) <= RANGE_SQ) {
res.add(wc);
}
}
}
public void chargePlayersItems(EntityPlayer player) {
private void chargePlayersItems(EntityPlayer player) {
Map<BlockCoord, IWirelessCharger> chargers = getChargersForWorld(player.worldObj);
if (chargers.isEmpty()) {
return;
@@ -108,13 +82,21 @@ public class WirelessChargerController {
return res;
}
private Map<BlockCoord, IWirelessCharger> getChargersForWorld(World world) {
Map<BlockCoord, IWirelessCharger> res = perWorldChargers.get(world.provider.dimensionId);
if (res == null) {
res = new HashMap<BlockCoord, IWirelessCharger>();
perWorldChargers.put(world.provider.dimensionId, res);
public int getChangeCount() {
return changeCount;
}
public void getChargers(World world, BlockCoord bc, Collection<IWirelessCharger> res) {
Map<BlockCoord, IWirelessCharger> chargers = getChargersForWorld(world);
for (IWirelessCharger wc : chargers.values()) {
if (wc.getLocation().getDistSq(bc) <= RANGE_SQ) {
res.add(wc);
}
}
return res;
}
private Map<BlockCoord, IWirelessCharger> getChargersForWorld(World world) {
return perWorldChargers.computeIfAbsent(world.provider.dimensionId, k -> new HashMap<>());
}
public Collection<IWirelessCharger> getChargers(World world) {
@@ -21,13 +21,17 @@ public enum Alloy {
SOULARIUM("soularium", 10.0f),
END_STEEL("endSteel", 10.0f);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final Alloy[] VALUES = values();
public final String unlocalisedName;
public final String iconKey;
private final List<String> oreIngots = new ArrayList<String>();
private final List<String> oreBlocks = new ArrayList<String>();
private final float hardness;
private Alloy(String baseName, float hardness, String oreDictName) {
Alloy(String baseName, float hardness, String oreDictName) {
this.unlocalisedName = "enderio." + baseName;
this.iconKey = "enderio:" + baseName;
if (oreDictName != null) {
@@ -40,7 +44,7 @@ public enum Alloy {
this.hardness = hardness;
}
private Alloy(String baseName, float hardness) {
Alloy(String baseName, float hardness) {
this(baseName, hardness, null);
}
@@ -45,8 +45,8 @@ public class BlockIngotStorage extends BlockEio implements IAdvancedTooltipProvi
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
icons = new IIcon[Alloy.values().length];
for (Alloy alloy : Alloy.values()) {
icons = new IIcon[Alloy.VALUES.length];
for (Alloy alloy : Alloy.VALUES) {
icons[alloy.ordinal()] = register.registerIcon(alloy.iconKey + "Block");
}
}
@@ -54,7 +54,7 @@ public class BlockIngotStorage extends BlockEio implements IAdvancedTooltipProvi
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
meta = MathHelper.clamp_int(meta, 0, Alloy.values().length - 1);
meta = MathHelper.clamp_int(meta, 0, Alloy.VALUES.length - 1);
return icons[meta];
}
@@ -70,7 +70,7 @@ public class BlockIngotStorage extends BlockEio implements IAdvancedTooltipProvi
@Override
public float getBlockHardness(World world, int x, int y, int z) {
return Alloy.values()[world.getBlockMetadata(x, y, z)].getHardness();
return Alloy.VALUES[world.getBlockMetadata(x, y, z)].getHardness();
}
@Override
@@ -21,7 +21,7 @@ public class BlockItemIngotStorage extends ItemBlock {
@Override
public String getUnlocalizedName(ItemStack stack) {
return "tile." + Alloy.values()[stack.getItemDamage()].unlocalisedName;
return "tile." + Alloy.VALUES[stack.getItemDamage()].unlocalisedName;
}
@Override
@@ -32,7 +32,7 @@ public class BlockItemIngotStorage extends ItemBlock {
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
for (Alloy alloy : Alloy.values()) {
for (Alloy alloy : Alloy.VALUES) {
list.add(new ItemStack(this, 1, alloy.ordinal()));
}
}
@@ -34,7 +34,7 @@ public class ItemAlloy extends Item {
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(ModObject.itemAlloy.unlocalisedName);
numItems = Alloy.values().length;
numItems = Alloy.VALUES.length;
if (useNuggets) {
numItems = numItems * 2;
}
@@ -55,13 +55,13 @@ public class ItemAlloy extends Item {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
int numAlloys = Alloy.values().length;
int numAlloys = Alloy.VALUES.length;
for (int i = 0; i < numAlloys; i++) {
icons[i] = IIconRegister.registerIcon(Alloy.values()[i].iconKey);
icons[i] = IIconRegister.registerIcon(Alloy.VALUES[i].iconKey);
}
if (useNuggets) {
for (int i = 0; i < numAlloys; i++) {
icons[i + numAlloys] = IIconRegister.registerIcon(Alloy.values()[i].iconKey + "Nugget");
icons[i + numAlloys] = IIconRegister.registerIcon(Alloy.VALUES[i].iconKey + "Nugget");
}
}
}
@@ -69,10 +69,10 @@ public class ItemAlloy extends Item {
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, numItems - 1);
if (i < Alloy.values().length) {
return Alloy.values()[i].unlocalisedName;
if (i < Alloy.VALUES.length) {
return Alloy.VALUES[i].unlocalisedName;
} else {
return Alloy.values()[i - Alloy.values().length].unlocalisedName + "Nugget";
return Alloy.VALUES[i - Alloy.VALUES.length].unlocalisedName + "Nugget";
}
}
@@ -1,5 +1,8 @@
package crazypants.enderio.material;
import static net.minecraft.util.EnumChatFormatting.RESET;
import java.text.DecimalFormat;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -9,6 +12,7 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
@@ -20,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.config.Config;
import crazypants.enderio.power.BasicCapacitor;
import crazypants.enderio.power.Capacitors;
import crazypants.enderio.power.ICapacitor;
@@ -28,6 +33,7 @@ import crazypants.enderio.power.ICapacitorItem;
public class ItemCapacitor extends Item implements ICapacitorItem {
private static final BasicCapacitor CAP = new BasicCapacitor();
private static final String SPACE = " ";
public static ItemCapacitor create() {
ItemCapacitor result = new ItemCapacitor();
@@ -44,7 +50,7 @@ public class ItemCapacitor extends Item implements ICapacitorItem {
setMaxDamage(0);
setMaxStackSize(64);
icons = new IIcon[Capacitors.values().length];
icons = new IIcon[Capacitors.VALUES.length];
}
protected void init() {
@@ -54,30 +60,30 @@ public class ItemCapacitor extends Item implements ICapacitorItem {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, Capacitors.values().length - 1);
damage = MathHelper.clamp_int(damage, 0, Capacitors.VALUES.length - 1);
return icons[damage];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
for (int i = 0; i < Capacitors.values().length; i++) {
icons[i] = IIconRegister.registerIcon(Capacitors.values()[i].iconKey);
for (int i = 0; i < Capacitors.VALUES.length; i++) {
icons[i] = IIconRegister.registerIcon(Capacitors.VALUES[i].iconKey);
}
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Capacitors.values().length - 1);
return Capacitors.values()[i].unlocalisedName;
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Capacitors.VALUES.length - 1);
return Capacitors.VALUES[i].unlocalisedName;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> par3List) {
for (int j = 0; j < Capacitors.values().length; ++j) {
for (int j = 0; j < Capacitors.VALUES.length; ++j) {
par3List.add(new ItemStack(par1, 1, j));
if (Capacitors.values()[j] == Capacitors.TOTEMIC_CAPACITOR) {
if (Capacitors.VALUES[j] == Capacitors.TOTEMIC_CAPACITOR) {
ItemStack stack = new ItemStack(par1, 1, j);
stack.addEnchantment(Enchantment.efficiency, 5);
par3List.add(stack);
@@ -87,16 +93,16 @@ public class ItemCapacitor extends Item implements ICapacitorItem {
@Override
public ICapacitor getCapacitor(ItemStack stack) {
int damage = MathHelper.clamp_int(stack.getItemDamage(), 0, Capacitors.values().length - 1);
int damage = MathHelper.clamp_int(stack.getItemDamage(), 0, Capacitors.VALUES.length - 1);
if (Capacitors.values()[damage] == Capacitors.TOTEMIC_CAPACITOR) {
if (Capacitors.VALUES[damage] == Capacitors.TOTEMIC_CAPACITOR) {
damage = MathHelper.clamp_int(
EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack) + 1,
1,
Capacitors.TOTEMIC_CAPACITOR.ordinal());
}
return Capacitors.values()[damage].capacitor;
return Capacitors.VALUES[damage].capacitor;
}
@Override
@@ -104,12 +110,43 @@ public class ItemCapacitor extends Item implements ICapacitorItem {
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List<String> par3List,
boolean par4) {
if (par1ItemStack != null && par1ItemStack.getItemDamage() > 0 && par1ItemStack.getItemDamage() != 7) {
par3List.add(EnderIO.lang.localize("machine.tooltip.upgrade"));
ICapacitor capacitor = getCapacitor(par1ItemStack);
par3List.add(EnumChatFormatting.GREEN + EnderIO.lang.localize("machine.tooltip.upgrade.name"));
if (SpecialTooltipHandler.showAdvancedTooltips()) {
SpecialTooltipHandler.addDetailedTooltipFromResources(par3List, "enderio.machine.tooltip.upgrade");
addUpgrades(par3List, capacitor);
addRangeUpgrade(par3List, capacitor);
} else {
SpecialTooltipHandler.addShowDetailsTooltip(par3List);
}
}
}
public void addUpgrades(List<String> list, ICapacitor capacitor) {
DecimalFormat formatter = new DecimalFormat("#,###");
String tierString = EnumChatFormatting.AQUA + EnderIO.lang.localize("machine.tooltip.upgrade.tier");
String maxEnergyStorageString = EnumChatFormatting.AQUA
+ EnderIO.lang.localize("machine.tooltip.upgrade.energystorage");
String maxEnergyReceivedString = EnumChatFormatting.AQUA
+ EnderIO.lang.localize("machine.tooltip.upgrade.energyreceived");
String maxEnergyExtractedString = EnumChatFormatting.AQUA
+ EnderIO.lang.localize("machine.tooltip.upgrade.energyextracted");
String upgrades = EnumChatFormatting.GOLD + EnderIO.lang.localize("machine.tooltip.upgrade");
String maxEnergyStorage = formatter.format(capacitor.getMaxEnergyStored());
int tier = capacitor.getTier();
String maxEnergyReceived = formatter.format(capacitor.getMaxEnergyReceived());
String maxEnergyExtracted = formatter.format(capacitor.getMaxEnergyExtracted());
list.add(upgrades);
list.add(SPACE + tierString + RESET + tier);
list.add(SPACE + maxEnergyReceivedString + RESET + maxEnergyReceived);
list.add(SPACE + maxEnergyExtractedString + RESET + maxEnergyExtracted);
list.add(SPACE + maxEnergyStorageString + RESET + maxEnergyStorage);
}
public void addRangeUpgrade(List<String> list, ICapacitor capacitor) {
String farmStation = EnumChatFormatting.AQUA + EnderIO.lang.localize("machine.tooltip.upgrade.farmstation");
String rangeUpgrade = EnumChatFormatting.GOLD + EnderIO.lang.localize("machine.tooltip.upgrade.range");
int range = Config.farmBonusSize * capacitor.getTier() - 1 + 2;
list.add(rangeUpgrade);
list.add(SPACE + farmStation + RESET + range);
}
}
@@ -36,14 +36,14 @@ public class ItemGrindingBall extends ItemAlloy {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
int numAlloys = Alloy.values().length;
int numAlloys = Alloy.VALUES.length;
for (int i = 0; i < numAlloys; i++)
icons[i] = IIconRegister.registerIcon(Alloy.values()[i].iconKey + "GrindingBall");
icons[i] = IIconRegister.registerIcon(Alloy.VALUES[i].iconKey + "GrindingBall");
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, numItems - 1);
return Alloy.values()[i].unlocalisedName + "_ball";
return Alloy.VALUES[i].unlocalisedName + "_ball";
}
}
@@ -31,7 +31,7 @@ public class ItemMaterial extends Item {
setCreativeTab(EnderIOTab.tabEnderIO);
setUnlocalizedName(ModObject.itemMaterial.unlocalisedName);
icons = new IIcon[Material.values().length];
icons = new IIcon[Material.VALUES.length];
}
private void init() {
@@ -41,29 +41,29 @@ public class ItemMaterial extends Item {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int damage) {
damage = MathHelper.clamp_int(damage, 0, Material.values().length - 1);
damage = MathHelper.clamp_int(damage, 0, Material.VALUES.length - 1);
return icons[damage];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister IIconRegister) {
int numParts = Material.values().length;
int numParts = Material.VALUES.length;
for (int i = 0; i < numParts; i++) {
icons[i] = IIconRegister.registerIcon(Material.values()[i].iconKey);
icons[i] = IIconRegister.registerIcon(Material.VALUES[i].iconKey);
}
}
@Override
public String getUnlocalizedName(ItemStack par1ItemStack) {
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Material.values().length - 1);
return Material.values()[i].unlocalisedName;
int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Material.VALUES.length - 1);
return Material.VALUES[i].unlocalisedName;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List<ItemStack> par3List) {
for (int j = 0; j < Material.values().length; ++j) {
for (int j = 0; j < Material.VALUES.length; ++j) {
par3List.add(new ItemStack(par1, 1, j));
}
}
@@ -74,7 +74,7 @@ public class ItemMaterial extends Item {
if (par1ItemStack == null) {
return false;
}
int damage = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Material.values().length - 1);
return Material.values()[damage].hasEffect;
int damage = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, Material.VALUES.length - 1);
return Material.VALUES[damage].hasEffect;
}
}
@@ -29,16 +29,20 @@ public enum Material {
ENDER_POWDER("enderCrystalPowder", true),
PRECIENT_POWDER("precientPowder", true);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final Material[] VALUES = values();
public final String unlocalisedName;
public final String iconKey;
public final String oreDict;
public final boolean hasEffect;
private Material(String unlocalisedName) {
Material(String unlocalisedName) {
this(unlocalisedName, false);
}
private Material(String unlocalisedName, boolean hasEffect) {
Material(String unlocalisedName, boolean hasEffect) {
this.unlocalisedName = "enderio." + unlocalisedName;
this.iconKey = "enderio:" + unlocalisedName;
this.hasEffect = hasEffect;
@@ -46,7 +50,7 @@ public enum Material {
}
public static void registerOres(Item item) {
for (Material m : values()) {
for (Material m : VALUES) {
OreDictionary.registerOre(m.oreDict, new ItemStack(item, 1, m.ordinal()));
}
}
@@ -1,5 +1,6 @@
package crazypants.enderio.material;
import static crazypants.enderio.EnderIO.hasGT5;
import static crazypants.enderio.material.Alloy.DARK_STEEL;
import static crazypants.enderio.material.Alloy.END_STEEL;
import static crazypants.enderio.material.Alloy.ENERGETIC_ALLOY;
@@ -58,20 +59,23 @@ public class MaterialRecipes {
public static void registerOresInDictionary() {
// Ore Dictionary Registration
for (PowderIngot powder : PowderIngot.values()) {
if (!powder.hasDependancy()) {
OreDictionary
.registerOre(powder.oreDictName, new ItemStack(EnderIO.itemPowderIngot, 1, powder.ordinal()));
if (!hasGT5) {
for (PowderIngot powder : PowderIngot.values()) {
if (!powder.hasDependancy()) {
OreDictionary.registerOre(
powder.oreDictName,
new ItemStack(EnderIO.itemPowderIngot, 1, powder.ordinal()));
}
}
}
for (Capacitors capacitor : Capacitors.values()) {
for (Capacitors capacitor : Capacitors.VALUES) {
OreDictionary.registerOre(
capacitor.getOreTag(),
new ItemStack(EnderIO.itemBasicCapacitor, 1, capacitor.ordinal()));
}
for (Alloy alloy : Alloy.values()) {
for (Alloy alloy : Alloy.VALUES) {
boolean isPrimaryName = true;
for (String oreDictName : alloy.getOreIngots()) {
OreDictionary.registerOre(oreDictName, alloy.getStackIngot());
@@ -95,7 +99,7 @@ public class MaterialRecipes {
}
}
for (AlloyEndergy alloy : AlloyEndergy.values()) {
for (AlloyEndergy alloy : AlloyEndergy.VALUES) {
boolean isPrimaryName = true;
for (String oreDictName : alloy.getOreIngots()) {
OreDictionary.registerOre(oreDictName, alloy.getStackIngot());
@@ -431,17 +435,19 @@ public class MaterialRecipes {
RecipeUtil.addShaped(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', "gemEmerald");
// Smelting
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack ingotIron = new ItemStack(Items.iron_ingot);
ItemStack ingotGold = new ItemStack(Items.gold_ingot);
if (!hasGT5) {
ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal());
ItemStack dustGold = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal());
ItemStack ingotIron = new ItemStack(Items.iron_ingot);
ItemStack ingotGold = new ItemStack(Items.gold_ingot);
GameRegistry.addSmelting(dustIron, ingotIron, 0);
GameRegistry.addSmelting(dustGold, ingotGold, 0);
GameRegistry.addSmelting(dustIron, ingotIron, 0);
GameRegistry.addSmelting(dustGold, ingotGold, 0);
// Ender Dusts
ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
RecipeUtil.addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
// Ender Dusts
ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal());
RecipeUtil.addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust);
}
// Dark Iron Bars
ItemStack diBars = new ItemStack(EnderIO.blockDarkIronBars, 16, 0);
@@ -548,13 +554,13 @@ public class MaterialRecipes {
'b',
EnderIO.blockDarkIronBars);
for (Alloy alloy : Alloy.values()) {
for (Alloy alloy : Alloy.VALUES) {
RecipeUtil.addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
RecipeUtil.addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
RecipeUtil.addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
}
for (AlloyEndergy alloy : AlloyEndergy.values()) {
for (AlloyEndergy alloy : AlloyEndergy.VALUES) {
RecipeUtil.addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.getOreIngot());
RecipeUtil.addShaped(alloy.getStackBall(5), " i ", "iii", " i ", 'i', alloy.getOreIngot());
RecipeUtil.addShapeless(alloy.getStackIngot(9), alloy.getOreBlock());
@@ -564,24 +570,29 @@ public class MaterialRecipes {
ItemStack darkRod = new ItemStack(EnderIO.itemMaterial, 1, Material.DARK_STEEL_ROD.ordinal());
RecipeUtil.addShaped(darkRod, " ns", "nsn", "sn ", 's', darkSteel, 'n', endSteelNugget);
// Food
ItemStack flour = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.FLOUR.ordinal());
ItemStack bread = new ItemStack(Items.bread, 1, 0);
if (!hasGT5) {
// Food
ItemStack flour = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.FLOUR.ordinal());
ItemStack bread = new ItemStack(Items.bread, 1, 0);
GameRegistry.addSmelting(flour, bread, 0.35f);
GameRegistry.addSmelting(flour, bread, 0.35f);
}
ItemStack enderios = EnderFood.ENDERIOS.getStack();
RecipeUtil.addShapeless(enderios, Items.bowl, Items.milk_bucket, "cropWheat", "dustEnderPearl");
if (OreDictionaryHelper.hasCopper()) {
ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal());
ItemStack ingotCoppper = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_COPPER);
GameRegistry.addSmelting(dustCopper, ingotCoppper, 0);
}
if (OreDictionaryHelper.hasTin()) {
ItemStack dustTin = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_TIN.ordinal());
ItemStack ingotTin = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_TIN);
GameRegistry.addSmelting(dustTin, ingotTin, 0);
if (!hasGT5) {
if (OreDictionaryHelper.hasCopper()) {
ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal());
ItemStack ingotCoppper = OreDictionaryPreferences.instance
.getPreferred(OreDictionaryHelper.INGOT_COPPER);
GameRegistry.addSmelting(dustCopper, ingotCoppper, 0);
}
if (OreDictionaryHelper.hasTin()) {
ItemStack dustTin = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_TIN.ordinal());
ItemStack ingotTin = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_TIN);
GameRegistry.addSmelting(dustTin, ingotTin, 0);
}
}
}
}
@@ -19,13 +19,17 @@ public enum AlloyEndergy {
ENERGETIC_SILVER("energeticSilver", 7.0f),
VIVID_ALLOY("vividAlloy", 4.0f);
/**
* Cached values() array for frequent read-only operations, the array should NOT be mutated.
*/
public static final AlloyEndergy[] VALUES = values();
public final String unlocalisedName;
public final String iconKey;
private final List<String> oreIngots = new ArrayList<String>();
private final List<String> oreBlocks = new ArrayList<String>();
private final float hardness;
private AlloyEndergy(String baseName, float hardness, String oreDictName) {
AlloyEndergy(String baseName, float hardness, String oreDictName) {
this.unlocalisedName = "enderio." + baseName;
this.iconKey = "enderio:" + baseName;
if (oreDictName != null) {
@@ -37,7 +41,7 @@ public enum AlloyEndergy {
this.hardness = hardness;
}
private AlloyEndergy(String baseName, float hardness) {
AlloyEndergy(String baseName, float hardness) {
this(baseName, hardness, null);
}
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more