diff --git a/build.gradle b/build.gradle index f55bc56ca..c131121ef 100644 --- a/build.gradle +++ b/build.gradle @@ -68,7 +68,7 @@ minecraft { } dependencies { - deobfCompile "MCMultiPart:MCMultiPart-experimental:${config.mcmp_version}:universal" + deobfCompile "MCMultiPart2:MCMultiPart-exp:${config.mcmp_version}:universal" deobfCompile "mezz.jei:jei_${config.minecraft_version}:${config.jei_version}" } diff --git a/build.properties b/build.properties index 44459176e..b6fcb2088 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ -minecraft_version=1.10.2 +minecraft_version=1.11.2 mappings_version=snapshot_20160627 -forge_version=12.18.1.2014 -mcmp_version=2.0.0_88 -jei_version=3.7.6.231 +forge_version=13.20.0.2226 +mcmp_version=2.0.0_9 +jei_version=4.2.9.247 mod_version=9.2.2 diff --git a/src/api/java/buildcraft/api/IDoubleRegistry.java b/src/api/java/buildcraft/api/IDoubleRegistry.java deleted file mode 100755 index 3c5db9254..000000000 --- a/src/api/java/buildcraft/api/IDoubleRegistry.java +++ /dev/null @@ -1,10 +0,0 @@ -package buildcraft.api; - -import java.util.Map.Entry; -import java.util.Set; - -public interface IDoubleRegistry extends ISimpleRegistry { - void registerDefinition(T definition); - - Set> getDefinitions(); -} diff --git a/src/api/java/buildcraft/api/ISimpleRegistry.java b/src/api/java/buildcraft/api/ISimpleRegistry.java deleted file mode 100755 index 9227214f4..000000000 --- a/src/api/java/buildcraft/api/ISimpleRegistry.java +++ /dev/null @@ -1,12 +0,0 @@ -package buildcraft.api; - -interface ISimpleRegistry { - /** @param uniqueTag The tag to look up. Can be null. - * @return The unique definition associated with the unique tag, or null if the tag was not mapped */ - T getDefinition(String uniqueTag); - - /** @param definition The definition to look up. Can be null. - * @return The unique to for that definition. Will never be null, but will be an empty string if the definition did - * not exist. */ - String getTag(T definition); -} diff --git a/src/api/java/buildcraft/api/ITripleRegistry.java b/src/api/java/buildcraft/api/ITripleRegistry.java deleted file mode 100755 index ea29b613c..000000000 --- a/src/api/java/buildcraft/api/ITripleRegistry.java +++ /dev/null @@ -1,30 +0,0 @@ -package buildcraft.api; - -import java.util.Set; - -import org.apache.commons.lang3.tuple.Triple; - -import net.minecraft.item.Item; - -public interface ITripleRegistry extends ISimpleRegistry { - /** @return An unmodifiable set containing all the current mappings of the registry */ - Set> getDefinitions(); - - // Specifics - - /** @param definition The pipe definition to look up. Can be null. - * @return The item the has been mapped to the definition, or null if the definition was not mapped */ - Item getItem(T definition); - - /** @param item The item to look up the definition of. Can be null. - * @return The definition associated with that item, or null if the item was not mapped. */ - T getDefinition(Item item); - - /** @param item The item to look up the tag of. Can be null. - * @return The unique tag associated with that item, or null if the item was not mapped. */ - String getUniqueTag(Item item); - - /** @param tag The tag to look up the item with. - * @return The item associated with that tag, or null if the tag was not mapped. */ - Item getItem(String tag); -} diff --git a/src/api/java/buildcraft/api/ObjectDefinition.java b/src/api/java/buildcraft/api/ObjectDefinition.java deleted file mode 100755 index 54c9bd127..000000000 --- a/src/api/java/buildcraft/api/ObjectDefinition.java +++ /dev/null @@ -1,32 +0,0 @@ -package buildcraft.api; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; - -/* Note that neither this class (Or any of its subtypes) overrides equals or hash code, despite it being used as a key - * in a hash table. This is to speed up comparisons as no two ObjectDefinitions instances should be created with the - * same values. */ -public class ObjectDefinition { - /** A globally unique tag for the pipe */ - public final String globalUniqueTag; - /** A mod unique tag for the pipe. WARNING: this should only be used to register other mod-unique things, such as - * the pipe or gate item. For general use, use {@link #globalUniqueTag} */ - public final String modUniqueTag; - - protected static String getCurrentMod() { - ModContainer container = Loader.instance().activeModContainer(); - if (container == null) { - throw new IllegalStateException("Objects MUST be created inside a mod"); - } - return container.getModId(); - } - - private ObjectDefinition(String mod, String modUniqueTag) { - this.globalUniqueTag = mod + ":" + modUniqueTag; - this.modUniqueTag = modUniqueTag; - } - - public ObjectDefinition(String tag) { - this(getCurrentMod(), tag); - } -} diff --git a/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java b/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java new file mode 100755 index 000000000..2517af2bb --- /dev/null +++ b/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java @@ -0,0 +1,115 @@ +package buildcraft.api.blocks; + +import java.util.List; +import java.util.Map; + +import javax.annotation.Nullable; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; + +/** Provides a simple way to paint a single block, iterating through all {@link ICustomPaintHandler}'s that are + * registered for the block. */ +public enum CustomPaintHelper { + INSTANCE; + + /* If you want to test your class-based rotation registration then add the system property + * "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */ + private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.painting"); + + private final Map> handlers = Maps.newIdentityHashMap(); + private final List allHandlers = Lists.newArrayList(); + + /** Registers a handler that will be called LAST for ALL blocks, if all other paint handlers have returned PASS or + * none are registered for that block. */ + public void registerHandlerForAll(ICustomPaintHandler handler) { + if (DEBUG) { + BCLog.logger.info("[api.painting] Adding a paint handler for ALL blocks (" + handler.getClass() + ")"); + } + allHandlers.add(handler); + } + + /** Register's a paint handler for every class of a given block. */ + public void registerHandlerForAll(Class blockClass, ICustomPaintHandler handler) { + for (Block block : Block.REGISTRY) { + Class foundClass = block.getClass(); + if (blockClass.isAssignableFrom(foundClass)) { + if (DEBUG) { + BCLog.logger.info("[api.painting] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); + } + registerHandlerInternal(block, handler); + } + } + } + + public void registerHandler(Block block, ICustomPaintHandler handler) { + if (registerHandlerInternal(block, handler)) { + if (DEBUG) { + BCLog.logger.info("[api.painting] Setting a paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); + } + } else if (DEBUG) { + BCLog.logger.info("[api.painting] Adding another paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); + } + } + + private boolean registerHandlerInternal(Block block, ICustomPaintHandler handler) { + if (!handlers.containsKey(block)) { + List forBlock = Lists.newArrayList(); + forBlock.add(handler); + handlers.put(block, forBlock); + return true; + } else { + handlers.get(block).add(handler); + return false; + } + } + + /** Attempts to paint a block at the given position. Basically iterates through all registered paint handlers. */ + public EnumActionResult attemptPaintBlock(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paint) { + Block block = state.getBlock(); + if (block instanceof ICustomPaintHandler) { + return ((ICustomPaintHandler) block).attemptPaint(world, pos, state, hitPos, hitSide, paint); + } + List custom = handlers.get(block); + if (custom == null || custom.isEmpty()) { + return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); + } + for (ICustomPaintHandler handler : custom) { + EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); + if (result != EnumActionResult.PASS) { + return result; + } + } + return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); + } + + private EnumActionResult defaultAttemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, EnumFacing hitSide, @Nullable EnumDyeColor paint) { + for (ICustomPaintHandler handler : allHandlers) { + EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); + if (result != EnumActionResult.PASS) { + return result; + } + } + if (paint == null) { + return EnumActionResult.FAIL; + } + Block b = state.getBlock(); + if (b.recolorBlock(world, pos, hitSide, paint)) { + return EnumActionResult.SUCCESS; + } else { + return EnumActionResult.FAIL; + } + } +} diff --git a/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java b/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java new file mode 100755 index 000000000..235c0de11 --- /dev/null +++ b/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java @@ -0,0 +1,76 @@ +package buildcraft.api.blocks; + +import java.util.List; +import java.util.Map; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; + +public enum CustomRotationHelper { + INSTANCE; + + /* If you want to test your class-based rotation registration then add the system property + * "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */ + private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.rotation"); + + private final Map> handlers = Maps.newIdentityHashMap(); + + public void registerHandlerForAll(Class blockClass, ICustomRotationHandler handler) { + for (Block block : Block.REGISTRY) { + Class foundClass = block.getClass(); + if (blockClass.isAssignableFrom(foundClass)) { + if (DEBUG) { + BCLog.logger.info("[api.rotation] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); + } + registerHandlerInternal(block, handler); + } + } + } + + public void registerHandler(Block block, ICustomRotationHandler handler) { + if (registerHandlerInternal(block, handler)) { + if (DEBUG) { + BCLog.logger.info("[api.rotation] Setting a rotation handler for block " + block.getRegistryName()); + } + } else if (DEBUG) { + BCLog.logger.info("[api.rotation] Adding another rotation handler for block " + block.getRegistryName()); + } + } + + private boolean registerHandlerInternal(Block block, ICustomRotationHandler handler) { + if (!handlers.containsKey(block)) { + List forBlock = Lists.newArrayList(); + forBlock.add(handler); + handlers.put(block, forBlock); + return true; + } else { + handlers.get(block).add(handler); + return false; + } + } + + public EnumActionResult attemptRotateBlock(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched) { + Block block = state.getBlock(); + if (block instanceof ICustomRotationHandler) { + return ((ICustomRotationHandler) block).attemptRotation(world, pos, state, sideWrenched); + } + if (!handlers.containsKey(block)) return EnumActionResult.PASS; + for (ICustomRotationHandler handler : handlers.get(block)) { + EnumActionResult result = handler.attemptRotation(world, pos, state, sideWrenched); + if (result != EnumActionResult.PASS) { + return result; + } + } + return EnumActionResult.PASS; + } +} diff --git a/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java b/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java new file mode 100755 index 000000000..fd79c910a --- /dev/null +++ b/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java @@ -0,0 +1,31 @@ +package buildcraft.api.blocks; + +import javax.annotation.Nullable; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +/** Provides a way to paint blocks from any position. You can either implement this on a block, or register an instance + * for a block with {@link CustomPaintHelper} */ +public interface ICustomPaintHandler { + /** Attempts to paint the given block. This can also only paint a specific part of the block (as the hit position is + * given). + * + * @param world The world that the block is contained within. + * @param pos The position of the block. + * @param state The current state of the block. + * @param hitPos The absolute hit position of the paintbrush, relative the world's origin. + * @param hitSide The side of the block that was hit. + * @param paintColour The paint colour to attempt to paint with, null if the paint should be cleared (so if this was + * a stained glass block, and null was passed, this would set it to a normal, clear, non-stained glass + * block. + * @return The result of attempting to paint. SUCCESS means that you changed the block from before to a new value, + * FAIL means you COULD have handled the block, but it was already painted to that colour, or PASS if you + * have no idea how to handle the block in question. */ + EnumActionResult attemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paintColour); +} diff --git a/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java b/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java new file mode 100755 index 000000000..9076f8fd0 --- /dev/null +++ b/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java @@ -0,0 +1,11 @@ +package buildcraft.api.blocks; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface ICustomRotationHandler { + EnumActionResult attemptRotation(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched); +} diff --git a/src/api/java/buildcraft/api/blocks/package-info.java b/src/api/java/buildcraft/api/blocks/package-info.java new file mode 100755 index 000000000..c3bc6eac1 --- /dev/null +++ b/src/api/java/buildcraft/api/blocks/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blocks") +package buildcraft.api.blocks; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java b/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java new file mode 100755 index 000000000..dad91b98f --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java @@ -0,0 +1,30 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import java.io.File; + +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +/** This class is provided as a utility class for third-party mods that would like to easily deploy structures that are + * written in blueprints. It does not offer control on material that needs to get in, or how the structure is deployed, + * but allows to create contents of a blueprint in one cycle. Note that these functionalities will only work if + * BuildCraft is installed. */ +public abstract class BlueprintDeployer { + + /** The deployed instantiated by BuildCraft. This is set by the BuildCraft builder mod. Mods that want to work with + * BuildCraft not installed should check for this value to be not null. */ + public static BlueprintDeployer instance; + + /** Deploy the contents of the blueprints as if the builder was located at {pos} facing the direction dir. */ + public abstract void deployBlueprint(World world, BlockPos pos, EnumFacing facing, File file); + + /** Deploy the contents of the byte array as if the builder was located at {pos} facing the direction dir. */ + + public abstract void deployBlueprintFromFileStream(World world, BlockPos pos, EnumFacing dir, byte[] data); + +} diff --git a/src/api/java/buildcraft/api/blueprints/BuilderAPI.java b/src/api/java/buildcraft/api/blueprints/BuilderAPI.java new file mode 100755 index 000000000..ac15b474b --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/BuilderAPI.java @@ -0,0 +1,16 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +public final class BuilderAPI { + public static ISchematicRegistry schematicRegistry; + public static ISchematicHelper schematicHelper; + + private static final long MJ = 1000 * 1000; + public static final long BREAK_POWER = 16 * MJ;// micro Mj + public static final long BUILD_POWER = 24 * MJ;// micro Mj + + private BuilderAPI() {} +} diff --git a/src/api/java/buildcraft/api/blueprints/BuildingPermission.java b/src/api/java/buildcraft/api/blueprints/BuildingPermission.java new file mode 100755 index 000000000..8661240c4 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/BuildingPermission.java @@ -0,0 +1,21 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +/** Schematics recorded in the blueprints can restrict situations where a blueprint can be used. A same schematic class + * can have different permissions depending on its contents. It's particularly useful when fixing a schematic, if + * blueprints that saved the previous version should not be built because of a bug (such as dupe bug on inventories). */ +public enum BuildingPermission { + /** No restrictions, blueprints using this schematic are good in all contexts. */ + ALL, + + /** This blueprints containing this schematic can only be used in creative. Maybe the block can't be crafted in + * survival in the first place, or the content of the schematic is known to have dupe bugs. */ + CREATIVE_ONLY, + + /** Blueprints containing this schematic should not be built. This is typically used when a critical problems have + * been fixed, but older versions of the schematic are too badly broken to be retreived. */ + NONE, +} diff --git a/src/api/java/buildcraft/api/blueprints/IBuilderContext.java b/src/api/java/buildcraft/api/blueprints/IBuilderContext.java new file mode 100755 index 000000000..e5eb8900b --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/IBuilderContext.java @@ -0,0 +1,22 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import buildcraft.api.core.IBox; + +/** This interface provide contextual information when building or initializing blueprint slots. */ +public interface IBuilderContext { + + Vec3d rotatePositionLeft(Vec3d pos); + + IBox surroundingBox(); + + World world(); + + MappingRegistry getMappingRegistry(); +} diff --git a/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java b/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java new file mode 100755 index 000000000..7327f2e20 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java @@ -0,0 +1,7 @@ +package buildcraft.api.blueprints; + +import net.minecraft.item.ItemStack; + +public interface ISchematicHelper { + boolean isEqualItem(ItemStack a, ItemStack b); +} diff --git a/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java b/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java new file mode 100755 index 000000000..503c315d5 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java @@ -0,0 +1,19 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; + +public interface ISchematicRegistry { + void registerSchematicBlock(Block block, Class clazz, Object... params); + + void registerSchematicBlock(IBlockState state, Class clazz, Object... params); + + void registerSchematicEntity(Class entityClass, Class schematicClass, Object... params); + + boolean isSupported(IBlockState state); +} diff --git a/src/api/java/buildcraft/api/blueprints/ITileBuilder.java b/src/api/java/buildcraft/api/blueprints/ITileBuilder.java new file mode 100755 index 000000000..2c06f64c3 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/ITileBuilder.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.inventory.IInventory; + +public interface ITileBuilder extends IInventory { + + boolean isBuildingMaterialSlot(int i); + +} diff --git a/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java b/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java new file mode 100755 index 000000000..f84cee627 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +public class MappingNotFoundException extends Exception { + private static final long serialVersionUID = 1L; + + public MappingNotFoundException(String msg) { + super(msg); + } +} diff --git a/src/api/java/buildcraft/api/blueprints/MappingRegistry.java b/src/api/java/buildcraft/api/blueprints/MappingRegistry.java new file mode 100755 index 000000000..d2d9b9060 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/MappingRegistry.java @@ -0,0 +1,422 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map.Entry; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; + +import org.apache.logging.log4j.Level; + +import net.minecraft.block.Block; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fml.common.FMLModContainer; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; +import net.minecraftforge.fml.common.registry.GameRegistry; + +import buildcraft.api.core.BCLog; + +public class MappingRegistry { + + public HashMap blockToId = new HashMap(); + public ArrayList idToBlock = new ArrayList(); + + public HashMap itemToId = new HashMap(); + public ArrayList idToItem = new ArrayList(); + + public HashMap, Integer> entityToId = new HashMap, Integer>(); + public ArrayList> idToEntity = new ArrayList>(); + + private void registerItem(Item item) { + if (item == null) throw new IllegalArgumentException("Cannot register a null item!"); + if (!itemToId.containsKey(item)) { + idToItem.add(item); + itemToId.put(item, idToItem.size() - 1); + } + } + + private void registerBlock(Block block) { + if (block == null) throw new IllegalArgumentException("Cannot register a null block!"); + if (!blockToId.containsKey(block)) { + idToBlock.add(block); + blockToId.put(block, idToBlock.size() - 1); + } + } + + private void registerEntity(Class entityClass) { + if (entityClass == null) throw new IllegalArgumentException("Cannot register a null entityClass!"); + if (!entityToId.containsKey(entityClass)) { + idToEntity.add(entityClass); + entityToId.put(entityClass, idToEntity.size() - 1); + } + } + + public Item getItemForId(int id) throws MappingNotFoundException { + if (id >= idToItem.size()) { + throw new MappingNotFoundException("no item mapping at position " + id); + } + + Item result = idToItem.get(id); + + if (result == null) { + throw new MappingNotFoundException("no item mapping at position " + id); + } else { + return result; + } + } + + public int getIdForItem(Item item) { + if (item == null) throw new NullPointerException("item"); + if (!itemToId.containsKey(item)) { + registerItem(item); + } + + return itemToId.get(item); + } + + public int itemIdToRegistry(int id) { + Item item = Item.getItemById(id); + + return getIdForItem(item); + } + + public ResourceLocation itemIdToWorld(int id) throws MappingNotFoundException { + Item item = getItemForId(id); + + return Item.REGISTRY.getNameForObject(item); + } + + public Block getBlockForId(int id) throws MappingNotFoundException { + if (id >= idToBlock.size()) { + throw new MappingNotFoundException("no block mapping at position " + id); + } + + Block result = idToBlock.get(id); + + if (result == null) { + throw new MappingNotFoundException("no block mapping at position " + id); + } else { + return result; + } + } + + public int getIdForBlock(Block block) { + if (!blockToId.containsKey(block)) { + registerBlock(block); + } + + return blockToId.get(block); + } + + public int blockIdToRegistry(int id) { + Block block = Block.getBlockById(id); + + return getIdForBlock(block); + } + + public ResourceLocation blockIdToWorld(int id) throws MappingNotFoundException { + Block block = getBlockForId(id); + + return Block.REGISTRY.getNameForObject(block); + } + + public Class getEntityForId(int id) throws MappingNotFoundException { + if (id >= idToEntity.size()) { + throw new MappingNotFoundException("no entity mapping at position " + id); + } + + Class result = idToEntity.get(id); + + if (result == null) { + throw new MappingNotFoundException("no entity mapping at position " + id); + } else { + return result; + } + } + + public int getIdForEntity(Class entity) { + if (!entityToId.containsKey(entity)) { + registerEntity(entity); + } + + return entityToId.get(entity); + } + + /** Relocates a stack nbt from the registry referential to the world referential. */ + public void stackToWorld(NBTTagCompound nbt) throws MappingNotFoundException { + if (nbt.hasKey("id", Constants.NBT.TAG_SHORT)) { + Item item = getItemForId(nbt.getShort("id")); + nbt.setString("id", (item.getRegistryName().toString())); + } + } + + // versions before 1.8 saved stacks with an Item ID as a short + private boolean isOldStackLayout(NBTTagCompound nbt) { + return nbt.hasKey("id") && nbt.hasKey("Count") && nbt.hasKey("Damage") && nbt.getTag("id") instanceof NBTTagShort && nbt.getTag( + "Count") instanceof NBTTagByte && nbt.getTag("Damage") instanceof NBTTagShort; + } + + public void scanAndTranslateStacksToWorld(NBTTagCompound nbt) throws MappingNotFoundException { + // First, check if this nbt is itself a stack + + if (isOldStackLayout(nbt)) { + stackToWorld(nbt); + } + + // Then, look at the nbt compound contained in this nbt (even if it's a + // stack) and checks for stacks in it. + for (String key : (Collection) nbt.getKeySet()) { + if (nbt.getTag(key) instanceof NBTTagCompound) { + try { + scanAndTranslateStacksToWorld(nbt.getCompoundTag(key)); + } catch (MappingNotFoundException e) { + nbt.removeTag(key); + } + } + + if (nbt.getTag(key) instanceof NBTTagList) { + NBTTagList list = (NBTTagList) nbt.getTag(key); + + if (list.getTagType() == Constants.NBT.TAG_COMPOUND) { + for (int i = list.tagCount() - 1; i >= 0; --i) { + try { + scanAndTranslateStacksToWorld(list.getCompoundTagAt(i)); + } catch (MappingNotFoundException e) { + list.removeTag(i); + } + } + } + } + } + } + + public void write(NBTTagCompound nbt) { + NBTTagList blocksMapping = new NBTTagList(); + + for (Block b : idToBlock) { + NBTTagCompound sub = new NBTTagCompound(); + if (b != null) { + Object obj = Block.REGISTRY.getNameForObject(b); + if (obj == null) { + BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + + ") does not have a registry name! This is a bug!"); + } else { + String name = obj.toString(); + if (name == null || name.length() == 0) { + BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() + + ") has an empty registry name! This is a bug!"); + } else { + sub.setString("name", name); + } + } + } else { + throw new IllegalArgumentException("Found a null block!"); + } + blocksMapping.appendTag(sub); + } + + nbt.setTag("blocksMapping", blocksMapping); + + NBTTagList itemsMapping = new NBTTagList(); + + for (Item i : idToItem) { + NBTTagCompound sub = new NBTTagCompound(); + if (i != null) { + ResourceLocation obj = Item.REGISTRY.getNameForObject(i); + if (obj == null) { + BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + + ") does not have a registry name! This is a bug!"); + } else { + String name = obj.toString(); + if (name == null || name.length() == 0) { + BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() + + ") has an empty registry name! This is a bug!"); + } else { + sub.setString("name", name); + } + } + } else { + throw new IllegalArgumentException("Found a null item!"); + } + itemsMapping.appendTag(sub); + } + + nbt.setTag("itemsMapping", itemsMapping); + + NBTTagList entitiesMapping = new NBTTagList(); + + for (Class e : idToEntity) { + NBTTagCompound sub = new NBTTagCompound(); + sub.setString("name", e.getCanonicalName()); + entitiesMapping.appendTag(sub); + } + + nbt.setTag("entitiesMapping", entitiesMapping); + + // System.out.println("[W] idToItem size : " + idToItem.size()); + // for (Item i : idToItem) { + // System.out.println("- " + (i != null ? i.toString() : "null")); + // } + } + + private Object getMissingMappingFromFML(boolean isBlock, String name, int i) { + ResourceLocation location = new ResourceLocation(name); + String modName = name.split(":")[0]; + if (Loader.isModLoaded(modName)) { + try { + FMLMissingMappingsEvent.MissingMapping mapping = new FMLMissingMappingsEvent.MissingMapping(isBlock ? GameRegistry.Type.BLOCK + : GameRegistry.Type.ITEM, location, i); + ListMultimap missingMapping = ArrayListMultimap.create(); + missingMapping.put(modName, mapping); + FMLMissingMappingsEvent event = new FMLMissingMappingsEvent(missingMapping); + for (ModContainer container : Loader.instance().getModList()) { + if (container instanceof FMLModContainer) { + event.applyModContainer(container); + ((FMLModContainer) container).handleModStateEvent(event); + if (mapping.getAction() != FMLMissingMappingsEvent.Action.DEFAULT) { + break; + } + } + } + if (mapping.getAction() == FMLMissingMappingsEvent.Action.REMAP) { + return mapping.getTarget(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + + public void read(NBTTagCompound nbt) { + NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < blocksMapping.tagCount(); ++i) { + NBTTagCompound sub = blocksMapping.getCompoundTagAt(i); + if (!sub.hasKey("name")) { + // Keeping the order correct + idToBlock.add(null); + BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!"); + continue; + } + String name = sub.getString("name"); + ResourceLocation location = new ResourceLocation(name); + Block b = null; + + if (!Block.REGISTRY.containsKey(location) && name.contains(":")) { + b = (Block) getMissingMappingFromFML(true, name, i); + if (b != null) { + BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b)); + } + } + + if (b == null && Block.REGISTRY.containsKey(location)) { + b = (Block) Block.REGISTRY.getObject(location); + } + + if (b != null) { + registerBlock(b); + } else { + // Keeping the order correct + idToBlock.add(null); + BCLog.logger.log(Level.WARN, "Can't load block " + name); + } + } + + NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < itemsMapping.tagCount(); ++i) { + NBTTagCompound sub = itemsMapping.getCompoundTagAt(i); + if (!sub.hasKey("name")) { + // Keeping the order correct + idToItem.add(null); + BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!"); + continue; + } + + String name = sub.getString("name"); + ResourceLocation location = new ResourceLocation(name); + Item item = null; + + if (!Item.REGISTRY.containsKey(location) && name.contains(":")) { + item = (Item) getMissingMappingFromFML(false, name, i); + if (item != null) { + BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item)); + } + } + + if (item == null && Item.REGISTRY.containsKey(location)) { + item = (Item) Item.REGISTRY.getObject(location); + } + + if (item != null) { + registerItem(item); + } else { + // Keeping the order correct + idToItem.add(null); + BCLog.logger.log(Level.WARN, "Can't load item " + name); + } + } + + NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < entitiesMapping.tagCount(); ++i) { + NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i); + String name = sub.getString("name"); + Class e = null; + + try { + e = (Class) Class.forName(name); + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); + } + + if (e != null) { + registerEntity(e); + } else { + // Keeping the order correct + idToEntity.add(null); + BCLog.logger.log(Level.WARN, "Can't load entity " + name); + } + } + + // System.out.println("[R] idToItem size : " + idToItem.size()); + // for (Item i : idToItem) { + // System.out.println("- " + (i != null ? i.toString() : "null")); + // } + } + + public void addToCrashReport(CrashReportCategory cat) { + cat.addCrashSection("Item Map Count", itemToId.size()); + for (Entry e : itemToId.entrySet()) { + cat.addCrashSection(" - ID " + e.getValue(), Item.REGISTRY.getNameForObject(e.getKey())); + } + + cat.addCrashSection("Block Map Count", blockToId.size()); + for (Entry e : blockToId.entrySet()) { + cat.addCrashSection(" - ID " + e.getValue(), Block.REGISTRY.getNameForObject(e.getKey())); + } + + cat.addCrashSection("Entity Map Count", entityToId.size()); + for (Entry, Integer> e : entityToId.entrySet()) { + cat.addCrashSection(" - ID " + e.getValue(), e.getKey()); + } + } +} diff --git a/src/api/java/buildcraft/api/blueprints/Schematic.java b/src/api/java/buildcraft/api/blueprints/Schematic.java new file mode 100755 index 000000000..a0bb497b9 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/Schematic.java @@ -0,0 +1,196 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +import buildcraft.api.core.IInvSlot; + +/** A schematic is a piece of a blueprint. It allows to stock blocks or entities to blueprints, and can have a state + * that moves from a blueprint referential to a world referential. Although default schematic behavior will be OK for a + * lot of objects, specific blocks and entities may be associated with a dedicated schematic class, which will be + * instantiated automatically. + * + * Schematic perform "id translation" in case the block ids between a blueprint and the world installation are + * different. Mapping is done through the builder context. + * + * Detailed documentation on the schematic behavior can be found on + * http://www.mod-buildcraft.com/wiki/doku.php?id=builder_support + * + * Example of schematics for minecraft blocks are available in the package buildcraft.core.schematics. */ +// is being replaced by a different schematic implementation +// a simalir styled one to this might be made ontop of the other one though +public abstract class Schematic { + /** Blocks are build in various stages, in order to make sure that a block can indeed be placed, and that it's + * unlikely to disturb other blocks. */ + public enum BuildingStage { + /** Standalone blocks do not change once placed. */ + STANDALONE, + + /** Expanding blocks will grow and may disturb other block locations, like liquids. */ + EXPANDING + } + + /** This is called to verify whether the required item is equal to the supplied item. + * + * Primarily rely on this for checking metadata/NBT - the item ID itself might have been filtered out by previously + * running code. */ + public boolean isItemMatchingRequirement(ItemStack suppliedStack, ItemStack requiredStack) { + return BuilderAPI.schematicHelper.isEqualItem(suppliedStack, requiredStack); + } + + /** This is called each time an item matches a requirement. By default, it will increase damage of items that can be + * damaged by the amount of the requirement, and remove the intended amount of items that can't be damaged. + * + * Client may override this behavior. Note that this subprogram may be called twice with the same parameters, once + * with a copy of requirements and stack to check if the entire requirements can be fulfilled, and once with the + * real inventory. Implementer is responsible for updating req (with the remaining requirements if any) and slot + * (after usage). + * + * returns what was used (similar to req, but created from slot, so that any NBT based differences are drawn from + * the correct source) */ + public ItemStack useItem(IBuilderContext context, ItemStack req, IInvSlot slot) { + ItemStack stack = slot.getStackInSlot(); + ItemStack result = stack.copy(); + + if (stack.isItemStackDamageable()) { + if (req.getItemDamage() + stack.getItemDamage() <= stack.getMaxDamage()) { + stack.setItemDamage(req.getItemDamage() + stack.getItemDamage()); + result.setItemDamage(req.getItemDamage()); + req.setCount(0); + } + + if (stack.getItemDamage() >= stack.getMaxDamage()) { + slot.decreaseStackInSlot(1); + } + } else { + if (stack.getCount() >= req.getCount()) { + result.setCount(req.getCount()); + stack.setCount(stack.getCount() - req.getCount()); + req.setCount(0); + } else { + req.setCount(req.getCount() - stack.getCount()); + stack.setCount(0); + } + } + + if (stack.getCount() == 0) { + stack.setCount(1); + if (stack.getItem().hasContainerItem(stack)) { + ItemStack newStack = stack.getItem().getContainerItem(stack); + slot.setStackInSlot(newStack); + } else { + slot.setStackInSlot(null); + } + } + + return result; + } + + /** Perform a 90 degree rotation to the slot. */ + public void rotateLeft(IBuilderContext context) { + + } + + /** Applies translations to all positions in the schematic to center in the blueprint referential */ + public void translateToBlueprint(Vec3d transform) { + + } + + /** Apply translations to all positions in the schematic to center in the builder referential */ + public void translateToWorld(Vec3d transform) {} + + /** Translates blocks and item ids to the blueprint referential */ + public void idsToBlueprint(MappingRegistry registry) {} + + /** Translates blocks and item ids to the world referential */ + public void idsToWorld(MappingRegistry registry) {} + + /** Initializes a schematic for blueprint according to an objet placed on {x, y, z} on the world. For blocks, block + * and meta fields will be initialized automatically. */ + public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) {} + + /** Places the block in the world, at the location specified in the slot, using the stack in parameters */ + public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) {} + + /** Write specific requirements coming from the world to the blueprint. */ + public void storeRequirements(IBuilderContext context, BlockPos pos) {} + + /** Returns the requirements needed to build this block. When the requirements are met, they will be removed all at + * once from the builder, before calling writeToWorld. */ + public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) {} + + /** Returns the amount of energy required to build this slot, depends on the stacks selected for the build. */ + public int getEnergyRequirement(NonNullList stacksUsed) { + int result = 0; + + if (stacksUsed != null) { + for (ItemStack s : stacksUsed) { + result += s.getCount() ;//* BuilderAPI.BUILD_ENERGY; + } + } + + return result; + } + + /** Returns the flying stacks to display in the builder animation. */ + public NonNullList getStacksToDisplay(NonNullList stackConsumed) { + return stackConsumed; + } + + /** Return the stage where this schematic has to be built. */ + public BuildingStage getBuildStage() { + return BuildingStage.STANDALONE; + } + + /** Return true if the block on the world correspond to the block stored in the blueprint at the location given by + * the slot. By default, this subprogram is permissive and doesn't take into account metadata. + * + * Post processing will be called on these blocks. */ + public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { + return true; + } + + /** Return true if the block should not be placed to the world. Requirements will not be asked on such a block, and + * building will not be called. + * + * Post processing will be called on these blocks. */ + public boolean doNotBuild() { + return false; + } + + /** Return true if the schematic should not be used at all. This is computed straight after readFromNBT can be used + * to deactivate schematics in which an inconsistency is detected. It will be considered as a block of air instead. + * + * Post processing will *not* be called on these blocks. */ + public boolean doNotUse() { + return false; + } + + /** Return the maximium building permission for blueprint containing this schematic. */ + public BuildingPermission getBuildingPermission() { + return BuildingPermission.ALL; + } + + /** Called on a block when the blueprint has finished to place all the blocks. This may be useful to adjust variable + * depending on surrounding blocks that may not be there already at initial building. */ + public void postProcessing(IBuilderContext context, BlockPos pos) {} + + /** Saves this schematic to the blueprint NBT. */ + public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {} + + /** Loads this schematic from the blueprint NBT. */ + public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {} + + /** Returns the number of cycles to wait after building this schematic. Tiles and entities typically require more + * wait, around 5 cycles. */ + public int buildTime() { + return 1; + } +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicBlock.java b/src/api/java/buildcraft/api/blueprints/SchematicBlock.java new file mode 100755 index 000000000..a1492df6d --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicBlock.java @@ -0,0 +1,193 @@ +/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.NonNullList; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fluids.BlockFluidBase; + +import buildcraft.api.core.BCLog; + +public class SchematicBlock extends SchematicBlockBase { + public IBlockState state = null; + public BuildingPermission defaultPermission = BuildingPermission.ALL; + + /** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this + * list or compute their own int Schematic. */ + public NonNullList storedRequirements = NonNullList.create(); + + private boolean doNotUse = false; + + @Override + public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { + if (state != null) { + if (storedRequirements.size() != 0) { + requirements.addAll(storedRequirements); + } else { + requirements.add(getItemStack(state)); + } + } + } + + @Override + public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { + IBlockState placed = context.world().getBlockState(pos); + if (state == placed) return true; + if (state.getBlock() != placed.getBlock()) return false; + // This fixes bugs with blocks like stairs that return extra properties that were not visible from the meta. + if (state.getBlock().getMetaFromState(state) == placed.getBlock().getMetaFromState(placed)) return true; + return false; + } + + @Override + public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { + super.placeInWorld(context, pos, stacks); + + this.setBlockInWorld(context, pos); + } + + @Override + public void storeRequirements(IBuilderContext context, BlockPos pos) { + super.storeRequirements(context, pos); + + if (state != null) { + storedRequirements = NonNullList.create(); + List drops = state.getBlock().getDrops(context.world(), pos, state, 0); + if (drops != null) { + storedRequirements.addAll(drops); + } + } + } + + @Override + public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.writeSchematicToNBT(nbt, registry); + + writeBlockToNBT(nbt, registry); + writeRequirementsToNBT(nbt, registry); + } + + @Override + public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.readSchematicFromNBT(nbt, registry); + + readBlockFromNBT(nbt, registry); + if (!doNotUse()) { + readRequirementsFromNBT(nbt, registry); + } + } + + /** Get a list of relative block coordinates which have to be built before this block can be placed. */ + public Set getPrerequisiteBlocks(IBuilderContext context) { + Set indexes = new HashSet(); + if (state.getBlock() instanceof BlockFalling) { + indexes.add(new BlockPos(0, -1, 0)); + } + return indexes; + } + + @Override + public BuildingStage getBuildStage() { + if (state.getBlock() instanceof BlockFluidBase || state.getBlock() instanceof BlockLiquid) { + return BuildingStage.EXPANDING; + } else { + return BuildingStage.STANDALONE; + } + } + + @Override + public BuildingPermission getBuildingPermission() { + return defaultPermission; + } + + // Utility functions + protected void setBlockInWorld(IBuilderContext context, BlockPos pos) { + context.world().setBlockState(pos, state, 3); + } + + @Override + public boolean doNotUse() { + return doNotUse; + } + + protected void readBlockFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + try { + Block block = registry.getBlockForId(nbt.getInteger("blockId")); + state = block.getStateFromMeta(nbt.getInteger("blockMeta")); + } catch (MappingNotFoundException e) { + BCLog.logger.info(e); + doNotUse = true; + } + } + + protected void readRequirementsFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + storedRequirements = NonNullList.create(); + if (nbt.hasKey("rq")) { + NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < rq.tagCount(); ++i) { + try { + NBTTagCompound sub = rq.getCompoundTagAt(i); + registry.stackToWorld(sub); + storedRequirements.add(new ItemStack(sub)); + } catch (MappingNotFoundException e) { + defaultPermission = BuildingPermission.CREATIVE_ONLY; + } catch (Throwable t) { + t.printStackTrace(); + defaultPermission = BuildingPermission.CREATIVE_ONLY; + } + } + } + } + + protected void writeBlockToNBT(NBTTagCompound nbt, MappingRegistry registry) { + nbt.setInteger("blockId", registry.getIdForBlock(state.getBlock())); + nbt.setInteger("blockMeta", state.getBlock().getMetaFromState(state)); + } + + protected void writeRequirementsToNBT(NBTTagCompound nbt, MappingRegistry registry) { + if (storedRequirements.size() > 0) { + NBTTagList rq = new NBTTagList(); + + for (ItemStack stack : storedRequirements) { + if (stack == null || stack.getItem() == null) throw new IllegalStateException("Found a null requirement! " + getClass()); + NBTTagCompound sub = new NBTTagCompound(); + stack.writeToNBT(sub); + rq.appendTag(sub); + } + + nbt.setTag("rq", rq); + } + } + + protected ItemStack getItemStack(IBlockState state, int quantity) { + return new ItemStack(state.getBlock(), quantity, state.getBlock().damageDropped(state)); + } + + protected ItemStack getItemStack(IBlockState state) { + return getItemStack(state, 1); + } + + // Pretty much all blocks (that rotate) rotate this way now + @Override + public void rotateLeft(IBuilderContext context) { + // FIXME: This might be the wrong way + state = state.withRotation(Rotation.CLOCKWISE_90); + } +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java b/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java new file mode 100755 index 000000000..69f18a2eb --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java @@ -0,0 +1,9 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +public abstract class SchematicBlockBase extends Schematic { + +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicEntity.java b/src/api/java/buildcraft/api/blueprints/SchematicEntity.java new file mode 100755 index 000000000..5d856c71d --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicEntity.java @@ -0,0 +1,193 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import java.util.Collections; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.Vec3d; + +import net.minecraftforge.common.util.Constants; + +public class SchematicEntity extends Schematic { + public Class entity; + + /** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from + * Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded + * from BptBlock.writeToWorld using the standard writeNBT function. */ + public NBTTagCompound entityNBT = new NBTTagCompound(); + + /** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this + * list or compute their own int Schematic. */ + public NonNullList storedRequirements = NonNullList.withSize(0, null); + public BuildingPermission defaultPermission = BuildingPermission.ALL; + + @Override + public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { + requirements.addAll(storedRequirements); + } + + public void writeToWorld(IBuilderContext context) { + Entity e = EntityList.createEntityFromNBT(entityNBT, context.world()); + context.world().spawnEntity(e); + } + + public void readFromWorld(IBuilderContext context, Entity entity) { + entity.writeToNBTOptional(entityNBT); + } + + @Override + public void translateToBlueprint(Vec3d transform) { + NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); + Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); + pos = pos.add(transform); + entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); + } + + @Override + public void translateToWorld(Vec3d transform) { + NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); + Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); + pos = pos.add(transform); + + entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); + } + + @Override + public void idsToBlueprint(MappingRegistry registry) {} + + @Override + public void idsToWorld(MappingRegistry registry) { + try { + registry.scanAndTranslateStacksToWorld(entityNBT); + } catch (MappingNotFoundException e) { + entityNBT = new NBTTagCompound(); + } + } + + @Override + public void rotateLeft(IBuilderContext context) { + NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); + Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); + pos = context.rotatePositionLeft(pos); + entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); + + nbttaglist = entityNBT.getTagList("Rotation", 5); + float yaw = nbttaglist.getFloatAt(0); + yaw += 90; + entityNBT.setTag("Rotation", this.newFloatNBTList(yaw, nbttaglist.getFloatAt(1))); + } + + @Override + public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.writeSchematicToNBT(nbt, registry); + + nbt.setInteger("entityId", registry.getIdForEntity(entity)); + nbt.setTag("entity", entityNBT); + + NBTTagList rq = new NBTTagList(); + + for (ItemStack stack : storedRequirements) { + NBTTagCompound sub = new NBTTagCompound(); + stack.writeToNBT(stack.writeToNBT(sub)); + sub.setInteger("id", registry.getIdForItem(stack.getItem())); + rq.appendTag(sub); + } + + nbt.setTag("rq", rq); + } + + @Override + public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.readSchematicFromNBT(nbt, registry); + + entityNBT = nbt.getCompoundTag("entity"); + + NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND); + + NonNullList rqs = NonNullList.create(); + + for (int i = 0; i < rq.tagCount(); ++i) { + try { + NBTTagCompound sub = rq.getCompoundTagAt(i); + + if (sub.getInteger("id") >= 0) { + // Maps the id in the blueprint to the id in the world + sub.setInteger("id", Item.REGISTRY.getIDForObject(registry.getItemForId(sub.getInteger("id")))); + + rqs.add(new ItemStack(sub)); + } else { + defaultPermission = BuildingPermission.CREATIVE_ONLY; + } + } catch (Throwable t) { + t.printStackTrace(); + defaultPermission = BuildingPermission.CREATIVE_ONLY; + } + } + + storedRequirements = rqs; + } + + protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) { + NBTTagList nbttaglist = new NBTTagList(); + double[] adouble = par1ArrayOfDouble; + int i = par1ArrayOfDouble.length; + + for (int j = 0; j < i; ++j) { + double d1 = adouble[j]; + nbttaglist.appendTag(new NBTTagDouble(d1)); + } + + return nbttaglist; + } + + protected NBTTagList newFloatNBTList(float... par1ArrayOfFloat) { + NBTTagList nbttaglist = new NBTTagList(); + float[] afloat = par1ArrayOfFloat; + int i = par1ArrayOfFloat.length; + + for (int j = 0; j < i; ++j) { + float f1 = afloat[j]; + nbttaglist.appendTag(new NBTTagFloat(f1)); + } + + return nbttaglist; + } + + public boolean isAlreadyBuilt(IBuilderContext context) { + NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); + Vec3d newPosition = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); + + for (Object o : context.world().loadedEntityList) { + Entity e = (Entity) o; + + Vec3d existingPositon = new Vec3d(e.posX, e.posY, e.posZ); + + if (existingPositon.distanceTo(newPosition) <= 0.1) { + return true; + } + } + + return false; + } + + @Override + public int buildTime() { + return 5; + } + + @Override + public BuildingPermission getBuildingPermission() { + return defaultPermission; + } +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicFactory.java b/src/api/java/buildcraft/api/blueprints/SchematicFactory.java new file mode 100755 index 000000000..878b15714 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicFactory.java @@ -0,0 +1,51 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import java.util.HashMap; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class SchematicFactory { + + private static final HashMap> factories = new HashMap>(); + + private static final HashMap, SchematicFactory> schematicToFactory = + new HashMap, SchematicFactory>(); + + protected abstract S loadSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException; + + public void saveSchematicToWorldNBT(NBTTagCompound nbt, S object, MappingRegistry registry) { + nbt.setString("factoryID", getClass().getCanonicalName()); + } + + public static Schematic createSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException { + String factoryName = nbt.getString("factoryID"); + + if (factories.containsKey(factoryName)) { + return factories.get(factoryName).loadSchematicFromWorldNBT(nbt, registry); + } else { + return null; + } + } + + public static void registerSchematicFactory(Class clas, SchematicFactory factory) { + schematicToFactory.put(clas, factory); + factories.put(factory.getClass().getCanonicalName(), factory); + } + + public static SchematicFactory getFactory(Class clas) { + Class superClass = clas.getSuperclass(); + + if (schematicToFactory.containsKey(clas)) { + return schematicToFactory.get(clas); + } else if (superClass != null) { + return getFactory(superClass); + } else { + return null; + } + } + +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicFluid.java b/src/api/java/buildcraft/api/blueprints/SchematicFluid.java new file mode 100755 index 000000000..f044bf021 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicFluid.java @@ -0,0 +1,83 @@ +/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.block.BlockLiquid; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.fluids.FluidStack; + +@Deprecated +public class SchematicFluid extends SchematicBlock { + + private final ItemStack fluidItem; + + public SchematicFluid(FluidStack fluidStack) { + this.fluidItem = new ItemStack(fluidStack.getFluid().getBlock(), 1); + } + + @Override + public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { + if (getLevel() == 0) { + requirements.add(fluidItem); + } + } + + @Override + public void storeRequirements(IBuilderContext context, BlockPos pos) { + // cancel requirements reading + } + + @Override + public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { + if (getLevel() == 0) { + return state == context.world().getBlockState(pos) && (context.world().getBlockState(pos).getValue(BlockLiquid.LEVEL)) == 0; + } else { + return state == context.world().getBlockState(pos); + } + } + + @Override + public void rotateLeft(IBuilderContext context) { + + } + + @Override + public boolean doNotBuild() { + return getLevel() != 0; + } + + @Override + public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { + if (getLevel() == 0) { + context.world().setBlockState(pos, state, 3); + } + } + + @Override + public void postProcessing(IBuilderContext context, BlockPos pos) { + if (getLevel() != 0) { + context.world().setBlockState(pos, state, 3); + } + } + + @Override + public NonNullList getStacksToDisplay(NonNullList stackConsumed) { + NonNullList result = NonNullList.create(); + result.add(fluidItem); + return result; + } + + @Override + public int getEnergyRequirement(NonNullList stacksUsed) { + return 1;// * BuilderAPI.BUILD_ENERGY; + } + + public int getLevel() { + return state.getValue(BlockLiquid.LEVEL); + } +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicMask.java b/src/api/java/buildcraft/api/blueprints/SchematicMask.java new file mode 100755 index 000000000..3d811bce4 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicMask.java @@ -0,0 +1,83 @@ +/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; + +import buildcraft.api.core.BuildCraftAPI; + +public class SchematicMask extends SchematicBlockBase { + /** True of the block should be a solid block (stone, grass or a furnace) and false if it shouldn't (flowers, air or + * vines) */ + public boolean isConcrete = true; + + public SchematicMask() { + + } + + public SchematicMask(boolean isConcrete) { + this.isConcrete = isConcrete; + } + + @Override + public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { + if (isConcrete) { + if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), pos)) { + return; + } else { + ItemStack stack = stacks.get(0); + EntityPlayer player = BuildCraftAPI.fakePlayerProvider.getBuildCraftPlayer((WorldServer) context.world()); + + // force the block to be air block, in case it's just a soft + // block which replacement is not straightforward + context.world().setBlockToAir(pos); + + // Find nearest solid surface to place on + EnumFacing solidFace = null; + for (EnumFacing face : EnumFacing.values()) { + BlockPos offset = pos.offset(face); + if (!BuildCraftAPI.isSoftBlock(context.world(), offset)) { + solidFace = face; + break; + } + } + ItemBlock itemBlock = (ItemBlock) stack.getItem(); + + IBlockState state = itemBlock.block.getStateForPlacement(context.world(), pos, solidFace, 0, 0, 0, stack.getMetadata(), player, EnumHand.MAIN_HAND); + itemBlock.placeBlockAt(stack, player, context.world(), pos, solidFace, 0, 0, 0, state); + } + } else { + context.world().setBlockToAir(pos); + } + } + + @Override + public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { + if (isConcrete) { + return !BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos); + } else { + return BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos); + } + } + + @Override + public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { + nbt.setBoolean("isConcrete", isConcrete); + } + + @Override + public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + isConcrete = nbt.getBoolean("isConcrete"); + } +} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicTile.java b/src/api/java/buildcraft/api/blueprints/SchematicTile.java new file mode 100755 index 000000000..318e27eb3 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/SchematicTile.java @@ -0,0 +1,109 @@ +/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.blueprints; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; + +public class SchematicTile extends SchematicBlock { + + /** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from + * Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded + * from BptBlock.writeToWorld using the standard writeNBT function. */ + public NBTTagCompound tileNBT = new NBTTagCompound(); + + @Override + public void idsToBlueprint(MappingRegistry registry) {} + + @Override + public void idsToWorld(MappingRegistry registry) { + try { + registry.scanAndTranslateStacksToWorld(tileNBT); + } catch (MappingNotFoundException e) { + tileNBT = new NBTTagCompound(); + } + } + + public void onNBTLoaded() { + + } + + /** Places the block in the world, at the location specified in the slot. */ + @Override + public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { + super.placeInWorld(context, pos, stacks); + + if (state.getBlock().hasTileEntity(state)) { + tileNBT.setInteger("x", pos.getX()); + tileNBT.setInteger("y", pos.getY()); + tileNBT.setInteger("z", pos.getZ()); + TileEntity tile = TileEntity.create(context.world(), tileNBT); + if (tile != null) { + tile.setWorld(context.world()); + context.world().setTileEntity(pos, tile); + } + } + } + + @Override + public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) { + super.initializeFromObjectAt(context, pos); + + if (state.getBlock().hasTileEntity(state)) { + TileEntity tile = context.world().getTileEntity(pos); + + if (tile != null) { + tile.writeToNBT(tileNBT); + } + + tileNBT = tileNBT.copy(); + onNBTLoaded(); + } + } + + @Override + public void storeRequirements(IBuilderContext context, BlockPos pos) { + super.storeRequirements(context, pos); + + if (state.getBlock().hasTileEntity(state)) { + TileEntity tile = context.world().getTileEntity(pos); + + if (tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + + for (int i = 0; i < inv.getSizeInventory(); ++i) { + ItemStack stack = inv.getStackInSlot(i); + if (!stack.isEmpty()) { + storedRequirements.add(stack); + } + } + } + } + } + + @Override + public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.writeSchematicToNBT(nbt, registry); + + nbt.setTag("blockCpt", tileNBT); + } + + @Override + public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { + super.readSchematicFromNBT(nbt, registry); + + tileNBT = nbt.getCompoundTag("blockCpt"); + onNBTLoaded(); + } + + @Override + public int buildTime() { + return 5; + } +} diff --git a/src/api/java/buildcraft/api/blueprints/package-info.java b/src/api/java/buildcraft/api/blueprints/package-info.java new file mode 100755 index 000000000..3b3632424 --- /dev/null +++ b/src/api/java/buildcraft/api/blueprints/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.5", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints") +package buildcraft.api.blueprints; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/boards/IRedstoneBoard.java b/src/api/java/buildcraft/api/boards/IRedstoneBoard.java new file mode 100755 index 000000000..2aa375e92 --- /dev/null +++ b/src/api/java/buildcraft/api/boards/IRedstoneBoard.java @@ -0,0 +1,12 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.boards; + +public interface IRedstoneBoard { + + void updateBoard(T container); + + RedstoneBoardNBT getNBTHandler(); +} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java b/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java new file mode 100755 index 000000000..0ced64a8b --- /dev/null +++ b/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java @@ -0,0 +1,45 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.boards; + +import java.util.List; +import java.util.Random; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.common.util.Constants; + +public abstract class RedstoneBoardNBT { + + private static Random rand = new Random(); + + public abstract String getID(); + + public abstract void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced); + + public abstract String getDisplayName(); + + public abstract IRedstoneBoard create(NBTTagCompound nbt, T object); + + public abstract String getItemModelLocation(); + + public void createBoard(NBTTagCompound nbt) { + nbt.setString("id", getID()); + } + + public int getParameterNumber(NBTTagCompound nbt) { + if (!nbt.hasKey("parameters")) { + return 0; + } else { + return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount(); + } + } + + public float nextFloat(int difficulty) { + return 1F - (float) Math.pow(rand.nextFloat(), 1F / difficulty); + } +} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java new file mode 100755 index 000000000..edfe79cb5 --- /dev/null +++ b/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java @@ -0,0 +1,32 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.boards; + +import java.util.Collection; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class RedstoneBoardRegistry { + + public static RedstoneBoardRegistry instance; + + /** Register a redstone board type. + * + * @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information. + * @param microJoules MJ price of the board, in micro MJ. */ + public abstract void registerBoardType(RedstoneBoardNBT redstoneBoardNBT, long microJoules); + + public abstract void setEmptyRobotBoard(RedstoneBoardRobotNBT redstoneBoardNBT); + + public abstract RedstoneBoardRobotNBT getEmptyRobotBoard(); + + public abstract RedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt); + + public abstract RedstoneBoardNBT getRedstoneBoard(String id); + + public abstract Collection> getAllBoardNBTs(); + + public abstract long getPowerCost(RedstoneBoardNBT board); +} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java new file mode 100755 index 000000000..b0ed0638f --- /dev/null +++ b/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java @@ -0,0 +1,29 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.boards; + +import buildcraft.api.robots.AIRobot; +import buildcraft.api.robots.EntityRobotBase; + +public abstract class RedstoneBoardRobot extends AIRobot implements IRedstoneBoard { + + public RedstoneBoardRobot(EntityRobotBase iRobot) { + super(iRobot); + } + + @Override + public abstract RedstoneBoardRobotNBT getNBTHandler(); + + @Override + public final void updateBoard(EntityRobotBase container) { + + } + + @Override + public boolean canLoadFromNBT() { + return true; + } + +} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java new file mode 100755 index 000000000..4a4161b19 --- /dev/null +++ b/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java @@ -0,0 +1,23 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.boards; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +import buildcraft.api.robots.EntityRobotBase; + +public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT { + + @Override + public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) { + return create(robot); + } + + public abstract RedstoneBoardRobot create(EntityRobotBase robot); + + public abstract ResourceLocation getRobotTexture(); + +} diff --git a/src/api/java/buildcraft/api/boards/package-info.java b/src/api/java/buildcraft/api/boards/package-info.java new file mode 100755 index 000000000..6253f5b79 --- /dev/null +++ b/src/api/java/buildcraft/api/boards/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|boards") +package buildcraft.api.boards; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/APIHelper.java b/src/api/java/buildcraft/api/core/APIHelper.java similarity index 90% rename from src/api/java/buildcraft/api/APIHelper.java rename to src/api/java/buildcraft/api/core/APIHelper.java index dd47dcc7c..9d8613201 100755 --- a/src/api/java/buildcraft/api/APIHelper.java +++ b/src/api/java/buildcraft/api/core/APIHelper.java @@ -1,4 +1,8 @@ -package buildcraft.api; +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.core; import java.util.Arrays; @@ -7,8 +11,6 @@ import org.apache.commons.lang3.StringUtils; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.LoaderState; -import buildcraft.api.core.BCLog; - public class APIHelper { public static T getInstance(String clsName, Class baseVersion) { return getNamedInstance(clsName, "INSTANCE", baseVersion); diff --git a/src/api/java/buildcraft/api/core/BCDebugging.java b/src/api/java/buildcraft/api/core/BCDebugging.java new file mode 100755 index 000000000..3badeb901 --- /dev/null +++ b/src/api/java/buildcraft/api/core/BCDebugging.java @@ -0,0 +1,112 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.core; + +import java.util.Locale; + +import net.minecraft.world.World; + +/** Provides a way to quickly enable or disable certain debug conditions via VM arguments or whether the client/server + * is in a dev environment */ +public class BCDebugging { + public enum DebugStatus { + NONE, + ENABLE, + LOGGING_ONLY, + ALL; + } + + enum DebugLevel { + LOG, + COMPLEX; + + final String name = name().toLowerCase(Locale.ROOT); + boolean isAllOn; + } + + private static final DebugStatus DEBUG_STATUS; + + static { + // Basically we enable debugging for the dev-environment, and disable everything for normal players. + // However if you provide VM arguments then the behaviour changes somewhat: + // (VM argument is "-Dbuildcraft.debug=...") + // - "enable" Enables debugging even if you are not in a dev environment + // - "disable" Disables ALL debugging (and doesn't output any messages even in the dev environment) + // - "log" Major debug options are turned on. Registry setup + API usage etc + // - "all" All possible debug options are turned on. Lots of spam. Not recommended. + + String value = System.getProperty("buildcraft.debug"); + if ("enable".equals(value)) DEBUG_STATUS = DebugStatus.ENABLE; + else if ("all".equals(value)) DEBUG_STATUS = DebugStatus.ALL; + else if ("disable".equals(value)) { + // let people disable the messages if they are in a dev environment but don't want messages. + DEBUG_STATUS = DebugStatus.NONE; + } else if ("log".equals(value)) { + // Some debugging options are more than just logging, so we will differentiate between them + DEBUG_STATUS = DebugStatus.LOGGING_ONLY; + } else if (World.class.getName().contains("World")) { + // Dev environment + DEBUG_STATUS = DebugStatus.ENABLE; + } else { + // Most likely a built jar - don't spam people with info they probably don't need + DEBUG_STATUS = DebugStatus.NONE; + } + + if (DEBUG_STATUS == DebugStatus.ALL) { + BCLog.logger.info("[debugger] Debugging automatically enabled for ALL of buildcraft. Prepare for log spam."); + } else if (DEBUG_STATUS == DebugStatus.LOGGING_ONLY) { + BCLog.logger.info("[debugger] Debugging automatically enabled for some non-spammy parts of buildcraft."); + } else if (DEBUG_STATUS == DebugStatus.ENABLE) { + BCLog.logger.info("[debugger] Debugging not automatically enabled for all of buildcraft. Logging all possible debug options."); + BCLog.logger.info(" To enable it for only logging messages add \"-Dbuildcraft.debug=log\" to your launch VM arguments"); + BCLog.logger.info(" To enable it for ALL debugging \"-Dbuildcraft.debug=all\" to your launch VM arguments"); + BCLog.logger.info(" To remove this message and all future ones add \"-Dbuildcraft.debug=disable\" to your launch VM arguments"); + } + + DebugLevel.COMPLEX.isAllOn = DEBUG_STATUS == DebugStatus.ALL; + DebugLevel.LOG.isAllOn = DEBUG_STATUS == DebugStatus.ALL || DEBUG_STATUS == DebugStatus.LOGGING_ONLY; + } + + public static boolean shouldDebugComplex(String string) { + return shouldDebug(string, DebugLevel.COMPLEX); + } + + public static boolean shouldDebugLog(String string) { + return shouldDebug(string, DebugLevel.LOG); + } + + private static boolean shouldDebug(String option, DebugLevel type) { + String prop = getProp(option); + String actual = System.getProperty(prop); + if ("false".equals(actual)) { + BCLog.logger.info("[debugger] Debugging manually disabled for \"" + option + "\" (" + type + ")."); + return false; + } else if ("true".equals(actual)) { + BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ")."); + return true; + } + if (type.isAllOn) { + BCLog.logger.info("[debugger] Debugging automatically enabled for \"" + option + "\" (" + type + ")."); + return true; + } + if ("complex".equals(actual) || type.name.equals(actual)) { + BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ")."); + return true; + } else { + StringBuilder log = new StringBuilder(); + log.append("[debugger] To enable debugging for "); + log.append(option); + log.append(" add the option \"-D"); + log.append(prop); + log.append("=true\" to your launch config as a VM argument (" + type + ")."); + BCLog.logger.info(log); + } + return false; + } + + private static String getProp(String string) { + return "buildcraft." + string + ".debug"; + } +} diff --git a/src/api/java/buildcraft/api/core/EnumPipePart.java b/src/api/java/buildcraft/api/core/EnumPipePart.java index a805d3ef6..13b1ffc3f 100755 --- a/src/api/java/buildcraft/api/core/EnumPipePart.java +++ b/src/api/java/buildcraft/api/core/EnumPipePart.java @@ -1,17 +1,17 @@ package buildcraft.api.core; -import io.netty.buffer.ByteBuf; - import java.util.Locale; import java.util.Map; +import com.google.common.collect.Maps; + import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTPrimitive; import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; -import com.google.common.collect.Maps; +import io.netty.buffer.ByteBuf; public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 { DOWN(EnumFacing.DOWN), @@ -24,6 +24,7 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 facingMap = Maps.newEnumMap(EnumFacing.class); private static final Map nameMap = Maps.newHashMap(); private static final int MAX_VALUES = values().length; @@ -47,12 +48,12 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8= MAX_VALUES) return EnumPipePart.CENTER; - return values()[meta]; + return VALUES[meta]; } private EnumPipePart(EnumFacing face) { @@ -100,7 +101,7 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 6) return CENTER; return values()[ord]; } diff --git a/src/api/java/buildcraft/api/core/IBCFakePlayer.java b/src/api/java/buildcraft/api/core/IBCFakePlayer.java index bef600f2b..893547214 100755 --- a/src/api/java/buildcraft/api/core/IBCFakePlayer.java +++ b/src/api/java/buildcraft/api/core/IBCFakePlayer.java @@ -4,11 +4,22 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import java.lang.ref.WeakReference; +import com.mojang.authlib.GameProfile; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayer; + public interface IBCFakePlayer { - WeakReference getBuildCraftPlayer(WorldServer world); + + /** Returns the generic buildcraft fake player. Note that you shouldn't use this anymore, as you should store the + * UUID of the real player who created the block or entity that calls this. */ + @Deprecated + FakePlayer getBuildCraftPlayer(WorldServer world); + + /** @param world + * @param profile The owner's profile. + * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this + * player is left around as it holds a reference to the world object. */ + FakePlayer getFakePlayer(WorldServer world, GameProfile profile); } diff --git a/src/api/java/buildcraft/api/core/IBox.java b/src/api/java/buildcraft/api/core/IBox.java index 56007e382..2c6a4a3bb 100755 --- a/src/api/java/buildcraft/api/core/IBox.java +++ b/src/api/java/buildcraft/api/core/IBox.java @@ -14,6 +14,4 @@ public interface IBox extends IZone { BlockPos min(); BlockPos max(); - - void createLaserData(); } diff --git a/src/api/java/buildcraft/api/core/IBuildCraftMod.java b/src/api/java/buildcraft/api/core/IBuildCraftMod.java index c287088b1..d7774c99e 100755 --- a/src/api/java/buildcraft/api/core/IBuildCraftMod.java +++ b/src/api/java/buildcraft/api/core/IBuildCraftMod.java @@ -2,6 +2,7 @@ package buildcraft.api.core; import net.minecraftforge.common.config.Property; +@Deprecated public interface IBuildCraftMod { Property getOption(String name); } diff --git a/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java b/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java new file mode 100755 index 000000000..aba2d8a64 --- /dev/null +++ b/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java @@ -0,0 +1,18 @@ +package buildcraft.api.core; + +import javax.annotation.Nullable; + +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; + +/** A version of {@link IFluidHandler} that can drain a fluid that a fluid filter accepts. */ +public interface IFluidHandlerAdv extends IFluidHandler { + /** Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. + * + * @param filter A filter to filter the possible fluids that can be extracted. + * @param maxDrain The maximum amount of fluid to drain + * @param doDrain If false, drain will only be simulated. + * @return FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained. */ + @Nullable + FluidStack drain(IFluidFilter filter, int maxDrain, boolean doDrain); +} diff --git a/src/api/java/buildcraft/api/core/IIconProvider.java b/src/api/java/buildcraft/api/core/IIconProvider.java deleted file mode 100755 index 0583835a0..000000000 --- a/src/api/java/buildcraft/api/core/IIconProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.core; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IIconProvider { - public TextureAtlasSprite getIcon(int iconIndex); - - @SideOnly(Side.CLIENT) - public void registerIcons(TextureMap iconRegister); -} diff --git a/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java b/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java index de0f99e95..42d0d2469 100755 --- a/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java +++ b/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java @@ -2,6 +2,7 @@ package buildcraft.api.core; import io.netty.buffer.ByteBuf; +@Deprecated public interface INetworkLoadable_BC8 { T readFromByteBuf(ByteBuf buf); diff --git a/src/api/java/buildcraft/api/core/IStackFilter.java b/src/api/java/buildcraft/api/core/IStackFilter.java index ef4f55883..815861c44 100755 --- a/src/api/java/buildcraft/api/core/IStackFilter.java +++ b/src/api/java/buildcraft/api/core/IStackFilter.java @@ -4,11 +4,17 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; /** This interface provides a convenient means of dealing with entire classes of items without having to specify each * item individually. */ public interface IStackFilter { - boolean matches(ItemStack stack); + /** Check to see if a given stack matches this filter. + * + * @param stack The stack to test. stack.isEmpty will always return false. + * @return True if it does match, false otherwise. */ + boolean matches(@Nonnull ItemStack stack); } diff --git a/src/api/java/buildcraft/api/core/Identifier.java b/src/api/java/buildcraft/api/core/Identifier.java deleted file mode 100755 index c74e8df1b..000000000 --- a/src/api/java/buildcraft/api/core/Identifier.java +++ /dev/null @@ -1,234 +0,0 @@ -package buildcraft.api.core; - -import java.util.Map; -import java.util.UUID; - -import com.google.common.base.Supplier; - -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** Identifies an in world tile entity or movable entity. Feel free to extend this class if your tile entity contains - * multiple identifiable {@link IPowerConnection}. Just make sure to register it with - * {@link #registerType(String, Supplier)} to make loading work. - *

- * Created on 1 Jan 2016 by AlexIIL */ -public abstract class Identifier { - private static Map> registeredIdentifiers; - - static { - registeredIdentifiers.put("mincraft:tile", new Supplier() { - @Override - public Identifier get() { - return new Tile(0, null); - } - }); - registeredIdentifiers.put("mincraft:entity", new Supplier() { - @Override - public Identifier get() { - return new MovableEntity(0, null); - } - }); - } - - protected final int dimId; - - public static void registerType(String type, Supplier constructor) { - if (constructor == null) throw new NullPointerException("constructor"); - if (constructor.get() == null) throw new NullPointerException("constructor.get()"); - registeredIdentifiers.put(type, constructor); - } - - public static Identifier getFor(Object obj) { - if (obj == null) throw new NullPointerException("obj"); - if (obj instanceof TileEntity) { - return Tile.create((TileEntity) obj); - } - if (obj instanceof Entity) { - return MovableEntity.create((Entity) obj); - } - if (obj instanceof NBTTagCompound) { - NBTTagCompound nbt = (NBTTagCompound) obj; - String type = nbt.getString("type"); - if (!registeredIdentifiers.containsKey(type)) return null; - return registeredIdentifiers.get(type).get().load(nbt.getCompoundTag("data")); - } - throw new IllegalArgumentException("Unknown type " + obj.getClass()); - } - - public static NBTTagCompound save(Identifier ident) { - NBTTagCompound tag = new NBTTagCompound(); - tag.setString("type", ident.typeId()); - tag.setTag("data", ident.save()); - return tag; - } - - private Identifier(int dimId) { - this.dimId = dimId; - } - - public abstract Object getByIdentifier(MinecraftServer server); - - public abstract boolean isLoaded(MinecraftServer server); - - protected abstract Identifier load(NBTTagCompound tag); - - protected abstract NBTTagCompound save(); - - public abstract String typeId(); - - @SideOnly(Side.CLIENT) - public abstract Object getByIdentifierClient(); - - @SideOnly(Side.CLIENT) - public abstract boolean isLoadedClient(); - - public static class Tile extends Identifier { - private final BlockPos pos; - - public static Tile create(TileEntity tile) { - if (tile.getWorld() == null) throw new NullPointerException("tile.getWorld() for the tile " + tile.getClass()); - if (tile.getPos() == null) throw new NullPointerException("tile.getPos() for the tile " + tile.getClass()); - return new Tile(tile.getWorld().provider.getDimension(), tile.getPos()); - } - - private Tile(int dimId, BlockPos pos) { - super(dimId); - this.pos = pos; - } - - @Override - public Tile load(NBTTagCompound tag) { - int dimId = tag.getInteger("dimId"); - int[] arr = tag.getIntArray("pos"); - if (arr.length == 0) return null; - return new Tile(dimId, new BlockPos(arr[0], arr[1], arr[2])); - } - - @Override - protected NBTTagCompound save() { - NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("dimId", dimId); - tag.setIntArray("pos", new int[] { pos.getX(), pos.getY(), pos.getZ() }); - return tag; - } - - @Override - public String typeId() { - return "minecraft:tile"; - } - - @Override - public TileEntity getByIdentifier(MinecraftServer server) { - World world = server.worldServerForDimension(dimId); - if (world == null) return null; - return world.getTileEntity(pos); - } - - @Override - public boolean isLoaded(MinecraftServer server) { - World world = server.worldServerForDimension(dimId); - if (world == null) return false; - return world.getTileEntity(pos) != null; - } - - @Override - @SideOnly(Side.CLIENT) - public TileEntity getByIdentifierClient() { - World world = Minecraft.getMinecraft().theWorld; - if (world == null || world.provider.getDimension() != dimId) return null; - return world.getTileEntity(pos); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean isLoadedClient() { - World world = Minecraft.getMinecraft().theWorld; - if (world == null || world.provider.getDimension() != dimId) return false; - return world.getTileEntity(pos) != null; - } - - } - - public static class MovableEntity extends Identifier { - private final UUID uniqueId; - - public static MovableEntity create(Entity ent) { - if (ent.getEntityWorld() == null) throw new NullPointerException("ent.getEntityWorld() for the entity " + ent.getClass()); - if (ent.getPersistentID() == null) throw new NullPointerException("ent.getPersistentID() for the entity " + ent.getClass()); - return new MovableEntity(ent.getEntityWorld().provider.getDimension(), ent.getPersistentID()); - } - - private MovableEntity(int dimId, UUID uniqueId) { - super(dimId); - this.uniqueId = uniqueId; - } - - private Entity get(World world) { - for (Entity entity : world.loadedEntityList) { - if (entity.getPersistentID().equals(uniqueId)) { - return entity; - } - } - return null; - } - - @Override - public Entity getByIdentifier(MinecraftServer server) { - World world = server.worldServerForDimension(dimId); - if (world == null || world.provider.getDimension() != dimId) return null; - return get(world); - } - - @Override - public boolean isLoaded(MinecraftServer server) { - World world = server.worldServerForDimension(dimId); - if (world == null || world.provider.getDimension() != dimId) return false; - return get(world) != null; - } - - @Override - @SideOnly(Side.CLIENT) - public Entity getByIdentifierClient() { - World world = Minecraft.getMinecraft().theWorld; - if (world == null || world.provider.getDimension() != dimId) return null; - return get(world); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean isLoadedClient() { - World world = Minecraft.getMinecraft().theWorld; - if (world == null || world.provider.getDimension() != dimId) return false; - return get(world) != null; - } - - @Override - protected MovableEntity load(NBTTagCompound tag) { - int dimId = tag.getInteger("dimId"); - UUID uuid = UUID.fromString(tag.getString("uuid")); - return new MovableEntity(dimId, uuid); - } - - @Override - protected NBTTagCompound save() { - NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("dimId", dimId); - tag.setString("uuid", uniqueId.toString()); - return tag; - } - - @Override - public String typeId() { - return "minecraft:entity"; - } - } -} diff --git a/src/api/java/buildcraft/api/core/SafeTimeTracker.java b/src/api/java/buildcraft/api/core/SafeTimeTracker.java index 9390d87e7..30593bef0 100755 --- a/src/api/java/buildcraft/api/core/SafeTimeTracker.java +++ b/src/api/java/buildcraft/api/core/SafeTimeTracker.java @@ -6,6 +6,7 @@ package buildcraft.api.core; import net.minecraft.world.World; +/** Provides a way of tracking time in the world, without requiring manual ticking. */ public class SafeTimeTracker { private long lastMark = Long.MIN_VALUE; @@ -32,6 +33,7 @@ public class SafeTimeTracker { randomRange = random; } + /** Return true if the internal delay has passed since last time marked was called successfully. */ public boolean markTimeIfDelay(World world) { return markTimeIfDelay(world, internalDelay); } diff --git a/src/api/java/buildcraft/api/core/StackKey.java b/src/api/java/buildcraft/api/core/StackKey.java index 3d2037ee2..d8c2c44cc 100755 --- a/src/api/java/buildcraft/api/core/StackKey.java +++ b/src/api/java/buildcraft/api/core/StackKey.java @@ -9,7 +9,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; /** This class is used whenever stacks needs to be stored as keys. */ @@ -55,7 +54,7 @@ public final class StackKey { } public static StackKey fluid(Fluid fluid) { - return new StackKey(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME)); + return new StackKey(new FluidStack(fluid, 1000)); } public static StackKey fluid(FluidStack fluidStack) { diff --git a/src/api/java/buildcraft/api/core/package-info.java b/src/api/java/buildcraft/api/core/package-info.java index f0b642a91..dde5377cc 100755 --- a/src/api/java/buildcraft/api/core/package-info.java +++ b/src/api/java/buildcraft/api/core/package-info.java @@ -2,7 +2,7 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.1", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") +@API(apiVersion = "2.2", owner = "buildcraftlib", provides = "BuildCraftAPI|core") package buildcraft.api.core; import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/crops/CropManager.java b/src/api/java/buildcraft/api/crops/CropManager.java new file mode 100755 index 000000000..97879829f --- /dev/null +++ b/src/api/java/buildcraft/api/crops/CropManager.java @@ -0,0 +1,86 @@ +package buildcraft.api.crops; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public final class CropManager { + private static List handlers = new ArrayList(); + private static ICropHandler defaultHandler; + + private CropManager() { + + } + + public static void registerHandler(ICropHandler cropHandler) { + handlers.add(cropHandler); + } + + public static void setDefaultHandler(ICropHandler cropHandler) { + defaultHandler = cropHandler; + } + + public static ICropHandler getDefaultHandler() { + return defaultHandler; + } + + public static boolean isSeed(ItemStack stack) { + for (ICropHandler cropHandler : handlers) { + if (cropHandler.isSeed(stack)) { + return true; + } + } + return defaultHandler.isSeed(stack); + } + + public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) { + for (ICropHandler cropHandler : handlers) { + if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos)) { + return true; + } + } + return defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos); + } + + /** Attempts to plant the crop given by the seed into the world. Also checks to make sure that + * {@link ICropHandler#isSeed(ItemStack)} is true, and + * {@link ICropHandler#canSustainPlant(World, ItemStack, BlockPos)} is true for the position. */ + public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos) { + for (ICropHandler cropHandler : handlers) { + if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos) && cropHandler.plantCrop(world, player, seed, pos)) { + return true; + } + } + if (defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos)) { + return defaultHandler.plantCrop(world, player, seed, pos); + } + return false; + } + + public static boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos) { + for (ICropHandler cropHandler : handlers) { + if (cropHandler.isMature(blockAccess, state, pos)) { + return true; + } + } + return defaultHandler.isMature(blockAccess, state, pos); + } + + public static boolean harvestCrop(World world, BlockPos pos, NonNullList drops) { + IBlockState state = world.getBlockState(pos); + for (ICropHandler cropHandler : handlers) { + if (cropHandler.isMature(world, state, pos)) { + return cropHandler.harvestCrop(world, pos, drops); + } + } + return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops); + } + +} diff --git a/src/api/java/buildcraft/api/crops/ICropHandler.java b/src/api/java/buildcraft/api/crops/ICropHandler.java new file mode 100755 index 000000000..6b2324ac8 --- /dev/null +++ b/src/api/java/buildcraft/api/crops/ICropHandler.java @@ -0,0 +1,55 @@ +package buildcraft.api.crops; + +import com.mojang.authlib.GameProfile; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public interface ICropHandler { + + /** Check if an item is a seed. + * + * @param stack + * @return true if the item can be planted. */ + boolean isSeed(ItemStack stack); + + /** Check if the item can be planted. You can assume canSustainPlant() will only be called if isSeed() returned + * true. + * + * @param world + * @param seed + * @param pos + * @return true if the item can be planted at pos. */ + boolean canSustainPlant(World world, ItemStack seed, BlockPos pos); + + /** Plant the item in the block. You can assume plantCrop() will only be called if canSustainPlant() returned true. + * + * @param world + * @param player + * @param seed + * @param pos + * @return true if the item was planted at pos. */ + boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos); + + /** Check if a crop is mature and can be harvested. + * + * @param blockAccess + * @param state + * @param pos + * @return true if the block at pos is mature and can be harvested. */ + boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos); + + /** Harvest the crop. You can assume harvestCrop() will only be called if isMature() returned true. + * + * @param world + * @param pos + * @param drops a list to return the harvest's drops. + * @return true if the block was successfully harvested. */ + boolean harvestCrop(World world, BlockPos pos, NonNullList drops); + +} diff --git a/src/api/java/buildcraft/api/package-info.java b/src/api/java/buildcraft/api/crops/package-info.java similarity index 74% rename from src/api/java/buildcraft/api/package-info.java rename to src/api/java/buildcraft/api/crops/package-info.java index 640f52a7d..803ce050a 100755 --- a/src/api/java/buildcraft/api/package-info.java +++ b/src/api/java/buildcraft/api/crops/package-info.java @@ -2,7 +2,7 @@ * * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") -package buildcraft.api; +@API(apiVersion = "1.1", owner = "BuildCraftAPI|Core", provides = "BuildCraftAPI|crops") +package buildcraft.api.crops; import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java b/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java index 0956fa11e..f161e2ba8 100755 --- a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java +++ b/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java @@ -9,7 +9,10 @@ public enum EnumDecoratedBlock implements IStringSerializable { BLUEPRINT(10), TEMPLATE(10), PAPER(10), - LEATHER(10); + LEATHER(10), + LASER_BACK(0); + + public static final EnumDecoratedBlock[] VALUES = values(); public final int lightValue; @@ -21,4 +24,11 @@ public enum EnumDecoratedBlock implements IStringSerializable { public String getName() { return name().toLowerCase(Locale.ROOT); } + + public static EnumDecoratedBlock fromMeta(int meta) { + if (meta < 0 || meta >= VALUES.length) { + return EnumDecoratedBlock.DESTROY; + } + return VALUES[meta]; + } } diff --git a/src/api/java/buildcraft/api/enums/EnumLaserTableType.java b/src/api/java/buildcraft/api/enums/EnumLaserTableType.java index cc8b41e7d..dbf99a5c7 100755 --- a/src/api/java/buildcraft/api/enums/EnumLaserTableType.java +++ b/src/api/java/buildcraft/api/enums/EnumLaserTableType.java @@ -1,21 +1,13 @@ package buildcraft.api.enums; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.IStringSerializable; -import buildcraft.api.properties.BuildCraftProperties; - public enum EnumLaserTableType implements IStringSerializable { ASSEMBLY_TABLE, ADVANCED_CRAFTING_TABLE, INTEGRATION_TABLE, CHARGING_TABLE, - PROGRAMMING_TABLE, - STAMPING_TABLE; - - public static EnumLaserTableType getType(IBlockState state) { - return (EnumLaserTableType) state.getValue(BuildCraftProperties.LASER_TABLE_TYPE); - } + PROGRAMMING_TABLE; @Override public String getName() { diff --git a/src/api/java/buildcraft/api/enums/EnumEnergyStage.java b/src/api/java/buildcraft/api/enums/EnumPowerStage.java similarity index 76% rename from src/api/java/buildcraft/api/enums/EnumEnergyStage.java rename to src/api/java/buildcraft/api/enums/EnumPowerStage.java index 319b80440..0a88baecd 100755 --- a/src/api/java/buildcraft/api/enums/EnumEnergyStage.java +++ b/src/api/java/buildcraft/api/enums/EnumPowerStage.java @@ -4,7 +4,7 @@ import java.util.Locale; import net.minecraft.util.IStringSerializable; -public enum EnumEnergyStage implements IStringSerializable { +public enum EnumPowerStage implements IStringSerializable { BLUE, GREEN, YELLOW, @@ -12,7 +12,7 @@ public enum EnumEnergyStage implements IStringSerializable { OVERHEAT, BLACK; - public static final EnumEnergyStage[] VALUES = values(); + public static final EnumPowerStage[] VALUES = values(); private final String modelName = name().toLowerCase(Locale.ROOT); diff --git a/src/api/java/buildcraft/api/enums/EnumSpring.java b/src/api/java/buildcraft/api/enums/EnumSpring.java index 85eed2ca0..478b5cae8 100755 --- a/src/api/java/buildcraft/api/enums/EnumSpring.java +++ b/src/api/java/buildcraft/api/enums/EnumSpring.java @@ -1,5 +1,7 @@ package buildcraft.api.enums; +import java.util.Locale; + import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.IStringSerializable; @@ -14,6 +16,7 @@ public enum EnumSpring implements IStringSerializable { public final int tickRate, chance; public IBlockState liquidBlock; public boolean canGen = true; + private final String lowerCaseName = name().toLowerCase(Locale.ROOT); private EnumSpring(int tickRate, int chance, IBlockState liquidBlock) { this.tickRate = tickRate; @@ -27,6 +30,6 @@ public enum EnumSpring implements IStringSerializable { @Override public String getName() { - return this.name(); + return lowerCaseName; } } diff --git a/src/api/java/buildcraft/api/events/BlockInteractionEvent.java b/src/api/java/buildcraft/api/events/BlockInteractionEvent.java new file mode 100755 index 000000000..4a4d8b7bd --- /dev/null +++ b/src/api/java/buildcraft/api/events/BlockInteractionEvent.java @@ -0,0 +1,22 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.events; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class BlockInteractionEvent extends Event { + public final EntityPlayer player; + public final IBlockState state; + + public BlockInteractionEvent(EntityPlayer player, IBlockState state) { + this.player = player; + this.state = state; + } +} diff --git a/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java b/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java new file mode 100755 index 000000000..22a8a74fa --- /dev/null +++ b/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java @@ -0,0 +1,25 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.events; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class BlockPlacedDownEvent extends Event { + public final EntityPlayer player; + public final IBlockState state; + public final BlockPos pos; + + public BlockPlacedDownEvent(EntityPlayer player, BlockPos pos, IBlockState state) { + this.player = player; + this.state = state; + this.pos = pos; + } +} diff --git a/src/api/java/buildcraft/api/events/PipePlacedEvent.java b/src/api/java/buildcraft/api/events/PipePlacedEvent.java new file mode 100755 index 000000000..3664a57d2 --- /dev/null +++ b/src/api/java/buildcraft/api/events/PipePlacedEvent.java @@ -0,0 +1,24 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.events; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.fml.common.eventhandler.Event; + +public class PipePlacedEvent extends Event { + public EntityPlayer player; + public Item pipeType; + public BlockPos pos; + + public PipePlacedEvent(EntityPlayer player, Item pipeType, BlockPos pos) { + this.player = player; + this.pipeType = pipeType; + this.pos = pos; + } + +} diff --git a/src/api/java/buildcraft/api/events/RobotEvent.java b/src/api/java/buildcraft/api/events/RobotEvent.java new file mode 100755 index 000000000..9b12b64d2 --- /dev/null +++ b/src/api/java/buildcraft/api/events/RobotEvent.java @@ -0,0 +1,53 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.events; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +import buildcraft.api.robots.EntityRobotBase; + +public abstract class RobotEvent extends Event { + public final EntityRobotBase robot; + + public RobotEvent(EntityRobotBase robot) { + this.robot = robot; + } + + @Cancelable + public static class Place extends RobotEvent { + public final EntityPlayer player; + + public Place(EntityRobotBase robot, EntityPlayer player) { + super(robot); + this.player = player; + } + } + + @Cancelable + public static class Interact extends RobotEvent { + public final EntityPlayer player; + public final ItemStack item; + + public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) { + super(robot); + this.player = player; + this.item = item; + } + } + + @Cancelable + public static class Dismantle extends RobotEvent { + public final EntityPlayer player; + + public Dismantle(EntityRobotBase robot, EntityPlayer player) { + super(robot); + this.player = player; + } + } +} diff --git a/src/api/java/buildcraft/api/events/RobotPlacementEvent.java b/src/api/java/buildcraft/api/events/RobotPlacementEvent.java new file mode 100755 index 000000000..b0abc44d8 --- /dev/null +++ b/src/api/java/buildcraft/api/events/RobotPlacementEvent.java @@ -0,0 +1,22 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.events; + +import net.minecraft.entity.player.EntityPlayer; + +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; + +@Cancelable +public class RobotPlacementEvent extends Event { + public EntityPlayer player; + public String robotProgram; + + public RobotPlacementEvent(EntityPlayer player, String robotProgram) { + this.player = player; + this.robotProgram = robotProgram; + } + +} diff --git a/src/api/java/buildcraft/api/events/package-info.java b/src/api/java/buildcraft/api/events/package-info.java new file mode 100755 index 000000000..06cd25fea --- /dev/null +++ b/src/api/java/buildcraft/api/events/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|events") +package buildcraft.api.events; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/facades/FacadeAPI.java b/src/api/java/buildcraft/api/facades/FacadeAPI.java new file mode 100755 index 000000000..b3e214ea8 --- /dev/null +++ b/src/api/java/buildcraft/api/facades/FacadeAPI.java @@ -0,0 +1,9 @@ +package buildcraft.api.facades; + +public final class FacadeAPI { + public static IFacadeItem facadeItem; + + private FacadeAPI() { + + } +} diff --git a/src/api/java/buildcraft/api/facades/FacadeType.java b/src/api/java/buildcraft/api/facades/FacadeType.java new file mode 100755 index 000000000..c88d89ff4 --- /dev/null +++ b/src/api/java/buildcraft/api/facades/FacadeType.java @@ -0,0 +1,14 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.facades; + +public enum FacadeType { + Basic, + Phased; + + public static FacadeType fromOrdinal(int ordinal) { + return ordinal == 1 ? Phased : Basic; + } +} diff --git a/src/api/java/buildcraft/api/facades/IFacadeItem.java b/src/api/java/buildcraft/api/facades/IFacadeItem.java new file mode 100755 index 000000000..1fe981a3b --- /dev/null +++ b/src/api/java/buildcraft/api/facades/IFacadeItem.java @@ -0,0 +1,16 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.facades; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +public interface IFacadeItem { + FacadeType getFacadeType(ItemStack facade); + + ItemStack getFacadeForBlock(IBlockState state); + + IBlockState[] getBlockStatesForFacade(ItemStack facade); +} diff --git a/src/api/java/buildcraft/api/facades/package-info.java b/src/api/java/buildcraft/api/facades/package-info.java new file mode 100755 index 000000000..2c79167b3 --- /dev/null +++ b/src/api/java/buildcraft/api/facades/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|facades") +package buildcraft.api.facades; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/filler/FillerManager.java b/src/api/java/buildcraft/api/filler/FillerManager.java new file mode 100755 index 000000000..03567c45a --- /dev/null +++ b/src/api/java/buildcraft/api/filler/FillerManager.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.filler; + +public final class FillerManager { + + public static IFillerRegistry registry; + + /** Deactivate constructor */ + private FillerManager() {} +} diff --git a/src/api/java/buildcraft/api/filler/IFillerPattern.java b/src/api/java/buildcraft/api/filler/IFillerPattern.java new file mode 100755 index 000000000..db52b51f0 --- /dev/null +++ b/src/api/java/buildcraft/api/filler/IFillerPattern.java @@ -0,0 +1,12 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.filler; + +import buildcraft.api.statements.IStatement; + +/** A type of statement that is used for filler patterns. */ +public interface IFillerPattern extends IStatement { + // Object getBlockOverlay(); +} diff --git a/src/api/java/buildcraft/api/filler/IFillerRegistry.java b/src/api/java/buildcraft/api/filler/IFillerRegistry.java new file mode 100755 index 000000000..f9e588f62 --- /dev/null +++ b/src/api/java/buildcraft/api/filler/IFillerRegistry.java @@ -0,0 +1,19 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.filler; + +import java.util.Collection; + +public interface IFillerRegistry { + void addPattern(IFillerPattern pattern); + + IFillerPattern getPattern(String patternName); + + IFillerPattern getNextPattern(IFillerPattern currentPattern); + + IFillerPattern getPreviousPattern(IFillerPattern currentPattern); + + Collection getPatterns(); +} diff --git a/src/api/java/buildcraft/api/filler/package-info.java b/src/api/java/buildcraft/api/filler/package-info.java new file mode 100755 index 000000000..3e9d907de --- /dev/null +++ b/src/api/java/buildcraft/api/filler/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "4.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|filler") +package buildcraft.api.filler; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/fuels/ICoolantManager.java b/src/api/java/buildcraft/api/fuels/ICoolantManager.java index 849bf1acf..fb535c438 100755 --- a/src/api/java/buildcraft/api/fuels/ICoolantManager.java +++ b/src/api/java/buildcraft/api/fuels/ICoolantManager.java @@ -6,7 +6,10 @@ package buildcraft.api.fuels; import java.util.Collection; +import net.minecraft.item.ItemStack; + import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import buildcraft.api.core.StackKey; @@ -17,7 +20,7 @@ public interface ICoolantManager { ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant); - ISolidCoolant addSolidCoolant(StackKey solid, StackKey liquid, float multiplier); + ISolidCoolant addSolidCoolant(ItemStack solid, FluidStack fluid, float multiplier); Collection getCoolants(); @@ -25,5 +28,5 @@ public interface ICoolantManager { ICoolant getCoolant(Fluid fluid); - ISolidCoolant getSolidCoolant(StackKey solid); + ISolidCoolant getSolidCoolant(ItemStack solid); } diff --git a/src/api/java/buildcraft/api/fuels/IFuel.java b/src/api/java/buildcraft/api/fuels/IFuel.java index a2590c608..65891f75a 100755 --- a/src/api/java/buildcraft/api/fuels/IFuel.java +++ b/src/api/java/buildcraft/api/fuels/IFuel.java @@ -9,7 +9,9 @@ import net.minecraftforge.fluids.Fluid; public interface IFuel { Fluid getFluid(); + /** @return The number of ticks that a single bucket (1000mb) of this fuel will burn for. */ int getTotalBurningTime(); - int getPowerPerCycle(); + /** @return The amount (in micro mj) of power that this fuel will give off in 1 tick. */ + long getPowerPerCycle(); } diff --git a/src/api/java/buildcraft/api/fuels/IFuelManager.java b/src/api/java/buildcraft/api/fuels/IFuelManager.java index 367818270..137882139 100755 --- a/src/api/java/buildcraft/api/fuels/IFuelManager.java +++ b/src/api/java/buildcraft/api/fuels/IFuelManager.java @@ -12,9 +12,9 @@ import net.minecraftforge.fluids.FluidStack; public interface IFuelManager { IFuel addFuel(IFuel fuel); - IFuel addFuel(Fluid fluid, int powerPerCycle, int totalBurningTime); + IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime); - IDirtyFuel addDirtyFuel(Fluid fuel, int powerPerCycle, int totalBurningTime, FluidStack residue); + IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); Collection getFuels(); diff --git a/src/api/java/buildcraft/api/gates/IGate.java b/src/api/java/buildcraft/api/gates/IGate.java new file mode 100755 index 000000000..2d9302c3c --- /dev/null +++ b/src/api/java/buildcraft/api/gates/IGate.java @@ -0,0 +1,28 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.gates; + +import java.util.List; + +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementSlot; +import buildcraft.api.statements.containers.ISidedStatementContainer; +import buildcraft.api.transport.pipe.IPipeHolder; + +public interface IGate extends ISidedStatementContainer { + + IPipeHolder getPipeHolder(); + + List getTriggers(); + + List getActions(); + + List getActiveActions(); + + List getTriggerParameters(int slot); + + List getActionParameters(int slot); +} diff --git a/src/api/java/buildcraft/api/gates/package-info.java b/src/api/java/buildcraft/api/gates/package-info.java new file mode 100755 index 000000000..b86ad48bd --- /dev/null +++ b/src/api/java/buildcraft/api/gates/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") +package buildcraft.api.gates; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/items/IList.java b/src/api/java/buildcraft/api/items/IList.java index 4e9c1bc17..1456d2468 100755 --- a/src/api/java/buildcraft/api/items/IList.java +++ b/src/api/java/buildcraft/api/items/IList.java @@ -1,7 +1,9 @@ package buildcraft.api.items; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; public interface IList extends INamedItem { - boolean matches(ItemStack stackList, ItemStack item); + boolean matches(@Nonnull ItemStack stackList, @Nonnull ItemStack item); } diff --git a/src/api/java/buildcraft/api/items/IMapLocation.java b/src/api/java/buildcraft/api/items/IMapLocation.java index e7b2299b9..b10adecd0 100755 --- a/src/api/java/buildcraft/api/items/IMapLocation.java +++ b/src/api/java/buildcraft/api/items/IMapLocation.java @@ -2,6 +2,8 @@ package buildcraft.api.items; import java.util.List; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -22,7 +24,7 @@ public interface IMapLocation extends INamedItem { public final int meta = ordinal(); - public static MapLocationType getFromStack(ItemStack stack) { + public static MapLocationType getFromStack(@Nonnull ItemStack stack) { int dam = stack.getItemDamage(); if (dam < 0 || dam >= values().length) { return MapLocationType.CLEAN; @@ -30,7 +32,7 @@ public interface IMapLocation extends INamedItem { return values()[dam]; } - public void setToStack(ItemStack stack) { + public void setToStack(@Nonnull ItemStack stack) { stack.setItemDamage(meta); } } @@ -39,29 +41,29 @@ public interface IMapLocation extends INamedItem { * * @param stack * @return The point representing the map location. */ - BlockPos getPoint(ItemStack stack); + BlockPos getPoint(@Nonnull ItemStack stack); /** This function can be used for SPOT and AREA types. * * @param stack * @return The box representing the map location. */ - IBox getBox(ItemStack stack); + IBox getBox(@Nonnull ItemStack stack); /** This function can be used for SPOT, AREA and ZONE types. The PATH type needs to be handled separately. * * @param stack * @return An IZone representing the map location - also an instance of IBox for SPOT and AREA types. */ - IZone getZone(ItemStack stack); + IZone getZone(@Nonnull ItemStack stack); /** This function can be used for SPOT and PATH types. * * @param stack * @return A list of BlockPoses representing the path the Map Location stores. */ - List getPath(ItemStack stack); + List getPath(@Nonnull ItemStack stack); /** This function can be used for SPOT types only. * * @param stack * @return The side of the spot. */ - EnumFacing getPointSide(ItemStack stack); + EnumFacing getPointSide(@Nonnull ItemStack stack); } diff --git a/src/api/java/buildcraft/api/items/INamedItem.java b/src/api/java/buildcraft/api/items/INamedItem.java index 4080dae2f..87c342075 100755 --- a/src/api/java/buildcraft/api/items/INamedItem.java +++ b/src/api/java/buildcraft/api/items/INamedItem.java @@ -1,9 +1,11 @@ package buildcraft.api.items; +import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; public interface INamedItem { - String getName(ItemStack stack); + String getName(@Nonnull ItemStack stack); - boolean setName(ItemStack stack, String name); + boolean setName(@Nonnull ItemStack stack, String name); } diff --git a/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java b/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java new file mode 100755 index 000000000..8616d10fe --- /dev/null +++ b/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java @@ -0,0 +1,18 @@ +package buildcraft.api.library; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public interface ILibraryTypeHandler { + boolean isHandler(ItemStack stack, boolean store); + + String getFileExtension(); + + int getTextColor(); + + String getName(ItemStack stack); + + ItemStack load(ItemStack stack, NBTTagCompound compound); + + boolean store(ItemStack stack, NBTTagCompound compound); +} diff --git a/src/api/java/buildcraft/api/library/LibraryAPI.java b/src/api/java/buildcraft/api/library/LibraryAPI.java new file mode 100755 index 000000000..b3b1e84f8 --- /dev/null +++ b/src/api/java/buildcraft/api/library/LibraryAPI.java @@ -0,0 +1,30 @@ +package buildcraft.api.library; + +import java.util.HashSet; +import java.util.Set; + +@Deprecated +public final class LibraryAPI { + private static final Set handlers = new HashSet(); + + private LibraryAPI() { + + } + + public static Set getHandlerSet() { + return handlers; + } + + public static void registerHandler(LibraryTypeHandler handler) { + handlers.add(handler); + } + + public static LibraryTypeHandler getHandlerFor(String extension) { + for (LibraryTypeHandler h : handlers) { + if (h.isInputExtension(extension)) { + return h; + } + } + return null; + } +} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandler.java b/src/api/java/buildcraft/api/library/LibraryTypeHandler.java new file mode 100755 index 000000000..08db4f6f3 --- /dev/null +++ b/src/api/java/buildcraft/api/library/LibraryTypeHandler.java @@ -0,0 +1,31 @@ +package buildcraft.api.library; + +import net.minecraft.item.ItemStack; + +@Deprecated +public abstract class LibraryTypeHandler { + public enum HandlerType { + LOAD, + STORE + } + + private final String extension; + + public LibraryTypeHandler(String extension) { + this.extension = extension; + } + + public abstract boolean isHandler(ItemStack stack, HandlerType type); + + public boolean isInputExtension(String ext) { + return extension.equals(ext); + } + + public String getOutputExtension() { + return extension; + } + + public abstract int getTextColor(); + + public abstract String getName(ItemStack stack); +} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java b/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java new file mode 100755 index 000000000..c7c5e2317 --- /dev/null +++ b/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java @@ -0,0 +1,13 @@ +package buildcraft.api.library; + +import net.minecraft.item.ItemStack; + +public abstract class LibraryTypeHandlerByteArray extends LibraryTypeHandler { + public LibraryTypeHandlerByteArray(String extension) { + super(extension); + } + + public abstract ItemStack load(ItemStack stack, byte[] data); + + public abstract byte[] store(ItemStack stack); +} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java b/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java new file mode 100755 index 000000000..a656ff7c7 --- /dev/null +++ b/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java @@ -0,0 +1,14 @@ +package buildcraft.api.library; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public abstract class LibraryTypeHandlerNBT extends LibraryTypeHandler { + public LibraryTypeHandlerNBT(String extension) { + super(extension); + } + + public abstract ItemStack load(ItemStack stack, NBTTagCompound nbt); + + public abstract boolean store(ItemStack stack, NBTTagCompound nbt); +} diff --git a/src/api/java/buildcraft/api/library/package-info.java b/src/api/java/buildcraft/api/library/package-info.java new file mode 100755 index 000000000..e41a0dc0f --- /dev/null +++ b/src/api/java/buildcraft/api/library/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|library") +package buildcraft.api.library; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/lists/ListMatchHandler.java b/src/api/java/buildcraft/api/lists/ListMatchHandler.java new file mode 100755 index 000000000..339176ed9 --- /dev/null +++ b/src/api/java/buildcraft/api/lists/ListMatchHandler.java @@ -0,0 +1,28 @@ +package buildcraft.api.lists; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +public abstract class ListMatchHandler { + public enum Type { + TYPE, + MATERIAL, + CLASS + } + + public abstract boolean matches(Type type, @Nonnull ItemStack stack, @Nonnull ItemStack target, boolean precise); + + public abstract boolean isValidSource(Type type, @Nonnull ItemStack stack); + + /** Get custom client examples. + * + * @param type + * @param stack + * @return A List (even empty!) if the examples satisfy this handler, null if iteration and .matches should be used + * instead. */ + public NonNullList getClientExamples(Type type, @Nonnull ItemStack stack) { + return null; + } +} diff --git a/src/api/java/buildcraft/api/lists/ListRegistry.java b/src/api/java/buildcraft/api/lists/ListRegistry.java new file mode 100755 index 000000000..1f3655244 --- /dev/null +++ b/src/api/java/buildcraft/api/lists/ListRegistry.java @@ -0,0 +1,26 @@ +package buildcraft.api.lists; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.Item; + +public final class ListRegistry { + public static final List> itemClassAsType = new ArrayList>(); + private static final List handlers = new ArrayList(); + + private ListRegistry() { + + } + + public static void registerHandler(ListMatchHandler h) { + if (h != null) { + handlers.add(h); + } + } + + public static List getHandlers() { + return Collections.unmodifiableList(handlers); + } +} diff --git a/src/api/java/buildcraft/api/lists/package-info.java b/src/api/java/buildcraft/api/lists/package-info.java new file mode 100755 index 000000000..603c33587 --- /dev/null +++ b/src/api/java/buildcraft/api/lists/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|lists") +package buildcraft.api.lists; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/mj/ILaserTarget.java b/src/api/java/buildcraft/api/mj/ILaserTarget.java new file mode 100755 index 000000000..26adb399c --- /dev/null +++ b/src/api/java/buildcraft/api/mj/ILaserTarget.java @@ -0,0 +1,26 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.mj; + +/** This interface should be defined by any Tile which wants to receive power from BuildCraft lasers. + * + * The respective Block MUST implement ILaserTargetBlock! */ +public interface ILaserTarget { + + /** Returns true if the target currently needs power. For example, if the Advanced Crafting Table has work to do. + * + * @return true if needs power */ + boolean requiresLaserPower(); + + /** Transfers power from the laser to the target. + * + * @param microJoules The number of micro Minecraft Joules to accept */ + void receiveLaserPower(long microJoules); + + /** Return true if the Tile Entity object is no longer a valid target. For example, if its been invalidated. + * + * @return true if no longer a valid target object */ + boolean isInvalidTarget(); +} diff --git a/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java b/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java new file mode 100755 index 000000000..3e511f7d5 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java @@ -0,0 +1,12 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.mj; + +/** This is a marker interface for laser targets. Implement it on your Block. + * + * It is used by BuildCraft Lasers for optimization purposes. */ +public interface ILaserTargetBlock { + +} diff --git a/src/api/java/buildcraft/api/mj/IMjConnector.java b/src/api/java/buildcraft/api/mj/IMjConnector.java new file mode 100755 index 000000000..3c5f997a3 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjConnector.java @@ -0,0 +1,15 @@ +package buildcraft.api.mj; + +import javax.annotation.Nonnull; + +/** Signifies that this should visibly connect to other Mj handling entities/tiles. This should NEVER be the tile + * entity, but an encapsulated class that refers back to it. Use {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} to access + * this. */ +public interface IMjConnector { + /** Checks to see if this connector can connect to the other connector. By default this should check that the other + * connector is the same power system. + * + * @param other + * @return */ + boolean canConnect(@Nonnull IMjConnector other); +} diff --git a/src/api/java/buildcraft/api/mj/IMjEffectManager.java b/src/api/java/buildcraft/api/mj/IMjEffectManager.java new file mode 100755 index 000000000..c7fb899b0 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjEffectManager.java @@ -0,0 +1,15 @@ +package buildcraft.api.mj; + +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +/** Various effects for showing power loss visibly, and for large amounts of power, causes some damage to nearby + * entities. */ +public interface IMjEffectManager { + void createPowerLossEffect(World world, Vec3d center, long microJoulesLost); + + void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost); + + void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost); +} diff --git a/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java b/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java new file mode 100755 index 000000000..55b33c685 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java @@ -0,0 +1,11 @@ +package buildcraft.api.mj; + +/** Designates a machine that provides power passively- it does not attempt to manually output its power (like an + * engine). Power can be extracted from this by powered wooden kinesis pipes, for example. */ +public interface IMjPassiveProvider extends IMjConnector { + /** Attempts to extract power from this provider + * + * @param simulate + * @return Either 0, min, max, or a value between min and max. */ + long extractPower(long min, long max, boolean simulate); +} diff --git a/src/api/java/buildcraft/api/mj/IMjReadable.java b/src/api/java/buildcraft/api/mj/IMjReadable.java new file mode 100755 index 000000000..616592263 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjReadable.java @@ -0,0 +1,8 @@ +package buildcraft.api.mj; + +/** Indicates an MJ consumer that has readable information. */ +public interface IMjReadable extends IMjConnector { + long getStored(); + + long getCapacity(); +} diff --git a/src/api/java/buildcraft/api/mj/IMjReceiver.java b/src/api/java/buildcraft/api/mj/IMjReceiver.java new file mode 100755 index 000000000..fe9eadd0b --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjReceiver.java @@ -0,0 +1,19 @@ +package buildcraft.api.mj; + +/** Designates a machine that can receive power. */ +public interface IMjReceiver extends IMjConnector { + /** @return The number of microjoules that this receiver currently wants, and can accept. */ + long getPowerRequested(); + + /** Receives power. You are encouraged to either: + *

    + *
  • Use up all power immediately, or when you next tick. + *
  • Store all power in something like an {@link MjBattery} for later usage. + *
  • Refuse all power (if you have no more work to do or your {@link MjBattery} is full). + *
+ * + * @param microJoules The number of micro joules to add. + * @param simulate If true then just pretend you received power- don't actually change any of your internal state. + * @return The excess power. */ + long receivePower(long microJoules, boolean simulate); +} diff --git a/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java b/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java new file mode 100755 index 000000000..11eb5de63 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java @@ -0,0 +1,4 @@ +package buildcraft.api.mj; + +/** Designates that a receiver can receive redstone power (cheap, free, small amounts) */ +public interface IMjRedstoneReceiver extends IMjReceiver {} diff --git a/src/api/java/buildcraft/api/mj/MjAPI.java b/src/api/java/buildcraft/api/mj/MjAPI.java new file mode 100755 index 000000000..8bf317e1f --- /dev/null +++ b/src/api/java/buildcraft/api/mj/MjAPI.java @@ -0,0 +1,184 @@ +package buildcraft.api.mj; + +import java.text.DecimalFormat; +import java.util.concurrent.Callable; + +import javax.annotation.Nonnull; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.CapabilityManager; + +import buildcraft.api.core.APIHelper; + +public class MjAPI { + + // ################################ + // + // Useful constants (Public API) + // + // ################################ + + /** A single minecraft joule, in micro joules (the power system base unit) */ + public static final long ONE_MINECRAFT_JOULE = 1 * 1000L * 1000L; + /** The same as {@link #ONE_MINECRAFT_JOULE}, but a shorter field name */ + public static final long MJ = ONE_MINECRAFT_JOULE; + + /** The decimal format used to display values of MJ to the player. Note that this */ + public static final DecimalFormat MJ_DISPLAY_FORMAT = new DecimalFormat("###0.##"); + + public static final IMjEffectManager EFFECT_MANAGER = APIHelper.getInstance("", IMjEffectManager.class, NullaryEffectManager.INSTANCE); + + // ############### + // + // Capabilities + // + // ############### + + @Nonnull + public static final Capability CAP_CONNECTOR; + + @Nonnull + public static final Capability CAP_RECEIVER; + + @Nonnull + public static final Capability CAP_REDSTONE_RECEIVER; + + @Nonnull + public static final Capability CAP_READABLE; + + @Nonnull + public static final Capability CAP_PASSIVE_PROVIDER; + + // ############### + // + // Helpful methods + // + // ############### + + /** Formats a given MJ value to a player-oriented string. Note that this does not append "MJ" to the value. */ + public static String formatMj(long microMj) { + return formatMjInternal(microMj / (double) MJ); + } + + /** Formats a given MJ value to a player-oriented string. Note that this DOES append "*MJ" to the value. This does + * however shorten it down to a small length, and displays "µ", "m", "K" or "M" or "G" before the MJ depending on + * how big or small the value is. */ + public static String formatMjShort(long microJoules) { + if (microJoules == 0) { + return "0 Mj"; + } + long limit = 1; + final long nextUnitCap = 800; + if (microJoules < nextUnitCap * limit) {// micro MJ + return formatMjInternal(microJoules) + " µMJ"; + } + limit *= 1000; + if (microJoules < nextUnitCap * limit) { // milli MJ + return formatMjInternal(microJoules / (double) limit) + " mMJ"; + } + limit *= 1000; + if (microJoules < nextUnitCap * limit) { // MJ + return formatMjInternal(microJoules / (double) limit) + " MJ"; + } + limit *= 1000; + if (microJoules < nextUnitCap * limit) {// kilo MJ + return formatMjInternal(microJoules / (double) limit) + " KMJ"; + } + limit *= 1000; + if (microJoules < nextUnitCap * limit) {// mega MJ + return formatMjInternal(microJoules / (double) limit) + " MMJ"; + } + limit *= 1000; + return formatMjInternal(microJoules / (double) limit) + " GMJ"; + } + + // ######################################## + // + // Null based classes + // + // ######################################## + + public enum NullaryEffectManager implements IMjEffectManager { + INSTANCE; + @Override public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {} + @Override public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {} + @Override public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {} + } + // @formatter:on + + // #################### + // + // Internal API logic + // + // ################### + + // Private fields for the registrations -- this allows us to make the actual fields @Nonnull as we check later + @CapabilityInject(IMjConnector.class) + private static final Capability CAP_CONNECTOR_FIRST = null; + + @CapabilityInject(IMjReceiver.class) + private static final Capability CAP_RECEIVER_FIRST = null; + + @CapabilityInject(IMjRedstoneReceiver.class) + private static final Capability CAP_REDSTONE_RECEIVER_FIRST = null; + + @CapabilityInject(IMjReadable.class) + private static final Capability CAP_READABLE_FIRST = null; + + @CapabilityInject(IMjPassiveProvider.class) + private static final Capability CAP_PASSIVE_PROVIDER_FIRST = null; + + static { + registerCapability(IMjConnector.class); + registerCapability(IMjReceiver.class); + registerCapability(IMjRedstoneReceiver.class); + registerCapability(IMjReadable.class); + registerCapability(IMjPassiveProvider.class); + + CAP_CONNECTOR = ensureRegistration(CAP_CONNECTOR_FIRST, IMjConnector.class); + CAP_RECEIVER = ensureRegistration(CAP_RECEIVER_FIRST, IMjReceiver.class); + CAP_REDSTONE_RECEIVER = ensureRegistration(CAP_REDSTONE_RECEIVER_FIRST, IMjRedstoneReceiver.class); + CAP_READABLE = ensureRegistration(CAP_READABLE_FIRST, IMjReadable.class); + CAP_PASSIVE_PROVIDER = ensureRegistration(CAP_PASSIVE_PROVIDER_FIRST, IMjPassiveProvider.class); + } + + private static void registerCapability(Class clazz) { + CapabilityManager.INSTANCE.register(clazz, new VoidStorage(), new Callable() { + // No lambda because of java 6... :( + @Override + public T call() throws Exception { + throw new IllegalStateException("You must create your own instances!"); + } + }); + } + + @Nonnull + private static Capability ensureRegistration(Capability cap, Class clazz) { + if (cap == null) { + throw new Error("Capability registration failed for " + clazz); + } + return cap; + } + + private static class VoidStorage implements Capability.IStorage { + @Override + public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { + throw new IllegalStateException("You must create your own instances!"); + } + + @Override + public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { + throw new IllegalStateException("You must create your own instances!"); + } + } + + private static String formatMjInternal(double val) { + return MJ_DISPLAY_FORMAT.format(val); + } +} diff --git a/src/api/java/buildcraft/api/mj/MjBattery.java b/src/api/java/buildcraft/api/mj/MjBattery.java new file mode 100755 index 000000000..ca86ce1f3 --- /dev/null +++ b/src/api/java/buildcraft/api/mj/MjBattery.java @@ -0,0 +1,116 @@ +package buildcraft.api.mj; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.INBTSerializable; + +import io.netty.buffer.ByteBuf; + +/** Provides a basic implementation of a simple battery. Note that you should call {@link #tick(World, BlockPos)} or + * {@link #tick(World, Vec3d)} every tick to allow for losing excess power. */ +public class MjBattery implements INBTSerializable { + private final long capacity; + private long microJoules = 0; + + public MjBattery(long capacity) { + this.capacity = capacity; + } + + @Override + public NBTTagCompound serializeNBT() { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setLong("stored", microJoules); + return nbt; + } + + @Override + public void deserializeNBT(NBTTagCompound nbt) { + microJoules = nbt.getLong("stored"); + } + + public void writeToBuffer(ByteBuf buffer) { + buffer.writeLong(microJoules); + } + + public void readFromBuffer(ByteBuf buffer) { + microJoules = buffer.readLong(); + } + + public long addPower(long microJoulesToAdd, boolean simulate) { + if (!simulate) { + this.microJoules += microJoulesToAdd; + } + return 0; + } + + /** Attempts to add power, but only if this is not already full. + * + * @param microJoulesToAdd The power to add. + * @return The excess power. */ + public long addPowerChecking(long microJoulesToAdd, boolean simulate) { + if (isFull()) { + return microJoulesToAdd; + } else { + return addPower(microJoulesToAdd, simulate); + } + } + + public long extractAll() { + return extractPower(0, microJoules); + } + + /** Attempts to extract exactly the given amount of power. + * + * @param power The amount of power to extract. + * @return True if the power was removed, false if not. */ + public boolean extractPower(long power) { + return extractPower(power, power) > 0; + } + + public long extractPower(long min, long max) { + if (microJoules < min) return 0; + long extracting = Math.min(microJoules, max); + microJoules -= extracting; + return extracting; + } + + public boolean isFull() { + return microJoules >= capacity; + } + + public long getStored() { + return microJoules; + } + + public long getCapacity() { + return capacity; + } + + public void tick(World world, BlockPos position) { + tick(world, new Vec3d(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5)); + } + + public void tick(World world, Vec3d position) { + if (microJoules > capacity * 2) { + losePower(world, position); + } + } + + protected void losePower(World world, Vec3d position) { + long diff = microJoules - capacity * 2; + long lost = ceilDivide(diff, 32); + microJoules -= lost; + MjAPI.EFFECT_MANAGER.createPowerLossEffect(world, position, lost); + } + + private static long ceilDivide(long val, long by) { + return (val / by) + (val % by == 0 ? 0 : 1); + } + + public String getDebugString() { + return MjAPI.formatMj(microJoules) + " / " + MjAPI.formatMj(capacity) + " MJ"; + } +} diff --git a/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java b/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java new file mode 100755 index 000000000..41f78747d --- /dev/null +++ b/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java @@ -0,0 +1,57 @@ +package buildcraft.api.mj; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; + +/** Provides a quick way to return all types of a single {@link IMjConnector} for all the different capabilities. */ +public class MjCapabilityHelper implements ICapabilityProvider { + + @Nonnull + private final IMjConnector connector; + + @Nullable + private final IMjReceiver receiver; + + @Nullable + private final IMjRedstoneReceiver rsReceiver; + + @Nullable + private final IMjReadable readable; + + @Nullable + private final IMjPassiveProvider provider; + + public MjCapabilityHelper(@Nonnull IMjConnector mj) { + this.connector = mj; + this.receiver = mj instanceof IMjReceiver ? (IMjReceiver) mj : null; + this.rsReceiver = mj instanceof IMjRedstoneReceiver ? (IMjRedstoneReceiver) mj : null; + this.readable = mj instanceof IMjReadable ? (IMjReadable) mj : null; + this.provider = mj instanceof IMjPassiveProvider ? (IMjPassiveProvider) mj : null; + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + if (capability == MjAPI.CAP_CONNECTOR) return true; + if (capability == MjAPI.CAP_RECEIVER) return receiver != null; + if (capability == MjAPI.CAP_REDSTONE_RECEIVER) return rsReceiver != null; + if (capability == MjAPI.CAP_READABLE) return readable != null; + if (capability == MjAPI.CAP_PASSIVE_PROVIDER) return provider != null; + return false; + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + if (capability == MjAPI.CAP_CONNECTOR) return (T) connector; + if (capability == MjAPI.CAP_RECEIVER) return (T) receiver; + if (capability == MjAPI.CAP_REDSTONE_RECEIVER) return (T) rsReceiver; + if (capability == MjAPI.CAP_READABLE) return (T) readable; + if (capability == MjAPI.CAP_PASSIVE_PROVIDER) return (T) provider; + return null; + } + +} diff --git a/src/api/java/buildcraft/api/mj/package-info.java b/src/api/java/buildcraft/api/mj/package-info.java new file mode 100755 index 000000000..c2670e4cf --- /dev/null +++ b/src/api/java/buildcraft/api/mj/package-info.java @@ -0,0 +1,26 @@ +/** Contains the Minecraft Joule API (shortened to Mj), reborn. + *

+ * MJ is stored in the long type, as micro Mj - so you need a long storing a value of 1 million to have a single MJ. All + * power should be passed around in code as micro Mj (10 ^ -6 of an Mj), but shown to the player as full MJ - so divided by 1 + * million. + *

+ * A single MJ as a constant is available in {@link buildcraft.api.mj.MjAPI#ONE_MINECRAFT_JOULE}, and two player + * formatter's ( {@link buildcraft.api.mj.MjAPI#formatMj(long)}, and {@link buildcraft.api.mj.MjAPI#formatMjShort(long)} + *

+ *

Capability's

+ *

+ * MJ should be exposed from tile entities and entities via the forge capability system as one of the following types: + *

    + *
  • {@link buildcraft.api.mj.IMjConnector} for *anything* that can (potentially) connect to any other Mj type. All + * other types extend this. You should expose this with the capability + * {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR}
  • + *
  • {@link buildcraft.api.mj.IMjReadable} for something that has an internal battery. This is used for adding gate + * triggers. This should be exposed with the capability {@link buildcraft.api.mj.MjAPI#CAP_READABLE}
  • + *
  • {@link buildcraft.api.mj.IMjReceiver} for something that receives power. This should be exposed with the + * capability {@link buildcraft.api.mj.MjAPI#CAP_RECEIVER}
  • + *
+ * Note that you *must* expose the base interface types as capabilities as well as the top type so if you have an + * instance of {@link buildcraft.api.mj.IMjReceiver} then you must return it for both of the capability's + * {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} and {@link buildcraft.api.mj.MjAPI#CAP_RECEIVER}. A simple way to do + * this is provided in {@link buildcraft.api.mj.MjCapabilityHelper}. */ +package buildcraft.api.mj; diff --git a/src/api/java/buildcraft/api/permission/IOwner.java b/src/api/java/buildcraft/api/permission/IOwner.java new file mode 100755 index 000000000..0fa178d2b --- /dev/null +++ b/src/api/java/buildcraft/api/permission/IOwner.java @@ -0,0 +1,24 @@ +package buildcraft.api.permission; + +import java.util.UUID; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.MinecraftServer; + +/** Defines an owner -- this is an actual player in the world, or an offline player. */ +public interface IOwner { + /** Gets the player, if they actually exist on the server */ + @Nullable + EntityPlayer getPlayer(MinecraftServer server); + + /** Gets the player's UUID */ + @Nonnull + UUID getPlayerUUID(); + + /** Gets the player's name. */ + @Nonnull + String getPlayerName(); +} diff --git a/src/api/java/buildcraft/api/permission/IPlayerOwned.java b/src/api/java/buildcraft/api/permission/IPlayerOwned.java new file mode 100755 index 000000000..b6c4350bb --- /dev/null +++ b/src/api/java/buildcraft/api/permission/IPlayerOwned.java @@ -0,0 +1,8 @@ +package buildcraft.api.permission; + +import com.mojang.authlib.GameProfile; + +/** Defines an entity or tile that is owned by a specific player. */ +public interface IPlayerOwned { + GameProfile getOwner(); +} diff --git a/src/api/java/buildcraft/api/power/IEngine.java b/src/api/java/buildcraft/api/power/IEngine.java new file mode 100755 index 000000000..c25037cc4 --- /dev/null +++ b/src/api/java/buildcraft/api/power/IEngine.java @@ -0,0 +1,26 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.power; + +import net.minecraft.util.EnumFacing; + +/** Engines should implement this interface if they want to support BuildCraft's behaviour of passing power between + * engines without using receivePower() (which has other issues). */ +public interface IEngine { + /** Returns true if the engine wants to receive power from another engine on this side. + * + * @param side + * @return */ + boolean canReceiveFromEngine(EnumFacing side); + + /** Receives power from an engine. + * + * @param microJoules The number of micro joules to add. + * @param simulate If true then just pretend you received power- don't actually change any of your internal state. + * @return True if all the power was accepted, false if not. + * + * @see buildcraft.api.mj.IMjReceiver#receivePower(long, boolean) */ + boolean receivePower(long microJoules, boolean simulate); +} diff --git a/src/api/java/buildcraft/api/power/IRedstoneEngine.java b/src/api/java/buildcraft/api/power/IRedstoneEngine.java new file mode 100755 index 000000000..3fc534d45 --- /dev/null +++ b/src/api/java/buildcraft/api/power/IRedstoneEngine.java @@ -0,0 +1,7 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.power; + +public interface IRedstoneEngine {} diff --git a/src/api/java/buildcraft/api/power/package-info.java b/src/api/java/buildcraft/api/power/package-info.java new file mode 100755 index 000000000..c20c3ee4c --- /dev/null +++ b/src/api/java/buildcraft/api/power/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.3", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power") +package buildcraft.api.power; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java b/src/api/java/buildcraft/api/properties/BuildCraftProperties.java index e689a6e1a..d7f883b7b 100755 --- a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java +++ b/src/api/java/buildcraft/api/properties/BuildCraftProperties.java @@ -18,7 +18,7 @@ public final class BuildCraftProperties { public static final BuildCraftProperty ENGINE_TYPE = BuildCraftProperty.create("type", EnumEngineType.class); public static final BuildCraftProperty LASER_TABLE_TYPE = BuildCraftProperty.create("type", EnumLaserTableType.class); public static final BuildCraftProperty MACHINE_STATE = BuildCraftProperty.create("state", EnumMachineState.class); - public static final BuildCraftProperty ENERGY_STAGE = BuildCraftProperty.create("stage", EnumEnergyStage.class); + public static final BuildCraftProperty ENERGY_STAGE = BuildCraftProperty.create("stage", EnumPowerStage.class); public static final BuildCraftProperty BLUEPRINT_TYPE = BuildCraftProperty.create("blueprint_type", EnumBlueprintType.class); public static final BuildCraftProperty DECORATED_BLOCK = BuildCraftProperty.create("decoration_type", EnumDecoratedBlock.class); @@ -29,6 +29,7 @@ public final class BuildCraftProperties { public static final BuildCraftProperty MOVING = BuildCraftProperty.create("moving", false); public static final BuildCraftProperty LED_DONE = BuildCraftProperty.create("led_done", false); public static final BuildCraftProperty ACTIVE = BuildCraftProperty.create("active", false); + public static final BuildCraftProperty VALID = BuildCraftProperty.create("valid", false); public static final BuildCraftProperty CONNECTED_UP = BuildCraftProperty.create("connected_up", false); public static final BuildCraftProperty CONNECTED_DOWN = BuildCraftProperty.create("connected_down", false); diff --git a/src/api/java/buildcraft/api/properties/BuildCraftProperty.java b/src/api/java/buildcraft/api/properties/BuildCraftProperty.java index b768d251a..f13f82c5b 100755 --- a/src/api/java/buildcraft/api/properties/BuildCraftProperty.java +++ b/src/api/java/buildcraft/api/properties/BuildCraftProperty.java @@ -60,7 +60,7 @@ public class BuildCraftProperty> extends PropertyHelper< /** first and last are both inclusive values (use 0, 12, 3 to create an array of [0, 3, 6, 9, 12]) */ public static BuildCraftProperty create(String name, int first, int last, int difference) { int actualDiff = Math.abs(difference); - int number = MathHelper.floor_float(Math.abs(first - last) / (float) actualDiff + 1); + int number = MathHelper.floor(Math.abs(first - last) / (float) actualDiff + 1); Integer[] array = new Integer[number]; int addedDiff = actualDiff * (first > last ? -1 : 1); int current = first; diff --git a/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java b/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java new file mode 100755 index 000000000..0baba21c0 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java @@ -0,0 +1,109 @@ +package buildcraft.api.recipes; + +import java.io.IOException; +import java.util.Iterator; + +import com.google.common.collect.ImmutableSet; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.NonNullList; + +import net.minecraftforge.common.util.Constants; + +/** Provides an immutable assembly recipe */ +public final class AssemblyRecipe { + public final long requiredMicroJoules; + public final ImmutableSet requiredStacks; + public final ItemStack output; + + public AssemblyRecipe(long requiredMicroJoules, ImmutableSet requiredStacks, ItemStack output) { + this.requiredMicroJoules = requiredMicroJoules; + this.requiredStacks = requiredStacks; + this.output = output; + } + + public AssemblyRecipe(NBTTagCompound nbt) { + requiredMicroJoules = nbt.getLong("required_micro_joules"); + NBTTagList requiredStacksTag = nbt.getTagList("required_stacks", Constants.NBT.TAG_COMPOUND); + NonNullList requiredStacksArray = NonNullList.withSize(requiredStacksTag.tagCount(), ItemStack.EMPTY); + for(int i = 0; i < requiredStacksTag.tagCount(); i++) { + requiredStacksArray.set(i, new ItemStack(requiredStacksTag.getCompoundTagAt(i))); + } + requiredStacks = ImmutableSet.copyOf(requiredStacksArray); + output = new ItemStack(nbt.getCompoundTag("output")); + } + + public AssemblyRecipe(PacketBuffer buffer) throws IOException { + requiredMicroJoules = buffer.readLong(); + int count = buffer.readInt(); + NonNullList requiredStacksArray = NonNullList.withSize(count, ItemStack.EMPTY); + for(int i = 0; i < count; i++) { + requiredStacksArray.set(i, buffer.readItemStack()); + } + requiredStacks = ImmutableSet.copyOf(requiredStacksArray); + output = buffer.readItemStack(); + } + + public NBTTagCompound writeToNBT() { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setLong("required_micro_joules", requiredMicroJoules); + NBTTagList requiredStacksTag = new NBTTagList(); + for(ItemStack requiredStack : requiredStacks) { + requiredStacksTag.appendTag(requiredStack.serializeNBT()); + } + nbt.setTag("required_stacks", requiredStacksTag); + nbt.setTag("output", output.serializeNBT()); + return nbt; + } + + public void writeToBuffer(PacketBuffer buffer) { + buffer.writeLong(requiredMicroJoules); + buffer.writeInt(requiredStacks.size()); + requiredStacks.forEach(buffer::writeItemStack); + buffer.writeItemStack(output); + } + + @Override + public boolean equals(Object o) { + if(this == o) { + return true; + } + if(o == null || getClass() != o.getClass()) { + return false; + } + + AssemblyRecipe that = (AssemblyRecipe) o; + + if(requiredMicroJoules != that.requiredMicroJoules) { + return false; + } + if(requiredStacks != null && that.requiredStacks != null) { + Iterator iterator1 = requiredStacks.iterator(); + Iterator iterator2 = that.requiredStacks.iterator(); + while(iterator1.hasNext()) { + if (!iterator2.hasNext()) { + return false; + } + ItemStack o1 = iterator1.next(); + ItemStack o2 = iterator2.next(); + if (!ItemStack.areItemStacksEqual(o1, o2)) { + return false; + } + } + return !iterator2.hasNext() && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; + } else { + return requiredStacks == null && that.requiredStacks == null && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; + } + } + + @Override + public int hashCode() { + int result = (int) (requiredMicroJoules ^ (requiredMicroJoules >>> 32)); + result = 31 * result + (requiredStacks != null ? requiredStacks.hashCode() : 0); + result = 31 * result + (output != null ? output.hashCode() : 0); + return result; + } +} diff --git a/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java new file mode 100755 index 000000000..fd0838ab5 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java @@ -0,0 +1,14 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.recipes; + +public final class BuildcraftRecipeRegistry { + + public static IAssemblyRecipeRegistry assemblyRecipes; + public static IIntegrationRecipeRegistry integrationRecipes; + public static IComplexRefineryRecipeManager complexRefinery; + + private BuildcraftRecipeRegistry() {} +} diff --git a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java new file mode 100755 index 000000000..4e051d78d --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java @@ -0,0 +1,20 @@ +package buildcraft.api.recipes; + +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +/** Provides a way of registering complex recipes without needing to register every possible variant. If you want the + * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class + * IAssemblyRecipeViewable. */ +public interface IAssemblyRecipeProvider { + + /** Should return a list of all the valid recipes given the input items. The list may be empty, but must not be + * null. Note that this will *most likely* be slow to check everything, so you should cache the return value and + * re-use it when you can. */ + @Nonnull + List getRecipesFor(@Nonnull NonNullList possibleIn); +} diff --git a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java new file mode 100755 index 000000000..9665f40d7 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java @@ -0,0 +1,19 @@ +package buildcraft.api.recipes; + +import java.util.Iterator; + +import javax.annotation.Nonnull; + +public interface IAssemblyRecipeRegistry extends IAssemblyRecipeProvider { + void addRecipe(@Nonnull AssemblyRecipe recipe); + + void addRecipeProvider(@Nonnull IAssemblyRecipeProvider provider); + + /** Gets all of the simple recipes that are registered. Note that you *can* use the returned iterator's + * {@link Iterator#remove()} method to remove recipes from this registry. */ + Iterable getAllRecipes(); + + /** Gets all of the complex recipe providers that are registered. Note that you *can* use the returned iterator's + * {@link Iterator#remove()} method to remove providers from this registry. */ + Iterable getAllRecipeProviders(); +} diff --git a/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java b/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java new file mode 100755 index 000000000..5623b5eaa --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java @@ -0,0 +1,66 @@ +package buildcraft.api.recipes; + +import java.util.Set; + +import com.google.common.base.Predicate; + +import net.minecraftforge.fluids.FluidStack; + +public interface IComplexRefineryRecipeManager { + IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks); + + IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting); + + ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks); + + ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting); + + IDistilationRecipe createDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks); + + IDistilationRecipe addDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks, boolean replaceExisting); + + IComplexRefineryRegistry getHeatableRegistry(); + + IComplexRefineryRegistry getCoolableRegistry(); + + IComplexRefineryRegistry getDistilationRegistry(); + + public interface IComplexRefineryRegistry { + /** @return an unmodifiable set containing all of the distilation recipies that satisfy the given predicate. All + * of the recipe objects are guarenteed to never be null. */ + Set getRecipes(Predicate toReturn); + + /** @return an unmodifiable set containing all of the distilation recipies. */ + Set getAllRecipes(); + + R getRecipeForInput(FluidStack fluid); + + Set removeRecipes(Predicate toRemove); + + R addRecipe(R recipe, boolean replaceExisting); + } + + public interface IComplexRefineryRecipe { + int ticks(); + + FluidStack in(); + } + + public interface IHeatExchangerRecipe extends IComplexRefineryRecipe { + FluidStack out(); + + int heatFrom(); + + int heatTo(); + } + + public interface IHeatableRecipe extends IHeatExchangerRecipe {} + + public interface ICoolableRecipe extends IHeatExchangerRecipe {} + + public interface IDistilationRecipe extends IComplexRefineryRecipe { + FluidStack outGas(); + + FluidStack outLiquid(); + } +} diff --git a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java new file mode 100755 index 000000000..77b1cfc22 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java @@ -0,0 +1,20 @@ +package buildcraft.api.recipes; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +/** Provides a way of registering complex recipes without needing to register every possible variant. If you want the + * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class + * IIntegrationRecipeViewable. */ +public interface IIntegrationRecipeProvider { + /** Gets an integration recipe for the given ingredients. + * + * @param target The center itemstack. + * @param toIntegrate A list of stacks to try to integrate to the + * @return */ + @Nullable + IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate); +} diff --git a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java new file mode 100755 index 000000000..7e4c55b72 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java @@ -0,0 +1,17 @@ +package buildcraft.api.recipes; + +import java.util.Iterator; + +public interface IIntegrationRecipeRegistry extends IIntegrationRecipeProvider { + void addRecipe(IntegrationRecipe recipe); + + void addRecipeProvider(IIntegrationRecipeProvider provider); + + /** Gets all of the simple recipes that are registered. Note that you *can* use the returned iterator's + * {@link Iterator#remove()} method to remove recipes from this registry. */ + Iterable getAllRecipes(); + + /** Gets all of the complex recipe providers that are registered. Note that you *can* use the returned iterator's + * {@link Iterator#remove()} method to remove providers from this registry. */ + Iterable getAllRecipeProviders(); +} diff --git a/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java b/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java new file mode 100755 index 000000000..afaac2dd8 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java @@ -0,0 +1,120 @@ +package buildcraft.api.recipes; + +import java.io.IOException; +import java.util.Iterator; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.NonNullList; + +import net.minecraftforge.common.util.Constants; + +public final class IntegrationRecipe { + public final long requiredMicroJoules; + public final @Nonnull ItemStack target; + public final NonNullList toIntegrate; + public final ItemStack output; + + public IntegrationRecipe(long requiredMicroJoules, @Nonnull ItemStack target, NonNullList toIntegrate, ItemStack output) { + this.requiredMicroJoules = requiredMicroJoules; + this.target = target; + this.toIntegrate = toIntegrate; + this.output = output; + } + + public IntegrationRecipe(NBTTagCompound nbt) { + requiredMicroJoules = nbt.getLong("required_micro_joules"); + target = new ItemStack(nbt.getCompoundTag("target")); + NBTTagList toIntegrateTag = nbt.getTagList("to_integrate", Constants.NBT.TAG_COMPOUND); + toIntegrate = NonNullList.withSize(toIntegrateTag.tagCount(), ItemStack.EMPTY); + for (int i = 0; i < toIntegrateTag.tagCount(); i++) { + toIntegrate.set(i, new ItemStack(toIntegrateTag.getCompoundTagAt(i))); + } + output = new ItemStack(nbt.getCompoundTag("output")); + } + + public IntegrationRecipe(PacketBuffer buffer) throws IOException { + requiredMicroJoules = buffer.readLong(); + ItemStack stack = buffer.readItemStack(); + if (stack == null) throw new NullPointerException("stack");// should never happen + target = stack; + int count = buffer.readInt(); + toIntegrate = NonNullList.withSize(count, ItemStack.EMPTY); + for (int i = 0; i < count; i++) { + toIntegrate.set(i, buffer.readItemStack()); + } + output = buffer.readItemStack(); + } + + public NBTTagCompound writeToNBT() { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setLong("required_micro_joules", requiredMicroJoules); + nbt.setTag("target", target.serializeNBT()); + NBTTagList toIntegrateTag = new NBTTagList(); + for (ItemStack toIntegrateElement : toIntegrate) { + toIntegrateTag.appendTag(toIntegrateElement.serializeNBT()); + } + nbt.setTag("to_integrate", toIntegrateTag); + nbt.setTag("output", output.serializeNBT()); + return nbt; + } + + public void writeToBuffer(PacketBuffer buffer) { + buffer.writeLong(requiredMicroJoules); + buffer.writeItemStack(target); + buffer.writeInt(toIntegrate.size()); + for (ItemStack stack : toIntegrate) { + buffer.writeItemStack(stack); + } + buffer.writeItemStack(output); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + IntegrationRecipe that = (IntegrationRecipe) o; + + if (requiredMicroJoules != that.requiredMicroJoules) { + return false; + } + if (!ItemStack.areItemStacksEqual(target, that.target)) { + return false; + } + if (toIntegrate != null && that.toIntegrate != null) { + Iterator iterator1 = toIntegrate.iterator(); + Iterator iterator2 = that.toIntegrate.iterator(); + while (iterator1.hasNext()) { + if (!iterator2.hasNext()) { + return false; + } + ItemStack o1 = iterator1.next(); + ItemStack o2 = iterator2.next(); + if (!ItemStack.areItemStacksEqual(o1, o2)) { + return false; + } + } + return !iterator2.hasNext() && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; + } else { + return toIntegrate == null && that.toIntegrate == null && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; + } + } + + @Override + public int hashCode() { + int result = (int) (requiredMicroJoules ^ (requiredMicroJoules >>> 32)); + result = 31 * result + (target != null ? target.hashCode() : 0); + result = 31 * result + (toIntegrate != null ? toIntegrate.hashCode() : 0); + result = 31 * result + (output != null ? output.hashCode() : 0); + return result; + } +} diff --git a/src/api/java/buildcraft/api/recipes/package-info.java b/src/api/java/buildcraft/api/recipes/package-info.java new file mode 100755 index 000000000..f8cc9942a --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|recipes") +package buildcraft.api.recipes; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/robots/AIRobot.java b/src/api/java/buildcraft/api/robots/AIRobot.java new file mode 100755 index 000000000..0fad58245 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/AIRobot.java @@ -0,0 +1,222 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.robots; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import buildcraft.api.mj.MjAPI; + +public class AIRobot { + public EntityRobotBase robot; + + private AIRobot delegateAI; + private AIRobot parentAI; + + private boolean success; + + public AIRobot(EntityRobotBase iRobot) { + robot = iRobot; + success = true; + } + + public void start() { + + } + + public void preempt(AIRobot ai) { + + } + + public void update() { + // Update should always handle terminate. Some AI are not using update + // at all, their code being in start() and end(). In these case, + // calling update is a malfunction, the ai should be terminated. + terminate(); + } + + public void end() { + + } + + /** This gets called when a delegate AI ends work naturally. + * + * @param ai The delegate AI which ended work. */ + public void delegateAIEnded(AIRobot ai) { + + } + + /** This gets called when a delegate AI is forcibly aborted. + * + * @param ai The delegate AI which was aborted. */ + public void delegateAIAborted(AIRobot ai) { + + } + + public void writeSelfToNBT(NBTTagCompound nbt) { + + } + + public void loadSelfFromNBT(NBTTagCompound nbt) { + + } + + public boolean success() { + return success; + } + + protected void setSuccess(boolean iSuccess) { + success = iSuccess; + } + + public long getPowerCost() { + return MjAPI.MJ / 10; + } + + public boolean canLoadFromNBT() { + return false; + } + + /** Tries to receive items in parameters, return items that are left after the operation. */ + public ItemStack receiveItem(ItemStack stack) { + return stack; + } + + public final void terminate() { + abortDelegateAI(); + end(); + + if (parentAI != null) { + parentAI.delegateAI = null; + parentAI.delegateAIEnded(this); + } + } + + public final void abort() { + abortDelegateAI(); + + try { + end(); + + if (parentAI != null) { + parentAI.delegateAI = null; + parentAI.delegateAIAborted(this); + } + } catch (Throwable e) { + e.printStackTrace(); + delegateAI = null; + + if (parentAI != null) { + parentAI.delegateAI = null; + } + } + } + + public final void cycle() { + try { + preempt(delegateAI); + + if (delegateAI != null) { + delegateAI.cycle(); + } else { + robot.getBattery().extractPower(1, getPowerCost()); + update(); + } + } catch (Throwable e) { + e.printStackTrace(); + abort(); + } + } + + public final void startDelegateAI(AIRobot ai) { + abortDelegateAI(); + delegateAI = ai; + ai.parentAI = this; + delegateAI.start(); + } + + public final void abortDelegateAI() { + if (delegateAI != null) { + delegateAI.abort(); + } + } + + public final AIRobot getActiveAI() { + if (delegateAI != null) { + return delegateAI.getActiveAI(); + } else { + return this; + } + } + + public final AIRobot getDelegateAI() { + return delegateAI; + } + + public final void writeToNBT(NBTTagCompound nbt) { + nbt.setString("aiName", RobotManager.getAIRobotName(getClass())); + + NBTTagCompound data = new NBTTagCompound(); + writeSelfToNBT(data); + nbt.setTag("data", data); + + if (delegateAI != null && delegateAI.canLoadFromNBT()) { + NBTTagCompound sub = new NBTTagCompound(); + + delegateAI.writeToNBT(sub); + nbt.setTag("delegateAI", sub); + } + } + + public final void loadFromNBT(NBTTagCompound nbt) { + loadSelfFromNBT(nbt.getCompoundTag("data")); + + if (nbt.hasKey("delegateAI")) { + NBTTagCompound sub = nbt.getCompoundTag("delegateAI"); + + try { + Class aiRobotClass; + if (sub.hasKey("class")) { + // Migration support for 6.4.x + aiRobotClass = RobotManager.getAIRobotByLegacyClassName(sub.getString("class")); + } else { + aiRobotClass = RobotManager.getAIRobotByName(sub.getString("aiName")); + } + if (aiRobotClass != null) { + delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot); + delegateAI.parentAI = this; + + if (delegateAI.canLoadFromNBT()) { + delegateAI.loadFromNBT(sub); + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + } + + public static AIRobot loadAI(NBTTagCompound nbt, EntityRobotBase robot) { + AIRobot ai = null; + + try { + Class aiRobotClass; + if (nbt.hasKey("class")) { + // Migration support for 6.4.x + aiRobotClass = RobotManager.getAIRobotByLegacyClassName(nbt.getString("class")); + } else { + aiRobotClass = RobotManager.getAIRobotByName(nbt.getString("aiName")); + } + if (aiRobotClass != null) { + ai = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot); + ai.loadFromNBT(nbt); + } + } catch (Throwable e) { + e.printStackTrace(); + } + + return ai; + } +} diff --git a/src/api/java/buildcraft/api/robots/DockingStation.java b/src/api/java/buildcraft/api/robots/DockingStation.java new file mode 100755 index 000000000..28ecb0830 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/DockingStation.java @@ -0,0 +1,225 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.robots; + +import net.minecraft.inventory.IInventory; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.capability.IFluidHandler; + +import buildcraft.api.core.BCLog; +import buildcraft.api.core.EnumPipePart; +import buildcraft.api.statements.StatementSlot; +import buildcraft.api.transport.IInjectable; + +public abstract class DockingStation { + public EnumFacing side; + public World world; + + private long robotTakingId = EntityRobotBase.NULL_ROBOT_ID; + private EntityRobotBase robotTaking; + + private boolean linkIsMain = false; + + private BlockPos pos; + + public DockingStation(BlockPos iIndex, EnumFacing iSide) { + pos = iIndex; + side = iSide; + } + + public DockingStation() {} + + public boolean isMainStation() { + return linkIsMain; + } + + public BlockPos getPos() { + return pos; + } + + public EnumFacing side() { + return side; + } + + public EntityRobotBase robotTaking() { + if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { + return null; + } else if (robotTaking == null) { + robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(robotTakingId); + } + + return robotTaking; + } + + public void invalidateRobotTakingEntity() { + robotTaking = null; + } + + public long linkedId() { + return robotTakingId; + } + + public boolean takeAsMain(EntityRobotBase robot) { + if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { + IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); + linkIsMain = true; + robotTaking = robot; + robotTakingId = robot.getRobotId(); + registry.registryMarkDirty(); + robot.setMainStation(this); + registry.take(this, robot.getRobotId()); + + return true; + } else { + return robotTakingId == robot.getRobotId(); + } + } + + public boolean take(EntityRobotBase robot) { + if (robotTaking == null) { + IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); + linkIsMain = false; + robotTaking = robot; + robotTakingId = robot.getRobotId(); + registry.registryMarkDirty(); + registry.take(this, robot.getRobotId()); + + return true; + } else { + return robot.getRobotId() == robotTakingId; + } + } + + public void release(EntityRobotBase robot) { + if (robotTaking == robot && !linkIsMain) { + IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); + unsafeRelease(robot); + registry.registryMarkDirty(); + registry.release(this, robot.getRobotId()); + } + } + + /** Same a release but doesn't clear the registry (presumably called from the registry). */ + public void unsafeRelease(EntityRobotBase robot) { + if (robotTaking == robot) { + linkIsMain = false; + robotTaking = null; + robotTakingId = EntityRobotBase.NULL_ROBOT_ID; + } + } + + public void writeToNBT(NBTTagCompound nbt) { + nbt.setIntArray("pos", new int[] { getPos().getX(), getPos().getY(), getPos().getZ() }); + nbt.setByte("side", (byte) side.ordinal()); + nbt.setBoolean("isMain", linkIsMain); + nbt.setLong("robotId", robotTakingId); + } + + public void readFromNBT(NBTTagCompound nbt) { + if (nbt.hasKey("index")) { + // For compatibility with older versions of minecraft and buildcraft + NBTTagCompound indexNBT = nbt.getCompoundTag("index"); + int x = indexNBT.getInteger("i"); + int y = indexNBT.getInteger("j"); + int z = indexNBT.getInteger("k"); + pos = new BlockPos(x, y, z); + } else { + int[] array = nbt.getIntArray("pos"); + if (array.length == 3) { + pos = new BlockPos(array[0], array[1], array[2]); + } else if (array.length != 0) { + BCLog.logger.warn("Found an integer array that wwas not the right length! (" + array + ")"); + } else { + BCLog.logger.warn("Did not find any integer positions! This is a bug!"); + } + } + side = EnumFacing.values()[nbt.getByte("side")]; + linkIsMain = nbt.getBoolean("isMain"); + robotTakingId = nbt.getLong("robotId"); + } + + public boolean isTaken() { + return robotTakingId != EntityRobotBase.NULL_ROBOT_ID; + } + + public long robotIdTaking() { + return robotTakingId; + } + + public BlockPos index() { + return pos; + } + + @Override + public String toString() { + return "{" + pos + ", " + side + " :" + robotTakingId + "}"; + } + + public boolean linkIsDocked() { + if (robotTaking() != null) { + return robotTaking().getDockingStation() == this; + } else { + return false; + } + } + + public boolean canRelease() { + return !isMainStation() && !linkIsDocked(); + } + + public boolean isInitialized() { + return true; + } + + public abstract Iterable getActiveActions(); + + public IInjectable getItemOutput() { + return null; + } + + public EnumPipePart getItemOutputSide() { + return EnumPipePart.CENTER; + } + + public IInventory getItemInput() { + return null; + } + + public EnumPipePart getItemInputSide() { + return EnumPipePart.CENTER; + } + + public IFluidHandler getFluidOutput() { + return null; + } + + public EnumPipePart getFluidOutputSide() { + return EnumPipePart.CENTER; + } + + public IFluidHandler getFluidInput() { + return null; + } + + public EnumPipePart getFluidInputSide() { + return EnumPipePart.CENTER; + } + + public boolean providesPower() { + return false; + } + + public IRequestProvider getRequestProvider() { + return null; + } + + public void onChunkUnload() { + + } +} diff --git a/src/api/java/buildcraft/api/robots/EntityRobotBase.java b/src/api/java/buildcraft/api/robots/EntityRobotBase.java new file mode 100755 index 000000000..0e6439d04 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/EntityRobotBase.java @@ -0,0 +1,86 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.robots; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.items.IItemHandler; + +import buildcraft.api.boards.RedstoneBoardRobot; +import buildcraft.api.core.IFluidHandlerAdv; +import buildcraft.api.core.IZone; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.mj.MjBattery; + +public abstract class EntityRobotBase extends EntityLiving implements IItemHandler, IFluidHandlerAdv { + + public static final long MAX_POWER = 5000 * MjAPI.MJ; + public static final long SAFETY_POWER = MAX_POWER / 5; + public static final long SHUTDOWN_POWER = 0; + public static final long NULL_ROBOT_ID = Long.MAX_VALUE; + + public EntityRobotBase(World par1World) { + super(par1World); + } + + public abstract void setItemInUse(ItemStack stack); + + public abstract void setItemActive(boolean b); + + public abstract boolean isMoving(); + + public abstract DockingStation getLinkedStation(); + + public abstract RedstoneBoardRobot getBoard(); + + public abstract void aimItemAt(float yaw, float pitch); + + public abstract void aimItemAt(BlockPos pos); + + public abstract float getAimYaw(); + + public abstract float getAimPitch(); + + public long getPower() { + return getBattery().getStored(); + } + + public abstract MjBattery getBattery(); + + public abstract DockingStation getDockingStation(); + + public abstract void dock(DockingStation station); + + public abstract void undock(); + + public abstract IZone getZoneToWork(); + + public abstract IZone getZoneToLoadUnload(); + + public abstract boolean containsItems(); + + public abstract boolean hasFreeSlot(); + + public abstract void unreachableEntityDetected(Entity entity); + + public abstract boolean isKnownUnreachable(Entity entity); + + public abstract long getRobotId(); + + public abstract IRobotRegistry getRegistry(); + + public abstract void releaseResources(); + + public abstract void onChunkUnload(); + + public abstract ItemStack receiveItem(TileEntity tile, ItemStack stack); + + public abstract void setMainStation(DockingStation station); +} diff --git a/src/api/java/buildcraft/api/robots/IDockingStationProvider.java b/src/api/java/buildcraft/api/robots/IDockingStationProvider.java new file mode 100755 index 000000000..0cbd3c3b8 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/IDockingStationProvider.java @@ -0,0 +1,6 @@ +package buildcraft.api.robots; + +/** By default, this can be either an IPipePluggable or a TileEntity. */ +public interface IDockingStationProvider { + DockingStation getStation(); +} diff --git a/src/api/java/buildcraft/api/robots/IRequestProvider.java b/src/api/java/buildcraft/api/robots/IRequestProvider.java new file mode 100755 index 000000000..2e56148a8 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/IRequestProvider.java @@ -0,0 +1,32 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.robots; + +import net.minecraft.item.ItemStack; + +/** Provide requests of items that need to be fulfilled. + * + * Requests are organized as an linear array, where null entries mark slots without a requests. A request in a slot, or + * the amount of slots, is allowed to change before a call to {@link #offerItem(int, ItemStack)}, but it is not + * recommended that this is frequent, since the request delivery won't fail until it is offered the previous request. */ +public interface IRequestProvider { + /** Return the total number of request slots available from this provider. + * + * @return */ + int getRequestsCount(); + + /** Return a stack with the request in the slot. + * + * @param slot + * @return the request in the slot, or null if there's no request. */ + ItemStack getRequest(int slot); + + /** Fulfill the request in slot with the stack given and return any excess. + * + * @param slot + * @param stack + * @return any excess that was not used to fulfill the request. */ + ItemStack offerItem(int slot, ItemStack stack); +} diff --git a/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java b/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java new file mode 100755 index 000000000..fa39ee1a1 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java @@ -0,0 +1,14 @@ +package buildcraft.api.robots; + +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IRobotOverlayItem { + boolean isValidRobotOverlay(ItemStack stack); + + @SideOnly(Side.CLIENT) + void renderRobotOverlay(ItemStack stack, TextureManager textureManager); +} diff --git a/src/api/java/buildcraft/api/robots/IRobotRegistry.java b/src/api/java/buildcraft/api/robots/IRobotRegistry.java new file mode 100755 index 000000000..96360f564 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/IRobotRegistry.java @@ -0,0 +1,56 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.robots; + +import java.util.Collection; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; + +public interface IRobotRegistry { + + long getNextRobotId(); + + void registerRobot(EntityRobotBase robot); + + void killRobot(EntityRobotBase robot); + + void unloadRobot(EntityRobotBase robot); + + EntityRobotBase getLoadedRobot(long id); + + boolean isTaken(ResourceId resourceId); + + long robotIdTaking(ResourceId resourceId); + + EntityRobotBase robotTaking(ResourceId resourceId); + + boolean take(ResourceId resourceId, EntityRobotBase robot); + + boolean take(ResourceId resourceId, long robotId); + + void release(ResourceId resourceId); + + void releaseResources(EntityRobotBase robot); + + DockingStation getStation(BlockPos pos, EnumFacing side); + + Collection getStations(); + + void registerStation(DockingStation station); + + void removeStation(DockingStation station); + + void take(DockingStation station, long robotId); + + void release(DockingStation station, long robotId); + + void writeToNBT(NBTTagCompound nbt); + + void readFromNBT(NBTTagCompound nbt); + + void registryMarkDirty(); +} diff --git a/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java b/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java new file mode 100755 index 000000000..001249453 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java @@ -0,0 +1,7 @@ +package buildcraft.api.robots; + +import net.minecraft.world.World; + +public interface IRobotRegistryProvider { + IRobotRegistry getRegistry(World world); +} diff --git a/src/api/java/buildcraft/api/robots/ResourceId.java b/src/api/java/buildcraft/api/robots/ResourceId.java new file mode 100755 index 000000000..539503a0f --- /dev/null +++ b/src/api/java/buildcraft/api/robots/ResourceId.java @@ -0,0 +1,39 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.robots; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class ResourceId { + + protected ResourceId() {} + + public void writeToNBT(NBTTagCompound nbt) { + nbt.setString("resourceName", RobotManager.getResourceIdName(getClass())); + } + + protected void readFromNBT(NBTTagCompound nbt) {} + + public static ResourceId load(NBTTagCompound nbt) { + try { + Class cls; + if (nbt.hasKey("class")) { + // Migration support for 6.4.x + cls = RobotManager.getResourceIdByLegacyClassName(nbt.getString("class")); + } else { + cls = RobotManager.getResourceIdByName(nbt.getString("resourceName")); + } + + ResourceId id = (ResourceId) cls.newInstance(); + id.readFromNBT(nbt); + + return id; + } catch (Throwable e) { + e.printStackTrace(); + } + + return null; + } +} diff --git a/src/api/java/buildcraft/api/robots/ResourceIdBlock.java b/src/api/java/buildcraft/api/robots/ResourceIdBlock.java new file mode 100755 index 000000000..4e89a5826 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/ResourceIdBlock.java @@ -0,0 +1,71 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.robots; + +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; + +import buildcraft.api.core.EnumPipePart; + +public class ResourceIdBlock extends ResourceId { + + public BlockPos pos = new BlockPos(0, 0, 0); + public EnumPipePart side = EnumPipePart.CENTER; + + public ResourceIdBlock() { + + } + + public ResourceIdBlock(int x, int y, int z) { + pos = new BlockPos(x, y, z); + } + + public ResourceIdBlock(BlockPos iIndex) { + pos = iIndex; + } + + public ResourceIdBlock(TileEntity tile) { + pos = tile.getPos(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || obj.getClass() != getClass()) { + return false; + } + + ResourceIdBlock compareId = (ResourceIdBlock) obj; + + return pos.equals(compareId.pos) && side == compareId.side; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(pos.hashCode()).append(side != null ? side.ordinal() : 0).build(); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + int[] arr = new int[] { pos.getX(), pos.getY(), pos.getZ() }; + nbt.setIntArray("pos", arr); + + nbt.setTag("side", side.writeToNBT()); + } + + @Override + protected void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + int[] arr = nbt.getIntArray("pos"); + pos = new BlockPos(arr[0], arr[1], arr[2]); + + side = EnumPipePart.readFromNBT(nbt.getTag("side")); + } +} diff --git a/src/api/java/buildcraft/api/robots/ResourceIdRequest.java b/src/api/java/buildcraft/api/robots/ResourceIdRequest.java new file mode 100755 index 000000000..d224b8e76 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/ResourceIdRequest.java @@ -0,0 +1,54 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.robots; + +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import net.minecraft.nbt.NBTTagCompound; + +import buildcraft.api.core.EnumPipePart; + +public class ResourceIdRequest extends ResourceIdBlock { + + private int slot; + + public ResourceIdRequest() { + + } + + public ResourceIdRequest(DockingStation station, int slot) { + pos = station.index(); + side = EnumPipePart.fromFacing(station.side()); + this.slot = slot; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + if (!super.equals(obj)) return false; + ResourceIdRequest compareId = (ResourceIdRequest) obj; + + return slot == compareId.slot; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(super.hashCode()).append(slot).build(); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setInteger("localId", slot); + } + + @Override + protected void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + slot = nbt.getInteger("localId"); + } +} diff --git a/src/api/java/buildcraft/api/robots/RobotManager.java b/src/api/java/buildcraft/api/robots/RobotManager.java new file mode 100755 index 000000000..aa59fc4d7 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/RobotManager.java @@ -0,0 +1,114 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.robots; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import buildcraft.api.core.BCLog; + +public abstract class RobotManager { + public static IRobotRegistryProvider registryProvider; + public static ArrayList> aiRobots = new ArrayList>(); + + static { + aiRobotsByNames = new HashMap>(); + aiRobotsNames = new HashMap, String>(); + aiRobotsByLegacyClassNames = new HashMap>(); + resourceIdNames = new HashMap, String>(); + resourceIdByNames = new HashMap>(); + resourceIdLegacyClassNames = new HashMap>(); + dockingStationNames = new HashMap, String>(); + dockingStationByNames = new HashMap>(); + + registerResourceId(ResourceIdBlock.class, "resourceIdBlock", "buildcraft.core.robots.ResourceIdBlock"); + registerResourceId(ResourceIdRequest.class, "resourceIdRequest", "buildcraft.core.robots.ResourceIdRequest"); + } + + private static Map, String> aiRobotsNames; + private static Map> aiRobotsByNames; + private static Map> aiRobotsByLegacyClassNames; + + private static Map, String> resourceIdNames; + private static Map> resourceIdByNames; + private static Map> resourceIdLegacyClassNames; + + private static Map, String> dockingStationNames; + private static Map> dockingStationByNames; + + public static void registerAIRobot(Class aiRobot, String name) { + registerAIRobot(aiRobot, name, null); + } + + public static void registerAIRobot(Class aiRobot, String name, String legacyClassName) { + if (aiRobotsByNames.containsKey(name)) { + BCLog.logger.info("Overriding " + aiRobotsByNames.get(name).getName() + " with " + aiRobot.getName()); + } + + // Check if NBT-load constructor is present + try { + aiRobot.getConstructor(EntityRobotBase.class); + } catch (NoSuchMethodException e) { + throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load construtor! This is a bug!"); + } + + aiRobots.add(aiRobot); + aiRobotsByNames.put(name, aiRobot); + aiRobotsNames.put(aiRobot, name); + if (legacyClassName != null) { + aiRobotsByLegacyClassNames.put(legacyClassName, aiRobot); + } + } + + public static Class getAIRobotByName(String aiRobotName) { + return aiRobotsByNames.get(aiRobotName); + } + + public static String getAIRobotName(Class aiRobotClass) { + return aiRobotsNames.get(aiRobotClass); + } + + public static Class getAIRobotByLegacyClassName(String aiRobotLegacyClassName) { + return aiRobotsByLegacyClassNames.get(aiRobotLegacyClassName); + } + + public static void registerResourceId(Class resourceId, String name) { + registerResourceId(resourceId, name, null); + } + + public static void registerResourceId(Class resourceId, String name, String legacyClassName) { + resourceIdByNames.put(name, resourceId); + resourceIdNames.put(resourceId, name); + if (legacyClassName != null) { + resourceIdLegacyClassNames.put(legacyClassName, resourceId); + } + } + + public static Class getResourceIdByName(String resourceIdName) { + return resourceIdByNames.get(resourceIdName); + } + + public static String getResourceIdName(Class resouceIdClass) { + return resourceIdNames.get(resouceIdClass); + } + + public static Class getResourceIdByLegacyClassName(String resourceIdLegacyClassName) { + return resourceIdLegacyClassNames.get(resourceIdLegacyClassName); + } + + public static void registerDockingStation(Class dockingStation, String name) { + dockingStationByNames.put(name, dockingStation); + dockingStationNames.put(dockingStation, name); + } + + public static Class getDockingStationByName(String dockingStationTypeName) { + return dockingStationByNames.get(dockingStationTypeName); + } + + public static String getDockingStationName(Class dockingStation) { + return dockingStationNames.get(dockingStation); + } +} diff --git a/src/api/java/buildcraft/api/robots/package-info.java b/src/api/java/buildcraft/api/robots/package-info.java new file mode 100755 index 000000000..4fd622b34 --- /dev/null +++ b/src/api/java/buildcraft/api/robots/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics") +package buildcraft.api.robots; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/statements/IAction.java b/src/api/java/buildcraft/api/statements/IAction.java new file mode 100755 index 000000000..2cd0c359f --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IAction.java @@ -0,0 +1,6 @@ +package buildcraft.api.statements; + +/** Marker interface that designates a class as being an action. Note that you *must* implement ONE of the following + * interfaces to be recognised as an action: {@link IActionInternal}, {@link IActionInternalSided}, or + * {@link IActionExternal} */ +public interface IAction extends IStatement {} diff --git a/src/api/java/buildcraft/api/statements/IActionExternal.java b/src/api/java/buildcraft/api/statements/IActionExternal.java new file mode 100755 index 000000000..9086612ca --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionExternal.java @@ -0,0 +1,12 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +public interface IActionExternal extends IAction { + void actionActivate(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/IActionInternal.java b/src/api/java/buildcraft/api/statements/IActionInternal.java new file mode 100755 index 000000000..1ec5260f3 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionInternal.java @@ -0,0 +1,10 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +public interface IActionInternal extends IAction { + + void actionActivate(IStatementContainer source, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/IActionInternalSided.java b/src/api/java/buildcraft/api/statements/IActionInternalSided.java new file mode 100755 index 000000000..0ae3d70d3 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionInternalSided.java @@ -0,0 +1,7 @@ +package buildcraft.api.statements; + +import net.minecraft.util.EnumFacing; + +public interface IActionInternalSided extends IAction { + void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/IActionProvider.java b/src/api/java/buildcraft/api/statements/IActionProvider.java new file mode 100755 index 000000000..fa550ff83 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionProvider.java @@ -0,0 +1,20 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import java.util.Collection; + +import javax.annotation.Nonnull; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +public interface IActionProvider { + void addInternalActions(Collection actions, IStatementContainer container); + + void addInternalSidedActions(Collection actions, IStatementContainer container, @Nonnull EnumFacing side); + + void addExternalActions(Collection actions, @Nonnull EnumFacing side, TileEntity tile); +} diff --git a/src/api/java/buildcraft/api/statements/IActionReceptor.java b/src/api/java/buildcraft/api/statements/IActionReceptor.java new file mode 100755 index 000000000..34155b86a --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionReceptor.java @@ -0,0 +1,9 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +public interface IActionReceptor { + void actionActivated(IStatement statement, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/IActionSingle.java b/src/api/java/buildcraft/api/statements/IActionSingle.java new file mode 100755 index 000000000..861e37eb2 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IActionSingle.java @@ -0,0 +1,6 @@ +package buildcraft.api.statements; + +public interface IActionSingle extends IAction { + /** @return True if this action should only be fired for the first tick of it being active. */ + boolean singleActionTick(); +} diff --git a/src/api/java/buildcraft/api/statements/IGuiSlot.java b/src/api/java/buildcraft/api/statements/IGuiSlot.java new file mode 100755 index 000000000..c7386dd69 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IGuiSlot.java @@ -0,0 +1,20 @@ +package buildcraft.api.statements; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IGuiSlot { + /** Every parameter needs a unique tag, it should be in the format of "<modid>:<name>". + * + * @return the unique id */ + String getUniqueTag(); + + /** Return the parameter description in the UI */ + String getDescription(); + + /** @return A sprite to show in a GUI, or null if this should not render a sprite. */ + @SideOnly(Side.CLIENT) + TextureAtlasSprite getGuiSprite(); +} diff --git a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java new file mode 100755 index 000000000..cb2dc78e1 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java @@ -0,0 +1,13 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import java.util.List; + +public interface IOverrideDefaultStatements { + List overrideTriggers(); + + List overrideActions(); +} diff --git a/src/api/java/buildcraft/api/statements/IStatement.java b/src/api/java/buildcraft/api/statements/IStatement.java new file mode 100755 index 000000000..70c20836e --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IStatement.java @@ -0,0 +1,26 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +/** Designates some sort of statement. Most of the time you should implement {@link ITriggerExternal}, + * {@link ITriggerInternal}, {@link IActionExternal} or {@link IActionInternal} though. */ +public interface IStatement extends IGuiSlot { + + /** Return the maximum number of parameter this statement can have, 0 if none. */ + int maxParameters(); + + /** Return the minimum number of parameter this statement can have, 0 if none. */ + int minParameters(); + + /** Create parameters for the statement. */ + IStatementParameter createParameter(int index); + + /** This returns the statement after a left rotation. Used in particular in blueprints orientation. */ + IStatement rotateLeft(); + + /** This returns a group of related statements. For example "redstone signal input" should probably return an array + * of "RS_SIGNAL_ON" and "RS_SIGNAL_OFF". It is recommended to return an array containing this object. */ + IStatement[] getPossible(); +} diff --git a/src/api/java/buildcraft/api/statements/IStatementContainer.java b/src/api/java/buildcraft/api/statements/IStatementContainer.java new file mode 100755 index 000000000..2e7652fd8 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IStatementContainer.java @@ -0,0 +1,15 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +/** This is implemented by objects containing Statements, such as Gates and TileEntities. */ +public interface IStatementContainer { + TileEntity getTile(); + + TileEntity getNeighbourTile(EnumFacing side); +} diff --git a/src/api/java/buildcraft/api/statements/IStatementParameter.java b/src/api/java/buildcraft/api/statements/IStatementParameter.java new file mode 100755 index 000000000..8e15b9c46 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/IStatementParameter.java @@ -0,0 +1,33 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public interface IStatementParameter extends IGuiSlot { + + /** @return An itemstack to render for this parameter, or {@link ItemStack#EMPTY} if this should not render an + * itemstack. */ + @Nonnull + ItemStack getItemStack(); + + /** Return true if you handled the mouse click and do not want all possible values to be shown, or false if you + * did nothing and wish to show all possible values. + * + * @see #getPossible(IStatementContainer, IStatement)*/ + boolean onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse); + + void readFromNBT(NBTTagCompound compound); + + void writeToNBT(NBTTagCompound compound); + + /** This returns the parameter after a left rotation. Used in particular in blueprints orientation. */ + IStatementParameter rotateLeft(); + + IStatementParameter[] getPossible(IStatementContainer source, IStatement stmt); +} diff --git a/src/api/java/buildcraft/api/statements/ITrigger.java b/src/api/java/buildcraft/api/statements/ITrigger.java new file mode 100755 index 000000000..cdb65c971 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITrigger.java @@ -0,0 +1,6 @@ +package buildcraft.api.statements; + +/** Marker interface that designates a class as being a trigger. Note that you *must* implement ONE of the following + * interfaces to be recognised as a trigger: {@link ITriggerInternal}, {@link ITriggerInternalSided}, or + * {@link ITriggerExternal} */ +public interface ITrigger extends IStatement {} diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternal.java b/src/api/java/buildcraft/api/statements/ITriggerExternal.java new file mode 100755 index 000000000..87a848fef --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerExternal.java @@ -0,0 +1,14 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +public interface ITriggerExternal extends ITrigger { + + boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + +} diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java new file mode 100755 index 000000000..5b8ce9ee2 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java @@ -0,0 +1,16 @@ +package buildcraft.api.statements; + +import net.minecraft.util.EnumFacing; + +/** This interface can be used by tiles to override external trigger behaviour. + * + * Please use wisely. */ +public interface ITriggerExternalOverride { + public enum Result { + TRUE, + FALSE, + IGNORE + } + + Result override(EnumFacing side, IStatementContainer source, ITriggerExternal trigger, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternal.java b/src/api/java/buildcraft/api/statements/ITriggerInternal.java new file mode 100755 index 000000000..8ca49961d --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerInternal.java @@ -0,0 +1,11 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +public interface ITriggerInternal extends ITrigger { + + boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters); + +} diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java b/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java new file mode 100755 index 000000000..73459f004 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java @@ -0,0 +1,7 @@ +package buildcraft.api.statements; + +import net.minecraft.util.EnumFacing; + +public interface ITriggerInternalSided extends ITrigger { + boolean isTriggerActive(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/ITriggerProvider.java b/src/api/java/buildcraft/api/statements/ITriggerProvider.java new file mode 100755 index 000000000..8f3bf0317 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerProvider.java @@ -0,0 +1,21 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import java.util.Collection; + +import javax.annotation.Nonnull; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +public interface ITriggerProvider { + void addInternalTriggers(Collection triggers, IStatementContainer container); + + void addInternalSidedTriggers(Collection triggers, IStatementContainer container, @Nonnull EnumFacing side); + + /** Returns the list of triggers available to a gate next to the given block. */ + void addExternalTriggers(Collection triggers, @Nonnull EnumFacing side, TileEntity tile); +} diff --git a/src/api/java/buildcraft/api/statements/StatementManager.java b/src/api/java/buildcraft/api/statements/StatementManager.java new file mode 100755 index 000000000..61266e583 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/StatementManager.java @@ -0,0 +1,144 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import java.util.*; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +import buildcraft.api.core.BCLog; + +public final class StatementManager { + + public static Map statements = new HashMap(); + public static Map> parameters = new HashMap>(); + private static List triggerProviders = new LinkedList(); + private static List actionProviders = new LinkedList(); + + static { + registerParameterClass(StatementParameterItemStack.class); + } + + /** Deactivate constructor */ + private StatementManager() {} + + public static void registerTriggerProvider(ITriggerProvider provider) { + if (provider != null && !triggerProviders.contains(provider)) { + triggerProviders.add(provider); + } + } + + public static void registerActionProvider(IActionProvider provider) { + if (provider != null && !actionProviders.contains(provider)) { + actionProviders.add(provider); + } + } + + public static void registerStatement(IStatement statement) { + statements.put(statement.getUniqueTag(), statement); + } + + public static void registerParameterClass(Class param) { + parameters.put(createParameter(param).getUniqueTag(), param); + } + + public static List getExternalTriggers(EnumFacing side, TileEntity entity) { + if (entity instanceof IOverrideDefaultStatements) { + List result = ((IOverrideDefaultStatements) entity).overrideTriggers(); + if (result != null) { + return result; + } + } + + LinkedHashSet triggers = new LinkedHashSet(); + + for (ITriggerProvider provider : triggerProviders) { + provider.addExternalTriggers(triggers, side, entity); + } + + return new ArrayList(triggers); + } + + public static List getExternalActions(EnumFacing side, TileEntity entity) { + if (entity instanceof IOverrideDefaultStatements) { + List result = ((IOverrideDefaultStatements) entity).overrideActions(); + if (result != null) { + return result; + } + } + + LinkedHashSet actions = new LinkedHashSet(); + + for (IActionProvider provider : actionProviders) { + provider.addExternalActions(actions, side, entity); + } + + return new ArrayList(actions); + } + + public static List getInternalTriggers(IStatementContainer container) { + LinkedHashSet triggers = new LinkedHashSet(); + + for (ITriggerProvider provider : triggerProviders) { + provider.addInternalTriggers(triggers, container); + } + + return new ArrayList(triggers); + } + + public static List getInternalActions(IStatementContainer container) { + LinkedHashSet actions = new LinkedHashSet(); + + for (IActionProvider provider : actionProviders) { + provider.addInternalActions(actions, container); + } + + return new ArrayList(actions); + } + + public static List getInternalSidedTriggers(IStatementContainer container, EnumFacing side) { + LinkedHashSet triggers = new LinkedHashSet(); + + for (ITriggerProvider provider : triggerProviders) { + provider.addInternalSidedTriggers(triggers, container, side); + } + + return new ArrayList(triggers); + } + + public static List getInternalSidedActions(IStatementContainer container, EnumFacing side) { + LinkedHashSet actions = new LinkedHashSet(); + + for (IActionProvider provider : actionProviders) { + provider.addInternalSidedActions(actions, container, side); + } + + return new ArrayList(actions); + } + + public static IStatementParameter createParameter(String kind) { + return createParameter(parameters.get(kind)); + } + + private static IStatementParameter createParameter(Class param) { + if (param == null) { + return null; + } + + try { + return param.newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (Error error) { + BCLog.logErrorAPI(error, IStatementParameter.class); + throw error; + } + + return null; + } +} diff --git a/src/api/java/buildcraft/api/statements/StatementMouseClick.java b/src/api/java/buildcraft/api/statements/StatementMouseClick.java new file mode 100755 index 000000000..c39ed336f --- /dev/null +++ b/src/api/java/buildcraft/api/statements/StatementMouseClick.java @@ -0,0 +1,23 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +public final class StatementMouseClick { + private int button; + private boolean shift; + + public StatementMouseClick(int button, boolean shift) { + this.button = button; + this.shift = shift; + } + + public boolean isShift() { + return shift; + } + + public int getButton() { + return button; + } +} diff --git a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java new file mode 100755 index 000000000..5ed9c4088 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java @@ -0,0 +1,108 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.statements; + +import java.util.Objects; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class StatementParameterItemStack implements IStatementParameter { + // needed because ItemStack.EMPTY doesn't have @Nonnull applied to it :/ + @Nonnull + private static final ItemStack EMPTY_STACK; + + static { + ItemStack stack = ItemStack.EMPTY; + if (stack == null) throw new Error("Somehow ItemStack.EMPTY was null!"); + EMPTY_STACK = stack; + } + + @Nonnull + protected ItemStack stack = EMPTY_STACK; + + @Override + public TextureAtlasSprite getGuiSprite() { + return null; + } + + @Override + public ItemStack getItemStack() { + return stack; + } + + @Override + public boolean onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) { + if (stack != null) { + this.stack = stack.copy(); + this.stack.setCount(1); + } else { + this.stack = EMPTY_STACK; + } + return true; + } + + @Override + public void writeToNBT(NBTTagCompound compound) { + if (!stack.isEmpty()) { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.writeToNBT(tagCompound); + compound.setTag("stack", tagCompound); + } + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + ItemStack read = new ItemStack(compound.getCompoundTag("stack")); + if (read.isEmpty()) { + stack = EMPTY_STACK; + } else { + stack = read; + } + } + + @Override + public boolean equals(Object object) { + if (object instanceof StatementParameterItemStack) { + StatementParameterItemStack param = (StatementParameterItemStack) object; + + return ItemStack.areItemStacksEqual(stack, param.stack) && ItemStack.areItemStackTagsEqual(stack, param.stack); + } else { + return false; + } + } + + @Override + public int hashCode() { + return Objects.hashCode(stack); + } + + @Override + public String getDescription() { + if (stack.isEmpty()) { + return ""; + } else { + return stack.getDisplayName(); + } + } + + @Override + public String getUniqueTag() { + return "buildcraft:stack"; + } + + @Override + public IStatementParameter rotateLeft() { + return this; + } + + @Override + public IStatementParameter[] getPossible(IStatementContainer source, IStatement stmt) { + return null; + } +} diff --git a/src/api/java/buildcraft/api/statements/StatementSlot.java b/src/api/java/buildcraft/api/statements/StatementSlot.java new file mode 100755 index 000000000..b3306b4bd --- /dev/null +++ b/src/api/java/buildcraft/api/statements/StatementSlot.java @@ -0,0 +1,45 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ +package buildcraft.api.statements; + +import java.util.Arrays; +import java.util.Objects; + +import buildcraft.api.core.EnumPipePart; + +public class StatementSlot { + public IStatement statement; + public IStatementParameter[] parameters; + public EnumPipePart part = EnumPipePart.CENTER; + + @Override + public boolean equals(Object o) { + if (!(o instanceof StatementSlot)) { + return false; + } + StatementSlot s = (StatementSlot) o; + if (s.statement != statement || parameters.length != s.parameters.length) { + return false; + } + for (int i = 0; i < parameters.length; i++) { + IStatementParameter p1 = parameters[i]; + IStatementParameter p2 = s.parameters[i]; + if (p1 == null) { + if (p2 != null) return false; + continue; + } + if (p2 == null) return false; + if (!(p1.equals(p2))) { + return false; + } + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(statement, Arrays.deepHashCode(parameters)); + } +} diff --git a/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java new file mode 100755 index 000000000..1d7989aa0 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java @@ -0,0 +1,17 @@ +package buildcraft.api.statements.containers; + +import net.minecraft.util.EnumFacing; + +public interface IRedstoneStatementContainer { + /** Get the redstone input from a given side. + * + * @param side The side - use "null" for maximum input. + * @return The redstone input, from 0 to 15. */ + int getRedstoneInput(EnumFacing side); + + /** Set the redstone input for a given side. + * + * @param side The side - use "null" for all sides. + * @return Whether the set was successful. */ + boolean setRedstoneOutput(EnumFacing side, int value); +} diff --git a/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java new file mode 100755 index 000000000..b65ace45a --- /dev/null +++ b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java @@ -0,0 +1,10 @@ +package buildcraft.api.statements.containers; + +import net.minecraft.util.EnumFacing; + +import buildcraft.api.statements.IStatementContainer; + +/** Created by asie on 3/14/15. */ +public interface ISidedStatementContainer extends IStatementContainer { + EnumFacing getSide(); +} diff --git a/src/api/java/buildcraft/api/statements/package-info.java b/src/api/java/buildcraft/api/statements/package-info.java new file mode 100755 index 000000000..7dd2c74e6 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements") +package buildcraft.api.statements; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/tablet/ITablet.java b/src/api/java/buildcraft/api/tablet/ITablet.java new file mode 100755 index 000000000..e88a4cf36 --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/ITablet.java @@ -0,0 +1,19 @@ +package buildcraft.api.tablet; + +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.fml.relauncher.Side; + +public interface ITablet { + Side getSide(); + + void refreshScreen(TabletBitmap data); + + int getScreenWidth(); + + int getScreenHeight(); + + void launchProgram(String name); + + void sendMessage(NBTTagCompound compound); +} diff --git a/src/api/java/buildcraft/api/tablet/TabletAPI.java b/src/api/java/buildcraft/api/tablet/TabletAPI.java new file mode 100755 index 000000000..529862790 --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/TabletAPI.java @@ -0,0 +1,20 @@ +package buildcraft.api.tablet; + +import java.util.HashMap; +import java.util.Map; + +public final class TabletAPI { + private static final Map programs = new HashMap(); + + private TabletAPI() { + + } + + public static void registerProgram(TabletProgramFactory factory) { + programs.put(factory.getName(), factory); + } + + public static TabletProgramFactory getProgram(String name) { + return programs.get(name); + } +} diff --git a/src/api/java/buildcraft/api/tablet/TabletBitmap.java b/src/api/java/buildcraft/api/tablet/TabletBitmap.java new file mode 100755 index 000000000..82b236b9f --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/TabletBitmap.java @@ -0,0 +1,55 @@ +package buildcraft.api.tablet; + +public class TabletBitmap { + public final int width, height; + protected int[] data; + + public TabletBitmap(int width, int height) { + this.width = width; + this.height = height; + this.data = new int[width * height]; + } + + public TabletBitmap(ITablet tablet) { + this(tablet.getScreenWidth(), tablet.getScreenHeight()); + } + + public int[] getData() { + return data; + } + + public int get(int x, int y) { + if (x < 0 || y < 0 || x >= width || y >= height) { + return 0; + } + return data[y * width + x]; + } + + public void set(int x, int y, int shade) { + if (x < 0 || y < 0 || x >= width || y >= height) { + return; + } + data[y * width + x] = shade; + } + + public void set(int x, int y, TabletBitmap bitmap) { + for (int i = 0; i < bitmap.height; i++) { + if (i >= height) { + break; + } + for (int h = 0; h < bitmap.width; h++) { + if (h >= width) { + break; + } + + set(x + h, y + i, bitmap.get(h, i)); + } + } + } + + public TabletBitmap duplicate() { + TabletBitmap cloned = new TabletBitmap(this.width, this.height); + cloned.data = this.data.clone(); + return cloned; + } +} diff --git a/src/api/java/buildcraft/api/tablet/TabletProgram.java b/src/api/java/buildcraft/api/tablet/TabletProgram.java new file mode 100755 index 000000000..ea098f47c --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/TabletProgram.java @@ -0,0 +1,17 @@ +package buildcraft.api.tablet; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class TabletProgram { + public void tick(float time) { + + } + + public boolean hasEnded() { + return false; + } + + public void receiveMessage(NBTTagCompound compound) { + + } +} diff --git a/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java b/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java new file mode 100755 index 000000000..8f3bb414c --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java @@ -0,0 +1,19 @@ +package buildcraft.api.tablet; + +public abstract class TabletProgramFactory { + /** Create an instance of the tablet program specified by this Factory. + * + * Both parameters are mutable and can be edited freely; however, the NBTTagCompound will only be synchronized after + * you leave the program. + * + * Please note that the program runs client-side SOLELY. For server-side queries, you must implement a custom + * communications protocol. + * + * @param tablet + * @return An instance of the TabletProgram. */ + public abstract TabletProgram create(ITablet tablet); + + public abstract String getName(); + + public abstract TabletBitmap getIcon(); +} diff --git a/src/api/java/buildcraft/api/tablet/TabletTicker.java b/src/api/java/buildcraft/api/tablet/TabletTicker.java new file mode 100755 index 000000000..33656fb80 --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/TabletTicker.java @@ -0,0 +1,36 @@ +package buildcraft.api.tablet; + +/** Utility class for capturing tablet ticks every X seconds. */ +public class TabletTicker { + private final float tickTime; + private float time = 0.0F; + private int ticked = 0; + + public TabletTicker(float tickTime) { + this.tickTime = tickTime; + } + + public void add(float time) { + this.time += time; + + while (this.time >= tickTime) { + this.time -= tickTime; + ticked++; + } + } + + public int getTicks() { + return ticked; + } + + public boolean tick() { + boolean oldTicked = ticked > 0; + ticked = 0; + return oldTicked; + } + + public void reset() { + ticked = 0; + time = 0; + } +} diff --git a/src/api/java/buildcraft/api/tablet/package-info.java b/src/api/java/buildcraft/api/tablet/package-info.java new file mode 100755 index 000000000..cc87d8657 --- /dev/null +++ b/src/api/java/buildcraft/api/tablet/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tablet") +package buildcraft.api.tablet; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/tiles/IControllable.java b/src/api/java/buildcraft/api/tiles/IControllable.java new file mode 100755 index 000000000..633d1fc28 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/IControllable.java @@ -0,0 +1,37 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.tiles; + +/** This interface should be implemented by any Tile Entity which wishes to have non-redstone automation (for example, + * BuildCraft Gates, but also other mods which implement it, e.g. OpenComputers). */ +public interface IControllable { + public enum Mode { + Unknown, + On, + Off, + Mode, + Loop; + + public static final Mode[] VALUES = values(); + public static final Mode[] VALID_VALUES = { On, Off, Loop }; + } + + /** Get the current control mode of the Tile Entity. + * + * @return */ + Mode getControlMode(); + + /** Set the mode of the Tile Entity. + * + * @param mode */ + void setControlMode(Mode mode); + + /** Check if a given control mode is accepted. If you query IControllable tiles, you MUST check with + * acceptsControlMode first. + * + * @param mode + * @return True if this control mode is accepted. */ + boolean acceptsControlMode(Mode mode); +} diff --git a/src/api/java/buildcraft/api/tiles/IDebuggable.java b/src/api/java/buildcraft/api/tiles/IDebuggable.java new file mode 100755 index 000000000..4e5cb3d5d --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/IDebuggable.java @@ -0,0 +1,17 @@ +package buildcraft.api.tiles; + +import java.util.List; + +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public interface IDebuggable { + /** Get the debug information from a tile entity as a list of strings, used for the F3 debug menu. The left and + * right parameters correspond to the sides of the F3 screen. + * + * @param side The side the block was clicked on, may be null if we don't know, or is the "centre" side */ + @SideOnly(Side.CLIENT) + void getDebugInfo(List left, List right, EnumFacing side); +} diff --git a/src/api/java/buildcraft/api/tiles/IHasWork.java b/src/api/java/buildcraft/api/tiles/IHasWork.java new file mode 100755 index 000000000..fa8719644 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/IHasWork.java @@ -0,0 +1,14 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.tiles; + +/** This interface should be implemented by any Tile Entity which carries out work (crafting, ore processing, mining, et + * cetera). */ +public interface IHasWork { + /** Check if the Tile Entity is currently doing any work. + * + * @return True if the Tile Entity is doing work. */ + boolean hasWork(); +} diff --git a/src/api/java/buildcraft/api/tiles/IHeatable.java b/src/api/java/buildcraft/api/tiles/IHeatable.java new file mode 100755 index 000000000..1af6d6b59 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/IHeatable.java @@ -0,0 +1,26 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.tiles; + +/** This interface should be implemented by Tile Entities which have an internal heat value. */ +public interface IHeatable { + /** @return The minimum heat value, in degrees. */ + double getMinHeatValue(); + + /** @return The preferred heat value, in degrees. */ + double getIdealHeatValue(); + + /** @return The maxmimum heat value, in degrees. */ + double getMaxHeatValue(); + + /** @return The current heat value, in degrees. */ + double getCurrentHeatValue(); + + /** Set the heat of the tile. + * + * @param value Heat value, in degrees. + * @return The heat the tile has after the set. */ + double setHeatValue(double value); +} diff --git a/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java b/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java new file mode 100755 index 000000000..89a7c1456 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java @@ -0,0 +1,10 @@ +package buildcraft.api.tiles; + +import net.minecraft.util.math.BlockPos; + +import buildcraft.api.core.IAreaProvider; + +/** Used for more fine-grained control of whether or not a machine connects to the provider here. */ +public interface ITileAreaProvider extends IAreaProvider { + boolean isValidFromLocation(BlockPos pos); +} diff --git a/src/api/java/buildcraft/api/tiles/package-info.java b/src/api/java/buildcraft/api/tiles/package-info.java new file mode 100755 index 000000000..d4c217fc3 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "1.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tiles") +package buildcraft.api.tiles; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/tools/IToolWrench.java b/src/api/java/buildcraft/api/tools/IToolWrench.java index 74aaa7e6e..9201b5560 100755 --- a/src/api/java/buildcraft/api/tools/IToolWrench.java +++ b/src/api/java/buildcraft/api/tools/IToolWrench.java @@ -4,30 +4,29 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.tools; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.RayTraceResult; /*** Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft */ public interface IToolWrench { - /*** Called to ensure that the wrench can be used. To get the ItemStack that is used, check - * player.inventory.getCurrentItem() + /*** Called to ensure that the wrench can be used. * * @param player - The player doing the wrenching - * @param pos - The coordinates for the block being wrenched + * @param hand - Which hand was holding the wrench + * @param wrench - The item stack that holds the wrench + * @param rayTrace - The object that is being wrenched * * @return true if wrenching is allowed, false if not */ - boolean canWrench(EntityPlayer player, BlockPos pos); + boolean canWrench(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); - /*** Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get - * the ItemStack that was used, check player.inventory.getCurrentItem() + /*** Callback after the wrench has been used. This can be used to decrease durability or for other purposes. * * @param player - The player doing the wrenching - * @param pos - The position of the block being wrenched */ - void wrenchUsed(EntityPlayer player, BlockPos pos); - - boolean canWrench(EntityPlayer player, Entity entity); - - void wrenchUsed(EntityPlayer player, Entity entity); + * @param hand - Which hand was holding the wrench + * @param wrench - The item stack that holds the wrench + * @param rayTrace - The object that is being wrenched */ + void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); } diff --git a/src/api/java/buildcraft/api/transport/EnumWirePart.java b/src/api/java/buildcraft/api/transport/EnumWirePart.java new file mode 100755 index 000000000..6b9e983d2 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/EnumWirePart.java @@ -0,0 +1,80 @@ +package buildcraft.api.transport; + +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.AxisDirection; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.Vec3d; + +public enum EnumWirePart { + EAST_UP_SOUTH(true, true, true), + EAST_UP_NORTH(true, true, false), + EAST_DOWN_SOUTH(true, false, true), + EAST_DOWN_NORTH(true, false, false), + WEST_UP_SOUTH(false, true, true), + WEST_UP_NORTH(false, true, false), + WEST_DOWN_SOUTH(false, false, true), + WEST_DOWN_NORTH(false, false, false); + + public static final EnumWirePart[] VALUES = values(); + + public final AxisDirection x, y, z; + + /** The bounding box for rendering a wire or selecting an already-placed wire. */ + public final AxisAlignedBB boundingBox; + + /** The bounding box that is used when adding pipe wire to a pipe */ + public final AxisAlignedBB boundingBoxPossible; + + EnumWirePart(boolean x, boolean y, boolean z) { + this.x = x ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; + this.y = y ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; + this.z = z ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; + double x1 = this.x.getOffset() * (5 / 16.0) + 0.5; + double y1 = this.y.getOffset() * (5 / 16.0) + 0.5; + double z1 = this.z.getOffset() * (5 / 16.0) + 0.5; + double x2 = this.x.getOffset() * (4 / 16.0) + 0.5; + double y2 = this.y.getOffset() * (4 / 16.0) + 0.5; + double z2 = this.z.getOffset() * (4 / 16.0) + 0.5; + this.boundingBox = new AxisAlignedBB(x1, y1, z1, x2, y2, z2); + + Vec3d center = new Vec3d(0.5, 0.5, 0.5); + Vec3d edge = new Vec3d(x ? 0.75 : 0.25, y ? 0.75 : 0.25, z ? 0.75 : 0.25); + this.boundingBoxPossible = new AxisAlignedBB(center.xCoord, center.yCoord, center.zCoord, edge.xCoord, edge.yCoord, edge.zCoord); + } + + public AxisDirection getDirection(EnumFacing.Axis axis) { + switch (axis) { + case X: + return x; + case Y: + return y; + case Z: + return z; + } + return null; + } + + public static EnumWirePart get(int x, int y, int z) { + return get(// + (x % 2 + 2) % 2 == 1,// + (y % 2 + 2) % 2 == 1,// + (z % 2 + 2) % 2 == 1 // + ); + } + + public static EnumWirePart get(boolean x, boolean y, boolean z) { + if (x) { + if (y) { + return z ? EAST_UP_SOUTH : EAST_UP_NORTH; + } else { + return z ? EAST_DOWN_SOUTH : EAST_DOWN_NORTH; + } + } else { + if (y) { + return z ? WEST_UP_SOUTH : WEST_UP_NORTH; + } else { + return z ? WEST_DOWN_SOUTH : WEST_DOWN_NORTH; + } + } + } +} diff --git a/src/api/java/buildcraft/api/transport/IInjectable.java b/src/api/java/buildcraft/api/transport/IInjectable.java new file mode 100755 index 000000000..0292ae2ef --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IInjectable.java @@ -0,0 +1,28 @@ +package buildcraft.api.transport; + +import javax.annotation.Nonnull; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +/** Interface for pipes to implement if they can accept items in a similar fashion to BC pipes. */ +// TODO: Forge Capability! +public interface IInjectable { + /** Tests to see if this pipe can accept items from the given direction. Useless to call this if you are going to + * call {@link #injectItem(ItemStack, boolean, EnumFacing, EnumDyeColor, double)} straight after. */ + boolean canInjectItems(EnumFacing from); + + /** Offers an ItemStack for addition to the pipe. Will be rejected if the pipe doesn't accept items from that side. + * This should never be called on the client side! Implementors are free to throw an exception if be called on the + * client side. + * + * @param stack ItemStack offered for addition. Do not manipulate this! + * @param doAdd If false no actual addition should take place. Implementors should simulate. + * @param from Orientation the ItemStack is offered from. + * @param color The color of the item to be added to the pipe, or null for no color. + * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be used. + * @return The left over stack that was not accepted. */ + @Nonnull + ItemStack injectItem(@Nonnull ItemStack stack, boolean doAdd, EnumFacing from, EnumDyeColor color, double speed); +} diff --git a/src/api/java/buildcraft/api/transport/IItemPluggable.java b/src/api/java/buildcraft/api/transport/IItemPluggable.java new file mode 100755 index 000000000..f18df6344 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IItemPluggable.java @@ -0,0 +1,22 @@ +package buildcraft.api.transport; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +import buildcraft.api.transport.pipe.IPipeHolder; +import buildcraft.api.transport.pluggable.PipePluggable; + +/** Designates an item that can be placed onto a pipe as a {@link PipePluggable}. */ +public interface IItemPluggable { + /** Called when this item is placed onto a pipe holder. This can return null if this item does not make a valid + * pluggable. Note that if you return a non-null pluggable then it will *definatly* be added to the pipe, and you + * are responsible for making all the effects yourself (like the sound effect). + * + * @param stack The stack that holds this item + * @param holder The pipe holder + * @param side The side that the pluggable should be placed on + * @return A pluggable to place onto the pipe */ + PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side); +} diff --git a/src/api/java/buildcraft/api/transport/IStripesActivator.java b/src/api/java/buildcraft/api/transport/IStripesActivator.java new file mode 100755 index 000000000..a0dd7c878 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IStripesActivator.java @@ -0,0 +1,16 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.transport; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +public interface IStripesActivator { + boolean sendItem(@Nonnull ItemStack itemStack, EnumFacing from); + + void dropItem(@Nonnull ItemStack itemStack, EnumFacing from); +} diff --git a/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java b/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java new file mode 100755 index 000000000..888cac43e --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java @@ -0,0 +1,18 @@ +package buildcraft.api.transport; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IStripesHandlerBlock { + + /** @param world + * @param pos + * @param direction + * @param player + * @param activator + * @return True if this broke a block, false otherwise (note that this handler MUST NOT return false if it has + * changed the world in any way) */ + boolean handle(World world, BlockPos pos, EnumFacing direction, EntityPlayer player, IStripesActivator activator); +} diff --git a/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java b/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java new file mode 100755 index 000000000..6512be8cb --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java @@ -0,0 +1,30 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.transport; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IStripesHandlerItem { + + /** Called to handle the given {@link ItemStack} within the world. Note that the player's inventory will be empty, + * except that the target stack will be set into its {@link EnumHand#MAIN_HAND}. Any items left in the players + * inventory will be returned back through the activator with + * {@link IStripesActivator#sendItem(ItemStack, EnumFacing)} + * + * @param world + * @param pos + * @param direction + * @param stack The {@link ItemStack} being used + * @param player + * @param activator + * @return True if this used the item, false otherwise (note that this handler MUST NOT return false if it has + * changed the world in any way) */ + boolean handle(World world, BlockPos pos, EnumFacing direction, ItemStack stack, EntityPlayer player, IStripesActivator activator); +} diff --git a/src/api/java/buildcraft/api/transport/IStripesRegistry.java b/src/api/java/buildcraft/api/transport/IStripesRegistry.java new file mode 100755 index 000000000..73e881993 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IStripesRegistry.java @@ -0,0 +1,36 @@ +package buildcraft.api.transport; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IStripesRegistry { + + /** Adds a handler with a {@link HandlerPriority} of {@linkplain HandlerPriority#NORMAL NORMAL} */ + void addHandler(IStripesHandlerItem handler); + + void addHandler(IStripesHandlerItem handler, HandlerPriority priority); + + /** Adds a handler with a {@link HandlerPriority} of {@linkplain HandlerPriority#NORMAL NORMAL} */ + void addHandler(IStripesHandlerBlock handler); + + void addHandler(IStripesHandlerBlock handler, HandlerPriority priority); + + /** @param pos The position of the stripes pipe. + * @return True if a handler handled the itemstack, false otherwise (and so nothing has been done) */ + boolean handleItem(World world, BlockPos pos, EnumFacing direction, ItemStack stack, EntityPlayer player, IStripesActivator activator); + + /** @return True if a handler broke a block, false otherwise (and so nothing has been done) */ + boolean handleBlock(World world, BlockPos pos, EnumFacing direction, EntityPlayer player, IStripesActivator activator); + + // TODO: Ensure that this method really will work better than an integer for priorities. + public enum HandlerPriority { + HIGHEST, + HIGH, + NORMAL, + LOW, + LOWEST + } +} diff --git a/src/api/java/buildcraft/api/transport/IWireManager.java b/src/api/java/buildcraft/api/transport/IWireManager.java new file mode 100755 index 000000000..942c3ab58 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IWireManager.java @@ -0,0 +1,24 @@ +package buildcraft.api.transport; + +import net.minecraft.item.EnumDyeColor; + +import buildcraft.api.transport.pipe.IPipeHolder; + +public interface IWireManager { + + IPipeHolder getHolder(); + + void updateBetweens(boolean recursive); + + EnumDyeColor getColorOfPart(EnumWirePart part); + + EnumDyeColor removePart(EnumWirePart part); + + boolean addPart(EnumWirePart part, EnumDyeColor colour); + + boolean hasPartOfColor(EnumDyeColor color); + + boolean isPowered(EnumWirePart part); + + boolean isAnyPowered(EnumDyeColor color); +} diff --git a/src/api/java/buildcraft/api/transport/WireNode.java b/src/api/java/buildcraft/api/transport/WireNode.java new file mode 100755 index 000000000..5430b6438 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/WireNode.java @@ -0,0 +1,61 @@ +package buildcraft.api.transport; + +import java.util.EnumMap; +import java.util.Map; + +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.AxisDirection; +import net.minecraft.util.math.BlockPos; + +public class WireNode { + public final BlockPos pos; + public final EnumWirePart part; + private final int hash; + + public WireNode(BlockPos pos, EnumWirePart part) { + this.pos = pos; + this.part = part; + hash = pos.hashCode() * 31 + part.hashCode(); + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + WireNode other = (WireNode) obj; + return part == other.part // + && pos.equals(other.pos); + } + + @Override + public String toString() { + return "(" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ", " + part + ")"; + } + + public WireNode offset(EnumFacing face) { + int nx = (part.x == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetX(); + int ny = (part.y == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetY(); + int nz = (part.z == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetZ(); + EnumWirePart nPart = EnumWirePart.get(nx, ny, nz); + if (nx < 0 || ny < 0 || nz < 0 || nx > 1 || ny > 1 || nz > 1) { + return new WireNode(pos.offset(face), nPart); + } else { + return new WireNode(pos, nPart); + } + } + + public Map getAllPossibleConnections() { + Map map = new EnumMap<>(EnumFacing.class); + + for (EnumFacing face : EnumFacing.VALUES) { + map.put(face, offset(face)); + } + return map; + } +} diff --git a/src/api/java/buildcraft/api/transport/package-info.java b/src/api/java/buildcraft/api/transport/package-info.java new file mode 100755 index 000000000..004c271a1 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/package-info.java @@ -0,0 +1,8 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +@API(apiVersion = "5.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport") +package buildcraft.api.transport; + +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java b/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java new file mode 100755 index 000000000..ded7b2e22 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java @@ -0,0 +1,13 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface ICustomPipeConnection { + /** @return How long the connecting pipe should extend for, in addition to its normal 4/16f connection. Values less + * than or equal to -4/16 indicate that the pipe will not connect at all, and will render as it it was not + * connected. */ + public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java b/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java new file mode 100755 index 000000000..25bc329ca --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java @@ -0,0 +1,25 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; + +import buildcraft.api.core.IFluidFilter; + +public interface IFlowFluid { + /** @param millibuckets + * @param from + * @param filter The fluidstack that the extracted fluid must match, or null for any fluid. + * @return The fluidstack extracted and inserted into the pipe. */ + FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack filter); + + /** Advanced version of {@link #tryExtractFluid(int, EnumFacing, FluidStack)}. Note that this only works for + * instances of {@link IFluidHandler} that ALSO extends IFluidHandlerAdv + * + * @param millibuckets + * @param from + * @param filter A filter to try and match fluids. + * @return The fluidstack extracted and inserted into the pipe. */ + FluidStack tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java b/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java new file mode 100755 index 000000000..91a8b3afa --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java @@ -0,0 +1,32 @@ +package buildcraft.api.transport.pipe; + +import javax.annotation.Nonnull; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +import buildcraft.api.core.IStackFilter; +import buildcraft.api.transport.IInjectable; + +public interface IFlowItems extends IInjectable { + /** Attempts to extract items from the inventory connected to this pipe on the given side. + * + * @param count The maximum number of items to extract + * @param from The direction to extract from. + * @param colour The colour that extracted items should be painted. + * @param filter The filter to determine what can be extracted. + * @return The number of items extracted. */ + int tryExtractItems(int count, EnumFacing from, EnumDyeColor colour, IStackFilter filter); + + /** Inserts an item directly into the centre of this pipe, going in the given direction. This should ONLY be called + * from an instance of {@link PipeBehaviour}, as otherwise it can lead to problems. (For example crashing if a pipe + * contains an item that the pipe behaviour doesn't expect). + * + * @param stack ItemStack offered for addition. Do not manipulate this! + * @param from Orientation the ItemStack should pretend to be coming from. + * @param colour The colour of the item to be added to the pipe, or null for no colour. + * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be + * used. */ + void insertItemsForce(@Nonnull ItemStack stack, EnumFacing from, EnumDyeColor colour, double speed); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java b/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java new file mode 100755 index 000000000..051d0ad1c --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java @@ -0,0 +1,17 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.util.EnumFacing; + +import buildcraft.api.mj.IMjPassiveProvider; + +public interface IFlowPower { + /** Makes this pipe reconfigure itself, possibly due to the addition of new modules. */ + void reconfigure(); + + /** Attempts to extract power from the {@link IMjPassiveProvider} connected to this pipe on the given side. + * + * @param maxPower The Maximum amount of power that can be extracted. + * @param from The side (of this pipe) to take power from. + * @return The amount of power extracted. */ + long tryExtractPower(long maxPower, EnumFacing from); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java b/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java new file mode 100755 index 000000000..fbff67747 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java @@ -0,0 +1,7 @@ +package buildcraft.api.transport.pipe; + +/** To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct + * dependency on transport. */ +public interface IItemPipe { + PipeDefinition getDefiniton(); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipe.java b/src/api/java/buildcraft/api/transport/pipe/IPipe.java new file mode 100755 index 000000000..2a7a15c30 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipe.java @@ -0,0 +1,36 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.common.capabilities.ICapabilityProvider; + +public interface IPipe extends ICapabilityProvider { + IPipeHolder getHolder(); + + PipeDefinition getDefinition(); + + PipeBehaviour getBehaviour(); + + PipeFlow getFlow(); + + EnumDyeColor getColour(); + + void setColour(EnumDyeColor colour); + + void markForUpdate(); + + TileEntity getConnectedTile(EnumFacing side); + + IPipe getConnectedPipe(EnumFacing side); + + boolean isConnected(EnumFacing side); + + ConnectedType getConnectedType(EnumFacing side); + + public enum ConnectedType { + TILE, + PIPE; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java b/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java new file mode 100755 index 000000000..f981c9ea2 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java @@ -0,0 +1,11 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.client.renderer.VertexBuffer; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IPipeBehaviourRenderer { + void render(B behaviour, double x, double y, double z, float partialTicks, VertexBuffer vb); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java b/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java new file mode 100755 index 000000000..55a514286 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java @@ -0,0 +1,26 @@ +/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com + * + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ +package buildcraft.api.transport.pipe; + +import net.minecraft.util.EnumFacing; + +@Deprecated +// TODO: Test to see if this is necessary! (Or perhaps make it a capability) +public interface IPipeConnection { + + enum ConnectOverride { + + CONNECT, + DISCONNECT, + DEFAULT + } + + /** Allows you to override pipe connection logic. + * + * @param type + * @param with + * @return CONNECT to force a connection, DISCONNECT to force no connection, and DEFAULT to let the pipe decide. */ + ConnectOverride overridePipeConnection(Object/*IPipeTile.PipeType*/ type, EnumFacing with); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java b/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java new file mode 100755 index 000000000..787f9e99d --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java @@ -0,0 +1,12 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.client.renderer.VertexBuffer; + +public interface IPipeFlowRenderer { + /** @param flow The flow to render + * @param x + * @param y + * @param z + * @param vb The (optional) vertex buffer that you can render into. Note that you can still do GL stuff. */ + void render(F flow, double x, double y, double z, float partialTicks, VertexBuffer vb); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java b/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java new file mode 100755 index 000000000..5ce5173b4 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java @@ -0,0 +1,95 @@ +package buildcraft.api.transport.pipe; + +import com.mojang.authlib.GameProfile; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import buildcraft.api.statements.containers.IRedstoneStatementContainer; +import buildcraft.api.transport.IWireManager; +import buildcraft.api.transport.pluggable.PipePluggable; + +/** Designates a tile that can contain a pipe, up to 6 sided pluggables. */ +public interface IPipeHolder extends IRedstoneStatementContainer { + World getPipeWorld(); + + BlockPos getPipePos(); + + TileEntity getPipeTile(); + + IPipe getPipe(); + + PipePluggable getPluggable(EnumFacing side); + + TileEntity getNeighbouringTile(EnumFacing side); + + IPipe getNeighbouringPipe(EnumFacing side); + + IWireManager getWireManager(); + + GameProfile getOwner(); + + /** @return True if at least 1 handler received this event, false if not. */ + boolean fireEvent(PipeEvent event); + + void scheduleRenderUpdate(); + + /** @param parts The parts that want to send a network update. */ + void scheduleNetworkUpdate(PipeMessageReceiver... parts); + + /** Schedules a GUI network update, that is only the players who currently have a pipe element open in a GUI will be + * updated. + * + * @param parts The parts that want to send a network update. */ + void scheduleNetworkGuiUpdate(PipeMessageReceiver... parts); + + /** Sends a custom message from a pluggable or pipe centre to the server/client (depending on which side this is + * currently on). */ + void sendMessage(PipeMessageReceiver to, IWriter writer); + + void sendGuiMessage(PipeMessageReceiver to, IWriter writer); + + /** Called on the server whenever a gui container object is opened. */ + void onPlayerOpen(EntityPlayer player); + + /** Called on the server whenever a gui container object is closed. */ + void onPlayerClose(EntityPlayer player); + + public enum PipeMessageReceiver { + BEHAVIOUR(null), + FLOW(null), + PLUGGABLE_DOWN(EnumFacing.DOWN), + PLUGGABLE_UP(EnumFacing.UP), + PLUGGABLE_NORTH(EnumFacing.NORTH), + PLUGGABLE_SOUTH(EnumFacing.SOUTH), + PLUGGABLE_WEST(EnumFacing.WEST), + PLUGGABLE_EAST(EnumFacing.EAST), + WIRES(null); + // Wires are updated differently (they never use this API) + + public static final PipeMessageReceiver[] VALUES = values(); + public static final PipeMessageReceiver[] PLUGGABLES = new PipeMessageReceiver[6]; + + static { + for (PipeMessageReceiver type : VALUES) { + if (type.face != null) { + PLUGGABLES[type.face.ordinal()] = type; + } + } + } + + public final EnumFacing face; + + PipeMessageReceiver(EnumFacing face) { + this.face = face; + } + } + + public interface IWriter { + void write(PacketBuffer buffer); + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java b/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java new file mode 100755 index 000000000..23672c6bf --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java @@ -0,0 +1,17 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.util.ResourceLocation; + +public interface IPipeRegistry { + PipeDefinition getDefinition(ResourceLocation identifier); + + IItemPipe registerPipeAndItem(PipeDefinition definition); + + void registerPipe(PipeDefinition definition); + + void setItemForPipe(PipeDefinition definition, IItemPipe item); + + IItemPipe getItemForPipe(PipeDefinition definition); + + Iterable getAllRegisteredPipes(); +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeApi.java b/src/api/java/buildcraft/api/transport/pipe/PipeApi.java new file mode 100755 index 000000000..f401dc48f --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeApi.java @@ -0,0 +1,52 @@ +package buildcraft.api.transport.pipe; + +import java.util.IdentityHashMap; +import java.util.Map; + +import buildcraft.api.transport.IStripesRegistry; +import buildcraft.api.transport.pluggable.IPluggableRegistry; + +/** The central holding class for all pipe related registers and methods. */ +public final class PipeApi { + public static IPipeRegistry pipeRegistry; + public static IPluggableRegistry pluggableRegistry; + public static IStripesRegistry stripeRegistry; + public static PipeFlowType flowStructure; + public static PipeFlowType flowItems; + public static PipeFlowType flowFluids; + public static PipeFlowType flowPower; + + /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced + * by BuildCraft Transport to config-defined values. */ + public static FluidTransferInfo transferInfoDefault = new FluidTransferInfo(20, 10); + + public static final Map fluidTransferData = new IdentityHashMap<>(); + + public static FluidTransferInfo getFluidTransferInfo(PipeDefinition def) { + FluidTransferInfo info = fluidTransferData.get(def); + if (info == null) { + return transferInfoDefault; + } else { + return info; + } + } + + public static class FluidTransferInfo { + /** Controls the maximum amount of fluid that can be transfered around and out of a pipe per tick. Note that + * this does not affect the flow rate coming into the pipe. */ + public final int transferPerTick; + + /** Controls how long the pipe should delay incoming fluids by. Minimum value is 1, because of the way that + * fluids are handled internally. This value is multiplied by the fluids viscosity, and divided by 100 to give + * the actual delay. */ + public final double transferDelayMultiplier; + + public FluidTransferInfo(int transferPerTick, int transferDelay) { + this.transferPerTick = transferPerTick; + if (transferDelay <= 0) { + transferDelay = 1; + } + this.transferDelayMultiplier = transferDelay; + } + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java b/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java new file mode 100755 index 000000000..04650bfb2 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java @@ -0,0 +1,26 @@ +package buildcraft.api.transport.pipe; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import buildcraft.api.transport.pluggable.IPlugDynamicRenderer; +import buildcraft.api.transport.pluggable.IPluggableStaticBaker; +import buildcraft.api.transport.pluggable.PipePluggable; +import buildcraft.api.transport.pluggable.PluggableModelKey; + +@SideOnly(Side.CLIENT) +public enum PipeApiClient { + INSTANCE; + + public static IClientRegistry registry; + + public interface IClientRegistry { + void registerRenderer(Class flowClass, IPipeFlowRenderer renderer); + + void registerRenderer(Class behaviourClass, IPipeBehaviourRenderer renderer); + +

void registerRenderer(Class plugClass, IPlugDynamicRenderer

renderer); + +

void registerBaker(Class keyClass, IPluggableStaticBaker

renderer); + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java b/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java new file mode 100755 index 000000000..624d75b99 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java @@ -0,0 +1,67 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.RayTraceResult; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; + +import buildcraft.api.core.EnumPipePart; + +public abstract class PipeBehaviour implements ICapabilityProvider { + public final IPipe pipe; + + public PipeBehaviour(IPipe pipe) { + this.pipe = pipe; + } + + public PipeBehaviour(IPipe pipe, NBTTagCompound nbt) { + this.pipe = pipe; + } + + public NBTTagCompound writeToNbt() { + NBTTagCompound nbt = new NBTTagCompound(); + + return nbt; + } + + public void writePayload(PacketBuffer buffer, Side side) {} + + public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) {} + + public int getTextureIndex(EnumFacing face) { + return 0; + } + + // Event handling + + public boolean canConnect(EnumFacing face, PipeBehaviour other) { + return true; + } + + public boolean canConnect(EnumFacing face, TileEntity oTile) { + return true; + } + + public boolean onPipeActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, EnumPipePart part) { + return false; + } + + public void onTick() {} + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return false; + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + return null; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java b/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java new file mode 100755 index 000000000..336ce551a --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java @@ -0,0 +1,51 @@ +package buildcraft.api.transport.pipe; + +import java.util.Map; + +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +/** Use this class to register blocks with custom block sizes so that pipes can connect to them properly. Note that you + * do not need to register a custom pipe connection if your block implements ICustomPipeConnection. The registered + * version does not override your own implementation. */ +public final class PipeConnectionAPI { + private static final Map connections = Maps.newHashMap(); + private static final ICustomPipeConnection NOTHING = new ICustomPipeConnection() { + @Override + public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state) { + return 0; + } + }; + + /** Register a block with a custom connection. Useful if you don't own the block class or are adding it for some-one + * else. + * + * @param block The block instance + * @param connection The connection instance */ + public static void registerConnection(Block block, ICustomPipeConnection connection) { + connections.put(block, connection); + } + + /** Ensures that a particular block will always have the default connection, no matter what the bounding box the the + * block is. */ + public static void registerConnectionAsNothing(Block block) { + connections.put(block, NOTHING); + } + + /** Gets the current custom connection that the block uses. Will be null if nothing has been set. */ + public static ICustomPipeConnection getCustomConnection(Block block) { + if (block instanceof ICustomPipeConnection) { + return (ICustomPipeConnection) block; + } + ICustomPipeConnection connection = connections.get(block); + if (connection != null) { + return connection; + } + return null; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java b/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java new file mode 100755 index 000000000..845d6b70b --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java @@ -0,0 +1,159 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; + +public final class PipeDefinition { + public final ResourceLocation identifier; + public final IPipeCreator logicConstructor; + public final IPipeLoader logicLoader; + public final PipeFlowType flowType; + public final String[] textures; + public final int itemTextureTop, itemTextureCenter, itemTextureBottom; + + public PipeDefinition(PipeDefinitionBuilder builder) { + this.identifier = builder.identifier; + this.textures = new String[builder.textureSuffixes.length]; + for (int i = 0; i < textures.length; i++) { + textures[i] = builder.texturePrefix + builder.textureSuffixes[i]; + } + this.logicConstructor = builder.logicConstructor; + this.logicLoader = builder.logicLoader; + this.flowType = builder.flowType; + this.itemTextureTop = builder.itemTextureTop; + this.itemTextureCenter = builder.itemTextureCenter; + this.itemTextureBottom = builder.itemTextureBottom; + } + + @FunctionalInterface + public interface IPipeCreator { + PipeBehaviour createBehaviour(IPipe t); + } + + @FunctionalInterface + public interface IPipeLoader { + PipeBehaviour loadBehaviour(IPipe t, NBTTagCompound u); + } + + public static class PipeDefinitionBuilder { + public ResourceLocation identifier; + public String texturePrefix; + public String[] textureSuffixes = { "" }; + public IPipeCreator logicConstructor; + public IPipeLoader logicLoader; + public PipeFlowType flowType; + public int itemTextureTop = 0; + public int itemTextureCenter = 0; + public int itemTextureBottom = 0; + + public PipeDefinitionBuilder() {} + + public PipeDefinitionBuilder(ResourceLocation identifier, IPipeCreator logicConstructor, IPipeLoader logicLoader, PipeFlowType flowType) { + this.identifier = identifier; + this.logicConstructor = logicConstructor; + this.logicLoader = logicLoader; + this.flowType = flowType; + } + + public PipeDefinitionBuilder idTexPrefix(String both) { + return id(both).texPrefix(both); + } + + public PipeDefinitionBuilder idTex(String both) { + return id(both).tex(both); + } + + private static String getActiveModId() { + ModContainer mod = Loader.instance().activeModContainer(); + if (mod == null) { + throw new IllegalStateException("Cannot interact with PipeDefinition outside of an activly scoped mod!"); + } + return mod.getModId(); + } + + public PipeDefinitionBuilder id(String post) { + identifier = new ResourceLocation(getActiveModId(), post); + return this; + } + + public PipeDefinitionBuilder tex(String prefix, String... suffixes) { + return texPrefix(prefix).texSuffixes(suffixes); + } + + /** Sets the texture prefix to be: [current_mod_id]:pipes/[prefix] where [current_mod_id] is the + * modid of the currently loaded mod, and [prefix] is the string parameter given. + * + * @return this */ + public PipeDefinitionBuilder texPrefix(String prefix) { + return texPrefixDirect(getActiveModId() + ":pipes/" + prefix); + } + + /** Sets the {@link #texturePrefix} to the input string, without any additions or changes (unlike + * {@link #texPrefix(String)}) + * + * @return this */ + public PipeDefinitionBuilder texPrefixDirect(String prefix) { + texturePrefix = prefix; + return this; + } + + /** Sets {@link #textureSuffixes} to the given array, or to {""} if the argument list is empty or + * null. + * + * @return this. */ + public PipeDefinitionBuilder texSuffixes(String... suffixes) { + if (suffixes == null || suffixes.length == 0) { + textureSuffixes = new String[] { "" }; + } else { + textureSuffixes = suffixes; + } + return this; + } + + public PipeDefinitionBuilder itemTex(int all) { + itemTextureTop = all; + itemTextureCenter = all; + itemTextureBottom = all; + return this; + } + + public PipeDefinitionBuilder itemTex(int top, int center, int bottom) { + itemTextureTop = top; + itemTextureCenter = center; + itemTextureBottom = bottom; + return this; + } + + public PipeDefinitionBuilder logic(IPipeCreator creator, IPipeLoader loader) { + logicConstructor = creator; + logicLoader = loader; + return this; + } + + public PipeDefinitionBuilder flowItem() { + return flow(PipeApi.flowItems); + } + + public PipeDefinitionBuilder flowFluid() { + return flow(PipeApi.flowFluids); + } + + public PipeDefinitionBuilder flowPower() { + return flow(PipeApi.flowPower); + } + + public PipeDefinitionBuilder flow(PipeFlowType flow) { + flowType = flow; + return this; + } + + public PipeDefinition define() { + PipeDefinition def = new PipeDefinition(this); + PipeApi.pipeRegistry.registerPipe(def); + return def; + } + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java b/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java new file mode 100755 index 000000000..a5c41062c --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java @@ -0,0 +1,28 @@ +package buildcraft.api.transport.pipe; + +/** The base class for all pipe events. Some event classes can be cancelled with {@link #cancel()}, however this will + * only have an effect if {@link #canBeCancelled} is true. Refer to indervidual classes for information on what*/ +public abstract class PipeEvent { + public final boolean canBeCancelled; + public final IPipeHolder holder; + private boolean canceled = false; + + public PipeEvent(IPipeHolder holder) { + this(false, holder); + } + + protected PipeEvent(boolean canBeCancelled, IPipeHolder holder) { + this.canBeCancelled = canBeCancelled; + this.holder = holder; + } + + public void cancel() { + if (canBeCancelled) { + canceled = true; + } + } + + public boolean isCanceled() { + return canceled; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java new file mode 100755 index 000000000..ea6b37acc --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java @@ -0,0 +1,18 @@ +package buildcraft.api.transport.pipe; + +import buildcraft.api.core.EnumPipePart; +import buildcraft.api.statements.IAction; +import buildcraft.api.statements.IStatementParameter; + +public class PipeEventActionActivate extends PipeEvent { + public final IAction action; + public final IStatementParameter[] params; + public final EnumPipePart part; + + public PipeEventActionActivate(IPipeHolder holder, IAction action, IStatementParameter[] params, EnumPipePart part) { + super(holder); + this.action = action; + this.params = params; + this.part = part; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java new file mode 100755 index 000000000..f31714203 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java @@ -0,0 +1,130 @@ +package buildcraft.api.transport.pipe; + +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; + +import com.google.common.collect.Lists; + +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.fluids.FluidStack; + +public abstract class PipeEventFluid extends PipeEvent { + + public final IFlowFluid flow; + + protected PipeEventFluid(IPipeHolder holder, IFlowFluid flow) { + super(holder); + this.flow = flow; + } + + protected PipeEventFluid(boolean canBeCancelled, IPipeHolder holder, IFlowFluid flow) { + super(canBeCancelled, holder); + this.flow = flow; + } + + public static class SideCheck extends PipeEventFluid { + public final FluidStack fluid; + + /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower + * value than a lower priority. */ + private final int[] priority = new int[6]; + private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); + + public SideCheck(IPipeHolder holder, IFlowFluid flow, FluidStack fluid) { + super(holder, flow); + this.fluid = fluid; + } + + /** Checks to see if a side if allowed. Note that this may return true even though a later handler might + * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not + * check the filters for a specific side if its already been disallowed) */ + public boolean isAllowed(EnumFacing side) { + return allowed.contains(side); + } + + /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then the + * fluid will stay in the current pipe section. */ + public void disallow(EnumFacing... sides) { + for (EnumFacing side : sides) { + allowed.remove(side); + } + } + + public void disallowAll(Collection sides) { + allowed.removeAll(sides); + } + + public void disallowAllExcept(EnumFacing... sides) { + allowed.retainAll(Lists.newArrayList(sides)); + } + + public void disallowAllExcept(Collection sides) { + allowed.retainAll(sides); + } + + public void disallowAll() { + allowed.clear(); + } + + public void increasePriority(EnumFacing side) { + increasePriority(side, 1); + } + + public void increasePriority(EnumFacing side, int by) { + priority[side.ordinal()] -= by; + } + + public void decreasePriority(EnumFacing side) { + decreasePriority(side, 1); + } + + public void decreasePriority(EnumFacing side, int by) { + increasePriority(side, -by); + } + + public EnumSet getOrder() { + if (allowed.isEmpty()) { + return EnumSet.noneOf(EnumFacing.class); + } + if (allowed.size() == 1) { + return allowed; + } + outer_loop: while (true) { + int val = priority[0]; + for (int i = 1; i < priority.length; i++) { + if (priority[i] != val) { + break outer_loop; + } + } + // No need to work out the order when all destinations have the same priority + return allowed; + } + + int[] ordered = Arrays.copyOf(priority, 6); + Arrays.sort(ordered); + int last = 0; + for (int i = 0; i < 6; i++) { + int current = ordered[i]; + if (i != 0 && current == last) { + continue; + } + last = current; + EnumSet set = EnumSet.noneOf(EnumFacing.class); + for (EnumFacing face : EnumFacing.VALUES) { + if (allowed.contains(face)) { + if (priority[face.ordinal()] == current) { + set.add(face); + } + } + } + if (set.size() > 0) { + return set; + } + } + return EnumSet.noneOf(EnumFacing.class); + } + } + +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java new file mode 100755 index 000000000..1ef3667a6 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java @@ -0,0 +1,29 @@ +package buildcraft.api.transport.pipe; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** Designates a method that will receive a pipe event. The method must be public and take a single parameter that + * extends {@link PipeEvent}.
+ * An example is:
+ * + @PipeEventHandler
+ public void sideCheck(PipeEventItem.SideCheck sideCheck) {
+ // Logic ommited
+ } + * + *
*/ +@Retention(RUNTIME) +@Target(METHOD) +public @interface PipeEventHandler { + /** Designates the priority that the handler will be given. All handlers in vanilla BuildCraft use + * {@link PipeEventPriority#NORMAL}, so this is given for other pipe mods to fire before or after all BC logic has + * taken place. */ + PipeEventPriority priority() default PipeEventPriority.NORMAL; + + /** If true then the event handler will be called even if an event has already been cancelled. */ + boolean receiveCancelled() default false; +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java new file mode 100755 index 000000000..6e1d44820 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java @@ -0,0 +1,349 @@ +package buildcraft.api.transport.pipe; + +import java.util.*; + +import javax.annotation.Nonnull; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; + +public abstract class PipeEventItem extends PipeEvent { + + public final IFlowItems flow; + + protected PipeEventItem(IPipeHolder holder, IFlowItems flow) { + super(holder); + this.flow = flow; + } + + protected PipeEventItem(boolean canBeCancelled, IPipeHolder holder, IFlowItems flow) { + super(canBeCancelled, holder); + this.flow = flow; + } + + // ################ + // + // Misc events + // + // ################ + + /** Fires whenever item insertion is attempted. The item might have been extracted by the pipe behaviour, inserted + * by another pipe or even a different kind of tile. Note that you have no way of telling what caused this event. */ + public static class TryInsert extends PipeEventItem { + public final EnumDyeColor colour; + public final EnumFacing from; + /** The itemstack that is attempting to be inserted. NEVER CHANGE THIS! */ + @Nonnull + public final ItemStack attempting; + /** The count of items that are being accepted into this pipe. Starts off at the stack count of + * {@link #attempting} */ + public int accepted; + + public TryInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack attempting) { + super(true, holder, flow); + this.colour = colour; + this.from = from; + this.attempting = attempting; + this.accepted = attempting.getCount(); + } + + /** Stops the item from being accepted. */ + @Override + public void cancel() { + super.cancel(); + } + } + + public static abstract class ReachDest extends PipeEventItem { + public EnumDyeColor colour; + @Nonnull + private ItemStack stack; + + public ReachDest(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack) { + super(holder, flow); + this.colour = colour; + this.stack = stack; + } + + @Nonnull + public ItemStack getStack() { + return this.stack; + } + + public void setStack(ItemStack stack) { + if (stack == null) { + throw new NullPointerException("stack"); + } else { + this.stack = stack; + } + } + } + + /** Fired after {@link TryInsert} (if some items were allowed in) to modify the incoming itemstack or its colour. */ + public static class OnInsert extends ReachDest { + public final EnumFacing from; + + public OnInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { + super(holder, flow, colour, stack); + this.from = from; + } + } + + /** Fired whenever an item reaches the centre of a pipe. Note that you *can* change the itemstack or the colour. */ + public static class ReachCenter extends ReachDest { + public final EnumFacing from; + + public ReachCenter(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { + super(holder, flow, colour, stack); + this.from = from; + } + } + + /** Fired whenever an item reaches the end of a pipe. Note that you *can* change the itemstack or the colour. */ + public static class ReachEnd extends ReachDest { + public final EnumFacing to; + + public ReachEnd(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing to) { + super(holder, flow, colour, stack); + this.to = to; + } + } + + // ############################ + // + // Destination related + // + // ############################ + + /** Fired after {@link ReachCenter} to determine what sides are the items NOT allowed to go to, and the order of + * priority for the allowed sides. */ + public static class SideCheck extends PipeEventItem { + public final EnumDyeColor colour; + public final EnumFacing from; + @Nonnull + public final ItemStack stack; + + /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower + * value than a lower priority. */ + private final int[] priority = new int[6]; + private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); + + public SideCheck(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack stack) { + super(holder, flow); + this.colour = colour; + this.from = from; + this.stack = stack; + } + + /** Checks to see if a side if allowed. Note that this may return true even though a later handler might + * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not + * check the filters for a specific side if its already been disallowed) */ + public boolean isAllowed(EnumFacing side) { + return allowed.contains(side); + } + + /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then + * {@link TryBounce} will be fired to test if the item can bounce back. */ + public void disallow(EnumFacing... sides) { + for (EnumFacing side : sides) { + allowed.remove(side); + } + } + + public void disallowAll(Collection sides) { + allowed.removeAll(sides); + } + + public void disallowAllExcept(EnumFacing... sides) { + allowed.retainAll(Lists.newArrayList(sides)); + } + + public void disallowAll() { + allowed.clear(); + } + + public void increasePriority(EnumFacing side) { + increasePriority(side, 1); + } + + public void increasePriority(EnumFacing side, int by) { + priority[side.ordinal()] -= by; + } + + public void decreasePriority(EnumFacing side) { + decreasePriority(side, 1); + } + + public void decreasePriority(EnumFacing side, int by) { + increasePriority(side, -by); + } + + public List> getOrder() { + // Skip the calculations if the size is simple + switch (allowed.size()) { + case 0: + return ImmutableList.of(); + case 1: + return ImmutableList.of(allowed); + } + outer_loop: while (true) { + int val = priority[0]; + for (int i = 1; i < priority.length; i++) { + if (priority[i] != val) { + break outer_loop; + } + } + // No need to work out the order when all destinations have the same priority + return ImmutableList.of(allowed); + } + + int[] ordered = Arrays.copyOf(priority, 6); + Arrays.sort(ordered); + int last = 0; + List> list = Lists.newArrayList(); + for (int i = 0; i < 6; i++) { + int current = ordered[i]; + if (i != 0 && current == last) { + continue; + } + last = current; + EnumSet set = EnumSet.noneOf(EnumFacing.class); + for (EnumFacing face : EnumFacing.VALUES) { + if (allowed.contains(face)) { + if (priority[face.ordinal()] == current) { + set.add(face); + } + } + } + if (set.size() > 0) { + list.add(set); + } + } + return list; + } + } + + /** Fired after {@link SideCheck} (if all sides were disallowed) to see if the item is allowed to bounce back to + * where it was inserted. */ + public static class TryBounce extends PipeEventItem { + public final EnumDyeColor colour; + public final EnumFacing from; + @Nonnull + public final ItemStack stack; + public boolean canBounce = false; + + public TryBounce(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack stack) { + super(holder, flow); + this.colour = colour; + this.from = from; + this.stack = stack; + } + } + + public static class Drop extends PipeEventItem { + @Nonnull + private ItemStack stack; + + public Drop(IPipeHolder holder, IFlowItems flow, @Nonnull ItemStack stack) { + super(holder, flow); + this.stack = stack; + } + + @Nonnull + public ItemStack getStack() { + return this.stack; + } + + public void setStack(ItemStack stack) { + if (stack == null) { + throw new NullPointerException("stack"); + } else { + this.stack = stack; + } + } + } + + /** Base class for {@link Split} and {@link FindDest}. Do not listen to this directly! */ + public static abstract class OrderedEvent extends PipeEventItem { + public final List> orderedDestinations; + + public OrderedEvent(IPipeHolder holder, IFlowItems flow, List> orderedDestinations) { + super(holder, flow); + this.orderedDestinations = orderedDestinations; + } + + public ImmutableList generateRandomOrder() { + ImmutableList.Builder builder = ImmutableList.builder(); + for (EnumSet set : orderedDestinations) { + List faces = new ArrayList<>(set); + Collections.shuffle(faces); + builder.addAll(faces); + } + return builder.build(); + } + } + + /** Fired after {@link SideCheck} (if at least one valid side was found) or after {@link TryBounce} if no valid + * sides were detected, but it was allowed to bounce back. This event is for splitting up (or modifying) the input + * itemstack. This is most helpful for implementing full round-robin behaviour, or diamond-pipe based splitting. If + * you need to generate a random facing for each one then use {@link OrderedEvent#generateRandomOrder()}. */ + public static class Split extends OrderedEvent { + public final List items = new ArrayList<>(); + + public Split(IPipeHolder holder, IFlowItems flow, List> order, ItemEntry toSplit) { + super(holder, flow, order); + items.add(toSplit); + } + } + + /** Fired after {@link Split}. This event is for assigning a destination to each {@link ItemEntry} in + * {@link Split#items}. If you need to generate a random facing for each one then use + * {@link OrderedEvent#generateRandomOrder()}. */ + public static class FindDest extends OrderedEvent { + public final ImmutableList items; + + public FindDest(IPipeHolder holder, IFlowItems flow, List> orderedDestinations, ImmutableList items) { + super(holder, flow, orderedDestinations); + this.items = items; + } + } + + /** Fired after {@link FindDest}. */ + public static class ModifySpeed extends PipeEventItem { + public final ItemEntry item; + public final double currentSpeed; + public double targetSpeed = 0; + public double maxSpeedChange = 0; + + public ModifySpeed(IPipeHolder holder, IFlowItems flow, ItemEntry item, double initSpeed) { + super(holder, flow); + this.item = item; + currentSpeed = initSpeed; + } + + public void modifyTo(double target, double maxDelta) { + targetSpeed = target; + maxSpeedChange = maxDelta; + } + } + + /** Mostly immutable holding class for item stacks. */ + public static class ItemEntry { + public final EnumDyeColor colour; + @Nonnull + public final ItemStack stack; + public final EnumFacing from; + /** An list of the destinations to try, in order. */ + public List to; + + public ItemEntry(EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { + this.colour = colour; + this.stack = stack; + this.from = from; + } + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java new file mode 100755 index 000000000..1a91c517c --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java @@ -0,0 +1,73 @@ +package buildcraft.api.transport.pipe; + +import buildcraft.api.mj.MjAPI; + +public abstract class PipeEventPower extends PipeEvent { + public final IFlowPower flow; + + protected PipeEventPower(IPipeHolder holder, IFlowPower flow) { + super(holder); + this.flow = flow; + } + + protected PipeEventPower(boolean canBeCancelled, IPipeHolder holder, IFlowPower flow) { + super(canBeCancelled, holder); + this.flow = flow; + } + + public static class Configure extends PipeEventPower { + private long maxPower = 10 * MjAPI.MJ; + /** The percentage resistance of the power pipe (as in, percentage of current power going through the pipe). + * Should be a number between 0 and {@link MjAPI#MJ} */ + private long powerResistance = -1; + /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, + * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ + private long powerLoss = -1; + private boolean receiver = false; + + public Configure(IPipeHolder holder, IFlowPower flow) { + super(holder, flow); + } + + public long getMaxPower() { + return this.maxPower; + } + + public void setMaxPower(long maxPower) { + this.maxPower = maxPower; + } + + /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, + * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ + public long getPowerLoss() { + return this.powerLoss; + } + + /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, + * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ + public void setPowerLoss(long powerLoss) { + this.powerLoss = powerLoss; + } + + /** The percentage resistance of the power pipe (percentage of current power going through the pipe that will be + * lost). Should be a number between 0 and {@link MjAPI#MJ} */ + public long getPowerResistance() { + return this.powerResistance; + } + + /** The percentage resistance of the power pipe (percentage of current power going through the pipe that will be + * lost). Should be a number between 0 and {@link MjAPI#MJ} */ + public void setPowerResistance(long powerResistance) { + this.powerResistance = powerResistance; + } + + public boolean isReceiver() { + return this.receiver; + } + + /** Sets this pipe to be one that receives power from external sources. */ + public void setReceiver(boolean receiver) { + this.receiver = receiver; + } + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java new file mode 100755 index 000000000..cedaaa83f --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java @@ -0,0 +1,7 @@ +package buildcraft.api.transport.pipe; + +public enum PipeEventPriority { + PRE, + NORMAL, + POST; +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java new file mode 100755 index 000000000..5d96cafc2 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java @@ -0,0 +1,66 @@ +package buildcraft.api.transport.pipe; + +import java.util.Collection; + +import javax.annotation.Nonnull; + +import net.minecraft.util.EnumFacing; + +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionInternalSided; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerInternalSided; + +public abstract class PipeEventStatement extends PipeEvent { + public PipeEventStatement(IPipeHolder holder) { + super(holder); + } + + /** Fired when a pipe should add internal triggers to the list of all possible triggers */ + public static class AddTriggerInternal extends PipeEventStatement { + public final Collection triggers; + + public AddTriggerInternal(IPipeHolder holder, Collection triggers) { + super(holder); + this.triggers = triggers; + } + } + + /** Fired when a pipe should add internal sided triggers to the list of all possible triggers */ + public static class AddTriggerInternalSided extends PipeEventStatement { + public final Collection triggers; + + @Nonnull + public final EnumFacing side; + + public AddTriggerInternalSided(IPipeHolder holder, Collection triggers, @Nonnull EnumFacing side) { + super(holder); + this.triggers = triggers; + this.side = side; + } + } + + /** Fired when a pipe should add internal actions to the list of all possible actions */ + public static class AddActionInternal extends PipeEventStatement { + public final Collection actions; + + public AddActionInternal(IPipeHolder holder, Collection actions) { + super(holder); + this.actions = actions; + } + } + + /** Fired when a pipe should add internal actions to the list of all possible actions */ + public static class AddActionInternalSided extends PipeEventStatement { + public final Collection actions; + + @Nonnull + public final EnumFacing side; + + public AddActionInternalSided(IPipeHolder holder, Collection actions, @Nonnull EnumFacing side) { + super(holder); + this.actions = actions; + this.side = side; + } + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java b/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java new file mode 100755 index 000000000..d35e34a22 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java @@ -0,0 +1,82 @@ +package buildcraft.api.transport.pipe; + +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.RayTraceResult; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fml.relauncher.Side; + +import buildcraft.api.core.EnumPipePart; +import buildcraft.api.transport.pipe.IPipeHolder.IWriter; +import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; + +public abstract class PipeFlow implements ICapabilityProvider { + /** The ID for completely refreshing the state of this flow. */ + public static final int NET_ID_FULL_STATE = 0; + /** The ID for updating what has changed since the last NET_ID_FULL_STATE or NET_ID_UPDATE has been sent. */ + // Wait, what? How is that a good idea or even sensible to make updates work this way? + public static final int NET_ID_UPDATE = 1; + + public final IPipe pipe; + + public PipeFlow(IPipe pipe) { + this.pipe = pipe; + } + + public PipeFlow(IPipe pipe, NBTTagCompound nbt) { + this.pipe = pipe; + } + + public NBTTagCompound writeToNbt() { + return new NBTTagCompound(); + } + + /** Writes a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ + public void writePayload(int id, PacketBuffer buffer, Side side) {} + + /** Reads a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ + public void readPayload(int id, PacketBuffer buffer, Side side) throws IOException {} + + public void sendPayload(int id) { + final Side side = pipe.getHolder().getPipeWorld().isRemote ? Side.CLIENT : Side.SERVER; + sendCustomPayload(id, (buf) -> writePayload(id, buf, side)); + } + + public final void sendCustomPayload(int id, IWriter writer) { + pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, new IWriter() { + @Override + public void write(PacketBuffer buffer) { + buffer.writeBoolean(true); + buffer.writeShort(id); + writer.write(buffer); + } + }); + } + + public abstract boolean canConnect(EnumFacing face, PipeFlow other); + + public abstract boolean canConnect(EnumFacing face, TileEntity oTile); + + public void onTick() {} + + public boolean onFlowActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, EnumPipePart part) { + return false; + } + + @Override + public final boolean hasCapability(Capability capability, EnumFacing facing) { + return getCapability(capability, facing) != null; + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + return null; + } +} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java b/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java new file mode 100755 index 000000000..290517012 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java @@ -0,0 +1,23 @@ +package buildcraft.api.transport.pipe; + +import net.minecraft.nbt.NBTTagCompound; + +public final class PipeFlowType { + public final IFlowCreator creator; + public final IFlowLoader loader; + + public PipeFlowType(IFlowCreator creator, IFlowLoader loader) { + this.creator = creator; + this.loader = loader; + } + + @FunctionalInterface + public interface IFlowCreator { + PipeFlow createFlow(IPipe t); + } + + @FunctionalInterface + public interface IFlowLoader { + PipeFlow loadFlow(IPipe t, NBTTagCompound u); + } +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java new file mode 100755 index 000000000..a3ad9f329 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java @@ -0,0 +1,11 @@ +package buildcraft.api.transport.pluggable; + +import net.minecraft.block.state.IBlockState; + +public interface IFacadePluggable { + IBlockState getCurrentState(); + + boolean isTransparent(); + + boolean isHollow(); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java new file mode 100755 index 000000000..916f4fe69 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java @@ -0,0 +1,7 @@ +package buildcraft.api.transport.pluggable; + +import net.minecraft.client.renderer.VertexBuffer; + +public interface IPlugDynamicRenderer

{ + void render(P plug, double x, double y, double z, float partialTicks, VertexBuffer vb); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java b/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java new file mode 100755 index 000000000..300b575bf --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java @@ -0,0 +1,9 @@ +package buildcraft.api.transport.pluggable; + +import net.minecraft.util.ResourceLocation; + +public interface IPluggableRegistry { + void register(PluggableDefinition definition); + + PluggableDefinition getDefinition(ResourceLocation identifier); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java b/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java new file mode 100755 index 000000000..a3f001214 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java @@ -0,0 +1,13 @@ +package buildcraft.api.transport.pluggable; + +import java.util.List; + +import net.minecraft.client.renderer.block.model.BakedQuad; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IPluggableStaticBaker { + List bake(K key); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java new file mode 100755 index 000000000..a1b180519 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java @@ -0,0 +1,104 @@ +package buildcraft.api.transport.pluggable; + +import java.io.IOException; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.RayTraceResult; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; + +import buildcraft.api.transport.pipe.IPipeHolder; +import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; + +public abstract class PipePluggable { + public final PluggableDefinition definition; + public final IPipeHolder holder; + public final EnumFacing side; + + public PipePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side) { + this.definition = definition; + this.holder = holder; + this.side = side; + } + + public NBTTagCompound writeToNbt() { + NBTTagCompound nbt = new NBTTagCompound(); + return nbt; + } + + /** Writes the payload that will be passed into + * {@link PluggableDefinition#loadFromBuffer(IPipeHolder, EnumFacing, PacketBuffer)} on the client. (This is called + * on the server and sent to the client). Note that this will be called *instead* of write and read payload. */ + public void writeCreationPayload(PacketBuffer buffer) { + + } + + public void writePayload(PacketBuffer buffer, Side side) { + + } + + public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) throws IOException { + + } + + public final void scheduleNetworkUpdate() { + holder.scheduleNetworkUpdate(PipeMessageReceiver.PLUGGABLES[side.ordinal()]); + } + + public void onTick() {} + + /** @return A bounding box that will be used for collisions and raytracing. */ + public abstract AxisAlignedBB getBoundingBox(); + + /** @return True if the pipe cannot connect outwards (it is blocked), or False if this does not block the pipe. */ + public boolean isBlocking() { + return false; + } + + /** Gets the value of a specified capability key, or null if the given capability is not supported at the call time. + * This is effectively {@link ICapabilityProvider}, but where + * {@link ICapabilityProvider#hasCapability(Capability, EnumFacing)} will return true when this returns a non-null + * value. */ + public T getCapability(@Nonnull Capability cap) { + return null; + } + + /** Called whenever this pluggable is removed from the pipe. + * + * @param toDrop A list containing all the items to drop (so you should add your items to this list) */ + public void onRemove(NonNullList toDrop) { + ItemStack stack = getPickStack(); + if (!stack.isEmpty()) { + toDrop.add(stack); + } + } + + /** Called whenever this pluggable is picked by the player (similar to Block.getPickBlock) + * + * @return The stack that should be picked, or ItemStack.EMPTY if no stack can be picked from this pluggable. */ + public ItemStack getPickStack() { + return ItemStack.EMPTY; + } + + public boolean onPluggableActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ) { + return false; + } + + @Nullable + public PluggableModelKey getModelRenderKey(BlockRenderLayer layer) { + return null; + } +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java b/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java new file mode 100755 index 000000000..f6e371c3d --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java @@ -0,0 +1,69 @@ +package buildcraft.api.transport.pluggable; + +import javax.annotation.Nullable; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; + +import buildcraft.api.transport.pipe.IPipeHolder; + +public final class PluggableDefinition { + public final ResourceLocation identifier; + + public final IPluggableNetLoader loader; + public final IPluggableNbtReader reader; + + @Nullable + public final IPluggableCreator creator; + + public PluggableDefinition(ResourceLocation identifier, IPluggableNbtReader reader, IPluggableNetLoader loader) { + this.identifier = identifier; + this.reader = reader; + this.loader = loader; + this.creator = null; + } + + public PluggableDefinition(ResourceLocation identifier, IPluggableCreator creator) { + this.identifier = identifier; + this.reader = creator; + this.loader = creator; + this.creator = creator; + } + + public PipePluggable readFromNbt(IPipeHolder holder, EnumFacing side, NBTTagCompound nbt) { + return reader.readFromNbt(this, holder, side, nbt); + } + + public PipePluggable loadFromBuffer(IPipeHolder holder, EnumFacing side, PacketBuffer buffer) { + return loader.loadFromBuffer(this, holder, side, buffer); + } + + // FIXME: J8 API usage + J8 default interfaces + + @FunctionalInterface + public interface IPluggableNbtReader { + PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, NBTTagCompound nbt); + } + + @FunctionalInterface + public interface IPluggableNetLoader { + PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, PacketBuffer buffer); + } + + @FunctionalInterface + public interface IPluggableCreator extends IPluggableNbtReader, IPluggableNetLoader { + @Override + default PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, PacketBuffer buffer) { + return createSimplePluggable(definition, holder, side); + } + + @Override + default PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, NBTTagCompound nbt) { + return createSimplePluggable(definition, holder, side); + } + + PipePluggable createSimplePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side); + } +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java b/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java new file mode 100755 index 000000000..7c832c195 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java @@ -0,0 +1,38 @@ +package buildcraft.api.transport.pluggable; + +import java.util.Objects; + +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; + +public abstract class PluggableModelKey { + public final BlockRenderLayer layer; + public final EnumFacing side; + private final int hash; + + public PluggableModelKey(BlockRenderLayer layer, EnumFacing side) { + if (layer != BlockRenderLayer.CUTOUT && layer != BlockRenderLayer.TRANSLUCENT) { + throw new IllegalArgumentException("Can only use CUTOUT or TRANSLUCENT at the moment (was " + layer + ")"); + } + if (side == null) throw new NullPointerException("side"); + this.layer = layer; + this.side = side; + this.hash = Objects.hash(layer, side); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + PluggableModelKey other = (PluggableModelKey) obj; + if (layer != other.layer) return false; + if (side != other.side) return false; + return true; + } + + @Override + public int hashCode() { + return hash; + } +} diff --git a/src/api/java/ic2/api/crops/BaseSeed.class b/src/api/java/ic2/api/crops/BaseSeed.class index 988c7c665..47efa3131 100644 Binary files a/src/api/java/ic2/api/crops/BaseSeed.class and b/src/api/java/ic2/api/crops/BaseSeed.class differ diff --git a/src/api/java/ic2/api/crops/BaseSeed.java b/src/api/java/ic2/api/crops/BaseSeed.java index 8770bcfcf..5f5f4446d 100644 --- a/src/api/java/ic2/api/crops/BaseSeed.java +++ b/src/api/java/ic2/api/crops/BaseSeed.java @@ -14,14 +14,20 @@ public class BaseSeed { * @param statResistance plant resistance stat * @param stackSize for internal usage only */ - public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) { - super(); + public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance) { this.crop = crop; this.size = size; this.statGrowth = statGrowth; this.statGain = statGain; this.statResistance = statResistance; - this.stackSize = stackSize; + } + + /** + * @deprecated use the other constructor instead + */ + @Deprecated + public BaseSeed(CropCard crop, int size, int statGrowth, int statGain, int statResistance, int stackSize) { + this(crop, size, statGrowth, statGain, statResistance); } /** @@ -48,9 +54,4 @@ public class BaseSeed { * Plant resistance stat. */ public int statResistance; - - /** - * For internal usage only. - */ - public int stackSize; } diff --git a/src/api/java/ic2/api/crops/CropCard.class b/src/api/java/ic2/api/crops/CropCard.class index ed102068e..dab248f4b 100644 Binary files a/src/api/java/ic2/api/crops/CropCard.class and b/src/api/java/ic2/api/crops/CropCard.class differ diff --git a/src/api/java/ic2/api/crops/CropCard.java b/src/api/java/ic2/api/crops/CropCard.java index 347803a8d..60350036e 100644 --- a/src/api/java/ic2/api/crops/CropCard.java +++ b/src/api/java/ic2/api/crops/CropCard.java @@ -1,8 +1,6 @@ package ic2.api.crops; -import java.util.ArrayList; import java.util.List; -import java.util.Locale; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -21,40 +19,48 @@ public abstract class CropCard { } /** - * Plant name for identifying this crop within your mod. + * Plant id for identifying this crop within your mod. + *
+ * The id has to be unique within the mod and is used for saving. + *
+ * By default this id will be also used to determine {@link #getUnlocalizedName()} and {@link #getTexturesLocation()}. * - * The name has to be unique within the mod and is used for saving. - * By default this name will be also used to determine displayKey() and registerSprites(). + * @note changing the id or owner will cause existing crops in users' worlds to disappear. * - * @note changing name or owner will cause existing crops in users' worlds to disappear. - * - * @return Plant name + * @return Plant id */ - public abstract String getName(); + public abstract String getId(); /** - * Determine the mod id owning this crop. + * Determine the mod owning this crop. * * The owner serves as a name space. With every mod using a different owner, a mod only has to - * make sure it doesn't have conflicts with name() in itself. - * It's recommended to hard code this to your mod id as specified in the @Mod annotation. - * Do not use IC2's mod id here. + * make sure it doesn't have getId() conflicts within itself. The identifier has to be lower + * case to ensure compatibility with future versions. + *
+ * It's recommended to hard code this to your lower case mod id as specified in the @Mod + * annotation, as {@link #getUnlocalizedName()} will use it by default. + *
+ * Do not use IC2's mod id here. * - * @note changing name or owner will cause existing crops in users' worlds to disappear. + * @note changing the id or owner will cause existing crops in users' worlds to disappear. + * + * @return owning mod identifier, lower case. */ public abstract String getOwner(); /** * Translation key for display to the player. * - * It's highly recommended to specify a valid key from your language file here, e.g. add - * "yourmod.crop.yourCropName = Your crop's name" to the language file, override name() to - * return "yourCropName" and override displayName() to return "yourmod.crop."+name(). + * It's recommended to specify a valid key from your language file here. + *
+ * e.g. Add "yourmod.crop.yourCropName = Your crop's name" to the language file, + * override {@link #getId()} to return "yourCropName" and override {@link #getOwner()} to return "yourmod". * * @return Unlocalized name. */ - public String getDisplayName() { - return getName(); // return the raw name for backwards compatibility + public String getUnlocalizedName() { + return getOwner() + ".crop." + getId(); //Good enough default } /** @@ -81,14 +87,14 @@ public abstract class CropCard { if (i == 0) { String s = att[0]; if (att.length >= 2) { - s+=", "+att[1]; - if (att.length >= 3) s+=","; + s += ", " + att[1]; + if (att.length >= 3) s += ","; } return s; } if (att.length < 3) return ""; String s = att[2]; - if (att.length >= 4) s+=", "+att[3]; + if (att.length >= 4) s += ", " + att[3]; return s; } @@ -102,7 +108,7 @@ public abstract class CropCard { } /** - * Object containing the crop properties info - See ic2.api.crops.CropProperties for more info. + * Object containing the crop properties info - See {@link CropProperties} for more info. */ public abstract CropProperties getProperties(); @@ -113,13 +119,13 @@ public abstract class CropCard { * @return Attributes as an array of strings */ public String[] getAttributes() { - return new String[] {}; + return new String[0]; } /** * Determine the max crop size. * - * Currently only used for texture allocation. + * Currently used for texture allocation, growth and harvesting control (by default). */ public abstract int getMaxSize(); @@ -266,9 +272,9 @@ public abstract class CropCard { public float dropSeedChance(ICropTile crop) { if (crop.getCurrentSize() == 1) return 0; float base = 0.5F; - if (crop.getCurrentSize() == 2) base/=2F; + if (crop.getCurrentSize() == 2) base /= 2F; for (int i = 0; i < getProperties().getTier(); i++) { - base*=0.8; + base *= 0.8; } return base; } @@ -291,7 +297,7 @@ public abstract class CropCard { * @param crop reference to ICropTile */ public void onNeighbourChange(ICropTile crop) { - // + // NO-OP } /** @@ -303,7 +309,7 @@ public abstract class CropCard { return false; } - /*** + /** * Get the emitted redstone signal strength. * * @return The redstone signal strength. @@ -361,8 +367,7 @@ public abstract class CropCard { * @return Whether the plant spreads weed */ public boolean isWeed(ICropTile cropTile) { - return cropTile.getCurrentSize() >= 2 && - (cropTile.getCrop() == Crops.weed || cropTile.getStatGrowth() >= 24); + return cropTile.getCurrentSize() >= 2 && (cropTile.getCrop() == Crops.weed || cropTile.getStatGrowth() >= 24); } /** @@ -371,22 +376,8 @@ public abstract class CropCard { * @return The crop world object. */ public World getWorld(ICropTile cropTile) { - return cropTile.getWorld(); + return cropTile.getWorldObj(); } - /** - * Retrieve the crop's unlocalized name. - * @return Unlocalized name - */ - public String getUnlocalizedName() { - return "crop." + getName() + ".name"; - } - - public List getModelLocation() { - List ret = new ArrayList(); - for (int i = 1; i <= getMaxSize(); i++) { - ret.add(new ResourceLocation(getOwner().toLowerCase(Locale.ENGLISH), "blocks/crop/"+getName()+"_"+i)); - } - return ret; - } + public abstract List getTexturesLocation(); } diff --git a/src/api/java/ic2/api/crops/CropProperties.class b/src/api/java/ic2/api/crops/CropProperties.class index 31cd7c24f..11cd6c540 100644 Binary files a/src/api/java/ic2/api/crops/CropProperties.class and b/src/api/java/ic2/api/crops/CropProperties.class differ diff --git a/src/api/java/ic2/api/crops/CropSoilType.class b/src/api/java/ic2/api/crops/CropSoilType.class new file mode 100644 index 000000000..fd7b99366 Binary files /dev/null and b/src/api/java/ic2/api/crops/CropSoilType.class differ diff --git a/src/api/java/ic2/api/crops/CropSoilType.java b/src/api/java/ic2/api/crops/CropSoilType.java new file mode 100644 index 000000000..1a8dddf50 --- /dev/null +++ b/src/api/java/ic2/api/crops/CropSoilType.java @@ -0,0 +1,42 @@ +package ic2.api.crops; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + +/** + * List of possible blocks to be used as soil for a crop. + * @author estebes + */ +public enum CropSoilType { + //DIRT(Blocks.DIRT), + FARMLAND(Blocks.FARMLAND), + MYCELIUM(Blocks.MYCELIUM), + SAND(Blocks.SAND), + SOULSAND(Blocks.SOUL_SAND); + + private CropSoilType(@Nonnull Block block) { + this.block = block; + } + + public Block getBlock() { + return this.block; + } + + /** + * Check if a block can be used as soil. + * @param block the block + * @return true if the block is a possible crop soil + */ + public static boolean contais(Block block) { + for (CropSoilType aux : CropSoilType.values()) { + if (aux.getBlock() == block) { + return true; + } + } + return false; + } + + private final Block block; +} diff --git a/src/api/java/ic2/api/crops/ExampleCropCard.class b/src/api/java/ic2/api/crops/ExampleCropCard.class new file mode 100644 index 000000000..774eb7d4e Binary files /dev/null and b/src/api/java/ic2/api/crops/ExampleCropCard.class differ diff --git a/src/api/java/ic2/api/crops/ExampleCropCard.java b/src/api/java/ic2/api/crops/ExampleCropCard.java new file mode 100644 index 000000000..2fc522066 --- /dev/null +++ b/src/api/java/ic2/api/crops/ExampleCropCard.java @@ -0,0 +1,53 @@ +package ic2.api.crops; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.List; + +/** + * CropCard example + * @author estebes + */ +public class ExampleCropCard extends CropCard { + @Override + public String getId() { + return "example"; + } + + @Override + public String getOwner() { + return "myaddon"; + } + + /** + * See {@link CropProperties} for more info. + */ + @Override + public CropProperties getProperties() { + return new CropProperties(1, 0, 4, 0, 0, 2); + } + + @Override + public int getMaxSize() { + return 5; + } + + @Override + public ItemStack getGain(ICropTile crop) { + return new ItemStack(Items.DIAMOND, 1); + } + + @Override + public List getTexturesLocation() { + List ret = new ArrayList(getMaxSize()); + + for (int size = 1; size <= getMaxSize(); size++) { + ret.add(new ResourceLocation("myaddon", "blocks/crop/" + getId() + "_" + size)); + } + + return ret; + } +} diff --git a/src/api/java/ic2/api/crops/ICropTile.class b/src/api/java/ic2/api/crops/ICropTile.class index cc8c4eb01..adb43df8e 100644 Binary files a/src/api/java/ic2/api/crops/ICropTile.class and b/src/api/java/ic2/api/crops/ICropTile.class differ diff --git a/src/api/java/ic2/api/crops/ICropTile.java b/src/api/java/ic2/api/crops/ICropTile.java index 8df7968d6..21357bc7c 100644 --- a/src/api/java/ic2/api/crops/ICropTile.java +++ b/src/api/java/ic2/api/crops/ICropTile.java @@ -8,10 +8,12 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import ic2.api.info.ILocatable; + /** * Interface implemented by the crop tile entity. */ -public interface ICropTile { +public interface ICropTile extends ILocatable { /** * Get the crop. * @@ -91,14 +93,14 @@ public interface ICropTile { * * @return Crop nutrient storage */ - public int getStorageNutrient(); + public int getStorageNutrients(); /** * Set the crop's nutrient storage. * - * @param storageNutrient Crop nutrient storage + * @param nutrients Crop nutrient storage */ - public void setStorageNutrient(int storageNutrient); + public void setStorageNutrients(int nutrients); /** * Get the crop's hydration storage. @@ -111,9 +113,9 @@ public interface ICropTile { /** * Set the crop's water storage. * - * @param storageWater Crop water storage + * @param water Crop water storage */ - public void setStorageWater(int storageWater); + public void setStorageWater(int water); /** * Get the crop's Weed-Ex storage. @@ -125,9 +127,9 @@ public interface ICropTile { /** * Set the crop's Weed-Ex storage. * - * @param storageWeedEX Crop Weed-Ex storage + * @param weedEX Crop Weed-Ex storage */ - public void setStorageWeedEX(int storageWeedEX); + public void setStorageWeedEX(int weedEX); /** * Get the crop's plant scan level. @@ -169,7 +171,7 @@ public interface ICropTile { * * @return Crop humidity level */ - public int getHumidity(); + public int getTerrainHumidity(); /** * Get the crop's nutrient level. @@ -180,7 +182,7 @@ public interface ICropTile { * * @return Crop nutrient level */ - public int getNutrients(); + public int getTerrainNutrients(); /** * Get the crop's air quality. @@ -191,20 +193,25 @@ public interface ICropTile { * * @return Crop air quality */ - public int getAirQuality(); + public int getTerrainAirQuality(); /** * Get the crop's world. + * @deprecated This method causes a MethodNotFoundException in a obfuscated environment. + * Use {@link #getWorldObj()} instead * * @return Crop world */ + @Deprecated public World getWorld(); /** * Get the crop's location. + * @deprecated Use {@link #getPosition()} instead. * * @return Crop location */ + @Deprecated public BlockPos getLocation(); /** diff --git a/src/api/java/ic2/api/crops/package-info.class b/src/api/java/ic2/api/crops/package-info.class deleted file mode 100644 index 3ca3f3754..000000000 Binary files a/src/api/java/ic2/api/crops/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/crops/package-info.java b/src/api/java/ic2/api/crops/package-info.java deleted file mode 100644 index 6d4a180d1..000000000 --- a/src/api/java/ic2/api/crops/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.crops; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/energy/event/package-info.class b/src/api/java/ic2/api/energy/event/package-info.class deleted file mode 100644 index 1b070c88f..000000000 Binary files a/src/api/java/ic2/api/energy/event/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/event/package-info.java b/src/api/java/ic2/api/energy/event/package-info.java deleted file mode 100644 index 25ed85d13..000000000 --- a/src/api/java/ic2/api/energy/event/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.event; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/energy/package-info.class b/src/api/java/ic2/api/energy/package-info.class deleted file mode 100644 index 68a0db695..000000000 Binary files a/src/api/java/ic2/api/energy/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/package-info.java b/src/api/java/ic2/api/energy/package-info.java deleted file mode 100644 index 26bd21e31..000000000 --- a/src/api/java/ic2/api/energy/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.class b/src/api/java/ic2/api/energy/prefab/BasicSink.class deleted file mode 100644 index 35d58ecb5..000000000 Binary files a/src/api/java/ic2/api/energy/prefab/BasicSink.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/prefab/BasicSink.java b/src/api/java/ic2/api/energy/prefab/BasicSink.java deleted file mode 100644 index 70c29fb63..000000000 --- a/src/api/java/ic2/api/energy/prefab/BasicSink.java +++ /dev/null @@ -1,374 +0,0 @@ -package ic2.api.energy.prefab; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; - -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergyEmitter; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.info.Info; -import ic2.api.item.ElectricItem; - -/** - * BasicSink is a simple adapter to provide an ic2 energy sink. - * - * It's designed to be attached to a tile entity as a delegate. Functionally BasicSink acts as a - * one-time configurable input energy buffer, thus providing a common use case for machines. - * - * Sub-classing BasicSink instead of using it as a delegate works as well, but isn't recommended. - * The delegate can be extended with additional functionality through a sub class though. - * - * The constraints set by BasicSink like the strict tank-like energy buffering should provide a - * more easy to use and stable interface than using IEnergySink directly while aiming for - * optimal performance. - * - * Using BasicSink involves the following steps: - * - create a BasicSink instance in your TileEntity, typically in a field - * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSink - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. - * - call useEnergy whenever appropriate. canUseEnergy determines if enough energy is available - * without consuming the energy. - * - optionally use getEnergyStored to display the output buffer charge level - * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - * - * Example implementation code: - * @code{.java} - * public class SomeTileEntity extends TileEntity { - * // new basic energy sink, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSink ic2EnergySink = new BasicSink(this, 1000, 1); - * - * @Override - * public void invalidate() { - * ic2EnergySink.invalidate(); // notify the energy sink - * ... - * super.invalidate(); // this is important for mc! - * } - * - * @Override - * public void onChunkUnload() { - * ic2EnergySink.onChunkUnload(); // notify the energy sink - * ... - * } - * - * @Override - * public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - * - * ic2EnergySink.readFromNBT(tag); - * ... - * } - * - * @Override - * public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - * - * ic2EnergySink.writeToNBT(tag); - * ... - * } - * - * @Override - * public void update() { - * ic2EnergySink.update(); // notify the energy sink - * ... - * if (ic2EnergySink.useEnergy(5)) { // use 5 eu from the sink's buffer this tick - * ... // do something with the energy - * } - * ... - * } - * - * ... - * } - * @endcode - */ -public class BasicSink extends TileEntity implements IEnergySink, ITickable { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** - - /** - * Constructor for a new BasicSink delegate. - * - * @param parent1 TileEntity represented by this energy sink. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSink(TileEntity parent1, int capacity1, int tier1) { - this.parent = parent1; - this.capacity = capacity1; - this.tier = tier1; - } - - // in-world te forwards >> - - /** - * Forward for the base TileEntity's update(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void update() { - if (!addedToEnet) onLoaded(); - } - - /** - * Notification that the base TileEntity finished loaded, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !parent.getWorld().isRemote && - Info.isIc2Available()) { - worldObj = parent.getWorld(); - pos = parent.getPos(); - - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - - addedToEnet = true; - } - } - - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); - - onChunkUnload(); - } - - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - - addedToEnet = false; - } - } - - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - - NBTTagCompound data = tag.getCompoundTag("IC2BasicSink"); - - energyStored = data.getDouble("energy"); - } - - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public NBTTagCompound writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } - - NBTTagCompound data = new NBTTagCompound(); - - data.setDouble("energy", energyStored); - - tag.setTag("IC2BasicSink", data); - - return tag; - } - - // << in-world te forwards - // methods for using this adapter >> - - /** - * Get the maximum amount of energy this sink can hold in its buffer. - * - * @return Capacity in EU. - */ - public int getCapacity() { - return capacity; - } - - /** - * Set the maximum amount of energy this sink can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(int capacity1) { - this.capacity = capacity1; - } - - /** - * Get the IC2 energy tier for this sink. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } - - /** - * Set the IC2 energy tier for this sink. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - this.tier = tier1; - } - - /** - * Determine the energy stored in the sink's input buffer. - * - * @return amount in EU, may be above capacity - */ - public double getEnergyStored() { - return energyStored; - } - - /** - * Set the stored energy to the specified amount. - * - * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } - - /** - * Determine if the specified amount of energy is available. - * - * @param amount in EU - * @return true if the amount is available - */ - public boolean canUseEnergy(double amount) { - return energyStored >= amount; - } - - /** - * Use the specified amount of energy, if available. - * - * @param amount amount to use - * @return true if the amount was available - */ - public boolean useEnergy(double amount) { - if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { - energyStored -= amount; - - return true; - } - return false; - } - - /** - * Discharge the supplied ItemStack into this sink's energy buffer. - * - * @param stack ItemStack to discharge (null is ignored) - * @param limit Transfer limit, values <= 0 will use the battery's limit - * @return true if energy was transferred - */ - public boolean discharge(ItemStack stack, int limit) { - if (stack == null || !Info.isIc2Available()) return false; - - double amount = capacity - energyStored; - if (amount <= 0) return false; - - if (limit > 0 && limit < amount) amount = limit; - - amount = ElectricItem.manager.discharge(stack, amount, tier, limit > 0, true, false); - - energyStored += amount; - - return amount > 0; - } - - // << methods for using this adapter - - // backwards compatibility (ignore these) >> - - @Deprecated - public void onupdate() { - update(); - } - - @Deprecated - public void onInvalidate() { - invalidate(); - } - - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } - - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } - - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } - - // << backwards compatibility - - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** - - // energy net interface >> - - @Override - public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { - return true; - } - - @Override - public double getDemandedEnergy() { - return Math.max(0, capacity - energyStored); - } - - @Override - public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) { - energyStored += amount; - - return 0; - } - - @Override - public int getSinkTier() { - return tier; - } - - // << energy net interface - - - public final TileEntity parent; - - protected int capacity; - protected int tier; - protected double energyStored; - protected boolean addedToEnet; -} diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.class b/src/api/java/ic2/api/energy/prefab/BasicSource.class deleted file mode 100644 index 1ac62875a..000000000 Binary files a/src/api/java/ic2/api/energy/prefab/BasicSource.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/prefab/BasicSource.java b/src/api/java/ic2/api/energy/prefab/BasicSource.java deleted file mode 100644 index 9715cd4bd..000000000 --- a/src/api/java/ic2/api/energy/prefab/BasicSource.java +++ /dev/null @@ -1,376 +0,0 @@ -package ic2.api.energy.prefab; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; - -import ic2.api.energy.EnergyNet; -import ic2.api.energy.event.EnergyTileLoadEvent; -import ic2.api.energy.event.EnergyTileUnloadEvent; -import ic2.api.energy.tile.IEnergyAcceptor; -import ic2.api.energy.tile.IEnergySource; -import ic2.api.info.Info; -import ic2.api.item.ElectricItem; - -/** - * BasicSource is a simple adapter to provide an ic2 energy source. - * - * It's designed to be attached to a tile entity as a delegate. Functionally BasicSource acts as a - * one-time configurable output energy buffer, thus providing a common use case for generators. - * - * Sub-classing BasicSource instead of using it as a delegate works as well, but isn't recommended. - * The delegate can be extended with additional functionality through a sub class though. - * - * The constraints set by BasicSource like the strict tank-like energy buffering should provide a - * more easy to use and stable interface than using IEnergySource directly while aiming for - * optimal performance. - * - * Using BasicSource involves the following steps: - * - create a BasicSource instance in your TileEntity, typically in a field - * - forward invalidate, onChunkUnload, readFromNBT, writeToNBT and updateEntity to the BasicSource - * instance. - * If you have other means of determining when the tile entity is fully loaded, notify onLoaded - * that way instead of forwarding updateEntity. - * - call addEnergy whenever appropriate, using getFreeCapacity may determine if e.g. the generator - * should run - * - optionally use getEnergyStored to display the output buffer charge level - * - optionally use setEnergyStored to sync the stored energy to the client (e.g. in the Container) - * - * Example implementation code: - * @code{.java} - * public class SomeTileEntity extends TileEntity { - * // new basic energy source, 1000 EU buffer, tier 1 (32 EU/t, LV) - * private BasicSource ic2EnergySource = new BasicSource(this, 1000, 1); - * - * @Override - * public void invalidate() { - * ic2EnergySource.invalidate(); // notify the energy source - * ... - * super.invalidate(); // this is important for mc! - * } - * - * @Override - * public void onChunkUnload() { - * ic2EnergySource.onChunkUnload(); // notify the energy source - * ... - * } - * - * @Override - * public void readFromNBT(NBTTagCompound tag) { - * super.readFromNBT(tag); - * - * ic2EnergySource.readFromNBT(tag); - * ... - * } - * - * @Override - * public void writeToNBT(NBTTagCompound tag) { - * super.writeToNBT(tag); - * - * ic2EnergySource.writeToNBT(tag); - * ... - * } - * - * @Override - * public void update() { - * ic2EnergySource.update(); // notify the energy source - * ... - * ic2EnergySource.addEnergy(5); // add 5 eu to the source's buffer this tick - * ... - * } - * - * ... - * } - * @endcode - */ -public class BasicSource extends TileEntity implements IEnergySource, ITickable { - // ********************************** - // *** Methods for use by the mod *** - // ********************************** - - /** - * Constructor for a new BasicSource delegate. - * - * @param parent1 Base TileEntity represented by this energy source. - * @param capacity1 Maximum amount of eu to store. - * @param tier1 IC2 tier, 1 = LV, 2 = MV, ... - */ - public BasicSource(TileEntity parent1, double capacity1, int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); - - this.parent = parent1; - this.capacity = capacity1 < power ? power : capacity1; - this.tier = tier1; - this.power = power; - } - - // in-world te forwards >> - - /** - * Forward for the base TileEntity's update(), used for creating the energy net link. - * Either updateEntity or onLoaded have to be used. - */ - @Override - public void update() { - if (!addedToEnet) onLoaded(); - } - - /** - * Notification that the base TileEntity finished loading, for advanced uses. - * Either updateEntity or onLoaded have to be used. - */ - public void onLoaded() { - if (!addedToEnet && - !parent.getWorld().isRemote && - Info.isIc2Available()) { - worldObj = parent.getWorld(); - pos = parent.getPos(); - - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - - addedToEnet = true; - } - } - - /** - * Forward for the base TileEntity's invalidate(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void invalidate() { - super.invalidate(); - - onChunkUnload(); - } - - /** - * Forward for the base TileEntity's onChunkUnload(), used for destroying the energy net link. - * Both invalidate and onChunkUnload have to be used. - */ - @Override - public void onChunkUnload() { - if (addedToEnet && - Info.isIc2Available()) { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); - - addedToEnet = false; - } - } - - /** - * Forward for the base TileEntity's readFromNBT(), used for loading the state. - * - * @param tag Compound tag as supplied by TileEntity.readFromNBT() - */ - @Override - public void readFromNBT(NBTTagCompound tag) { - super.readFromNBT(tag); - - NBTTagCompound data = tag.getCompoundTag("IC2BasicSource"); - - energyStored = data.getDouble("energy"); - } - - /** - * Forward for the base TileEntity's writeToNBT(), used for saving the state. - * - * @param tag Compound tag as supplied by TileEntity.writeToNBT() - */ - @Override - public NBTTagCompound writeToNBT(NBTTagCompound tag) { - try { - super.writeToNBT(tag); - } catch (RuntimeException e) { - // happens if this is a delegate, ignore - } - - NBTTagCompound data = new NBTTagCompound(); - - data.setDouble("energy", energyStored); - - tag.setTag("IC2BasicSource", data); - - return tag; - } - - // << in-world te forwards - // methods for using this adapter >> - - /** - * Get the maximum amount of energy this source can hold in its buffer. - * - * @return Capacity in EU. - */ - public double getCapacity() { - return capacity; - } - - /** - * Set the maximum amount of energy this source can hold in its buffer. - * - * @param capacity1 Capacity in EU. - */ - public void setCapacity(double capacity1) { - if (capacity1 < power) capacity1 = power; - - this.capacity = capacity1; - } - - /** - * Get the IC2 energy tier for this source. - * - * @return IC2 Tier. - */ - public int getTier() { - return tier; - } - - /** - * Set the IC2 energy tier for this source. - * - * @param tier1 IC2 Tier. - */ - public void setTier(int tier1) { - double power = EnergyNet.instance.getPowerFromTier(tier1); - - if (capacity < power) capacity = power; - - this.tier = tier1; - this.power = power; - } - - - /** - * Determine the energy stored in the source's output buffer. - * - * @return amount in EU - */ - public double getEnergyStored() { - return energyStored; - } - - /** - * Set the stored energy to the specified amount. - * - * This is intended for server -> client synchronization, e.g. to display the stored energy in - * a GUI through getEnergyStored(). - * - * @param amount - */ - public void setEnergyStored(double amount) { - energyStored = amount; - } - - /** - * Determine the free capacity in the source's output buffer. - * - * @return amount in EU - */ - public double getFreeCapacity() { - return capacity - energyStored; - } - - /** - * Add some energy to the output buffer. - * - * @param amount maximum amount of energy to add - * @return amount added/used, NOT remaining - */ - public double addEnergy(double amount) { - if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; - if (amount > capacity - energyStored) amount = capacity - energyStored; - - energyStored += amount; - - return amount; - } - - /** - * Charge the supplied ItemStack from this source's energy buffer. - * - * @param stack ItemStack to charge (null is ignored) - * @return true if energy was transferred - */ - public boolean charge(ItemStack stack) { - if (stack == null || !Info.isIc2Available()) return false; - - double amount = ElectricItem.manager.charge(stack, energyStored, tier, false, false); - - energyStored -= amount; - - return amount > 0; - } - - // << methods for using this adapter - - // backwards compatibility (ignore these) >> - - @Deprecated - public void onupdate() { - update(); - } - - @Deprecated - public void onInvalidate() { - invalidate(); - } - - @Deprecated - public void onOnChunkUnload() { - onChunkUnload(); - } - - @Deprecated - public void onReadFromNbt(NBTTagCompound tag) { - readFromNBT(tag); - } - - @Deprecated - public void onWriteToNbt(NBTTagCompound tag) { - writeToNBT(tag); - } - - // << backwards compatibility - - // ****************************** - // *** Methods for use by ic2 *** - // ****************************** - - // energy net interface >> - - @Override - public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { - return true; - } - - @Override - public double getOfferedEnergy() { - return Math.min(energyStored, power); - } - - @Override - public void drawEnergy(double amount) { - energyStored -= amount; - } - - @Override - public int getSourceTier() { - return tier; - } - - // << energy net interface - - - public final TileEntity parent; - - protected double capacity; - protected int tier; - protected double power; - protected double energyStored; - protected boolean addedToEnet; -} diff --git a/src/api/java/ic2/api/energy/prefab/package-info.class b/src/api/java/ic2/api/energy/prefab/package-info.class deleted file mode 100644 index 59b4c1ff8..000000000 Binary files a/src/api/java/ic2/api/energy/prefab/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/prefab/package-info.java b/src/api/java/ic2/api/energy/prefab/package-info.java deleted file mode 100644 index f640ee1de..000000000 --- a/src/api/java/ic2/api/energy/prefab/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.prefab; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/energy/tile/IChargingSlot.class b/src/api/java/ic2/api/energy/tile/IChargingSlot.class new file mode 100644 index 000000000..761910731 Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IChargingSlot.class differ diff --git a/src/api/java/ic2/api/energy/tile/IChargingSlot.java b/src/api/java/ic2/api/energy/tile/IChargingSlot.java new file mode 100644 index 000000000..2238326ea --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IChargingSlot.java @@ -0,0 +1,16 @@ +package ic2.api.energy.tile; + +/** + * Represents a slot (or set of slots) that can have electric items in them to be charged + * + * @author Chocohead + */ +public interface IChargingSlot { + /** + * Called when the energy component is ticked to fill the slots + * + * @param amount The amount of energy available for the slot(s) + * @return The amount of energy used charging the items in the slot(s) + */ + public double charge(double amount); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.class b/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.class new file mode 100644 index 000000000..b364517df Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.class differ diff --git a/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.java b/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.java new file mode 100644 index 000000000..2ad9c42c8 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IColoredEnergyTile.java @@ -0,0 +1,21 @@ +package ic2.api.energy.tile; + +import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.EnumFacing; + +/** + * Interface, that allows Blocks to be colored and have their connectivity based on that color. + * This allows for any Energy Tile to be colored. (Conductors, Sinks, Sources) + * @author Aroma1997 + */ +public interface IColoredEnergyTile extends IEnergyTile { + + /** + * This is to get a Energy Tile's color for the given side. Mainly used for checking connectivity. + * @param side The side you want to get the color from. + * @return The color of the Energy Tile at the given side or null, if it's uncolored. + */ + EnumDyeColor getColor(EnumFacing side); + + +} diff --git a/src/api/java/ic2/api/energy/tile/IDischargingSlot.class b/src/api/java/ic2/api/energy/tile/IDischargingSlot.class new file mode 100644 index 000000000..06518bd86 Binary files /dev/null and b/src/api/java/ic2/api/energy/tile/IDischargingSlot.class differ diff --git a/src/api/java/ic2/api/energy/tile/IDischargingSlot.java b/src/api/java/ic2/api/energy/tile/IDischargingSlot.java new file mode 100644 index 000000000..64ea69bd8 --- /dev/null +++ b/src/api/java/ic2/api/energy/tile/IDischargingSlot.java @@ -0,0 +1,17 @@ +package ic2.api.energy.tile; + +/** + * Represents a slot (or set of slots) that can have electric items in them to be discharged + * + * @author Chocohead + */ +public interface IDischargingSlot { + /** + * Called when the energy component is ticked to empty the slots + * + * @param space The amount of free space for energy that can be stored + * @param ignoreLimit Whether to ignore the discharge limit of the item in the slot(s) + * @return The amount of energy discharged from the items in the slot(s) + */ + public double discharge(double space, boolean ignoreLimit); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/IOverloadHandler.java b/src/api/java/ic2/api/energy/tile/IOverloadHandler.java index db2f39caf..ebaeb9e83 100644 --- a/src/api/java/ic2/api/energy/tile/IOverloadHandler.java +++ b/src/api/java/ic2/api/energy/tile/IOverloadHandler.java @@ -9,9 +9,9 @@ public interface IOverloadHandler { * Called when overloaded. This will override the default explosion. * The default explosion will therefore NOT happen, when you return true here. * If you return false, you can use this as a onExplode hook, but still let the default explosion happen. - * @note Would set the block to air and cause an explosion of power 2.5 by default + * @note Will set the block to air and cause an explosion of power 2.5 if false is returned * @param tier The tier of power, that was injected into the energy sink, that caused it to explode. - * @return Whether you the default explosion should be cancelled. + * @return Whether the default explosion should be cancelled. */ boolean onOverload(int tier); } \ No newline at end of file diff --git a/src/api/java/ic2/api/energy/tile/package-info.class b/src/api/java/ic2/api/energy/tile/package-info.class deleted file mode 100644 index 8f2d38743..000000000 Binary files a/src/api/java/ic2/api/energy/tile/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/energy/tile/package-info.java b/src/api/java/ic2/api/energy/tile/package-info.java deleted file mode 100644 index 565a16e14..000000000 --- a/src/api/java/ic2/api/energy/tile/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.energy.tile; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/energy/usage.txt b/src/api/java/ic2/api/energy/usage.txt index e3c9de817..bad72a93d 100644 --- a/src/api/java/ic2/api/energy/usage.txt +++ b/src/api/java/ic2/api/energy/usage.txt @@ -89,6 +89,10 @@ An energy conductor has to post the following events: Additionally the interface IEnergyConductor has to be implemented. +-- general --- +Optionally, you can implement the interface IColoredEnergyTile, which allows for some basic color-based +connectivity. This can be used for IEnergyConductors, but is not limited to them. + ------------------------------ -- Energy Network Delegates -- diff --git a/src/api/java/ic2/api/event/TeBlockFinalCallEvent.class b/src/api/java/ic2/api/event/TeBlockFinalCallEvent.class new file mode 100644 index 000000000..98ae85734 Binary files /dev/null and b/src/api/java/ic2/api/event/TeBlockFinalCallEvent.class differ diff --git a/src/api/java/ic2/api/event/TeBlockFinalCallEvent.java b/src/api/java/ic2/api/event/TeBlockFinalCallEvent.java new file mode 100644 index 000000000..3b1958d4f --- /dev/null +++ b/src/api/java/ic2/api/event/TeBlockFinalCallEvent.java @@ -0,0 +1,20 @@ +package ic2.api.event; + +import net.minecraftforge.fml.common.eventhandler.Event; + +import ic2.api.info.ITeBlock; + +/** This event is a notification for an internal event you might will to subscribe to if you're using ITeBlock, hence it is empty. + *

+ * For more information such as why this event exists, when it's posted, and how to react to it properly, see {@link ITeBlock}. + *

+ * + * @see ITeBlock + * + * @since IC2 2.6.67 + * @version 1.0 + * + * @author Chocohead + */ +public final class TeBlockFinalCallEvent extends Event { +} \ No newline at end of file diff --git a/src/api/java/ic2/api/event/package-info.class b/src/api/java/ic2/api/event/package-info.class deleted file mode 100644 index c1ce15887..000000000 Binary files a/src/api/java/ic2/api/event/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/event/package-info.java b/src/api/java/ic2/api/event/package-info.java deleted file mode 100644 index 71ba156af..000000000 --- a/src/api/java/ic2/api/event/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.event; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/info/ILocatable.class b/src/api/java/ic2/api/info/ILocatable.class new file mode 100644 index 000000000..9f77e09d6 Binary files /dev/null and b/src/api/java/ic2/api/info/ILocatable.class differ diff --git a/src/api/java/ic2/api/info/ILocatable.java b/src/api/java/ic2/api/info/ILocatable.java new file mode 100644 index 000000000..47bc34428 --- /dev/null +++ b/src/api/java/ic2/api/info/ILocatable.java @@ -0,0 +1,24 @@ +package ic2.api.info; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +/** + * Interface for things, that have a location. + * The function names are the way they are, because of obfuscation issues. + * See https://github.com/md-5/SpecialSource/issues/12 + * @author Aroma1997 + */ +public interface ILocatable { + + /** + * @return the position of the object. + */ + BlockPos getPosition(); + + /** + * @return the world of this object. + */ + World getWorldObj(); + +} diff --git a/src/api/java/ic2/api/info/ITeBlock.class b/src/api/java/ic2/api/info/ITeBlock.class new file mode 100644 index 000000000..5de8990ad Binary files /dev/null and b/src/api/java/ic2/api/info/ITeBlock.class differ diff --git a/src/api/java/ic2/api/info/ITeBlock.java b/src/api/java/ic2/api/info/ITeBlock.java new file mode 100644 index 000000000..fe44aa734 --- /dev/null +++ b/src/api/java/ic2/api/info/ITeBlock.java @@ -0,0 +1,344 @@ +package ic2.api.info; + +import java.util.Set; + +import net.minecraft.block.material.Material; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.common.MinecraftForge; + +import ic2.api.event.TeBlockFinalCallEvent; +import ic2.api.item.ITeBlockSpecialItem; +import ic2.api.tile.IWrenchable; + +/** First of all, yes this class is empty. It's public documentation for the actual internal interface ITeBlock. Use the internal one not this! + *

+ * You may be asking, why would an internal interface need documenting? Well, the answer is so people can use TileEntityBlock. + * That class is the base for all IC2 tile entities, so by being able to use that you're level to IC2. + * Many methods are protected in there too, as they're only designed to be called by BlockTileEntity (which is the block all IC2 tile entities will be on), + * by being able to extend it means all those methods you can now extend and be confident they will be called correctly. + *

+ *

+ * The more observant might have noticed there was an event that allowed you to do basically the same thing called TeBlockBakeEvent. + * Whilst that event used to add your own class onto TeBlock (that wasn't ideal as you could end up using the same ID as another addon which would cause a crash), + * this allows you to completely implement your own version of TeBlock, then let IC2 take it and build the necessary structures around it. + * Both mean you no longer have to use EnumHelper and lots of reflection to mess about with TeBlock, + * just to be left with either a crash from doing it too late/wrong, or lots of code bound to IC2 (such as language keys and blockstate jsons being in IC2's assets). + *

+ *

+ * Unlike TeBlockBakeEvent, this gives you near total control of your tile entities: + *

+ * You can pick whether each of your tile entity items show up in creative, and the order in which they do.
+ * You can choose whether you use an enum or class for your implementation. + * We use (and I personally recommend) using an enum, as the values should never change, but in the end the choice is yours.
+ * There is a proper separation between each registered ITeBlock by resource location, rather than everything being inserted into a single enum. + * You also receive your own instance of BlockTileEntity and ItemBlockTileEntity rather than having to use IC2's own one.
+ * All the language keys and blockstate file are in your own assets (which you can, and in fact have to, pick). + *
+ * It is a vast improvement over TeBlockBakeEvent, which is probably important as it's gone now ;) + *

+ *
+ * The event allows you to properly register your own version of TeBlock in a way that will be as fully supported as is physically possible. + * It's not in the actual API itself as it's heavily dependent on internal classes, so you have this instead. + * This is also probably the most documented thing in the entire IC2 API. I'm too kind really. ;) + *

+ *
+ *

+ * So that's all well and good, but what you really want is an example of how to do it properly. Good idea, let's go. + *


+ *import net.minecraftforge.common.MinecraftForge;
+ *import net.minecraftforge.fml.common.Mod;
+ *import net.minecraftforge.fml.common.Mod.EventHandler;
+ *import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+ *import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+ *
+ *{@literal @}Mod(modId="ExampleIC2Addon")
+ *public class ExampleIC2Addon {
+ *	public ExampleIC2Addon() {
+ *		//You have to register before IC2 reaches Pre-Initialization, which unless you specifically load before it is unlikely you'll achieve.
+ *		//Especially if you're an addon, you'll want to be loading after IC2 not before!
+ *		//But, your mod's constructor will definitely be called before then. The issue is it's called more than once.
+ *		//If you try registering the same tile entity ID twice it will crash (more on that later), so you'll have to use a singleton instance.
+ *		//An enum works well for this, but anything will work as long as it's registered to the event bus once, and only once.
+ *		MinecraftForge.EVENT_BUS.register(TileEntityRegisterer.INSTANCE);
+ *	}
+ *
+ *	{@literal @}EventHandler
+ *	public void preInit(FMLPreInitializationEvent event) {
+ *		MyTeBlock.registerTileEntities();
+ *	}
+ *
+ *	{@literal @}EventHandler
+ *	public void preInit(FMLInitializationEvent event) {
+ *		MyTeBlock.buildDummies();
+ *	}
+ *}
+ *
+ *import ic2.api.event.TeBlockFinalCallEvent;
+ *import ic2.core.block.TeBlockRegistry;
+ *import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+ *
+ *public enum TileEntityRegisterer {
+ *	INSTANCE;
+ *
+ *	{@literal @}SubscribeEvent
+ *	public void register(TeBlockFinalCallEvent event) {
+ *		TeBlockRegistry.addAll(MyTeBlock.class, MyTeBlock.IDENTITY);
+ *	}
+ *}
+ *
+ *import ic2.core.block.BlockTileEntity;
+ *import ic2.core.block.ITeBlock;
+ *import ic2.core.block.TileEntityBlock;
+ *import ic2.core.item.block.ItemBlockTileEntity;
+ *import ic2.core.ref.TeBlock.DefaultDrop;
+ *import ic2.core.ref.TeBlock.HarvestTool;
+ *import ic2.core.ref.TeBlock.ITePlaceHandler;
+ *import ic2.core.util.Util;
+ *import net.minecraft.block.material.Material;
+ *import net.minecraft.creativetab.CreativeTabs;
+ *import net.minecraft.item.EnumRarity;
+ *import net.minecraft.item.ItemStack;
+ *import net.minecraft.tileentity.TileEntity;
+ *import net.minecraft.util.EnumFacing;
+ *import net.minecraft.util.ResourceLocation;
+ *
+ *public enum MyTeBlock implements ITeBlock {
+ *	my_machine_name(MyMachineTileEntity.class, 0, false, Util.noFacings, false, HarvestTool.Pickaxe, DefaultDrop.Machine, 5, 10, EnumRarity.UNCOMMON, Material.IRON);
+ *
+ *	private MyTeBlock(Class teClass, int ID,
+ *			boolean hasActive, Set{@literal <}EnumFacing{@literal >} possibleFacings, boolean canBeWrenched,
+ *			HarvestTool tool, DefaultDrop drop,
+ *			float hardness, float explosionResistance, EnumRarity rarity, Material material) {
+ *		this.teClass = teClass;
+ *		this.ID = ID;
+ *		this.hasActive = hasActive;
+ *		this.possibleFacings = possibleFacings;
+ *		this.canBeWrenched = canBeWrenched;
+ *		this.tool = tool;
+ *		this.drop = drop;
+ *		this.hardness = hardness;
+ *		this.explosionResistance = explosionResistance;
+ *		this.rarity = rarity;
+ *		this.material = material;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public boolean hasItem() {
+ *		return teClass != null && itemMeta != -1;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public String getName() {
+ *		return name();
+ *	}
+ *
+ *	{@literal @}Override
+ *	public ResourceLocation getIdentifier() {
+ *		return IDENTITY;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public Class getTeClass() {
+ *		return teClass;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public boolean hasActive() {
+ *		return hasActive;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public int getId() {
+ *		return ID;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public float getHardness() {
+ *		return hardness;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public HarvestTool getHarvestTool() {
+ *		return tool;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public DefaultDrop getDefaultDrop() {
+ *		return drop;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public float getExplosionResistance() {
+ *		return explosionResistance;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public boolean allowWrenchRotating() {
+ *		return canBeWrenched;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public Set{@literal <}EnumFacing{@literal >} getSupportedFacings() {
+ *		return possibleFacings;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public EnumRarity getRarity() {
+ *		return rarity;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public Material getMaterial() {
+ *		return material;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public void addSubBlocks(List{@literal <}ItemStack{@literal >} list, BlockTileEntity block, ItemBlockTileEntity item, CreativeTabs tab) {
+ *		for (MyTeBlock block : values()) {
+ *			if (type.hasItem()) {
+ *				list.add(block.getItemStack(type));
+ *			}
+ *		}
+ *	}
+ *
+ *	{@literal @}Override
+ *	public void setPlaceHandler(ITePlaceHandler handler) {
+ *		this.placeHandler = handler;
+ *	}
+ *
+ *	{@literal @}Override
+ *	public ITePlaceHandler getPlaceHandler() {
+ *		return placeHandler;
+ *	}
+ *
+ *	public static void registerTileEntities() {
+ *		for (MyTeBlock block : values()) {
+ *			if (block.teClass != null) TileEntity.addMapping(block.teClass, IDENTITY.getResourceDomain() + ':' + block.getName());
+ *		}
+ *	}
+ *
+ *	public static void buildDummies() {
+ *		for (MyTeBlock block : values()) {
+ *			//System.out.printf("Registering %s (with teClass %s)%n", block.getName(), block.teClass);
+ *			if (block.teClass != null) {
+ *				try {
+ *					block.dummyTe = block.teClass.newInstance();
+ *				} catch (Exception e) {
+ *					e.printStackTrace();
+ *				}
+ *			}
+ *		}
+ *	}
+ *
+ *	{@literal @}Override
+ *	public TileEntityBlock getDummyTe() {
+ *		return dummyTe;
+ *	}
+ *
+ *	private final Class teClass;
+ *	private final int ID;
+ *	private final boolean hasActive;
+ *	private final Set{@literal <}EnumFacing{@literal >} possibleFacings;
+ *	private final boolean canBeWrenched;
+ *	private final HarvestTool tool;
+ *	private final DefaultDrop drop;
+ *	private final float hardness;
+ *	private final float explosionResistance;
+ *	private final EnumRarity rarity;
+ *	private final Material material;
+ *	private TileEntityBlock dummyTe;
+ *	private ITePlaceHandler placeHandler;
+ *
+ *	public static final ResourceLocation IDENTITY = new ResourceLocation("ExampleIC2Addon", "machines");
+ *}
+ *  
+ * And that's it, you now have my_machine_name registered with the MyMachineTileEntity tile entity class, + * the language key to translate it's name being ExampleIC2Addon.machines.my_machine_name and + * the blockstate being in machines.json file in your mod's assets. + *

+ *
+ *

+ * But hang on, what are all the parameters of our new enum and what does ITeBlock do with them? What are dummy tile entities for? + * Don't worry, it's quite simple (once you know it at least). + *

+ *

+ * First we'll start on what {@link TeBlockFinalCallEvent} is. It's posted on the {@link MinecraftForge#EVENT_BUS} just before the blocks are built, + * after which point any further attempts to register ITeBlocks will fail, as we can't inject them late due to the model generating. + * It is best to hook into this to register your ITeBlocks, as it will be guaranteed to be posted at the right time. + *

+ * In terms of ITeBlock, there's quite a bit of information it needs in order to function. We'll go through each parameter (or getter method most cases too) in turn: + *

    + *
  • name: The name the new tile entity. This is important as the localisation and resource names depend on it, as well as some network syncing code.
  • + *
  • teClass: The class of your tile entity, it must extend TileEntityBlock otherwise it would miss critical methods to work. + * If extending that is a problem then using ITeBlock isn't what you should be doing.
  • + *
  • itemMeta: The ID of the new instance. This is utterly critical, as it's the thing used to detect which ITeBlock an item is. + * That's very important as the tile entity class is worked out by the ID when a block's being placed in ItemBlockTileEntity. + * Changing this will cause everyone's items to change and there is no stopping that if you do. + * The ID you pick should start at 0, and go up to Short.MAX_VALUE. + * Use -1 if the tile entity doesn't have an item form (or is placed using an item other than ItemBlockTileEntity).
  • + *
  • identifier: The resource location associated with the ITeBlock. + * The language keys, translations and internal mappings all use this, so it's best to store it as a static final variable and use that. + *
  • hasActive: If the tile entity has an active state too, which is based off whether TileEntityBlock#getActive() returns true or not. + * The models for that will be at name_active, you can check te.json for an example if you wish.
  • + *
  • supportedFacings: A set of EnumFacings that the block can face, used for rotating by the wrench for example. + * IC2 has some useful constants relating to that in Util (allFacings, horizontalFacings, downSideFacings and noFacings).
  • + *
  • allowWrenchRotating: Whether the tile entity can be rotated with a wrench (for {@link IWrenchable}).
  • + *
  • harvestTool: The tool used to harvest the tile entity, currently only None, Pickaxe, Shovel and Axe. + * More can be added on request, but support has to be specifically added, so there's no nice way via EnumHelper unfortunately.
  • + *
  • defaultDrop: The item(s) that will drop when the block is broken using the correct tool. Currently only Self, None, Generator, Machine, and AdvMachine. + * Like harvestTool, more can be added upon request.
  • + *
  • hardness: The hardness the block should have with the tile entity, IC2 normally uses 5.
  • + *
  • explosionResistance: The explosionResistance the block should have with the tile entity, IC2 normally uses 10.
  • + *
  • rarity: The EnumRarity that the item will have for the tile entity.
  • + *
  • material: The {@link Material} that the block representing the tile entity should have. Maximum of 16 different ones per ITeBlock registration.
  • + *
  • placeHandler: Custom placement logic, used for things like Reactor Chambers within IC2 itself. + * Returning null for this uses the default logic (placing like a normal block).
  • + *
  • dummyTe: An instance of the tile entity never registered to the world (don't try doing that) used for getting additional information about the Tile Entity. + * Mostly an internal thing, only exposed in case your Tile Entity uses a special constructor.
  • + * + *
  • addSubBlocks: Called by BlockTileEntity to add all the ITeBlocks you want to the creative menu. + * {@link BlockTileEntity#getItemStack(ITeBlock)} will be a useful method to get the item stack, a block instance is passed for that reason. + * This is only called once on a random ITeBlock for the resource location, because they are internally stored in a {@link Set} so has no order. + * Will probably be changed to a static method if/when the move is made to only Java 8 support. + *
+ * IMPORTANT THINGS TO NOTE + *
+ *
Getting your instance of BlockTileEntity and ItemBlockTileEntity
+ *
For BlockTileEntity, use {@link TeBlockRegistry#get(ResourceLocation)}.
+ * For ItemBlockTileEntity, use {@link BlockTileEntity#getItem()}.
+ *
Using a custom item model for your ITeBlock
+ *
Implement ITeBlockSpecialItem along with ITeBlock, then the item model will be what's provided rather than the block model.
+ *
+ * More will be added to this list if questions keep re-occurring, or are about a suitably important topic. + *

+ *
+ *

+ * There, that should be everything you need to utilise ITeBlock to add your own tile entities using IC2's very flexible framework. + * I'll be happy to answer any questions you have on it, your best bet is to ask me (Chocohead) on the IC2 forums, + * although if you post in the support section other people might be able to help before I see your post. + * I'll certainly take suggestions too, this is a first version of ITeBlock, so I'm sure there could be improvements made. + *
+ * Goodness I spent too long on this again... + *

+ * + * + * @see {@link TeBlockFinalCallEvent} for the event you'll need to subscribe to. + * @see {@link ic2.core.ref.TeBlock} for how all the IC2 implements {@link ITeBlock}. + * @see {@link ic2.core.ref.TeBlock.HarvestTool} for the currently available tools (you'll need this for adding new tile entities). + * @see {@link ic2.core.ref.TeBlock.DefaultDrop} for the currently available drops (you'll need this for adding new tile entities too). + * @see {@link ic2.core.ref.TeBlock.ITePlaceHandler} for making your own block placement handler (example in {@link ic2.core.item.ItemHandlers#reactorChamberPlace}). + * @see {@link ic2.core.util.Util} for the useful facings you might want for supportedFacings. + * @see {@link ic2.core.block.TileEntityBlock} for the base tile entity. + * @see {@link ic2.core.block.BlockTileEntity} for the base block (you'll never need to construct this yourself). + * @see {@link ic2.core.item.block.ItemBlockTileEntity} for the base item (you'll never need to construct this yourself either). + * @see {@link ITeBlockSpecialItem} for the interface used to have a custom item location. + * + * + * @since IC2 2.6.114 + * @version 1.2 + * + * @author Chocohead + */ +public interface ITeBlock { +} \ No newline at end of file diff --git a/src/api/java/ic2/api/info/package-info.class b/src/api/java/ic2/api/info/package-info.class deleted file mode 100644 index 6cd21d416..000000000 Binary files a/src/api/java/ic2/api/info/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/info/package-info.java b/src/api/java/ic2/api/info/package-info.java deleted file mode 100644 index ecd40e27d..000000000 --- a/src/api/java/ic2/api/info/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.info; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/item/HudMode.class b/src/api/java/ic2/api/item/HudMode.class new file mode 100644 index 000000000..200362d96 Binary files /dev/null and b/src/api/java/ic2/api/item/HudMode.class differ diff --git a/src/api/java/ic2/api/item/HudMode.java b/src/api/java/ic2/api/item/HudMode.java new file mode 100644 index 000000000..d78c60210 --- /dev/null +++ b/src/api/java/ic2/api/item/HudMode.java @@ -0,0 +1,37 @@ +package ic2.api.item; + +public enum HudMode { + DISABLED("ic2.hud.disabled"), BASIC("ic2.hud.basic"), EXTENDED("ic2.hud.extended"), ADVANCED("ic2.hud.advanced"); + + private HudMode(String key) { + translationKey = key; + } + + private final String translationKey; + + public boolean shouldDisplay() { + return this != DISABLED; + } + + public boolean hasTooltip() { + return this == EXTENDED || this == ADVANCED; + } + + public String getTranslationKey() { + return translationKey; + } + + public int getID() { + return ordinal(); + } + + public static HudMode getFromID(int ID) { + return VALUES[ID % VALUES.length]; + } + + public static int getMaxMode() { + return VALUES.length - 1; + } + + private static final HudMode[] VALUES = values(); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/item/IC2Items.java b/src/api/java/ic2/api/item/IC2Items.java index 5240178f7..b0c113981 100644 --- a/src/api/java/ic2/api/item/IC2Items.java +++ b/src/api/java/ic2/api/item/IC2Items.java @@ -17,7 +17,7 @@ import net.minecraftforge.fml.common.ModContainer; * * Getting the associated Block/Item for an ItemStack x: Blocks: * ((ItemBlock)x.getItem).getBlock() Items: x.getItem() - * Alternatively, you can direwctly call IC2Items.instance.getItem(name) or IC2Items.instance.getBlock(name) + * Alternatively, you can directly call IC2Items.instance.getItem(name) or IC2Items.instance.getBlock(name) * * It is recommended, that you keep a reference to the Items you get here. * @@ -159,6 +159,7 @@ dust,small_obsidian Tiny Pile of Obsidian Dust dust,small_silver Tiny Pile of Silver Dust dust,small_sulfur Tiny Pile of Sulfur Dust dust,small_tin Tiny Pile of Tin Dust +dust,tin_hydrated Hydrated Tin Dust ingot: ingot,alloy Mixed Metal Ingot @@ -224,6 +225,7 @@ misc_resource,iridium_shard Iridium Shard misc_resource,matter UU-Matter misc_resource,resin Sticky Resin misc_resource,slag Slag +misc_resource,iodine Iodine block_cutting_blade: block_cutting_blade,iron Block Cutting Blade (Iron) @@ -267,6 +269,8 @@ crafting,steel_rotor_blade Steel Rotor Blade crafting,carbon_rotor_blade Carbon Rotor Blade crafting,steam_turbine_blade Steam Turbine Blade crafting,steam_turbine Steam Turbine +crafting,jetpack_attachment_plate Jetpack Attachment Plate +crafting,coin Industrial Credit crystal_memory: crystal_memory Crystal Memory @@ -283,7 +287,7 @@ crop_res,hops Hops crop_res,weed Weed terra_wart: -terra_wart item.terra_wart +terra_wart Terra Wart re_battery: re_battery RE-Battery @@ -363,6 +367,9 @@ neutron_reflector Neutron Reflector thick_neutron_reflector: thick_neutron_reflector Thick Neutron Reflector +iridium_reflector: +iridium_reflector Iridium Neutron Reflector + rsh_condensator: rsh_condensator RSH-Condensator @@ -425,6 +432,7 @@ debug_item Debug Item foam_sprayer: foam_sprayer CF Sprayer +foam_sprayer,ic2construction_foam CF Sprayer forge_hammer: forge_hammer Forge Hammer @@ -435,6 +443,9 @@ frequency_transmitter Frequency Transmitter meter: meter EU-Reader +remote: +remote Dynamite-O-Mote + tool_box: tool_box Tool Box @@ -456,9 +467,15 @@ mug,cold_coffee Cold Coffee mug,dark_coffee Dark Coffee mug,coffee Coffee +crop_stick: +crop_stick Crop + cropnalyzer: cropnalyzer Cropnalyzer +crop_seed_bag: +crop_seed_bag * Seeds + weeding_trowel: weeding_trowel Weeding Trowel @@ -563,8 +580,11 @@ upgrade,transformer Transformer Upgrade upgrade,energy_storage Energy Storage Upgrade upgrade,redstone_inverter Redstone Signal Inverter Upgrade upgrade,ejector Ejector Upgrade +upgrade,advanced_ejector Advanced Ejector Upgrade upgrade,pulling Pulling Upgrade +upgrade,advanced_pulling Advanced Pulling Upgrade upgrade,fluid_ejector Fluid Ejector Upgrade +upgrade,fluid_pulling Fluid Pulling Upgrade advanced_batpack: advanced_batpack Adv.Batpack @@ -652,6 +672,9 @@ static_boots Static Boots filled_tin_can: filled_tin_can (Filled) Tin Can +iodine_tablet: +iodine_tablet Iodine Tablet + rotor_wood: rotor_wood Kinetic Gearbox Rotor (Wood) @@ -664,6 +687,12 @@ rotor_carbon Kinetic Gearbox Rotor (Carbon) rotor_steel: rotor_steel Kinetic Gearbox Rotor (Steel) +dynamite: +dynamite Dynamite + +dynamite_sticky: +dynamite_sticky Sticky Dynamite + ================================================= Blocks: @@ -752,6 +781,13 @@ te,hv_transformer HV-Transformer te,ev_transformer EV-Transformer te,tank Tank te,chunk_loader Chunk Loader +te,item_buffer_2 Compact Item Buffer +te,rci_rsh Reactor Coolant Injector (RSH) +te,rci_lzh Reactor Coolant Injector (LZH) +te,creative_generator Creative Generator +te,steam_repressurizer Steam Re-Pressurizer +te,industrial_workbench Industrial Workbench +te,batch_crafter Batch Crafter resource: resource,basalt Basalt @@ -793,7 +829,9 @@ fence: fence,iron Iron Fence sheet: +sheet,resin Resin Sheet sheet,rubber Rubber Sheet +sheet,wool Wool Sheet glass: glass,reinforced Reinforced Glass diff --git a/src/api/java/ic2/api/item/IItemAPI.class b/src/api/java/ic2/api/item/IItemAPI.class index 12684eb4b..18bc079bd 100644 Binary files a/src/api/java/ic2/api/item/IItemAPI.class and b/src/api/java/ic2/api/item/IItemAPI.class differ diff --git a/src/api/java/ic2/api/item/IItemAPI.java b/src/api/java/ic2/api/item/IItemAPI.java index ba6dc0a42..9b72459d0 100644 --- a/src/api/java/ic2/api/item/IItemAPI.java +++ b/src/api/java/ic2/api/item/IItemAPI.java @@ -1,6 +1,7 @@ package ic2.api.item; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -11,6 +12,17 @@ import net.minecraft.item.ItemStack; */ public interface IItemAPI { + /** + * Get the default blockstate for a specific block name and variant.
+ * For machines etc, you might want to make your detection a bit more fuzzy, + * because the BlockState also contains properties like the facing and the active + * state of a machine. + * @param name The name of the block. + * @param variant The variant of the block. + * @return The default state of the block with that variant. + */ + IBlockState getBlockState(String name, String variant); + /** * Get an ItemStack for a specific item name. * diff --git a/src/api/java/ic2/api/item/IItemHudInfo.class b/src/api/java/ic2/api/item/IItemHudInfo.class index 82e7f8297..4602f697b 100644 Binary files a/src/api/java/ic2/api/item/IItemHudInfo.class and b/src/api/java/ic2/api/item/IItemHudInfo.class differ diff --git a/src/api/java/ic2/api/item/IItemHudInfo.java b/src/api/java/ic2/api/item/IItemHudInfo.java index 35194f366..112d69102 100644 --- a/src/api/java/ic2/api/item/IItemHudInfo.java +++ b/src/api/java/ic2/api/item/IItemHudInfo.java @@ -2,23 +2,32 @@ package ic2.api.item; import java.util.List; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +/** + * An interface to allow the applied {@link Item} to override the overlay HUD text (which otherwise defaults to it's tooltip). + * + * @author Thunderdark + */ public interface IItemHudInfo { - /* - Add Info to Nano- and Quantum-Suit Helm Hud - for stack - - @Override - public List getHudInfo(ItemStack stack) { - List info = new LinkedList(); - info.add("i am a Cool Item"); - info.add("and have Cool info"); - return info; - } - - + /** + *

Adds info to {@link IItemHudProvider}s for the given stack. + * Return an empty list not null if no info is given.

+ * + *

+	 *	{@literal @}override
+	 *	public List{@literal <}String{@literal >} getHudInfo(ItemStack stack, boolean advanced) {
+	 *		List{@literal <}String{@literal >} info = new LinkedList{@literal <}String{@literal >}();
+	 *		info.add("I am a cool item");
+	 *		info.add("and have cool info.");
+	 * 		return info;
+	 * 	}
+	 *	
+ * + * @param stack The stack to get information for + * @param advanced Whether the HUD is in extended or advanced display mode + * @return A list of strings to draw in the overlay */ - - public List getHudInfo(ItemStack stack); -} + public List getHudInfo(ItemStack stack, boolean advanced); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/item/IItemHudProvider$IItemHudBarProvider.class b/src/api/java/ic2/api/item/IItemHudProvider$IItemHudBarProvider.class new file mode 100644 index 000000000..f8ee4fcbd Binary files /dev/null and b/src/api/java/ic2/api/item/IItemHudProvider$IItemHudBarProvider.class differ diff --git a/src/api/java/ic2/api/item/IItemHudProvider.class b/src/api/java/ic2/api/item/IItemHudProvider.class new file mode 100644 index 000000000..df596fec3 Binary files /dev/null and b/src/api/java/ic2/api/item/IItemHudProvider.class differ diff --git a/src/api/java/ic2/api/item/IItemHudProvider.java b/src/api/java/ic2/api/item/IItemHudProvider.java new file mode 100644 index 000000000..47639b3b9 --- /dev/null +++ b/src/api/java/ic2/api/item/IItemHudProvider.java @@ -0,0 +1,46 @@ +package ic2.api.item; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * An interface to show that an {@link Item} can display the HUD overlay if worn. + * + * @author Chocohead + */ +public interface IItemHudProvider extends IElectricItem { + /** + * Whether the given stack should display the HUD overlay. + * + * @param stack The stack currently being worn + * @return Whether the HUD overlay should be drawn + */ + boolean doesProvideHUD(ItemStack stack); + + /** + * Gets the current {@link HudMode} of the worn stack (probably stored as NBT) + * + * @param stack The stack currently being worn + * @return The HUD overlay mode + */ + HudMode getHudMode(ItemStack stack); + + /** + *

Override the percent shown by the HUD overlay for the applied item.

+ * + *

By default, {@link IElectricItem}s have the percentage charged shown, + * damageable items have their {@link Item#getDurabilityForDisplay(ItemStack)} values shown + * and items that don't apply to either aren't shown at all.

+ * + * @author Chocohead + */ + public static interface IItemHudBarProvider { + /** + * Get the percent to show in the overlay HUD for the given stack. + * + * @param stack The stack to get the percent for. + * @return A number between 0 and 100, less than 0 will not render the item at all. + */ + int getBarPercent(ItemStack stack); + } +} \ No newline at end of file diff --git a/src/api/java/ic2/api/item/ITeBlockSpecialItem.class b/src/api/java/ic2/api/item/ITeBlockSpecialItem.class new file mode 100644 index 000000000..5d2b1a280 Binary files /dev/null and b/src/api/java/ic2/api/item/ITeBlockSpecialItem.class differ diff --git a/src/api/java/ic2/api/item/ITeBlockSpecialItem.java b/src/api/java/ic2/api/item/ITeBlockSpecialItem.java new file mode 100644 index 000000000..7d9ca63eb --- /dev/null +++ b/src/api/java/ic2/api/item/ITeBlockSpecialItem.java @@ -0,0 +1,35 @@ +package ic2.api.item; + +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.ItemStack; + +import ic2.api.info.ITeBlock; + +/** + * Change the default icon for an {@link ITeBlock} by implementing this. + * + * @since IC2 2.6.85 + * @version 1.0 + * + * @see {@link ITeBlock} for more information + * + * @author Chocohead + */ +public interface ITeBlockSpecialItem { + /** + * Should the model be delegated to the {@link ITeBlock} or the default used? + * + * @param stack The itemstack being rendered + * @return Whether the {@link ITeBlock} will return an {@link ModelResourceLocation} + */ + boolean doesOverrideDefault(ItemStack stack); + + /** + * The {@link ModelResourceLocation} for the given stack. + * Will still use the default even if {@link #doesOverrideDefault(ItemStack)} returns true if this returns null. + * + * @param stack The itemstack being rendered + * @return The model location to be used + */ + ModelResourceLocation getModelLocation(ItemStack stack); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/item/package-info.class b/src/api/java/ic2/api/item/package-info.class deleted file mode 100644 index 69fb7c313..000000000 Binary files a/src/api/java/ic2/api/item/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/item/package-info.java b/src/api/java/ic2/api/item/package-info.java deleted file mode 100644 index e02ec6e11..000000000 --- a/src/api/java/ic2/api/item/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.item; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/network/IGrowingBuffer.class b/src/api/java/ic2/api/network/IGrowingBuffer.class new file mode 100644 index 000000000..416349df7 Binary files /dev/null and b/src/api/java/ic2/api/network/IGrowingBuffer.class differ diff --git a/src/api/java/ic2/api/network/IGrowingBuffer.java b/src/api/java/ic2/api/network/IGrowingBuffer.java new file mode 100644 index 000000000..6b2353d57 --- /dev/null +++ b/src/api/java/ic2/api/network/IGrowingBuffer.java @@ -0,0 +1,36 @@ +package ic2.api.network; + +import java.io.DataInput; +import java.io.DataOutput; + +public interface IGrowingBuffer extends DataInput, DataOutput { + /** + * Write a number of variable size to the buffer + * + * @param i The number to write + */ + void writeVarInt(int i); + + /** + * Write a string directly to the buffer, + * opposed to {@link DataOutput#writeUTF(String)} that properly encodes Unicode characters first + * + * @param s The string to write + */ + void writeString(String s); + + /** + * Read a number of variable size to the buffer + * + * @return The variably sized number stored on the buffer + */ + int readVarInt(); + + /** + * Read a string directly from the buffer, + * opposed to {@link DataInput#readUTF()} that properly decodes Unicode characters first + * + * @return The string stored on the buffer + */ + String readString(); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/network/INetworkCustomEncoder.class b/src/api/java/ic2/api/network/INetworkCustomEncoder.class new file mode 100644 index 000000000..64885fcfb Binary files /dev/null and b/src/api/java/ic2/api/network/INetworkCustomEncoder.class differ diff --git a/src/api/java/ic2/api/network/INetworkCustomEncoder.java b/src/api/java/ic2/api/network/INetworkCustomEncoder.java new file mode 100644 index 000000000..86885139c --- /dev/null +++ b/src/api/java/ic2/api/network/INetworkCustomEncoder.java @@ -0,0 +1,36 @@ +package ic2.api.network; + +import java.io.IOException; + +/** + * Allow extensions to {@link ic2.core.network.DataEncoder} for encoding custom data types not already handled by IC2. + * Register this to DataEncoder itself using #addNetworkEncoder(Class, INetworkCustomEncoder). + * + * @author Chocohead + */ +public interface INetworkCustomEncoder { + /** + * Encode the given instance into the buffer + * + * @param buffer The network buffer + * @param instance The instance being encoded + * + * @throws IOException Because {@link ic2.core.network.DataEncoder#encode(IGrowingBuffer, Object, boolean)} does. + */ + void encode(IGrowingBuffer buffer, Object instance) throws IOException; + + /** + * @param buffer The network buffer + * + * @return The instance the information on the network represents + * + * @throws IOException Because {@link ic2.core.network.DataEncoder#decode(IGrowingBuffer, ic2.core.network.DataEncoder.EncodedType)} does. + */ + Object decode(IGrowingBuffer buffer) throws IOException; + + /** + * @return false the type accesses the world or otherwise requires to be run on the main thread, + * true if it doesn't. + */ + boolean isThreadSafe(); +} \ No newline at end of file diff --git a/src/api/java/ic2/api/network/INetworkManager.class b/src/api/java/ic2/api/network/INetworkManager.class index d0fd9c34a..aee59174e 100644 Binary files a/src/api/java/ic2/api/network/INetworkManager.class and b/src/api/java/ic2/api/network/INetworkManager.class differ diff --git a/src/api/java/ic2/api/network/INetworkManager.java b/src/api/java/ic2/api/network/INetworkManager.java index bef3c59d0..81a55f778 100644 --- a/src/api/java/ic2/api/network/INetworkManager.java +++ b/src/api/java/ic2/api/network/INetworkManager.java @@ -25,4 +25,6 @@ public interface INetworkManager { void initiateClientItemEvent(ItemStack stack, int event); + void sendInitialData(TileEntity te); + } diff --git a/src/api/java/ic2/api/network/NetworkHelper.class b/src/api/java/ic2/api/network/NetworkHelper.class index 665d98507..055d909fb 100644 Binary files a/src/api/java/ic2/api/network/NetworkHelper.class and b/src/api/java/ic2/api/network/NetworkHelper.class differ diff --git a/src/api/java/ic2/api/network/NetworkHelper.java b/src/api/java/ic2/api/network/NetworkHelper.java index a2f71256d..84d52cf3d 100644 --- a/src/api/java/ic2/api/network/NetworkHelper.java +++ b/src/api/java/ic2/api/network/NetworkHelper.java @@ -20,6 +20,10 @@ import net.minecraftforge.fml.relauncher.Side; * which is needed by the clients outside the GUI, such as rendering the block, playing sounds or * producing effects. Anything which is only visible inside the GUI should be synchronized through * the Container class associated to the GUI in Container.updateProgressBar(). + * + * All methods in this class use the current effective side to determine the Network Manager to use. + * If you do not want it to use the effective side, use {@link #getNetworkManager(Side)} to get the + * Network Manager for a specific side. */ public final class NetworkHelper { // server -> client @@ -93,6 +97,15 @@ public final class NetworkHelper { getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).initiateItemEvent(player, stack, event, limitRange); } + /** + * Send initial TileEntity data to the clients. Requires the te to implement + * {@link INetworkDataProvider}. + * @param te The te to send the initial data for. + */ + public static void sendInitialData(TileEntity te) { + getNetworkManager(FMLCommonHandler.instance().getEffectiveSide()).sendInitialData(te); + } + // client -> server diff --git a/src/api/java/ic2/api/network/package-info.class b/src/api/java/ic2/api/network/package-info.class deleted file mode 100644 index c2d4dd55b..000000000 Binary files a/src/api/java/ic2/api/network/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/network/package-info.java b/src/api/java/ic2/api/network/package-info.java deleted file mode 100644 index f31d2033e..000000000 --- a/src/api/java/ic2/api/network/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.network; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/package-info.class b/src/api/java/ic2/api/package-info.class deleted file mode 100644 index 70b3064f5..000000000 Binary files a/src/api/java/ic2/api/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/package-info.java b/src/api/java/ic2/api/package-info.java deleted file mode 100644 index 51f09d297..000000000 --- a/src/api/java/ic2/api/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/reactor/IBaseReactorComponent.class b/src/api/java/ic2/api/reactor/IBaseReactorComponent.class new file mode 100644 index 000000000..2c33a15c6 Binary files /dev/null and b/src/api/java/ic2/api/reactor/IBaseReactorComponent.class differ diff --git a/src/api/java/ic2/api/reactor/IBaseReactorComponent.java b/src/api/java/ic2/api/reactor/IBaseReactorComponent.java new file mode 100644 index 000000000..7e5383b9e --- /dev/null +++ b/src/api/java/ic2/api/reactor/IBaseReactorComponent.java @@ -0,0 +1,21 @@ +package ic2.api.reactor; + +import net.minecraft.item.ItemStack; + +/** + * Items implementing this class will not get spilled out of the reactor, when they are in one. + * @author Aroma1997 + */ +public interface IBaseReactorComponent { + + /** + * This is to determine if the given Item can be put into a reactor.
+ * Items already in the reactor won't get spilled out. This only gets called, + * when placing the item in. + * @param stack The given reactor component. + * @param reactor The specific reactor to place the item in. + * @return If the item is accepted in the reactor. + */ + boolean canBePlacedIn(ItemStack stack, IReactor reactor); + +} diff --git a/src/api/java/ic2/api/reactor/IReactor.class b/src/api/java/ic2/api/reactor/IReactor.class index f711174e2..3b27ee12f 100644 Binary files a/src/api/java/ic2/api/reactor/IReactor.class and b/src/api/java/ic2/api/reactor/IReactor.class differ diff --git a/src/api/java/ic2/api/reactor/IReactor.java b/src/api/java/ic2/api/reactor/IReactor.java index 7f2cefc93..63b5d6057 100644 --- a/src/api/java/ic2/api/reactor/IReactor.java +++ b/src/api/java/ic2/api/reactor/IReactor.java @@ -5,10 +5,12 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import ic2.api.info.ILocatable; + /** * Interface implemented nuclear reactors, expected to be a {@link TileEntity}, but does not have to be. */ -public interface IReactor { +public interface IReactor extends ILocatable { /** * Return the tile entity representing the reactor core. *
@@ -22,18 +24,22 @@ public interface IReactor { * Return the reactor's current world instance (it's position can be acquired using {@link #getReactorPos()}. *
* Should be the same world as {@link #getCoreTe()} returns if it's not null. + * @deprecated See {@link #getWorldObj()} * * @return The reactor's world object */ + @Deprecated //TODO: remove for 1.11 public World getReactorWorld(); //getWorld has obfuscation issues (https://github.com/md-5/SpecialSource/issues/12) /** * Return the reactor's current position in the world ({@link #getReactorWorld()}. *
* Should be the same position as {@link #getCoreTe()} returns if it's not null. + * @deprecated See {@link #getPosition()} * * @return The reactor's current position */ + @Deprecated //TODO: remove for 1.11 public BlockPos getReactorPos(); //As would getPos /** diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.class b/src/api/java/ic2/api/reactor/IReactorComponent.class index cf1b0fb7a..8a7a6fccd 100644 Binary files a/src/api/java/ic2/api/reactor/IReactorComponent.class and b/src/api/java/ic2/api/reactor/IReactorComponent.class differ diff --git a/src/api/java/ic2/api/reactor/IReactorComponent.java b/src/api/java/ic2/api/reactor/IReactorComponent.java index 4b934e0c0..7916cc17b 100644 --- a/src/api/java/ic2/api/reactor/IReactorComponent.java +++ b/src/api/java/ic2/api/reactor/IReactorComponent.java @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; * All IC2 ReactorComponents implement and use this Interface * */ -public interface IReactorComponent { +public interface IReactorComponent extends IBaseReactorComponent { /** * Called by reactor upon iterating through it's inventory (every cycle). * Perform all necessary calculation/interaction here diff --git a/src/api/java/ic2/api/reactor/package-info.class b/src/api/java/ic2/api/reactor/package-info.class deleted file mode 100644 index d27d5e085..000000000 Binary files a/src/api/java/ic2/api/reactor/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/reactor/package-info.java b/src/api/java/ic2/api/reactor/package-info.java deleted file mode 100644 index b500c3d34..000000000 --- a/src/api/java/ic2/api/reactor/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.reactor; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class index 309dd5d11..b9899a9f2 100644 Binary files a/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class and b/src/api/java/ic2/api/recipe/ICannerEnrichRecipeManager$Input.class differ diff --git a/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerOutput.class b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerOutput.class new file mode 100644 index 000000000..e0fe95255 Binary files /dev/null and b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerOutput.class differ diff --git a/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerRecipe.class b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerRecipe.class new file mode 100644 index 000000000..8896a87a8 Binary files /dev/null and b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager$ElectrolyzerRecipe.class differ diff --git a/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.class b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.class new file mode 100644 index 000000000..a41162e9a Binary files /dev/null and b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.class differ diff --git a/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.java b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.java new file mode 100644 index 000000000..3b2917c57 --- /dev/null +++ b/src/api/java/ic2/api/recipe/IElectrolyzerRecipeManager.java @@ -0,0 +1,120 @@ +package ic2.api.recipe; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.apache.commons.lang3.tuple.Pair; + +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +/** + * Electrolyzer recipe manager, similar to {@link ISemiFluidFuelManager} and {@link IFermenterRecipeManager}, + * but more sided to fit how the Electrolyzer now works + * + * @author Chocohead + */ +public interface IElectrolyzerRecipeManager extends ILiquidAcceptManager { + /** + * Add a new recipe to the electrolyzer. + * + * @param input The name of the fluid being electrolyzed + * @param inputAmount The amount of input fluid used per operation (in millibuckets) + * @param EUaTick The EU used per tick + * @param outputs The output fluids, with a given direction for the tank to fill + */ + void addRecipe(@Nonnull String input, int inputAmount, int EUaTick, @Nonnull ElectrolyzerOutput... outputs); + + /** + * Add a new recipe to the electrolyzer. + * + * @param input The name of the fluid being electrolyzed + * @param inputAmount The amount of input fluid used per operation (in millibuckets) + * @param EUaTick The EU used per tick + * @param ticksNeeded The number of ticks each operation takes, will default to 200 if not given + * @param outputs The output fluids, with a given direction for the tank to fill + */ + void addRecipe(@Nonnull String input, int inputAmount, int EUaTick, int ticksNeeded, @Nonnull ElectrolyzerOutput... outputs); + + /** + * Get an electrolyzer recipe for the given fluid + * + * @param Input fluid + * @return The found recipe or null if no recipe is found + */ + ElectrolyzerRecipe getElectrolysisInformation(Fluid fluid); + + /** + * Get the {@link ElectrolyzerOutput}s for the given input fluid + * + * @param Input fluid + * @return Outputs and tank directions + */ + ElectrolyzerOutput[] getOutput(Fluid input); + + /** + * Gets the whole current fluid mappings + * @return The current fluid map + */ + Map getRecipeMap(); + + @ParametersAreNonnullByDefault + public static final class ElectrolyzerOutput { + /** + * @param fluidName The name of the output fluid + * @param fluidAmount The amount of the fluid produced per operation (in millibuckets) + * @param tankDirection The direction relative to the electrolyzer that the output tank should be + */ + public ElectrolyzerOutput(String fluidName, int fluidAmount, EnumFacing tankDirection) { + this.fluidName = fluidName; + this.fluidAmount = fluidAmount; + this.tankDirection = tankDirection; + } + + public FluidStack getOutput() { + return FluidRegistry.getFluid(fluidName) == null ? null : new FluidStack(FluidRegistry.getFluid(this.fluidName), this.fluidAmount); + } + + public Pair getFullOutput() { + return Pair.of(getOutput(), tankDirection); + } + + public final String fluidName; + public final int fluidAmount; + public final EnumFacing tankDirection; + } + + public static final class ElectrolyzerRecipe { + public ElectrolyzerRecipe(int inputAmount, int EUaTick, int ticksNeeded, ElectrolyzerOutput... outputs) { + this.inputAmount = inputAmount; + this.EUaTick = EUaTick; + this.ticksNeeded = ticksNeeded; + this.outputs = validateOutputs(outputs); + } + + private ElectrolyzerOutput[] validateOutputs(ElectrolyzerOutput[] outputs) { + if (outputs.length < 1 || outputs.length > 5) { + throw new RuntimeException("Cannot have "+outputs.length+" outputs of an Electrolzer recipe, must be between 1 and 5"); + } + Set directions = new HashSet(outputs.length * 2, 0.5F); + for (ElectrolyzerOutput output : outputs) { + if (!directions.add(output.tankDirection)) { + throw new RuntimeException("Duplicate direction in Electrolzer outputs ("+output.tankDirection+')'); + } + } + return outputs; + } + + public final int inputAmount; + public final int EUaTick; + public final int ticksNeeded; + public final ElectrolyzerOutput[] outputs; + } +} \ No newline at end of file diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class b/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class index cb375fc2b..4b8138fe0 100644 Binary files a/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class and b/src/api/java/ic2/api/recipe/IFermenterRecipeManager$FermentationProperty.class differ diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class index 78c4f28f8..450f09a43 100644 Binary files a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class and b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.class differ diff --git a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java index a7b7907ab..87fcba699 100644 --- a/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java +++ b/src/api/java/ic2/api/recipe/IFermenterRecipeManager.java @@ -13,11 +13,11 @@ import net.minecraftforge.fluids.FluidStack; */ public interface IFermenterRecipeManager extends ILiquidAcceptManager { /** - * Add a new fluid to the fermenter. + * Add a new recipe to the fermenter. * * @param input The name of the fluid to ferment - * @param inputAmount The amount of input fluid used per operation - * @param ticks The total amount of heat needed to convert the input into the output + * @param inputAmount The amount of input fluid used per operation (in millibuckets) + * @param heat The total amount of heat needed to convert the input into the output * @param output The name of the fluid that is being fermented into * @param outputAmount The amount of output fluid produced per operation */ @@ -44,7 +44,7 @@ public interface IFermenterRecipeManager extends ILiquidAcceptManager { */ Map getRecipeMap(); - public static class FermentationProperty { + public static final class FermentationProperty { public FermentationProperty(int inputAmount, int heat, String output, int outputAmount) { this.inputAmount = inputAmount; this.heat = heat; diff --git a/src/api/java/ic2/api/recipe/IRecipeInput.java b/src/api/java/ic2/api/recipe/IRecipeInput.java index 0c842d639..dd49f757a 100644 --- a/src/api/java/ic2/api/recipe/IRecipeInput.java +++ b/src/api/java/ic2/api/recipe/IRecipeInput.java @@ -4,10 +4,15 @@ import java.util.List; import net.minecraft.item.ItemStack; +/** + * Interface for recipe ingredient matchers. + * + * See {@link Recipes#inputFactory} for some default factory methods. + */ public interface IRecipeInput { /** * Check if subject matches this recipe input, ignoring the amount. - * + * * @param subject ItemStack to check * @return true if it matches the requirement */ @@ -15,16 +20,16 @@ public interface IRecipeInput { /** * Determine the minimum input stack size. - * + * * @return input amount required */ int getAmount(); /** * List all possible inputs (best effort). - * - * The stack size is undefined, use getAmount to get the correct one. - * + * + * The stack size has to match getAmount(). + * * @return list of inputs, may be incomplete */ List getInputs(); diff --git a/src/api/java/ic2/api/recipe/IRecipeInputFactory.class b/src/api/java/ic2/api/recipe/IRecipeInputFactory.class new file mode 100644 index 000000000..b6e90226b Binary files /dev/null and b/src/api/java/ic2/api/recipe/IRecipeInputFactory.class differ diff --git a/src/api/java/ic2/api/recipe/IRecipeInputFactory.java b/src/api/java/ic2/api/recipe/IRecipeInputFactory.java new file mode 100644 index 000000000..f802ebb2f --- /dev/null +++ b/src/api/java/ic2/api/recipe/IRecipeInputFactory.java @@ -0,0 +1,17 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.Fluid; + +public interface IRecipeInputFactory { + IRecipeInput forStack(ItemStack stack); + IRecipeInput forStack(ItemStack stack, int amount); + IRecipeInput forOreDict(String name); + IRecipeInput forOreDict(String name, int amount); + IRecipeInput forOreDict(String name, int amount, int metaOverride); + IRecipeInput forFluidContainer(Fluid fluid); + IRecipeInput forFluidContainer(Fluid fluid, int amount); + IRecipeInput forAny(IRecipeInput... options); + IRecipeInput forAny(Iterable options); +} diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager$BurnProperty.class b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager$BurnProperty.class index e1aba6db9..890fd21cd 100644 Binary files a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager$BurnProperty.class and b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager$BurnProperty.class differ diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.class b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.class index 562181cd5..3d867b887 100644 Binary files a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.class and b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.class differ diff --git a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java index 87c34270d..f9313d1d2 100644 --- a/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java +++ b/src/api/java/ic2/api/recipe/ISemiFluidFuelManager.java @@ -8,7 +8,7 @@ import net.minecraftforge.fluids.Fluid; public interface ISemiFluidFuelManager extends ILiquidAcceptManager { /** * Add a new fluid to the semi fluid generator. - * + * * @param fluidName the fluid to burn * @param amount amount of fluid to consume per tick * @param power amount of energy generated per tick @@ -20,10 +20,10 @@ public interface ISemiFluidFuelManager extends ILiquidAcceptManager { Map getBurnProperties(); - public static class BurnProperty { - public BurnProperty(int amount1, double power1) { - this.amount = amount1; - this.power = power1; + public static final class BurnProperty { + public BurnProperty(int amount, double power) { + this.amount = amount; + this.power = power; } public final int amount; diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class index eb5042a08..01caff171 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class and b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java index 3c05ed758..545b3a398 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java +++ b/src/api/java/ic2/api/recipe/RecipeInputFluidContainer.java @@ -1,18 +1,18 @@ package ic2.api.recipe; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; - import ic2.api.item.IC2Items; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +/** + * @deprecated Use {@link Recipes#inputFactory} instead. + */ +@Deprecated public class RecipeInputFluidContainer implements IRecipeInput { public RecipeInputFluidContainer(Fluid fluid) { this(fluid, Fluid.BUCKET_VOLUME); @@ -25,7 +25,7 @@ public class RecipeInputFluidContainer implements IRecipeInput { @Override public boolean matches(ItemStack subject) { - FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); + /*FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); if (fs == null && subject.getItem() instanceof IFluidContainerItem) { IFluidContainerItem item = (IFluidContainerItem)subject.getItem(); @@ -34,7 +34,8 @@ public class RecipeInputFluidContainer implements IRecipeInput { // match amount precisely to avoid having to deal with leftover return fs == null && fluid == null || - fs != null && fs.getFluid() == fluid && fs.amount >= amount; + fs != null && fs.getFluid() == fluid && fs.amount >= amount;*/ + return false; } @Override @@ -46,12 +47,15 @@ public class RecipeInputFluidContainer implements IRecipeInput { public List getInputs() { List ret = new ArrayList(); - for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); - } - ret.add(IC2Items.getItem("fluid_cell", fluid.getName())); + /*for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (data.fluid.getFluid() != fluid) continue; - return ret; + ret.add(RecipeUtil.setImmutableSize(data.filledContainer, getAmount())); + }*/ + + ret.add(RecipeUtil.setImmutableSize(IC2Items.getItem("fluid_cell", fluid.getName()), getAmount())); + + return Collections.unmodifiableList(ret); } @Override diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.class b/src/api/java/ic2/api/recipe/RecipeInputItemStack.class index c956c06d8..adccec38f 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputItemStack.class and b/src/api/java/ic2/api/recipe/RecipeInputItemStack.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java index 84f86ea12..459e6adf9 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputItemStack.java +++ b/src/api/java/ic2/api/recipe/RecipeInputItemStack.java @@ -1,28 +1,34 @@ package ic2.api.recipe; import java.util.Arrays; +import java.util.Collections; import java.util.List; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; +/** + * @deprecated Use {@link Recipes#inputFactory} instead. + */ +@Deprecated public class RecipeInputItemStack implements IRecipeInput { - public RecipeInputItemStack(ItemStack aInput) { - this(aInput, aInput.stackSize); + public RecipeInputItemStack(ItemStack input) { + this(input, input.getCount()); } - public RecipeInputItemStack(ItemStack aInput, int aAmount) { - if (aInput.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); + public RecipeInputItemStack(ItemStack input, int amount) { + if (input.getItem() == null) throw new IllegalArgumentException("Invalid item stack specfied"); - input = aInput.copy(); // Never forget to copy. - amount = aAmount; + this.input = input.copy(); // Never forget to copy. + this.amount = amount; } @Override public boolean matches(ItemStack subject) { - return subject.getItem() == input.getItem() && - (subject.getItemDamage() == input.getItemDamage() || input.getItemDamage() == OreDictionary.WILDCARD_VALUE); + return subject.getItem() == input.getItem() && // Item matching + (subject.getMetadata() == input.getMetadata() || input.getMetadata() == OreDictionary.WILDCARD_VALUE) && //meta matching + (input.getMetadata() == OreDictionary.WILDCARD_VALUE || RecipeUtil.matchesNBT(subject.getTagCompound(), input.getTagCompound())); //nbt matching. } @Override @@ -32,14 +38,12 @@ public class RecipeInputItemStack implements IRecipeInput { @Override public List getInputs() { - return Arrays.asList(input); + return Collections.unmodifiableList(Arrays.asList(RecipeUtil.setImmutableSize(input, getAmount()))); } @Override public String toString() { - ItemStack stack = input.copy(); - input.stackSize = amount; - return "RInputItemStack<"+stack+">"; + return "RInputItemStack<"+RecipeUtil.setImmutableSize(input, amount)+">"; } public final ItemStack input; diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.class b/src/api/java/ic2/api/recipe/RecipeInputOreDict.class index e7a3a2db3..705039579 100644 Binary files a/src/api/java/ic2/api/recipe/RecipeInputOreDict.class and b/src/api/java/ic2/api/recipe/RecipeInputOreDict.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java index e6e4695d0..b2e26ee1e 100644 --- a/src/api/java/ic2/api/recipe/RecipeInputOreDict.java +++ b/src/api/java/ic2/api/recipe/RecipeInputOreDict.java @@ -9,18 +9,22 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; +/** + * @deprecated Use {@link Recipes#inputFactory} instead. + */ +@Deprecated public class RecipeInputOreDict implements IRecipeInput { - public RecipeInputOreDict(String input1) { - this(input1, 1); + public RecipeInputOreDict(String input) { + this(input, 1); } - public RecipeInputOreDict(String input1, int amount1) { - this(input1, amount1, null); + public RecipeInputOreDict(String input, int amount) { + this(input, amount, null); } - public RecipeInputOreDict(String input1, int amount1, Integer meta) { - this.input = input1; - this.amount = amount1; + public RecipeInputOreDict(String input, int amount, Integer meta) { + this.input = input; + this.amount = amount; this.meta = meta; } @@ -56,21 +60,23 @@ public class RecipeInputOreDict implements IRecipeInput { List ores = getOres(); // check if we have to filter the list first - boolean hasInvalidEntries = false; + boolean hasUnsuitableEntries = false; for (ItemStack stack : ores) { - if (stack.getItem() == null) { - hasInvalidEntries = true; + if (stack.getItem() == null || stack.getCount() != getAmount()) { + hasUnsuitableEntries = true; break; } } - if (!hasInvalidEntries) return ores; + if (!hasUnsuitableEntries) return ores; List ret = new ArrayList(ores.size()); for (ItemStack stack : ores) { - if (stack.getItem() != null) ret.add(stack); // ignore invalid + if (stack.getItem() != null) { // ignore invalid + ret.add(RecipeUtil.setImmutableSize(stack, getAmount())); + } } return Collections.unmodifiableList(ret); diff --git a/src/api/java/ic2/api/recipe/RecipeUtil.class b/src/api/java/ic2/api/recipe/RecipeUtil.class new file mode 100644 index 000000000..eaf0c311c Binary files /dev/null and b/src/api/java/ic2/api/recipe/RecipeUtil.class differ diff --git a/src/api/java/ic2/api/recipe/RecipeUtil.java b/src/api/java/ic2/api/recipe/RecipeUtil.java new file mode 100644 index 000000000..7c901af78 --- /dev/null +++ b/src/api/java/ic2/api/recipe/RecipeUtil.java @@ -0,0 +1,34 @@ +package ic2.api.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; + +class RecipeUtil { + public static ItemStack setImmutableSize(ItemStack stack, int size) { + if (stack.getCount() != size) { + stack = stack.copy(); + stack.setCount(size); + } + + return stack; + } + + /** + * Checks whether the first Compound has all tags, the second one has as well. Used for ItemStack matching. + * @param subject The NBT to check. + * @param target The NBT to match. + * @return whether the first NBT has all tags equal to the one of the second. + */ + public static boolean matchesNBT(NBTTagCompound subject, NBTTagCompound target) { + if (subject == null) return target == null || target.hasNoTags(); + if (target == null) return true; + for (String key : target.getKeySet()) { + NBTBase targetNBT = target.getTag(key); + if (!subject.hasKey(key) || targetNBT.getId() != subject.getTagId(key)) return false; + NBTBase subjectNBT = subject.getTag(key); + if (!targetNBT.equals(subjectNBT)) return false; + } + return true; + } +} diff --git a/src/api/java/ic2/api/recipe/Recipes.class b/src/api/java/ic2/api/recipe/Recipes.class index 135ea928e..6f4bb5a2b 100644 Binary files a/src/api/java/ic2/api/recipe/Recipes.class and b/src/api/java/ic2/api/recipe/Recipes.class differ diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java index 50fc6e6fb..214148129 100644 --- a/src/api/java/ic2/api/recipe/Recipes.java +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -1,39 +1,156 @@ package ic2.api.recipe; - /** * General recipe registry. * - * @author Richard + *

IMachineRecipeManager.addRecipe takes a metadata parameter, the expected contents are specified + * below as "recipe meta". The metadata NBT itself should be null for "no recipe meta" or a + * NBTTagCompound with keys matching the names and value types mentioned below. + * + *

Example: Compressor recipe, Sand -> Glass: + *

{@code
+ * Recipes.compressor.addRecipe(new RecipeInputItemStack(new ItemStack(Blocks.SAND)), null, false, new ItemStack(Blocks.GLASS));
+ * }
+ * + *

Example: Metal former rolling recipe, Platinum ingot (oredict) -> Platinum plate: + *

{@code
+ * Recipes.metalformerRolling.addRecipe(new RecipeInputOreDict("ingotPlatinum"), null, false, myPlatinumPlateStack)
+ * }
+ * + *

Example: Mass fabricator amplifier, nether stars amplifying 1M EU: + *

{@code
+ * NBTTagCompound meta = new NBTTagCompound();
+ * meta.setInteger("amplification", 1000000);
+ * Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(Items.NETHER_STAR)), meta, false);
+ * }
+ * */ public class Recipes { + /** + * Convenience factory for various recipe input variants. + */ + public static IRecipeInputFactory inputFactory; + + /** + * Recipe manager for furnace recipes. + * + *

No recipe meta. + * + * @deprecated currently unused/not implemented, uses the vanilla furnace recipe list + */ + @Deprecated public static IMachineRecipeManager furnace; + + /** + * Recipe manager for macerator recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager macerator; + + /** + * Recipe manager for extractor recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager extractor; + + /** + * Recipe manager for compressor recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager compressor; + + /** + * Recipe manager for thermal centrifuge recipes. + * + *

Recipe meta: + *

    + *
  • int minHeat: minimum heat level required + *
+ */ public static IMachineRecipeManager centrifuge; + + /** + * Recipe manager for blast cutter recipes. + * + *

Recipe meta: + *

    + *
  • int hardness: minimum blade hardness (3=iron, 6=steel, 9=diamond) + *
+ */ public static IMachineRecipeManager blockcutter; + + /** + * Recipe manager for blast furnace recipes. + * + *

Recipe meta: + *

    + *
  • int fluid: input fluid amount per cycle (in mB) + *
  • int duration: process duration (in ticks) + *
+ */ public static IMachineRecipeManager blastfurnace; + + /** + * Recipe manager for recycler recipes. + * + *

No recipe meta. + * + * @note the implementation is currently immutable, any non-blacklisted item will be accepted, + * chance checking is up to the caller. + */ public static IMachineRecipeManager recycler; + + /** + * Recipe manager for metal former extrusion mode recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager metalformerExtruding; + + /** + * Recipe manager for metal former cutting mode recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager metalformerCutting; + + /** + * Recipe manager for metal former rolling mode recipes. + * + *

No recipe meta. + */ public static IMachineRecipeManager metalformerRolling; + + /** + * Recipe manager for ore washing plant recipes. + * + *

Recipe meta: + *

    + *
  • int amount: input fluid amount per cycle (in mB) + *
+ */ public static IMachineRecipeManager oreWashing; public static ICannerBottleRecipeManager cannerBottle; public static ICannerEnrichRecipeManager cannerEnrich; + public static IElectrolyzerRecipeManager electrolyzer; public static IFermenterRecipeManager fermenter; /** - * Reference amplifier values: + * Recipe manager for uu mass fabricator (matter gen) recipes. * - * 5000: Scrap - * 45000: Scrapbox + *

Recipe meta: + *

    + *
  • int amplification: amount of eu to be amplified per item (fixed +5x) + *
* - * As Parameter for the Amplification Value you have to use the NBTTagCompound - * - * NBTTagCompound nbt = new NBTTagCompound(); - * nbt.setInteger("amplification", aValue); - * matterAmplifier.addRecipe(yourStack, nbt); + *

Reference values: + *

    + *
  • 5000: Scrap + *
  • 45000: Scrapbox + *
*/ public static IMachineRecipeManager matterAmplifier; /** diff --git a/src/api/java/ic2/api/recipe/package-info.class b/src/api/java/ic2/api/recipe/package-info.class deleted file mode 100644 index 8a795bbdb..000000000 Binary files a/src/api/java/ic2/api/recipe/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/recipe/package-info.java b/src/api/java/ic2/api/recipe/package-info.java deleted file mode 100644 index 54b01a44e..000000000 --- a/src/api/java/ic2/api/recipe/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.recipe; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/tile/package-info.class b/src/api/java/ic2/api/tile/package-info.class deleted file mode 100644 index 9cd6bac26..000000000 Binary files a/src/api/java/ic2/api/tile/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/tile/package-info.java b/src/api/java/ic2/api/tile/package-info.java deleted file mode 100644 index 17bcde171..000000000 --- a/src/api/java/ic2/api/tile/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.tile; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/ic2/api/util/package-info.class b/src/api/java/ic2/api/util/package-info.class deleted file mode 100644 index 6aa78d24c..000000000 Binary files a/src/api/java/ic2/api/util/package-info.class and /dev/null differ diff --git a/src/api/java/ic2/api/util/package-info.java b/src/api/java/ic2/api/util/package-info.java deleted file mode 100644 index 8fe79432f..000000000 --- a/src/api/java/ic2/api/util/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@API(apiVersion="1.0", owner="IC2", provides="IC2API") -package ic2.api.util; -import net.minecraftforge.fml.common.API; - diff --git a/src/api/java/li/cil/oc/api/internal/Robot.java b/src/api/java/li/cil/oc/api/internal/Robot.java index b618deadb..04adf66df 100755 --- a/src/api/java/li/cil/oc/api/internal/Robot.java +++ b/src/api/java/li/cil/oc/api/internal/Robot.java @@ -1,9 +1,8 @@ package li.cil.oc.api.internal; -import li.cil.oc.api.network.EnvironmentHost; import li.cil.oc.api.network.Environment; +import li.cil.oc.api.network.EnvironmentHost; import net.minecraft.inventory.ISidedInventory; -import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -29,7 +28,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; *

* This interface is not meant to be implemented, just used. */ -public interface Robot extends Agent, Environment, EnvironmentHost, Tiered, ISidedInventory, IFluidHandler { +public interface Robot extends Agent, Environment, EnvironmentHost, Tiered, ISidedInventory { /** * The number of built-in components in this robot. */ diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java index 721af2336..d9983d39e 100644 --- a/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java +++ b/src/api/java/micdoodle8/mods/galacticraft/api/world/ISolarLevel.java @@ -9,8 +9,8 @@ package micdoodle8.mods.galacticraft.api.world; *

* for example: *

- * if (worldObj.provider instanceof ISolarLevel) solarStrength *= ((ISolarLevel) - * worldObj.provider).getSolarEnergyMultiplier(); + * if (world.provider instanceof ISolarLevel) solarStrength *= ((ISolarLevel) + * world.provider).getSolarEnergyMultiplier(); */ public interface ISolarLevel { diff --git a/src/api/java/net/darkhax/tesla/Tesla.java b/src/api/java/net/darkhax/tesla/Tesla.java index 540c2ca8d..5f32c9919 100755 --- a/src/api/java/net/darkhax/tesla/Tesla.java +++ b/src/api/java/net/darkhax/tesla/Tesla.java @@ -13,7 +13,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION_NUMBER, acceptedMinecraftVersions = "[1.9.4,1.10.2]") +@Mod(modid = Constants.MOD_ID, name = Constants.MOD_NAME, version = Constants.VERSION_NUMBER) public class Tesla { @Mod.Instance(Constants.MOD_ID) diff --git a/src/api/java/net/darkhax/tesla/lib/Constants.java b/src/api/java/net/darkhax/tesla/lib/Constants.java index 1264984bf..6cba6148e 100755 --- a/src/api/java/net/darkhax/tesla/lib/Constants.java +++ b/src/api/java/net/darkhax/tesla/lib/Constants.java @@ -1,8 +1,8 @@ -package net.darkhax.tesla.lib; - -public class Constants { - - public static final String MOD_ID = "tesla"; - public static final String MOD_NAME = "TESLA"; - public static final String VERSION_NUMBER = "1.2.1.0"; -} +package net.darkhax.tesla.lib; + +public class Constants { + + public static final String MOD_ID = "tesla"; + public static final String MOD_NAME = "TESLA"; + public static final String VERSION_NUMBER = "1.3.0.0"; +} diff --git a/src/api/java/net/darkhax/tesla/lib/PowerBar.java b/src/api/java/net/darkhax/tesla/lib/PowerBar.java index 1ac5f4737..a1009de2b 100755 --- a/src/api/java/net/darkhax/tesla/lib/PowerBar.java +++ b/src/api/java/net/darkhax/tesla/lib/PowerBar.java @@ -8,32 +8,42 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class PowerBar { - + + /** + * The width of the power bar. + */ + public static final int WIDTH = 14; + + /** + * The height of the power bar. + */ + public static final int HEIGHT = 50; + /** * Constant reference to the included gui element sheet. */ private static final ResourceLocation TEXTURE_SHEET = new ResourceLocation("tesla", "textures/gui/elements.png"); - + /** * The x position of the power bar on the screen. */ private final int x; - + /** * The y position of the power bar on the screen. */ private final int y; - + /** * The screen to draw the power bar on. */ private final GuiScreen screen; - + /** * The type of background the use when drawing the power bar. */ private final BackgroundType background; - + /** * Object that can be used to draw a power bar on the screen. * @@ -43,58 +53,74 @@ public class PowerBar { * @param type The background type to use for the power bar. */ public PowerBar(GuiScreen screen, int x, int y, BackgroundType type) { - + this.background = type; this.screen = screen; this.x = x; this.y = y; } - + /** * Draws a power bar that represents the power held within an ITeslaHolder. - * + * * @param holder The holder to represent. */ public void draw (ITeslaHolder holder) { - + draw(holder.getStoredPower(), holder.getCapacity()); } - + /** * Draws a power bard that represents the based power information. - * + * * @param power The amount of power to represent. * @param capacity The capacity to represent. */ public void draw (long power, long capacity) { - + screen.mc.getTextureManager().bindTexture(TEXTURE_SHEET); - + if (this.background == BackgroundType.LIGHT) - screen.drawTexturedModalRect(x, y, 3, 1, 14, 50); - + screen.drawTexturedModalRect(x, y, 3, 1, WIDTH, HEIGHT); + else if (this.background == BackgroundType.DARK) - screen.drawTexturedModalRect(x, y, 3, 53, 14, 50); - - long powerOffset = (power * 51) / capacity; - screen.drawTexturedModalRect(x + 1, (int) (y + 50 - powerOffset), 18, (int) (51 - powerOffset), 14, (int) (powerOffset + 2)); + screen.drawTexturedModalRect(x, y, 3, 53, WIDTH, HEIGHT); + + long powerOffset = (power * (HEIGHT + 1)) / capacity; + screen.drawTexturedModalRect(x + 1, (int) (y + HEIGHT - powerOffset), 18, (int) ((HEIGHT + 1) - powerOffset), WIDTH, (int) (powerOffset + 2)); } - + + /** + * @return The x position of the power bar on the screen. + */ + public int getX() { + + return x; + } + + /** + * @return The y position of the power bar on the screen. + */ + public int getY() { + + return y; + } + /** * Describes a background image to be rendered for a power bar. */ public enum BackgroundType { - + /** * No background texture. */ NONE, - + /** * The lighter background texture. */ LIGHT, - + /** * The darker background texture. */ diff --git a/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java b/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java index 2d9f9012d..1893b5c7c 100755 --- a/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java +++ b/src/api/java/net/darkhax/tesla/lib/TeslaUtils.java @@ -1,302 +1,425 @@ -package net.darkhax.tesla.lib; - -import java.util.ArrayList; -import java.util.List; - -import net.darkhax.tesla.api.ITeslaConsumer; -import net.darkhax.tesla.api.ITeslaHolder; -import net.darkhax.tesla.api.ITeslaProducer; -import net.darkhax.tesla.capability.TeslaCapabilities; -import net.minecraft.client.resources.I18n; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; - -public class TeslaUtils { - - /** - * The smallest unit of power measurement. - */ - public static final int TESLA = 1; - - /** - * The amount of Tesla in a KiloTesla. One thousand. - */ - public static final int KILOTESLA = 1000; - - /** - * The amount of Telsa in a MegaTesla. One Million. - */ - public static final int MEGATESLA = 1000000; - - /** - * The amount of Tesla in a GigaTesla. One Billion. - */ - public static final int GIGATESLA = 1000000000; - - /** - * The amount of Telsa in a TeraTesla. One Trillion. - */ - public static final long TERATESLA = 1000000000000L; - - /** - * The amount of Tesla in a PentaTesla. One Quadrilli.on - */ - public static final long PENTATESLA = 1000000000000000L; - - /** - * The amount of Tesla in a ExaTesla. One Quintilian. - * - * The ExaTesla should not be treated as the largest unit of Tesla. The naming scheme can - * go on indefinitely. The next unit would be a ZettaTesla, followed by YottaTesla, - * BronoTesla, GeopTesla and so on. While it is possible to define these measurements, - * there really isn't a point. - */ - public static final long EXATESLA = 1000000000000000000L; - - /** - * Converts an amount of Tesla units into a human readable String. The string amount is - * only rounded to one decimal place. - * - * @param tesla The amount of Tesla units to display. - * @return A human readable display of the Tesla units. - */ - public static String getDisplayableTeslaCount (long tesla) { - - if (tesla < 1000) - return tesla + " T"; - - final int exp = (int) (Math.log(tesla) / Math.log(1000)); - final char unitType = "KMGTPE".charAt(exp - 1); - return String.format("%.1f %sT", tesla / Math.pow(1000, exp), unitType); - } - - /** - * Gets the abbreviated name of the best unit to describe the provided power. For example, - * anything less than 1000 will return t for tesla, while anything between 999 and one - * million will return kt for kilo tesla. This method has support for up to Exatesla. - * - * @param tesla The amount of Tesla to get the unit for. - * @return The abbreviated name for the unit used to describe the provided power amount. - */ - public static String getUnitType (long tesla) { - - if (tesla < 1000) - return tesla + "t"; - - final int exp = (int) (Math.log(tesla) / Math.log(1000)); - return "kmgtpe".charAt(exp - 1) + "t"; - } - - /** - * Gets the name of the the power unit that best represents the amount of provided power. - * The name will be translated to the local language, or english if that language is not - * yet supported. - * - * @param tesla The amount of Tesla to get the unit name for. - * @return The name of the power unit that best represents the amount of power provided. - */ - public static String getLocalizedUnitType (long tesla) { - - return I18n.format("unit.tesla." + getUnitType(tesla)); - } - - /** - * Checks if a capability provider has support for Tesla. - * - * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. - * @param side The side to check. - * @return Whether or not the provider has support for Tesla. - */ - public static boolean hasTeslaSupport (ICapabilityProvider provider, EnumFacing side) { - - return isTeslaHolder(provider, side) || isTeslaConsumer(provider, side) || isTeslaProducer(provider, side); - } - - /** - * Checks if a capability provider is a Tesla holder. - * - * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. - * @param side The side to check. - * @return Whether or not the provider is a Tesla holder. - */ - public static boolean isTeslaHolder (ICapabilityProvider provider, EnumFacing side) { - - return provider.hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); - } - - /** - * Checks if a capability provider is a Tesla consumer. - * - * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. - * @param side The side to check. - * @return Whether or not the provider is a Tesla consumer. - */ - public static boolean isTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { - - return provider.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side); - } - - /** - * Checks if a capability provider is a Tesla producer. - * - * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. - * @param side The side to check. - * @return Whether or not the provider is a Tesla producer. - */ - public static boolean isTeslaProducer (ICapabilityProvider provider, EnumFacing side) { - - return provider.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, side); - } - - /** - * Gets an ITeslaHolder implementation from the capability provider. - * - * @param provider The provider to get the capability from. - * @param side The side to access; - * @return A Tesla holder implementation, or null if none could be found. - */ - public static ITeslaHolder getTeslaHolder (ICapabilityProvider provider, EnumFacing side) { - - return (ITeslaHolder) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); - } - - /** - * Gets an ITeslaConsumer implementation from the capability provider. - * - * @param provider The provider to get the capability from. - * @param side The side to access; - * @return A Tesla consumer implementation, or null if none could be found. - */ - public static ITeslaConsumer getTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { - - return (ITeslaConsumer) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); - } - - /** - * Gets an ITeslaProducer implementation from the capability provider. - * - * @param provider The provider to get the capability from. - * @param side The side to access; - * @return A Tesla producer implementation, or null if none could be found. - */ - public static ITeslaProducer getTeslaProducer (ICapabilityProvider provider, EnumFacing side) { - - return (ITeslaProducer) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); - } - - /** - * Gets the capacity of a provider. - * - * @param provider The provider to access. - * @param side The side to access. - * @return The capacity of the provider. 0 if it has no capacity. - */ - public static long getCapacity (ICapabilityProvider provider, EnumFacing side) { - - return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getCapacity() : 0; - } - - /** - * Gets the stored power of a provider. - * - * @param provider The provider to access. - * @param side The side to access. - * @return The amount of power stored. - */ - public static long getStoredPower (ICapabilityProvider provider, EnumFacing side) { - - return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getStoredPower() : 0; - } - - /** - * Attempt to give power to a provider. - * - * @param power The amount of power to offer. - * @param simulated Whether or not this is being called as part of a simulation. - * Simulations are used to get information without affecting the Tesla Producer. - * @return The amount of power that the consumer accepts. - */ - public static long givePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { - - return isTeslaConsumer(provider, side) ? getTeslaConsumer(provider, side).givePower(power, simulated) : 0; - } - - /** - * Attempts to take power from a provider. - * - * @param power The amount of power to request. - * @param simulated Whether or not this is being called as part of a simulation. - * Simulations are used to get information without affecting the Tesla Producer. - * @return The amount of power that the Tesla Producer will give. - */ - public static long takePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { - - return isTeslaProducer(provider, side) ? getTeslaProducer(provider, side).takePower(power, simulated) : 0; - } - - /** - * Gets a list of all capabilities that touch a BlockPos. This will search for tile - * entities touching the BlockPos and then query them for access to their capabilities. - * - * @param capability The capability you want to retrieve. - * @param world The world that this is happening in. - * @param pos The position to search around. - * @return A list of all capabilities that are being held by connected blocks. - */ - public static List getConnectedCapabilities (Capability capability, World world, BlockPos pos) { - - final List capabilities = new ArrayList(); - - for (final EnumFacing side : EnumFacing.values()) { - - final TileEntity tile = world.getTileEntity(pos.offset(side)); - - if (tile != null && !tile.isInvalid() && tile.hasCapability(capability, side.getOpposite())) - capabilities.add(tile.getCapability(capability, side.getOpposite())); - } - - return capabilities; - } - - /** - * Attempts to give power to all consumers touching the given BlockPos. - * - * @param world The world that this is happening in. - * @param pos The position to search around. - * @param amount The amount of power to offer to each individual face. - * @param simulated Whether or not this is being ran as part of a simulation. - * @return The amount of power that was consumed. - */ - public static long distributePowerToAllFaces (World world, BlockPos pos, long amount, boolean simulated) { - - long consumedPower = 0L; - - for (final ITeslaConsumer consumer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_CONSUMER, world, pos)) - consumedPower += consumer.givePower(amount, simulated); - - return consumedPower; - } - - /** - * Attempts to consume power from all producers touching the given BlockPos. - * - * @param world The world that this is happening in. - * @param pos The position to search around. - * @param amount The amount of power to request from each individual face. - * @param simulated Whether or not this is being ran as part of a simulation. - * @return The amount of power that was successfully consumed. - */ - public static long consumePowerFromAllFaces (World world, BlockPos pos, long amount, boolean simulated) { - - long recievedPower = 0L; - - for (final ITeslaProducer producer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_PRODUCER, world, pos)) - recievedPower += producer.takePower(amount, simulated); - - return recievedPower; - } +package net.darkhax.tesla.lib; + +import java.util.ArrayList; +import java.util.List; + +import com.mojang.realmsclient.gui.ChatFormatting; + +import net.darkhax.tesla.api.ITeslaConsumer; +import net.darkhax.tesla.api.ITeslaHolder; +import net.darkhax.tesla.api.ITeslaProducer; +import net.darkhax.tesla.api.implementation.BaseTeslaContainer; +import net.darkhax.tesla.capability.TeslaCapabilities; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class TeslaUtils { + + /** + * The smallest unit of power measurement. + */ + public static final int TESLA = 1; + + /** + * The amount of Tesla in a KiloTesla. One thousand. + */ + public static final int KILOTESLA = 1000; + + /** + * The amount of Telsa in a MegaTesla. One Million. + */ + public static final int MEGATESLA = 1000000; + + /** + * The amount of Tesla in a GigaTesla. One Billion. + */ + public static final int GIGATESLA = 1000000000; + + /** + * The amount of Telsa in a TeraTesla. One Trillion. + */ + public static final long TERATESLA = 1000000000000L; + + /** + * The amount of Tesla in a PentaTesla. One Quadrillion. + */ + public static final long PETATESLA = 1000000000000000L; + + /** + * The amount of Tesla in a ExaTesla. One Quintilian. + * + * The ExaTesla should not be treated as the largest unit of Tesla. The naming scheme can + * go on indefinitely. The next unit would be a ZettaTesla, followed by YottaTesla, + * BronoTesla, GeopTesla and so on. While it is possible to define these measurements, + * there really isn't a point. + */ + public static final long EXATESLA = 1000000000000000000L; + + /** + * Converts an amount of Tesla units into a human readable String. The string amount is + * only rounded to one decimal place. + * + * @param tesla The amount of Tesla units to display. + * @return A human readable display of the Tesla units. + */ + public static String getDisplayableTeslaCount (long tesla) { + + if (tesla < 1000) + return tesla + " T"; + + final int exp = (int) (Math.log(tesla) / Math.log(1000)); + final char unitType = "KMGTPE".charAt(exp - 1); + return String.format("%.1f %sT", tesla / Math.pow(1000, exp), unitType); + } + + /** + * Gets the abbreviated name of the best unit to describe the provided power. For example, + * anything less than 1000 will return t for tesla, while anything between 999 and one + * million will return kt for kilo tesla. This method has support for up to Exatesla. + * + * @param tesla The amount of Tesla to get the unit for. + * @return The abbreviated name for the unit used to describe the provided power amount. + */ + public static String getUnitType (long tesla) { + + if (tesla < 1000) + return tesla + "t"; + + final int exp = (int) (Math.log(tesla) / Math.log(1000)); + return "kmgtpe".charAt(exp - 1) + "t"; + } + + /** + * Gets the name of the the power unit that best represents the amount of provided power. + * The name will be translated to the local language, or english if that language is not + * yet supported. + * + * @param tesla The amount of Tesla to get the unit name for. + * @return The name of the power unit that best represents the amount of power provided. + */ + public static String getLocalizedUnitType (long tesla) { + + return I18n.format("unit.tesla." + getUnitType(tesla)); + } + + /** + * Checks if a capability provider has support for Tesla. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider has support for Tesla. + */ + public static boolean hasTeslaSupport (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) || isTeslaConsumer(provider, side) || isTeslaProducer(provider, side); + } + + /** + * Checks if a capability provider is a Tesla holder. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla holder. + */ + public static boolean isTeslaHolder (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Checks if a capability provider is a Tesla consumer. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla consumer. + */ + public static boolean isTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side); + } + + /** + * Checks if a capability provider is a Tesla producer. + * + * @param provider The provider to check. ItemStack/TileEntity/Entity and so on. + * @param side The side to check. + * @return Whether or not the provider is a Tesla producer. + */ + public static boolean isTeslaProducer (ICapabilityProvider provider, EnumFacing side) { + + return provider.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, side); + } + + /** + * Gets an ITeslaHolder implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla holder implementation, or null if none could be found. + */ + public static ITeslaHolder getTeslaHolder (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaHolder) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side); + } + + /** + * Gets an ITeslaConsumer implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla consumer implementation, or null if none could be found. + */ + public static ITeslaConsumer getTeslaConsumer (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaConsumer) provider.getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, side); + } + + /** + * Gets an ITeslaProducer implementation from the capability provider. + * + * @param provider The provider to get the capability from. + * @param side The side to access; + * @return A Tesla producer implementation, or null if none could be found. + */ + public static ITeslaProducer getTeslaProducer (ICapabilityProvider provider, EnumFacing side) { + + return (ITeslaProducer) provider.getCapability(TeslaCapabilities.CAPABILITY_PRODUCER, side); + } + + /** + * Gets the capacity of a provider. + * + * @param provider The provider to access. + * @param side The side to access. + * @return The capacity of the provider. 0 if it has no capacity. + */ + public static long getCapacity (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getCapacity() : 0; + } + + /** + * Gets the stored power of a provider. + * + * @param provider The provider to access. + * @param side The side to access. + * @return The amount of power stored. + */ + public static long getStoredPower (ICapabilityProvider provider, EnumFacing side) { + + return isTeslaHolder(provider, side) ? getTeslaHolder(provider, side).getStoredPower() : 0; + } + + /** + * Attempt to give power to a provider. + * + * @param power The amount of power to offer. + * @param simulated Whether or not this is being called as part of a simulation. + * Simulations are used to get information without affecting the Tesla Producer. + * @return The amount of power that the consumer accepts. + */ + public static long givePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { + + return isTeslaConsumer(provider, side) ? getTeslaConsumer(provider, side).givePower(power, simulated) : 0; + } + + /** + * Attempts to take power from a provider. + * + * @param power The amount of power to request. + * @param simulated Whether or not this is being called as part of a simulation. + * Simulations are used to get information without affecting the Tesla Producer. + * @return The amount of power that the Tesla Producer will give. + */ + public static long takePower (ICapabilityProvider provider, EnumFacing side, long power, boolean simulated) { + + return isTeslaProducer(provider, side) ? getTeslaProducer(provider, side).takePower(power, simulated) : 0; + } + + /** + * Gets a list of all capabilities that touch a BlockPos. This will search for tile + * entities touching the BlockPos and then query them for access to their capabilities. + * + * @param capability The capability you want to retrieve. + * @param world The world that this is happening in. + * @param pos The position to search around. + * @return A list of all capabilities that are being held by connected blocks. + */ + public static List getConnectedCapabilities (Capability capability, World world, BlockPos pos) { + + final List capabilities = new ArrayList(); + + for (final EnumFacing side : EnumFacing.values()) { + + final TileEntity tile = world.getTileEntity(pos.offset(side)); + + if (tile != null && !tile.isInvalid() && tile.hasCapability(capability, side.getOpposite())) + capabilities.add(tile.getCapability(capability, side.getOpposite())); + } + + return capabilities; + } + + /** + * Attempts to give power to all consumers touching the given BlockPos. + * + * @param world The world that this is happening in. + * @param pos The position to search around. + * @param amount The amount of power to offer to each individual face. + * @param simulated Whether or not this is being ran as part of a simulation. + * @return The amount of power that was consumed. + */ + public static long distributePowerToAllFaces (World world, BlockPos pos, long amount, boolean simulated) { + + long consumedPower = 0L; + + for (final ITeslaConsumer consumer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_CONSUMER, world, pos)) + consumedPower += consumer.givePower(amount, simulated); + + return consumedPower; + } + + /** + * Attempts to consume power from all producers touching the given BlockPos. + * + * @param world The world that this is happening in. + * @param pos The position to search around. + * @param amount The amount of power to request from each individual face. + * @param simulated Whether or not this is being ran as part of a simulation. + * @return The amount of power that was successfully consumed. + */ + public static long consumePowerFromAllFaces (World world, BlockPos pos, long amount, boolean simulated) { + + long recievedPower = 0L; + + for (final ITeslaProducer producer : getConnectedCapabilities(TeslaCapabilities.CAPABILITY_PRODUCER, world, pos)) + recievedPower += producer.takePower(amount, simulated); + + return recievedPower; + } + + /** + * Checks if a capability is for the Tesla holder. + * + * @param capability The capability to check. + * @return Whether or not the capability is for the Tesla holder. + */ + public static boolean isHolderCapability (Capability capability) { + + return capability == TeslaCapabilities.CAPABILITY_HOLDER; + } + + /** + * Checks if a capability is for the Tesla consumer. + * + * @param capability The capability to check. + * @return Whether or not the capability is for the Tesla consumer. + */ + public static boolean isConsumerCapability (Capability capability) { + + return capability == TeslaCapabilities.CAPABILITY_CONSUMER; + } + + /** + * Checks if a capability is for the Tesla producer. + * + * @param capability The capability to check. + * @return Whether or not the capability is for the Tesla producer. + */ + public static boolean isProducerCapability (Capability capability) { + + return capability == TeslaCapabilities.CAPABILITY_PRODUCER; + } + + /** + * Checks if a capability is a Tesla capability + * + * @param capability The capability to check. + * @return Whether or not the capability is a Tesla capability. + */ + public static boolean isTeslaCapability (Capability capability) { + + return isHolderCapability(capability) || isConsumerCapability(capability) || isProducerCapability(capability); + } + + /** + * Generates tooltip data for an ItemStack that has the ITeslaHolder interface. + * Additionally, if the holder is a BaseTeslaContainer, input/output rates will be shown. + * + * @param stack The ItemStack to make the tooltip for. + * @param tooltip A list of strings which represent the lines of the tooltip. + */ + @SideOnly(Side.CLIENT) + public static void createTooltip (ItemStack stack, List tooltip) { + + if (isTeslaHolder(stack, EnumFacing.DOWN)) { + + final KeyBinding keyBindSneak = Minecraft.getMinecraft().gameSettings.keyBindSneak; + final ITeslaHolder holder = TeslaUtils.getTeslaHolder(stack, EnumFacing.DOWN); + + if (GameSettings.isKeyDown(keyBindSneak)) { + + addHolderInfo(holder, tooltip); + + if (holder instanceof BaseTeslaContainer) { + + final BaseTeslaContainer container = (BaseTeslaContainer) holder; + tooltip.add(ChatFormatting.DARK_AQUA + I18n.format("tooltip.tesla.input", Long.toString(container.getInputRate()))); + tooltip.add(ChatFormatting.DARK_AQUA + I18n.format("tooltip.tesla.output", Long.toString(container.getOutputRate()))); + } + } + + else + tooltip.add(I18n.format("tooltip.tesla.showinfo", ChatFormatting.DARK_AQUA, keyBindSneak.getDisplayName(), ChatFormatting.GRAY)); + } + } + + /** + * Adds Tesla holder info to a tooltip. + * + * @param stack The ItemStack to display info for. + * @param tooltip The tooltip to add the info to. + */ + @SideOnly(Side.CLIENT) + public static void addHolderInfo (ItemStack stack, List tooltip) { + + if (isTeslaHolder(stack, EnumFacing.DOWN)) + addHolderInfo(getTeslaHolder(stack, EnumFacing.DOWN), tooltip); + } + + /** + * Adds Tesla holder info to a tooltip. + * + * @param holder The ITeslaHolder to display info for. + * @param tooltip The tooltip to add the info to. + */ + @SideOnly(Side.CLIENT) + public static void addHolderInfo (ITeslaHolder holder, List tooltip) { + + addHolderInfo(holder.getStoredPower(), holder.getCapacity(), tooltip); + } + + /** + * Adds Tesla holder info to a tooltip. + * + * @param stored The amount of stored power. + * @param capacity The max capacity. + * @param tooltip The tooltip to add the info to. + */ + @SideOnly(Side.CLIENT) + public static void addHolderInfo (long stored, long capacity, List tooltip) { + + tooltip.add(ChatFormatting.DARK_AQUA + I18n.format("tooltip.tesla.powerinfo", Long.toString(stored), Long.toString(capacity))); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/api/Coord4D.java b/src/main/java/mekanism/api/Coord4D.java index b222b4424..918f96e2b 100644 --- a/src/main/java/mekanism/api/Coord4D.java +++ b/src/main/java/mekanism/api/Coord4D.java @@ -45,7 +45,7 @@ public class Coord4D yCoord = (int)entity.posY; zCoord = (int)entity.posZ; - dimensionId = entity.worldObj.provider.getDimension(); + dimensionId = entity.world.provider.getDimension(); } /** @@ -57,9 +57,9 @@ public class Coord4D */ public Coord4D(double x, double y, double z, int dimension) { - xCoord = MathHelper.floor_double(x); - yCoord = MathHelper.floor_double(y); - zCoord = MathHelper.floor_double(z); + xCoord = MathHelper.floor(x); + yCoord = MathHelper.floor(y); + zCoord = MathHelper.floor(z); dimensionId = dimension; } @@ -295,7 +295,7 @@ public class Coord4D int subX = xCoord - obj.xCoord; int subY = yCoord - obj.yCoord; int subZ = zCoord - obj.zCoord; - return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); + return (int)MathHelper.sqrt(subX * subX + subY * subY + subZ * subZ); } /** diff --git a/src/main/java/mekanism/api/Pos3D.java b/src/main/java/mekanism/api/Pos3D.java index b00c51484..9849a3323 100644 --- a/src/main/java/mekanism/api/Pos3D.java +++ b/src/main/java/mekanism/api/Pos3D.java @@ -181,7 +181,7 @@ public class Pos3D extends Vec3d double subX = xCoord - pos.xCoord; double subY = yCoord - pos.yCoord; double subZ = zCoord - pos.zCoord; - return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); + return MathHelper.sqrt(subX * subX + subY * subY + subZ * subZ); } /** diff --git a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java index e19a94749..707cc23bb 100644 --- a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java +++ b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java @@ -46,7 +46,7 @@ public abstract class DynamicNetwork> implemen protected int updateDelay = 0; protected boolean firstUpdate = true; - protected World worldObj = null; + protected World world = null; public void addNewTransmitters(Collection> newTransmitters) { @@ -61,9 +61,9 @@ public abstract class DynamicNetwork> implemen { if(transmitter.isValid()) { - if(worldObj == null) + if(world == null) { - worldObj = transmitter.world(); + world = transmitter.world(); } for(EnumFacing side : EnumFacing.VALUES) @@ -180,7 +180,7 @@ public abstract class DynamicNetwork> implemen public void invalidateTransmitter(IGridTransmitter transmitter) { - if(!worldObj.isRemote && transmitter.isValid()) + if(!world.isRemote && transmitter.isValid()) { transmitter.takeShare(); transmitter.setTransmitterNetwork(null); @@ -334,7 +334,7 @@ public abstract class DynamicNetwork> implemen public World getWorld() { - return worldObj; + return world; } public abstract Set> getAcceptors(Object data); diff --git a/src/main/java/mekanism/api/util/StackUtils.java b/src/main/java/mekanism/api/util/StackUtils.java index 01f2815f8..6cd18686e 100644 --- a/src/main/java/mekanism/api/util/StackUtils.java +++ b/src/main/java/mekanism/api/util/StackUtils.java @@ -11,21 +11,21 @@ public final class StackUtils { public static List split(ItemStack stack) { - if(stack == null || stack.stackSize == 0) + if(stack == null || stack.getCount() == 0) { return null; } List ret = new ArrayList(); - if(stack.stackSize == 1) + if(stack.getCount() == 1) { ret.add(stack); return ret; } - int remain = stack.stackSize % 2; - int split = (int)((float)(stack.stackSize)/2F); + int remain = stack.getCount() % 2; + int split = (int)((float)(stack.getCount())/2F); ret.add(size(stack, split+remain)); ret.add(size(stack, split)); @@ -145,7 +145,7 @@ public final class StackUtils } ItemStack ret = stack.copy(); - ret.stackSize = size; + ret.setCount(size); return ret; } @@ -162,7 +162,7 @@ public final class StackUtils public static int getSize(ItemStack stack) { - return stack != null ? stack.stackSize : 0; + return stack != null ? stack.getCount() : 0; } public static List getMergeRejects(ItemStack[] orig, ItemStack[] toAdd) @@ -213,7 +213,7 @@ public final class StackUtils return orig; } - return StackUtils.size(orig, Math.min(orig.getMaxStackSize(), orig.stackSize+toAdd.stackSize)); + return StackUtils.size(orig, Math.min(orig.getMaxStackSize(), orig.getCount()+toAdd.getCount())); } public static ItemStack getMergeReject(ItemStack orig, ItemStack toAdd) @@ -233,7 +233,7 @@ public final class StackUtils return orig; } - int newSize = orig.stackSize+toAdd.stackSize; + int newSize = orig.getCount()+toAdd.getCount(); if(newSize > orig.getMaxStackSize()) { diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index e443519b4..6dc5d50f2 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -212,7 +212,7 @@ import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderSkeleton; -import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.AbstractSkeleton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; @@ -289,7 +289,7 @@ public class ClientProxy extends CommonProxy @Override public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, BlockPos pos, EnumHand hand) { - TileEntityPersonalChest tileEntity = (TileEntityPersonalChest)entityplayer.worldObj.getTileEntity(pos); + TileEntityPersonalChest tileEntity = (TileEntityPersonalChest)entityplayer.world.getTileEntity(pos); if(id == 0) { @@ -856,7 +856,7 @@ public class ClientProxy extends CommonProxy @Override public void addHitEffects(Coord4D coord, RayTraceResult mop) { - if(Minecraft.getMinecraft().theWorld != null) + if(Minecraft.getMinecraft().world != null) { Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(coord.getPos(), mop); } @@ -1007,7 +1007,7 @@ public class ClientProxy extends CommonProxy }); RenderingRegistry.registerEntityRenderingHandler(EntityBabySkeleton.class, new IRenderFactory() { @Override - public Render createRenderFor(RenderManager manager) + public Render createRenderFor(RenderManager manager) { return new RenderSkeleton(manager); } @@ -1114,20 +1114,20 @@ public class ClientProxy extends CommonProxy return context.getServerHandler().playerEntity; } else { - return Minecraft.getMinecraft().thePlayer; + return Minecraft.getMinecraft().player; } } @Override public void handlePacket(Runnable runnable, EntityPlayer player) { - if(player == null || player.worldObj.isRemote) + if(player == null || player.world.isRemote) { Minecraft.getMinecraft().addScheduledTask(runnable); } - else if(player != null && !player.worldObj.isRemote) + else if(player != null && !player.world.isRemote) { - ((WorldServer)player.worldObj).addScheduledTask(runnable); //singleplayer + ((WorldServer)player.world).addScheduledTask(runnable); //singleplayer } } diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index e63846429..d3cb07f4c 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -94,9 +94,9 @@ public class ClientTickHandler { MekanismClient.ticksPassed++; - if(!hasNotified && mc.theWorld != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null) + if(!hasNotified && mc.world != null && Mekanism.latestVersionNumber != null && Mekanism.recentNews != null) { - MekanismUtils.checkForUpdates(mc.thePlayer); + MekanismUtils.checkForUpdates(mc.player); hasNotified = true; } @@ -116,7 +116,7 @@ public class ClientTickHandler } } - if(mc.theWorld != null) + if(mc.world != null) { shouldReset = true; } @@ -126,15 +126,15 @@ public class ClientTickHandler shouldReset = false; } - if(mc.theWorld != null && !Mekanism.proxy.isPaused()) + if(mc.world != null && !Mekanism.proxy.isPaused()) { - if((!initHoliday || MekanismClient.ticksPassed % 1200 == 0) && mc.thePlayer != null) + if((!initHoliday || MekanismClient.ticksPassed % 1200 == 0) && mc.player != null) { HolidayManager.check(); initHoliday = true; } - for(EntityPlayer entityPlayer : mc.theWorld.playerEntities) + for(EntityPlayer entityPlayer : mc.world.playerEntities) { if(entityPlayer instanceof AbstractClientPlayer) { @@ -203,63 +203,63 @@ public class ClientTickHandler } } - ItemStack bootStack = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.FEET); + ItemStack bootStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET); if(bootStack != null && bootStack.getItem() instanceof ItemFreeRunners) { - mc.thePlayer.stepHeight = 1.002F; + mc.player.stepHeight = 1.002F; } else { - if(mc.thePlayer.stepHeight == 1.002F) + if(mc.player.stepHeight == 1.002F) { - mc.thePlayer.stepHeight = 0.5F; + mc.player.stepHeight = 0.5F; } } - if(Mekanism.flamethrowerActive.contains(mc.thePlayer.getName()) != isFlamethrowerOn(mc.thePlayer)) + if(Mekanism.flamethrowerActive.contains(mc.player.getName()) != isFlamethrowerOn(mc.player)) { - if(isFlamethrowerOn(mc.thePlayer)) + if(isFlamethrowerOn(mc.player)) { - Mekanism.flamethrowerActive.add(mc.thePlayer.getName()); + Mekanism.flamethrowerActive.add(mc.player.getName()); } else { - Mekanism.flamethrowerActive.remove(mc.thePlayer.getName()); + Mekanism.flamethrowerActive.remove(mc.player.getName()); } - Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(PacketFlamethrowerData.FlamethrowerPacket.UPDATE, null, mc.thePlayer.getName(), isFlamethrowerOn(mc.thePlayer))); + Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(PacketFlamethrowerData.FlamethrowerPacket.UPDATE, null, mc.player.getName(), isFlamethrowerOn(mc.player))); } - if(Mekanism.jetpackOn.contains(mc.thePlayer.getName()) != isJetpackOn(mc.thePlayer)) + if(Mekanism.jetpackOn.contains(mc.player.getName()) != isJetpackOn(mc.player)) { - if(isJetpackOn(mc.thePlayer)) + if(isJetpackOn(mc.player)) { - Mekanism.jetpackOn.add(mc.thePlayer.getName()); + Mekanism.jetpackOn.add(mc.player.getName()); } else { - Mekanism.jetpackOn.remove(mc.thePlayer.getName()); + Mekanism.jetpackOn.remove(mc.player.getName()); } - Mekanism.packetHandler.sendToServer(new JetpackDataMessage(JetpackPacket.UPDATE, mc.thePlayer.getName(), isJetpackOn(mc.thePlayer))); + Mekanism.packetHandler.sendToServer(new JetpackDataMessage(JetpackPacket.UPDATE, mc.player.getName(), isJetpackOn(mc.player))); } - if(Mekanism.gasmaskOn.contains(mc.thePlayer.getName()) != isGasMaskOn(mc.thePlayer)) + if(Mekanism.gasmaskOn.contains(mc.player.getName()) != isGasMaskOn(mc.player)) { - if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null) + if(isGasMaskOn(mc.player) && mc.currentScreen == null) { - Mekanism.gasmaskOn.add(mc.thePlayer.getName()); + Mekanism.gasmaskOn.add(mc.player.getName()); } else { - Mekanism.gasmaskOn.remove(mc.thePlayer.getName()); + Mekanism.gasmaskOn.remove(mc.player.getName()); } - Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage(ScubaTankPacket.UPDATE, mc.thePlayer.getName(), isGasMaskOn(mc.thePlayer))); + Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage(ScubaTankPacket.UPDATE, mc.player.getName(), isGasMaskOn(mc.player))); } if(client.enablePlayerSounds) { for(String username : Mekanism.jetpackOn) { - EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); + EntityPlayer player = mc.world.getPlayerEntityByName(username); if(player != null) { @@ -274,7 +274,7 @@ public class ClientTickHandler for(String username : Mekanism.gasmaskOn) { - EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); + EntityPlayer player = mc.world.getPlayerEntityByName(username); if(player != null) { @@ -287,7 +287,7 @@ public class ClientTickHandler } } - for(EntityPlayer player : (List)mc.theWorld.playerEntities) + for(EntityPlayer player : (List)mc.world.playerEntities) { if(hasFlamethrower(player)) { @@ -301,7 +301,7 @@ public class ClientTickHandler } } - ItemStack chestStack = mc.thePlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + ItemStack chestStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); if(chestStack != null && chestStack.getItem() instanceof ItemJetpack) { @@ -309,84 +309,84 @@ public class ClientTickHandler MekanismClient.updateKey(mc.gameSettings.keyBindSneak, KeySync.DESCEND); } - if(isFlamethrowerOn(mc.thePlayer)) + if(isFlamethrowerOn(mc.player)) { - ItemFlamethrower flamethrower = (ItemFlamethrower)mc.thePlayer.inventory.getCurrentItem().getItem(); + ItemFlamethrower flamethrower = (ItemFlamethrower)mc.player.inventory.getCurrentItem().getItem(); - if(!mc.thePlayer.capabilities.isCreativeMode) + if(!mc.player.capabilities.isCreativeMode) { - flamethrower.useGas(mc.thePlayer.inventory.getCurrentItem()); + flamethrower.useGas(mc.player.inventory.getCurrentItem()); } } - if(isJetpackOn(mc.thePlayer)) + if(isJetpackOn(mc.player)) { ItemJetpack jetpack = (ItemJetpack)chestStack.getItem(); if(jetpack.getMode(chestStack) == JetpackMode.NORMAL) { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D); - mc.thePlayer.fallDistance = 0.0F; + mc.player.motionY = Math.min(mc.player.motionY + 0.15D, 0.5D); + mc.player.fallDistance = 0.0F; } else if(jetpack.getMode(chestStack) == JetpackMode.HOVER) { if((!mc.gameSettings.keyBindJump.isKeyDown() && !mc.gameSettings.keyBindSneak.isKeyDown()) || (mc.gameSettings.keyBindJump.isKeyDown() && mc.gameSettings.keyBindSneak.isKeyDown()) || mc.currentScreen != null) { - if(mc.thePlayer.motionY > 0) + if(mc.player.motionY > 0) { - mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, 0); + mc.player.motionY = Math.max(mc.player.motionY - 0.15D, 0); } - else if(mc.thePlayer.motionY < 0) + else if(mc.player.motionY < 0) { - if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) + if(!CommonPlayerTickHandler.isOnGround(mc.player)) { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0); + mc.player.motionY = Math.min(mc.player.motionY + 0.15D, 0); } } } else { if(mc.gameSettings.keyBindJump.isKeyDown() && mc.currentScreen == null) { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D); + mc.player.motionY = Math.min(mc.player.motionY + 0.15D, 0.2D); } else if(mc.gameSettings.keyBindSneak.isKeyDown() && mc.currentScreen == null) { - if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) + if(!CommonPlayerTickHandler.isOnGround(mc.player)) { - mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D); + mc.player.motionY = Math.max(mc.player.motionY - 0.15D, -0.2D); } } } - mc.thePlayer.fallDistance = 0.0F; + mc.player.fallDistance = 0.0F; } jetpack.useGas(chestStack); } - if(isGasMaskOn(mc.thePlayer)) + if(isGasMaskOn(mc.player)) { ItemScubaTank tank = (ItemScubaTank)chestStack.getItem(); final int max = 300; tank.useGas(chestStack); - GasStack received = tank.useGas(chestStack, max-mc.thePlayer.getAir()); + GasStack received = tank.useGas(chestStack, max-mc.player.getAir()); if(received != null) { - mc.thePlayer.setAir(mc.thePlayer.getAir()+received.amount); + mc.player.setAir(mc.player.getAir()+received.amount); } - if(mc.thePlayer.getAir() == max) + if(mc.player.getAir() == max) { - for(Object obj : mc.thePlayer.getActivePotionEffects()) + for(Object obj : mc.player.getActivePotionEffects()) { if(obj instanceof PotionEffect) { for(int i = 0; i < 9; i++) { - ((PotionEffect)obj).onUpdate(mc.thePlayer); + ((PotionEffect)obj).onUpdate(mc.player); } } } @@ -423,12 +423,12 @@ public class ClientTickHandler public static boolean isJetpackOn(EntityPlayer player) { - if(player != mc.thePlayer) + if(player != mc.player) { return Mekanism.jetpackOn.contains(player.getName()); } - ItemStack stack = player.inventory.armorInventory[2]; + ItemStack stack = player.inventory.armorInventory.get(2); if(stack != null && !player.capabilities.isCreativeMode) { @@ -464,13 +464,13 @@ public class ClientTickHandler public static boolean isGasMaskOn(EntityPlayer player) { - if(player != mc.thePlayer) + if(player != mc.player) { return Mekanism.gasmaskOn.contains(player.getName()); } - ItemStack tank = player.inventory.armorInventory[2]; - ItemStack mask = player.inventory.armorInventory[3]; + ItemStack tank = player.inventory.armorInventory.get(2); + ItemStack mask = player.inventory.armorInventory.get(3); if(tank != null && mask != null) { @@ -493,7 +493,7 @@ public class ClientTickHandler public static boolean isFlamethrowerOn(EntityPlayer player) { - if(player != mc.thePlayer) + if(player != mc.player) { return Mekanism.flamethrowerActive.contains(player.getName()); } diff --git a/src/main/java/mekanism/client/HolidayManager.java b/src/main/java/mekanism/client/HolidayManager.java index bb36b594f..fceffc0d4 100644 --- a/src/main/java/mekanism/client/HolidayManager.java +++ b/src/main/java/mekanism/client/HolidayManager.java @@ -42,7 +42,7 @@ public final class HolidayManager { if(holiday.getDate().equals(date)) { - holiday.onEvent(mc.thePlayer); + holiday.onEvent(mc.player); holidaysNotified.add(holiday); } } @@ -103,13 +103,13 @@ public final class HolidayManager public void onEvent(EntityPlayer player) { String themedLines = getThemedLines(new EnumColor[] {EnumColor.DARK_GREEN, EnumColor.DARK_RED}, 13); - player.addChatMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); - player.addChatMessage(new TextComponentString(EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); - player.addChatMessage(new TextComponentString(EnumColor.RED + "May you have plenty of Christmas cheer")); - player.addChatMessage(new TextComponentString(EnumColor.RED + "and have a relaxing holiday with your")); - player.addChatMessage(new TextComponentString(EnumColor.RED + "family :)")); - player.addChatMessage(new TextComponentString(EnumColor.DARK_GREY + "-aidancbrady")); - player.addChatMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); + player.sendMessage(new TextComponentString(EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); + player.sendMessage(new TextComponentString(EnumColor.RED + "May you have plenty of Christmas cheer")); + player.sendMessage(new TextComponentString(EnumColor.RED + "and have a relaxing holiday with your")); + player.sendMessage(new TextComponentString(EnumColor.RED + "family :)")); + player.sendMessage(new TextComponentString(EnumColor.DARK_GREY + "-aidancbrady")); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } @Override @@ -152,12 +152,12 @@ public final class HolidayManager public void onEvent(EntityPlayer player) { String themedLines = getThemedLines(new EnumColor[] {EnumColor.WHITE, EnumColor.YELLOW}, 13); - player.addChatMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); - player.addChatMessage(new TextComponentString(EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); - player.addChatMessage(new TextComponentString(EnumColor.AQUA + "Best wishes to you as we enter this")); - player.addChatMessage(new TextComponentString(EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + "! :)")); - player.addChatMessage(new TextComponentString(EnumColor.DARK_GREY + "-aidancbrady")); - player.addChatMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); + player.sendMessage(new TextComponentString(EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + player.getName() + EnumColor.RED + "!")); + player.sendMessage(new TextComponentString(EnumColor.AQUA + "Best wishes to you as we enter this")); + player.sendMessage(new TextComponentString(EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + "! :)")); + player.sendMessage(new TextComponentString(EnumColor.DARK_GREY + "-aidancbrady")); + player.sendMessage(new TextComponentString(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); } } diff --git a/src/main/java/mekanism/client/MekanismClient.java b/src/main/java/mekanism/client/MekanismClient.java index 2ed8f26db..be1cf7c34 100644 --- a/src/main/java/mekanism/client/MekanismClient.java +++ b/src/main/java/mekanism/client/MekanismClient.java @@ -30,10 +30,10 @@ public class MekanismClient extends Mekanism { boolean down = Minecraft.getMinecraft().currentScreen == null && key.isPressed(); - if(down != keyMap.has(Minecraft.getMinecraft().thePlayer, type)) + if(down != keyMap.has(Minecraft.getMinecraft().player, type)) { Mekanism.packetHandler.sendToServer(new KeyMessage(type, down)); - keyMap.update(Minecraft.getMinecraft().thePlayer, type, down); + keyMap.update(Minecraft.getMinecraft().player, type, down); } } diff --git a/src/main/java/mekanism/client/MekanismKeyHandler.java b/src/main/java/mekanism/client/MekanismKeyHandler.java index 6527c1e13..906eb3c35 100644 --- a/src/main/java/mekanism/client/MekanismKeyHandler.java +++ b/src/main/java/mekanism/client/MekanismKeyHandler.java @@ -75,7 +75,7 @@ public class MekanismKeyHandler extends MekKeyHandler { if(kb == modeSwitchKey) { - EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; + EntityPlayer player = FMLClientHandler.instance().getClient().player; ItemStack toolStack = player.inventory.getCurrentItem(); Item item = StackUtils.getItem(toolStack); @@ -87,7 +87,7 @@ public class MekanismKeyHandler extends MekKeyHandler int toSet = configurator.getState(toolStack).ordinal() < ConfiguratorMode.values().length-1 ? configurator.getState(toolStack).ordinal() + 1 : 0; configurator.setState(toolStack, ConfiguratorMode.values()[toSet]); Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(EnumHand.MAIN_HAND, configurator.getState(toolStack))); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configureState") + ": " + configurator.getColor(configurator.getState(toolStack)) + configurator.getStateDisplay(configurator.getState(toolStack)))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configureState") + ": " + configurator.getColor(configurator.getState(toolStack)) + configurator.getStateDisplay(configurator.getState(toolStack)))); } else if(player.isSneaking() && item instanceof ItemElectricBow) { @@ -95,7 +95,7 @@ public class MekanismKeyHandler extends MekKeyHandler bow.setFireState(toolStack, !bow.getFireState(toolStack)); Mekanism.packetHandler.sendToServer(new ElectricBowStateMessage(EnumHand.MAIN_HAND, bow.getFireState(toolStack))); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.fireMode") + ": " + (bow.getFireState(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(bow.getFireState(toolStack)))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.fireMode") + ": " + (bow.getFireState(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(bow.getFireState(toolStack)))); } else if(player.isSneaking() && item instanceof ItemBlockMachine) { @@ -105,7 +105,7 @@ public class MekanismKeyHandler extends MekKeyHandler { machine.setBucketMode(toolStack, !machine.getBucketMode(toolStack)); Mekanism.packetHandler.sendToServer(new PortableTankStateMessage(EnumHand.MAIN_HAND, machine.getBucketMode(toolStack))); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + (machine.getBucketMode(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(machine.getBucketMode(toolStack)))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + (machine.getBucketMode(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(machine.getBucketMode(toolStack)))); } } else if(player.isSneaking() && item instanceof ItemWalkieTalkie) @@ -126,12 +126,12 @@ public class MekanismKeyHandler extends MekKeyHandler flamethrower.incrementMode(toolStack); Mekanism.packetHandler.sendToServer(new PacketFlamethrowerData.FlamethrowerDataMessage(PacketFlamethrowerData.FlamethrowerPacket.MODE, EnumHand.MAIN_HAND, null, false)); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.flamethrower.modeBump") + ": " + flamethrower.getMode(toolStack).getName())); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.flamethrower.modeBump") + ": " + flamethrower.getMode(toolStack).getName())); } } else if(kb == armorModeSwitchKey) { - EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; + EntityPlayer player = FMLClientHandler.instance().getClient().player; ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); Item chestItem = StackUtils.getItem(chestStack); diff --git a/src/main/java/mekanism/client/gui/GuiDictionary.java b/src/main/java/mekanism/client/gui/GuiDictionary.java index d7ced029f..0052915c2 100644 --- a/src/main/java/mekanism/client/gui/GuiDictionary.java +++ b/src/main/java/mekanism/client/gui/GuiDictionary.java @@ -121,7 +121,7 @@ public class GuiDictionary extends GuiMekanism if(stack != null) { itemType = stack.copy(); - itemType.stackSize = 1; + itemType.setCount(1); scrollList.setText(MekanismUtils.getOreDictName(itemType)); SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); @@ -133,12 +133,12 @@ public class GuiDictionary extends GuiMekanism if(xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { itemType = stack.copy(); - itemType.stackSize = 1; + itemType.setCount(1); scrollList.setText(MekanismUtils.getOreDictName(itemType)); } diff --git a/src/main/java/mekanism/client/gui/GuiFactory.java b/src/main/java/mekanism/client/gui/GuiFactory.java index 0c7ac8c49..7acc136ea 100644 --- a/src/main/java/mekanism/client/gui/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/GuiFactory.java @@ -168,7 +168,7 @@ public class GuiFactory extends GuiMekanism if(xAxis > 8 && xAxis < 168 && yAxis > 78 && yAxis < 83) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && stack.getItem() instanceof ItemGaugeDropper) { diff --git a/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java b/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java index 8d88ce143..4be9bd802 100644 --- a/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java +++ b/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java @@ -206,11 +206,11 @@ public class GuiFormulaicAssemblicator extends GuiMekanism if(slot.getStack() == null || !slot.getStack().isItemEqual(stack)) { - drawGradientRect(guiWidth + slot.xDisplayPosition, guiHeight + slot.yDisplayPosition, guiWidth + slot.xDisplayPosition + 16, guiHeight + slot.yDisplayPosition + 16, -2137456640, -2137456640); + drawGradientRect(guiWidth + slot.xPos, guiHeight + slot.yPos, guiWidth + slot.xPos + 16, guiHeight + slot.yPos + 16, -2137456640, -2137456640); } RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemAndEffectIntoGUI(stack, guiWidth + slot.xDisplayPosition, guiHeight + slot.yDisplayPosition); + itemRender.renderItemAndEffectIntoGUI(stack, guiWidth + slot.xPos, guiHeight + slot.yPos); MekanismRenderer.resetColor(); GlStateManager.popMatrix(); } diff --git a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java index 81ae3c518..1e2dcc17e 100644 --- a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java @@ -275,7 +275,7 @@ public class GuiMItemStackFilter extends GuiMekanism if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { @@ -284,7 +284,7 @@ public class GuiMItemStackFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { filter.itemType = stack.copy(); - filter.itemType.stackSize = 1; + filter.itemType.setCount(1); } } } @@ -299,7 +299,7 @@ public class GuiMItemStackFilter extends GuiMekanism if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); ItemStack toUse = null; if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) @@ -309,7 +309,7 @@ public class GuiMItemStackFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { toUse = stack.copy(); - toUse.stackSize = 1; + toUse.setCount(1); } } } diff --git a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java index 10c155e57..7119c29d7 100644 --- a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java @@ -257,7 +257,7 @@ public class GuiMMaterialFilter extends GuiMekanism if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { @@ -266,7 +266,7 @@ public class GuiMMaterialFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { filter.materialItem = stack.copy(); - filter.materialItem.stackSize = 1; + filter.materialItem.setCount(1); } } } @@ -281,7 +281,7 @@ public class GuiMMaterialFilter extends GuiMekanism if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); ItemStack toUse = null; if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) @@ -291,7 +291,7 @@ public class GuiMMaterialFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { toUse = stack.copy(); - toUse.stackSize = 1; + toUse.setCount(1); } } } diff --git a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java index b7cd628e9..755e9b5cd 100644 --- a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java @@ -327,7 +327,7 @@ public class GuiMModIDFilter extends GuiMekanism if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); ItemStack toUse = null; if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) @@ -337,7 +337,7 @@ public class GuiMModIDFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { toUse = stack.copy(); - toUse.stackSize = 1; + toUse.setCount(1); } } } diff --git a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java index 6fb610f7d..7674dda7f 100644 --- a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java @@ -327,7 +327,7 @@ public class GuiMOreDictFilter extends GuiMekanism if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); ItemStack toUse = null; if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) @@ -337,7 +337,7 @@ public class GuiMOreDictFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { toUse = stack.copy(); - toUse.stackSize = 1; + toUse.setCount(1); } } } diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index e6cc6b8f1..c8474db08 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -116,7 +116,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper } } - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && stack.getItem() instanceof ItemConfigurator && hovering != null) { @@ -158,7 +158,7 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper protected boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) { - return isPointInRegion(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY); + return isPointInRegion(slot.xPos, slot.yPos, 16, 16, mouseX, mouseY); } @Override diff --git a/src/main/java/mekanism/client/gui/GuiRobitCrafting.java b/src/main/java/mekanism/client/gui/GuiRobitCrafting.java index 9b526cc70..a3cffeb13 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitCrafting.java +++ b/src/main/java/mekanism/client/gui/GuiRobitCrafting.java @@ -108,7 +108,7 @@ public class GuiRobitCrafting extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 21, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { @@ -118,19 +118,19 @@ public class GuiRobitCrafting extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 23, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 24, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 25, mc.world, robit.getEntityId(), 0, 0); } } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitInventory.java b/src/main/java/mekanism/client/gui/GuiRobitInventory.java index 8ba3cf020..7088f4cc6 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitInventory.java +++ b/src/main/java/mekanism/client/gui/GuiRobitInventory.java @@ -108,13 +108,13 @@ public class GuiRobitInventory extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 21, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 22, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { @@ -124,13 +124,13 @@ public class GuiRobitInventory extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 24, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 25, mc.world, robit.getEntityId(), 0, 0); } } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitMain.java b/src/main/java/mekanism/client/gui/GuiRobitMain.java index 04b251356..8f7086a6e 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitMain.java +++ b/src/main/java/mekanism/client/gui/GuiRobitMain.java @@ -95,7 +95,7 @@ public class GuiRobitMain extends GuiMekanism } else if(i == Keyboard.KEY_ESCAPE) { - mc.thePlayer.closeScreen(); + mc.player.closeScreen(); } nameChangeField.textboxKeyTyped(c, i); @@ -275,25 +275,25 @@ public class GuiRobitMain extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 22, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 23, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 24, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 25, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { diff --git a/src/main/java/mekanism/client/gui/GuiRobitRepair.java b/src/main/java/mekanism/client/gui/GuiRobitRepair.java index 3eaf1ce89..c5b3a9a91 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitRepair.java +++ b/src/main/java/mekanism/client/gui/GuiRobitRepair.java @@ -3,7 +3,6 @@ package mekanism.client.gui; import io.netty.buffer.Unpooled; import java.io.IOException; -import java.util.List; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; @@ -24,6 +23,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.client.CPacketCustomPayload; +import net.minecraft.util.NonNullList; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -86,7 +86,7 @@ public class GuiRobitRepair extends GuiMekanism implements IContainerListener boolean flag = true; String s = I18n.translateToLocalFormatted("container.repair.cost", repairContainer.maximumCost); - if(repairContainer.maximumCost >= 40 && !mc.thePlayer.capabilities.isCreativeMode) + if(repairContainer.maximumCost >= 40 && !mc.player.capabilities.isCreativeMode) { s = LangUtils.localize("container.repair.expensive"); k = 16736352; @@ -132,7 +132,7 @@ public class GuiRobitRepair extends GuiMekanism implements IContainerListener if(itemNameField.textboxKeyTyped(c, i)) { repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(itemNameField.getText()))); + mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(itemNameField.getText()))); } else { super.keyTyped(c, i); @@ -155,25 +155,25 @@ public class GuiRobitRepair extends GuiMekanism implements IContainerListener { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 21, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 22, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 23, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 24, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { @@ -254,7 +254,7 @@ public class GuiRobitRepair extends GuiMekanism implements IContainerListener } @Override - public void updateCraftingInventory(Container container, List list) + public void updateCraftingInventory(Container container, NonNullList list) { sendSlotContents(container, 0, container.getSlot(0).getStack()); } @@ -270,7 +270,7 @@ public class GuiRobitRepair extends GuiMekanism implements IContainerListener if(itemstack != null) { repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(itemNameField.getText()))); + mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(itemNameField.getText()))); } } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitSmelting.java b/src/main/java/mekanism/client/gui/GuiRobitSmelting.java index f72be0621..c27d63342 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitSmelting.java +++ b/src/main/java/mekanism/client/gui/GuiRobitSmelting.java @@ -116,19 +116,19 @@ public class GuiRobitSmelting extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 21, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 22, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 23, mc.world, robit.getEntityId(), 0, 0); } else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { @@ -138,7 +138,7 @@ public class GuiRobitSmelting extends GuiMekanism { SoundHandler.playSound(SoundEvents.UI_BUTTON_CLICK); Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); + mc.player.openGui(Mekanism.instance, 25, mc.world, robit.getEntityId(), 0, 0); } } } diff --git a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java index 045de868d..79eaae575 100644 --- a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java +++ b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java @@ -146,7 +146,7 @@ public class GuiSecurityDesk extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - if(tileEntity.frequency != null && tileEntity.owner != null && tileEntity.owner.equals(mc.thePlayer.getName())) + if(tileEntity.frequency != null && tileEntity.owner != null && tileEntity.owner.equals(mc.player.getName())) { if(xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) { @@ -309,7 +309,7 @@ public class GuiSecurityDesk extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - if(tileEntity.frequency != null && tileEntity.owner != null && mc.thePlayer.getName().equals(tileEntity.owner)) + if(tileEntity.frequency != null && tileEntity.owner != null && mc.player.getName().equals(tileEntity.owner)) { drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize + (tileEntity.frequency.override ? 0 : 6), 22, 6, 6); diff --git a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java index 0a9677eda..484f66335 100644 --- a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java +++ b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java @@ -210,7 +210,7 @@ public class GuiSideConfiguration extends GuiMekanism TileEntity tile = (TileEntity)configurable; - if(tile == null || mc.theWorld.getTileEntity(tile.getPos()) == null) + if(tile == null || mc.world.getTileEntity(tile.getPos()) == null) { mc.displayGuiScreen(null); } diff --git a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java index c53ea7733..cb25e9ca4 100644 --- a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java @@ -310,12 +310,12 @@ public class GuiTItemStackFilter extends GuiMekanism if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { filter.itemType = stack.copy(); - filter.itemType.stackSize = 1; + filter.itemType.setCount(1); } else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { diff --git a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java index c6c8323f4..6f0987f72 100644 --- a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java @@ -241,7 +241,7 @@ public class GuiTMaterialFilter extends GuiMekanism if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { @@ -250,7 +250,7 @@ public class GuiTMaterialFilter extends GuiMekanism if(Block.getBlockFromItem(stack.getItem()) != Blocks.BEDROCK) { filter.materialItem = stack.copy(); - filter.materialItem.stackSize = 1; + filter.materialItem.setCount(1); } } } diff --git a/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java b/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java index 10ac5c1d8..531c09f1e 100644 --- a/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java @@ -63,7 +63,7 @@ public class GuiFluidGauge extends GuiGauge { if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(guiObj instanceof GuiMekanism && stack != null && stack.getItem() instanceof ItemGaugeDropper) { diff --git a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java index c7eed7461..3a0ff9768 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java @@ -50,7 +50,7 @@ public class GuiGasGauge extends GuiGauge { if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(guiObj instanceof GuiMekanism && stack != null && stack.getItem() instanceof ItemGaugeDropper) { diff --git a/src/main/java/mekanism/client/gui/element/GuiGauge.java b/src/main/java/mekanism/client/gui/element/GuiGauge.java index 4baa040c2..042fcd5c0 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGauge.java @@ -131,7 +131,7 @@ public abstract class GuiGauge extends GuiElement { if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack stack = mc.player.inventory.getItemStack(); if(stack != null && stack.getItem() instanceof ItemConfigurator && color != null) { diff --git a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java index f650a52a1..ddbe25dc6 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java @@ -72,7 +72,7 @@ public class GuiSecurityTab extends GuiElement int renderX = 26 + (18*mode.ordinal()); - if(getOwner() != null && getOwner().equals(mc.thePlayer.getName()) && + if(getOwner() != null && getOwner().equals(mc.player.getName()) && (data == null || !data.override)) { if(xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) @@ -99,7 +99,7 @@ public class GuiSecurityTab extends GuiElement { String securityDisplay = isItem ? SecurityUtils.getSecurityDisplay(getItem(), Side.CLIENT) : SecurityUtils.getSecurityDisplay(tileEntity, Side.CLIENT); String securityText = EnumColor.GREY + LangUtils.localize("gui.security") + ": " + securityDisplay; - String ownerText = SecurityUtils.getOwnerDisplay(mc.thePlayer.getName(), getOwner()); + String ownerText = SecurityUtils.getOwnerDisplay(mc.player.getName(), getOwner()); String overrideText = EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"; if(isItem ? SecurityUtils.isOverridden(getItem(), Side.CLIENT) : SecurityUtils.isOverridden(tileEntity, Side.CLIENT)) @@ -120,7 +120,7 @@ public class GuiSecurityTab extends GuiElement { if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { - mc.thePlayer.closeScreen(); + mc.player.closeScreen(); return null; } @@ -140,7 +140,7 @@ public class GuiSecurityTab extends GuiElement { if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { - mc.thePlayer.closeScreen(); + mc.player.closeScreen(); return SecurityMode.PUBLIC; } @@ -157,7 +157,7 @@ public class GuiSecurityTab extends GuiElement { if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { - mc.thePlayer.closeScreen(); + mc.player.closeScreen(); return null; } @@ -170,7 +170,7 @@ public class GuiSecurityTab extends GuiElement private ItemStack getItem() { - return mc.thePlayer.getHeldItem(currentHand); + return mc.player.getHeldItem(currentHand); } @Override @@ -181,7 +181,7 @@ public class GuiSecurityTab extends GuiElement { if(button == 0 && general.allowProtection) { - if(getOwner() != null && mc.thePlayer.getName().equals(getOwner())) + if(getOwner() != null && mc.player.getName().equals(getOwner())) { if(xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) { diff --git a/src/main/java/mekanism/client/jei/BaseRecipeCategory.java b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java index ebf8eb421..a73b99f35 100644 --- a/src/main/java/mekanism/client/jei/BaseRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/BaseRecipeCategory.java @@ -11,6 +11,7 @@ import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.FluidType; import mekanism.common.util.LangUtils; +import mezz.jei.api.gui.IDrawable; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -72,9 +73,6 @@ public abstract class BaseRecipeCategory implements IRecipeCategory, IGuiWrapper e.renderBackground(0, 0, -xOffset, -yOffset); } } - - @Override - public void drawAnimations(Minecraft minecraft) {} @Override public void drawTexturedRect(int x, int y, int u, int v, int w, int h) @@ -172,4 +170,16 @@ public abstract class BaseRecipeCategory implements IRecipeCategory, IGuiWrapper public void addGuiElements() {} public static class GuiDummy extends Gui {} + + @Override + public IDrawable getIcon() + { + return null; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + return null; + } } diff --git a/src/main/java/mekanism/client/jei/GuiElementHandler.java b/src/main/java/mekanism/client/jei/GuiElementHandler.java index b6e1bb9ed..8b260b442 100644 --- a/src/main/java/mekanism/client/jei/GuiElementHandler.java +++ b/src/main/java/mekanism/client/jei/GuiElementHandler.java @@ -36,4 +36,10 @@ public class GuiElementHandler implements IAdvancedGuiHandler return null; } + + @Override + public Object getIngredientUnderMouse(GuiContainer guiContainer, int mouseX, int mouseY) + { + return null; + } } diff --git a/src/main/java/mekanism/client/jei/MekanismJEI.java b/src/main/java/mekanism/client/jei/MekanismJEI.java index 62fd80d55..e3066f852 100644 --- a/src/main/java/mekanism/client/jei/MekanismJEI.java +++ b/src/main/java/mekanism/client/jei/MekanismJEI.java @@ -104,10 +104,9 @@ import mekanism.common.recipe.machines.SeparatorRecipe; import mekanism.common.recipe.machines.SolarNeutronRecipe; import mekanism.common.recipe.machines.ThermalEvaporationRecipe; import mekanism.common.recipe.machines.WasherRecipe; -import mekanism.common.util.ItemDataUtils; -import mezz.jei.api.IJeiRuntime; -import mezz.jei.api.IModPlugin; +import mezz.jei.api.BlankModPlugin; import mezz.jei.api.IModRegistry; +import mezz.jei.api.ISubtypeRegistry; import mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter; import mezz.jei.api.JEIPlugin; import mezz.jei.api.recipe.IRecipeCategory; @@ -116,7 +115,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @JEIPlugin -public class MekanismJEI implements IModPlugin +public class MekanismJEI extends BlankModPlugin { public static ISubtypeInterpreter NBT_INTERPRETER = new ISubtypeInterpreter() { @Override @@ -138,25 +137,29 @@ public class MekanismJEI implements IModPlugin } }; + @Override + public void registerItemSubtypes(ISubtypeRegistry registry) + { + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.EnergyCube), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.GasTank), NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(MekanismBlocks.CardboardBox), NBT_INTERPRETER); + } + @Override public void register(IModRegistry registry) { registry.addAdvancedGuiHandlers(new GuiElementHandler()); - registry.addRecipeHandlers(new ShapedMekanismRecipeHandler()); - registry.addRecipeHandlers(new ShapelessMekanismRecipeHandler()); + registry.addRecipeHandlers(new ShapedMekanismRecipeHandler(registry.getJeiHelpers())); + registry.addRecipeHandlers(new ShapelessMekanismRecipeHandler(registry.getJeiHelpers())); - registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismItems.ItemProxy)); - registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismBlocks.BoundingBlock)); - - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.EnergyCube), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.GasTank), NBT_INTERPRETER); - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(MekanismBlocks.CardboardBox), NBT_INTERPRETER); + registry.getJeiHelpers().getIngredientBlacklist().addIngredientToBlacklist(new ItemStack(MekanismItems.ItemProxy)); + registry.getJeiHelpers().getIngredientBlacklist().addIngredientToBlacklist(new ItemStack(MekanismBlocks.BoundingBlock)); try { registerBasicMachine(registry, Recipe.ENRICHMENT_CHAMBER, "tile.MachineBlock.EnrichmentChamber.name", ProgressBar.BLUE, EnrichmentRecipeHandler.class, EnrichmentRecipeWrapper.class); @@ -329,7 +332,4 @@ public class MekanismJEI implements IModPlugin registry.addRecipes(recipes); } - - @Override - public void onRuntimeAvailable(IJeiRuntime runtime) {} } diff --git a/src/main/java/mekanism/client/jei/crafting/ShapedMekanismRecipeHandler.java b/src/main/java/mekanism/client/jei/crafting/ShapedMekanismRecipeHandler.java index ce3918257..e00fa6099 100644 --- a/src/main/java/mekanism/client/jei/crafting/ShapedMekanismRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/crafting/ShapedMekanismRecipeHandler.java @@ -1,18 +1,20 @@ package mekanism.client.jei.crafting; import mekanism.common.recipe.ShapedMekanismRecipe; +import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeHandler; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; public class ShapedMekanismRecipeHandler implements IRecipeHandler { - @Override - public String getRecipeCategoryUid() + private final IJeiHelpers jeiHelpers; + + public ShapedMekanismRecipeHandler(IJeiHelpers helpers) { - return VanillaRecipeCategoryUid.CRAFTING; + jeiHelpers = helpers; } - + @Override public Class getRecipeClass() { @@ -22,7 +24,7 @@ public class ShapedMekanismRecipeHandler implements IRecipeHandler getOutputs() - { - return Collections.singletonList(recipe.getRecipeOutput()); + try { + List> inputs = stackHelper.expandRecipeItemStackInputs(Arrays.asList(recipe.getInput())); + ingredients.setInputLists(ItemStack.class, inputs); + ingredients.setOutput(ItemStack.class, recipeOutput); + } catch (RuntimeException e) { + String info = ErrorUtil.getInfoFromBrokenCraftingRecipe(recipe, Arrays.asList(recipe.getInput()), recipeOutput); + throw new BrokenCraftingRecipeException(info, e); + } } @Override diff --git a/src/main/java/mekanism/client/jei/crafting/ShapelessMekanismRecipeHandler.java b/src/main/java/mekanism/client/jei/crafting/ShapelessMekanismRecipeHandler.java index bd1f4692a..e89c19be7 100644 --- a/src/main/java/mekanism/client/jei/crafting/ShapelessMekanismRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/crafting/ShapelessMekanismRecipeHandler.java @@ -3,12 +3,20 @@ package mekanism.client.jei.crafting; import javax.annotation.Nonnull; import mekanism.common.recipe.ShapelessMekanismRecipe; +import mezz.jei.api.IJeiHelpers; import mezz.jei.api.recipe.IRecipeHandler; import mezz.jei.api.recipe.IRecipeWrapper; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; public class ShapelessMekanismRecipeHandler implements IRecipeHandler { + private final IJeiHelpers jeiHelpers; + + public ShapelessMekanismRecipeHandler(IJeiHelpers helpers) + { + jeiHelpers = helpers; + } + @Override @Nonnull public Class getRecipeClass() @@ -16,18 +24,11 @@ public class ShapelessMekanismRecipeHandler implements IRecipeHandler getOutputs() - { - return Collections.singletonList(recipe.getRecipeOutput()); + try { + List> inputs = stackHelper.expandRecipeItemStackInputs(recipe.getInput()); + ingredients.setInputLists(ItemStack.class, inputs); + + if (recipeOutput != null) + { + ingredients.setOutput(ItemStack.class, recipeOutput); + } + } catch (RuntimeException e) { + String info = ErrorUtil.getInfoFromBrokenCraftingRecipe(recipe, recipe.getInput(), recipeOutput); + throw new BrokenCraftingRecipeException(info, e); + } } } diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java index 12ab12557..9dd516690 100644 --- a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeCategory.java @@ -1,5 +1,7 @@ package mekanism.client.jei.machine; +import java.util.List; + import mekanism.api.gas.GasStack; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; @@ -12,6 +14,7 @@ import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.jei.BaseRecipeCategory; import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mekanism.common.recipe.outputs.ItemStackOutput; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mezz.jei.api.IGuiHelper; @@ -19,6 +22,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -91,7 +95,7 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof AdvancedMachineRecipeWrapper) { @@ -106,8 +110,20 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory itemStacks.init(1, false, 87, 18); itemStacks.init(2, false, 27, 36); - itemStacks.setFromRecipe(0, recipeWrapper.getInputs()); - itemStacks.setFromRecipe(1, recipeWrapper.getOutputs()); + itemStacks.set(0, input.itemStack); + itemStacks.set(1, ((ItemStackOutput)tempRecipe.recipeOutput).output); itemStacks.set(2, ((AdvancedMachineRecipeWrapper)recipeWrapper).getFuelStacks(input.gasType)); } + + @Override + public IDrawable getIcon() + { + return null; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + return null; + } } diff --git a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeHandler.java index cc6a0e8c6..9213867f3 100644 --- a/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/AdvancedMachineRecipeHandler.java @@ -24,13 +24,6 @@ public class AdvancedMachineRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(((AdvancedMachineInput)recipe.getInput()).itemStack); - } - - @Nonnull - @Override - public List getOutputs() - { - return Arrays.asList(((ItemStackOutput)recipe.getOutput()).output); + ingredients.setInput(ItemStack.class, ((AdvancedMachineInput)recipe.getInput()).itemStack); + ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java index 3bf0f6948..7bbb1c91b 100644 --- a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeCategory.java @@ -1,5 +1,7 @@ package mekanism.client.jei.machine; +import java.util.List; + import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; import mekanism.client.gui.element.GuiProgress; @@ -9,6 +11,7 @@ import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.jei.BaseRecipeCategory; +import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.ChanceMachineRecipe; import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.common.util.MekanismUtils; @@ -18,6 +21,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.util.ResourceLocation; @@ -73,7 +77,7 @@ public class ChanceMachineRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChanceMachineRecipeWrapper) { @@ -86,13 +90,13 @@ public class ChanceMachineRecipeCategory extends BaseRecipeCategory itemStacks.init(1, false, 87, 18); itemStacks.init(2, false, 103, 18); - itemStacks.setFromRecipe(0, recipeWrapper.getInputs()); + itemStacks.set(0, ((ItemStackInput)tempRecipe.recipeInput).ingredient); ChanceOutput output = (ChanceOutput)tempRecipe.getOutput(); if(output.hasPrimary()) { - itemStacks.setFromRecipe(1, output.primaryOutput); + itemStacks.set(1, output.primaryOutput); } if(output.hasSecondary()) @@ -100,4 +104,16 @@ public class ChanceMachineRecipeCategory extends BaseRecipeCategory itemStacks.set(2, output.secondaryOutput); } } + + @Override + public IDrawable getIcon() + { + return null; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + return null; + } } diff --git a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeHandler.java index aeedbeaa6..157e024e6 100644 --- a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeHandler.java @@ -24,13 +24,6 @@ public class ChanceMachineRecipeHandler im return wrapperClass; } - @Nonnull - @Override - public String getRecipeCategoryUid() - { - return category.getUid(); - } - @Nonnull @Override public IRecipeWrapper getRecipeWrapper(@Nonnull T recipe) diff --git a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java index a32363c46..bffdd4f9f 100644 --- a/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/ChanceMachineRecipeWrapper.java @@ -5,9 +5,12 @@ import java.util.List; import javax.annotation.Nonnull; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.ChanceMachineRecipe; import mekanism.common.recipe.outputs.ChanceOutput; +import mekanism.common.recipe.outputs.ItemStackOutput; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -25,20 +28,12 @@ public class ChanceMachineRecipeWrapper extends BlankRecipeWrapper category = c; } - @Nonnull @Override - public List getInputs() - { - return Arrays.asList(((ItemStackInput)recipe.getInput()).ingredient); - } - - @Nonnull - @Override - public List getOutputs() + public void getIngredients(IIngredients ingredients) { ChanceOutput output = (ChanceOutput)recipe.getOutput(); - - return Arrays.asList(output.primaryOutput, output.secondaryOutput); + ingredients.setInput(ItemStack.class, ((AdvancedMachineInput)recipe.getInput()).itemStack); + ingredients.setOutputs(ItemStack.class, Arrays.asList(output.primaryOutput, output.secondaryOutput)); } @Override diff --git a/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java index 5b41c8194..8420d776b 100644 --- a/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/MachineRecipeCategory.java @@ -1,5 +1,7 @@ package mekanism.client.jei.machine; +import java.util.List; + import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; import mekanism.client.gui.element.GuiProgress; @@ -17,7 +19,9 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; public class MachineRecipeCategory extends BaseRecipeCategory @@ -72,7 +76,7 @@ public class MachineRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof MachineRecipeWrapper) { @@ -84,7 +88,18 @@ public class MachineRecipeCategory extends BaseRecipeCategory itemStacks.init(0, true, 27, 0); itemStacks.init(1, false, 87, 18); - itemStacks.setFromRecipe(0, recipeWrapper.getInputs()); - itemStacks.setFromRecipe(1, recipeWrapper.getOutputs()); + itemStacks.set(ingredients); + } + + @Override + public IDrawable getIcon() + { + return null; + } + + @Override + public List getTooltipStrings(int mouseX, int mouseY) + { + return null; } } diff --git a/src/main/java/mekanism/client/jei/machine/MachineRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/MachineRecipeHandler.java index 5788e452a..66e8de1d5 100644 --- a/src/main/java/mekanism/client/jei/machine/MachineRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/MachineRecipeHandler.java @@ -24,13 +24,6 @@ public class MachineRecipeHandler implements IRe return wrapperClass; } - @Nonnull - @Override - public String getRecipeCategoryUid() - { - return category.getUid(); - } - @Nonnull @Override public IRecipeWrapper getRecipeWrapper(@Nonnull T recipe) diff --git a/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java index 7cc872bdd..ed68fe334 100644 --- a/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/MachineRecipeWrapper.java @@ -1,13 +1,9 @@ package mekanism.client.jei.machine; -import java.util.Arrays; -import java.util.List; - -import javax.annotation.Nonnull; - -import mekanism.common.recipe.inputs.ItemStackInput; +import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.machines.BasicMachineRecipe; import mekanism.common.recipe.outputs.ItemStackOutput; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; @@ -23,17 +19,10 @@ public class MachineRecipeWrapper extends BlankRecipeWrapper category = c; } - @Nonnull @Override - public List getInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(((ItemStackInput)recipe.getInput()).ingredient); - } - - @Nonnull - @Override - public List getOutputs() - { - return Arrays.asList(((ItemStackOutput)recipe.getOutput()).output); + ingredients.setInput(ItemStack.class, ((AdvancedMachineInput)recipe.getInput()).itemStack); + ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output); } } diff --git a/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java index bb4acf946..11f4eea49 100644 --- a/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/advanced/OsmiumCompressorRecipeWrapper.java @@ -8,6 +8,7 @@ import mekanism.client.jei.machine.AdvancedMachineRecipeCategory; import mekanism.client.jei.machine.AdvancedMachineRecipeWrapper; import mekanism.common.MekanismItems; import mekanism.common.recipe.machines.AdvancedMachineRecipe; +import mezz.jei.api.ingredients.IIngredients; import net.minecraft.item.ItemStack; public class OsmiumCompressorRecipeWrapper extends AdvancedMachineRecipeWrapper diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java index 8b3749745..35e4de0ee 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeCategory.java @@ -8,6 +8,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -59,7 +60,7 @@ public class ChemicalCrystallizerRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChemicalCrystallizerRecipeWrapper) { diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeHandler.java index fd518981b..3b4c31cb4 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalCrystallizerRecipeHandler.java @@ -20,13 +20,6 @@ public class ChemicalCrystallizerRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return new ArrayList(); - } - - @Nonnull - @Override - public List getOutputs() - { - return Arrays.asList(recipe.getOutput().output); + ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java index dc9d631b0..7d9670aa4 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeCategory.java @@ -9,6 +9,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -62,7 +63,7 @@ public class ChemicalDissolutionChamberRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChemicalDissolutionChamberRecipeWrapper) { diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeHandler.java index f6a2346d3..3db319e83 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalDissolutionChamberRecipeHandler.java @@ -20,13 +20,6 @@ public class ChemicalDissolutionChamberRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(recipe.getInput().ingredient); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInput(GasStack.class, new GasStack(GasRegistry.getGas("sulfuricAcid"), 1000)); + ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java index acdc7cbc2..10efbef17 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeCategory.java @@ -6,6 +6,7 @@ import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -65,7 +66,7 @@ public class ChemicalInfuserRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChemicalInfuserRecipeWrapper) { diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeHandler.java index 48e24670e..8053a3588 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalInfuserRecipeHandler.java @@ -20,13 +20,6 @@ public class ChemicalInfuserRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return new ArrayList(); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInputs(GasStack.class, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas)); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java index 0f8bd2c81..26200d23a 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeCategory.java @@ -16,6 +16,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -82,7 +83,7 @@ public class ChemicalOxidizerRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChemicalOxidizerRecipeWrapper) { @@ -92,7 +93,6 @@ public class ChemicalOxidizerRecipeCategory extends BaseRecipeCategory IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); itemStacks.init(0, true, 25-xOffset, 35-yOffset); - itemStacks.set(0, tempRecipe.getInput().ingredient); } } diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeHandler.java index 726a8a452..12da4634b 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalOxidizerRecipeHandler.java @@ -20,13 +20,6 @@ public class ChemicalOxidizerRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(recipe.getInput().ingredient); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java index c7e895a9f..1e75c67e5 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeCategory.java @@ -10,6 +10,7 @@ import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -66,7 +67,7 @@ public class ChemicalWasherRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ChemicalWasherRecipeWrapper) { @@ -76,7 +77,7 @@ public class ChemicalWasherRecipeCategory extends BaseRecipeCategory IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); fluidStacks.init(0, true, 6-xOffset, 5-yOffset, 16, 58, 1000, false, fluidOverlay); - fluidStacks.set(0, recipeWrapper.getFluidInputs()); + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); fluidStacks.addTooltipCallback(new ITooltipCallback() { @Override diff --git a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeHandler.java index 022f904fe..a62c7817e 100644 --- a/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/chemical/ChemicalWasherRecipeHandler.java @@ -20,13 +20,6 @@ public class ChemicalWasherRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return new ArrayList(); - } - - @Nonnull - @Override - public List getFluidInputs() - { - return Arrays.asList(new FluidStack(FluidRegistry.WATER, 1000)); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInput(FluidStack.class, new FluidStack(FluidRegistry.WATER, 1000)); + ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java index a05358924..333d1b5cb 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeCategory.java @@ -1,5 +1,6 @@ package mekanism.client.jei.machine.other; +import java.util.ArrayList; import java.util.List; import mekanism.client.gui.element.GuiFluidGauge; @@ -23,6 +24,7 @@ import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -113,7 +115,7 @@ public class ElectrolyticSeparatorRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ElectrolyticSeparatorRecipeWrapper) { @@ -123,7 +125,7 @@ public class ElectrolyticSeparatorRecipeCategory extends BaseRecipeCategory IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); fluidStacks.init(0, true, 2, 2, 16, 58, tempRecipe.getInput().ingredient.amount, false, fluidOverlay); - fluidStacks.set(0, recipeWrapper.getFluidInputs()); + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); fluidStacks.addTooltipCallback(new ITooltipCallback() { @Override diff --git a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeHandler.java index 4f138e298..87e54cbbd 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/ElectrolyticSeparatorRecipeHandler.java @@ -20,13 +20,6 @@ public class ElectrolyticSeparatorRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return new ArrayList(); - } - - @Nonnull - @Override - public List getFluidInputs() - { - return Arrays.asList(recipe.getInput().ingredient); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInput(FluidStack.class, recipe.recipeInput.ingredient); + ingredients.setOutputs(GasStack.class, Arrays.asList(recipe.recipeOutput.leftGas, recipe.recipeOutput.rightGas)); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java index d85ccfca8..c72d378c4 100644 --- a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeCategory.java @@ -25,6 +25,7 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; @@ -110,7 +111,7 @@ public class MetallurgicInfuserRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof MetallurgicInfuserRecipeWrapper) { @@ -124,7 +125,7 @@ public class MetallurgicInfuserRecipeCategory extends BaseRecipeCategory itemStacks.init(2, true, 11, 18); itemStacks.set(0, tempRecipe.getInput().inputStack); - itemStacks.setFromRecipe(1, recipeWrapper.getOutputs()); + itemStacks.set(1, tempRecipe.getOutput().output); itemStacks.set(2, getInfuseStacks(tempRecipe.getInput().infuse.type)); } } diff --git a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeHandler.java index d974c4780..ff3df9d31 100644 --- a/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/MetallurgicInfuserRecipeHandler.java @@ -20,13 +20,6 @@ public class MetallurgicInfuserRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - List list = new ArrayList(); - list.add(recipe.getInput().inputStack); - list.addAll(MetallurgicInfuserRecipeCategory.getInfuseStacks(recipe.getInput().infuse.type)); + List inputStacks = Arrays.asList(recipe.recipeInput.inputStack); + List infuseStacks = MetallurgicInfuserRecipeCategory.getInfuseStacks(recipe.getInput().infuse.type); - return list; - } - - @Nonnull - @Override - public List getOutputs() - { - return Arrays.asList(recipe.getOutput().output); + ingredients.setInput(ItemStack.class, recipe.recipeInput.inputStack); + ingredients.setInputLists(ItemStack.class, Arrays.asList(inputStacks, infuseStacks)); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.output); } } diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java index d41b2f99a..744b414ca 100644 --- a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeCategory.java @@ -24,6 +24,7 @@ import mezz.jei.api.gui.IGuiItemStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -111,7 +112,7 @@ public class PRCRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof PRCRecipeWrapper) { @@ -123,15 +124,14 @@ public class PRCRecipeCategory extends BaseRecipeCategory itemStacks.init(0, true, 53-xOffset, 34-yOffset); itemStacks.init(1, false, 115-xOffset, 34-yOffset); - itemStacks.set(0, recipeWrapper.getInputs()); - itemStacks.set(1, recipeWrapper.getOutputs()); + itemStacks.set(0, tempRecipe.recipeInput.getSolid()); + itemStacks.set(1, tempRecipe.recipeOutput.getItemOutput()); IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); fluidStacks.init(0, true, 3, 0, 16, 58, tempRecipe.getInput().getFluid().amount, false, fluidOverlay); - fluidStacks.set(0, recipeWrapper.getFluidInputs()); + fluidStacks.set(0, tempRecipe.recipeInput.getFluid()); fluidStacks.addTooltipCallback(new ITooltipCallback() { - @Override public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) { diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeHandler.java index 2567cafb8..f583f11d6 100644 --- a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeHandler.java @@ -20,13 +20,6 @@ public class PRCRecipeHandler implements IRecipeHandler return PRCRecipeWrapper.class; } - @Nonnull - @Override - public String getRecipeCategoryUid() - { - return category.getUid(); - } - @Nonnull @Override public IRecipeWrapper getRecipeWrapper(@Nonnull PRCRecipeWrapper recipe) diff --git a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java index 4d1ddcfce..b9c59ab41 100644 --- a/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java +++ b/src/main/java/mekanism/client/jei/machine/other/PRCRecipeWrapper.java @@ -1,14 +1,14 @@ package mekanism.client.jei.machine.other; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import javax.annotation.Nonnull; import javax.annotation.Nullable; +import mekanism.api.gas.GasStack; import mekanism.common.recipe.machines.PressurizedRecipe; import mekanism.common.util.LangUtils; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.BlankRecipeWrapper; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -25,25 +25,14 @@ public class PRCRecipeWrapper extends BlankRecipeWrapper category = c; } - @Nonnull @Override - public List getInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(recipe.getInput().getSolid()); - } - - @Nonnull - @Override - public List getFluidInputs() - { - return Arrays.asList(recipe.getInput().getFluid()); - } - - @Nonnull - @Override - public List getOutputs() - { - return Arrays.asList(recipe.getOutput().getItemOutput()); + ingredients.setInput(ItemStack.class, recipe.recipeInput.getSolid()); + ingredients.setInput(FluidStack.class, recipe.recipeInput.getFluid()); + ingredients.setInput(GasStack.class, recipe.recipeInput.getGas()); + ingredients.setOutput(ItemStack.class, recipe.recipeOutput.getItemOutput()); + ingredients.setOutput(GasStack.class, recipe.recipeOutput.getGasOutput()); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java index bfb7f318d..647553c90 100644 --- a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeCategory.java @@ -1,5 +1,7 @@ package mekanism.client.jei.machine.other; +import java.util.List; + import mekanism.api.gas.GasStack; import mekanism.client.jei.BaseRecipeCategory; import mezz.jei.api.IGuiHelper; @@ -7,9 +9,11 @@ import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory { @@ -63,7 +67,7 @@ public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof RotaryCondensentratorRecipeWrapper) { @@ -73,6 +77,13 @@ public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks(); fluidStacks.init(0, !tempRecipe.condensentrating, 134-xOffset, 14-yOffset, 16, 58, 1000, false, fluidOverlay); - fluidStacks.set(0, tempRecipe.condensentrating ? recipeWrapper.getFluidOutputs() : recipeWrapper.getFluidInputs()); + + if(tempRecipe.condensentrating) + { + fluidStacks.set(0, ingredients.getOutputs(FluidStack.class).get(0)); + } + else { + fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0)); + } } } diff --git a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeHandler.java index 74e16658d..585412270 100644 --- a/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/RotaryCondensentratorRecipeHandler.java @@ -20,13 +20,6 @@ public class RotaryCondensentratorRecipeHandler implements IRecipeHandler getInputs() - { - return new ArrayList(); - } - - @Nonnull - @Override - public List getFluidInputs() + public void getIngredients(IIngredients ingredients) { if(condensentrating) { - return new ArrayList(); + ingredients.setInput(GasStack.class, new GasStack(gasType, 1000)); + ingredients.setOutput(FluidStack.class, new FluidStack(fluidType, 1000)); } else { - return Arrays.asList(new FluidStack(fluidType, 1000)); - } - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); - } - - @Nonnull - @Override - public List getFluidOutputs() - { - if(condensentrating) - { - return Arrays.asList(new FluidStack(fluidType, 1000)); - } - else { - return new ArrayList(); + ingredients.setInput(FluidStack.class, new FluidStack(fluidType, 1000)); + ingredients.setOutput(GasStack.class, new GasStack(gasType, 1000)); } } diff --git a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java index 23d5e0d95..1187f95f5 100644 --- a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeCategory.java @@ -1,11 +1,14 @@ package mekanism.client.jei.machine.other; +import java.util.List; + import mekanism.client.jei.BaseRecipeCategory; import mekanism.common.recipe.machines.SolarNeutronRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -59,7 +62,7 @@ public class SolarNeutronRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof SolarNeutronRecipeWrapper) { diff --git a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeHandler.java index f55e1170c..03ed6c079 100644 --- a/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/SolarNeutronRecipeHandler.java @@ -20,13 +20,6 @@ public class SolarNeutronRecipeHandler implements IRecipeHandler getInputs() + public void getIngredients(IIngredients ingredients) { - return new ArrayList(); - } - - @Nonnull - @Override - public List getOutputs() - { - return new ArrayList(); + ingredients.setInput(GasStack.class, recipe.getInput().ingredient); + ingredients.setOutput(GasStack.class, recipe.getOutput().output); } @Nullable diff --git a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java index a191ffbf7..bf9cf0aaf 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java +++ b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeCategory.java @@ -10,6 +10,7 @@ import mezz.jei.api.gui.IGuiFluidStackGroup; import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.ITickTimer; import mezz.jei.api.gui.ITooltipCallback; +import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; @@ -56,7 +57,7 @@ public class ThermalEvaporationRecipeCategory extends BaseRecipeCategory } @Override - public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper) + public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) { if(recipeWrapper instanceof ThermalEvaporationRecipeWrapper) { @@ -68,11 +69,10 @@ public class ThermalEvaporationRecipeCategory extends BaseRecipeCategory fluidStacks.init(0, true, 7-xOffset, 14-yOffset, 16, 58, tempRecipe.getInput().ingredient.amount, false, fluidOverlay); fluidStacks.init(1, false, 153-xOffset, 14-yOffset, 16, 58, tempRecipe.getOutput().output.amount, false, fluidOverlay); - fluidStacks.set(0, recipeWrapper.getFluidInputs()); - fluidStacks.set(1, recipeWrapper.getFluidOutputs()); + fluidStacks.set(0, tempRecipe.recipeInput.ingredient); + fluidStacks.set(1, tempRecipe.recipeOutput.output); fluidStacks.addTooltipCallback(new ITooltipCallback() { - @Override public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List tooltip) { diff --git a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeHandler.java b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeHandler.java index 7722eb8cd..89a22ef99 100644 --- a/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeHandler.java +++ b/src/main/java/mekanism/client/jei/machine/other/ThermalEvaporationRecipeHandler.java @@ -20,13 +20,6 @@ public class ThermalEvaporationRecipeHandler implements IRecipeHandler getFluidInputs() + public void getIngredients(IIngredients ingredients) { - return Arrays.asList(recipe.getInput().ingredient); - } - - @Nonnull - @Override - public List getFluidOutputs() - { - return Arrays.asList(recipe.getOutput().output); + ingredients.setInput(FluidStack.class, recipe.getInput().ingredient); + ingredients.setOutput(FluidStack.class, recipe.getOutput().output); } } diff --git a/src/main/java/mekanism/client/render/MinerVisualRenderer.java b/src/main/java/mekanism/client/render/MinerVisualRenderer.java index d1d2bc2aa..f72e44355 100644 --- a/src/main/java/mekanism/client/render/MinerVisualRenderer.java +++ b/src/main/java/mekanism/client/render/MinerVisualRenderer.java @@ -61,7 +61,7 @@ public final class MinerVisualRenderer { if(x == -data.radius || x == data.radius || y == data.minY-data.yCoord || y == data.maxY-data.yCoord || z == -data.radius || z == data.radius) { - models.add(createModel(new Coord4D(x, y, z, mc.theWorld.provider.getDimension()))); + models.add(createModel(new Coord4D(x, y, z, mc.world.provider.getDimension()))); } } } diff --git a/src/main/java/mekanism/client/render/RenderTickHandler.java b/src/main/java/mekanism/client/render/RenderTickHandler.java index fa733fc45..a0391d33d 100644 --- a/src/main/java/mekanism/client/render/RenderTickHandler.java +++ b/src/main/java/mekanism/client/render/RenderTickHandler.java @@ -42,10 +42,10 @@ public class RenderTickHandler { if(event.phase == Phase.END) { - if(mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused()) + if(mc.player != null && mc.world != null && !mc.isGamePaused()) { - EntityPlayer player = mc.thePlayer; - World world = mc.thePlayer.worldObj; + EntityPlayer player = mc.player; + World world = mc.player.world; FontRenderer font = mc.fontRendererObj; RayTraceResult pos = player.rayTrace(40.0D, 1.0F); @@ -109,7 +109,7 @@ public class RenderTickHandler { for(String s : Mekanism.jetpackOn) { - EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); + EntityPlayer p = mc.world.getPlayerEntityByName(s); if(p == null) { @@ -154,7 +154,7 @@ public class RenderTickHandler { for(String s : Mekanism.gasmaskOn) { - EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); + EntityPlayer p = mc.world.getPlayerEntityByName(s); if(p == null || !p.isInWater()) { diff --git a/src/main/java/mekanism/client/render/ctm/Quad.java b/src/main/java/mekanism/client/render/ctm/Quad.java index 87751f069..3a2c3b404 100644 --- a/src/main/java/mekanism/client/render/ctm/Quad.java +++ b/src/main/java/mekanism/client/render/ctm/Quad.java @@ -483,6 +483,12 @@ public class Quad private boolean applyDiffuseLighting; + @Override + public void setTexture(TextureAtlasSprite sprite) + { + //TODO ignore for now + } + @Override public void setQuadTint(int tint) { diff --git a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java index 88c9715ee..8ae7b9cad 100644 --- a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java +++ b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java @@ -35,7 +35,7 @@ public class RenderObsidianTNTPrimed extends Render if(entityobsidiantnt.fuse - partialTicks + 1.0F < 10.0F) { float f = 1.0F - (entityobsidiantnt.fuse - partialTicks + 1.0F) / 10.0F; - f = MathHelper.clamp_float(f, 0.0F, 1.0F); + f = MathHelper.clamp(f, 0.0F, 1.0F); f = f * f; f = f * f; float f1 = 1.0F + f * 0.3F; diff --git a/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java b/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java index 9162bdf62..83d9ce2ad 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java @@ -44,7 +44,7 @@ public class RenderConfigurableMachine"; } @Override - public List getCommandAliases() + public List getAliases() { return Arrays.asList(new String[] {"mekanism", "mek"}); } @@ -49,13 +49,13 @@ public class CommandMekanism extends CommandBase { if(params.length < 1) { - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber)); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + " *Latest Version: " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + " *Developed on Mac OS X 10.8 Mountain Lion")); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady")); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews)); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber)); + sender.sendMessage(new TextComponentString(EnumColor.GREY + " *Latest Version: " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); + sender.sendMessage(new TextComponentString(EnumColor.GREY + " *Developed on Mac OS X 10.8 Mountain Lion")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews)); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } else if(params.length >= 1) { @@ -63,25 +63,25 @@ public class CommandMekanism extends CommandBase { if(params.length == 1) { - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk" + EnumColor.GREY + " -- displays the main page.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk help" + EnumColor.GREY + " -- displays this guide.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter" + EnumColor.GREY + " -- provides information on teleporters.")); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk" + EnumColor.GREY + " -- displays the main page.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk help" + EnumColor.GREY + " -- displays this guide.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter" + EnumColor.GREY + " -- provides information on teleporters.")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } else if(params[1].equalsIgnoreCase("teleporter")) { - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq list" + EnumColor.GREY + " -- displays a list of the public frequencies.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq list [user]" + EnumColor.GREY + " -- displays a list of a certain user's private frequencies.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq delete [freq]" + EnumColor.GREY + " -- removes a frequency from the public list.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq delete [user] [freq]" + EnumColor.GREY + " -- removes a freqency from a certain user's private list.")); - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq deleteAll [user]" + EnumColor.GREY + " -- removes all frequencies owned by a certain user.")); - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq list" + EnumColor.GREY + " -- displays a list of the public frequencies.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq list [user]" + EnumColor.GREY + " -- displays a list of a certain user's private frequencies.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq delete [freq]" + EnumColor.GREY + " -- removes a frequency from the public list.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq delete [user] [freq]" + EnumColor.GREY + " -- removes a freqency from a certain user's private list.")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " /mk teleporter freq deleteAll [user]" + EnumColor.GREY + " -- removes all frequencies owned by a certain user.")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } } else if(params[0].equalsIgnoreCase("version")) @@ -90,38 +90,38 @@ public class CommandMekanism extends CommandBase { if(general.updateNotifications || Mekanism.latestVersionNumber == null || Mekanism.recentNews == null || Mekanism.latestVersionNumber.equals("null")) { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Minecraft is in offline mode, could not check for updates.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Minecraft is in offline mode, could not check for updates.")); } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date.")); } } } else if(params[0].equalsIgnoreCase("news")) { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews)); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews)); } else if(params[0].equalsIgnoreCase("latest")) { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for this mod is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + ".")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " The latest version for this mod is " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber + EnumColor.GREY + ".")); } else if(params[0].equalsIgnoreCase("teleporter")) { if(params.length == 2) { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Invalid parameters.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Invalid parameters.")); } else if(params[1].equalsIgnoreCase("freq") || params[1].equalsIgnoreCase("frequencies")) { if(params[2].equalsIgnoreCase("list")) { - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); if(params.length == 3) { for(Frequency freq : Mekanism.publicTeleporters.getFrequencies()) { - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); } } else { @@ -131,15 +131,15 @@ public class CommandMekanism extends CommandBase { for(Frequency freq : manager.getFrequencies()) { - sender.addChatMessage(new TextComponentString(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); + sender.sendMessage(new TextComponentString(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); } } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); } } - sender.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + sender.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } else if(params[2].equalsIgnoreCase("delete")) { @@ -148,10 +148,10 @@ public class CommandMekanism extends CommandBase if(Mekanism.publicTeleporters.containsFrequency(params[3].trim())) { Mekanism.publicTeleporters.remove(params[3].trim()); - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); } } else if(params.length == 5) @@ -163,14 +163,14 @@ public class CommandMekanism extends CommandBase if(manager.containsFrequency(params[4].trim())) { manager.remove(params[4].trim()); - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); } } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); } } } @@ -186,10 +186,10 @@ public class CommandMekanism extends CommandBase int amount = Mekanism.publicTeleporters.removeAll(owner); amount += manager.removeAll(owner); - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed " + amount + " frequencies.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed " + amount + " frequencies.")); } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); } } } @@ -198,7 +198,7 @@ public class CommandMekanism extends CommandBase else if(params[0].equalsIgnoreCase("debug")) { MekanismAPI.debug = !MekanismAPI.debug; - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + MekanismAPI.debug)); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + MekanismAPI.debug)); } else if(params[0].equalsIgnoreCase("op")) { @@ -221,7 +221,7 @@ public class CommandMekanism extends CommandBase } } else { - sender.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help.")); + sender.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help.")); } } } diff --git a/src/main/java/mekanism/common/CommonPlayerTickHandler.java b/src/main/java/mekanism/common/CommonPlayerTickHandler.java index cc9925b29..56c57b573 100644 --- a/src/main/java/mekanism/common/CommonPlayerTickHandler.java +++ b/src/main/java/mekanism/common/CommonPlayerTickHandler.java @@ -53,7 +53,7 @@ public class CommonPlayerTickHandler if(isFlamethrowerOn(player)) { - player.worldObj.spawnEntityInWorld(new EntityFlame(player)); + player.world.spawnEntity(new EntityFlame(player)); if(!player.capabilities.isCreativeMode) { @@ -144,13 +144,13 @@ public class CommonPlayerTickHandler public static boolean isOnGround(EntityPlayer player) { - int x = MathHelper.floor_double(player.posX); + int x = MathHelper.floor(player.posX); int y = (int)Math.round(player.posY - 1); - int z = MathHelper.floor_double(player.posZ); + int z = MathHelper.floor(player.posZ); BlockPos pos = new BlockPos(x, y, z); - IBlockState s = player.worldObj.getBlockState(pos); - AxisAlignedBB box = s.getCollisionBoundingBox(player.worldObj, pos); + IBlockState s = player.world.getBlockState(pos); + AxisAlignedBB box = s.getCollisionBoundingBox(player.world, pos); AxisAlignedBB playerBox = player.getCollisionBoundingBox(); return box != null && playerBox != null && playerBox.offset(0, -0.01, 0).intersectsWith(box); @@ -158,7 +158,7 @@ public class CommonPlayerTickHandler public boolean isJetpackOn(EntityPlayer player) { - ItemStack stack = player.inventory.armorInventory[2]; + ItemStack stack = player.inventory.armorInventory.get(2); if(stack != null && !player.capabilities.isCreativeMode) { @@ -194,8 +194,8 @@ public class CommonPlayerTickHandler public static boolean isGasMaskOn(EntityPlayer player) { - ItemStack tank = player.inventory.armorInventory[2]; - ItemStack mask = player.inventory.armorInventory[3]; + ItemStack tank = player.inventory.armorInventory.get(2); + ItemStack mask = player.inventory.armorInventory.get(3); if(tank != null && mask != null) { diff --git a/src/main/java/mekanism/common/CommonPlayerTracker.java b/src/main/java/mekanism/common/CommonPlayerTracker.java index 8788813b7..bc293c82f 100644 --- a/src/main/java/mekanism/common/CommonPlayerTracker.java +++ b/src/main/java/mekanism/common/CommonPlayerTracker.java @@ -25,7 +25,7 @@ public class CommonPlayerTracker @SubscribeEvent public void onPlayerLoginEvent(PlayerLoggedInEvent event) { - if(!event.player.worldObj.isRemote) + if(!event.player.world.isRemote) { Mekanism.packetHandler.sendTo(new ConfigSyncMessage(), (EntityPlayerMP)event.player); Mekanism.packetHandler.sendTo(new BoxBlacklistMessage(), (EntityPlayerMP)event.player); @@ -52,7 +52,7 @@ public class CommonPlayerTracker Mekanism.gasmaskOn.remove(event.player.getName()); Mekanism.flamethrowerActive.remove(event.player.getName()); - if(!event.player.worldObj.isRemote) + if(!event.player.world.isRemote) { Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player); Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player); diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index ae6924260..71fe7f00e 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -632,7 +632,7 @@ public class CommonProxy implements IGuiProvider dummyPlayer = createNewPlayer(world); } else { - dummyPlayer.get().worldObj = world; + dummyPlayer.get().world = world; } return dummyPlayer; @@ -645,7 +645,7 @@ public class CommonProxy implements IGuiProvider dummyPlayer = createNewPlayer(world, x, y, z); } else { - dummyPlayer.get().worldObj = world; + dummyPlayer.get().world = world; dummyPlayer.get().posX = x; dummyPlayer.get().posY = y; dummyPlayer.get().posZ = z; @@ -663,7 +663,7 @@ public class CommonProxy implements IGuiProvider { if(player instanceof EntityPlayerMP) { - ((WorldServer)player.worldObj).addScheduledTask(runnable); + ((WorldServer)player.world).addScheduledTask(runnable); } } diff --git a/src/main/java/mekanism/common/CreativeTabMekanism.java b/src/main/java/mekanism/common/CreativeTabMekanism.java index 607eb82f4..de97a8c0d 100644 --- a/src/main/java/mekanism/common/CreativeTabMekanism.java +++ b/src/main/java/mekanism/common/CreativeTabMekanism.java @@ -18,8 +18,8 @@ public class CreativeTabMekanism extends CreativeTabs } @Override - public Item getTabIconItem() + public ItemStack getTabIconItem() { - return MekanismItems.AtomicAlloy; + return new ItemStack(MekanismItems.AtomicAlloy); } } diff --git a/src/main/java/mekanism/common/LaserManager.java b/src/main/java/mekanism/common/LaserManager.java index e54619403..f6c17b3ff 100644 --- a/src/main/java/mekanism/common/LaserManager.java +++ b/src/main/java/mekanism/common/LaserManager.java @@ -68,7 +68,7 @@ public class LaserManager if(energy > 256) { - e.attackEntityFrom(DamageSource.generic, (float)energy/1000F); + e.attackEntityFrom(DamageSource.GENERIC, (float)energy/1000F); } } diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 54f8f3ad5..182bcf866 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -1191,11 +1191,11 @@ public class Mekanism public void addEntities() { //Registrations - EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 64, 5, true); - EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 64, 2, true); - EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 64, 1, true); - EntityRegistry.registerModEntity(EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true); - EntityRegistry.registerModEntity(EntityFlame.class, "Flame", 4, this, 64, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation("mekanism", "ObsidianTNT"), EntityObsidianTNT.class, "ObsidianTNT", 0, this, 64, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation("mekanism", "Robit"), EntityRobit.class, "Robit", 1, this, 64, 2, true); + EntityRegistry.registerModEntity(new ResourceLocation("mekanism", "Balloon"), EntityBalloon.class, "Balloon", 2, this, 64, 1, true); + EntityRegistry.registerModEntity(new ResourceLocation("mekanism", "BabySkeleton"), EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true); + EntityRegistry.registerModEntity(new ResourceLocation("mekanism", "Flame"), EntityFlame.class, "Flame", 4, this, 64, 5, true); //Tile entities GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); @@ -1556,7 +1556,7 @@ public class Mekanism return; } - ChunkPos coordPair = event.getChunk().getChunkCoordIntPair(); + ChunkPos coordPair = event.getChunk().getPos(); worldTickHandler.addRegenChunk(event.getWorld().provider.getDimension(), coordPair); } } diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index 233d9b1d6..61a7a0818 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -288,7 +288,7 @@ public class PacketHandler { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - for(EntityPlayerMP player : server.getPlayerList().getPlayerList()) + for(EntityPlayerMP player : server.getPlayerList().getPlayers()) { sendTo(message, player); } @@ -336,7 +336,7 @@ public class PacketHandler if(server != null && cuboid != null) { - for(EntityPlayerMP player : (List)server.getPlayerList().getPlayerList()) + for(EntityPlayerMP player : (List)server.getPlayerList().getPlayers()) { if(player.dimension == dimId && cuboid.isVecInside(new Vec3d(player.posX, player.posY, player.posZ))) { @@ -352,7 +352,7 @@ public class PacketHandler if(server != null) { - for(EntityPlayerMP player : (List)server.getPlayerList().getPlayerList()) + for(EntityPlayerMP player : (List)server.getPlayerList().getPlayers()) { if(player.dimension == range.dimensionId && Range4D.getChunkRange(player).intersects(range)) { diff --git a/src/main/java/mekanism/common/base/FluidItemWrapper.java b/src/main/java/mekanism/common/base/FluidItemWrapper.java index 3aa348d35..0d7338086 100644 --- a/src/main/java/mekanism/common/base/FluidItemWrapper.java +++ b/src/main/java/mekanism/common/base/FluidItemWrapper.java @@ -3,7 +3,6 @@ package mekanism.common.base; import mekanism.common.capabilities.ItemCapabilityWrapper.ItemCapability; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.FluidTankProperties; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -19,7 +18,7 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandler @Override public int fill(FluidStack resource, boolean doFill) { - if(getStack().stackSize != 1) + if(getStack().getCount() != 1) { return 0; } @@ -30,7 +29,7 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandler @Override public FluidStack drain(FluidStack resource, boolean doDrain) { - if(getStack().stackSize != 1 || resource == null) + if(getStack().getCount() != 1 || resource == null) { return null; } @@ -51,7 +50,7 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandler @Override public FluidStack drain(int maxDrain, boolean doDrain) { - if(getStack().stackSize != 1) + if(getStack().getCount() != 1) { return null; } @@ -59,9 +58,9 @@ public class FluidItemWrapper extends ItemCapability implements IFluidHandler return getItem().drain(getStack(), maxDrain, doDrain); } - public IFluidContainerItem getItem() + public IFluidItemWrapper getItem() { - return (IFluidContainerItem)getStack().getItem(); + return (IFluidItemWrapper)getStack().getItem(); } @Override diff --git a/src/main/java/mekanism/common/base/IFluidItemWrapper.java b/src/main/java/mekanism/common/base/IFluidItemWrapper.java new file mode 100644 index 000000000..c21861ac9 --- /dev/null +++ b/src/main/java/mekanism/common/base/IFluidItemWrapper.java @@ -0,0 +1,15 @@ +package mekanism.common.base; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +public interface IFluidItemWrapper +{ + public FluidStack getFluid(ItemStack container); + + public int getCapacity(ItemStack container); + + public int fill(ItemStack container, FluidStack resource, boolean doFill); + + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain); +} diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index c9c0de1d4..4d0a80d79 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -1,6 +1,5 @@ package mekanism.common.block; -import java.util.List; import java.util.Random; import mekanism.api.Coord4D; @@ -58,9 +57,11 @@ import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; @@ -220,7 +221,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos fromPos) { if(!world.isRemote) { @@ -299,7 +300,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(BasicBlockType type : BasicBlockType.values()) { @@ -412,10 +413,10 @@ public abstract class BlockBasic extends Block implements ICTMBlock { if(!player.isSneaking()) { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, bin.removeStack().copy())); + world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.removeStack().copy())); } else { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, bin.remove(1).copy())); + world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.remove(1).copy())); } } } @@ -423,10 +424,11 @@ public abstract class BlockBasic extends Block implements ICTMBlock } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { BasicBlockType type = BasicBlockType.get(state); TileEntity tile = world.getTileEntity(pos); + ItemStack stack = entityplayer.getHeldItem(hand); if(type == BasicBlockType.REFINED_OBSIDIAN) { @@ -487,13 +489,13 @@ public abstract class BlockBasic extends Block implements ICTMBlock if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, pos); + ((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); } int change = bin.facing.rotateY().ordinal(); bin.setFacing((short)change); - world.notifyNeighborsOfStateChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this, true); } return true; @@ -514,19 +516,19 @@ public abstract class BlockBasic extends Block implements ICTMBlock } else if(bin.addTicks > 0 && bin.getItemCount() > 0) { - ItemStack[] inv = entityplayer.inventory.mainInventory; + NonNullList inv = entityplayer.inventory.mainInventory; - for(int i = 0; i < inv.length; i++) + for(int i = 0; i < inv.size(); i++) { if(bin.getItemCount() == bin.tier.storage) { break; } - if(inv[i] != null) + if(inv.get(i) != null) { - ItemStack remain = bin.add(inv[i]); - inv[i] = remain; + ItemStack remain = bin.add(inv.get(i)); + inv.set(i, remain); bin.addTicks = 5; } @@ -598,15 +600,15 @@ public abstract class BlockBasic extends Block implements ICTMBlock { tileEntity.structure.fluidStored.amount -= filled; } - else if(itemStack.stackSize == 1) + else if(itemStack.getCount() == 1) { tileEntity.structure.fluidStored.amount -= filled; player.setHeldItem(hand, copyStack); } - else if(itemStack.stackSize > 1 && player.inventory.addItemStackToInventory(copyStack)) + else if(itemStack.getCount() > 1 && player.inventory.addItemStackToInventory(copyStack)) { tileEntity.structure.fluidStored.amount -= filled; - itemStack.stackSize--; + itemStack.shrink(1); } if(tileEntity.structure.fluidStored.amount == 0) @@ -631,7 +633,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock boolean filled = false; FluidStack drained = handler.drain(needed, !player.capabilities.isCreativeMode); - if(copyStack.stackSize == 0) + if(copyStack.getCount() == 0) { copyStack = null; } @@ -645,7 +647,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock else { if(copyStack != null) { - if(itemStack.stackSize == 1) + if(itemStack.getCount() == 1) { player.setHeldItem(hand, copyStack); filled = true; @@ -653,16 +655,16 @@ public abstract class BlockBasic extends Block implements ICTMBlock else { if(player.inventory.addItemStackToInventory(copyStack)) { - itemStack.stackSize--; + itemStack.shrink(1); filled = true; } } } else { - itemStack.stackSize--; + itemStack.shrink(1); - if(itemStack.stackSize == 0) + if(itemStack.getCount() == 0) { player.setHeldItem(hand, null); } @@ -777,7 +779,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock if(world.getTileEntity(pos) instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int side = MathHelper.floor((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); int change = 3; @@ -910,7 +912,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); @@ -931,7 +933,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; @@ -1035,8 +1037,8 @@ public abstract class BlockBasic extends Block implements ICTMBlock } @Override - public boolean isBeaconBase(IBlockAccess worldObj, BlockPos pos, BlockPos beacon) + public boolean isBeaconBase(IBlockAccess world, BlockPos pos, BlockPos beacon) { - return BasicBlockType.get(worldObj.getBlockState(pos)).isBeaconBase; + return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockBounding.java b/src/main/java/mekanism/common/block/BlockBounding.java index 6fc3b8700..a1d311b74 100644 --- a/src/main/java/mekanism/common/block/BlockBounding.java +++ b/src/main/java/mekanism/common/block/BlockBounding.java @@ -49,12 +49,12 @@ public class BlockBounding extends Block } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { try { TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(pos); IBlockState state1 = world.getBlockState(tileEntity.mainPos); - return state1.getBlock().onBlockActivated(world, tileEntity.mainPos, state1, player, hand, stack, side, hitX, hitY, hitZ); + return state1.getBlock().onBlockActivated(world, tileEntity.mainPos, state1, player, hand, side, hitX, hitY, hitZ); } catch(Exception e) { return false; } @@ -93,13 +93,13 @@ public class BlockBounding extends Block } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { try { TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(pos); tileEntity.onNeighborChange(state.getBlock()); IBlockState state1 = world.getBlockState(tileEntity.mainPos); - state1.getBlock().neighborChanged(state1, world, tileEntity.mainPos, this); + state1.getBlock().neighborChanged(state1, world, tileEntity.mainPos, neighborBlock, neighborPos); } catch(Exception e) {} } diff --git a/src/main/java/mekanism/common/block/BlockCardboardBox.java b/src/main/java/mekanism/common/block/BlockCardboardBox.java index 34cb64f2b..cb062fc8a 100644 --- a/src/main/java/mekanism/common/block/BlockCardboardBox.java +++ b/src/main/java/mekanism/common/block/BlockCardboardBox.java @@ -65,7 +65,7 @@ public class BlockCardboardBox extends BlockContainer } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote && entityplayer.isSneaking()) { @@ -88,7 +88,7 @@ public class BlockCardboardBox extends BlockContainer if(data.block != null) { - IBlockState newstate = data.block.onBlockPlaced(world, pos, side, hitX, hitY, hitZ, data.meta, entityplayer); + IBlockState newstate = data.block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, data.meta, entityplayer, hand); data.meta = newstate.getBlock().getMetaFromState(newstate); } @@ -112,7 +112,7 @@ public class BlockCardboardBox extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } } @@ -146,7 +146,7 @@ public class BlockCardboardBox extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; @@ -182,7 +182,7 @@ public class BlockCardboardBox extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index 38e0952fe..9d3e6630f 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -1,6 +1,5 @@ package mekanism.common.block; -import java.util.List; import java.util.Random; import mekanism.api.energy.IEnergizedItem; @@ -36,9 +35,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -107,7 +108,7 @@ public class BlockEnergyCube extends BlockContainer } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(!world.isRemote) { @@ -124,7 +125,7 @@ public class BlockEnergyCube extends BlockContainer public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int side = MathHelper.floor((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); int change = 3; @@ -164,7 +165,7 @@ public class BlockEnergyCube extends BlockContainer @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(EnergyCubeTier tier : EnergyCubeTier.values()) { @@ -187,7 +188,7 @@ public class BlockEnergyCube extends BlockContainer } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -195,6 +196,7 @@ public class BlockEnergyCube extends BlockContainer } TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(pos); + ItemStack stack = entityplayer.getHeldItem(hand); if(stack != null) { @@ -213,13 +215,13 @@ public class BlockEnergyCube extends BlockContainer if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, pos); + ((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); } int change = tileEntity.facing.rotateAround(side.getAxis()).ordinal(); tileEntity.setFacing((short)change); - world.notifyNeighborsOfStateChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this, true); } else { SecurityUtils.displayNoAccess(entityplayer); @@ -259,7 +261,7 @@ public class BlockEnergyCube extends BlockContainer double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); @@ -340,7 +342,7 @@ public class BlockEnergyCube extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index a452c7c80..2d85db7f0 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -36,6 +36,7 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import buildcraft.api.tools.IToolWrench; @@ -98,7 +99,7 @@ public class BlockGasTank extends BlockContainer { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int side = MathHelper.floor((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int change = 3; switch(side) @@ -114,7 +115,7 @@ public class BlockGasTank extends BlockContainer } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(!world.isRemote) { @@ -136,7 +137,7 @@ public class BlockGasTank extends BlockContainer } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -144,6 +145,7 @@ public class BlockGasTank extends BlockContainer } TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(pos); + ItemStack stack = entityplayer.getHeldItem(hand); if(stack != null) { @@ -162,13 +164,13 @@ public class BlockGasTank extends BlockContainer if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, pos); + ((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); } int change = tileEntity.facing.rotateY().ordinal(); tileEntity.setFacing((short)change); - world.notifyNeighborsOfStateChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this, true); } else { SecurityUtils.displayNoAccess(entityplayer); @@ -209,7 +211,7 @@ public class BlockGasTank extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); @@ -230,7 +232,7 @@ public class BlockGasTank extends BlockContainer EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index a3c447cff..4a2d4f70a 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1,11 +1,9 @@ package mekanism.common.block; -import java.util.List; import java.util.Random; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.client; -import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.util.StackUtils; @@ -13,7 +11,6 @@ import mekanism.client.render.ctm.CTMBlockRenderContext; import mekanism.client.render.ctm.CTMData; import mekanism.client.render.ctm.ICTMBlock; import mekanism.common.Mekanism; -import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.FluidTankTier; import mekanism.common.base.IActiveState; import mekanism.common.base.IBoundingBlock; @@ -73,16 +70,16 @@ import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fluids.capability.IFluidHandler; @@ -246,7 +243,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int side = MathHelper.floor((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(placer.rotationPitch); int change = 3; @@ -403,7 +400,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(MachineType type : MachineType.getValidMachines()) { @@ -441,7 +438,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -450,6 +447,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); + ItemStack stack = entityplayer.getHeldItem(hand); if(stack != null) { @@ -468,7 +466,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, pos); + ((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); } int change = tileEntity.facing.rotateY().ordinal(); @@ -491,7 +489,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock } tileEntity.setFacing((short)change); - world.notifyNeighborsOfStateChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this, true); } else { SecurityUtils.displayNoAccess(entityplayer); @@ -682,7 +680,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); @@ -736,13 +734,13 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock if(filled > 0) { - if(itemStack.stackSize == 1) + if(itemStack.getCount() == 1) { player.setHeldItem(hand, copyStack); } - else if(itemStack.stackSize > 1 && player.inventory.addItemStackToInventory(copyStack)) + else if(itemStack.getCount() > 1 && player.inventory.addItemStackToInventory(copyStack)) { - itemStack.stackSize--; + itemStack.shrink(1); } if(tileEntity.tier != FluidTankTier.CREATIVE) @@ -766,7 +764,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock boolean filled = false; FluidStack drained = handler.drain(needed, !player.capabilities.isCreativeMode); - if(copyStack.stackSize == 0) + if(copyStack.getCount() == 0) { copyStack = null; } @@ -780,7 +778,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock else { if(copyStack != null) { - if(itemStack.stackSize == 1) + if(itemStack.getCount() == 1) { player.setHeldItem(hand, copyStack); filled = true; @@ -788,16 +786,16 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock else { if(player.inventory.addItemStackToInventory(copyStack)) { - itemStack.stackSize--; + itemStack.shrink(1); filled = true; } } } else { - itemStack.stackSize--; + itemStack.shrink(1); - if(itemStack.stackSize == 0) + if(itemStack.getCount() == 0) { player.setHeldItem(hand, null); } @@ -832,7 +830,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(!world.isRemote) { @@ -977,7 +975,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; @@ -1011,7 +1009,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) + public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { if(world.getTileEntity(pos) instanceof TileEntityChargepad) { diff --git a/src/main/java/mekanism/common/block/BlockObsidianTNT.java b/src/main/java/mekanism/common/block/BlockObsidianTNT.java index e13a85405..d4c7962b7 100644 --- a/src/main/java/mekanism/common/block/BlockObsidianTNT.java +++ b/src/main/java/mekanism/common/block/BlockObsidianTNT.java @@ -46,7 +46,7 @@ public class BlockObsidianTNT extends Block } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(world.isBlockIndirectlyGettingPowered(pos) > 0) { @@ -62,7 +62,7 @@ public class BlockObsidianTNT extends Block { EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F); entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; - world.spawnEntityInWorld(entity); + world.spawnEntity(entity); } } @@ -71,14 +71,16 @@ public class BlockObsidianTNT extends Block if(!world.isRemote) { EntityObsidianTNT entity = new EntityObsidianTNT(world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F); - world.spawnEntityInWorld(entity); + world.spawnEntity(entity); entity.playSound(SoundEvents.ENTITY_TNT_PRIMED, 1.0F, 1.0F); } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack stack = entityplayer.getHeldItem(hand); + if(stack != null && stack.getItem() == Items.FLINT_AND_STEEL) { explode(world, pos); @@ -87,7 +89,7 @@ public class BlockObsidianTNT extends Block return true; } else { - return super.onBlockActivated(world, pos, state, entityplayer, hand, stack, side, hitX, hitY, hitZ); + return super.onBlockActivated(world, pos, state, entityplayer, hand, side, hitX, hitY, hitZ); } } diff --git a/src/main/java/mekanism/common/block/BlockOre.java b/src/main/java/mekanism/common/block/BlockOre.java index e69b452ba..da3128698 100644 --- a/src/main/java/mekanism/common/block/BlockOre.java +++ b/src/main/java/mekanism/common/block/BlockOre.java @@ -1,7 +1,5 @@ package mekanism.common.block; -import java.util.List; - import mekanism.common.Mekanism; import mekanism.common.block.states.BlockStateOre; import mekanism.common.block.states.BlockStateOre.EnumOreType; @@ -12,6 +10,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -59,7 +58,7 @@ public class BlockOre extends Block @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(EnumOreType ore : EnumOreType.values()) { diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java index 844cfb592..1187eb49e 100644 --- a/src/main/java/mekanism/common/block/BlockPlastic.java +++ b/src/main/java/mekanism/common/block/BlockPlastic.java @@ -1,7 +1,5 @@ package mekanism.common.block; -import java.util.List; - import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.block.states.BlockStatePlastic; @@ -15,6 +13,7 @@ import net.minecraft.entity.Entity; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; @@ -80,7 +79,7 @@ public class BlockPlastic extends Block @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(int i = 0; i < EnumColor.DYES.length; i++) { diff --git a/src/main/java/mekanism/common/block/BlockPlasticFence.java b/src/main/java/mekanism/common/block/BlockPlasticFence.java index a7d5e4ee3..2d8719ab0 100644 --- a/src/main/java/mekanism/common/block/BlockPlasticFence.java +++ b/src/main/java/mekanism/common/block/BlockPlasticFence.java @@ -1,9 +1,6 @@ package mekanism.common.block; import static mekanism.common.block.states.BlockStatePlastic.colorProperty; - -import java.util.List; - import mekanism.api.EnumColor; import mekanism.common.Mekanism; import net.minecraft.block.BlockFence; @@ -17,6 +14,7 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -49,7 +47,7 @@ public class BlockPlasticFence extends BlockFence @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(int i = 0; i < EnumColor.DYES.length; i++) { diff --git a/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java b/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java index 4b36ef498..9e98989d8 100644 --- a/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java +++ b/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java @@ -8,6 +8,7 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.common.PacketHandler; import mekanism.common.frequency.Frequency; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidRegistry; @@ -91,7 +92,7 @@ public class InventoryFrequency extends Frequency if(nbtTags.hasKey("storedItem")) { - storedItem = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("storedItem")); + storedItem = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("storedItem")); } temperature = nbtTags.getDouble("temperature"); diff --git a/src/main/java/mekanism/common/content/matrix/MatrixCache.java b/src/main/java/mekanism/common/content/matrix/MatrixCache.java index 482a2a4ec..5a78c24a4 100644 --- a/src/main/java/mekanism/common/content/matrix/MatrixCache.java +++ b/src/main/java/mekanism/common/content/matrix/MatrixCache.java @@ -1,6 +1,7 @@ package mekanism.common.content.matrix; import mekanism.common.multiblock.MultiblockCache; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -35,7 +36,7 @@ public class MatrixCache extends MultiblockCache if(slotID >= 0 && slotID < 2) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } } diff --git a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java index 25428cc5f..f9f5d7974 100644 --- a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java +++ b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -56,7 +57,7 @@ public class MItemStackFilter extends MinerFilter super.read(nbtTags); fuzzy = nbtTags.getBoolean("fuzzy"); - itemType = ItemStack.loadItemStackFromNBT(nbtTags); + itemType = InventoryUtils.loadFromNBT(nbtTags); } @Override @@ -69,7 +70,7 @@ public class MItemStackFilter extends MinerFilter data.add(fuzzy); data.add(MekanismUtils.getID(itemType)); - data.add(itemType.stackSize); + data.add(itemType.getCount()); data.add(itemType.getItemDamage()); } @@ -88,7 +89,7 @@ public class MItemStackFilter extends MinerFilter { int code = 1; code = 31 * code + MekanismUtils.getID(itemType); - code = 31 * code + itemType.stackSize; + code = 31 * code + itemType.getCount(); code = 31 * code + itemType.getItemDamage(); return code; } diff --git a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java index 6ce3d3287..4dc42db46 100644 --- a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java +++ b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.common.content.transporter.Finder.MaterialFinder; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -49,7 +50,7 @@ public class MMaterialFilter extends MinerFilter { super.read(nbtTags); - materialItem = ItemStack.loadItemStackFromNBT(nbtTags); + materialItem = InventoryUtils.loadFromNBT(nbtTags); } @Override @@ -60,7 +61,7 @@ public class MMaterialFilter extends MinerFilter super.write(data); data.add(MekanismUtils.getID(materialItem)); - data.add(materialItem.stackSize); + data.add(materialItem.getCount()); data.add(materialItem.getItemDamage()); } @@ -77,7 +78,7 @@ public class MMaterialFilter extends MinerFilter { int code = 1; code = 31 * code + MekanismUtils.getID(materialItem); - code = 31 * code + materialItem.stackSize; + code = 31 * code + materialItem.getCount(); code = 31 * code + materialItem.getItemDamage(); return code; } diff --git a/src/main/java/mekanism/common/content/miner/MinerFilter.java b/src/main/java/mekanism/common/content/miner/MinerFilter.java index f7f93eb8b..7e24cc037 100644 --- a/src/main/java/mekanism/common/content/miner/MinerFilter.java +++ b/src/main/java/mekanism/common/content/miner/MinerFilter.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,7 +36,7 @@ public abstract class MinerFilter if(nbtTags.hasKey("replaceStack")) { - replaceStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack")); + replaceStack = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("replaceStack")); } } diff --git a/src/main/java/mekanism/common/content/tank/TankCache.java b/src/main/java/mekanism/common/content/tank/TankCache.java index eb23200c4..e21abb21e 100644 --- a/src/main/java/mekanism/common/content/tank/TankCache.java +++ b/src/main/java/mekanism/common/content/tank/TankCache.java @@ -2,6 +2,7 @@ package mekanism.common.content.tank; import mekanism.common.multiblock.MultiblockCache; import mekanism.common.util.FluidContainerUtils.ContainerEditMode; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -47,7 +48,7 @@ public class TankCache extends MultiblockCache if(slotID >= 0 && slotID < 2) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } diff --git a/src/main/java/mekanism/common/content/transporter/InvStack.java b/src/main/java/mekanism/common/content/transporter/InvStack.java index b1644d378..5ac8ab11f 100644 --- a/src/main/java/mekanism/common/content/transporter/InvStack.java +++ b/src/main/java/mekanism/common/content/transporter/InvStack.java @@ -33,13 +33,13 @@ public final class InvStack for(ItemStack stack : itemStacks) { - size += stack.stackSize; + size += stack.getCount(); } if(!itemStacks.isEmpty()) { ItemStack ret = itemStacks.get(0).copy(); - ret.stackSize = size; + ret.setCount(size); return ret; } @@ -59,16 +59,16 @@ public final class InvStack { ItemStack stack = itemStacks.get(i); - if(inventory.getStackInSlot(slotIDs.get(i)).stackSize == stack.stackSize && stack.stackSize <= amount) + if(inventory.getStackInSlot(slotIDs.get(i)).getCount() == stack.getCount() && stack.getCount() <= amount) { inventory.setInventorySlotContents(slotIDs.get(i), null); - amount -= stack.stackSize; + amount -= stack.getCount(); } else { ItemStack ret = stack.copy(); - ret.stackSize = inventory.getStackInSlot(slotIDs.get(i)).stackSize - Math.min(stack.stackSize, amount); + ret.setCount(inventory.getStackInSlot(slotIDs.get(i)).getCount() - Math.min(stack.getCount(), amount)); inventory.setInventorySlotContents(slotIDs.get(i), ret); - amount -= ret.stackSize; + amount -= ret.getCount(); } if(amount == 0) @@ -80,6 +80,6 @@ public final class InvStack public void use() { - use(getStack().stackSize); + use(getStack().getCount()); } } diff --git a/src/main/java/mekanism/common/content/transporter/StackSearcher.java b/src/main/java/mekanism/common/content/transporter/StackSearcher.java index 002f75f6d..e9eb6e74b 100644 --- a/src/main/java/mekanism/common/content/transporter/StackSearcher.java +++ b/src/main/java/mekanism/common/content/transporter/StackSearcher.java @@ -80,19 +80,19 @@ public class StackSearcher if(theInventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(i), type)) { ItemStack stack = theInventory.getStackInSlot(i); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + int current = ret.getStack() != null ? ret.getStack().getCount() : 0; - if(current+stack.stackSize <= max) + if(current+stack.getCount() <= max) { ret.appendStack(i, stack.copy()); } else { ItemStack copy = stack.copy(); - copy.stackSize = max-current; + copy.setCount(max-current); ret.appendStack(i, copy); } - if(ret.getStack() != null && ret.getStack().stackSize == max) + if(ret.getStack() != null && ret.getStack().getCount() == max) { return ret; } @@ -112,9 +112,9 @@ public class StackSearcher if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(slotID), type)) { ItemStack stack = sidedInventory.getStackInSlot(slotID); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + int current = ret.getStack() != null ? ret.getStack().getCount() : 0; - if(current+stack.stackSize <= max) + if(current+stack.getCount() <= max) { ItemStack copy = stack.copy(); @@ -128,12 +128,12 @@ public class StackSearcher if(sidedInventory.canExtractItem(slotID, copy, side.getOpposite())) { - copy.stackSize = max-current; + copy.setCount(max-current); ret.appendStack(slotID, copy); } } - if(ret.getStack() != null && ret.getStack().stackSize == max) + if(ret.getStack() != null && ret.getStack().getCount() == max) { return ret; } @@ -142,7 +142,7 @@ public class StackSearcher } } - if(ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) + if(ret != null && ret.getStack() != null && ret.getStack().getCount() >= min) { return ret; } diff --git a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java index d3ea5564d..15e974509 100644 --- a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.common.content.transporter.Finder.ItemStackFinder; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -32,7 +33,7 @@ public class TItemStackFilter extends TransporterFilter return false; } - return (itemType.getHasSubtypes() ? itemType.isItemEqual(itemStack) : itemType.getItem() == itemStack.getItem()) && (!sizeMode || itemStack.stackSize >= min); + return (itemType.getHasSubtypes() ? itemType.isItemEqual(itemStack) : itemType.getItem() == itemStack.getItem()) && (!sizeMode || itemStack.getCount() >= min); } @Override @@ -73,7 +74,7 @@ public class TItemStackFilter extends TransporterFilter min = nbtTags.getInteger("min"); max = nbtTags.getInteger("max"); - itemType = ItemStack.loadItemStackFromNBT(nbtTags); + itemType = InventoryUtils.loadFromNBT(nbtTags); } @Override @@ -88,7 +89,7 @@ public class TItemStackFilter extends TransporterFilter data.add(max); data.add(MekanismUtils.getID(itemType)); - data.add(itemType.stackSize); + data.add(itemType.getCount()); data.add(itemType.getItemDamage()); } @@ -110,7 +111,7 @@ public class TItemStackFilter extends TransporterFilter int code = 1; code = 31 * code + super.hashCode(); code = 31 * code + MekanismUtils.getID(itemType); - code = 31 * code + itemType.stackSize; + code = 31 * code + itemType.getCount(); code = 31 * code + itemType.getItemDamage(); code = 31 * code + (sizeMode ? 1 : 0); code = 31 * code + min; diff --git a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java index 792db9c1d..38ccc521b 100644 --- a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; import mekanism.common.content.transporter.Finder.MaterialFinder; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -53,7 +54,7 @@ public class TMaterialFilter extends TransporterFilter { super.read(nbtTags); - materialItem = ItemStack.loadItemStackFromNBT(nbtTags); + materialItem = InventoryUtils.loadFromNBT(nbtTags); } @Override @@ -64,7 +65,7 @@ public class TMaterialFilter extends TransporterFilter super.write(data); data.add(MekanismUtils.getID(materialItem)); - data.add(materialItem.stackSize); + data.add(materialItem.getCount()); data.add(materialItem.getItemDamage()); } @@ -81,7 +82,7 @@ public class TMaterialFilter extends TransporterFilter { int code = 1; code = 31 * code + MekanismUtils.getID(materialItem); - code = 31 * code + materialItem.stackSize; + code = 31 * code + materialItem.getCount(); code = 31 * code + materialItem.getItemDamage(); return code; } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterManager.java b/src/main/java/mekanism/common/content/transporter/TransporterManager.java index 0d81f4cc1..50ebb065b 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterManager.java @@ -153,45 +153,45 @@ public class TransporterManager if(inSlot == null) { - if(toInsert.stackSize <= inv.getInventoryStackLimit()) + if(toInsert.getCount() <= inv.getInventoryStackLimit()) { copy.inventory[i] = toInsert; return; } else { - int rejects = toInsert.stackSize - inv.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inv.getInventoryStackLimit(); ItemStack toSet = toInsert.copy(); - toSet.stackSize = inv.getInventoryStackLimit(); + toSet.setCount(inv.getInventoryStackLimit()); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); copy.inventory[i] = toSet; toInsert = remains; } } - else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + toSet.grow(inSlot.getCount()); copy.inventory[i] = toSet; return; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + toSet.setCount(max); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); copy.inventory[i] = toSet; @@ -221,7 +221,7 @@ public class TransporterManager } int amountRemaining = ((TileEntityBin)inv).getMaxStoredCount()-copy.binAmount; - copy.binAmount += Math.min(amountRemaining, toInsert.stackSize); + copy.binAmount += Math.min(amountRemaining, toInsert.getCount()); return; } @@ -242,45 +242,45 @@ public class TransporterManager if(inSlot == null) { - if(toInsert.stackSize <= inv.getInventoryStackLimit()) + if(toInsert.getCount() <= inv.getInventoryStackLimit()) { copy.inventory[slotID] = toInsert; return; } else { - int rejects = toInsert.stackSize - inv.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inv.getInventoryStackLimit(); ItemStack toSet = toInsert.copy(); - toSet.stackSize = inv.getInventoryStackLimit(); + toSet.setCount(inv.getInventoryStackLimit()); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); copy.inventory[slotID] = toSet; toInsert = remains; } } - else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + toSet.grow(inSlot.getCount()); copy.inventory[slotID] = toSet; return; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + toSet.setCount(max); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); copy.inventory[slotID] = toSet; @@ -295,17 +295,17 @@ public class TransporterManager public static boolean didEmit(ItemStack stack, ItemStack returned) { - return returned == null || returned.stackSize < stack.stackSize; + return returned == null || returned.getCount() < stack.getCount(); } public static ItemStack getToUse(ItemStack stack, ItemStack returned) { - if(returned == null || returned.stackSize == 0) + if(returned == null || returned.getCount() == 0) { return stack; } - return MekanismUtils.size(stack, stack.stackSize-returned.stackSize); + return MekanismUtils.size(stack, stack.getCount()-returned.getCount()); } /** @@ -366,31 +366,31 @@ public class TransporterManager } else if(inSlot == null) { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) + if(toInsert.getCount() <= inventory.getInventoryStackLimit()) { return null; } else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inventory.getInventoryStackLimit(); - if(rejects < toInsert.stackSize) + if(rejects < toInsert.getCount()) { toInsert = StackUtils.size(toInsert, rejects); } } } - else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { return null; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; - if(rejects < toInsert.stackSize) + if(rejects < toInsert.getCount()) { toInsert = StackUtils.size(toInsert, rejects); } @@ -415,12 +415,12 @@ public class TransporterManager int amountRemaining = ((TileEntityBin)inventory).getMaxStoredCount()-copy.binAmount; - if(toInsert.stackSize <= amountRemaining) + if(toInsert.getCount() <= amountRemaining) { return null; } else { - return StackUtils.size(toInsert, toInsert.stackSize-amountRemaining); + return StackUtils.size(toInsert, toInsert.getCount()-amountRemaining); } } else { @@ -441,31 +441,31 @@ public class TransporterManager } else if(inSlot == null) { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) + if(toInsert.getCount() <= inventory.getInventoryStackLimit()) { return null; } else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inventory.getInventoryStackLimit(); - if(rejects < toInsert.stackSize) + if(rejects < toInsert.getCount()) { toInsert = StackUtils.size(toInsert, rejects); } } } - else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { return null; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; - if(rejects < toInsert.stackSize) + if(rejects < toInsert.getCount()) { toInsert = StackUtils.size(toInsert, rejects); } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java index 3c9561a44..10c242c82 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java @@ -300,7 +300,7 @@ public final class TransporterPathfinder if(p.getPath().size() >= 2) { - if(TransporterManager.getToUse(stack.itemStack, rejects).stackSize >= min) + if(TransporterManager.getToUse(stack.itemStack, rejects).getCount() >= min) { PathfinderCache.cachedPaths.put(new PathData(start.coord(), dest, p.side), p.getPath()); diff --git a/src/main/java/mekanism/common/content/transporter/TransporterStack.java b/src/main/java/mekanism/common/content/transporter/TransporterStack.java index bd56f1931..70c7b0b31 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterStack.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterStack.java @@ -13,6 +13,7 @@ import mekanism.common.base.ILogisticalTransporter; import mekanism.common.capabilities.Capabilities; import mekanism.common.content.transporter.TransporterPathfinder.Destination; import mekanism.common.tile.TileEntityLogisticalSorter; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.TransporterUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -142,7 +143,7 @@ public class TransporterStack } pathType = Path.values()[nbtTags.getInteger("pathType")]; - itemStack = ItemStack.loadItemStackFromNBT(nbtTags); + itemStack = InventoryUtils.loadFromNBT(nbtTags); } public static TransporterStack readFromNBT(NBTTagCompound nbtTags) diff --git a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java index 9bbe19b25..99c9efac8 100644 --- a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java +++ b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java @@ -31,7 +31,7 @@ public class EntityBabySkeleton extends EntitySkeleton { dataManager.set(IS_CHILD, child); - if(worldObj != null && !worldObj.isRemote) + if(world != null && !world.isRemote) { IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.removeModifier(babySpeedBoostModifier); diff --git a/src/main/java/mekanism/common/entity/EntityBalloon.java b/src/main/java/mekanism/common/entity/EntityBalloon.java index 18453d922..b49b3e394 100644 --- a/src/main/java/mekanism/common/entity/EntityBalloon.java +++ b/src/main/java/mekanism/common/entity/EntityBalloon.java @@ -13,6 +13,7 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleRedstone; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.MoverType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; @@ -75,7 +76,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData public EntityBalloon(EntityLivingBase entity, EnumColor c) { - this(entity.worldObj); + this(entity.world); latchedEntity = entity; setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); @@ -122,11 +123,11 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData return; } - if(worldObj.isRemote) + if(world.isRemote) { if(dataManager.get(IS_LATCHED) == 1) { - latched = new Coord4D((int)dataManager.get(LATCHED_X), (int)dataManager.get(LATCHED_Y), (int)dataManager.get(LATCHED_Z), worldObj.provider.getDimension()); + latched = new Coord4D((int)dataManager.get(LATCHED_X), (int)dataManager.get(LATCHED_Y), (int)dataManager.get(LATCHED_Z), world.provider.getDimension()); } else { latched = null; @@ -134,7 +135,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData if(dataManager.get(IS_LATCHED) == 2) { - latchedEntity = (EntityLivingBase)worldObj.getEntityByID(dataManager.get(LATCHED_ID)); + latchedEntity = (EntityLivingBase)world.getEntityByID(dataManager.get(LATCHED_ID)); } else { latchedEntity = null; @@ -158,16 +159,16 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } } - if(!worldObj.isRemote) + if(!world.isRemote) { - if(latched != null && (latched.exists(worldObj) && latched.isAirBlock(worldObj))) + if(latched != null && (latched.exists(world) && latched.isAirBlock(world))) { latched = null; dataManager.set(IS_LATCHED, (byte)0); } - if(latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !worldObj.loadedEntityList.contains(latchedEntity))) + if(latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !world.loadedEntityList.contains(latchedEntity))) { latchedEntity = null; @@ -179,7 +180,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { motionY = Math.min(motionY*1.02F, 0.2F); - moveEntity(motionX, motionY, motionZ); + move(MoverType.SELF, motionX, motionY, motionZ); motionX *= 0.98; motionZ *= 0.98; @@ -232,7 +233,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData for(BlockPos posi = pos; posi.getY() > 0; posi = posi.down()) { - if(posi.getY() < 256 && !worldObj.isAirBlock(posi)) + if(posi.getY() < 256 && !world.isAirBlock(posi)) { return posi.getY()+1+(entity instanceof EntityPlayer ? 1 : 0); } @@ -243,7 +244,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData private void findCachedEntity() { - for(Object obj : worldObj.loadedEntityList) + for(Object obj : world.loadedEntityList) { if(obj instanceof EntityLivingBase) { @@ -261,7 +262,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { playSound(MekanismSounds.POP, 1, 1); - if(worldObj.isRemote) + if(world.isRemote) { for(int i = 0; i < 10; i++) { @@ -279,7 +280,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { Pos3D pos = new Pos3D(posX + (rand.nextFloat()*.6 - 0.3), posY + (rand.nextFloat()*.6 - 0.3), posZ + (rand.nextFloat()*.6 - 0.3)); - Particle fx = new ParticleRedstone.Factory().getEntityFX(0, worldObj, pos.xCoord, pos.yCoord, pos.zCoord, 0, 0, 0); + Particle fx = new ParticleRedstone.Factory().createParticle(0, world, pos.xCoord, pos.yCoord, pos.zCoord, 0, 0, 0); fx.setRBGColorF(color.getColor(0), color.getColor(1), color.getColor(2)); Minecraft.getMinecraft().effectRenderer.addEffect(fx); @@ -387,7 +388,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData } else if(type == 2) { - latchedEntity = (EntityLivingBase)worldObj.getEntityByID(data.readInt()); + latchedEntity = (EntityLivingBase)world.getEntityByID(data.readInt()); } else { latched = null; @@ -427,7 +428,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData else { setBeenAttacked(); - if(dmgSource != DamageSource.magic && dmgSource != DamageSource.drown && dmgSource != DamageSource.fall) + if(dmgSource != DamageSource.MAGIC && dmgSource != DamageSource.DROWN && dmgSource != DamageSource.FALL) { pop(); return true; @@ -439,7 +440,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData public boolean isLatched() { - if(!worldObj.isRemote) + if(!world.isRemote) { return latched != null || latchedEntity != null; } diff --git a/src/main/java/mekanism/common/entity/EntityFlame.java b/src/main/java/mekanism/common/entity/EntityFlame.java index b8a3e4aba..7304fbf66 100644 --- a/src/main/java/mekanism/common/entity/EntityFlame.java +++ b/src/main/java/mekanism/common/entity/EntityFlame.java @@ -47,7 +47,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData public EntityFlame(EntityPlayer player) { - this(player.worldObj); + this(player.world); Pos3D playerPos = new Pos3D(player).translate(0, 1.6, 0); Pos3D flameVec = new Pos3D(1, 1, 1); @@ -71,7 +71,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData public void setHeading(Pos3D motion) { - float d = MathHelper.sqrt_double((motion.xCoord * motion.xCoord) + (motion.zCoord * motion.zCoord)); + float d = MathHelper.sqrt((motion.xCoord * motion.xCoord) + (motion.zCoord * motion.zCoord)); prevRotationYaw = rotationYaw = (float)(Math.atan2(motion.xCoord, motion.zCoord) * 180.0D / Math.PI); prevRotationPitch = rotationPitch = (float)(Math.atan2(motion.yCoord, d) * 180.0D / Math.PI); @@ -113,7 +113,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { Vec3d localVec = new Vec3d(posX, posY, posZ); Vec3d motionVec = new Vec3d(posX + motionX*2, posY + motionY*2, posZ + motionZ*2); - RayTraceResult mop = worldObj.rayTraceBlocks(localVec, motionVec, true, false, false); + RayTraceResult mop = world.rayTraceBlocks(localVec, motionVec, true, false, false); localVec = new Vec3d(posX, posY, posZ); motionVec = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ); @@ -123,7 +123,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData } Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + List list = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); double entityDist = 0.0D; int i; @@ -183,19 +183,19 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData } else if(mop.typeOfHit == Type.BLOCK) { - IBlockState state = worldObj.getBlockState(mop.getBlockPos()); + IBlockState state = world.getBlockState(mop.getBlockPos()); Block block = state.getBlock(); - boolean fluid = MekanismUtils.isFluid(worldObj, new Coord4D(mop, worldObj)) || MekanismUtils.isDeadFluid(worldObj, new Coord4D(mop, worldObj)); + boolean fluid = MekanismUtils.isFluid(world, new Coord4D(mop, world)) || MekanismUtils.isDeadFluid(world, new Coord4D(mop, world)); - Coord4D sideCoord = new Coord4D(mop.getBlockPos().offset(mop.sideHit), worldObj); + Coord4D sideCoord = new Coord4D(mop.getBlockPos().offset(mop.sideHit), world); - if(general.aestheticWorldDamage && !fluid && (sideCoord.isAirBlock(worldObj) || sideCoord.isReplaceable(worldObj))) + if(general.aestheticWorldDamage && !fluid && (sideCoord.isAirBlock(world) || sideCoord.isReplaceable(world))) { - if(mode != ItemFlamethrower.FlamethrowerMode.COMBAT && !smeltBlock(new Coord4D(mop, worldObj))) + if(mode != ItemFlamethrower.FlamethrowerMode.COMBAT && !smeltBlock(new Coord4D(mop, world))) { - if(mode == ItemFlamethrower.FlamethrowerMode.INFERNO && !worldObj.isRemote) + if(mode == ItemFlamethrower.FlamethrowerMode.INFERNO && !world.isRemote) { - worldObj.setBlockState(sideCoord.getPos(), Blocks.FIRE.getDefaultState()); + world.setBlockState(sideCoord.getPos(), Blocks.FIRE.getDefaultState()); } } } @@ -217,7 +217,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData if(result != null) { - item.setEntityItemStack(StackUtils.size(result, item.getEntityItem().stackSize)); + item.setEntityItemStack(StackUtils.size(result, item.getEntityItem().getCount())); item.ticksExisted = 0; spawnParticlesAt(new Pos3D(item)); @@ -231,38 +231,38 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData private boolean smeltBlock(Coord4D block) { - ItemStack stack = block.getStack(worldObj); + ItemStack stack = block.getStack(world); if(stack == null) { return false; } - ItemStack result = FurnaceRecipes.instance().getSmeltingResult(block.getStack(worldObj)); + ItemStack result = FurnaceRecipes.instance().getSmeltingResult(block.getStack(world)); if(result != null && result.getItem() != null) { - if(!worldObj.isRemote) + if(!world.isRemote) { - IBlockState state = block.getBlockState(worldObj); + IBlockState state = block.getBlockState(world); Block b = state.getBlock(); Block newBlock = Block.getBlockFromItem(result.getItem()); if(newBlock != null && newBlock != Blocks.AIR) { - worldObj.setBlockState(block.getPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 3); + world.setBlockState(block.getPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 3); } else { - worldObj.setBlockToAir(block.getPos()); + world.setBlockToAir(block.getPos()); - EntityItem item = new EntityItem(worldObj, block.xCoord + 0.5, block.yCoord + 0.5, block.zCoord + 0.5, result.copy()); + EntityItem item = new EntityItem(world, block.xCoord + 0.5, block.yCoord + 0.5, block.zCoord + 0.5, result.copy()); item.motionX = 0; item.motionY = 0; item.motionZ = 0; - worldObj.spawnEntityInWorld(item); + world.spawnEntity(item); } - worldObj.playEvent(null, 2001, block.getPos(), Block.getStateId(state)); + world.playEvent(null, 2001, block.getPos(), Block.getStateId(state)); } spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5)); @@ -294,7 +294,7 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { for(int i = 0; i < 10; i++) { - worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.xCoord + (rand.nextFloat()-0.5), pos.yCoord + (rand.nextFloat()-0.5), pos.zCoord + (rand.nextFloat()-0.5), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.xCoord + (rand.nextFloat()-0.5), pos.yCoord + (rand.nextFloat()-0.5), pos.zCoord + (rand.nextFloat()-0.5), 0, 0, 0); } } diff --git a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java index 79b008e41..d92cf84f2 100644 --- a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java +++ b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java @@ -2,6 +2,7 @@ package mekanism.common.entity; import mekanism.api.MekanismConfig.general; import net.minecraft.entity.Entity; +import net.minecraft.entity.MoverType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; @@ -71,7 +72,7 @@ public class EntityObsidianTNT extends Entity motionY -= 0.04; - moveEntity(motionX, motionY, motionZ); + move(MoverType.SELF, motionX, motionY, motionZ); motionX *= 0.98; motionY *= 0.98; @@ -86,7 +87,7 @@ public class EntityObsidianTNT extends Entity if(fuse-- <= 0) { - if(!worldObj.isRemote) + if(!world.isRemote) { setDead(); explode(); @@ -97,18 +98,18 @@ public class EntityObsidianTNT extends Entity setDead(); } else { - worldObj.spawnParticle(EnumParticleTypes.LAVA, posX, posY + 0.5, posZ, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.LAVA, posX, posY + 0.5, posZ, 0, 0, 0); } } } else { - worldObj.spawnParticle(EnumParticleTypes.LAVA, posX, posY + 0.5, posZ, 0, 0, 0); + world.spawnParticle(EnumParticleTypes.LAVA, posX, posY + 0.5, posZ, 0, 0, 0); } } private void explode() { - worldObj.createExplosion(null, posX, posY, posZ, general.obsidianTNTBlastRadius, true); + world.createExplosion(null, posX, posY, posZ, general.obsidianTNTBlastRadius, true); hasExploded = true; } diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index 124091cfe..76e90b88e 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -13,12 +13,13 @@ import mekanism.api.energy.EnergizedItemManager; import mekanism.api.energy.IEnergizedItem; import mekanism.common.Mekanism; import mekanism.common.MekanismItems; -import mekanism.common.RobitAIFollow; -import mekanism.common.RobitAIPickup; import mekanism.common.base.ISustainedInventory; +import mekanism.common.entity.ai.RobitAIFollow; +import mekanism.common.entity.ai.RobitAIPickup; import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemRobit; import mekanism.common.tile.TileEntityChargepad; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import micdoodle8.mods.galacticraft.api.entity.IEntityBreathable; import net.minecraft.entity.EntityCreature; @@ -140,7 +141,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine @Override public void onEntityUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { if(getFollowing() && getOwner() != null && getDistanceSqToEntity(getOwner()) > 4 && !getNavigator().noPath() && getEnergy() > 0) { @@ -150,7 +151,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine super.onEntityUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(getDropPickup()) { @@ -206,9 +207,9 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine else if(inventory[27].getItem() == Items.REDSTONE && getEnergy()+ general.ENERGY_PER_REDSTONE <= MAX_ELECTRICITY) { setEnergy(getEnergy() + general.ENERGY_PER_REDSTONE); - inventory[27].stackSize--; + inventory[27].shrink(1); - if(inventory[27].stackSize <= 0) + if(inventory[27].getCount() <= 0) { inventory[27] = null; } @@ -220,7 +221,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine furnaceBurnTime--; } - if(!worldObj.isRemote) + if(!world.isRemote) { if(furnaceBurnTime == 0 && canSmelt()) { @@ -230,9 +231,9 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { if(inventory[29] != null) { - inventory[29].stackSize--; + inventory[29].shrink(1); - if(inventory[29].stackSize == 0) + if(inventory[29].getCount() == 0) { inventory[29] = inventory[29].getItem().getContainerItem(inventory[29]); } @@ -259,7 +260,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine private void collectItems() { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, getEntityBoundingBox().expand(1.5, 1.5, 1.5)); + List items = world.getEntitiesWithinAABB(EntityItem.class, getEntityBoundingBox().expand(1.5, 1.5, 1.5)); if(items != null && !items.isEmpty()) { @@ -277,24 +278,24 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if(itemStack == null) { inventory[i] = item.getEntityItem(); - onItemPickup(item, item.getEntityItem().stackSize); + onItemPickup(item, item.getEntityItem().getCount()); item.setDead(); playSound(SoundEvents.ENTITY_ITEM_PICKUP, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); break; } - else if(itemStack.isItemEqual(item.getEntityItem()) && itemStack.stackSize < itemStack.getMaxStackSize()) + else if(itemStack.isItemEqual(item.getEntityItem()) && itemStack.getCount() < itemStack.getMaxStackSize()) { - int needed = itemStack.getMaxStackSize() - itemStack.stackSize; - int toAdd = Math.min(needed, item.getEntityItem().stackSize); + int needed = itemStack.getMaxStackSize() - itemStack.getCount(); + int toAdd = Math.min(needed, item.getEntityItem().getCount()); - itemStack.stackSize += toAdd; - item.getEntityItem().stackSize -= toAdd; + itemStack.grow(toAdd); + item.getEntityItem().shrink(toAdd); onItemPickup(item, toAdd); - if(item.getEntityItem().stackSize == 0) + if(item.getEntityItem().getCount() == 0) { item.setDead(); } @@ -312,7 +313,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { setFollowing(false); - if(worldObj.provider.getDimension() != homeLocation.dimensionId) + if(world.provider.getDimension() != homeLocation.dimensionId) { changeDimension(homeLocation.dimensionId); } @@ -335,7 +336,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if(itemstack == null) return false; if(inventory[30] == null) return true; if(!inventory[30].isItemEqual(itemstack)) return false; - int result = inventory[30].stackSize + itemstack.stackSize; + int result = inventory[30].getCount() + itemstack.getCount(); return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } } @@ -352,12 +353,12 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } else if(inventory[30].isItemEqual(itemstack)) { - inventory[30].stackSize += itemstack.stackSize; + inventory[30].grow(itemstack.getCount()); } - inventory[28].stackSize--; + inventory[28].shrink(1); - if(inventory[28].stackSize <= 0) + if(inventory[28].getCount() <= 0) { inventory[28] = null; } @@ -368,7 +369,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { BlockPos pos = new BlockPos(this); - if(worldObj.getTileEntity(pos) instanceof TileEntityChargepad) + if(world.getTileEntity(pos) instanceof TileEntityChargepad) { return true; } @@ -377,13 +378,15 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } @Override - public EnumActionResult applyPlayerInteraction(EntityPlayer entityplayer, Vec3d vec, ItemStack stack, EnumHand hand) + public EnumActionResult applyPlayerInteraction(EntityPlayer entityplayer, Vec3d vec, EnumHand hand) { + ItemStack stack = entityplayer.getHeldItem(hand); + if(entityplayer.isSneaking()) { if(stack != null && stack.getItem() instanceof ItemConfigurator) { - if(!worldObj.isRemote) + if(!world.isRemote) { drop(); } @@ -395,7 +398,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine } } else { - entityplayer.openGui(Mekanism.instance, 21, worldObj, getEntityId(), 0, 0); + entityplayer.openGui(Mekanism.instance, 21, world, getEntityId(), 0, 0); return EnumActionResult.SUCCESS; } @@ -404,7 +407,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void drop() { - EntityItem entityItem = new EntityItem(worldObj, posX, posY+0.3, posZ, new ItemStack(MekanismItems.Robit)); + EntityItem entityItem = new EntityItem(world, posX, posY+0.3, posZ, new ItemStack(MekanismItems.Robit)); ItemRobit item = (ItemRobit)entityItem.getEntityItem().getItem(); item.setEnergy(entityItem.getEntityItem(), getEnergy()); @@ -416,7 +419,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine entityItem.motionY = rand.nextGaussian() * k + 0.2F; entityItem.motionZ = 0; - worldObj.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } @Override @@ -488,7 +491,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if(slotID >= 0 && slotID < inventory.length) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } } @@ -537,7 +540,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public EntityPlayer getOwner() { - return worldObj.getPlayerEntityByName(getOwnerName()); + return world.getPlayerEntityByName(getOwnerName()); } public String getOwnerName() @@ -589,7 +592,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { ItemStack tempStack; - if(getStackInSlot(slotID).stackSize <= amount) + if(getStackInSlot(slotID).getCount() <= amount) { tempStack = getStackInSlot(slotID); setInventorySlotContents(slotID, null); @@ -598,7 +601,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine else { tempStack = getStackInSlot(slotID).splitStack(amount); - if(getStackInSlot(slotID).stackSize == 0) + if(getStackInSlot(slotID).getCount() == 0) { setInventorySlotContents(slotID, null); } @@ -630,9 +633,9 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine { inventory[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if(itemstack != null && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.setCount(getInventoryStackLimit()); } } @@ -646,7 +649,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void markDirty() {} @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUsableByPlayer(EntityPlayer entityplayer) { return true; } @@ -698,7 +701,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine if(slotID >= 0 && slotID < inventory.length) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } } @@ -721,6 +724,20 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine return tagList; } + + @Override + public boolean isEmpty() + { + for(ItemStack stack : inventory) + { + if(stack != null) + { + return false; + } + } + + return true; + } @Override public boolean canBreath() diff --git a/src/main/java/mekanism/common/RobitAIFollow.java b/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java similarity index 82% rename from src/main/java/mekanism/common/RobitAIFollow.java rename to src/main/java/mekanism/common/entity/ai/RobitAIFollow.java index a40c324c4..3ad3e1848 100644 --- a/src/main/java/mekanism/common/RobitAIFollow.java +++ b/src/main/java/mekanism/common/entity/ai/RobitAIFollow.java @@ -1,4 +1,4 @@ -package mekanism.common; +package mekanism.common.entity.ai; import mekanism.common.entity.EntityRobit; import net.minecraft.block.Block; @@ -22,7 +22,7 @@ public class RobitAIFollow extends EntityAIBase private EntityPlayer theOwner; /** The world the robit is located in. */ - private World theWorld; + private World world; /** How fast the robit can travel. */ private float moveSpeed; @@ -44,7 +44,7 @@ public class RobitAIFollow extends EntityAIBase public RobitAIFollow(EntityRobit entityRobit, float speed, float min, float max) { theRobit = entityRobit; - theWorld = entityRobit.worldObj; + world = entityRobit.world; moveSpeed = speed; thePathfinder = entityRobit.getNavigator(); minDist = min; @@ -60,7 +60,7 @@ public class RobitAIFollow extends EntityAIBase { return false; } - else if(theRobit.worldObj.provider.getDimension() != player.worldObj.provider.getDimension()) + else if(theRobit.world.provider.getDimension() != player.world.provider.getDimension()) { return false; } @@ -88,7 +88,7 @@ public class RobitAIFollow extends EntityAIBase @Override public boolean continueExecuting() { - return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.worldObj.provider.getDimension() == theRobit.worldObj.provider.getDimension(); + return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.world.provider.getDimension() == theRobit.world.provider.getDimension(); } @Override @@ -122,9 +122,9 @@ public class RobitAIFollow extends EntityAIBase { if(theRobit.getDistanceSqToEntity(theOwner) >= 144.0D) { - int x = MathHelper.floor_double(theOwner.posX) - 2; - int y = MathHelper.floor_double(theOwner.getEntityBoundingBox().minY); - int z = MathHelper.floor_double(theOwner.posZ) - 2; + int x = MathHelper.floor(theOwner.posX) - 2; + int y = MathHelper.floor(theOwner.getEntityBoundingBox().minY); + int z = MathHelper.floor(theOwner.posZ) - 2; for(int l = 0; l <= 4; ++l) { @@ -133,7 +133,7 @@ public class RobitAIFollow extends EntityAIBase BlockPos pos = new BlockPos(x+l, y, z+i1); BlockPos under = new BlockPos(x + l, y - 1, z + i1); - if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.getBlockState(under).isSideSolid(theWorld, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) + if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under).isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) { theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); thePathfinder.clearPathEntity(); @@ -149,7 +149,7 @@ public class RobitAIFollow extends EntityAIBase private boolean isEmptyBlock(BlockPos pos) { - IBlockState iblockstate = theWorld.getBlockState(pos); + IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); return block == Blocks.AIR ? true : !iblockstate.isFullCube(); diff --git a/src/main/java/mekanism/common/RobitAIPickup.java b/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java similarity index 81% rename from src/main/java/mekanism/common/RobitAIPickup.java rename to src/main/java/mekanism/common/entity/ai/RobitAIPickup.java index fbc6af267..240bc70ac 100644 --- a/src/main/java/mekanism/common/RobitAIPickup.java +++ b/src/main/java/mekanism/common/entity/ai/RobitAIPickup.java @@ -1,4 +1,4 @@ -package mekanism.common; +package mekanism.common.entity.ai; import java.util.Iterator; import java.util.List; @@ -27,7 +27,7 @@ public class RobitAIPickup extends EntityAIBase private EntityRobit theRobit; /** The world the robit is located in. */ - private World theWorld; + private World world; /** How fast the robit can travel. */ private float moveSpeed; @@ -45,7 +45,7 @@ public class RobitAIPickup extends EntityAIBase public RobitAIPickup(EntityRobit entityRobit, float speed) { theRobit = entityRobit; - theWorld = entityRobit.worldObj; + world = entityRobit.world; moveSpeed = speed; thePathfinder = entityRobit.getNavigator(); } @@ -63,7 +63,7 @@ public class RobitAIPickup extends EntityAIBase return true; } - List items = theRobit.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(theRobit.posX-10, theRobit.posY-10, theRobit.posZ-10, theRobit.posX+10, theRobit.posY+10, theRobit.posZ+10)); + List items = theRobit.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(theRobit.posX-10, theRobit.posY-10, theRobit.posZ-10, theRobit.posX+10, theRobit.posY+10, theRobit.posZ+10)); Iterator iter = items.iterator(); //Cached for slight performance double closestDistance = -1; @@ -100,7 +100,7 @@ public class RobitAIPickup extends EntityAIBase @Override public boolean continueExecuting() { - return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(closest) > 100 && theRobit.getDropPickup() && theRobit.getEnergy() > 0 && closest.worldObj.provider.getDimension() == theRobit.worldObj.provider.getDimension(); + return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(closest) > 100 && theRobit.getDropPickup() && theRobit.getEnergy() > 0 && closest.world.provider.getDimension() == theRobit.world.provider.getDimension(); } @Override @@ -136,9 +136,9 @@ public class RobitAIPickup extends EntityAIBase { if(theRobit.getDistanceSqToEntity(closest) >= 144.0D) { - int x = MathHelper.floor_double(closest.posX) - 2; - int y = MathHelper.floor_double(closest.getEntityBoundingBox().minY); - int z = MathHelper.floor_double(closest.posZ) - 2; + int x = MathHelper.floor(closest.posX) - 2; + int y = MathHelper.floor(closest.getEntityBoundingBox().minY); + int z = MathHelper.floor(closest.posZ) - 2; for(int l = 0; l <= 4; ++l) { @@ -147,7 +147,7 @@ public class RobitAIPickup extends EntityAIBase BlockPos pos = new BlockPos(x+l, y, z+i1); BlockPos under = new BlockPos(x + l, y - 1, z + i1); - if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.getBlockState(under).isSideSolid(theWorld, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) + if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && world.getBlockState(under).isSideSolid(world, under, EnumFacing.UP) && isEmptyBlock(pos) && isEmptyBlock(new BlockPos(x + l, y + 1, z + i1))) { theRobit.setLocationAndAngles((x + l) + 0.5F, y, (z + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); thePathfinder.clearPathEntity(); @@ -163,7 +163,7 @@ public class RobitAIPickup extends EntityAIBase private boolean isEmptyBlock(BlockPos pos) { - IBlockState iblockstate = theWorld.getBlockState(pos); + IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); return block == Blocks.AIR ? true : !iblockstate.isFullCube(); diff --git a/src/main/java/mekanism/common/inventory/InventoryBin.java b/src/main/java/mekanism/common/inventory/InventoryBin.java index cc3a39030..e9e5313d3 100644 --- a/src/main/java/mekanism/common/inventory/InventoryBin.java +++ b/src/main/java/mekanism/common/inventory/InventoryBin.java @@ -4,6 +4,7 @@ import mekanism.api.util.StackUtils; import mekanism.common.Tier.BinTier; import mekanism.common.base.ITierItem; import mekanism.common.block.states.BlockStateBasic.BasicBlockType; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.ItemDataUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -22,7 +23,7 @@ public class InventoryBin if(getItemCount() > 0 && getItemType() != null) { ItemStack ret = getItemType().copy(); - ret.stackSize = Math.min(getItemType().getMaxStackSize(), getItemCount()); + ret.setCount(Math.min(getItemType().getMaxStackSize(), getItemCount())); return ret; } @@ -41,7 +42,7 @@ public class InventoryBin if(getTier() != BinTier.CREATIVE) { - setItemCount(getItemCount() - stack.stackSize); + setItemCount(getItemCount() - stack.getCount()); } return stack.copy(); @@ -58,14 +59,14 @@ public class InventoryBin if(getTier() != BinTier.CREATIVE) { - if(getItemCount() + stack.stackSize <= getMaxStorage()) + if(getItemCount() + stack.getCount() <= getMaxStorage()) { - setItemCount(getItemCount() + stack.stackSize); + setItemCount(getItemCount() + stack.getCount()); return null; } else { ItemStack rejects = getItemType().copy(); - rejects.stackSize = (getItemCount()+stack.stackSize) - getMaxStorage(); + rejects.setCount((getItemCount()+stack.getCount()) - getMaxStorage()); setItemCount(getMaxStorage()); @@ -82,7 +83,7 @@ public class InventoryBin public boolean isValid(ItemStack stack) { - if(stack == null || stack.stackSize <= 0) + if(stack == null || stack.getCount() <= 0) { return false; } @@ -137,7 +138,7 @@ public class InventoryBin return null; } - return ItemStack.loadItemStackFromNBT(ItemDataUtils.getCompound(bin, "storedItem")); + return InventoryUtils.loadFromNBT(ItemDataUtils.getCompound(bin, "storedItem")); } public void setItemType(ItemStack stack) diff --git a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java index 39da19070..a8950379f 100644 --- a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java @@ -1,6 +1,7 @@ package mekanism.common.inventory; import mekanism.common.base.ISustainedInventory; +import mekanism.common.util.InventoryUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.ItemStack; @@ -98,7 +99,7 @@ public class InventoryPersonalChest extends InventoryBasic if(slotID >= 0 && slotID < getSizeInventory()) { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); + setInventorySlotContents(slotID, InventoryUtils.loadFromNBT(tagCompound)); } } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index cd8b22f0c..ae4d162d5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -56,7 +56,7 @@ public class ContainerAdvancedElectricMachine extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -148,7 +148,7 @@ public class ContainerAdvancedElectricMachine extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -156,12 +156,12 @@ public class ContainerAdvancedElectricMachine extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java index b2a2db59a..9c5332d7e 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java @@ -55,7 +55,7 @@ public class ContainerChanceMachine extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -132,7 +132,7 @@ public class ContainerChanceMachine extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -140,12 +140,12 @@ public class ContainerChanceMachine extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java index 1dd32d5ff..4a126433f 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java @@ -54,7 +54,7 @@ public class ContainerChemicalCrystallizer extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -131,7 +131,7 @@ public class ContainerChemicalCrystallizer extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -139,12 +139,12 @@ public class ContainerChemicalCrystallizer extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java index 6f471c1c6..d35ddf5f5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java @@ -56,7 +56,7 @@ public class ContainerChemicalDissolutionChamber extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -145,7 +145,7 @@ public class ContainerChemicalDissolutionChamber extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -153,12 +153,12 @@ public class ContainerChemicalDissolutionChamber extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java index 634d69128..87c986e70 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java @@ -54,7 +54,7 @@ public class ContainerChemicalInfuser extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -124,7 +124,7 @@ public class ContainerChemicalInfuser extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -132,12 +132,12 @@ public class ContainerChemicalInfuser extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java index 7eea1d294..81e1fa5df 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java @@ -55,7 +55,7 @@ public class ContainerChemicalOxidizer extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -142,7 +142,7 @@ public class ContainerChemicalOxidizer extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -150,12 +150,12 @@ public class ContainerChemicalOxidizer extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java index 3960c3424..ce6c03d68 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java @@ -57,7 +57,7 @@ public class ContainerChemicalWasher extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -150,7 +150,7 @@ public class ContainerChemicalWasher extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -158,12 +158,12 @@ public class ContainerChemicalWasher extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java b/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java index 231ffec87..3c131040d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java @@ -64,7 +64,7 @@ public class ContainerDictionary extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -72,12 +72,12 @@ public class ContainerDictionary extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java index bb64f0c33..682205732 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -58,7 +58,7 @@ public class ContainerDigitalMiner extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerDigitalMiner extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerDigitalMiner extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java b/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java index 3dc9027f0..6de70e680 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java @@ -50,7 +50,7 @@ public class ContainerDynamicTank extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerDynamicTank extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerDynamicTank extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java index 1cea3ef0e..64972e635 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java @@ -54,7 +54,7 @@ public class ContainerElectricMachine extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -131,7 +131,7 @@ public class ContainerElectricMachine extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -139,12 +139,12 @@ public class ContainerElectricMachine extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java b/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java index 8587beb6b..4ef0d2251 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java @@ -54,7 +54,7 @@ public class ContainerElectricPump extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -131,7 +131,7 @@ public class ContainerElectricPump extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -139,12 +139,12 @@ public class ContainerElectricPump extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java b/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java index 3ef39d7ca..78034ffe4 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java @@ -56,7 +56,7 @@ public class ContainerElectrolyticSeparator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -146,7 +146,7 @@ public class ContainerElectrolyticSeparator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -154,12 +154,12 @@ public class ContainerElectrolyticSeparator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java index f91b6ff93..65839058b 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -55,7 +55,7 @@ public class ContainerEnergyCube extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -162,7 +162,7 @@ public class ContainerEnergyCube extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -170,12 +170,12 @@ public class ContainerEnergyCube extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java index cb038eda4..5381cea31 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java @@ -108,7 +108,7 @@ public class ContainerFactory extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -233,7 +233,7 @@ public class ContainerFactory extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -241,12 +241,12 @@ public class ContainerFactory extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java index f381aafec..367d129dc 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java @@ -46,7 +46,7 @@ public class ContainerFilter extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -81,7 +81,7 @@ public class ContainerFilter extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -89,12 +89,12 @@ public class ContainerFilter extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java b/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java index 88cc32cf7..d268ec10d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java @@ -50,7 +50,7 @@ public class ContainerFluidTank extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerFluidTank extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerFluidTank extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java b/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java index 1bc9db952..9fead128e 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java @@ -53,7 +53,7 @@ public class ContainerFluidicPlenisher extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -130,7 +130,7 @@ public class ContainerFluidicPlenisher extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -138,12 +138,12 @@ public class ContainerFluidicPlenisher extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java index c100f6ffd..9d4425baf 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java @@ -97,7 +97,7 @@ public class ContainerFormulaicAssemblicator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -180,7 +180,7 @@ public class ContainerFormulaicAssemblicator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -188,12 +188,12 @@ public class ContainerFormulaicAssemblicator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java b/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java index 78faf675e..e30802dd3 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java @@ -48,7 +48,7 @@ public class ContainerFuelwoodHeater extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -102,7 +102,7 @@ public class ContainerFuelwoodHeater extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -110,12 +110,12 @@ public class ContainerFuelwoodHeater extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java b/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java index ec318d728..1a9e736d2 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java @@ -50,7 +50,7 @@ public class ContainerGasTank extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -107,7 +107,7 @@ public class ContainerGasTank extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -115,12 +115,12 @@ public class ContainerGasTank extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java b/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java index d2db3283d..7a79d6295 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java @@ -54,7 +54,7 @@ public class ContainerInductionMatrix extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -161,7 +161,7 @@ public class ContainerInductionMatrix extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -169,12 +169,12 @@ public class ContainerInductionMatrix extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java index 3e0d0358e..42698157a 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java @@ -46,7 +46,7 @@ public class ContainerLaserAmplifier extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -81,7 +81,7 @@ public class ContainerLaserAmplifier extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -89,12 +89,12 @@ public class ContainerLaserAmplifier extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java b/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java index 63a1188d8..8aa0d9547 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java @@ -53,7 +53,7 @@ public class ContainerLaserTractorBeam extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -79,7 +79,7 @@ public class ContainerLaserTractorBeam extends Container return null; } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -87,12 +87,12 @@ public class ContainerLaserTractorBeam extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index 40449a222..4b874e610 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -57,7 +57,7 @@ public class ContainerMetallurgicInfuser extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -124,7 +124,7 @@ public class ContainerMetallurgicInfuser extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -132,12 +132,12 @@ public class ContainerMetallurgicInfuser extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerNull.java b/src/main/java/mekanism/common/inventory/container/ContainerNull.java index 765a0fa85..57275199d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerNull.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerNull.java @@ -43,7 +43,7 @@ public class ContainerNull extends Container { if(tileEntity != null) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } return true; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java index 596e2b496..7ebdeb245 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java @@ -49,7 +49,7 @@ public class ContainerOredictionificator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -109,7 +109,7 @@ public class ContainerOredictionificator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -117,12 +117,12 @@ public class ContainerOredictionificator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java index 9cd5e6b45..c45bfa209 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java @@ -53,7 +53,7 @@ public class ContainerPRC extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -130,7 +130,7 @@ public class ContainerPRC extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -138,12 +138,12 @@ public class ContainerPRC extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java index dddc5e0fa..f60a03527 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java @@ -89,7 +89,7 @@ public class ContainerPersonalChest extends Container { if(isBlock) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } return true; @@ -118,7 +118,7 @@ public class ContainerPersonalChest extends Container return null; } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -126,12 +126,12 @@ public class ContainerPersonalChest extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java index 94fb19314..ed8b49a47 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java @@ -46,7 +46,7 @@ public class ContainerQuantumEntangloporter extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -81,7 +81,7 @@ public class ContainerQuantumEntangloporter extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -89,12 +89,12 @@ public class ContainerQuantumEntangloporter extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java index ec720df2d..00272ebae 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java @@ -49,7 +49,7 @@ public class ContainerResistiveHeater extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerResistiveHeater extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerResistiveHeater extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java index 03a75e5a5..9c780c5ec 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java @@ -12,7 +12,7 @@ public class ContainerRobitCrafting extends ContainerWorkbench public ContainerRobitCrafting(InventoryPlayer inventory, EntityRobit entity) { - super(inventory, entity.worldObj, BlockPos.ORIGIN); + super(inventory, entity.world, BlockPos.ORIGIN); robit = entity; } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java index e0f418a14..4918e109b 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java @@ -69,7 +69,7 @@ public class ContainerRobitInventory extends Container return null; } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -77,12 +77,12 @@ public class ContainerRobitInventory extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java index a98e6eaaf..193ed3e2c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java @@ -12,7 +12,7 @@ public class ContainerRobitRepair extends ContainerRepair public ContainerRobitRepair(InventoryPlayer inventory, EntityRobit entity) { - super(inventory, entity.worldObj, BlockPos.ORIGIN, inventory.player); + super(inventory, entity.world, BlockPos.ORIGIN, inventory.player); robit = entity; } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java index a7e2ef5fd..6ae1fc800 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java @@ -159,7 +159,7 @@ public class ContainerRobitSmelting extends Container return null; } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack(null); } @@ -167,12 +167,12 @@ public class ContainerRobitSmelting extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java b/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java index a7f0708d2..dfe7c6b58 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java @@ -57,7 +57,7 @@ public class ContainerRotaryCondensentrator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -152,7 +152,7 @@ public class ContainerRotaryCondensentrator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -160,12 +160,12 @@ public class ContainerRotaryCondensentrator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java b/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java index d1bca514b..4997014f7 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java @@ -50,7 +50,7 @@ public class ContainerSecurityDesk extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerSecurityDesk extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerSecurityDesk extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java b/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java index 8abf8b2b8..d599a5bc9 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java @@ -49,7 +49,7 @@ public class ContainerSeismicVibrator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerSeismicVibrator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerSeismicVibrator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java b/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java index ec49f36cd..aa245f29d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java @@ -50,7 +50,7 @@ public class ContainerSolarNeutronActivator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -113,7 +113,7 @@ public class ContainerSolarNeutronActivator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -121,12 +121,12 @@ public class ContainerSolarNeutronActivator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java b/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java index 40e323c84..0d316eaef 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java @@ -49,7 +49,7 @@ public class ContainerTeleporter extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerTeleporter extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerTeleporter extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java index c5260eb72..c1cd61d72 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java @@ -54,7 +54,7 @@ public class ContainerThermalEvaporationController extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -132,7 +132,7 @@ public class ContainerThermalEvaporationController extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -140,12 +140,12 @@ public class ContainerThermalEvaporationController extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java b/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java index 46b7a0615..a00733463 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java @@ -50,7 +50,7 @@ public class ContainerUpgradeManagement extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return ((TileEntityContainerBlock)tileEntity).isUseableByPlayer(entityplayer); + return ((TileEntityContainerBlock)tileEntity).isUsableByPlayer(entityplayer); } @Override @@ -103,7 +103,7 @@ public class ContainerUpgradeManagement extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -111,12 +111,12 @@ public class ContainerUpgradeManagement extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/common/item/ItemAlloy.java b/src/main/java/mekanism/common/item/ItemAlloy.java index dca1f8087..0952825ac 100644 --- a/src/main/java/mekanism/common/item/ItemAlloy.java +++ b/src/main/java/mekanism/common/item/ItemAlloy.java @@ -22,9 +22,10 @@ public class ItemAlloy extends ItemMekanism } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(pos); + ItemStack stack = player.getHeldItem(hand); if(general.allowTransmitterAlloyUpgrade && CapabilityUtils.hasCapability(tile, Capabilities.ALLOY_INTERACTION_CAPABILITY, side)) { diff --git a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java index f8859f225..ecc3718ea 100644 --- a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java +++ b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java @@ -114,9 +114,9 @@ public class ItemAtomicDisassembler extends ItemEnergized { super.onBlockStartBreak(itemstack, pos, player); - if(!player.worldObj.isRemote) + if(!player.world.isRemote) { - IBlockState state = player.worldObj.getBlockState(pos); + IBlockState state = player.world.getBlockState(pos); Block block = state.getBlock(); int meta = block.getMetaFromState(state); @@ -126,7 +126,7 @@ public class ItemAtomicDisassembler extends ItemEnergized } ItemStack stack = new ItemStack(block, 1, meta); - Coord4D orig = new Coord4D(pos, player.worldObj); + Coord4D orig = new Coord4D(pos, player.world); List names = MekanismUtils.getOreDictName(stack); @@ -142,7 +142,7 @@ public class ItemAtomicDisassembler extends ItemEnergized if(getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) { - Set found = new Finder(player.worldObj, stack, new Coord4D(pos, player.worldObj)).calc(); + Set found = new Finder(player.world, stack, new Coord4D(pos, player.world)).calc(); for(Coord4D coord : found) { @@ -151,13 +151,13 @@ public class ItemAtomicDisassembler extends ItemEnergized continue; } - Block block2 = coord.getBlock(player.worldObj); + Block block2 = coord.getBlock(player.world); - block2.onBlockDestroyedByPlayer(player.worldObj, coord.getPos(), state); - player.worldObj.playEvent(null, 2001, coord.getPos(), Block.getStateId(state)); - player.worldObj.setBlockToAir(coord.getPos()); - block2.breakBlock(player.worldObj, coord.getPos(), state); - block2.dropBlockAsItem(player.worldObj, coord.getPos(), state, 0); + block2.onBlockDestroyedByPlayer(player.world, coord.getPos(), state); + player.world.playEvent(null, 2001, coord.getPos(), Block.getStateId(state)); + player.world.setBlockToAir(coord.getPos()); + block2.breakBlock(player.world, coord.getPos(), state); + block2.dropBlockAsItem(player.world, coord.getPos(), state, 0); setEnergy(itemstack, getEnergy(itemstack) - (general.DISASSEMBLER_USAGE*getEfficiency(itemstack))); } @@ -174,20 +174,24 @@ public class ItemAtomicDisassembler extends ItemEnergized } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { + ItemStack itemstack = entityplayer.getHeldItem(hand); + if(!world.isRemote && entityplayer.isSneaking()) { toggleMode(itemstack); - entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.modeToggle") + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")")); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.modeToggle") + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")")); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + if(!player.isSneaking()) { if(useHoe(stack, player, world, pos, side) == EnumActionResult.FAIL) @@ -342,7 +346,7 @@ public class ItemAtomicDisassembler extends ItemEnergized if(equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D, 0)); } return multimap; diff --git a/src/main/java/mekanism/common/item/ItemBalloon.java b/src/main/java/mekanism/common/item/ItemBalloon.java index 64775cac9..4ca5187e9 100644 --- a/src/main/java/mekanism/common/item/ItemBalloon.java +++ b/src/main/java/mekanism/common/item/ItemBalloon.java @@ -20,6 +20,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.translation.I18n; @@ -62,7 +63,7 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { for(int i = 0; i < EnumColor.DYES.length; i++) { @@ -78,18 +79,20 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { + ItemStack itemstack = entityplayer.getHeldItem(hand); + if(!world.isRemote) { Pos3D pos = new Pos3D(hand == EnumHand.MAIN_HAND ? -0.4 : 0.4, 0, 0.3).rotateYaw(entityplayer.renderYawOffset).translate(new Pos3D(entityplayer)); - world.spawnEntityInWorld(new EntityBalloon(world, pos.xCoord-0.5, pos.yCoord-0.25, pos.zCoord-0.5, getColor(itemstack))); + world.spawnEntity(new EntityBalloon(world, pos.xCoord-0.5, pos.yCoord-0.25, pos.zCoord-0.5, getColor(itemstack))); } if(!entityplayer.capabilities.isCreativeMode) { - itemstack.stackSize--; + itemstack.shrink(1); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); @@ -115,13 +118,15 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); + if(player.isSneaking()) { AxisAlignedBB bound = new AxisAlignedBB(pos, pos.add(1, 3, 1)); - List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); + List balloonsNear = player.world.getEntitiesWithinAABB(EntityBalloon.class, bound); if(balloonsNear.size() > 0) { @@ -145,8 +150,8 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem if(!world.isRemote) { - world.spawnEntityInWorld(new EntityBalloon(world, new Coord4D(pos, world), getColor(stack))); - stack.stackSize--; + world.spawnEntity(new EntityBalloon(world, new Coord4D(pos, world), getColor(stack))); + stack.shrink(1); } return EnumActionResult.SUCCESS; @@ -163,11 +168,11 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem { if(player.isSneaking()) { - if(!player.worldObj.isRemote) + if(!player.world.isRemote) { AxisAlignedBB bound = new AxisAlignedBB(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, entity.posY + entity.height + 4, entity.posZ + 0.2); - List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); + List balloonsNear = player.world.getEntitiesWithinAABB(EntityBalloon.class, bound); for(EntityBalloon balloon : balloonsNear) { @@ -177,8 +182,8 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem } } - player.worldObj.spawnEntityInWorld(new EntityBalloon(entity, getColor(stack))); - stack.stackSize--; + player.world.spawnEntity(new EntityBalloon(entity, getColor(stack))); + stack.shrink(1); } return true; @@ -198,7 +203,7 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { Coord4D coord = new Coord4D(source.getX(), source.getY(), source.getZ(), source.getWorld().provider.getDimension()); - EnumFacing side = (EnumFacing)source.func_189992_e().getValue(BlockDispenser.FACING); + EnumFacing side = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING); List entities = source.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, coord.offset(side).getBoundingBox()); boolean latched = false; @@ -220,7 +225,7 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem if(!hasBalloon) { - source.getWorld().spawnEntityInWorld(new EntityBalloon(entity, getColor(stack))); + source.getWorld().spawnEntity(new EntityBalloon(entity, getColor(stack))); latched = true; } } @@ -255,11 +260,11 @@ public class ItemBalloon extends ItemMekanism implements IMetaItem if(!source.getWorld().isRemote) { - source.getWorld().spawnEntityInWorld(new EntityBalloon(source.getWorld(), pos.xCoord, pos.yCoord, pos.zCoord, getColor(stack))); + source.getWorld().spawnEntity(new EntityBalloon(source.getWorld(), pos.xCoord, pos.yCoord, pos.zCoord, getColor(stack))); } } - stack.stackSize--; + stack.shrink(1); return stack; } diff --git a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java index 4f871a523..66be6954f 100644 --- a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java +++ b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java @@ -72,8 +72,10 @@ public class ItemBlockCardboardBox extends ItemBlock } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(!player.isSneaking() && !world.isAirBlock(pos) && stack.getItemDamage() == 0) { IBlockState state = world.getBlockState(pos); @@ -99,7 +101,7 @@ public class ItemBlockCardboardBox extends ItemBlock if(!player.capabilities.isCreativeMode) { - stack.stackSize--; + stack.shrink(1); } world.setBlockState(pos, MekanismBlocks.CardboardBox.getStateFromMeta(1), 3); diff --git a/src/main/java/mekanism/common/item/ItemBlockGasTank.java b/src/main/java/mekanism/common/item/ItemBlockGasTank.java index 904d449e5..121d5a958 100644 --- a/src/main/java/mekanism/common/item/ItemBlockGasTank.java +++ b/src/main/java/mekanism/common/item/ItemBlockGasTank.java @@ -38,6 +38,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -191,7 +192,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { for(GasTankTier tier : GasTankTier.values()) { diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index e137eb02b..bc8f249a7 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -20,6 +20,7 @@ import mekanism.common.Tier.FluidTankTier; import mekanism.common.Upgrade; import mekanism.common.base.FluidItemWrapper; import mekanism.common.base.IFactory; +import mekanism.common.base.IFluidItemWrapper; import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl.RedstoneControl; import mekanism.common.base.ISideConfiguration; @@ -72,7 +73,6 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.Optional.Interface; import net.minecraftforge.fml.common.Optional.InterfaceList; @@ -128,7 +128,7 @@ import cofh.api.energy.IEnergyContainerItem; @InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) -public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, ISustainedTank, IEnergyContainerItem, IFluidContainerItem, ITierItem, ISecurityItem +public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, ISustainedTank, IEnergyContainerItem, IFluidItemWrapper, ITierItem, ISecurityItem { public Block metaBlock; @@ -270,8 +270,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack stack = player.getHeldItem(hand); MachineType type = MachineType.get(stack); if(type == MachineType.FLUID_TANK && getBucketMode(stack)) @@ -279,7 +280,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec return EnumActionResult.PASS; } - return super.onItemUse(stack, player, world, pos, hand, side, hitX, hitY, hitZ); + return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ); } @Override @@ -385,7 +386,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec factory.recipeType = recipeType; factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); factory.secondaryEnergyPerTick = factory.getSecondaryEnergyPerTick(recipeType); - world.notifyNeighborsOfStateChange(pos, tileEntity.getBlockType()); + world.notifyNeighborsOfStateChange(pos, tileEntity.getBlockType(), true); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); } @@ -453,8 +454,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { + ItemStack itemstack = entityplayer.getHeldItem(hand); MachineType type = MachineType.get(itemstack); if(MachineType.get(itemstack) == MachineType.PERSONAL_CHEST) diff --git a/src/main/java/mekanism/common/item/ItemClump.java b/src/main/java/mekanism/common/item/ItemClump.java index 7ac776fcc..ef8fb12a3 100644 --- a/src/main/java/mekanism/common/item/ItemClump.java +++ b/src/main/java/mekanism/common/item/ItemClump.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Resource; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemClump extends ItemMekanism implements IMetaItem { @@ -29,7 +28,7 @@ public class ItemClump extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < Resource.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemConfigurationCard.java b/src/main/java/mekanism/common/item/ItemConfigurationCard.java index e35011dc7..9c1788384 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurationCard.java +++ b/src/main/java/mekanism/common/item/ItemConfigurationCard.java @@ -42,8 +42,10 @@ public class ItemConfigurationCard extends ItemMekanism } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); @@ -66,7 +68,7 @@ public class ItemConfigurationCard extends ItemMekanism { data.setString("dataType", getNameFromTile(tileEntity, side)); setData(stack, data); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurationCard.got").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(data.getString("dataType")) + EnumColor.GREY))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurationCard.got").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(data.getString("dataType")) + EnumColor.GREY))); } return EnumActionResult.SUCCESS; @@ -83,11 +85,11 @@ public class ItemConfigurationCard extends ItemMekanism special.setConfigurationData(getData(stack)); } - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.DARK_GREEN + LangUtils.localize("tooltip.configurationCard.set").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(getDataType(stack)) + EnumColor.DARK_GREEN))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.DARK_GREEN + LangUtils.localize("tooltip.configurationCard.set").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(getDataType(stack)) + EnumColor.DARK_GREEN))); setData(stack, null); } else { - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.configurationCard.unequal") + ".")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.configurationCard.unequal") + ".")); } return EnumActionResult.SUCCESS; diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index b3c53cdff..d95c2f6eb 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -37,6 +37,7 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -69,8 +70,10 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(!world.isRemote) { Block block = world.getBlockState(pos).getBlock(); @@ -87,7 +90,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool { if(!player.isSneaking()) { - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getViewModeText(getState(stack).getTransmission()) + ": " + initial.color + initial.localize() + " (" + initial.color.getColoredName() + ")")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getViewModeText(getState(stack).getTransmission()) + ": " + initial.color + initial.localize() + " (" + initial.color.getColoredName() + ")")); } else { if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) @@ -97,7 +100,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); MekanismUtils.incrementOutput(config, getState(stack).getTransmission(), MekanismUtils.getBaseOrientation(side, config.getOrientation())); SideData data = config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getToggleModeText(getState(stack).getTransmission()) + ": " + data.color + data.localize() + " (" + data.color.getColoredName() + ")")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getToggleModeText(getState(stack).getTransmission()) + ": " + data.color + data.localize() + " (" + data.color.getColoredName() + ")")); if(config instanceof TileEntityBasicBlock) { @@ -158,16 +161,16 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool float yRandom = random.nextFloat() * 0.8F + 0.1F; float zRandom = random.nextFloat() * 0.8F + 0.1F; - while(slotStack.stackSize > 0) + while(slotStack.getCount() > 0) { int j = random.nextInt(21) + 10; - if(j > slotStack.stackSize) + if(j > slotStack.getCount()) { - j = slotStack.stackSize; + j = slotStack.getCount(); } - slotStack.stackSize -= j; + slotStack.shrink(j); EntityItem item = new EntityItem(world, pos.getX() + xRandom, pos.getY() + yRandom, pos.getZ() + zRandom, new ItemStack(slotStack.getItem(), j, slotStack.getItemDamage())); if(slotStack.hasTagCompound()) @@ -179,7 +182,7 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool item.motionX = random.nextGaussian() * k; item.motionY = random.nextGaussian() * k + 0.2F; item.motionZ = random.nextGaussian() * k; - world.spawnEntityInWorld(item); + world.spawnEntity(item); inv.setInventorySlotContents(i, null); setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); @@ -264,23 +267,14 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool @Override @Method(modid = "BuildCraft") - public boolean canWrench(EntityPlayer player, BlockPos pos) + public boolean canWrench(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace) { - return canUseWrench(player.inventory.getCurrentItem(), player, pos); + return canUseWrench(wrench, player, rayTrace.getBlockPos()); } @Override @Method(modid = "BuildCraft") - public void wrenchUsed(EntityPlayer player, BlockPos pos) {} - - @Override - public boolean canWrench(EntityPlayer player, Entity entity) - { - return false; - } - - @Override - public void wrenchUsed(EntityPlayer player, Entity entity) {} + public void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace) {} @Override public boolean canUseWrench(ItemStack stack, EntityPlayer player, BlockPos pos) diff --git a/src/main/java/mekanism/common/item/ItemControlCircuit.java b/src/main/java/mekanism/common/item/ItemControlCircuit.java index d0aa4da47..c012dd3a2 100644 --- a/src/main/java/mekanism/common/item/ItemControlCircuit.java +++ b/src/main/java/mekanism/common/item/ItemControlCircuit.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Tier.BaseTier; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemControlCircuit extends ItemMekanism implements IMetaItem { @@ -29,7 +28,7 @@ public class ItemControlCircuit extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(BaseTier tier : BaseTier.values()) { diff --git a/src/main/java/mekanism/common/item/ItemCraftingFormula.java b/src/main/java/mekanism/common/item/ItemCraftingFormula.java index de5b7b4ce..4eb87bee4 100644 --- a/src/main/java/mekanism/common/item/ItemCraftingFormula.java +++ b/src/main/java/mekanism/common/item/ItemCraftingFormula.java @@ -57,7 +57,7 @@ public class ItemCraftingFormula extends ItemMekanism { if(InventoryUtils.canStack(stack, iterStack)) { - iterStack.stackSize += stack.stackSize; + iterStack.grow(stack.getCount()); found = true; } } @@ -73,13 +73,15 @@ public class ItemCraftingFormula extends ItemMekanism for(ItemStack stack : stacks) { - list.add(EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.stackSize + ")"); + list.add(EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.getCount() + ")"); } } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(player.isSneaking()) { if(!world.isRemote) @@ -141,7 +143,7 @@ public class ItemCraftingFormula extends ItemMekanism if(slotID >= 0 && slotID < 9) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } diff --git a/src/main/java/mekanism/common/item/ItemCrystal.java b/src/main/java/mekanism/common/item/ItemCrystal.java index 5f2a10a02..368d14d5d 100644 --- a/src/main/java/mekanism/common/item/ItemCrystal.java +++ b/src/main/java/mekanism/common/item/ItemCrystal.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Resource; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemCrystal extends ItemMekanism implements IMetaItem { @@ -29,7 +28,7 @@ public class ItemCrystal extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < Resource.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemDictionary.java b/src/main/java/mekanism/common/item/ItemDictionary.java index 88cf789c9..3f61365ec 100644 --- a/src/main/java/mekanism/common/item/ItemDictionary.java +++ b/src/main/java/mekanism/common/item/ItemDictionary.java @@ -27,8 +27,10 @@ public class ItemDictionary extends ItemMekanism } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(!player.isSneaking()) { IBlockState state = world.getBlockState(pos); @@ -43,15 +45,15 @@ public class ItemDictionary extends ItemMekanism if(!names.isEmpty()) { - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.keysFound") + ":")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.keysFound") + ":")); for(String name : names) { - player.addChatMessage(new TextComponentString(EnumColor.DARK_GREEN + " - " + name)); + player.sendMessage(new TextComponentString(EnumColor.DARK_GREEN + " - " + name)); } } else { - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.noKey") + ".")); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.noKey") + ".")); } } @@ -63,8 +65,10 @@ public class ItemDictionary extends ItemMekanism } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { + ItemStack itemstack = entityplayer.getHeldItem(hand); + if(entityplayer.isSneaking()) { entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); diff --git a/src/main/java/mekanism/common/item/ItemDirtyDust.java b/src/main/java/mekanism/common/item/ItemDirtyDust.java index 002f60bb3..92e45eade 100644 --- a/src/main/java/mekanism/common/item/ItemDirtyDust.java +++ b/src/main/java/mekanism/common/item/ItemDirtyDust.java @@ -1,13 +1,12 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Mekanism; import mekanism.common.Resource; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemDirtyDust extends ItemMekanism implements IMetaItem { @@ -31,7 +30,7 @@ public class ItemDirtyDust extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < Resource.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemDust.java b/src/main/java/mekanism/common/item/ItemDust.java index c65b0dd25..e75d24567 100644 --- a/src/main/java/mekanism/common/item/ItemDust.java +++ b/src/main/java/mekanism/common/item/ItemDust.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Resource; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemDust extends ItemMekanism implements IMetaItem { @@ -29,7 +28,7 @@ public class ItemDust extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < Resource.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemElectricBow.java b/src/main/java/mekanism/common/item/ItemElectricBow.java index 01ac9d867..e7f9b1f3a 100644 --- a/src/main/java/mekanism/common/item/ItemElectricBow.java +++ b/src/main/java/mekanism/common/item/ItemElectricBow.java @@ -99,16 +99,16 @@ public class ItemElectricBow extends ItemEnergized entityarrow.setFire(getFireState(itemstack) ? 100 : 0); - world.spawnEntityInWorld(entityarrow); + world.spawnEntity(entityarrow); } world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if(!noConsume) { - ammo.stackSize--; + ammo.shrink(1); - if(ammo.stackSize == 0) + if(ammo.getCount() == 0) { player.inventory.deleteStack(ammo); } @@ -162,8 +162,9 @@ public class ItemElectricBow extends ItemEnergized } @Override - public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) + public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) { + ItemStack itemStackIn = playerIn.getHeldItem(hand); boolean flag = findAmmo(playerIn) != null; ActionResult ret = ForgeEventFactory.onArrowNock(itemStackIn, worldIn, playerIn, hand, flag); diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index 8c803bcf0..b6b510750 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -20,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.Optional.Interface; import net.minecraftforge.fml.common.Optional.InterfaceList; @@ -66,7 +67,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack discharged = new ItemStack(this); list.add(discharged); diff --git a/src/main/java/mekanism/common/item/ItemFlamethrower.java b/src/main/java/mekanism/common/item/ItemFlamethrower.java index ef3eaf720..75c916adf 100644 --- a/src/main/java/mekanism/common/item/ItemFlamethrower.java +++ b/src/main/java/mekanism/common/item/ItemFlamethrower.java @@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; public class ItemFlamethrower extends ItemMekanism implements IGasItem { @@ -142,7 +143,7 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack empty = new ItemStack(this); setGas(empty, null); diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index ae0e16460..c20c07960 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -29,6 +29,7 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingAttackEvent; @@ -88,7 +89,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack discharged = new ItemStack(this); list.add(discharged); @@ -212,7 +213,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { ItemFreeRunners boots = (ItemFreeRunners)stack.getItem(); - if(boots.getEnergy(stack) > 0 && event.getSource() == DamageSource.fall) + if(boots.getEnergy(stack) > 0 && event.getSource() == DamageSource.FALL) { boots.setEnergy(stack, boots.getEnergy(stack)-event.getAmount()*50); event.setCanceled(true); diff --git a/src/main/java/mekanism/common/item/ItemGasMask.java b/src/main/java/mekanism/common/item/ItemGasMask.java index bb7654c81..4e1014b3c 100644 --- a/src/main/java/mekanism/common/item/ItemGasMask.java +++ b/src/main/java/mekanism/common/item/ItemGasMask.java @@ -64,7 +64,7 @@ public class ItemGasMask extends ItemArmor if(tank.getFlowing(chestStack) && tank.getGas(chestStack) != null) { - if(event.getSource() == DamageSource.magic) + if(event.getSource() == DamageSource.MAGIC) { event.setCanceled(true); } diff --git a/src/main/java/mekanism/common/item/ItemGaugeDropper.java b/src/main/java/mekanism/common/item/ItemGaugeDropper.java index 74a996972..0b1d5a79e 100644 --- a/src/main/java/mekanism/common/item/ItemGaugeDropper.java +++ b/src/main/java/mekanism/common/item/ItemGaugeDropper.java @@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.Fluid; @@ -47,7 +48,7 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { list.add(getEmptyItem()); } @@ -68,8 +69,10 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem } @Override - public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(player.isSneaking() && !world.isRemote) { setGas(stack, null); diff --git a/src/main/java/mekanism/common/item/ItemHDPE.java b/src/main/java/mekanism/common/item/ItemHDPE.java index c906715cc..4e9a0c5aa 100644 --- a/src/main/java/mekanism/common/item/ItemHDPE.java +++ b/src/main/java/mekanism/common/item/ItemHDPE.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Mekanism; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemHDPE extends ItemMekanism implements IMetaItem { @@ -30,7 +29,7 @@ public class ItemHDPE extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < PlasticItem.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemIngot.java b/src/main/java/mekanism/common/item/ItemIngot.java index e0a87d3f8..3dcd05bd6 100644 --- a/src/main/java/mekanism/common/item/ItemIngot.java +++ b/src/main/java/mekanism/common/item/ItemIngot.java @@ -1,11 +1,10 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemIngot extends ItemMekanism implements IMetaItem { @@ -32,7 +31,7 @@ public class ItemIngot extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter <= 6; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemJetpack.java b/src/main/java/mekanism/common/item/ItemJetpack.java index a960926ab..6445b68e1 100644 --- a/src/main/java/mekanism/common/item/ItemJetpack.java +++ b/src/main/java/mekanism/common/item/ItemJetpack.java @@ -26,6 +26,7 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.relauncher.Side; @@ -202,7 +203,7 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack empty = new ItemStack(this); setGas(empty, null); diff --git a/src/main/java/mekanism/common/item/ItemNetworkReader.java b/src/main/java/mekanism/common/item/ItemNetworkReader.java index 4dc65f938..724514acc 100644 --- a/src/main/java/mekanism/common/item/ItemNetworkReader.java +++ b/src/main/java/mekanism/common/item/ItemNetworkReader.java @@ -32,8 +32,10 @@ public class ItemNetworkReader extends ItemEnergized } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemStack stack = player.getHeldItem(hand); + if(!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); @@ -47,21 +49,21 @@ public class ItemNetworkReader extends ItemEnergized IGridTransmitter transmitter = CapabilityUtils.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()); - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkSize())); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkAcceptorSize())); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkNeeded())); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkBuffer())); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkFlow())); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkCapacity())); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkSize())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkAcceptorSize())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkNeeded())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkBuffer())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkFlow())); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkCapacity())); if(CapabilityUtils.hasCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { IHeatTransfer transfer = CapabilityUtils.getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); } - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); return EnumActionResult.SUCCESS; } @@ -70,9 +72,9 @@ public class ItemNetworkReader extends ItemEnergized if(drain) setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); IHeatTransfer transfer = CapabilityUtils.getCapability(tileEntity, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite()); - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + transfer.getTemp() + "K above ambient")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); return EnumActionResult.SUCCESS; } @@ -93,9 +95,9 @@ public class ItemNetworkReader extends ItemEnergized if(transmitter.getTransmitterNetwork().possibleAcceptors.containsKey(coord.offset(iterSide.getOpposite())) && !iteratedNetworks.contains(transmitter.getTransmitterNetwork())) { - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[" + transmitter.getTransmissionType().getName() + "]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new TextComponentString(EnumColor.GREY + " *Connected sides: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().acceptorDirections.get(coord.offset(iterSide.getOpposite())))); - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[" + transmitter.getTransmissionType().getName() + "]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + " *Connected sides: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().acceptorDirections.get(coord.offset(iterSide.getOpposite())))); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); iteratedNetworks.add(transmitter.getTransmitterNetwork()); } @@ -109,14 +111,14 @@ public class ItemNetworkReader extends ItemEnergized if(player.isSneaking() && MekanismAPI.debug) { String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); - player.addChatMessage(new TextComponentString(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); for(String s : strings) { - player.addChatMessage(new TextComponentString(EnumColor.DARK_GREY + s)); + player.sendMessage(new TextComponentString(EnumColor.DARK_GREY + s)); } - player.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + player.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); } } diff --git a/src/main/java/mekanism/common/item/ItemOtherDust.java b/src/main/java/mekanism/common/item/ItemOtherDust.java index e4f0eab3e..925ef1aed 100644 --- a/src/main/java/mekanism/common/item/ItemOtherDust.java +++ b/src/main/java/mekanism/common/item/ItemOtherDust.java @@ -1,11 +1,10 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemOtherDust extends ItemMekanism implements IMetaItem { @@ -36,7 +35,7 @@ public class ItemOtherDust extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < subtypes.length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java index 2ab8d31ca..df11d890d 100644 --- a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java +++ b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java @@ -40,14 +40,16 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { + ItemStack itemstack = entityplayer.getHeldItem(hand); + if(!world.isRemote) { if(getOwner(itemstack) == null) { setOwner(itemstack, entityplayer.getName()); - entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("gui.nowOwn"))); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("gui.nowOwn"))); } else { if(SecurityUtils.canAccess(entityplayer, itemstack)) @@ -72,7 +74,7 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem int neededEnergy = 1000; - if(entity.worldObj.provider.getDimension() != coords.dimensionId) + if(entity.world.provider.getDimension() != coords.dimensionId) { neededEnergy += 10000; } diff --git a/src/main/java/mekanism/common/item/ItemProxy.java b/src/main/java/mekanism/common/item/ItemProxy.java index 317842601..d40ee4bae 100644 --- a/src/main/java/mekanism/common/item/ItemProxy.java +++ b/src/main/java/mekanism/common/item/ItemProxy.java @@ -1,5 +1,6 @@ package mekanism.common.item; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.ItemDataUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -45,7 +46,7 @@ public class ItemProxy extends Item { if(ItemDataUtils.getBoolean(stack, "hasStack")) { - return ItemStack.loadItemStackFromNBT(ItemDataUtils.getCompound(stack, "savedItem")); + return InventoryUtils.loadFromNBT(ItemDataUtils.getCompound(stack, "savedItem")); } return null; @@ -58,11 +59,11 @@ public class ItemProxy extends Item { EntityPlayer player = (EntityPlayer)entity; - for(int i = 0; i < player.inventory.mainInventory.length; i++) + for(int i = 0; i < player.inventory.mainInventory.size(); i++) { - if(player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i].getItem() == this) + if(player.inventory.mainInventory.get(i) != null && player.inventory.mainInventory.get(i).getItem() == this) { - player.inventory.mainInventory[i] = null; + player.inventory.mainInventory.remove(i); } } } diff --git a/src/main/java/mekanism/common/item/ItemRobit.java b/src/main/java/mekanism/common/item/ItemRobit.java index a6e4940c4..46421de2d 100644 --- a/src/main/java/mekanism/common/item/ItemRobit.java +++ b/src/main/java/mekanism/common/item/ItemRobit.java @@ -39,9 +39,10 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory } @Override - public EnumActionResult onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, BlockPos pos, EnumHand hand, EnumFacing side, float posX, float posY, float posZ) + public EnumActionResult onItemUse(EntityPlayer entityplayer, World world, BlockPos pos, EnumHand hand, EnumFacing side, float posX, float posY, float posZ) { TileEntity tileEntity = world.getTileEntity(pos); + ItemStack itemstack = entityplayer.getHeldItem(hand); if(tileEntity instanceof TileEntityChargepad) { @@ -59,7 +60,7 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory robit.setInventory(getInventory(itemstack)); robit.setCustomNameTag(getName(itemstack)); - world.spawnEntityInWorld(robit); + world.spawnEntity(robit); } entityplayer.setHeldItem(hand, null); diff --git a/src/main/java/mekanism/common/item/ItemScubaTank.java b/src/main/java/mekanism/common/item/ItemScubaTank.java index dc46634b0..5de0d7404 100644 --- a/src/main/java/mekanism/common/item/ItemScubaTank.java +++ b/src/main/java/mekanism/common/item/ItemScubaTank.java @@ -24,6 +24,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -213,7 +214,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack empty = new ItemStack(this); setGas(empty, null); diff --git a/src/main/java/mekanism/common/item/ItemSeismicReader.java b/src/main/java/mekanism/common/item/ItemSeismicReader.java index 192d21d80..d59371dfe 100644 --- a/src/main/java/mekanism/common/item/ItemSeismicReader.java +++ b/src/main/java/mekanism/common/item/ItemSeismicReader.java @@ -29,15 +29,16 @@ public class ItemSeismicReader extends ItemEnergized } @Override - public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer entityplayer, EnumHand hand) { Chunk3D chunk = new Chunk3D(entityplayer); + ItemStack itemstack = entityplayer.getHeldItem(hand); if(getEnergy(itemstack) < ENERGY_USAGE && !entityplayer.capabilities.isCreativeMode) { if(!world.isRemote) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.needsEnergy"))); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.needsEnergy"))); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); @@ -46,7 +47,7 @@ public class ItemSeismicReader extends ItemEnergized { if(!world.isRemote) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.noVibrations"))); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.noVibrations"))); } return new ActionResult(EnumActionResult.SUCCESS, itemstack); diff --git a/src/main/java/mekanism/common/item/ItemShard.java b/src/main/java/mekanism/common/item/ItemShard.java index 2e10a282e..c9ee86afd 100644 --- a/src/main/java/mekanism/common/item/ItemShard.java +++ b/src/main/java/mekanism/common/item/ItemShard.java @@ -1,12 +1,11 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Resource; import mekanism.common.base.IMetaItem; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class ItemShard extends ItemMekanism implements IMetaItem { @@ -29,7 +28,7 @@ public class ItemShard extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(int counter = 0; counter < Resource.values().length; counter++) { diff --git a/src/main/java/mekanism/common/item/ItemTierInstaller.java b/src/main/java/mekanism/common/item/ItemTierInstaller.java index 6c63e4e3e..ba783a20e 100644 --- a/src/main/java/mekanism/common/item/ItemTierInstaller.java +++ b/src/main/java/mekanism/common/item/ItemTierInstaller.java @@ -1,7 +1,5 @@ package mekanism.common.item; -import java.util.List; - import mekanism.common.Tier.BaseTier; import mekanism.common.base.IMetaItem; import mekanism.common.base.ITierUpgradeable; @@ -14,6 +12,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -27,7 +26,7 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if(world.isRemote) { @@ -35,6 +34,7 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem } TileEntity tile = world.getTileEntity(pos); + ItemStack stack = player.getHeldItem(hand); BaseTier tier = BaseTier.values()[stack.getItemDamage()]; if(tile instanceof ITierUpgradeable) @@ -48,7 +48,7 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem { if(!player.capabilities.isCreativeMode) { - stack.stackSize--; + stack.shrink(1); } return EnumActionResult.SUCCESS; @@ -73,7 +73,7 @@ public class ItemTierInstaller extends ItemMekanism implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList itemList) { for(BaseTier tier : BaseTier.values()) { diff --git a/src/main/java/mekanism/common/item/ItemUpgrade.java b/src/main/java/mekanism/common/item/ItemUpgrade.java index 20fa6da5c..8519cadfd 100644 --- a/src/main/java/mekanism/common/item/ItemUpgrade.java +++ b/src/main/java/mekanism/common/item/ItemUpgrade.java @@ -53,11 +53,12 @@ public class ItemUpgrade extends ItemMekanism implements IUpgradeItem } @Override - public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { if(player.isSneaking()) { TileEntity tile = world.getTileEntity(pos); + ItemStack stack = player.getHeldItem(hand); Upgrade type = getUpgradeType(stack); if(tile instanceof IUpgradeTile) @@ -69,7 +70,7 @@ public class ItemUpgrade extends ItemMekanism implements IUpgradeItem if(!world.isRemote && component.getUpgrades(type) < type.getMax()) { component.addUpgrade(type); - stack.stackSize--; + stack.shrink(1); } } diff --git a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java index 0aae3ca9a..a839d322b 100644 --- a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java +++ b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java @@ -47,8 +47,10 @@ public class ItemWalkieTalkie extends ItemMekanism } @Override - public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack itemStack = player.getHeldItem(hand); + if(player.isSneaking()) { setOn(itemStack, !getOn(itemStack)); diff --git a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java index 6ea2ab73d..a6624b25d 100644 --- a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java +++ b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java @@ -37,7 +37,7 @@ public abstract class UpdateProtocol> */ public void loopThrough(Coord4D coord) { - World worldObj = pointer.getWorld(); + World world = pointer.getWorld(); int origX = coord.xCoord, origY = coord.yCoord, origZ = coord.zCoord; @@ -323,7 +323,7 @@ public abstract class UpdateProtocol> { TileEntity tile = new Coord4D(pos, pointer.getWorld()).getTileEntity(pointer.getWorld()); - if(tile == null || !tile.hasWorldObj() || tile.isInvalid()) + if(tile == null || !tile.hasWorld() || tile.isInvalid()) { return false; } diff --git a/src/main/java/mekanism/common/multipart/ItemGlowPanel.java b/src/main/java/mekanism/common/multipart/ItemGlowPanel.java index 74fb65c6b..454ee6878 100644 --- a/src/main/java/mekanism/common/multipart/ItemGlowPanel.java +++ b/src/main/java/mekanism/common/multipart/ItemGlowPanel.java @@ -1,7 +1,5 @@ package mekanism.common.multipart; -import java.util.List; - import mcmultipart.item.ItemMultiPart; import mcmultipart.multipart.IMultipart; import mekanism.api.EnumColor; @@ -13,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.translation.I18n; @@ -46,7 +45,7 @@ public class ItemGlowPanel extends ItemMultiPart implements IMetaItem } @Override - public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) + public void getSubItems(Item item, CreativeTabs tab, NonNullList listToAddTo) { for(EnumColor color : EnumColor.DYES) { diff --git a/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java b/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java index 03ab2ed1c..9ba0be96e 100644 --- a/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java +++ b/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java @@ -20,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -136,7 +137,7 @@ public class ItemPartTransmitter extends ItemMultiPart implements IMetaItem @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) + public void getSubItems(Item item, CreativeTabs tab, NonNullList listToAddTo) { for(TransmitterType type : TransmitterType.values()) { diff --git a/src/main/java/mekanism/common/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/multipart/MultipartMekanism.java index 3c0c355de..4a5ebb214 100644 --- a/src/main/java/mekanism/common/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/multipart/MultipartMekanism.java @@ -186,7 +186,7 @@ public class MultipartMekanism implements IPartFactory item.motionY = multipart.getWorld().rand.nextGaussian() * 0.05 + 0.2; item.motionZ = multipart.getWorld().rand.nextGaussian() * 0.05; item.setDefaultPickupDelay(); - multipart.getWorld().spawnEntityInWorld(item); + multipart.getWorld().spawnEntity(item); } public static void dropItems(Multipart multipart) diff --git a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java index 1d6e11ee3..7c421bbac 100644 --- a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java @@ -129,7 +129,7 @@ public class PartDiversionTransporter extends PartLogisticalTransporter refreshConnections(); notifyPartUpdate(); notifyTileChange(); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description)); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description)); Coord4D coord = new Coord4D(getPos(), getWorld()); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord, getNetworkedData(new ArrayList())), new Range4D(coord)); diff --git a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java index 776d6091b..60659fb39 100644 --- a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java @@ -149,7 +149,7 @@ public class PartLogisticalTransporter extends PartTransmitter> extends { if(!player.capabilities.isCreativeMode) { - stack.stackSize--; + stack.shrink(1); - if(stack.stackSize == 0) + if(stack.getCount() == 0) { player.setHeldItem(hand, null); } diff --git a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java index 91477a527..895fae48e 100644 --- a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java +++ b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java @@ -37,7 +37,7 @@ public class PacketConfigurationUpdate implements IMessageHandler { if(message.guiType == 0) { - player.openGui(Mekanism.instance, 21, player.worldObj, message.entityId, 0, 0); + player.openGui(Mekanism.instance, 21, player.world, message.entityId, 0, 0); } else if(message.guiType == 1) { - player.openGui(Mekanism.instance, 22, player.worldObj, message.entityId, 0, 0); + player.openGui(Mekanism.instance, 22, player.world, message.entityId, 0, 0); } else if(message.guiType == 2) { - player.openGui(Mekanism.instance, 23, player.worldObj, message.entityId, 0, 0); + player.openGui(Mekanism.instance, 23, player.world, message.entityId, 0, 0); } else if(message.guiType == 3) { - player.openGui(Mekanism.instance, 24, player.worldObj, message.entityId, 0, 0); + player.openGui(Mekanism.instance, 24, player.world, message.entityId, 0, 0); } else if(message.guiType == 4) { - player.openGui(Mekanism.instance, 25, player.worldObj, message.entityId, 0, 0); + player.openGui(Mekanism.instance, 25, player.world, message.entityId, 0, 0); } } else if(message.activeType == RobitPacketType.FOLLOW) { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + EntityRobit robit = (EntityRobit)player.world.getEntityByID(message.entityId); if(robit != null) { @@ -55,7 +55,7 @@ public class PacketRobit implements IMessageHandler } else if(message.activeType == RobitPacketType.NAME) { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + EntityRobit robit = (EntityRobit)player.world.getEntityByID(message.entityId); if(robit != null) { @@ -64,7 +64,7 @@ public class PacketRobit implements IMessageHandler } else if(message.activeType == RobitPacketType.GO_HOME) { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + EntityRobit robit = (EntityRobit)player.world.getEntityByID(message.entityId); if(robit != null) { @@ -73,7 +73,7 @@ public class PacketRobit implements IMessageHandler } else if(message.activeType == RobitPacketType.DROP_PICKUP) { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + EntityRobit robit = (EntityRobit)player.world.getEntityByID(message.entityId); if(robit != null) { diff --git a/src/main/java/mekanism/common/network/PacketScubaTankData.java b/src/main/java/mekanism/common/network/PacketScubaTankData.java index 3a8fe6c66..fda3e7529 100644 --- a/src/main/java/mekanism/common/network/PacketScubaTankData.java +++ b/src/main/java/mekanism/common/network/PacketScubaTankData.java @@ -29,9 +29,9 @@ public class PacketScubaTankData implements IMessageHandler 1) + if(bin == null || bin.getCount() > 1) { return null; } @@ -126,7 +127,7 @@ public class BinRecipe implements IRecipe } @Override - public ItemStack[] getRemainingItems(InventoryCrafting inv) + public NonNullList getRemainingItems(InventoryCrafting inv) { return ForgeHooks.defaultRecipeGetRemainingItems(inv); } @@ -148,7 +149,7 @@ public class BinRecipe implements IRecipe int size = inv.getItemCount(); ItemStack testRemove = inv.removeStack(); - int newCount = size-(testRemove != null ? testRemove.stackSize : 0); + int newCount = size-(testRemove != null ? testRemove.getCount() : 0); if(inv.getTier() == BinTier.CREATIVE) { @@ -180,7 +181,7 @@ public class BinRecipe implements IRecipe ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); - if(testRemain != null && testRemain.stackSize > 0) + if(testRemain != null && testRemain.getCount() > 0) { ItemStack proxy = new ItemStack(MekanismItems.ItemProxy); ((ItemProxy)proxy.getItem()).setSavedItem(proxy, testRemain.copy()); diff --git a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java index b899ef679..e574a8a7d 100644 --- a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java @@ -3,6 +3,7 @@ package mekanism.common.recipe; import java.util.HashMap; import mekanism.common.Mekanism; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.RecipeUtils; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; @@ -11,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Constants.NBT; @@ -154,7 +156,7 @@ public class ShapedMekanismRecipe implements IRecipe } @Override - public ItemStack[] getRemainingItems(InventoryCrafting inv) + public NonNullList getRemainingItems(InventoryCrafting inv) { return ForgeHooks.defaultRecipeGetRemainingItems(inv); } @@ -254,7 +256,7 @@ public class ShapedMekanismRecipe implements IRecipe return null; } - ItemStack result = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); + ItemStack result = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("result")); NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); if(result == null || list.tagCount() == 0) @@ -291,7 +293,7 @@ public class ShapedMekanismRecipe implements IRecipe } else if(compound.hasKey("itemstack")) { - ret[i] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack")); + ret[i] = InventoryUtils.loadFromNBT(compound.getCompoundTag("itemstack")); } else { Mekanism.logger.error("[Mekanism] Shaped recipe parse error: invalid input tag data key."); diff --git a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java index d093f2092..89c29d97e 100644 --- a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.List; import mekanism.common.Mekanism; +import mekanism.common.util.InventoryUtils; import mekanism.common.util.RecipeUtils; import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; @@ -13,6 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.NonNullList; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Constants.NBT; @@ -75,7 +77,7 @@ public class ShapelessMekanismRecipe implements IRecipe } @Override - public ItemStack[] getRemainingItems(InventoryCrafting inv) + public NonNullList getRemainingItems(InventoryCrafting inv) { return ForgeHooks.defaultRecipeGetRemainingItems(inv); } @@ -153,7 +155,7 @@ public class ShapelessMekanismRecipe implements IRecipe return null; } - ItemStack result = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); + ItemStack result = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("result")); NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); if(result == null || list.tagCount() == 0) @@ -174,7 +176,7 @@ public class ShapelessMekanismRecipe implements IRecipe } else if(compound.hasKey("itemstack")) { - ret[i] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack")); + ret[i] = InventoryUtils.loadFromNBT(compound.getCompoundTag("itemstack")); } else { Mekanism.logger.error("[Mekanism] Shapeless recipe parse error: invalid input tag data key."); diff --git a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java index 7725a1dbd..1ac2c15dc 100644 --- a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java @@ -3,6 +3,7 @@ package mekanism.common.recipe.inputs; import mekanism.api.gas.Gas; import mekanism.api.gas.GasTank; import mekanism.api.util.StackUtils; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,7 +24,7 @@ public class AdvancedMachineInput extends MachineInput @Override public void load(NBTTagCompound nbtTags) { - itemStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + itemStack = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("input")); gasType = Gas.readFromNBT(nbtTags.getCompoundTag("gasType")); } @@ -67,7 +68,7 @@ public class AdvancedMachineInput extends MachineInput public boolean matches(AdvancedMachineInput input) { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; + return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.getCount() >= itemStack.getCount(); } @Override diff --git a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java index 840443291..70da9e6a0 100644 --- a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java @@ -4,6 +4,7 @@ import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; import mekanism.api.util.StackUtils; import mekanism.common.InfuseStorage; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -34,7 +35,7 @@ public class InfusionInput extends MachineInput @Override public void load(NBTTagCompound nbtTags) { - inputStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + inputStack = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("input")); InfuseType type = InfuseRegistry.get(nbtTags.getString("infuseType")); int amount = nbtTags.getInteger("infuseAmount"); infuse = new InfuseStorage(type, amount); diff --git a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java index 76d0a8b7f..dc8001010 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java @@ -1,6 +1,7 @@ package mekanism.common.recipe.inputs; import mekanism.api.util.StackUtils; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; @@ -19,7 +20,7 @@ public class ItemStackInput extends MachineInput @Override public void load(NBTTagCompound nbtTags) { - ingredient = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + ingredient = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("input")); } @Override @@ -36,7 +37,7 @@ public class ItemStackInput extends MachineInput public ItemStackInput wildCopy() { - return new ItemStackInput(new ItemStack(ingredient.getItem(), ingredient.stackSize, OreDictionary.WILDCARD_VALUE)); + return new ItemStackInput(new ItemStack(ingredient.getItem(), ingredient.getCount(), OreDictionary.WILDCARD_VALUE)); } public boolean useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete) diff --git a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java index 7340c5888..f09301f21 100644 --- a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java @@ -27,14 +27,14 @@ public abstract class MachineInput> public static boolean inputContains(ItemStack container, ItemStack contained) { - if(container != null && container.stackSize >= contained.stackSize) + if(container != null && container.getCount() >= contained.getCount()) { if(MekanismUtils.getOreDictName(container).contains("treeSapling")) { return StackUtils.equalsWildcard(contained, container); } - return StackUtils.equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize; + return StackUtils.equalsWildcardWithNBT(contained, container) && container.getCount() >= contained.getCount(); } return false; diff --git a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java index 2fc3e919e..f73570d22 100644 --- a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java @@ -3,6 +3,7 @@ package mekanism.common.recipe.inputs; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.util.StackUtils; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; @@ -29,7 +30,7 @@ public class PressurizedInput extends MachineInput @Override public void load(NBTTagCompound nbtTags) { - theSolid = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemInput")); + theSolid = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("itemInput")); theFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("fluidInput")); theGas = GasStack.readFromNBT(nbtTags.getCompoundTag("gasInput")); } @@ -65,7 +66,7 @@ public class PressurizedInput extends MachineInput */ public boolean containsType(ItemStack stack) { - if(stack == null || stack.stackSize == 0) + if(stack == null || stack.getCount() == 0) { return false; } @@ -120,7 +121,7 @@ public class PressurizedInput extends MachineInput return false; } - return input.theSolid.stackSize >= theSolid.stackSize && input.theFluid.amount >= theFluid.amount && input.theGas.amount >= theGas.amount; + return input.theSolid.getCount() >= theSolid.getCount() && input.theFluid.amount >= theFluid.amount && input.theGas.amount >= theGas.amount; } @Override diff --git a/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java index 6ec02d1f4..61eb316b1 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java @@ -3,6 +3,7 @@ package mekanism.common.recipe.outputs; import java.util.Random; import mekanism.api.util.StackUtils; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -28,8 +29,8 @@ public class ChanceOutput extends MachineOutput @Override public void load(NBTTagCompound nbtTags) { - primaryOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("primaryOutput")); - secondaryOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("secondaryOutput")); + primaryOutput = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("primaryOutput")); + secondaryOutput = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("secondaryOutput")); secondaryChance = nbtTags.getDouble("secondaryChance"); } @@ -64,11 +65,11 @@ public class ChanceOutput extends MachineOutput inventory[primaryIndex] = primaryOutput.copy(); } } - else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].stackSize + primaryOutput.stackSize <= inventory[primaryIndex].getMaxStackSize()) + else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].getCount() + primaryOutput.getCount() <= inventory[primaryIndex].getMaxStackSize()) { if(doEmit) { - inventory[primaryIndex].stackSize += primaryOutput.stackSize; + inventory[primaryIndex].grow(primaryOutput.getCount()); } } else { @@ -87,11 +88,11 @@ public class ChanceOutput extends MachineOutput return true; } - else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].stackSize + primaryOutput.stackSize <= inventory[secondaryIndex].getMaxStackSize()) + else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].getCount() + primaryOutput.getCount() <= inventory[secondaryIndex].getMaxStackSize()) { if(doEmit) { - inventory[secondaryIndex].stackSize += secondaryOutput.stackSize; + inventory[secondaryIndex].grow(secondaryOutput.getCount()); } return true; diff --git a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java index 7ee952f81..975306dc3 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java @@ -1,5 +1,6 @@ package mekanism.common.recipe.outputs; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -17,7 +18,7 @@ public class ItemStackOutput extends MachineOutput @Override public void load(NBTTagCompound nbtTags) { - output = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("output")); + output = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("output")); } public boolean applyOutputs(ItemStack[] inventory, int index, boolean doEmit) @@ -31,11 +32,11 @@ public class ItemStackOutput extends MachineOutput return true; } - else if(inventory[index].isItemEqual(output) && inventory[index].stackSize + output.stackSize <= inventory[index].getMaxStackSize()) + else if(inventory[index].isItemEqual(output) && inventory[index].getCount() + output.getCount() <= inventory[index].getMaxStackSize()) { if(doEmit) { - inventory[index].stackSize += output.stackSize; + inventory[index].grow(output.getCount()); } return true; diff --git a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java index 5692be99a..2fadc230b 100644 --- a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java @@ -2,6 +2,7 @@ package mekanism.common.recipe.outputs; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; +import mekanism.common.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,7 +22,7 @@ public class PressurizedOutput extends MachineOutput @Override public void load(NBTTagCompound nbtTags) { - itemOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemOutput")); + itemOutput = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("itemOutput")); gasOutput = GasStack.readFromNBT(nbtTags.getCompoundTag("gasOutput")); } @@ -32,7 +33,7 @@ public class PressurizedOutput extends MachineOutput public boolean canAddProducts(ItemStack[] inventory, int index) { - return inventory[index] == null || (inventory[index].isItemEqual(itemOutput) && inventory[index].stackSize + itemOutput.stackSize <= inventory[index].getMaxStackSize()); + return inventory[index] == null || (inventory[index].isItemEqual(itemOutput) && inventory[index].getCount() + itemOutput.getCount() <= inventory[index].getMaxStackSize()); } public void fillTank(GasTank tank) @@ -48,7 +49,7 @@ public class PressurizedOutput extends MachineOutput } else if(inventory[index].isItemEqual(itemOutput)) { - inventory[index].stackSize += itemOutput.stackSize; + inventory[index].grow(itemOutput.getCount()); } } diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index d784d966a..9910c8bc4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -29,6 +29,17 @@ import cofh.api.energy.IEnergyReceiver; }) public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyReceiver, IEnergyProvider, IComputerIntegration, ISpecialConfigData { + @Override + public boolean isEmpty() + { + if(getInv() == null) + { + return true; + } + + return getInv().isEmpty(); + } + @Override public int getSizeInventory() { @@ -124,14 +135,14 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUsableByPlayer(EntityPlayer entityplayer) { if(getInv() == null) { return false; } - return getInv().isUseableByPlayer(entityplayer); + return getInv().isUsableByPlayer(entityplayer); } @Override @@ -381,15 +392,15 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp return null; } - TileEntity tile = new Coord4D(mainPos, worldObj).getTileEntity(worldObj); + TileEntity tile = new Coord4D(mainPos, world).getTileEntity(world); if(!(tile instanceof IAdvancedBoundingBlock)) { - worldObj.setBlockToAir(mainPos); + world.setBlockToAir(mainPos); return null; } - return (IAdvancedBoundingBlock)new Coord4D(mainPos, worldObj).getTileEntity(worldObj); + return (IAdvancedBoundingBlock)new Coord4D(mainPos, world).getTileEntity(world); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java index 243bf4707..85e31bab5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java @@ -102,10 +102,10 @@ public abstract class TileEntityAdvancedElectricMachine 0) { @@ -126,8 +126,8 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe if(clientFacing != facing) { - MekanismUtils.updateBlock(worldObj, getPos()); - worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock()); + MekanismUtils.updateBlock(world, getPos()); + world.notifyNeighborsOfStateChange(getPos(), world.getBlockState(getPos()).getBlock(), true); clientFacing = facing; } @@ -168,7 +168,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe { super.validate(); - if(worldObj.isRemote) + if(world.isRemote) { Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); } @@ -230,7 +230,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe facing = EnumFacing.getFront(direction); } - if(!(facing == clientFacing || worldObj.isRemote)) + if(!(facing == clientFacing || world.isRemote)) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); markDirty(); @@ -262,7 +262,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe public void onNeighborChange(Block block) { - if(!worldObj.isRemote) + if(!world.isRemote) { updatePower(); } @@ -270,7 +270,7 @@ public abstract class TileEntityBasicBlock extends TileEntity implements ITileNe private void updatePower() { - boolean power = worldObj.isBlockIndirectlyGettingPowered(getPos()) > 0; + boolean power = world.isBlockIndirectlyGettingPowered(getPos()) > 0; if(redstone != power) { diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java index 6adcecccd..d9d1b058b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java @@ -104,18 +104,18 @@ public abstract class TileEntityBasicMachine, { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -173,7 +173,7 @@ public abstract class TileEntityBasicMachine, { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index 2d67c4c33..30cf25771 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -39,8 +39,8 @@ import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Optional.Interface; -import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; @Interface(iface = "powercrystals.minefactoryreloaded.api.IDeepStorageUnit", modid = "MineFactoryReloaded") @@ -71,8 +71,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento private BinItemHandler myItemHandler; - public TileEntityBin(){ - this.myItemHandler = new BinItemHandler(this); + public TileEntityBin() + { + myItemHandler = new BinItemHandler(this); } @Override @@ -112,13 +113,13 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } else { topStack = itemType.copy(); - topStack.stackSize = itemType.getMaxStackSize()-remain; + topStack.setCount(itemType.getMaxStackSize()-remain); } count -= StackUtils.getSize(topStack); bottomStack = itemType.copy(); - bottomStack.stackSize = Math.min(itemType.getMaxStackSize(), count); + bottomStack.setCount(Math.min(itemType.getMaxStackSize(), count)); count -= StackUtils.getSize(bottomStack); @@ -127,7 +128,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento public boolean isValid(ItemStack stack) { - if(stack == null || stack.stackSize <= 0) + if(stack == null || stack.getCount() <= 0) { return false; } @@ -161,17 +162,17 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if(tier != BinTier.CREATIVE) { - if(getItemCount() + stack.stackSize <= tier.storage) + if(getItemCount() + stack.getCount() <= tier.storage) { if (!simulate) { - setItemCount(getItemCount() + stack.stackSize); + setItemCount(getItemCount() + stack.getCount()); } return null; } else { ItemStack rejects = stack.copy(); - rejects.stackSize = (getItemCount()+stack.stackSize) - tier.storage; + rejects.setCount((getItemCount()+stack.getCount()) - tier.storage); if (!simulate) { @@ -204,7 +205,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento return null; } - return remove(bottomStack.stackSize); + return remove(bottomStack.getCount()); } public ItemStack remove(int amount, boolean simulate) @@ -215,11 +216,11 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } ItemStack ret = itemType.copy(); - ret.stackSize = Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount()); + ret.setCount(Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount())); if(tier != BinTier.CREATIVE && !simulate) { - setItemCount(getItemCount() - ret.stackSize); + setItemCount(getItemCount() - ret.getCount()); } return ret; @@ -238,7 +239,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento @Override public void onUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { addTicks = Math.max(0, addTicks-1); delayTicks = Math.max(0, delayTicks-1); @@ -255,7 +256,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { if(bottomStack != null && isActive) { - TileEntity tile = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(worldObj); + TileEntity tile = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(world); if(CapabilityUtils.hasCapability(tile, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, EnumFacing.UP)) { @@ -318,12 +319,12 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento cacheCount = nbtTags.getInteger("itemCount"); tier = BinTier.values()[nbtTags.getInteger("tier")]; - bottomStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("bottomStack")); - topStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("topStack")); + bottomStack = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("bottomStack")); + topStack = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("topStack")); if(getItemCount() > 0) { - itemType = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemType")); + itemType = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("itemType")); } } @@ -363,7 +364,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento itemType = null; } - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } @@ -393,7 +394,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento if(toRemove > 0) { ItemStack ret = itemType.copy(); - ret.stackSize = toRemove; + ret.setCount(toRemove); setItemCount(getItemCount()-toRemove); @@ -430,10 +431,10 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { if(itemstack == null) { - setItemCount(getItemCount() - bottomStack.stackSize); + setItemCount(getItemCount() - bottomStack.getCount()); } else { - setItemCount(getItemCount() - (bottomStack.stackSize-itemstack.stackSize)); + setItemCount(getItemCount() - (bottomStack.getCount()-itemstack.getCount())); } } } @@ -444,9 +445,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento topStack = null; } else { - if(isValid(itemstack) && itemstack.stackSize > StackUtils.getSize(topStack) && tier != BinTier.CREATIVE) + if(isValid(itemstack) && itemstack.getCount() > StackUtils.getSize(topStack) && tier != BinTier.CREATIVE) { - add(StackUtils.size(itemstack, itemstack.stackSize-StackUtils.getSize(topStack))); + add(StackUtils.size(itemstack, itemstack.getCount()-StackUtils.getSize(topStack))); } } } @@ -457,7 +458,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { super.markDirty(); - if(!worldObj.isRemote) + if(!world.isRemote) { MekanismUtils.saveChunk(this); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); @@ -478,7 +479,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } ItemStack ret = stack.copy(); - ret.stackSize = 1; + ret.setCount(1); itemType = ret; } @@ -521,7 +522,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUsableByPlayer(EntityPlayer entityplayer) { return true; } @@ -537,6 +538,12 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { return i == 1 && isValid(itemstack); } + + @Override + public boolean isEmpty() + { + return getItemCount() == 0; + } @Override public int getField(int id) @@ -667,7 +674,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { setActive(!getActive()); - worldObj.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); + world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); return EnumActionResult.SUCCESS; } @@ -707,12 +714,28 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento { this.tileEntityBin = tileEntityBin; } + + @Override + public int getSlotLimit(int slot) + { + if(slot != 0) + { + return 0; + } + + return tier.storage; + } - public int getSlots(){return 1;} + @Override + public int getSlots() + { + return 1; + } + @Override public ItemStack getStackInSlot(int slot) { - if (slot != 0 || tileEntityBin.itemType == null) + if(slot != 0 || tileEntityBin.itemType == null) { return null; } @@ -720,19 +743,20 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento return MekanismUtils.size(tileEntityBin.itemType, tileEntityBin.getItemCount()); } + @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - if (slot != 0) + if(slot != 0) { return null; } + return tileEntityBin.add(stack, simulate); - } public ItemStack extractItem(int slot, int amount, boolean simulate) { - if (slot != 0) + if(slot != 0) { return null; } diff --git a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java index 03dc0c507..e18e97468 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java @@ -56,7 +56,7 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock= structure.upperRenderLocation.yCoord-1) { @@ -43,7 +43,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl { for(EnumFacing side : EnumFacing.values()) { - TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); if(tile != null && !(tile instanceof TileEntityBoilerValve) && CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { @@ -68,7 +68,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.yCoord-1) { @@ -124,7 +124,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public boolean canFill(EnumFacing from, Fluid fluid) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { return structure.upperRenderLocation != null && getPos().getY() < structure.upperRenderLocation.yCoord-1; } @@ -135,7 +135,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public boolean canDrain(EnumFacing from, Fluid fluid) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { return structure.upperRenderLocation != null && getPos().getY() >= structure.upperRenderLocation.yCoord-1; } @@ -146,7 +146,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public boolean hasCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { @@ -160,7 +160,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl @Override public T getCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { diff --git a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java index 49b136fdc..966f24a72 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java @@ -30,7 +30,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork { receivedCoords = true; - if(!worldObj.isRemote) + if(!world.isRemote) { mainPos = pos; @@ -43,7 +43,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork { super.validate(); - if(worldObj.isRemote) + if(world.isRemote) { Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); } @@ -51,13 +51,13 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork public void onNeighborChange(Block block) { - TileEntity tile = worldObj.getTileEntity(mainPos); + TileEntity tile = world.getTileEntity(mainPos); if(tile instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)tile; - int power = worldObj.isBlockIndirectlyGettingPowered(getPos()); + int power = world.isBlockIndirectlyGettingPowered(getPos()); if(prevPower != power) { @@ -82,7 +82,7 @@ public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork @Override public void handlePacketData(ByteBuf dataStream) { - if(worldObj.isRemote) + if(world.isRemote) { mainPos = new BlockPos(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); prevPower = dataStream.readInt(); diff --git a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java index 79d86135b..b9a7d4937 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java @@ -51,7 +51,7 @@ public abstract class TileEntityChanceMachine entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 0.2, getPos().getZ() + 1)); + List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(getPos().getX(), getPos().getY(), getPos().getZ(), getPos().getX() + 1, getPos().getY() + 0.2, getPos().getZ() + 1)); for(EntityLivingBase entity : entities) { @@ -108,10 +108,10 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock { if(isActive) { - worldObj.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.8F); + world.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.8F); } else { - worldObj.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.7F); + world.playSound((EntityPlayer)null, getPos().getX() + 0.5, getPos().getY() + 0.1, getPos().getZ() + 0.5, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.7F); } setActive(isActive); @@ -119,7 +119,7 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock } else if(isActive) { - worldObj.spawnParticle(EnumParticleTypes.REDSTONE, getPos().getX()+random.nextDouble(), getPos().getY()+0.15, getPos().getZ()+random.nextDouble(), 0, 0, 0); + world.spawnParticle(EnumParticleTypes.REDSTONE, getPos().getX()+random.nextDouble(), getPos().getY()+0.15, getPos().getZ()+random.nextDouble(), 0, 0, 0); } } @@ -203,7 +203,7 @@ public class TileEntityChargepad extends TileEntityNoisyElectricBlock if(clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index cab110150..3221ef178 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -117,18 +117,18 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -233,7 +233,7 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index d8fd64398..07230c142 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -95,18 +95,18 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri @Override public void onUpdate() { - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -289,7 +289,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index 2a08a98eb..49dbdbb0b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -90,18 +90,18 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -251,7 +251,7 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index b917fad40..97985b3d5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -87,18 +87,18 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -254,7 +254,7 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index aa544a8e8..2a8c56a3a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -106,18 +106,18 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -253,7 +253,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java b/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java index 8eb2932fa..7c2ca3add 100644 --- a/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java @@ -34,6 +34,20 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { fullName = name; } + + @Override + public boolean isEmpty() + { + for(ItemStack stack : inventory) + { + if(!stack.isEmpty()) + { + return false; + } + } + + return true; + } @Override public void readFromNBT(NBTTagCompound nbtTags) @@ -52,7 +66,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if(slotID >= 0 && slotID < getSizeInventory()) { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); + setInventorySlotContents(slotID, InventoryUtils.loadFromNBT(tagCompound)); } } } @@ -103,7 +117,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { ItemStack tempStack; - if(getStackInSlot(slotID).stackSize <= amount) + if(getStackInSlot(slotID).getCount() <= amount) { tempStack = getStackInSlot(slotID); setInventorySlotContents(slotID, null); @@ -112,7 +126,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl else { tempStack = getStackInSlot(slotID).splitStack(amount); - if(getStackInSlot(slotID).stackSize == 0) + if(getStackInSlot(slotID).getCount() == 0) { setInventorySlotContents(slotID, null); } @@ -144,16 +158,16 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl { inventory[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if(itemstack != null && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.setCount(getInventoryStackLimit()); } markDirty(); } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) + public boolean isUsableByPlayer(EntityPlayer entityplayer) { return !isInvalid(); } @@ -223,7 +237,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl if(slotID >= 0 && slotID < inventory.length) { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + inventory[slotID] = InventoryUtils.loadFromNBT(tagCompound); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index a35e517ab..06298fbf3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -156,7 +156,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(!initCalc) { @@ -207,7 +207,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I break; } - if(!coord.exists(worldObj)) + if(!coord.exists(world)) { set.clear(index); @@ -220,11 +220,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I continue; } - IBlockState state = coord.getBlockState(worldObj); + IBlockState state = coord.getBlockState(world); Block block = state.getBlock(); int meta = block.getMetaFromState(state); - if(block == null || coord.isAirBlock(worldObj)) + if(block == null || coord.isAirBlock(world)) { set.clear(index); @@ -262,7 +262,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I continue; } - List drops = MinerUtils.getDrops(worldObj, coord, silkTouch); + List drops = MinerUtils.getDrops(world, coord, silkTouch); if(canInsert(drops) && setReplace(coord, index)) { @@ -275,7 +275,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I toRemove.add(chunk); } - worldObj.playEvent(null, 2001, coord.getPos(), Block.getStateId(state)); + world.playEvent(null, 2001, coord.getPos(), Block.getStateId(state)); missingStack = null; } @@ -369,11 +369,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I */ public boolean setReplace(Coord4D obj, int index) { - IBlockState state = obj.getBlockState(worldObj); + IBlockState state = obj.getBlockState(world); Block block = state.getBlock(); - EntityPlayer dummy = Mekanism.proxy.getDummyPlayer((WorldServer)worldObj, obj.xCoord, obj.yCoord, obj.zCoord).get(); - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(worldObj, obj.getPos(), state, dummy); + EntityPlayer dummy = Mekanism.proxy.getDummyPlayer((WorldServer)world, obj.xCoord, obj.yCoord, obj.zCoord).get(); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, obj.getPos(), state, dummy); MinecraftForge.EVENT_BUS.post(event); if(!event.isCanceled()) @@ -382,13 +382,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(stack != null) { - worldObj.setBlockState(obj.getPos(), Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getItemDamage()), 3); + world.setBlockState(obj.getPos(), Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getItemDamage()), 3); - IBlockState s = obj.getBlockState(worldObj); - if(s.getBlock() instanceof BlockBush && !((BlockBush)s.getBlock()).canBlockStay(worldObj, obj.getPos(), s)) + IBlockState s = obj.getBlockState(world); + if(s.getBlock() instanceof BlockBush && !((BlockBush)s.getBlock()).canBlockStay(world, obj.getPos(), s)) { - s.getBlock().dropBlockAsItem(worldObj, obj.getPos(), s, 1); - worldObj.setBlockToAir(obj.getPos()); + s.getBlock().dropBlockAsItem(world, obj.getPos(), s, 1); + world.setBlockToAir(obj.getPos()); } return true; @@ -398,7 +398,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(filter == null || (filter.replaceStack == null || !filter.requireStack)) { - worldObj.setBlockToAir(obj.getPos()); + world.setBlockToAir(obj.getPos()); return true; } @@ -425,9 +425,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { if(inventory[i] != null && inventory[i].isItemEqual(filter.replaceStack)) { - inventory[i].stackSize--; + inventory[i].shrink(1); - if(inventory[i].stackSize == 0) + if(inventory[i].getCount() == 0) { inventory[i] = null; } @@ -520,9 +520,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I continue stacks; } - else if(testInv[i].isItemEqual(stack) && testInv[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) + else if(testInv[i].isItemEqual(stack) && testInv[i].getCount()+stack.getCount() <= stack.getMaxStackSize()) { - testInv[i].stackSize += stack.stackSize; + testInv[i].grow(stack.getCount()); added++; continue stacks; @@ -540,14 +540,14 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileEntity getPullInv() { - return Coord4D.get(this).translate(0, 2, 0).getTileEntity(worldObj); + return Coord4D.get(this).translate(0, 2, 0).getTileEntity(world); } public TileEntity getEjectInv() { EnumFacing side = facing.getOpposite(); - return worldObj.getTileEntity(getPos().up().offset(side, 2)); + return world.getTileEntity(getPos().up().offset(side, 2)); } public void add(List stacks) @@ -568,9 +568,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I continue stacks; } - else if(inventory[i].isItemEqual(stack) && inventory[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) + else if(inventory[i].isItemEqual(stack) && inventory[i].getCount()+stack.getCount() <= stack.getMaxStackSize()) { - inventory[i].stackSize += stack.stackSize; + inventory[i].grow(stack.getCount()); continue stacks; } @@ -648,7 +648,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { super.openInventory(player); - if(!worldObj.isRemote) + if(!world.isRemote) { Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player); } @@ -892,7 +892,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -1045,7 +1045,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public Coord4D getStartingCoord() { - return new Coord4D(getPos().getX()-radius, minY, getPos().getZ()-radius, worldObj.provider.getDimension()); + return new Coord4D(getPos().getX()-radius, minY, getPos().getZ()-radius, world.provider.getDimension()); } public Coord4D getCoordFromIndex(int index) @@ -1057,7 +1057,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I int y = start.yCoord+(index/diameter/diameter); int z = start.zCoord+(index/diameter)%diameter; - return new Coord4D(x, y, z, worldObj.provider.getDimension()); + return new Coord4D(x, y, z, world.provider.getDimension()); } @Override @@ -1144,8 +1144,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I } BlockPos pos1 = getPos().add(x, y, z); - MekanismUtils.makeAdvancedBoundingBlock(worldObj, pos1, Coord4D.get(this)); - worldObj.notifyNeighborsOfStateChange(pos1, getBlockType()); + MekanismUtils.makeAdvancedBoundingBlock(world, pos1, Coord4D.get(this)); + world.notifyNeighborsOfStateChange(pos1, getBlockType(), true); } } } @@ -1166,7 +1166,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { for(int z = -1; z <= +1; z++) { - worldObj.setBlockToAir(getPos().add(x, y, z)); + world.setBlockToAir(getPos().add(x, y, z)); } } } @@ -1181,7 +1181,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I public TileEntity getEjectTile() { EnumFacing side = facing.getOpposite(); - return worldObj.getTileEntity(getPos().up().offset(side)); + return world.getTileEntity(getPos().up().offset(side)); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java index 8b301bdf6..548917ca7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java @@ -54,7 +54,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { @@ -94,7 +94,7 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl @Override public T getCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index 5340044d0..681c7456c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -57,9 +57,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public void register() { - if(!worldObj.isRemote) + if(!world.isRemote) { - IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); if(registered != this) { @@ -79,9 +79,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public void deregister() { - if(!worldObj.isRemote) + if(!world.isRemote) { - IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); if(registered instanceof IEnergyTile) { diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java index 948e53b07..be4cf4112 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java @@ -66,10 +66,10 @@ public abstract class TileEntityElectricMachine= energyPerTick) { @@ -149,9 +149,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I super.onUpdate(); - if(!worldObj.isRemote && fluidTank.getFluid() != null) + if(!world.isRemote && fluidTank.getFluid() != null) { - TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.UP).getTileEntity(worldObj); + TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.UP).getTileEntity(world); if(tileEntity != null && CapabilityUtils.hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) { @@ -176,7 +176,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I for(EnumFacing orientation : EnumFacing.VALUES) { Coord4D wrapper = Coord4D.get(this).offset(orientation); - FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); + FluidStack fluid = MekanismUtils.getFluid(world, wrapper, hasFilter()); if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) { @@ -188,7 +188,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(shouldTake(fluid, wrapper)) { - worldObj.setBlockToAir(wrapper.getPos()); + world.setBlockToAir(wrapper.getPos()); } } @@ -200,7 +200,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I //and then add the adjacent block to the recurring list for(Coord4D wrapper : tempPumpList) { - FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); + FluidStack fluid = MekanismUtils.getFluid(world, wrapper, hasFilter()); if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) { @@ -211,7 +211,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(shouldTake(fluid, wrapper)) { - worldObj.setBlockToAir(wrapper.getPos()); + world.setBlockToAir(wrapper.getPos()); } } @@ -225,7 +225,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(Coord4D.get(this).distanceTo(side) <= general.maxPumpRange) { - fluid = MekanismUtils.getFluid(worldObj, side, hasFilter()); + fluid = MekanismUtils.getFluid(world, side, hasFilter()); if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) { @@ -237,7 +237,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I if(shouldTake(fluid, side)) { - worldObj.setBlockToAir(side.getPos()); + world.setBlockToAir(side.getPos()); } } @@ -514,7 +514,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I { reset(); - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.pumpReset"))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.pumpReset"))); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index c23e1a878..30fabc9f7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -115,18 +115,18 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -403,7 +403,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp { updateDelay = MekanismConfig.general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index 4c74a43ab..aa40026b3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -81,7 +81,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.charge(0, this); ChargeUtils.discharge(1, this); @@ -235,7 +235,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo if(prevTier != tier) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -293,7 +293,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo public int getRedstoneLevel() { double fractionFull = getEnergy()/getMaxEnergy(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); + return MathHelper.floor((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index 3a157f142..1633fdcb7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityFactory.java @@ -191,10 +191,10 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I return false; } - worldObj.setBlockToAir(getPos()); - worldObj.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5+tier.ordinal()+1), 3); + world.setBlockToAir(getPos()); + world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5+tier.ordinal()+1), 3); - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(getPos()); + TileEntityFactory factory = (TileEntityFactory)world.getTileEntity(getPos()); //Basic factory.facing = facing; @@ -269,22 +269,22 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(ticker == 1) { - worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); + world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } if(updateDelay > 0) @@ -338,7 +338,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); + world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); MekanismUtils.saveChunk(this); } @@ -487,7 +487,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I public int size() { - return stack != null ? stack.stackSize : 0; + return stack != null ? stack.getCount() : 0; } public Item item() @@ -532,9 +532,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I { gasTank.receive(stack, true); - inventory[4].stackSize--; + inventory[4].shrink(1); - if(inventory[4].stackSize == 0) + if(inventory[4].getCount() == 0) { inventory[4] = null; } @@ -552,9 +552,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I { infuseStored.amount += infuse.stored; infuseStored.type = infuse.type; - inventory[4].stackSize--; + inventory[4].shrink(1); - if(inventory[4].stackSize <= 0) + if(inventory[4].getCount() <= 0) { inventory[4] = null; } @@ -780,7 +780,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I if(!upgraded) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } @@ -801,13 +801,13 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } if(upgraded) { markDirty(); - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); upgraded = false; } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index 53615084c..977ae3847 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -110,7 +110,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public void onUpdate() { - if(worldObj.isRemote) + if(world.isRemote) { if(updateDelay > 0) { @@ -119,7 +119,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } @@ -197,7 +197,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc { if(fluidTank.getFluid() != null) { - TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(worldObj); + TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.DOWN).getTileEntity(world); if(tileEntity != null && CapabilityUtils.hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP)) { @@ -244,9 +244,9 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc { Coord4D up = Coord4D.get(this).offset(EnumFacing.UP); - if(up.getTileEntity(worldObj) instanceof TileEntityFluidTank) + if(up.getTileEntity(world) instanceof TileEntityFluidTank) { - IFluidHandler handler = CapabilityUtils.getCapability(up.getTileEntity(worldObj), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); + IFluidHandler handler = CapabilityUtils.getCapability(up.getTileEntity(world), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); if(PipeUtils.canFill(handler, fluid)) { @@ -361,7 +361,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -369,7 +369,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public int getRedstoneLevel() { double fractionFull = (float)fluidTank.getFluidAmount()/(float)fluidTank.getCapacity(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); + return MathHelper.floor((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } public int getCurrentNeeded() @@ -382,7 +382,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc } Coord4D top = Coord4D.get(this).offset(EnumFacing.UP); - TileEntity topTile = top.getTileEntity(worldObj); + TileEntity topTile = top.getTileEntity(world); if(topTile instanceof TileEntityFluidTank) { @@ -465,10 +465,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { - if(!worldObj.isRemote) + if(!world.isRemote) { setActive(!getActive()); - worldObj.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); + world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.UI_BUTTON_CLICK, SoundCategory.BLOCKS, 0.3F, 1); } return EnumActionResult.SUCCESS; @@ -562,9 +562,9 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc @Override public boolean canFill(EnumFacing from, Fluid fluid) { - if(from == EnumFacing.DOWN && worldObj != null && getPos() != null) + if(from == EnumFacing.DOWN && world != null && getPos() != null) { - TileEntity tile = worldObj.getTileEntity(getPos().offset(EnumFacing.DOWN)); + TileEntity tile = world.getTileEntity(getPos().offset(EnumFacing.DOWN)); if(isActive && !(tile instanceof TileEntityFluidTank)) { diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java index 0a5664592..f80f74943 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java @@ -87,7 +87,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen @Override public void onUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.discharge(2, this); @@ -125,7 +125,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen { if(fluidTank.getFluid().getFluid().canBePlacedInWorld()) { - worldObj.setBlockState(below.getPos(), MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3); + world.setBlockState(below.getPos(), MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3); setEnergy(getEnergy() - energyPerTick); fluidTank.drain(Fluid.BUCKET_VOLUME, true); @@ -171,11 +171,11 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen for(Coord4D coord : activeNodes) { - if(coord.exists(worldObj)) + if(coord.exists(world)) { if(canReplace(coord, true, false)) { - worldObj.setBlockState(coord.getPos(), MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3); + world.setBlockState(coord.getPos(), MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()).getDefaultState(), 3); fluidTank.drain(Fluid.BUCKET_VOLUME, true); } @@ -184,7 +184,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen { Coord4D sideCoord = coord.offset(dir); - if(sideCoord.exists(worldObj) && canReplace(sideCoord, true, true)) + if(sideCoord.exists(world) && canReplace(sideCoord, true, true)) { activeNodes.add(sideCoord); } @@ -212,17 +212,17 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen return false; } - if(coord.isAirBlock(worldObj) || MekanismUtils.isDeadFluid(worldObj, coord)) + if(coord.isAirBlock(world) || MekanismUtils.isDeadFluid(world, coord)) { return true; } - if(MekanismUtils.isFluid(worldObj, coord)) + if(MekanismUtils.isFluid(world, coord)) { return isPathfinding; } - return coord.getBlock(worldObj).isReplaceable(worldObj, coord.getPos()); + return coord.getBlock(world).isReplaceable(world, coord.getPos()); } @Override @@ -482,7 +482,7 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen usedNodes.clear(); finishedCalc = false; - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.plenisherReset"))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.plenisherReset"))); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java index 9aedb7eea..10814fba1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java @@ -97,7 +97,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.discharge(1, this); @@ -188,11 +188,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im if(item.getInventory(inventory[2]) != null && !item.isInvalid(inventory[2])) { - RecipeFormula itemFormula = new RecipeFormula(worldObj, item.getInventory(inventory[2])); + RecipeFormula itemFormula = new RecipeFormula(world, item.getInventory(inventory[2])); - if(itemFormula.isValidFormula(worldObj)) + if(itemFormula.isValidFormula(world)) { - if(formula != null && !formula.isFormulaEqual(worldObj, itemFormula)) + if(formula != null && !formula.isFormulaEqual(world, itemFormula)) { formula = itemFormula; operatingTicks = 0; @@ -217,7 +217,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im { super.markDirty(); - if(worldObj != null && !worldObj.isRemote) + if(world != null && !world.isRemote) { if(formula == null) { @@ -226,11 +226,11 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im dummyInv.setInventorySlotContents(i, inventory[27+i]); } - lastOutputStack = MekanismUtils.findMatchingRecipe(dummyInv, worldObj); + lastOutputStack = MekanismUtils.findMatchingRecipe(dummyInv, world); isRecipe = lastOutputStack != null; } else { - isRecipe = formula.matches(worldObj, inventory, 27); + isRecipe = formula.matches(world, inventory, 27); lastOutputStack = isRecipe ? formula.recipe.getRecipeOutput() : null; } } @@ -255,14 +255,14 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im { ItemStack stack = inventory[i]; - inventory[i].stackSize--; + inventory[i].shrink(1); - if(inventory[i].stackSize == 0) + if(inventory[i].getCount() == 0) { inventory[i] = null; } - if(stack.stackSize == 0 && stack.getItem().hasContainerItem(stack)) + if(stack.getCount() == 0 && stack.getItem().hasContainerItem(stack)) { ItemStack container = stack.getItem().getContainerItem(stack); @@ -305,7 +305,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im { boolean canOperate = true; - if(!formula.matches(worldObj, inventory, 27)) + if(!formula.matches(world, inventory, 27)) { canOperate = moveItemsToGrid(); } @@ -328,7 +328,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im for(int i = 27; i <= 35; i++) { - if(formula.isIngredientInPos(worldObj, inventory[i], i-27)) + if(formula.isIngredientInPos(world, inventory[i], i-27)) { continue; } @@ -348,12 +348,12 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im for(int j = 3; j <= 20; j++) { - if(inventory[j] != null && formula.isIngredientInPos(worldObj, inventory[j], i-27)) + if(inventory[j] != null && formula.isIngredientInPos(world, inventory[j], i-27)) { inventory[i] = StackUtils.size(inventory[j], 1); - inventory[j].stackSize--; + inventory[j].shrink(1); - if(inventory[j].stackSize == 0) + if(inventory[j].getCount() == 0) { inventory[j] = null; } @@ -384,7 +384,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im { for(int i = 27; i <= 35; i++) { - if(inventory[i] != null && (forcePush || (formula != null && !formula.isIngredientInPos(worldObj, inventory[i], i-27)))) + if(inventory[i] != null && (forcePush || (formula != null && !formula.isIngredientInPos(world, inventory[i], i-27)))) { inventory[i] = tryMoveToInput(inventory[i]); } @@ -421,14 +421,14 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im return null; } - else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].stackSize < inventory[i].getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].getCount() < inventory[i].getMaxStackSize()) { - int toUse = Math.min(stack.stackSize, inventory[i].getMaxStackSize()-inventory[i].stackSize); + int toUse = Math.min(stack.getCount(), inventory[i].getMaxStackSize()-inventory[i].getCount()); - inventory[i].stackSize += toUse; - stack.stackSize -= toUse; + inventory[i].grow(toUse); + stack.shrink(toUse); - if(stack.stackSize == 0) + if(stack.getCount() == 0) { return null; } @@ -453,18 +453,18 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im return true; } - else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].stackSize < inventory[i].getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].getCount() < inventory[i].getMaxStackSize()) { - int toUse = Math.min(stack.stackSize, inventory[i].getMaxStackSize()-inventory[i].stackSize); + int toUse = Math.min(stack.getCount(), inventory[i].getMaxStackSize()-inventory[i].getCount()); if(doMove) { - inventory[i].stackSize += toUse; + inventory[i].grow(toUse); } - stack.stackSize -= toUse; + stack.shrink(toUse); - if(stack.stackSize == 0) + if(stack.getCount() == 0) { return true; } @@ -482,9 +482,9 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im if(item.getInventory(inventory[2]) == null) { - RecipeFormula formula = new RecipeFormula(worldObj, inventory, 27); + RecipeFormula formula = new RecipeFormula(world, inventory, 27); - if(formula.isValidFormula(worldObj)) + if(formula.isValidFormula(world)) { item.setInventory(inventory[2], formula.input); } @@ -529,7 +529,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im return true; } else { - return formula.isIngredient(worldObj, itemstack); + return formula.isIngredient(world, itemstack); } } else if(slotID == 1) @@ -624,7 +624,7 @@ public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock im } } - formula = new RecipeFormula(worldObj, inv); + formula = new RecipeFormula(world, inv); } else { formula = null; diff --git a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java index 76a1bd0f3..ee3229cd5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java @@ -55,18 +55,18 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public void onUpdate() { - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -92,9 +92,9 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement if(burnTime > 0) { - inventory[0].stackSize--; + inventory[0].shrink(1); - if(inventory[0].stackSize == 0) + if(inventory[0].getCount() == 0) { inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); } @@ -160,7 +160,7 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -272,7 +272,7 @@ public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implement @Override public IHeatTransfer getAdjacent(EnumFacing side) { - TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); if(CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { diff --git a/src/main/java/mekanism/common/tile/TileEntityGasTank.java b/src/main/java/mekanism/common/tile/TileEntityGasTank.java index 12c17f4d3..3856b33b0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGasTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityGasTank.java @@ -96,7 +96,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH @Override public void onUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { if(inventory[0] != null && gasTank.getGas() != null) { @@ -309,7 +309,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH if(prevTier != tier) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -377,7 +377,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH public int getRedstoneLevel() { double fractionFull = (float)gasTank.getStored()/(float)gasTank.getMaxGas(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); + return MathHelper.floor((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java index cd2c68bd2..7ada7fce7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java @@ -45,7 +45,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock())), new Range4D(Coord4D.get(this))); - player.openGui(Mekanism.instance, 49, worldObj, getPos().getX(), getPos().getY(), getPos().getZ()); + player.openGui(Mekanism.instance, 49, world, getPos().getX(), getPos().getY(), getPos().getZ()); return true; } @@ -82,7 +82,7 @@ public class TileEntityInductionCasing extends TileEntityMultiblock())), new Range4D(Coord4D.get(this))); markDirty(); diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java index 0c2e9ebde..4af844969 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java @@ -34,7 +34,7 @@ public class TileEntityInductionProvider extends TileEntityBasicBlock if(prevTier != tier) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index 068671c59..011c3f22c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -44,12 +44,12 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc { super.onUpdate(); - if(worldObj.isRemote) + if(world.isRemote) { if(isActive) { - RayTraceResult mop = LaserManager.fireLaserClient(this, facing, usage.laserUsage, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop, worldObj); + RayTraceResult mop = LaserManager.fireLaserClient(this, facing, usage.laserUsage, world); + Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -59,9 +59,9 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig())))) { @@ -80,8 +80,8 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc { setActive(true); - LaserInfo info = LaserManager.fireLaser(this, facing, usage.laserUsage, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, worldObj); + LaserInfo info = LaserManager.fireLaser(this, facing, usage.laserUsage, world); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -91,9 +91,9 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { @@ -101,7 +101,7 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness) { - LaserManager.breakBlock(hitCoord, true, worldObj); + LaserManager.breakBlock(hitCoord, true, world); diggingProgress = 0; } } @@ -174,7 +174,7 @@ public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IAc if(clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java index 2718fc52a..5e1cd302e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java @@ -76,12 +76,12 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement @Override public void onUpdate() { - if(worldObj.isRemote) + if(world.isRemote) { if(on) { - RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop, worldObj); + RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, world); + Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -91,9 +91,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig())))) { @@ -132,8 +132,8 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } - LaserInfo info = LaserManager.fireLaser(this, facing, firing, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, worldObj); + LaserInfo info = LaserManager.fireLaser(this, facing, firing, world); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -143,9 +143,9 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { @@ -153,7 +153,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness) { - LaserManager.breakBlock(hitCoord, true, worldObj); + LaserManager.breakBlock(hitCoord, true, world); diggingProgress = 0; } } @@ -185,7 +185,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement if(emittingRedstone != prevRedstone) { - worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); + world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } } } @@ -220,7 +220,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement } double fractionFull = getEnergy()/getMaxEnergy(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); + return MathHelper.floor((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java index 7c3852ee0..c3dc4cf49 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java @@ -62,12 +62,12 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme @Override public void onUpdate() { - if(worldObj.isRemote) + if(world.isRemote) { if(on) { - RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop, worldObj); + RayTraceResult mop = LaserManager.fireLaserClient(this, facing, lastFired, world); + Coord4D hitCoord = mop == null ? null : new Coord4D(mop, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -77,9 +77,9 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, mop.sideHit) && !(LaserManager.getReceptor(tileHit, mop.sideHit).canLasersDig())))) { @@ -106,8 +106,8 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); } - LaserInfo info = LaserManager.fireLaser(this, facing, firing, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, worldObj); + LaserInfo info = LaserManager.fireLaser(this, facing, firing, world); + Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos, world); if(hitCoord == null || !hitCoord.equals(digging)) { @@ -117,9 +117,9 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme if(hitCoord != null) { - IBlockState blockHit = hitCoord.getBlockState(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.getPos()); + IBlockState blockHit = hitCoord.getBlockState(world); + TileEntity tileHit = hitCoord.getTileEntity(world); + float hardness = blockHit.getBlockHardness(world, hitCoord.getPos()); if(!(hardness < 0 || (LaserManager.isReceptor(tileHit, info.movingPos.sideHit) && !(LaserManager.getReceptor(tileHit, info.movingPos.sideHit).canLasersDig())))) { @@ -127,7 +127,7 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme if(diggingProgress >= hardness * general.laserEnergyNeededPerHardness) { - List drops = LaserManager.breakBlock(hitCoord, false, worldObj); + List drops = LaserManager.breakBlock(hitCoord, false, world); if(drops != null) receiveDrops(drops); diggingProgress = 0; } @@ -167,27 +167,30 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme inventory[i] = drop; continue outer; } + ItemStack slot = inventory[i]; + if(StackUtils.equalsWildcardWithNBT(slot, drop)) { - int change = Math.min(drop.stackSize, slot.getMaxStackSize() - slot.stackSize); - slot.stackSize += change; - drop.stackSize -= change; - if(drop.stackSize <= 0) continue outer; + int change = Math.min(drop.getCount(), slot.getMaxStackSize() - slot.getCount()); + slot.grow(change); + drop.shrink(change); + if(drop.getCount() <= 0) continue outer; } } + dropItem(drop); } } public void dropItem(ItemStack stack) { - EntityItem item = new EntityItem(worldObj, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, stack); - item.motionX = worldObj.rand.nextGaussian() * 0.05; - item.motionY = worldObj.rand.nextGaussian() * 0.05 + 0.2; - item.motionZ = worldObj.rand.nextGaussian() * 0.05; + EntityItem item = new EntityItem(world, getPos().getX() + 0.5, getPos().getY() + 1, getPos().getZ() + 0.5, stack); + item.motionX = world.rand.nextGaussian() * 0.05; + item.motionY = world.rand.nextGaussian() * 0.05 + 0.2; + item.motionZ = world.rand.nextGaussian() * 0.05; item.setPickupDelay(10); - worldObj.spawnEntityInWorld(item); + world.spawnEntity(item); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index 3a20aa8d8..dd0f64e65 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -84,7 +84,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { delayTicks = Math.max(0, delayTicks-1); @@ -95,8 +95,8 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(MekanismUtils.canFunction(this) && delayTicks == 0) { - TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(worldObj); - TileEntity front = Coord4D.get(this).offset(facing).getTileEntity(worldObj); + TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(world); + TileEntity front = Coord4D.get(this).offset(facing).getTileEntity(world); if(back instanceof IInventory && (front != null && CapabilityUtils.hasCapability(front, Capabilities.LOGISTICAL_TRANSPORTER_CAPABILITY, facing.getOpposite()) || front instanceof IInventory)) { @@ -134,7 +134,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(used != null) { - invStack.use(used.stackSize); + invStack.use(used.getCount()); inventory.markDirty(); setActive(true); sentItems = true; @@ -155,7 +155,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(used != null) { - invStack.use(used.stackSize); + invStack.use(used.getCount()); inventory.markDirty(); setActive(true); } @@ -468,7 +468,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen public boolean canSendHome(ItemStack stack) { - TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(worldObj); + TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(world); if(back instanceof IInventory) { @@ -480,12 +480,12 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen public boolean hasInventory() { - return Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(worldObj) instanceof IInventory; + return Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(world) instanceof IInventory; } public ItemStack sendHome(ItemStack stack) { - TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(worldObj); + TileEntity back = Coord4D.get(this).offset(facing.getOpposite()).getTileEntity(world); if(back instanceof IInventory) { @@ -527,7 +527,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen @Override public void openInventory(EntityPlayer player) { - if(!worldObj.isRemote) + if(!world.isRemote) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), new Range4D(Coord4D.get(this))); } @@ -562,7 +562,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen if(active && client.enableMachineSounds) { - worldObj.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), MekanismSounds.CLICK, SoundCategory.BLOCKS, 0.3F, 1); + world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), MekanismSounds.CLICK, SoundCategory.BLOCKS, 0.3F, 1); } clientActive = active; diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 80ad13a3c..db63b2d7a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -119,18 +119,18 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -156,9 +156,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i { infuseStored.amount += infuse.stored; infuseStored.type = infuse.type; - inventory[1].stackSize--; + inventory[1].shrink(1); - if(inventory[1].stackSize <= 0) + if(inventory[1].getCount() <= 0) { inventory[1] = null; } @@ -213,10 +213,10 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i return false; } - worldObj.setBlockToAir(getPos()); - worldObj.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5), 3); + world.setBlockToAir(getPos()); + world.setBlockState(getPos(), MekanismBlocks.MachineBlock.getStateFromMeta(5), 3); - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(getPos()); + TileEntityFactory factory = (TileEntityFactory)world.getTileEntity(getPos()); RecipeType type = RecipeType.INFUSING; //Basic @@ -419,7 +419,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java index 10c85fa31..ed760f50e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java +++ b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java @@ -59,7 +59,7 @@ public abstract class TileEntityMultiblock> extend @Override public void onUpdate() { - if(worldObj.isRemote) + if(world.isRemote) { if(structure == null) { @@ -77,16 +77,16 @@ public abstract class TileEntityMultiblock> extend prevStructure = clientHasStructure; } - if(playersUsing.size() > 0 && ((worldObj.isRemote && !clientHasStructure) || (!worldObj.isRemote && structure == null))) + if(playersUsing.size() > 0 && ((world.isRemote && !clientHasStructure) || (!world.isRemote && structure == null))) { for(EntityPlayer player : playersUsing) { - System.out.println(worldObj.isRemote + " " + clientHasStructure + " " + structure); + System.out.println(world.isRemote + " " + clientHasStructure + " " + structure); //player.closeScreen(); } } - if(!worldObj.isRemote) + if(!world.isRemote) { //System.out.println(pos + " " + structure); if(structure == null) @@ -116,11 +116,11 @@ public abstract class TileEntityMultiblock> extend for(EnumFacing side : EnumFacing.VALUES) { Coord4D obj = Coord4D.get(this).offset(side); - TileEntity tile = obj.getTileEntity(worldObj); + TileEntity tile = obj.getTileEntity(world); - if(!obj.isAirBlock(worldObj) && (tile == null || tile.getClass() != getClass())) + if(!obj.isAirBlock(world) && (tile == null || tile.getClass() != getClass())) { - obj.getBlock(worldObj).onNeighborChange(worldObj, obj.getPos(), getPos()); + obj.getBlock(world).onNeighborChange(world, obj.getPos(), getPos()); } } @@ -147,7 +147,7 @@ public abstract class TileEntityMultiblock> extend @Override public void doUpdate() { - if(!worldObj.isRemote && (structure == null || !getSynchronizedData().didTick)) + if(!world.isRemote && (structure == null || !getSynchronizedData().didTick)) { getProtocol().doUpdate(); @@ -164,7 +164,7 @@ public abstract class TileEntityMultiblock> extend { for(Coord4D obj : getSynchronizedData().locations) { - TileEntityMultiblock tileEntity = (TileEntityMultiblock)obj.getTileEntity(worldObj); + TileEntityMultiblock tileEntity = (TileEntityMultiblock)obj.getTileEntity(world); if(tileEntity != null && tileEntity.isRendering) { @@ -285,9 +285,9 @@ public abstract class TileEntityMultiblock> extend { getSynchronizedData().getInventory()[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if(itemstack != null && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.setCount(getInventoryStackLimit()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java index c170543a3..745b6d68f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java @@ -113,7 +113,7 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo { super.validate(); - if(worldObj.isRemote) + if(world.isRemote) { try { soundURL = HolidayManager.filterSound(new ResourceLocation("mekanism", "tile." + soundPath)); @@ -133,7 +133,7 @@ public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlo { super.onUpdate(); - if(worldObj.isRemote) + if(world.isRemote) { updateSound(); } diff --git a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java index e17350413..3513779e6 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java +++ b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java @@ -59,7 +59,7 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public void onUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { if(playersUsing.size() > 0) { @@ -79,9 +79,9 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple { if(inventory[1] == null) { - inventory[0].stackSize--; + inventory[0].shrink(1); - if(inventory[0].stackSize <= 0) + if(inventory[0].getCount() <= 0) { inventory[0] = null; } @@ -89,16 +89,16 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple inventory[1] = result; didProcess = true; } - else if(inventory[1].isItemEqual(result) && inventory[1].stackSize < inventory[1].getMaxStackSize()) + else if(inventory[1].isItemEqual(result) && inventory[1].getCount() < inventory[1].getMaxStackSize()) { - inventory[0].stackSize--; + inventory[0].shrink(1); - if(inventory[0].stackSize <= 0) + if(inventory[0].getCount() <= 0) { inventory[0] = null; } - inventory[1].stackSize++; + inventory[1].grow(1); didProcess = true; } @@ -319,7 +319,7 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple @Override public void openInventory(EntityPlayer player) { - if(!worldObj.isRemote) + if(!world.isRemote) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), new Range4D(Coord4D.get(this))); } diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index 7e329f26b..4ac75b2c0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -95,7 +95,7 @@ public class TileEntityPRC extends TileEntityBasicMachine 0) && (lidAngle == 0.0F)) { - worldObj.playSound(null, getPos().getX() + 0.5F, getPos().getY() + 0.5D, getPos().getZ() + 0.5F, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); + world.playSound(null, getPos().getX() + 0.5F, getPos().getY() + 0.5D, getPos().getZ() + 0.5F, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, (world.rand.nextFloat()*0.1F) + 0.9F); } if((playersUsing.size() == 0 && lidAngle > 0.0F) || (playersUsing.size() > 0 && lidAngle < 1.0F)) @@ -60,7 +60,7 @@ public class TileEntityPersonalChest extends TileEntityContainerBlock implements if(lidAngle < split && angle >= split) { - worldObj.playSound(null, getPos().getX() + 0.5D, getPos().getY() + 0.5D, getPos().getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); + world.playSound(null, getPos().getX() + 0.5D, getPos().getY() + 0.5D, getPos().getZ() + 0.5D, SoundEvents.BLOCK_CHEST_CLOSE, SoundCategory.BLOCKS, 0.5F, (world.rand.nextFloat()*0.1F) + 0.9F); } if(lidAngle < 0.0F) diff --git a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java index e4a0f0539..8447fd209 100644 --- a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java @@ -101,7 +101,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(configComponent.isEjecting(TransmissionType.ENERGY)) { @@ -156,7 +156,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp { super.invalidate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(frequency != null) { @@ -197,7 +197,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp { FrequencyManager manager = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER, getSecurity().getOwner()); Mekanism.privateEntangloporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); + manager.createOrLoad(world); } return Mekanism.privateEntangloporters.get(getSecurity().getOwner()); @@ -526,9 +526,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp { frequency.storedItem = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if(itemstack != null && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.setCount(getInventoryStackLimit()); } } } @@ -585,7 +585,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp @Override public IHeatTransfer getAdjacent(EnumFacing side) { - TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); if(hasFrequency() && configComponent.getOutput(TransmissionType.HEAT, side, facing).ioState == IOState.INPUT) { diff --git a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java index 7c080686a..1447a8a0b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java @@ -63,18 +63,18 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { boolean packet = false; @@ -194,7 +194,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -264,7 +264,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl @Override public IHeatTransfer getAdjacent(EnumFacing side) { - TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); if(CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index 95e4005e8..7af6230bd 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -97,7 +97,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { super.onUpdate(); - if(worldObj.isRemote) + if(world.isRemote) { if(updateDelay > 0) { @@ -106,12 +106,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -280,7 +280,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java index d1c88919a..9a4babe91 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java +++ b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java @@ -41,7 +41,7 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements @Override public void onUpdate() { - if(!worldObj.isRemote) + if(!world.isRemote) { if(owner != null && frequency != null) { @@ -280,7 +280,7 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements { super.invalidate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(frequency != null) { @@ -297,14 +297,14 @@ public class TileEntitySecurityDesk extends TileEntityContainerBlock implements @Override public void onPlace() { - MekanismUtils.makeBoundingBlock(worldObj, getPos().up(), Coord4D.get(this)); + MekanismUtils.makeBoundingBlock(world, getPos().up(), Coord4D.get(this)); } @Override public void onBreak() { - worldObj.setBlockToAir(getPos().up()); - worldObj.setBlockToAir(getPos()); + world.setBlockToAir(getPos().up()); + world.setBlockToAir(getPos()); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index 4b6da6656..5da9b5ff1 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -53,7 +53,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement { super.onUpdate(); - if(worldObj.isRemote) + if(world.isRemote) { if(isActive) { @@ -67,7 +67,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -145,7 +145,7 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -233,14 +233,14 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement @Override public void onPlace() { - MekanismUtils.makeBoundingBlock(worldObj, getPos().up(), Coord4D.get(this)); + MekanismUtils.makeBoundingBlock(world, getPos().up(), Coord4D.get(this)); } @Override public void onBreak() { - worldObj.setBlockToAir(getPos().up()); - worldObj.setBlockToAir(getPos()); + world.setBlockToAir(getPos().up()); + world.setBlockToAir(getPos()); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java index e39157be0..b014f990b 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java @@ -79,18 +79,18 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void onUpdate() { - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -114,9 +114,9 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im SolarNeutronRecipe recipe = getRecipe(); - boolean sky = ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.getHasNoSky() && worldObj.canSeeSky(getPos().up()); + boolean sky = ((!world.isRaining() && !world.isThundering()) || isDesert()) && !world.provider.hasNoSky() && world.canSeeSky(getPos().up()); - if(worldObj.isDaytime() && sky && canOperate(recipe) && MekanismUtils.canFunction(this)) + if(world.isDaytime() && sky && canOperate(recipe) && MekanismUtils.canFunction(this)) { setActive(true); @@ -144,7 +144,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im public boolean isDesert() { - return worldObj.provider.getBiomeForCoords(getPos()) instanceof BiomeDesert; + return world.provider.getBiomeForCoords(getPos()) instanceof BiomeDesert; } public SolarNeutronRecipe getRecipe() @@ -208,7 +208,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -279,14 +279,14 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im @Override public void onPlace() { - MekanismUtils.makeBoundingBlock(worldObj, Coord4D.get(this).offset(EnumFacing.UP).getPos(), Coord4D.get(this)); + MekanismUtils.makeBoundingBlock(world, Coord4D.get(this).offset(EnumFacing.UP).getPos(), Coord4D.get(this)); } @Override public void onBreak() { - worldObj.setBlockToAir(getPos().up()); - worldObj.setBlockToAir(getPos()); + world.setBlockToAir(getPos().up()); + world.setBlockToAir(getPos()); } @Override diff --git a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java index 0afacfd5e..960a107e6 100644 --- a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java +++ b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java @@ -21,7 +21,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural { if(master != null) { - TileEntity masterTile = master.getTileEntity(worldObj); + TileEntity masterTile = master.getTileEntity(world); if(masterTile instanceof IMultiblock) { @@ -40,7 +40,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural { if(master != null) { - TileEntity masterTile = master.getTileEntity(worldObj); + TileEntity masterTile = master.getTileEntity(world); if(masterTile instanceof IMultiblock) { @@ -90,7 +90,7 @@ public class TileEntityStructuralGlass extends TileEntity implements IStructural for(EnumFacing side : EnumFacing.VALUES) { Coord4D coord = pos.offset(side); - TileEntity tile = coord.getTileEntity(worldObj); + TileEntity tile = coord.getTileEntity(world); if(!iterated.contains(coord)) { diff --git a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java index 867f0ad29..5b73f70ad 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java +++ b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java @@ -38,7 +38,7 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock super.setMultiblock(id); - if(packet && !worldObj.isRemote) + if(packet && !world.isRemote) { Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); } @@ -47,7 +47,7 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock @Override public void onUpdate() { - if(worldObj.isRemote) + if(world.isRemote) { boolean newHot = false; @@ -58,7 +58,7 @@ public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock if(prevHot != newHot) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); prevHot = newHot; } diff --git a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index 0e36c3561..9cba43007 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -107,7 +107,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo resetBounds(); } - if(!worldObj.isRemote) + if(!world.isRemote) { FrequencyManager manager = getManager(frequency); @@ -215,7 +215,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { FrequencyManager manager = new FrequencyManager(Frequency.class, Frequency.TELEPORTER, getSecurity().getOwner()); Mekanism.privateTeleporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); + manager.createOrLoad(world); } return Mekanism.privateTeleporters.get(getSecurity().getOwner()); @@ -237,7 +237,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { super.onChunkUnload(); - if(!worldObj.isRemote && frequency != null) + if(!world.isRemote && frequency != null) { FrequencyManager manager = getManager(frequency); @@ -253,7 +253,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { super.invalidate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(frequency != null) { @@ -271,7 +271,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { List list = new ArrayList(); - for(Entity e : (List)worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds)) + for(Entity e : (List)world.getEntitiesWithinAABB(Entity.class, teleportBounds)) { list.add(e.getPersistentID()); } @@ -348,7 +348,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public void teleport() { - if(worldObj.isRemote) return; + if(world.isRemote) return; List entitiesInPortal = getToTeleport(); @@ -385,7 +385,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); - worldObj.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, entity.getSoundCategory(), 1.0F, 1.0F, false); + world.playSound(entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, entity.getSoundCategory(), 1.0F, 1.0F, false); } } } @@ -398,13 +398,13 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo WorldServer oldWorld = player.mcServer.worldServerForDimension(player.dimension); player.dimension = coord.dimensionId; WorldServer newWorld = player.mcServer.worldServerForDimension(player.dimension); - player.connection.sendPacket(new SPacketRespawn(player.dimension, player.worldObj.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType())); + player.connection.sendPacket(new SPacketRespawn(player.dimension, player.world.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType())); oldWorld.removeEntityDangerously(player); player.isDead = false; if(player.isEntityAlive()) { - newWorld.spawnEntityInWorld(player); + newWorld.spawnEntity(player); player.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); newWorld.updateEntityWithOptionalForce(player, false); player.setWorld(newWorld); @@ -434,18 +434,18 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { WorldServer world = server.worldServerForDimension(coord.dimensionId); - if(entity.worldObj.provider.getDimension() != coord.dimensionId) + if(entity.world.provider.getDimension() != coord.dimensionId) { - entity.worldObj.removeEntity(entity); + entity.world.removeEntity(entity); entity.isDead = false; - world.spawnEntityInWorld(entity); + world.spawnEntity(entity); entity.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, entity.rotationYaw, entity.rotationPitch); world.updateEntityWithOptionalForce(entity, false); entity.setWorld(world); world.resetUpdateEntityTick(); - Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), world); + Entity e = EntityList.newEntity(entity.getClass(), world); if(e != null) { @@ -456,7 +456,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo exception.printStackTrace(); } - world.spawnEntityInWorld(e); + world.spawnEntity(e); teleporter.didTeleport.add(e.getPersistentID()); } @@ -476,7 +476,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo for(EnumFacing iterSide : MekanismUtils.SIDE_DIRS) { - if(upperCoord.offset(iterSide).isAirBlock(player.worldObj)) + if(upperCoord.offset(iterSide).isAirBlock(player.world)) { side = iterSide; break; @@ -509,7 +509,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public List getToTeleport() { - List entities = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds); + List entities = world.getEntitiesWithinAABB(Entity.class, teleportBounds); List ret = new ArrayList(); for(Entity entity : entities) @@ -527,7 +527,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo { int energyCost = 1000; - if(entity.worldObj.provider.getDimension() != coords.dimensionId) + if(entity.world.provider.getDimension() != coords.dimensionId) { energyCost+=10000; } @@ -555,7 +555,7 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo public boolean isFrame(int x, int y, int z) { - IBlockState state = worldObj.getBlockState(new BlockPos(x, y, z)); + IBlockState state = world.getBlockState(new BlockPos(x, y, z)); return state.getBlock() == MekanismBlocks.BasicBlock && state.getBlock().getMetaFromState(state) == 7; } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java index 13f998d23..120941541 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java @@ -33,7 +33,7 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock @Override public void onUpdate() { - if(!worldObj.isRemote && ticker == 5 && !attempted && master == null) + if(!world.isRemote && ticker == 5 && !attempted && master == null) { updateController(); } @@ -72,7 +72,7 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock { super.onNeighborChange(block); - if(!worldObj.isRemote) + if(!world.isRemote) { TileEntityThermalEvaporationController tile = getController(); @@ -103,7 +103,7 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock { if(master != null) { - TileEntity tile = master.getTileEntity(worldObj); + TileEntity tile = master.getTileEntity(world); if(tile instanceof TileEntityThermalEvaporationController) { @@ -133,13 +133,13 @@ public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock { Coord4D coord = pos.offset(side); - if(!iterated.contains(coord) && coord.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock) + if(!iterated.contains(coord) && coord.getTileEntity(world) instanceof TileEntityThermalEvaporationBlock) { - ((TileEntityThermalEvaporationBlock)coord.getTileEntity(worldObj)).attempted = true; + ((TileEntityThermalEvaporationBlock)coord.getTileEntity(world)).attempted = true; - if(coord.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationController) + if(coord.getTileEntity(world) instanceof TileEntityThermalEvaporationController) { - found = (TileEntityThermalEvaporationController)coord.getTileEntity(worldObj); + found = (TileEntityThermalEvaporationController)coord.getTileEntity(world); return; } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java index dafd4afc9..e6549b3c7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java @@ -93,7 +93,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { updatedThisTick = false; @@ -188,7 +188,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva protected void refresh() { - if(!worldObj.isRemote) + if(!world.isRemote) { if(!updatedThisTick) { @@ -257,7 +257,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva { if(!temperatureSet) { - biomeTemp = worldObj.getBiomeForCoordsBody(getPos()).getFloatTemperature(getPos()); + biomeTemp = world.getBiomeForCoordsBody(getPos()).getFloatTemperature(getPos()); temperatureSet = true; } @@ -302,7 +302,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva public int getActiveSolars() { - if(worldObj.isRemote) + if(world.isRemote) { return clientSolarAmount; } @@ -331,13 +331,13 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva Coord4D startPoint = Coord4D.get(this); - while(startPoint.offset(EnumFacing.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock) + while(startPoint.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock) { startPoint = startPoint.offset(EnumFacing.UP); } Coord4D test = startPoint.offset(EnumFacing.DOWN).offset(right, 2); - isLeftOnFace = test.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock; + isLeftOnFace = test.getTileEntity(world) instanceof TileEntityThermalEvaporationBlock; startPoint = startPoint.offset(left, isLeftOnFace ? 1 : 2); @@ -380,17 +380,17 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva for(int z = 0; z < 4; z++) { Coord4D pointer = current.offset(right, x).offset(back, z); - TileEntity pointerTile = pointer.getTileEntity(worldObj); + TileEntity pointerTile = pointer.getTileEntity(world); int corner = getCorner(x, z); if(corner != -1) { - if(addSolarPanel(pointer.getTileEntity(worldObj), corner)) + if(addSolarPanel(pointer.getTileEntity(world), corner)) { continue; } - else if(pointer.offset(EnumFacing.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) + else if(pointer.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) { return false; } @@ -398,13 +398,13 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva else { if((x == 1 || x == 2) && (z == 1 || z == 2)) { - if(!pointer.isAirBlock(worldObj)) + if(!pointer.isAirBlock(world)) { return false; } } else { - if(pointer.offset(EnumFacing.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) + if(pointer.offset(EnumFacing.UP).getTileEntity(world) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) { return false; } @@ -455,7 +455,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva for(int z = 0; z < 4; z++) { Coord4D pointer = current.offset(right, x).offset(back, z); - TileEntity pointerTile = pointer.getTileEntity(worldObj); + TileEntity pointerTile = pointer.getTileEntity(world); if((x == 1 || x == 2) && (z == 1 || z == 2)) { @@ -474,7 +474,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva } } else { - if(foundCenter || !pointer.isAirBlock(worldObj)) + if(foundCenter || !pointer.isAirBlock(world)) { height = -1; return false; @@ -589,7 +589,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva if(structured != clientStructured) { inputTank.setCapacity(getMaxFluid()); - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); if(structured) { @@ -692,7 +692,7 @@ public class TileEntityThermalEvaporationController extends TileEntityThermalEva { for(Coord4D tankPart : tankParts) { - TileEntity tile = tankPart.getTileEntity(worldObj); + TileEntity tile = tankPart.getTileEntity(world); if(tile instanceof TileEntityThermalEvaporationBlock) { diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java index 124401c99..e6b813034 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java @@ -22,7 +22,7 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { if((master == null) == prevMaster) { @@ -30,9 +30,9 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat { Coord4D obj = Coord4D.get(this).offset(side); - if(!obj.isAirBlock(worldObj) && !(obj.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock)) + if(!obj.isAirBlock(world) && !(obj.getTileEntity(world) instanceof TileEntityThermalEvaporationBlock)) { - obj.getBlock(worldObj).onNeighborChange(worldObj, obj.getPos(), getPos()); + obj.getBlock(world).onNeighborChange(world, obj.getPos(), getPos()); } } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java index 82b50238f..e7f4c6bf0 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java @@ -207,7 +207,7 @@ public class TileComponentEjector implements ITileComponent } } - if(stack == null || prev.stackSize != stack.stackSize) + if(stack == null || prev.getCount() != stack.getCount()) { trackers.get(TransmissionType.ITEM)[index] = side.ordinal(); } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java index 23ae4e2f7..e212fa9b9 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java @@ -75,9 +75,9 @@ public class TileComponentUpgrade implements ITileComponent upgradeTicks = 0; addUpgrade(type); - tileEntity.inventory[upgradeSlot].stackSize--; + tileEntity.inventory[upgradeSlot].shrink(1); - if(tileEntity.inventory[upgradeSlot].stackSize == 0) + if(tileEntity.inventory[upgradeSlot].getCount() == 0) { tileEntity.inventory[upgradeSlot] = null; } diff --git a/src/main/java/mekanism/common/util/ChargeUtils.java b/src/main/java/mekanism/common/util/ChargeUtils.java index c3986ef6a..9ce8ac1a8 100644 --- a/src/main/java/mekanism/common/util/ChargeUtils.java +++ b/src/main/java/mekanism/common/util/ChargeUtils.java @@ -54,9 +54,9 @@ public final class ChargeUtils else if(inv.getStackInSlot(slotID).getItem() == Items.REDSTONE && storer.getEnergy()+general.ENERGY_PER_REDSTONE <= storer.getMaxEnergy()) { storer.setEnergy(storer.getEnergy() + general.ENERGY_PER_REDSTONE); - inv.getStackInSlot(slotID).stackSize--; + inv.getStackInSlot(slotID).shrink(1); - if(inv.getStackInSlot(slotID).stackSize <= 0) + if(inv.getStackInSlot(slotID).getCount() <= 0) { inv.setInventorySlotContents(slotID, null); } diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index 5e5b0b3f4..e372cde54 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -76,7 +76,7 @@ public final class FluidContainerUtils int drained = insertFluid(stack, inputCopy); - if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].stackSize == inventory[outSlot].getMaxStackSize())) + if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].getCount() == inventory[outSlot].getMaxStackSize())) { return stack; } @@ -89,12 +89,12 @@ public final class FluidContainerUtils } else if(ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy)) { - inventory[outSlot].stackSize++; + inventory[outSlot].grow(1); } - inventory[inSlot].stackSize--; + inventory[inSlot].shrink(1); - if(inventory[inSlot].stackSize == 0) + if(inventory[inSlot].getCount() == 0) { inventory[inSlot] = null; } @@ -135,14 +135,14 @@ public final class FluidContainerUtils ItemStack inputCopy = input.copy(); - if(inputCopy.stackSize == 0) + if(inputCopy.getCount() == 0) { inputCopy = null; } if(FluidUtil.getFluidContained(inputCopy) == null && inputCopy != null) { - if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].stackSize == inventory[outSlot].getMaxStackSize())) + if(inventory[outSlot] != null && (!ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy) || inventory[outSlot].getCount() == inventory[outSlot].getMaxStackSize())) { return stored; } @@ -173,13 +173,13 @@ public final class FluidContainerUtils } else if(ItemHandlerHelper.canItemStacksStack(inventory[outSlot], inputCopy)) { - inventory[outSlot].stackSize++; + inventory[outSlot].grow(1); } } - inventory[inSlot].stackSize--; + inventory[inSlot].shrink(1); - if(inventory[inSlot].stackSize == 0) + if(inventory[inSlot].getCount() == 0) { inventory[inSlot] = null; } diff --git a/src/main/java/mekanism/common/util/InventoryUtils.java b/src/main/java/mekanism/common/util/InventoryUtils.java index 369949c1c..aac1f4e61 100644 --- a/src/main/java/mekanism/common/util/InventoryUtils.java +++ b/src/main/java/mekanism/common/util/InventoryUtils.java @@ -11,6 +11,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.EnumFacing; @@ -91,7 +92,7 @@ public final class InventoryUtils if(inSlot == null) { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) + if(toInsert.getCount() <= inventory.getInventoryStackLimit()) { inventory.setInventorySlotContents(i, toInsert); inventory.markDirty(); @@ -99,13 +100,13 @@ public final class InventoryUtils return null; } else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inventory.getInventoryStackLimit(); ItemStack toSet = toInsert.copy(); - toSet.stackSize = inventory.getInventoryStackLimit(); + toSet.setCount(inventory.getInventoryStackLimit()); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); inventory.setInventorySlotContents(i, toSet); inventory.markDirty(); @@ -113,14 +114,14 @@ public final class InventoryUtils toInsert = remains; } } - else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + toSet.grow(inSlot.getCount()); inventory.setInventorySlotContents(i, toSet); inventory.markDirty(); @@ -128,13 +129,13 @@ public final class InventoryUtils return null; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + toSet.setCount(max); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); inventory.setInventorySlotContents(i, toSet); inventory.markDirty(); @@ -171,7 +172,7 @@ public final class InventoryUtils if(inSlot == null) { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) + if(toInsert.getCount() <= inventory.getInventoryStackLimit()) { inventory.setInventorySlotContents(slotID, toInsert); inventory.markDirty(); @@ -179,13 +180,13 @@ public final class InventoryUtils return null; } else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); + int rejects = toInsert.getCount() - inventory.getInventoryStackLimit(); ItemStack toSet = toInsert.copy(); - toSet.stackSize = inventory.getInventoryStackLimit(); + toSet.setCount(inventory.getInventoryStackLimit()); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); inventory.setInventorySlotContents(slotID, toSet); inventory.markDirty(); @@ -193,14 +194,14 @@ public final class InventoryUtils toInsert = remains; } } - else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(areItemsStackable(toInsert, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + toInsert.stackSize <= max) + if(inSlot.getCount() + toInsert.getCount() <= max) { ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + toSet.grow(inSlot.getCount()); inventory.setInventorySlotContents(slotID, toSet); inventory.markDirty(); @@ -208,13 +209,13 @@ public final class InventoryUtils return null; } else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int rejects = (inSlot.getCount() + toInsert.getCount()) - max; ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + toSet.setCount(max); ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + remains.setCount(rejects); inventory.setInventorySlotContents(slotID, toSet); inventory.markDirty(); @@ -242,10 +243,10 @@ public final class InventoryUtils { for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) { - if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).stackSize > 0) + if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).getCount() > 0) { ItemStack toSend = inventory.getStackInSlot(i).copy(); - toSend.stackSize = Math.min(amount, toSend.stackSize); + toSend.setCount(Math.min(amount, toSend.getCount())); return new InvStack(inventory, i, toSend); } @@ -261,10 +262,10 @@ public final class InventoryUtils { int slotID = slots[get]; - if(sidedInventory.getStackInSlot(slotID) != null && sidedInventory.getStackInSlot(slotID).stackSize > 0) + if(sidedInventory.getStackInSlot(slotID) != null && sidedInventory.getStackInSlot(slotID).getCount() > 0) { ItemStack toSend = sidedInventory.getStackInSlot(slotID).copy(); - toSend.stackSize = Math.min(amount, toSend.stackSize); + toSend.setCount(Math.min(amount, toSend.getCount())); if(sidedInventory.canExtractItem(slotID, toSend, side.getOpposite())) { @@ -291,19 +292,19 @@ public final class InventoryUtils if(inventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(i), type)) { ItemStack stack = inventory.getStackInSlot(i); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + int current = ret.getStack() != null ? ret.getStack().getCount() : 0; - if(current+stack.stackSize <= max) + if(current+stack.getCount() <= max) { ret.appendStack(i, stack.copy()); } else { ItemStack copy = stack.copy(); - copy.stackSize = max-current; + copy.setCount(max-current); ret.appendStack(i, copy); } - if(ret.getStack() != null && ret.getStack().stackSize == max) + if(ret.getStack() != null && ret.getStack().getCount() == max) { return ret; } @@ -323,9 +324,9 @@ public final class InventoryUtils if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(slotID), type)) { ItemStack stack = sidedInventory.getStackInSlot(slotID); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + int current = ret.getStack() != null ? ret.getStack().getCount() : 0; - if(current+stack.stackSize <= max) + if(current+stack.getCount() <= max) { ItemStack copy = stack.copy(); @@ -339,12 +340,12 @@ public final class InventoryUtils if(sidedInventory.canExtractItem(slotID, copy, side.getOpposite())) { - copy.stackSize = max-current; + copy.setCount(max-current); ret.appendStack(slotID, copy); } } - if(ret.getStack() != null && ret.getStack().stackSize == max) + if(ret.getStack() != null && ret.getStack().getCount() == max) { return ret; } @@ -353,7 +354,7 @@ public final class InventoryUtils } } - if(ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) + if(ret != null && ret.getStack() != null && ret.getStack().getCount() >= min) { return ret; } @@ -444,31 +445,31 @@ public final class InventoryUtils if(inSlot == null) { - if(itemStack.stackSize <= inventory.getInventoryStackLimit()) + if(itemStack.getCount() <= inventory.getInventoryStackLimit()) { return true; } else { - int rejects = itemStack.stackSize - inventory.getInventoryStackLimit(); + int rejects = itemStack.getCount() - inventory.getInventoryStackLimit(); - if(rejects < itemStack.stackSize) + if(rejects < itemStack.getCount()) { return true; } } } - else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(areItemsStackable(itemStack, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + itemStack.stackSize <= max) + if(inSlot.getCount() + itemStack.getCount() <= max) { return true; } else { - int rejects = (inSlot.stackSize + itemStack.stackSize) - max; + int rejects = (inSlot.getCount() + itemStack.getCount()) - max; - if(rejects < itemStack.stackSize) + if(rejects < itemStack.getCount()) { return true; } @@ -503,31 +504,31 @@ public final class InventoryUtils if(inSlot == null) { - if(itemStack.stackSize <= inventory.getInventoryStackLimit()) + if(itemStack.getCount() <= inventory.getInventoryStackLimit()) { return true; } else { - int rejects = itemStack.stackSize - inventory.getInventoryStackLimit(); + int rejects = itemStack.getCount() - inventory.getInventoryStackLimit(); - if(rejects < itemStack.stackSize) + if(rejects < itemStack.getCount()) { return true; } } } - else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) + else if(areItemsStackable(itemStack, inSlot) && inSlot.getCount() < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - if(inSlot.stackSize + itemStack.stackSize <= max) + if(inSlot.getCount() + itemStack.getCount() <= max) { return true; } else { - int rejects = (inSlot.stackSize + itemStack.stackSize) - max; + int rejects = (inSlot.getCount() + itemStack.getCount()) - max; - if(rejects < itemStack.stackSize) + if(rejects < itemStack.getCount()) { return true; } @@ -539,6 +540,12 @@ public final class InventoryUtils return false; } + + public static ItemStack loadFromNBT(NBTTagCompound nbtTags) + { + ItemStack ret = new ItemStack(nbtTags); + return ret; + } /*TODO From CCLib -- go back to that version when we're using dependencies again*/ public static boolean canStack(ItemStack stack1, ItemStack stack2) { diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 11356f648..f59a07ff1 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -127,28 +127,28 @@ public final class MekanismUtils if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1 || !list.isEmpty()) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.outdated") + ".")); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.outdated") + ".")); if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == 1) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber)); + entityplayer.sendMessage(new TextComponentString(EnumColor.INDIGO + " Mekanism: " + EnumColor.DARK_RED + Mekanism.versionNumber)); } for(IModule module : list) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion())); + entityplayer.sendMessage(new TextComponentString(EnumColor.INDIGO + " Mekanism" + module.getName() + ": " + EnumColor.DARK_RED + module.getVersion())); } - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.consider") + " " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.newFeatures") + ": " + EnumColor.INDIGO + Mekanism.recentNews)); - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.visit") + " " + EnumColor.DARK_GREY + "aidancbrady.com/mekanism" + EnumColor.GREY + " " + LangUtils.localize("update.toDownload") + ".")); - entityplayer.addChatMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.consider") + " " + EnumColor.DARK_GREY + Mekanism.latestVersionNumber)); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.newFeatures") + ": " + EnumColor.INDIGO + Mekanism.recentNews)); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + " " + LangUtils.localize("update.visit") + " " + EnumColor.DARK_GREY + "aidancbrady.com/mekanism" + EnumColor.GREY + " " + LangUtils.localize("update.toDownload") + ".")); + entityplayer.sendMessage(new TextComponentString(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); return true; } else if(Version.get(Mekanism.latestVersionNumber).comparedState(Mekanism.versionNumber) == -1) { - entityplayer.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("update.devBuild") + " " + EnumColor.DARK_GREY + Mekanism.versionNumber)); + entityplayer.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("update.devBuild") + " " + EnumColor.DARK_GREY + Mekanism.versionNumber)); return true; } } @@ -259,7 +259,7 @@ public final class MekanismUtils } /** - * Copies an ItemStack and returns it with a defined stackSize. + * Copies an ItemStack and returns it with a defined getCount(). * @param itemstack - stack to change size * @param size - size to change to * @return resized ItemStack @@ -267,7 +267,7 @@ public final class MekanismUtils public static ItemStack size(ItemStack itemstack, int size) { ItemStack newStack = itemstack.copy(); - newStack.stackSize = size; + newStack.setCount(size); return newStack; } @@ -1058,7 +1058,7 @@ public final class MekanismUtils double posY = player.posY; double posZ = player.posZ; - if(!player.worldObj.isRemote) + if(!player.world.isRemote) { posY += player.getEyeHeight(); @@ -1330,7 +1330,7 @@ public final class MekanismUtils return null; } - if((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) && dmgItems[0].getItem().isRepairable()) + if((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) && (dmgItems[0].getCount() == 1) && (dmgItems[1].getCount() == 1) && dmgItems[0].getItem().isRepairable()) { Item theItem = dmgItems[0].getItem(); int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamage(); @@ -1479,7 +1479,7 @@ public final class MekanismUtils } try { - if(isBCWrench(tool.getItem()) && ((IToolWrench)tool.getItem()).canWrench(player, pos)) + if(isBCWrench(tool.getItem())) //TODO too much hassle to check BC wrench-ability { return true; } diff --git a/src/main/java/mekanism/common/util/RecipeUtils.java b/src/main/java/mekanism/common/util/RecipeUtils.java index 189750ebb..954c24f39 100644 --- a/src/main/java/mekanism/common/util/RecipeUtils.java +++ b/src/main/java/mekanism/common/util/RecipeUtils.java @@ -273,7 +273,7 @@ public class RecipeUtils if(nbtTags.hasKey("itemstack")) { - return ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemstack")); + return InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("itemstack")); } else if(nbtTags.hasKey("itemname")) { diff --git a/src/main/java/mekanism/common/util/SecurityUtils.java b/src/main/java/mekanism/common/util/SecurityUtils.java index 836d5d5c4..35e67499f 100644 --- a/src/main/java/mekanism/common/util/SecurityUtils.java +++ b/src/main/java/mekanism/common/util/SecurityUtils.java @@ -121,7 +121,7 @@ public final class SecurityUtils public static void displayNoAccess(EntityPlayer player) { - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("gui.noAccessDesc"))); + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("gui.noAccessDesc"))); } public static SecurityMode getSecurity(ISecurityTile security, Side side) diff --git a/src/main/java/mekanism/common/util/TransporterUtils.java b/src/main/java/mekanism/common/util/TransporterUtils.java index caa891e0b..919b73b2f 100644 --- a/src/main/java/mekanism/common/util/TransporterUtils.java +++ b/src/main/java/mekanism/common/util/TransporterUtils.java @@ -105,7 +105,7 @@ public final class TransporterUtils entityItem.motionY = 0; entityItem.motionZ = 0; - tileEntity.world().spawnEntityInWorld(entityItem); + tileEntity.world().spawnEntity(entityItem); } public static float[] getStackPosition(ILogisticalTransporter tileEntity, TransporterStack stack, float partial) diff --git a/src/main/java/mekanism/common/voice/VoiceConnection.java b/src/main/java/mekanism/common/voice/VoiceConnection.java index 8c64909b9..8e7d76121 100644 --- a/src/main/java/mekanism/common/voice/VoiceConnection.java +++ b/src/main/java/mekanism/common/voice/VoiceConnection.java @@ -48,7 +48,7 @@ public class VoiceConnection extends Thread while(username == null && retryCount <= 100) { try { - List l = Collections.synchronizedList((List)((ArrayList)server.getPlayerList().getPlayerList()).clone()); + List l = Collections.synchronizedList((List)((ArrayList)server.getPlayerList().getPlayers()).clone()); for(Object obj : l) { diff --git a/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java index 384d9eb88..027868078 100644 --- a/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java +++ b/src/main/java/mekanism/generators/client/jei/GeneratorsJEI.java @@ -2,21 +2,17 @@ package mekanism.generators.client.jei; import mekanism.client.jei.MekanismJEI; import mekanism.generators.common.GeneratorsBlocks; -import mezz.jei.api.IJeiRuntime; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.IModRegistry; +import mezz.jei.api.BlankModPlugin; +import mezz.jei.api.ISubtypeRegistry; import mezz.jei.api.JEIPlugin; import net.minecraft.item.Item; @JEIPlugin -public class GeneratorsJEI implements IModPlugin +public class GeneratorsJEI extends BlankModPlugin { @Override - public void register(IModRegistry registry) + public void registerItemSubtypes(ISubtypeRegistry registry) { - registry.getJeiHelpers().getSubtypeRegistry().registerNbtInterpreter(Item.getItemFromBlock(GeneratorsBlocks.Generator), MekanismJEI.NBT_INTERPRETER); + registry.registerSubtypeInterpreter(Item.getItemFromBlock(GeneratorsBlocks.Generator), MekanismJEI.NBT_INTERPRETER); } - - @Override - public void onRuntimeAvailable(IJeiRuntime runtime) {} } diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 739400aaf..513545549 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -330,7 +330,7 @@ public class FusionReactor implements IFusionReactor for(Entity entity : entitiesToDie) { - entity.attackEntityFrom(DamageSource.magic, 50000F); + entity.attackEntityFrom(DamageSource.MAGIC, 50000F); } } diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 6f1ccc6f5..774c6f193 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -1,6 +1,5 @@ package mekanism.generators.common.block; -import java.util.List; import java.util.Random; import mekanism.api.MekanismConfig.client; @@ -52,10 +51,12 @@ import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; @@ -184,7 +185,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(!world.isRemote) { @@ -207,7 +208,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int side = MathHelper.floor((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int height = Math.round(entityliving.rotationPitch); int change = 3; @@ -284,7 +285,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item i, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item i, CreativeTabs creativetabs, NonNullList list) { for(GeneratorType type : GeneratorType.values()) { @@ -388,7 +389,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, new ItemStack(GeneratorsItems.TurbineBlade, amount)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } } @@ -401,7 +402,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing side, float playerX, float playerY, float playerZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -410,6 +411,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); + ItemStack stack = entityplayer.getHeldItem(hand); if(stack != null) { @@ -428,13 +430,13 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock if(MekanismUtils.isBCWrench(tool)) { - ((IToolWrench)tool).wrenchUsed(entityplayer, pos); + ((IToolWrench)tool).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); } int change = tileEntity.facing.rotateY().ordinal(); tileEntity.setFacing((short)change); - world.notifyNeighborsOfStateChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this, true); } else { SecurityUtils.displayNoAccess(entityplayer); @@ -461,9 +463,9 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock { if(!entityplayer.capabilities.isCreativeMode) { - stack.stackSize--; + stack.shrink(1); - if(stack.stackSize == 0) + if(stack.getCount() == 0) { entityplayer.setHeldItem(hand, null); } @@ -489,13 +491,13 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock } else if(stack.getItem() == GeneratorsItems.TurbineBlade) { - if(stack.stackSize < stack.getMaxStackSize()) + if(stack.getCount() < stack.getMaxStackSize()) { if(rod.editBlade(false)) { if(!entityplayer.capabilities.isCreativeMode) { - stack.stackSize++; + stack.grow(1); entityplayer.inventory.markDirty(); } } @@ -615,7 +617,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, getPickBlock(state, null, world, pos, player)); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return world.setBlockToAir(pos); @@ -694,7 +696,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 5e2442482..94b75abef 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -1,7 +1,5 @@ package mekanism.generators.common.block; -import java.util.List; - import mekanism.client.render.ctm.CTMBlockRenderContext; import mekanism.client.render.ctm.CTMData; import mekanism.client.render.ctm.ICTMBlock; @@ -35,7 +33,10 @@ import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.IExtendedBlockState; @@ -152,7 +153,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock } @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock) + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighborPos) { if(!world.isRemote) { @@ -166,7 +167,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, ItemStack stack, EnumFacing facing, float playerX, float playerY, float playerZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -175,6 +176,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); + ItemStack stack = entityplayer.getHeldItem(hand); if(stack != null) { @@ -186,7 +188,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock return true; } - ((IToolWrench)stack.getItem()).wrenchUsed(entityplayer, pos); + ((IToolWrench)stack.getItem()).wrenchUsed(entityplayer, hand, stack, new RayTraceResult(new Vec3d(hitX, hitY, hitZ), side, pos)); return true; } @@ -215,7 +217,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, NonNullList list) { for(BlockStateReactor.ReactorBlockType type : BlockStateReactor.ReactorBlockType.values()) { @@ -347,7 +349,7 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock EntityItem entityItem = new EntityItem(world, pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, itemStack); - world.spawnEntityInWorld(entityItem); + world.spawnEntity(entityItem); } return itemStack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java index 5c06a01b0..53e77a29a 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java @@ -51,7 +51,7 @@ public class ContainerBioGenerator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -121,7 +121,7 @@ public class ContainerBioGenerator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -129,12 +129,12 @@ public class ContainerBioGenerator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java index 307b238f2..08f94579d 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java @@ -50,7 +50,7 @@ public class ContainerGasGenerator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -123,7 +123,7 @@ public class ContainerGasGenerator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -131,12 +131,12 @@ public class ContainerGasGenerator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java index 6ddf1d154..d6da062b4 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java @@ -49,7 +49,7 @@ public class ContainerHeatGenerator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -119,7 +119,7 @@ public class ContainerHeatGenerator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -127,12 +127,12 @@ public class ContainerHeatGenerator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java index a1035999a..c6503f078 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java @@ -48,7 +48,7 @@ public class ContainerNeutronCapture extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -102,7 +102,7 @@ public class ContainerNeutronCapture extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -110,12 +110,12 @@ public class ContainerNeutronCapture extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java index 54d729b5c..01457e718 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java @@ -51,7 +51,7 @@ public class ContainerReactorController extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -105,7 +105,7 @@ public class ContainerReactorController extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -113,12 +113,12 @@ public class ContainerReactorController extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java index c4f6e07d7..0603491ae 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java @@ -48,7 +48,7 @@ public class ContainerSolarGenerator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -102,7 +102,7 @@ public class ContainerSolarGenerator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -110,12 +110,12 @@ public class ContainerSolarGenerator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java index 9914a6456..a745fa654 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java @@ -48,7 +48,7 @@ public class ContainerWindGenerator extends Container @Override public boolean canInteractWith(EntityPlayer entityplayer) { - return tileEntity.isUseableByPlayer(entityplayer); + return tileEntity.isUsableByPlayer(entityplayer); } @Override @@ -102,7 +102,7 @@ public class ContainerWindGenerator extends Container } } - if(slotStack.stackSize == 0) + if(slotStack.getCount() == 0) { currentSlot.putStack((ItemStack)null); } @@ -110,12 +110,12 @@ public class ContainerWindGenerator extends Container currentSlot.onSlotChanged(); } - if(slotStack.stackSize == stack.stackSize) + if(slotStack.getCount() == stack.getCount()) { return null; } - currentSlot.onPickupFromSlot(player, slotStack); + currentSlot.onTake(player, slotStack); } return stack; diff --git a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java index 910394a8c..a44098257 100644 --- a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java +++ b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java @@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; public class ItemHohlraum extends ItemMekanism implements IGasItem { @@ -146,7 +147,7 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem } @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) + public void getSubItems(Item item, CreativeTabs tabs, NonNullList list) { ItemStack empty = new ItemStack(this); setGas(empty, null); diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java index 19263ebe8..00c3c4dc0 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java @@ -29,13 +29,13 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i public void onPlace() { Coord4D current = Coord4D.get(this); - MekanismUtils.makeBoundingBlock(worldObj, getPos().add(0, 1, 0), current); + MekanismUtils.makeBoundingBlock(world, getPos().add(0, 1, 0), current); for(int x = -1; x <= 1; x++) { for(int z = -1; z <= 1; z++) { - MekanismUtils.makeBoundingBlock(worldObj, getPos().add(x, 2, z), current); + MekanismUtils.makeBoundingBlock(world, getPos().add(x, 2, z), current); } } } @@ -43,18 +43,18 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i @Override public void onBreak() { - worldObj.setBlockToAir(getPos().add(0, 1, 0)); + world.setBlockToAir(getPos().add(0, 1, 0)); for(int x = -1; x <= 1; x++) { for(int z = -1; z <= 1; z++) { - worldObj.setBlockToAir(getPos().add(x, 2, z)); + world.setBlockToAir(getPos().add(x, 2, z)); } } invalidate(); - worldObj.setBlockToAir(getPos()); + world.setBlockToAir(getPos()); } @Override diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index 37370ea33..783dff4dc 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -59,7 +59,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui { bioFuelSlot.fluidStored += drained.amount; - if(inventory[0].stackSize == 0) + if(inventory[0].getCount() == 0) { inventory[0] = null; } @@ -83,10 +83,10 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); } else { - inventory[0].stackSize--; + inventory[0].shrink(1); } - if(inventory[0].stackSize == 0) + if(inventory[0].getCount() == 0) { inventory[0] = null; } @@ -97,7 +97,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui if(canOperate()) { - if(!worldObj.isRemote) + if(!world.isRemote) { setActive(true); } @@ -106,7 +106,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui setEnergy(electricityStored + generators.bioGeneration); } else { - if(!worldObj.isRemote) + if(!world.isRemote) { setActive(false); } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index f7191960e..5d4561805 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -52,7 +52,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.charge(1, this); diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 0e7b5f50a..b63f27706 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -65,18 +65,18 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i { super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) + if(world.isRemote && updateDelay > 0) { updateDelay--; if(updateDelay == 0 && clientActive != isActive) { isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } - if(!worldObj.isRemote) + if(!world.isRemote) { if(updateDelay > 0) { @@ -160,7 +160,7 @@ public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock i { updateDelay = general.UPDATE_DELAY; isActive = clientActive; - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index c9eaccea5..4b1201e5e 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -65,7 +65,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.charge(1, this); @@ -91,10 +91,10 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); } else { - inventory[0].stackSize--; + inventory[0].shrink(1); } - if(inventory[0].stackSize == 0) + if(inventory[0].getCount() == 0) { inventory[0] = null; } @@ -203,7 +203,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu } } - if(worldObj.provider.getDimension() == -1) + if(world.provider.getDimension() == -1) { netherBoost = generators.heatGenerationNether; } @@ -213,7 +213,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu private boolean isLava(BlockPos pos) { - return worldObj.getBlockState(pos).getBlock() == Blocks.LAVA; + return world.getBlockState(pos).getBlock() == Blocks.LAVA; } public int getFuel(ItemStack itemstack) @@ -432,7 +432,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { if(canConnectHeat(side)) { - TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); if(CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 2967cd8d6..6609310aa 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -60,11 +60,11 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.charge(0, this); - if(worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.getHasNoSky() && worldObj.canSeeSky(getPos().add(0, 4, 0))) + if(world.isDaytime() && ((!world.isRaining() && !world.isThundering()) || isDesert()) && !world.provider.hasNoSky() && world.canSeeSky(getPos().add(0, 4, 0))) { seesSun = true; } @@ -85,7 +85,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator public boolean isDesert() { - return worldObj.provider.getBiomeForCoords(getPos()).getBiomeClass() == BiomeDesert.class; + return world.provider.getBiomeForCoords(getPos()).getBiomeClass() == BiomeDesert.class; } @Override @@ -124,9 +124,9 @@ public class TileEntitySolarGenerator extends TileEntityGenerator { ret = GENERATION_RATE; - if(MekanismUtils.existsAndInstance(worldObj.provider, "micdoodle8.mods.galacticraft.api.world.ISolarLevel")) + if(MekanismUtils.existsAndInstance(world.provider, "micdoodle8.mods.galacticraft.api.world.ISolarLevel")) { - ret *= ((ISolarLevel)worldObj.provider).getSolarEnergyMultiplier(); + ret *= ((ISolarLevel)world.provider).getSolarEnergyMultiplier(); } if(isDesert()) diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java index 93ec13faf..3576d962b 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java @@ -35,7 +35,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { ChargeUtils.charge(0, this); @@ -62,7 +62,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou { super.handlePacketData(dataStream); - if(worldObj.isRemote) + if(world.isRemote) { currentMultiplier = dataStream.readFloat(); } @@ -81,7 +81,7 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou /** Determines the current output multiplier, taking sky visibility and height into account. **/ public float getMultiplier() { - if(worldObj.canSeeSky(getPos().add(0, 4, 0))) + if(world.canSeeSky(getPos().add(0, 4, 0))) { final float minY = (float)generators.windGenerationMinY; final float maxY = (float)generators.windGenerationMaxY; @@ -146,21 +146,21 @@ public class TileEntityWindGenerator extends TileEntityGenerator implements IBou public void onPlace() { Coord4D current = Coord4D.get(this); - MekanismUtils.makeBoundingBlock(worldObj, getPos().offset(EnumFacing.UP, 1), current); - MekanismUtils.makeBoundingBlock(worldObj, getPos().offset(EnumFacing.UP, 2), current); - MekanismUtils.makeBoundingBlock(worldObj, getPos().offset(EnumFacing.UP, 3), current); - MekanismUtils.makeBoundingBlock(worldObj, getPos().offset(EnumFacing.UP, 4), current); + MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 1), current); + MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 2), current); + MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 3), current); + MekanismUtils.makeBoundingBlock(world, getPos().offset(EnumFacing.UP, 4), current); } @Override public void onBreak() { - worldObj.setBlockToAir(getPos().add(0, 1, 0)); - worldObj.setBlockToAir(getPos().add(0, 2, 0)); - worldObj.setBlockToAir(getPos().add(0, 3, 0)); - worldObj.setBlockToAir(getPos().add(0, 4, 0)); + world.setBlockToAir(getPos().add(0, 1, 0)); + world.setBlockToAir(getPos().add(0, 2, 0)); + world.setBlockToAir(getPos().add(0, 3, 0)); + world.setBlockToAir(getPos().add(0, 4, 0)); - worldObj.setBlockToAir(getPos()); + world.setBlockToAir(getPos()); } @Override diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java index 76cb83cca..6fb6e2a27 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java @@ -68,7 +68,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp changed = false; } - if(!worldObj.isRemote && ticker == 5 && !attempted && (getReactor() == null || !getReactor().isFormed())) + if(!world.isRemote && ticker == 5 && !attempted && (getReactor() == null || !getReactor().isFormed())) { updateController(); } @@ -104,7 +104,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp { super.onAdded(); - if(!worldObj.isRemote) + if(!world.isRemote) { if(getReactor() != null) { @@ -148,13 +148,13 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp { Coord4D coord = pos.offset(side); - if(!iterated.contains(coord) && coord.getTileEntity(worldObj) instanceof TileEntityReactorBlock) + if(!iterated.contains(coord) && coord.getTileEntity(world) instanceof TileEntityReactorBlock) { - ((TileEntityReactorBlock)coord.getTileEntity(worldObj)).attempted = true; + ((TileEntityReactorBlock)coord.getTileEntity(world)).attempted = true; - if(coord.getTileEntity(worldObj) instanceof TileEntityReactorController) + if(coord.getTileEntity(world) instanceof TileEntityReactorController) { - found = (TileEntityReactorController)coord.getTileEntity(worldObj); + found = (TileEntityReactorController)coord.getTileEntity(world); return; } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index c63dda4a3..fb6fc3b1b 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -106,7 +106,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen { super.onUpdate(); - if(worldObj.isRemote) + if(world.isRemote) { updateSound(); } @@ -115,7 +115,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen { getReactor().simulate(); - if(!worldObj.isRemote && (getReactor().isBurning() != clientBurning || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) + if(!world.isRemote && (getReactor().isBurning() != clientBurning || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) { Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); clientBurning = getReactor().isBurning(); @@ -268,7 +268,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen if(getReactor() == null) { setReactor(new FusionReactor(this)); - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } ((FusionReactor)getReactor()).formed = true; @@ -287,7 +287,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen else if(getReactor() != null) { setReactor(null); - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -409,7 +409,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock implemen { super.validate(); - if(worldObj.isRemote) + if(world.isRemote) { initSounds(); } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java index 677f5be99..931b76ad3 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java @@ -31,13 +31,13 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem { super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { boolean outputting = checkMode(); if(outputting != prevOutputting) { - worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); + world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } prevOutputting = outputting; @@ -52,7 +52,7 @@ public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implem public boolean checkMode() { - if(worldObj.isRemote) + if(world.isRemote) { return prevOutputting; } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index 319d153f0..d872eb100 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -86,12 +86,12 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { if(changed) { - worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType()); + world.notifyNeighborsOfStateChange(getPos(), getBlockType(), true); } super.onUpdate(); - if(!worldObj.isRemote) + if(!world.isRemote) { CableUtils.emit(this); @@ -101,7 +101,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl for(EnumFacing side : EnumFacing.values()) { - TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); if(tile != null && !(tile instanceof TileEntityReactorPort) && CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { @@ -364,7 +364,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public IHeatTransfer getAdjacent(EnumFacing side) { - TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity adj = Coord4D.get(this).offset(side).getTileEntity(world); if(CapabilityUtils.hasCapability(adj, Capabilities.HEAT_TRANSFER_CAPABILITY, side.getOpposite())) { @@ -396,9 +396,9 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl { getReactor().getInventory()[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if(itemstack != null && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.setCount(getInventoryStackLimit()); } } } @@ -447,7 +447,7 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl if(prevEject != fluidEject) { - MekanismUtils.updateBlock(worldObj, getPos()); + MekanismUtils.updateBlock(world, getPos()); } } } @@ -465,12 +465,11 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl @Override public EnumActionResult onSneakRightClick(EntityPlayer player, EnumFacing side) { - if(!worldObj.isRemote) + if(!world.isRemote) { fluidEject = !fluidEject; String modeText = " " + (fluidEject ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(fluidEject) + "."; - player.addChatMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.reactorPortEject") + modeText)); - + player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.reactorPortEject") + modeText)); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); markDirty(); } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java index 61e14acf5..74b8eb1c3 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java @@ -19,7 +19,7 @@ public class TileEntityRotationalComplex extends TileEntityInternalMultiblock super.setMultiblock(id); Coord4D coord = Coord4D.get(this).offset(EnumFacing.DOWN); - TileEntity tile = coord.getTileEntity(worldObj); + TileEntity tile = coord.getTileEntity(world); if(tile instanceof TileEntityTurbineRotor) { diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java index ed96a6b0d..52adcb310 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java @@ -47,7 +47,7 @@ public class TileEntityTurbineCasing extends TileEntityMultiblock 0) { @@ -174,12 +174,12 @@ public class TileEntityTurbineRotor extends TileEntityBasicBlock private boolean isRotor(Coord4D coord) { - return coord.getTileEntity(worldObj) instanceof TileEntityTurbineRotor; + return coord.getTileEntity(world) instanceof TileEntityTurbineRotor; } private boolean isComplex(Coord4D coord) { - return coord.getTileEntity(worldObj) instanceof TileEntityRotationalComplex; + return coord.getTileEntity(world) instanceof TileEntityRotationalComplex; } @Override @@ -187,7 +187,7 @@ public class TileEntityTurbineRotor extends TileEntityBasicBlock { super.onChunkLoad(); - if(!worldObj.isRemote) + if(!world.isRemote) { updateRotors(); } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java index 95b9fcba1..7f34255e8 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java @@ -56,7 +56,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I register(); } - if(!worldObj.isRemote) + if(!world.isRemote) { if(structure != null) { @@ -96,9 +96,9 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Method(modid = "IC2") public void register() { - if(!worldObj.isRemote) + if(!world.isRemote) { - IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); if(registered != this) { @@ -118,9 +118,9 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Method(modid = "IC2") public void deregister() { - if(!worldObj.isRemote) + if(!world.isRemote) { - IEnergyTile registered = EnergyNet.instance.getTile(worldObj, getPos()); + IEnergyTile registered = EnergyNet.instance.getTile(world, getPos()); if(registered instanceof IEnergyTile) { @@ -354,7 +354,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY; + return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY; } @Override @@ -397,7 +397,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I { if(fluid == FluidRegistry.getFluid("steam")) { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)); + return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)); } return false; @@ -418,7 +418,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public boolean hasCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || capability == Capabilities.ENERGY_STORAGE_CAPABILITY @@ -438,7 +438,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public T getCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.CABLE_OUTPUTTER_CAPABILITY) { diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java index fd71fd1ad..eaf059052 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java @@ -35,7 +35,7 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF for(EnumFacing side : EnumFacing.VALUES) { - TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(worldObj); + TileEntity tile = Coord4D.get(this).offset(side).getTileEntity(world); if(tile != null && CapabilityUtils.hasCapability(tile, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { @@ -53,7 +53,7 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF @Override public FluidTankInfo[] getTankInfo(EnumFacing from) { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fakeInfo} : PipeUtils.EMPTY; + return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fakeInfo} : PipeUtils.EMPTY; } @Override @@ -89,7 +89,7 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF @Override public boolean hasCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { @@ -103,7 +103,7 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF @Override public T getCapability(Capability capability, EnumFacing side) { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) + if((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { diff --git a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java index 9c344de3e..5747670e0 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java @@ -38,7 +38,7 @@ public class ItemMekanismHoe extends ItemMekanism { super(); toolMaterial = enumtoolmaterial; - maxStackSize = 1; + setMaxStackSize(1); setMaxDamage(enumtoolmaterial.getMaxUses()); setCreativeTab(CreativeTabs.TOOLS); speed = enumtoolmaterial.getDamageVsEntity() + 1.0F; @@ -52,8 +52,10 @@ public class ItemMekanismHoe extends ItemMekanism @Override @SuppressWarnings("incomplete-switch") - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getHeldItem(hand); + if(!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL; @@ -109,8 +111,8 @@ public class ItemMekanismHoe extends ItemMekanism if(equipmentSlot == EntityEquipmentSlot.MAINHAND) { - multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); - multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)(this.speed - 4.0F), 0)); + multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 0.0D, 0)); + multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)(this.speed - 4.0F), 0)); } return multimap; diff --git a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java index 091679e02..978e4bac3 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java @@ -35,8 +35,10 @@ public class ItemMekanismShovel extends ItemMekanismTool } @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack stack = playerIn.getHeldItem(hand); + if(!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { return EnumActionResult.FAIL;