diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java index 775d8d22..06b5b183 100644 --- a/src/main/java/cofh/api/CoFHAPIProps.java +++ b/src/main/java/cofh/api/CoFHAPIProps.java @@ -6,6 +6,6 @@ public class CoFHAPIProps { } - public static final String VERSION = "1.7.10R1.0.3"; + public static final String VERSION = "1.7.10R1.0.12"; } diff --git a/src/main/java/cofh/api/block/IBlockAppearance.java b/src/main/java/cofh/api/block/IBlockAppearance.java new file mode 100644 index 00000000..558d348e --- /dev/null +++ b/src/main/java/cofh/api/block/IBlockAppearance.java @@ -0,0 +1,51 @@ +package cofh.api.block; + +import net.minecraft.block.Block; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on blocks that can mimic the appearance of other blocks. Note that this is meant to be available server-side, so ensure the code is + * server-safe and doesn't use client-side code. + * + */ +public interface IBlockAppearance { + + /** + * This function returns the block that is being shown on a given side. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + */ + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side); + + /** + * This function returns metadata of the block that is being shown on a given side. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + */ + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side); + + /** + * This function returns whether the block's renderer will visually connect to other blocks implementing IBlockAppearance. + */ + public boolean supportsVisualConnections(); + +} diff --git a/src/main/java/cofh/api/block/IBlockConfigGui.java b/src/main/java/cofh/api/block/IBlockConfigGui.java new file mode 100644 index 00000000..9e00c87d --- /dev/null +++ b/src/main/java/cofh/api/block/IBlockConfigGui.java @@ -0,0 +1,31 @@ +package cofh.api.block; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on blocks which have a GUI that needs a tool (e.g., multimeter) to open. + * + */ +public interface IBlockConfigGui { + + /** + * This function will open a GUI if the player has permission. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + * @param player + * Player doing the configuring. + * @return True if the GUI was opened. + */ + public boolean openConfigGui(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player); +} diff --git a/src/main/java/cofh/api/block/IBlockDebug.java b/src/main/java/cofh/api/block/IBlockDebug.java index 091831c9..dc02f7f7 100644 --- a/src/main/java/cofh/api/block/IBlockDebug.java +++ b/src/main/java/cofh/api/block/IBlockDebug.java @@ -6,15 +6,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on blocks which have some debug method which can be activated via a tool or other means. - * + * * @author King Lemming - * + * */ public interface IBlockDebug { /** * This function debugs a block. - * + * * @param world * Reference to the world. * @param x diff --git a/src/main/java/cofh/api/block/IBlockInfo.java b/src/main/java/cofh/api/block/IBlockInfo.java index 12d96f0b..8494243c 100644 --- a/src/main/java/cofh/api/block/IBlockInfo.java +++ b/src/main/java/cofh/api/block/IBlockInfo.java @@ -12,15 +12,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on blocks which can provide information about themselves. If the block contains Tile Entities, then it is recommended that this * function serve as a passthrough for {@link ITileInfo}. - * + * * @author King Lemming - * + * */ public interface IBlockInfo { /** * This function appends information to a list provided to it. - * + * * @param world * Reference to the world. * @param x diff --git a/src/main/java/cofh/api/block/IDismantleable.java b/src/main/java/cofh/api/block/IDismantleable.java index 0e530a65..12c09e3a 100644 --- a/src/main/java/cofh/api/block/IDismantleable.java +++ b/src/main/java/cofh/api/block/IDismantleable.java @@ -8,9 +8,9 @@ import net.minecraft.world.World; /** * Implemented on Blocks which have some method of being instantly dismantled. - * + * * @author King Lemming - * + * */ public interface IDismantleable { diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java index 1674c189..25e0126a 100644 --- a/src/main/java/cofh/api/energy/EnergyStorage.java +++ b/src/main/java/cofh/api/energy/EnergyStorage.java @@ -4,9 +4,9 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. - * + * * @author King Lemming - * + * */ public class EnergyStorage implements IEnergyStorage { @@ -89,7 +89,7 @@ public class EnergyStorage implements IEnergyStorage { /** * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers * are guaranteed to have it. - * + * * @param energy */ public void setEnergyStored(int energy) { @@ -106,7 +106,7 @@ public class EnergyStorage implements IEnergyStorage { /** * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this * externally, as not all IEnergyHandlers are guaranteed to have it. - * + * * @param energy */ public void modifyEnergyStored(int energy) { diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java index 79bdf77a..301271e5 100644 --- a/src/main/java/cofh/api/energy/IEnergyConnection.java +++ b/src/main/java/cofh/api/energy/IEnergyConnection.java @@ -7,9 +7,9 @@ import net.minecraftforge.common.util.ForgeDirection; * accept it; otherwise just use IEnergyHandler. *

* Note that {@link IEnergyHandler} is an extension of this. - * + * * @author King Lemming - * + * */ public interface IEnergyConnection { diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java index c28455b1..3ef72576 100644 --- a/src/main/java/cofh/api/energy/IEnergyContainerItem.java +++ b/src/main/java/cofh/api/energy/IEnergyContainerItem.java @@ -6,15 +6,15 @@ import net.minecraft.item.ItemStack; * Implement this interface on Item classes that support external manipulation of their internal energy storages. *

* A reference implementation is provided {@link ItemEnergyContainer}. - * + * * @author King Lemming - * + * */ public interface IEnergyContainerItem { /** * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. - * + * * @param container * ItemStack to be charged. * @param maxReceive @@ -28,7 +28,7 @@ public interface IEnergyContainerItem { /** * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally * discharged. - * + * * @param container * ItemStack to be discharged. * @param maxExtract diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java index 22f2dbc6..6a4600a4 100644 --- a/src/main/java/cofh/api/energy/IEnergyHandler.java +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -42,7 +42,6 @@ public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver { @Override int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - /** * Returns the amount of energy currently stored. */ diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java index bc206560..414b2656 100644 --- a/src/main/java/cofh/api/energy/IEnergyStorage.java +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -5,15 +5,15 @@ package cofh.api.energy; * This is not to be implemented on TileEntities. This is for internal use only. *

* A reference implementation can be found at {@link EnergyStorage}. - * + * * @author King Lemming - * + * */ public interface IEnergyStorage { /** * Adds energy to the storage. Returns quantity of energy that was accepted. - * + * * @param maxReceive * Maximum amount of energy to be inserted. * @param simulate @@ -24,7 +24,7 @@ public interface IEnergyStorage { /** * Removes energy from the storage. Returns quantity of energy that was removed. - * + * * @param maxExtract * Maximum amount of energy to be extracted. * @param simulate diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java index 055ae45b..2d3659cb 100644 --- a/src/main/java/cofh/api/energy/ItemEnergyContainer.java +++ b/src/main/java/cofh/api/energy/ItemEnergyContainer.java @@ -6,9 +6,9 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. - * + * * @author King Lemming - * + * */ public class ItemEnergyContainer extends Item implements IEnergyContainerItem { diff --git a/src/main/java/cofh/api/inventory/IInventoryHandler.java b/src/main/java/cofh/api/inventory/IInventoryHandler.java index 4cb753c9..344e8153 100644 --- a/src/main/java/cofh/api/inventory/IInventoryHandler.java +++ b/src/main/java/cofh/api/inventory/IInventoryHandler.java @@ -7,18 +7,18 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on TileEntities which should handle items. - * + * * A reference implementation is provided {@link TileInventoryHandler}. - * + * * @author King Lemming - * + * */ public interface IInventoryHandler extends IInventoryConnection { /** * Insert an ItemStack into the IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns what is remaining of the * original stack - a null return means that the entire stack was accepted! - * + * * @param from * Orientation the item is inserted from. * @param item @@ -32,7 +32,7 @@ public interface IInventoryHandler extends IInventoryConnection { /** * Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a * null return means that nothing was extracted! - * + * * @param from * Orientation the item is extracted from. * @param item @@ -47,7 +47,7 @@ public interface IInventoryHandler extends IInventoryConnection { /** * Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a * null return means that nothing was extracted! - * + * * @param from * Orientation the item is extracted from. * @param maxExtract diff --git a/src/main/java/cofh/api/inventory/IInventoryRetainer.java b/src/main/java/cofh/api/inventory/IInventoryRetainer.java index 30309fb2..df79681e 100644 --- a/src/main/java/cofh/api/inventory/IInventoryRetainer.java +++ b/src/main/java/cofh/api/inventory/IInventoryRetainer.java @@ -2,9 +2,9 @@ package cofh.api.inventory; /** * Marks a block which will retain its inventory when broken. - * + * * @author King Lemming - * + * */ public interface IInventoryRetainer { diff --git a/src/main/java/cofh/api/item/IAugmentItem.java b/src/main/java/cofh/api/item/IAugmentItem.java index 497bace9..e17fa8de 100644 --- a/src/main/java/cofh/api/item/IAugmentItem.java +++ b/src/main/java/cofh/api/item/IAugmentItem.java @@ -8,7 +8,7 @@ public interface IAugmentItem { /** * Get the augmentation level for a given Augment and Augment Type. - * + * * @param stack * ItemStack representing the Augment. * @param type @@ -19,7 +19,7 @@ public interface IAugmentItem { /** * Get the Augment Types for a given Augment. Set ensure that there are no duplicates. - * + * * @param stack * ItemStack representing the Augment. * @return Set of the Augmentation Types. Should return an empty set if there are none (but this would be really stupid to make). DO NOT RETURN NULL. diff --git a/src/main/java/cofh/api/item/IEmpowerableItem.java b/src/main/java/cofh/api/item/IEmpowerableItem.java index f77c71f6..42877110 100644 --- a/src/main/java/cofh/api/item/IEmpowerableItem.java +++ b/src/main/java/cofh/api/item/IEmpowerableItem.java @@ -6,9 +6,9 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with * them. - * + * * @author King Lemming - * + * */ public interface IEmpowerableItem { @@ -19,7 +19,7 @@ public interface IEmpowerableItem { /** * Attempt to set the empowered state of the item. - * + * * @param stack * ItemStack to be empowered/disempowered. * @param state @@ -30,7 +30,7 @@ public interface IEmpowerableItem { /** * Callback method for reacting to a state change. Useful in KeyBinding handlers. - * + * * @param player * Player holding the item, if applicable. * @param stack diff --git a/src/main/java/cofh/api/item/IInventoryContainerItem.java b/src/main/java/cofh/api/item/IInventoryContainerItem.java index b87896cc..adadf10a 100644 --- a/src/main/java/cofh/api/item/IInventoryContainerItem.java +++ b/src/main/java/cofh/api/item/IInventoryContainerItem.java @@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on Item classes that are themselves inventories. - * + * * A reference implementation is provided {@link ItemInventoryContainer}. - * + * * @author King Lemming - * + * */ public interface IInventoryContainerItem { diff --git a/src/main/java/cofh/api/item/IMultiModeItem.java b/src/main/java/cofh/api/item/IMultiModeItem.java new file mode 100644 index 00000000..c236bbfb --- /dev/null +++ b/src/main/java/cofh/api/item/IMultiModeItem.java @@ -0,0 +1,56 @@ +package cofh.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with + * them. + * + * @author King Lemming + * + */ +public interface IMultiModeItem { + + /** + * Get the current mode of an item. + */ + int getMode(ItemStack stack); + + /** + * Attempt to set the empowered state of the item. + * + * @param stack + * ItemStack to set the mode on. + * @param mode + * Desired mode. + * @return TRUE if the operation was successful, FALSE if it was not. + */ + boolean setMode(ItemStack stack, int mode); + + /** + * Increment the current mode of an item. + */ + boolean incrMode(ItemStack stack); + + /** + * Decrement the current mode of an item. + */ + boolean decrMode(ItemStack stack); + + /** + * Returns the number of possible modes. + */ + int getNumModes(ItemStack stack); + + /** + * Callback method for reacting to a state change. Useful in KeyBinding handlers. + * + * @param player + * Player holding the item, if applicable. + * @param stack + * The item being held. + */ + void onModeChange(EntityPlayer player, ItemStack stack); + +} diff --git a/src/main/java/cofh/api/item/IToolHammer.java b/src/main/java/cofh/api/item/IToolHammer.java index 1ffefe72..f7b3918f 100644 --- a/src/main/java/cofh/api/item/IToolHammer.java +++ b/src/main/java/cofh/api/item/IToolHammer.java @@ -10,7 +10,7 @@ public interface IToolHammer { /** * Called to ensure that the wrench can be used. - * + * * @param item * The itemstack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) * @param user @@ -27,7 +27,7 @@ public interface IToolHammer { /** * Callback for when the tool has been used reactively. - * + * * @param item * The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) * @param user diff --git a/src/main/java/cofh/api/tileentity/IAugmentable.java b/src/main/java/cofh/api/tileentity/IAugmentable.java index 735ade14..5a99c598 100644 --- a/src/main/java/cofh/api/tileentity/IAugmentable.java +++ b/src/main/java/cofh/api/tileentity/IAugmentable.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * Implemented on objects which support Augments. - * + * * @author King Lemming - * + * */ public interface IAugmentable { diff --git a/src/main/java/cofh/api/tileentity/IEnergyInfo.java b/src/main/java/cofh/api/tileentity/IEnergyInfo.java index 72d553b3..6277a34c 100644 --- a/src/main/java/cofh/api/tileentity/IEnergyInfo.java +++ b/src/main/java/cofh/api/tileentity/IEnergyInfo.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on objects which can report information about their energy usage. - * + * * This is used for reporting purposes - Energy transactions are handled through IEnergyHandler! - * + * * @author King Lemming - * + * */ public interface IEnergyInfo { diff --git a/src/main/java/cofh/api/tileentity/IPlacedTile.java b/src/main/java/cofh/api/tileentity/IPlacedTile.java deleted file mode 100644 index df54a969..00000000 --- a/src/main/java/cofh/api/tileentity/IPlacedTile.java +++ /dev/null @@ -1,13 +0,0 @@ -package cofh.api.tileentity; - -/** - * Implement this interface on Tile Entities which need to know when they are placed into the world. - * - * @author Zeldo - * - */ -public interface IPlacedTile { - - public void tilePlaced(); - -} diff --git a/src/main/java/cofh/api/tileentity/IPortableData.java b/src/main/java/cofh/api/tileentity/IPortableData.java index 13134dbd..81d42964 100644 --- a/src/main/java/cofh/api/tileentity/IPortableData.java +++ b/src/main/java/cofh/api/tileentity/IPortableData.java @@ -5,18 +5,18 @@ import net.minecraft.nbt.NBTTagCompound; /** * Implement this interface on Tile Entities which can write a limited amount of data about themselves. - * + * * This is typically for the purposes of being transferred to a similar tile entity. - * + * * @author King Lemming - * + * */ public interface IPortableData { /** * Data identifier of the Tile Entity/Block. Used for display as well as verification purposes. Tiles with completely interchangeable data should return the * same type. - * + * * @return */ String getDataType(); diff --git a/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java b/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java index 40efe7c3..e6972091 100644 --- a/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java +++ b/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which allow for reconfiguration of their facing. - * + * * Coordination with the containing block is required. - * + * * @author King Lemming - * + * */ public interface IReconfigurableFacing { @@ -22,14 +22,14 @@ public interface IReconfigurableFacing { /** * Attempt to rotate the block. Arbitrary based on implementation. - * + * * @return True if rotation was successful, false otherwise. */ boolean rotateBlock(); /** * Set the facing of the block. - * + * * @param side * The side to set the facing to. * @return True if the facing was set, false otherwise. diff --git a/src/main/java/cofh/api/tileentity/IReconfigurableSides.java b/src/main/java/cofh/api/tileentity/IReconfigurableSides.java index 79c0f5bc..e3a708dd 100644 --- a/src/main/java/cofh/api/tileentity/IReconfigurableSides.java +++ b/src/main/java/cofh/api/tileentity/IReconfigurableSides.java @@ -2,17 +2,17 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which allow for reconfiguration of their sides. - * + * * Coordination with the containing block is required. - * + * * @author King Lemming - * + * */ public interface IReconfigurableSides { /** * Decrement the config for a given side. - * + * * @param side * The side to decrement. * @return True if config was changed, false otherwise. @@ -21,7 +21,7 @@ public interface IReconfigurableSides { /** * Increment the config for a given side. - * + * * @param side * The side to decrement. * @return True if config was changed, false otherwise. @@ -30,7 +30,7 @@ public interface IReconfigurableSides { /** * Set the config for a given side. - * + * * @param side * The side to set. * @param config @@ -41,7 +41,7 @@ public interface IReconfigurableSides { /** * Reset configs on all sides to their base values. - * + * * @return True if reset was successful, false otherwise. */ boolean resetSides(); diff --git a/src/main/java/cofh/api/tileentity/IRedstoneCache.java b/src/main/java/cofh/api/tileentity/IRedstoneCache.java index f1254d8d..1d873e53 100644 --- a/src/main/java/cofh/api/tileentity/IRedstoneCache.java +++ b/src/main/java/cofh/api/tileentity/IRedstoneCache.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which cache their redstone status. - * + * * Note that {@link IRedstoneControl} is an extension of this. - * + * * @author King Lemming - * + * */ public interface IRedstoneCache { diff --git a/src/main/java/cofh/api/tileentity/IRedstoneControl.java b/src/main/java/cofh/api/tileentity/IRedstoneControl.java index 11060325..f868affb 100644 --- a/src/main/java/cofh/api/tileentity/IRedstoneControl.java +++ b/src/main/java/cofh/api/tileentity/IRedstoneControl.java @@ -3,9 +3,9 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which have Redstone Control functionality. This means that a tile can be set to ignore redstone entirely, or * respond to a low or high redstone state. - * + * * @author King Lemming - * + * */ public interface IRedstoneControl extends IRedstoneCache { diff --git a/src/main/java/cofh/api/tileentity/ISecurable.java b/src/main/java/cofh/api/tileentity/ISecurable.java index 06018fa6..fd29f1e6 100644 --- a/src/main/java/cofh/api/tileentity/ISecurable.java +++ b/src/main/java/cofh/api/tileentity/ISecurable.java @@ -1,18 +1,22 @@ package cofh.api.tileentity; +import com.mojang.authlib.GameProfile; + +import net.minecraft.entity.player.EntityPlayer; + /** * Implement this interface on Tile Entities which can have access restrictions. - * + * * @author King Lemming - * + * */ public interface ISecurable { /** * Enum for Access Modes - Restricted is Friends Only, Private is Owner only. - * + * * @author King Lemming - * + * */ public static enum AccessMode { PUBLIC, RESTRICTED, PRIVATE; @@ -47,10 +51,14 @@ public interface ISecurable { boolean setOwnerName(String name); + boolean setOwner(GameProfile name); + AccessMode getAccess(); String getOwnerName(); - boolean canPlayerAccess(String name); + GameProfile getOwner(); + + boolean canPlayerAccess(EntityPlayer player); } diff --git a/src/main/java/cofh/api/tileentity/ISidedTexture.java b/src/main/java/cofh/api/tileentity/ISidedTexture.java index 1d5884f4..20be6dd6 100644 --- a/src/main/java/cofh/api/tileentity/ISidedTexture.java +++ b/src/main/java/cofh/api/tileentity/ISidedTexture.java @@ -5,15 +5,15 @@ import net.minecraft.util.IIcon; /** * Implement this interface on Tile Entities which can change their block's texture based on the current render pass. The block must defer the call to its Tile * Entity. - * + * * @author Zeldo Kavira - * + * */ public interface ISidedTexture { /** * Returns the icon to use for a given side and render pass. - * + * * @param side * Block side to get the texture for. * @param pass diff --git a/src/main/java/cofh/api/tileentity/ITileInfo.java b/src/main/java/cofh/api/tileentity/ITileInfo.java index f040694a..87e4ce8f 100644 --- a/src/main/java/cofh/api/tileentity/ITileInfo.java +++ b/src/main/java/cofh/api/tileentity/ITileInfo.java @@ -8,15 +8,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on Tile Entities which can provide information about themselves. - * + * * @author King Lemming - * + * */ public interface ITileInfo { /** * This function appends information to a list provided to it. - * + * * @param info * The list that the information should be appended to. * @param side diff --git a/src/main/java/cofh/api/transport/IEnderDestination.java b/src/main/java/cofh/api/transport/IEnderDestination.java new file mode 100644 index 00000000..30153c0d --- /dev/null +++ b/src/main/java/cofh/api/transport/IEnderDestination.java @@ -0,0 +1,17 @@ +package cofh.api.transport; + +public interface IEnderDestination extends IEnderAttuned { + + public boolean isNotValid(); + + public int x(); + public int y(); + public int z(); + public int dimension(); + + public int getDestination(); + + public boolean setDestination(int frequency); + + public boolean clearDestination(); +} diff --git a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java b/src/main/java/cofh/api/transport/IEnderEnergyHandler.java index 0886be76..892a5c66 100644 --- a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java +++ b/src/main/java/cofh/api/transport/IEnderEnergyHandler.java @@ -2,9 +2,9 @@ package cofh.api.transport; /** * This interface is implemented on Ender Attuned objects which can receive Energy (Redstone Flux). - * + * * @author King Lemming - * + * */ public interface IEnderEnergyHandler extends IEnderAttuned { @@ -15,7 +15,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive energy (Redstone Flux). - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveEnergy(); @@ -23,7 +23,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive energy. This returns the amount remaining, *not* the amount received - a return of 0 means that all energy * was received! - * + * * @param energy * Amount of energy to be received. * @param simulate diff --git a/src/main/java/cofh/api/transport/IEnderFluidHandler.java b/src/main/java/cofh/api/transport/IEnderFluidHandler.java index 3927fe1b..2f509e81 100644 --- a/src/main/java/cofh/api/transport/IEnderFluidHandler.java +++ b/src/main/java/cofh/api/transport/IEnderFluidHandler.java @@ -4,9 +4,9 @@ import net.minecraftforge.fluids.FluidStack; /** * This interface is implemented on Ender Attuned objects which can receive Fluid. - * + * * @author King Lemming - * + * */ public interface IEnderFluidHandler extends IEnderAttuned { @@ -17,7 +17,7 @@ public interface IEnderFluidHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive a FluidStack. - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveFluid(); @@ -25,7 +25,7 @@ public interface IEnderFluidHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive a FluidStack. This returns what remains of the original stack, *not* the amount received - a null return * means that the entire stack was received! - * + * * @param fluid * FluidStack to be received. * @param simulate diff --git a/src/main/java/cofh/api/transport/IEnderItemHandler.java b/src/main/java/cofh/api/transport/IEnderItemHandler.java index 2944a001..d5dad8f3 100644 --- a/src/main/java/cofh/api/transport/IEnderItemHandler.java +++ b/src/main/java/cofh/api/transport/IEnderItemHandler.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * This interface is implemented on Ender Attuned objects which can receive Items. - * + * * @author King Lemming - * + * */ public interface IEnderItemHandler extends IEnderAttuned { @@ -17,7 +17,7 @@ public interface IEnderItemHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive an ItemStack. - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveItems(); @@ -25,10 +25,10 @@ public interface IEnderItemHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive an ItemStack. This returns what remains of the original stack, *not* the amount received - a null return * means that the entire stack was received! - * + * * This function does not support simulation because Inventory manipulation in Minecraft is an absolute mess and it would be a computational liability to do * so. - * + * * @param item * ItemStack to be received. * @return An ItemStack representing how much is remaining. diff --git a/src/main/java/cofh/api/transport/IItemDuct.java b/src/main/java/cofh/api/transport/IItemDuct.java index 4c50c856..67338346 100644 --- a/src/main/java/cofh/api/transport/IItemDuct.java +++ b/src/main/java/cofh/api/transport/IItemDuct.java @@ -5,16 +5,16 @@ import net.minecraftforge.common.util.ForgeDirection; /** * This interface is implemented on ItemDucts. Use it to attempt to eject items into an entry point. - * + * * @author Zeldo Kavira, King Lemming - * + * */ public interface IItemDuct { /** * Insert an ItemStack into the IItemDuct. Will only accept items if there is a valid destination. This returns what is remaining of the original stack - a * null return means that the entire stack was accepted/routed! - * + * * @param from * Orientation the item is inserted from. * @param item diff --git a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java b/src/main/java/cofh/api/transport/RegistryEnderAttuned.java index 0f91b215..9213d95f 100644 --- a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java +++ b/src/main/java/cofh/api/transport/RegistryEnderAttuned.java @@ -1,7 +1,5 @@ package cofh.api.transport; -import gnu.trove.map.hash.THashMap; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -10,23 +8,69 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.Configuration; public final class RegistryEnderAttuned { - public static Map>> inputItem = new THashMap>>(); - public static Map>> inputFluid = new THashMap>>(); - public static Map>> inputEnergy = new THashMap>>(); + public static Map>> inputItem = new HashMap>>(); + public static Map>> inputFluid = new HashMap>>(); + public static Map>> inputEnergy = new HashMap>>(); - public static Map>> outputItem = new THashMap>>(); - public static Map>> outputFluid = new THashMap>>(); - public static Map>> outputEnergy = new THashMap>>(); + public static Map>> outputItem = new HashMap>>(); + public static Map>> outputFluid = new HashMap>>(); + public static Map>> outputEnergy = new HashMap>>(); + + public static Map> outputTeleport = new HashMap>(); public static Configuration linkConf; public static Map clientFrequencyNames = new LinkedHashMap(); public static Map clientFrequencyNamesReversed = new LinkedHashMap(); + private static class EnderDestination { + + private final int dimension; + private final int x, y, z; + private IEnderDestination output; + + public EnderDestination(IEnderDestination output) { + + x = output.x(); + y = output.y(); + z = output.z(); + dimension = output.dimension(); + this.output = output; + } + + public boolean hasOutput() { + + return DimensionManager.isDimensionRegistered(dimension); + } + + public IEnderDestination getOutput() { + + if (output == null || output.isNotValid()) { + output = null; + if (!DimensionManager.isDimensionRegistered(dimension)) { + return null; + } + WorldServer world = DimensionManager.getWorld(dimension); + if (world == null) { + DimensionManager.initDimension(dimension); + world = DimensionManager.getWorld(dimension); + } + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof IEnderDestination) { + output = (IEnderDestination) te; + } + } + return output; + } + } + public static void clear() { inputItem.clear(); @@ -85,6 +129,31 @@ public final class RegistryEnderAttuned { return outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); } + public static boolean hasDestination(IEnderDestination theAttuned) { + + return hasDestination(theAttuned, true); + } + + public static boolean hasDestination(IEnderDestination theAttuned, boolean to) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return false; + } + EnderDestination dest = map.get(to ? theAttuned.getDestination() : theAttuned.getFrequency()); + return dest == null ? false : dest.hasOutput(); + } + + public static IEnderDestination getDestination(IEnderDestination theAttuned) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return null; + } + EnderDestination dest = map.get(theAttuned.getDestination()); + return dest == null ? null : dest.getOutput(); + } + /* HELPER FUNCTIONS */ public static void addItemHandler(IEnderItemHandler theAttuned) { @@ -164,6 +233,16 @@ public final class RegistryEnderAttuned { } } + public static void addDestination(IEnderDestination theAttuned) { + + if (!hasDestination(theAttuned, false)) { + if (outputTeleport.get(theAttuned.getChannelString()) == null) { + outputTeleport.put(theAttuned.getChannelString(), new HashMap()); + } + outputTeleport.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new EnderDestination(theAttuned)); + } + } + public static void removeItemHandler(IEnderItemHandler theAttuned) { if (inputItem.get(theAttuned.getChannelString()) != null) { @@ -224,6 +303,23 @@ public final class RegistryEnderAttuned { } } + public static void removeDestination(IEnderDestination theAttuned) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return; + } + EnderDestination dest = map.get(theAttuned.getFrequency()); + if (dest == null) { + return; + } + if (dest.dimension == theAttuned.dimension()) { + if (dest.x == theAttuned.x() && dest.y == theAttuned.x() && dest.z == theAttuned.x()) { + map.remove(theAttuned.getFrequency()); + } + } + } + public static void add(IEnderAttuned theAttuned) { if (theAttuned instanceof IEnderItemHandler) { @@ -235,6 +331,9 @@ public final class RegistryEnderAttuned { if (theAttuned instanceof IEnderEnergyHandler) { addEnergyHandler((IEnderEnergyHandler) theAttuned); } + if (theAttuned instanceof IEnderDestination) { + addDestination((IEnderDestination) theAttuned); + } } public static void remove(IEnderAttuned theAttuned) { @@ -248,6 +347,9 @@ public final class RegistryEnderAttuned { if (theAttuned instanceof IEnderEnergyHandler) { removeEnergyHandler((IEnderEnergyHandler) theAttuned); } + if (theAttuned instanceof IEnderDestination) { + removeDestination((IEnderDestination) theAttuned); + } } public static void sortClientNames() { diff --git a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java index 9f570189..59d45ad9 100644 --- a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java +++ b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java @@ -962,6 +962,21 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade return res; } + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } + @Override public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues) { IRedstoneConduit conduit = getRedstoneConduit(world, x, y, z); diff --git a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java index 8647fd5e..b7731771 100644 --- a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java +++ b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java @@ -11,6 +11,7 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -184,4 +185,18 @@ public class BlockBuffer extends AbstractMachineBlock implements IFa return this; } + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java index 2f30b179..1748a7ca 100644 --- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java +++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java @@ -294,4 +294,19 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid } return this; } + + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java b/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java index 6f140eab..0d050766 100644 --- a/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java +++ b/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java @@ -16,6 +16,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.UsernameCache; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -71,7 +72,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt private BlockTravelAnchor() { super(ModObject.blockTravelAnchor.unlocalisedName, TileTravelAnchor.class); - if(!Config.travelAnchorEnabled) { + if (!Config.travelAnchorEnabled) { setCreativeTab(null); } } @@ -92,9 +93,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor tef = (TileTravelAnchor) te; - if(tef.getSourceBlock() != null) { + if (tef.getSourceBlock() != null) { return tef.getSourceBlock().getIcon(blockSide, tef.getSourceBlockMetadata()); } } @@ -108,9 +109,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack par6ItemStack) { - if(entity instanceof EntityPlayer) { + if (entity instanceof EntityPlayer) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor ta = (TileTravelAnchor) te; ta.setPlacedBy((EntityPlayer) entity); Block b = PainterUtil.getSourceBlock(par6ItemStack); @@ -124,9 +125,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public boolean openGui(World world, int x, int y, int z, EntityPlayer entityPlayer, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { + if (te instanceof ITravelAccessable) { ITravelAccessable ta = (ITravelAccessable) te; - if(ta.canUiBeAccessed(entityPlayer)) { + if (ta.canUiBeAccessed(entityPlayer)) { entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_TRAVEL_ACCESSABLE, world, x, y, z); } else { sendPrivateChatMessage(entityPlayer, ta.getPlacedBy()); @@ -134,20 +135,19 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt } return true; } - + public static void sendPrivateChatMessage(EntityPlayer player, UUID owner) { - if(player.worldObj.isRemote && !player.isSneaking()) { - player.addChatComponentMessage(new ChatComponentText(Lang.localize("gui.travelAccessable.privateBlock1") + " " - + EnumChatFormatting.RED + UsernameCache.getLastKnownUsername(owner) + EnumChatFormatting.WHITE + " " - + Lang.localize("gui.travelAccessable.privateBlock2"))); + if (player.worldObj.isRemote && !player.isSneaking()) { + player.addChatComponentMessage(new ChatComponentText(Lang.localize("gui.travelAccessable.privateBlock1") + " " + EnumChatFormatting.RED + + UsernameCache.getLastKnownUsername(owner) + EnumChatFormatting.WHITE + " " + Lang.localize("gui.travelAccessable.privateBlock2"))); } } - + @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { - if(ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { + if (te instanceof ITravelAccessable) { + if (ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { return new ContainerTravelAccessable(player.inventory, (ITravelAccessable) te, world); } else { return new ContainerTravelAuth(player.inventory); @@ -159,8 +159,8 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { - if(ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { + if (te instanceof ITravelAccessable) { + if (ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { return new GuiTravelAccessable(player.inventory, (ITravelAccessable) te, world); } else { return new GuiTravelAuth(player, (ITravelAccessable) te, world); @@ -173,13 +173,13 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt protected void processDrop(World world, int x, int y, int z, TileEntityEio te, ItemStack drop) { TileTravelAnchor anchor = (TileTravelAnchor) te; - if(anchor == null) { + if (anchor == null) { return; } ItemStack itemStack = new ItemStack(this); Block srcBlk = anchor.getSourceBlock(); - if(srcBlk != null) { + if (srcBlk != null) { itemStack = createItemStackForSourceBlock(anchor.getSourceBlock(), anchor.getSourceBlockMetadata()); drop.stackTagCompound = (NBTTagCompound) itemStack.stackTagCompound.copy(); } @@ -194,9 +194,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor tef = (TileTravelAnchor) te; - if(tef.getSourceBlock() != null) { + if (tef.getSourceBlock() != null) { return tef.getSourceBlock().colorMultiplier(world, x, y, z); } } @@ -214,7 +214,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt } public ItemStack createItemStackForSourceBlock(Block block, int damage) { - if(block == this) { + if (block == this) { return new ItemStack(this); } ItemStack result = new ItemStack(this, 1, damage); @@ -236,7 +236,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) { ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs); - if(paintSource == null) { + if (paintSource == null) { return new ResultStack[0]; } return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) }; @@ -246,7 +246,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { return ((TileTravelAnchor) te).getSourceBlockMetadata(); } return 0; @@ -255,9 +255,24 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public Block getFacade(IBlockAccess world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { return ((TileTravelAnchor) te).getSourceBlock(); } return this; } + + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/util/IFacade.java b/src/main/java/crazypants/util/IFacade.java index adbeb429..c6975bf7 100644 --- a/src/main/java/crazypants/util/IFacade.java +++ b/src/main/java/crazypants/util/IFacade.java @@ -1,5 +1,7 @@ package crazypants.util; -public interface IFacade extends info.jbcs.minecraft.chisel.api.IFacade, com.cricketcraft.chisel.api.IFacade { +import cofh.api.block.IBlockAppearance; + +public interface IFacade extends info.jbcs.minecraft.chisel.api.IFacade, com.cricketcraft.chisel.api.IFacade, IBlockAppearance { // :( }