Most of the 1.8 Port.

This commit is contained in:
AlgorithmX2 2015-06-15 19:44:59 -05:00
parent 17465e68e8
commit 38afde724b
824 changed files with 12120 additions and 9158 deletions

View File

@ -25,6 +25,7 @@ package appeng.api.config;
import java.util.EnumSet;
import javax.annotation.Nonnull;

View File

@ -28,12 +28,11 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.ItemStack;
import com.google.common.base.Optional;
import appeng.api.definitions.IItemDefinition;
import appeng.api.util.AEItemDefinition;
import com.google.common.base.Optional;
public enum Upgrades
{

View File

@ -3,6 +3,7 @@ package appeng.api.definitions;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import com.google.common.base.Optional;
@ -24,11 +25,9 @@ public interface IBlockDefinition extends IItemDefinition
* Compare Block with world.
*
* @param world world of block
* @param x x pos of block
* @param y y pos of block
* @param z z pos of block
* @param pos location
*
* @return if the block is placed in the world at the specific location.
*/
boolean isSameAs( IBlockAccess world, int x, int y, int z );
boolean isSameAs( IBlockAccess world, BlockPos pos );
}

View File

@ -57,8 +57,16 @@ public interface IBlocks
IBlockDefinition skyStone();
IBlockDefinition skyStoneBlock();
IBlockDefinition skyStoneBrick();
IBlockDefinition skyStoneSmallBrick();
IBlockDefinition skyChest();
IBlockDefinition skyChestBlock();
IBlockDefinition skyCompass();
IBlockDefinition skyStoneStair();
@ -77,6 +85,7 @@ public interface IBlocks
IBlockDefinition quartzPillarStair();
/*
IBlockDefinition skyStoneSlab();
IBlockDefinition skyStoneBlockSlab();
@ -92,7 +101,8 @@ public interface IBlocks
IBlockDefinition chiseledQuartzSlab();
IBlockDefinition quartzPillarSlab();
*/
/*
* misc
*/

View File

@ -2,6 +2,7 @@ package appeng.api.definitions;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -27,14 +28,12 @@ public interface IComparableDefinition
* Compare Block with world.
*
* @param world world of block
* @param x x pos of block
* @param y y pos of block
* @param z z pos of block
* @param pos in world.
*
* @return if the block is placed in the world at the specific location.
*
* @deprecated moved to {@link IBlockDefinition}. Is removed in the next major release rv3
*/
@Deprecated
boolean isSameAs( IBlockAccess world, int x, int y, int z );
boolean isSameAs( IBlockAccess world, BlockPos pos );
}

View File

@ -78,13 +78,13 @@ public interface IParts
IItemDefinition p2PTunnelLiquids();
IItemDefinition p2PTunnelEU();
//IItemDefinition p2PTunnelEU();
IItemDefinition p2PTunnelRF();
//IItemDefinition p2PTunnelRF();
IItemDefinition p2PTunnelLight();
IItemDefinition p2PTunnelOpenComputers();
//IItemDefinition p2PTunnelOpenComputers();
IItemDefinition cableAnchor();

View File

@ -24,8 +24,7 @@
package appeng.api.events;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event;
import appeng.api.features.ILocatable;

View File

@ -2,6 +2,7 @@ package appeng.api.features;
import java.util.List;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;

View File

@ -2,6 +2,7 @@ package appeng.api.features;
import java.util.Collection;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;

View File

@ -3,6 +3,7 @@ package appeng.api.features;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;

View File

@ -27,7 +27,6 @@ package appeng.api.features;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import appeng.api.config.TunnelType;

View File

@ -26,7 +26,6 @@ package appeng.api.features;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.util.IConfigManager;

View File

@ -27,7 +27,6 @@ package appeng.api.implementations;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;

View File

@ -25,7 +25,6 @@ package appeng.api.implementations;
import net.minecraft.tileentity.TileEntity;
import appeng.api.config.Upgrades;
import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.util.IConfigurableObject;

View File

@ -25,6 +25,7 @@ package appeng.api.implementations.guiobjects;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -35,5 +36,5 @@ import net.minecraft.world.World;
public interface IGuiItem
{
IGuiItemObject getGuiObject( ItemStack is, World world, int x, int y, int z );
IGuiItemObject getGuiObject( ItemStack is, World world, BlockPos pos );
}

View File

@ -25,7 +25,6 @@ package appeng.api.implementations.guiobjects;
import net.minecraft.inventory.IInventory;
import appeng.api.networking.IGridHost;

View File

@ -25,7 +25,6 @@ package appeng.api.implementations.items;
import net.minecraft.item.ItemStack;
import appeng.api.config.AccessRestriction;
import appeng.api.networking.energy.IAEPowerStorage;

View File

@ -26,6 +26,7 @@ package appeng.api.implementations.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
/**
@ -39,11 +40,9 @@ public interface IAEWrench
* Check if the wrench can be used.
*
* @param player wrenching player
* @param x x pos of wrenched block
* @param y y pos of wrenched block
* @param z z pos of wrenched block
* @param pos of block.
*
* @return true if wrench can be used
*/
boolean canWrench( ItemStack wrench, EntityPlayer player, int x, int y, int z );
boolean canWrench( ItemStack wrench, EntityPlayer player, BlockPos pos );
}

View File

@ -27,13 +27,12 @@ package appeng.api.implementations.items;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import com.mojang.authlib.GameProfile;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.IPlayerRegistry;
import appeng.api.networking.security.ISecurityRegistry;
import com.mojang.authlib.GameProfile;
public interface IBiometricCard
{

View File

@ -27,7 +27,6 @@ package appeng.api.implementations.items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.implementations.TransitionResult;
import appeng.api.util.WorldCoord;

View File

@ -25,7 +25,6 @@ package appeng.api.implementations.items;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellWorkbenchItem;
import appeng.api.storage.data.IAEItemStack;

View File

@ -25,7 +25,6 @@ package appeng.api.implementations.items;
import net.minecraft.item.ItemStack;
import appeng.api.config.Upgrades;

View File

@ -27,18 +27,18 @@ package appeng.api.implementations.parts;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.IGridHost;
import appeng.api.parts.BusSupport;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartHost;
import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
/**
* Implemented on the {@link IPart}s cable objects that can be placed at {@link ForgeDirection}.UNKNOWN in
* Implemented on the {@link IPart}s cable objects that can be placed at {@link AEPartLocation}.UNKNOWN in
* {@link IPartHost}s
*/
public interface IPartCable extends IPart, IGridHost
@ -75,7 +75,7 @@ public interface IPartCable extends IPart, IGridHost
*
* @param sides sides of cable
*/
void setValidSides( EnumSet<ForgeDirection> sides );
void setValidSides( EnumSet<EnumFacing> sides );
/**
* used to tests if a cable connects to neighbors visually.
@ -84,5 +84,5 @@ public interface IPartCable extends IPart, IGridHost
*
* @return true if this side is currently connects to an external block.
*/
boolean isConnected( ForgeDirection side );
boolean isConnected( EnumFacing side );
}

View File

@ -25,8 +25,7 @@ package appeng.api.implementations.tiles;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.util.AEColor;
@ -35,5 +34,5 @@ public interface IColorableTile
AEColor getColor();
boolean recolourBlock( ForgeDirection side, AEColor colour, EntityPlayer who );
boolean recolourBlock( EnumFacing side, AEColor colour, EntityPlayer who );
}

View File

@ -25,8 +25,7 @@ package appeng.api.implementations.tiles;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.crafting.ICraftingPatternDetails;
@ -42,7 +41,7 @@ public interface ICraftingMachine
*
* @return if it was accepted, all or nothing.
*/
boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection ejectionDirection );
boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table, EnumFacing ejectionDirection );
/**
* check if the crafting machine is accepting pushes via pushPattern, if this is false, all calls to push will fail,

View File

@ -24,7 +24,7 @@
package appeng.api.implementations.tiles;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
/**
@ -55,5 +55,5 @@ public interface ICrankable
/**
* @return true if the crank can attach on the given side.
*/
boolean canCrankAttach( ForgeDirection directionToCrank );
boolean canCrankAttach( EnumFacing directionToCrank );
}

View File

@ -24,8 +24,7 @@
package appeng.api.implementations.tiles;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IStorageMonitorable;
@ -36,5 +35,5 @@ import appeng.api.storage.IStorageMonitorable;
public interface ITileStorageMonitorable
{
IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src );
IStorageMonitorable getMonitorable( EnumFacing side, BaseActionSource src );
}

View File

@ -25,6 +25,7 @@ package appeng.api.movable;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -61,9 +62,7 @@ public interface IMovableHandler
*
* @param tile to be moved tile
* @param world world of tile
* @param x x coord of tile
* @param y y coord of tile
* @param z z coord of tile
* @param newPosition the new location
*/
void moveTile( TileEntity tile, World world, int x, int y, int z );
void moveTile( TileEntity tile, World world, BlockPos newPosition );
}

View File

@ -27,8 +27,7 @@ package appeng.api.networking;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.parts.IPart;
import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
@ -94,7 +93,7 @@ public interface IGridBlock
* Determine which sides of the block can be connected too, only used when isWorldAccessible returns true, not used
* for {@link IPart} implementations.
*/
EnumSet<ForgeDirection> getConnectableSides();
EnumSet<EnumFacing> getConnectableSides();
/**
* @return the IGridHost for the node, this will be an IGridPart or a TileEntity generally speaking.

View File

@ -24,7 +24,7 @@
package appeng.api.networking;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
/**
@ -54,7 +54,7 @@ public interface IGridConnection
*
* @return the direction of the connection, only valid for in world connections.
*/
ForgeDirection getDirection( IGridNode gridNode );
AEPartLocation getDirection( IGridNode gridNode );
/**
* by destroying a connection you may create new grids, and trigger un-expected behavior, you should only destroy

View File

@ -25,10 +25,9 @@ package appeng.api.networking;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.parts.IPart;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
/**
@ -49,7 +48,7 @@ public interface IGridHost
* @return a new IGridNode, create these with
* AEApi.INSTANCE().createGridNode( MyIGridBlock )
*/
IGridNode getGridNode( ForgeDirection dir );
IGridNode getGridNode( AEPartLocation dir );
/**
* Determines how cables render when they connect to this block. Priority is
@ -57,7 +56,7 @@ public interface IGridHost
*
* @param dir direction
*/
AECableType getCableConnectionType( ForgeDirection dir );
AECableType getCableConnectionType( AEPartLocation dir );
/**
* break this host, its violating security rules, just break your block, or part.

View File

@ -28,9 +28,8 @@ import java.util.EnumSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.IAppEngApi;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IReadOnlyCollection;
@ -89,9 +88,9 @@ public interface IGridNode
World getWorld();
/**
* @return a set of the connected sides, UNKNOWN represents an invisible connection
* @return a set of the connected sides, INTERNAL represents an invisible connection
*/
EnumSet<ForgeDirection> getConnectedSides();
EnumSet<AEPartLocation> getConnectedSides();
/**
* lets you iterate a nodes connections

View File

@ -27,15 +27,14 @@ package appeng.api.networking.crafting;
import java.util.concurrent.Future;
import net.minecraft.world.World;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEItemStack;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableSet;
public interface ICraftingGrid extends IGridCache
{

View File

@ -27,7 +27,6 @@ package appeng.api.networking.crafting;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.storage.data.IAEItemStack;

View File

@ -24,12 +24,12 @@
package appeng.api.networking.crafting;
import com.google.common.collect.ImmutableSet;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionHost;
import appeng.api.storage.data.IAEItemStack;
import com.google.common.collect.ImmutableSet;
public interface ICraftingRequester extends IActionHost
{

View File

@ -25,7 +25,6 @@ package appeng.api.networking.security;
import net.minecraft.entity.player.EntityPlayer;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGridCache;

View File

@ -24,5 +24,5 @@
@API( apiVersion = "rv2", owner = "appliedenergistics2", provides = "appliedenergistics2|API" ) package appeng.api;
import cpw.mods.fml.common.API;
import net.minecraftforge.fml.common.API;

View File

@ -24,12 +24,12 @@
package appeng.api.parts;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
/**
@ -50,12 +50,12 @@ public interface IFacadeContainer
/**
* Removed the facade on the given side, or does nothing.
*/
void removeFacade( IPartHost host, ForgeDirection side );
void removeFacade( IPartHost host, AEPartLocation side );
/**
* @return the {@link IFacadePart} for a given side, or null.
*/
IFacadePart getFacade( ForgeDirection s );
IFacadePart getFacade( AEPartLocation s );
/**
* rotate the facades left.

View File

@ -24,15 +24,15 @@
package appeng.api.parts;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.client.render.IRenderHelper;
/**
@ -69,7 +69,7 @@ public interface IFacadePart
* @param renderStilt if to render stilt
*/
@SideOnly( Side.CLIENT )
void renderStatic( int x, int y, int z, IPartRenderHelper instance, RenderBlocks renderer, IFacadeContainer fc, AxisAlignedBB busBounds, boolean renderStilt );
void renderStatic( BlockPos pos, IPartRenderHelper instance, IRenderHelper renderer, IFacadeContainer fc, AxisAlignedBB busBounds, boolean renderStilt );
/**
* render the part in inventory.
@ -78,12 +78,12 @@ public interface IFacadePart
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderInventory( IPartRenderHelper instance, RenderBlocks renderer );
void renderInventory( IPartRenderHelper instance, IRenderHelper renderer );
/**
* @return side the facade is in
*/
ForgeDirection getSide();
AEPartLocation getSide();
/**
* @return the box for the face of the facade

View File

@ -24,28 +24,27 @@
package appeng.api.parts;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.networking.IGridNode;
import appeng.api.util.AEPartLocation;
import appeng.client.render.IRenderHelper;
public interface IPart extends IBoxProvider
@ -74,7 +73,7 @@ public interface IPart extends IBoxProvider
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderInventory( IPartRenderHelper rh, RenderBlocks renderer );
void renderInventory( IPartRenderHelper rh, IRenderHelper renderer );
/**
* render world renderer ( preferred )
@ -88,7 +87,7 @@ public interface IPart extends IBoxProvider
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer );
void renderStatic( BlockPos pos, IPartRenderHelper rh, IRenderHelper renderer );
/**
* render TESR.
@ -102,14 +101,14 @@ public interface IPart extends IBoxProvider
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer );
void renderDynamic( double x, double y, double z, IPartRenderHelper rh, IRenderHelper renderer );
/**
* @return the Block sheet icon used when rendering the breaking particles, return null to use the ItemStack
* texture.
*/
@SideOnly( Side.CLIENT )
IIcon getBreakingTexture();
TextureAtlasSprite getBreakingTexture(IRenderHelper renderer);
/**
* return true only if your part require dynamic rendering, must be consistent.
@ -233,7 +232,7 @@ public interface IPart extends IBoxProvider
* @param host part side
* @param tile tile entity of part
*/
void setPartHostInfo( ForgeDirection side, IPartHost host, TileEntity tile );
void setPartHostInfo( AEPartLocation side, IPartHost host, TileEntity tile );
/**
* Called when you right click the part, very similar to Block.onActivateBlock
@ -273,12 +272,10 @@ public interface IPart extends IBoxProvider
* same as Block.randomDisplayTick, for but parts.
*
* @param world world of block
* @param x x coord of block
* @param y y coord of block
* @param z z coord of block
* @param pos location of block
* @param r random
*/
void randomDisplayTick( World world, int x, int y, int z, Random r );
void randomDisplayTick( World world, BlockPos pos, Random r );
/**
* Called when placed in the world by a player, this happens before addWorld.
@ -287,7 +284,7 @@ public interface IPart extends IBoxProvider
* @param held held item
* @param side placing side
*/
void onPlacement( EntityPlayer player, ItemStack held, ForgeDirection side );
void onPlacement( EntityPlayer player, ItemStack held, AEPartLocation side );
/**
* Used to determine which parts can be placed on what cables.

View File

@ -24,7 +24,7 @@
package appeng.api.parts;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
public interface IPartCollisionHelper
@ -47,17 +47,17 @@ public interface IPartCollisionHelper
/**
* @return east in world space.
*/
ForgeDirection getWorldX();
EnumFacing getWorldX();
/**
* @return up in world space.
*/
ForgeDirection getWorldY();
EnumFacing getWorldY();
/**
* @return forward in world space.
*/
ForgeDirection getWorldZ();
EnumFacing getWorldZ();
/**
* @return true if this test is to get the BB Collision information.

View File

@ -26,6 +26,8 @@ package appeng.api.parts;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
@ -69,16 +71,14 @@ public interface IPartHelper
* use in use item, to try and place a IBusItem
*
* @param is ItemStack of an item which implements {@link IPartItem}
* @param x x pos of part
* @param y y pos of part
* @param z z pos of part
* @param BlockPos pos of part
* @param side side which the part should be on
* @param player player placing part
* @param world part in world
*
* @return true if placing was successful
*/
boolean placeBus( ItemStack is, int x, int y, int z, int side, EntityPlayer player, World world );
boolean placeBus( ItemStack is, BlockPos pos, EnumFacing side, EntityPlayer player, World world );
/**
* @return the render mode

View File

@ -29,10 +29,10 @@ import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
@ -50,7 +50,7 @@ public interface IPartHost
IFacadeContainer getFacadeContainer();
/**
* Test if you can add a part to the specified side of the Part Host, {@link ForgeDirection}.UNKNOWN is used to
* Test if you can add a part to the specified side of the Part Host, {@link AEPartLocation}.UNKNOWN is used to
* represent the cable in the middle.
*
* @param part to be added part
@ -58,7 +58,7 @@ public interface IPartHost
*
* @return returns false if the part cannot be added.
*/
boolean canAddPart( ItemStack part, ForgeDirection side );
boolean canAddPart( ItemStack part, AEPartLocation side );
/**
* try to add a new part to the specified side, returns false if it failed to be added.
@ -68,19 +68,28 @@ public interface IPartHost
* @param owner with owning player
*
* @return null if the item failed to add, the side it was placed on other wise ( may different for cables,
* {@link ForgeDirection}.UNKNOWN )
* {@link AEPartLocation}.UNKNOWN )
*/
ForgeDirection addPart( ItemStack is, ForgeDirection side, EntityPlayer owner );
AEPartLocation addPart( ItemStack is, AEPartLocation side, EntityPlayer owner );
/**
* Get part by side ( center is {@link ForgeDirection}.UNKNOWN )
* Get part by side ( center is {@link AEPartLocation}.UNKNOWN )
*
* @param side side of part
*
* @return the part located on the specified side, or null if there is no part.
*/
IPart getPart( ForgeDirection side );
IPart getPart( AEPartLocation side );
/**
* Get part by side, this method cannot aquire the center part, you must use the other varient of getPart.
*
* @param side side of part
*
* @return the part located on the specified side, or null if there is no part.
*/
IPart getPart( EnumFacing side );
/**
* removes the part on the side, this doesn't drop it or anything, if you don't do something with it, its just
* "gone" and its never coming back; think about it.
@ -90,7 +99,7 @@ public interface IPartHost
* @param side side of part
* @param suppressUpdate - used if you need to replace a part's INSTANCE, without really removing it first.
*/
void removePart( ForgeDirection side, boolean suppressUpdate );
void removePart( AEPartLocation side, boolean suppressUpdate );
/**
* something changed, might want to send a packet to clients to update state.
@ -123,7 +132,7 @@ public interface IPartHost
*
* @return returns if microblocks are blocking this cable path.
*/
boolean isBlocked( ForgeDirection side );
boolean isBlocked( EnumFacing side );
/**
* finds the part located at the position ( pos must be relative, not global )
@ -151,7 +160,7 @@ public interface IPartHost
*
* @return true of the part host is receiving redstone from an external source.
*/
boolean hasRedstone( ForgeDirection side );
boolean hasRedstone( AEPartLocation side );
/**
* returns false if this block contains any parts or facades, true other wise.
@ -179,4 +188,5 @@ public interface IPartHost
* @return true if tile is in world
*/
boolean isInWorld();
}

View File

@ -27,12 +27,12 @@ package appeng.api.parts;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.client.render.IRenderHelper;
import appeng.client.texture.IAESprite;
public interface IPartRenderHelper
@ -57,31 +57,27 @@ public interface IPartRenderHelper
*
* render a single face.
*
* @param x x coord of part
* @param y y coord of part
* @param z z coord of part
* @param pos POSITION of part
* @param ico icon of part
* @param face direction its facing
* @param renderer renderer of part
*/
@SideOnly( Side.CLIENT )
void renderFace( int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer );
void renderFace( BlockPos pos, IAESprite ico, EnumFacing face, IRenderHelper renderer );
/**
* static renderer
*
* render a box with a cut out box in the center.
*
* @param x x pos of part
* @param y y pos of part
* @param z z pos of part
* @param pos pos of part
* @param ico icon of part
* @param face face of part
* @param edgeThickness thickness of the edge
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderFaceCutout( int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer );
void renderFaceCutout( BlockPos pos, IAESprite ico, EnumFacing face, float edgeThickness, IRenderHelper renderer );
/**
* static renderer
@ -94,17 +90,17 @@ public interface IPartRenderHelper
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderBlock( int x, int y, int z, RenderBlocks renderer );
void renderBlock( BlockPos pos, IRenderHelper renderer );
/**
* render a single face in inventory renderer.
*
* @param IIcon icon of part
* @param TextureAtlasSprite icon of part
* @param direction face of part
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderInventoryFace( IIcon IIcon, ForgeDirection direction, RenderBlocks renderer );
void renderInventoryFace( IAESprite IIcon, EnumFacing direction, IRenderHelper renderer );
/**
* render a box in inventory renderer.
@ -112,7 +108,7 @@ public interface IPartRenderHelper
* @param renderer renderer
*/
@SideOnly( Side.CLIENT )
void renderInventoryBox( RenderBlocks renderer );
void renderInventoryBox( IRenderHelper renderer );
/**
* inventory, and static renderer.
@ -126,16 +122,16 @@ public interface IPartRenderHelper
* @param west west face
* @param east east face
*/
void setTexture( IIcon down, IIcon up, IIcon north, IIcon south, IIcon west, IIcon east );
void setTexture( IAESprite down, IAESprite up, IAESprite north, IAESprite south, IAESprite west, IAESprite east );
/**
* inventory, and static renderer.
*
* set all sides to a single IIcon.
* set all sides to a single TextureAtlasSprite.
*
* @param ico to be set icon
*/
void setTexture( IIcon ico );
void setTexture( IAESprite ico );
/**
* configure the color multiplier for the inventory renderer.
@ -152,30 +148,17 @@ public interface IPartRenderHelper
/**
* @return the east vector in world directions, rather then renderer
*/
ForgeDirection getWorldX();
EnumFacing getWorldX();
/**
* @return the up vector in world directions, rather then renderer.
*/
ForgeDirection getWorldY();
EnumFacing getWorldY();
/**
* @return the forward vector in world directions, rather then renderer.
*/
ForgeDirection getWorldZ();
/**
* Pre-Calculates default lighting for the part, call this before using the render helper to render anything else to
* get simplified, but faster lighting for more then one block.
*
* Only worth it if you render more then 1 block.
*/
ISimplifiedBundle useSimplifiedRendering( int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim );
/**
* disables, useSimplifiedRendering.
*/
void normalRendering();
EnumFacing getWorldZ();
/**
* render a block using the current renderer state.
@ -185,7 +168,7 @@ public interface IPartRenderHelper
* @param z z pos of part
* @param renderer renderer of part
*/
void renderBlockCurrentBounds( int x, int y, int z, RenderBlocks renderer );
void renderBlockCurrentBounds( BlockPos pos, IRenderHelper renderer );
/**
* allow you to enable your part to render during the alpha pass or the standard pass.
@ -199,5 +182,5 @@ public interface IPartRenderHelper
*
* @param complementOf sides to render
*/
void setFacesToRender( EnumSet<ForgeDirection> complementOf );
void setFacesToRender( EnumSet<EnumFacing> complementOf );
}

View File

@ -1,30 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.parts;
public interface ISimplifiedBundle
{
}

View File

@ -27,7 +27,8 @@ package appeng.api.parts;
import java.util.Set;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.util.AEPartLocation;
/**
@ -46,7 +47,21 @@ public abstract class LayerBase extends TileEntity // implements IPartHost
*
* @return the part for the requested side.
*/
public IPart getPart( ForgeDirection side )
public IPart getPart( AEPartLocation side )
{
return null; // place holder.
}
/**
* Grants access for the layer to the parts of the host.
*
* This Method looks silly, that is because its not used at runtime, a real implementation will be used instead.
*
* @param side side of part
*
* @return the part for the requested side.
*/
public IPart getPart( EnumFacing side )
{
return null; // place holder.
}

View File

@ -24,7 +24,7 @@
package appeng.api.parts;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
/**
@ -44,25 +44,25 @@ public class SelectedPart
public final IFacadePart facade;
/**
* side the part is mounted too, or {@link ForgeDirection}.UNKNOWN for cables.
* side the part is mounted too, or {@link AEPartLocation}.UNKNOWN for cables.
*/
public final ForgeDirection side;
public final AEPartLocation side;
public SelectedPart()
{
this.part = null;
this.facade = null;
this.side = ForgeDirection.UNKNOWN;
this.side = AEPartLocation.INTERNAL;
}
public SelectedPart( IPart part, ForgeDirection side )
public SelectedPart( IPart part, AEPartLocation side )
{
this.part = part;
this.facade = null;
this.side = side;
}
public SelectedPart( IFacadePart facade, ForgeDirection side )
public SelectedPart( IFacadePart facade, AEPartLocation side )
{
this.part = null;
this.facade = facade;

View File

@ -25,7 +25,6 @@ package appeng.api.recipes;
import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientError;
import appeng.api.exceptions.RegistrationError;

View File

@ -25,6 +25,7 @@ package appeng.api.recipes;
import java.io.BufferedReader;
import javax.annotation.Nonnull;

View File

@ -26,12 +26,10 @@ package appeng.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.client.texture.IAESprite;
/**
@ -68,7 +66,7 @@ public interface ICellHandler
* assets for examples.
*/
@SideOnly( Side.CLIENT )
IIcon getTopTexture_Light();
IAESprite getTopTexture_Light();
/**
* @return the ME Chest texture for medium pixels this storage cell type, should be 10x10 with 3px of transparent
@ -76,7 +74,7 @@ public interface ICellHandler
* assets for examples.
*/
@SideOnly( Side.CLIENT )
IIcon getTopTexture_Medium();
IAESprite getTopTexture_Medium();
/**
* @return the ME Chest texture for dark pixels this storage cell type, should be 10x10 with 3px of transparent
@ -84,7 +82,7 @@ public interface ICellHandler
* assets for examples.
*/
@SideOnly( Side.CLIENT )
IIcon getTopTexture_Dark();
IAESprite getTopTexture_Dark();
/**
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item

View File

@ -26,7 +26,6 @@ package appeng.api.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEItemStack;

View File

@ -25,7 +25,6 @@ package appeng.api.storage;
import net.minecraft.item.ItemStack;
import appeng.api.IAppEngApi;

View File

@ -26,7 +26,6 @@ package appeng.api.storage;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.config.FuzzyMode;

View File

@ -25,8 +25,7 @@ package appeng.api.storage;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.security.BaseActionSource;
@ -45,7 +44,7 @@ public interface IExternalStorageHandler
*
* @return true, if it can get a handler via getInventory
*/
boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc );
boolean canHandle( TileEntity te, EnumFacing d, StorageChannel channel, BaseActionSource mySrc );
/**
* if this can handle the given inventory, return the a IMEInventory implementing class for it, if not return null
@ -60,5 +59,5 @@ public interface IExternalStorageHandler
*
* @return The Handler for the inventory
*/
IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src );
IMEInventory getInventory( TileEntity te, EnumFacing d, StorageChannel channel, BaseActionSource src );
}

View File

@ -25,8 +25,7 @@ package appeng.api.storage;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import appeng.api.IAppEngApi;
import appeng.api.networking.security.BaseActionSource;
@ -54,5 +53,5 @@ public interface IExternalStorageRegistry
*
* @return the handler for a given tile / forge direction
*/
IExternalStorageHandler getHandler( TileEntity te, ForgeDirection opposite, StorageChannel channel, BaseActionSource mySrc );
IExternalStorageHandler getHandler( TileEntity te, EnumFacing opposite, StorageChannel channel, BaseActionSource mySrc );
}

View File

@ -24,14 +24,13 @@
package appeng.api.storage;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.energy.IEnergySource;

View File

@ -28,14 +28,14 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import com.google.common.collect.ImmutableList;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import com.google.common.collect.ImmutableList;
/**
* Common implementation of a simple class that monitors injection/extraction of a inventory to send events to a list of
@ -55,13 +55,13 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
public MEMonitorHandler( IMEInventoryHandler<StackType> t )
{
this.internalHandler = t;
this.cachedList = (IItemList<StackType>) t.getChannel().createList();
this.cachedList = t.getChannel().createList();
}
public MEMonitorHandler( IMEInventoryHandler<StackType> t, StorageChannel chan )
{
this.internalHandler = t;
this.cachedList = (IItemList<StackType>) chan.createList();
this.cachedList = chan.createList();
}
@Override

View File

@ -24,12 +24,11 @@
package appeng.api.storage.data;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import java.io.IOException;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.StorageChannel;

View File

@ -25,7 +25,6 @@ package appeng.api.storage.data;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.features.IItemComparison;

View File

@ -0,0 +1,53 @@
package appeng.api.util;
import net.minecraft.util.AxisAlignedBB;
/**
* Mutable stand in for Axis Aligned BB, this was used to prevent GC Thrashing.. Related code could also be re-written.
*/
public class AEAxisAlignedBB
{
public double minX;
public double minY;
public double minZ;
public double maxX;
public double maxY;
public double maxZ;
public AxisAlignedBB getBoundingBox()
{
return AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ );
}
public AEAxisAlignedBB(double a,double b, double c, double d, double e, double f)
{
minX=a;
minY=b;
minZ=c;
maxX=d;
maxY=e;
maxZ=f;
}
public static AEAxisAlignedBB fromBounds(
double a,
double b,
double c,
double d,
double e,
double f )
{
return new AEAxisAlignedBB(a,b,c,d,e,f);
}
public static AEAxisAlignedBB fromBounds(
AxisAlignedBB bb )
{
return new AEAxisAlignedBB( bb.minX,
bb.minY,
bb.minZ,
bb.maxX,
bb.maxY,
bb.maxZ );
}
}

View File

@ -27,6 +27,7 @@ package appeng.api.util;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.util.StatCollector;
@ -38,39 +39,39 @@ import net.minecraft.util.StatCollector;
public enum AEColor
{
White( "gui.appliedenergistics2.White", 0xBEBEBE, 0xDBDBDB, 0xFAFAFA ),
White( "gui.appliedenergistics2.White", EnumDyeColor.WHITE, 0xBEBEBE, 0xDBDBDB, 0xFAFAFA ),
Orange( "gui.appliedenergistics2.Orange", 0xF99739, 0xFAAE44, 0xF4DEC3 ),
Orange( "gui.appliedenergistics2.Orange", EnumDyeColor.ORANGE, 0xF99739, 0xFAAE44, 0xF4DEC3 ),
Magenta( "gui.appliedenergistics2.Magenta", 0x821E82, 0xB82AB8, 0xC598C8 ),
Magenta( "gui.appliedenergistics2.Magenta", EnumDyeColor.MAGENTA, 0x821E82, 0xB82AB8, 0xC598C8 ),
LightBlue( "gui.appliedenergistics2.LightBlue", 0x628DCB, 0x82ACE7, 0xD8F6FF ),
LightBlue( "gui.appliedenergistics2.LightBlue", EnumDyeColor.LIGHT_BLUE, 0x628DCB, 0x82ACE7, 0xD8F6FF ),
Yellow( "gui.appliedenergistics2.Yellow", 0xFFF7AA, 0xF8FF4A, 0xFFFFE8 ),
Yellow( "gui.appliedenergistics2.Yellow", EnumDyeColor.YELLOW, 0xFFF7AA, 0xF8FF4A, 0xFFFFE8 ),
Lime( "gui.appliedenergistics2.Lime", 0x7CFF4A, 0xBBFF51, 0xE7F7D7 ),
Lime( "gui.appliedenergistics2.Lime", EnumDyeColor.LIME, 0x7CFF4A, 0xBBFF51, 0xE7F7D7 ),
Pink( "gui.appliedenergistics2.Pink", 0xDC8DB5, 0xF8B5D7, 0xF7DEEB ),
Pink( "gui.appliedenergistics2.Pink", EnumDyeColor.PINK, 0xDC8DB5, 0xF8B5D7, 0xF7DEEB ),
Gray( "gui.appliedenergistics2.Gray", 0x7C7C7C, 0xA0A0A0, 0xC9C9C9 ),
Gray( "gui.appliedenergistics2.Gray", EnumDyeColor.GRAY, 0x7C7C7C, 0xA0A0A0, 0xC9C9C9 ),
LightGray( "gui.appliedenergistics2.LightGray", 0x9D9D9D, 0xCDCDCD, 0xEFEFEF ),
LightGray( "gui.appliedenergistics2.LightGray", EnumDyeColor.SILVER, 0x9D9D9D, 0xCDCDCD, 0xEFEFEF ),
Cyan( "gui.appliedenergistics2.Cyan", 0x2F9BA5, 0x51AAC6, 0xAEDDF4 ),
Cyan( "gui.appliedenergistics2.Cyan", EnumDyeColor.CYAN, 0x2F9BA5, 0x51AAC6, 0xAEDDF4 ),
Purple( "gui.appliedenergistics2.Purple", 0x8230B2, 0xA453CE, 0xC7A3CC ),
Purple( "gui.appliedenergistics2.Purple", EnumDyeColor.PURPLE, 0x8230B2, 0xA453CE, 0xC7A3CC ),
Blue( "gui.appliedenergistics2.Blue", 0x2D29A0, 0x514AFF, 0xDDE6FF ),
Blue( "gui.appliedenergistics2.Blue", EnumDyeColor.BLUE, 0x2D29A0, 0x514AFF, 0xDDE6FF ),
Brown( "gui.appliedenergistics2.Brown", 0x724E35, 0xB7967F, 0xE0D2C8 ),
Brown( "gui.appliedenergistics2.Brown", EnumDyeColor.BROWN, 0x724E35, 0xB7967F, 0xE0D2C8 ),
Green( "gui.appliedenergistics2.Green", 0x45A021, 0x60E32E, 0xE3F2E3 ),
Green( "gui.appliedenergistics2.Green", EnumDyeColor.GREEN, 0x45A021, 0x60E32E, 0xE3F2E3 ),
Red( "gui.appliedenergistics2.Red", 0xA50029, 0xFF003C, 0xFFE6ED ),
Red( "gui.appliedenergistics2.Red", EnumDyeColor.RED, 0xA50029, 0xFF003C, 0xFFE6ED ),
Black( "gui.appliedenergistics2.Black", 0x2B2B2B, 0x565656, 0x848484 ),
Black( "gui.appliedenergistics2.Black", EnumDyeColor.BLACK, 0x2B2B2B, 0x565656, 0x848484 ),
Transparent( "gui.appliedenergistics2.Fluix", 0x1B2344, 0x895CA8, 0xD7BBEC );
Transparent( "gui.appliedenergistics2.Fluix", null, 0x1B2344, 0x895CA8, 0xD7BBEC );
public static final List<AEColor> VALID_COLORS = Arrays.asList( White, Orange, Magenta, LightBlue, Yellow, Lime, Pink, Gray, LightGray, Cyan, Purple, Blue, Brown, Green, Red, Black );
@ -94,12 +95,18 @@ public enum AEColor
*/
public final int whiteVariant;
AEColor( String unlocalizedName, int blackHex, int medHex, int whiteHex )
/**
* Vanilla Dye Equivilient
*/
public final EnumDyeColor dye;
AEColor( String unlocalizedName, EnumDyeColor dye, int blackHex, int medHex, int whiteHex )
{
this.unlocalizedName = unlocalizedName;
this.blackVariant = blackHex;
this.mediumVariant = medHex;
this.whiteVariant = whiteHex;
this.dye = dye;
}
/**

View File

@ -30,8 +30,8 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IItemDefinition;
@ -98,14 +98,12 @@ public interface AEItemDefinition
* Compare Block with world.
*
* @param world world of block
* @param x x pos of block
* @param y y pos of block
* @param z z pos of block
* @param pos in world.
*
* @return if the block is placed in the world at the specific location.
*
* @deprecated use {@link IComparableDefinition#isSameAs(IBlockAccess, int, int, int)} }
*/
@Deprecated
boolean sameAsBlock( IBlockAccess world, int x, int y, int z );
boolean sameAsBlock( IBlockAccess world, BlockPos pos );
}

View File

@ -0,0 +1,100 @@
package appeng.api.util;
import net.minecraft.util.EnumFacing;
/**
* Stand in for previous Forge Direction, Several uses of this class are simply legacy where as some uses of this class are intended.
*/
public enum AEPartLocation
{
/**
* Negative Y
*/
DOWN(0, -1, 0),
/**
* Positive Y
*/
UP(0, 1, 0),
/**
* Negative Z
*/
NORTH(0, 0, -1),
/**
* Positive Z
*/
SOUTH(0, 0, 1),
/**
* Negative X
*/
WEST(-1, 0, 0),
/**
* Posative X
*/
EAST(1, 0, 0),
/**
* Center or inside of the block.
*/
INTERNAL(0, 0, 0);
public final int xOffset;
public final int yOffset;
public final int zOffset;
private static final EnumFacing[] facings = { EnumFacing.DOWN, EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST, null };
private static final int[] OPPOSITES = {1, 0, 3, 2, 5, 4, 6};
public static final AEPartLocation[] SIDE_LOCATIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST};
private AEPartLocation(int x, int y, int z)
{
xOffset = x;
yOffset = y;
zOffset = z;
}
/**
* @return Part Location
*/
public static AEPartLocation fromOrdinal(int id)
{
if (id >= 0 && id < SIDE_LOCATIONS.length)
return SIDE_LOCATIONS[id];
return INTERNAL;
}
/**
* 100% chance of success.
*
* @param side
* @return proper Part Location for a facing enum.
*/
public static AEPartLocation fromFacing(EnumFacing side)
{
if ( side == null ) return INTERNAL;
return values()[side.ordinal()];
}
/**
* @return Opposite Part Location, INTERNAL remains INTERNAL.
*/
public AEPartLocation getOpposite()
{
return fromOrdinal(OPPOSITES[ordinal()]);
}
/**
* @return EnumFacing Equivalence, if Center returns null.
*/
public EnumFacing getFacing()
{
return facings[ordinal()];
}
}

View File

@ -25,6 +25,7 @@ package appeng.api.util;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -47,15 +48,22 @@ public class DimensionalCoord extends WorldCoord
public DimensionalCoord( TileEntity s )
{
super( s );
this.w = s.getWorldObj();
this.dimId = this.w.provider.dimensionId;
this.w = s.getWorld();
this.dimId = this.w.provider.getDimensionId();
}
public DimensionalCoord( World _w, int _x, int _y, int _z )
public DimensionalCoord( World _w, int x, int y, int z )
{
super( _x, _y, _z );
super( x,y,z );
this.w = _w;
this.dimId = _w.provider.dimensionId;
this.dimId = _w.provider.getDimensionId();
}
public DimensionalCoord( World _w, BlockPos pos )
{
super( pos );
this.w = _w;
this.dimId = _w.provider.getDimensionId();
}
@Override
@ -96,4 +104,5 @@ public class DimensionalCoord extends WorldCoord
{
return this.w;
}
}

View File

@ -27,6 +27,7 @@ package appeng.api.util;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -38,10 +39,8 @@ public interface ICommonTile
* the block itself.
*
* @param world world of tile entity
* @param x x pos of tile entity
* @param y y pos of tile entity
* @param z z pos of tile entity
* @param pos location of the block
* @param drops drops of tile entity
*/
void getDrops( World world, int x, int y, int z, List<ItemStack> drops );
void getDrops( World world, BlockPos pos, List<ItemStack> drops );
}

View File

@ -27,7 +27,6 @@ package appeng.api.util;
import java.util.Set;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.Settings;

View File

@ -23,8 +23,9 @@
package appeng.api.util;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.ForgeDirection;
/**
@ -45,12 +46,12 @@ public interface IOrientable
/**
* @return the direction the tile is facing
*/
ForgeDirection getForward();
EnumFacing getForward();
/**
* @return the direction top of the tile
*/
ForgeDirection getUp();
EnumFacing getUp();
/**
* Update the orientation
@ -58,5 +59,5 @@ public interface IOrientable
* @param Forward new forward direction
* @param Up new upwards direction
*/
void setOrientation( ForgeDirection Forward, ForgeDirection Up );
void setOrientation( EnumFacing Forward, EnumFacing Up );
}

View File

@ -24,6 +24,7 @@
package appeng.api.util;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -46,5 +47,5 @@ public interface IOrientableBlock
*
* @return a IOrientable if applicable
*/
IOrientable getOrientable( IBlockAccess world, int x, int y, int z );
IOrientable getOrientable( IBlockAccess world, BlockPos z );
}

View File

@ -25,7 +25,7 @@ package appeng.api.util;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.BlockPos;
/**
@ -41,7 +41,7 @@ public class WorldCoord
public WorldCoord( TileEntity s )
{
this( s.xCoord, s.yCoord, s.zCoord );
this( s.getPos() );
}
public WorldCoord( int _x, int _y, int _z )
@ -51,11 +51,19 @@ public class WorldCoord
this.z = _z;
}
public WorldCoord subtract( ForgeDirection direction, int length )
public WorldCoord(
BlockPos pos )
{
this.x -= direction.offsetX * length;
this.y -= direction.offsetY * length;
this.z -= direction.offsetZ * length;
x = pos.getX();
y = pos.getY();
z = pos.getZ();
}
public WorldCoord subtract( AEPartLocation direction, int length )
{
this.x -= direction.xOffset * length;
this.y -= direction.yOffset * length;
this.z -= direction.zOffset * length;
return this;
}
@ -94,7 +102,7 @@ public class WorldCoord
/**
* Will Return NULL if it's at some diagonal!
*/
public ForgeDirection directionTo( WorldCoord loc )
public AEPartLocation directionTo( WorldCoord loc )
{
int ox = this.x - loc.x;
int oy = this.y - loc.y;
@ -104,34 +112,34 @@ public class WorldCoord
int ylen = Math.abs( oy );
int zlen = Math.abs( oz );
if( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.EAST, xlen ) ) )
{
return ForgeDirection.EAST;
return AEPartLocation.EAST;
}
if( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.WEST, xlen ) ) )
{
return ForgeDirection.WEST;
return AEPartLocation.WEST;
}
if( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.NORTH, zlen ) ) )
{
return ForgeDirection.NORTH;
return AEPartLocation.NORTH;
}
if( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.SOUTH, zlen ) ) )
{
return ForgeDirection.SOUTH;
return AEPartLocation.SOUTH;
}
if( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.UP, ylen ) ) )
{
return ForgeDirection.UP;
return AEPartLocation.UP;
}
if( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) )
if( loc.isEqual( this.copy().add( AEPartLocation.DOWN, ylen ) ) )
{
return ForgeDirection.DOWN;
return AEPartLocation.DOWN;
}
return null;
@ -142,11 +150,11 @@ public class WorldCoord
return this.x == c.x && this.y == c.y && this.z == c.z;
}
public WorldCoord add( ForgeDirection direction, int length )
public WorldCoord add( AEPartLocation direction, int length )
{
this.x += direction.offsetX * length;
this.y += direction.offsetY * length;
this.z += direction.offsetZ * length;
this.x += direction.xOffset * length;
this.y += direction.yOffset * length;
this.z += direction.zOffset * length;
return this;
}
@ -167,6 +175,11 @@ public class WorldCoord
return obj instanceof WorldCoord && this.isEqual( (WorldCoord) obj );
}
public BlockPos getPos()
{
return new BlockPos(x,y,z);
}
@Override
public String toString()
{

View File

@ -23,12 +23,14 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.IResource;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
@ -36,24 +38,27 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
import appeng.client.render.WorldRender;
import appeng.client.texture.BaseIcon;
import appeng.client.texture.FlippableIcon;
import appeng.client.texture.MissingIcon;
import appeng.client.texture.IAESprite;
import appeng.core.AppEng;
import appeng.core.features.AEBlockFeatureHandler;
import appeng.core.features.AEFeature;
import appeng.core.features.FeatureNameExtractor;
@ -64,9 +69,13 @@ import appeng.helpers.ICustomCollision;
import appeng.util.LookDirection;
import appeng.util.Platform;
import com.google.common.base.Optional;
public abstract class AEBaseBlock extends Block implements IAEFeature
{
public static final PropertyEnum AXIS_ORIENTATION = PropertyEnum.create("axis", EnumFacing.Axis.class);
private final String featureFullName;
protected final Optional<String> featureSubName;
protected boolean isOpaque = true;
@ -76,7 +85,13 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
private IFeatureHandler handler;
@SideOnly( Side.CLIENT )
BlockRenderInfo renderInfo;
@Override
public boolean isVisuallyOpaque()
{
return isOpaque && isFullSize;
}
protected AEBaseBlock( Material mat )
{
this( mat, Optional.<String>absent() );
@ -117,13 +132,29 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return this.featureFullName;
}
public void registerNoIcons()
public static final UnlistedBlockPos AE_BLOCK_POS = new UnlistedBlockPos();
public static final UnlistedBlockAccess AE_BLOCK_ACCESS = new UnlistedBlockAccess();
@Override
final protected BlockState createBlockState()
{
final BlockRenderInfo info = this.getRendererInstance();
final FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
info.updateIcons( i, i, i, i, i, i );
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] { AE_BLOCK_POS, AE_BLOCK_ACCESS} );
}
@Override
final public IBlockState getExtendedState(
IBlockState state,
IBlockAccess world,
BlockPos pos )
{
return ((IExtendedBlockState)super.getExtendedState( state, world, pos ) ).withProperty( AE_BLOCK_POS, pos ).withProperty( AE_BLOCK_ACCESS, world );
}
protected IProperty[] getAEStates()
{
return new IProperty[0];
}
@SideOnly( Side.CLIENT )
public BlockRenderInfo getRendererInstance()
{
@ -134,7 +165,9 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
try
{
final BaseBlockRender renderer = this.getRenderer().newInstance();
Class<? extends BaseBlockRender> re = this.getRenderer();
if ( re == null ) return null; // use 1.8 models.
final BaseBlockRender renderer = re.newInstance();
this.renderInfo = new BlockRenderInfo( renderer );
return this.renderInfo;
@ -148,6 +181,15 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
throw new IllegalStateException( "Failed to create a new instance of " + this.getRenderer() + " because of permissions.", e );
}
}
@Override
public int colorMultiplier(
IBlockAccess worldIn,
BlockPos pos,
int colorTint )
{
return colorTint;
}
@SideOnly( Side.CLIENT )
protected Class<? extends BaseBlockRender> getRenderer()
@ -155,11 +197,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return BaseBlockRender.class;
}
public IIcon unmappedGetIcon( IBlockAccess w, int x, int y, int z, int s )
{
return super.getIcon( w, x, y, z, s );
}
protected void setFeature( EnumSet<AEFeature> f )
{
final AEBlockFeatureHandler featureHandler = new AEBlockFeatureHandler( f, this, this.featureSubName );
@ -187,34 +224,14 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
{
return this.isOpaque;
}
@Override
public boolean renderAsNormalBlock()
public boolean isNormalCube()
{
return this.isFullSize && this.isOpaque;
}
@Override
@SideOnly( Side.CLIENT )
public int getRenderType()
{
return WorldRender.INSTANCE.getRenderId();
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
{
return this.getIcon( this.mapRotation( w, x, y, z, s ), w.getBlockMetadata( x, y, z ) );
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
{
return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
}
protected ICustomCollision getCustomCollision( World w, int x, int y, int z )
protected ICustomCollision getCustomCollision( World w, BlockPos pos )
{
if( this instanceof ICustomCollision )
{
@ -223,42 +240,61 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return null;
}
@Override
@SuppressWarnings( "unchecked" )
// NOTE: WAS FINAL, changed for Immibis
public void addCollisionBoxesToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
@SideOnly( Side.CLIENT )
public IAESprite getIcon( IBlockAccess w, BlockPos pos, EnumFacing side )
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
IBlockState state =w.getBlockState( pos );
IOrientable ori = getOrientable( w, pos );
if ( ori == null )
return getIcon( side,state );
return this.getIcon( this.mapRotation( ori, side ), state );
}
@SideOnly( Side.CLIENT )
public IAESprite getIcon( EnumFacing side, IBlockState state )
{
return this.getRendererInstance().getTexture( AEPartLocation.fromFacing( side ) );
}
@Override
public void addCollisionBoxesToList(
World w,
BlockPos pos,
IBlockState state,
AxisAlignedBB bb,
List out,
Entity e )
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
if( collisionHandler != null && bb != null )
{
List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>();
collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e );
collisionHandler.addCollidingBlockToList( w, pos, bb, tmp, e );
for( AxisAlignedBB b : tmp )
{
b.minX += x;
b.minY += y;
b.minZ += z;
b.maxX += x;
b.maxY += y;
b.maxZ += z;
if( bb.intersectsWith( b ) )
AxisAlignedBB offset = b.offset( pos.getX(), pos.getY(), pos.getZ() );
if( bb.intersectsWith( offset ) )
{
out.add( b );
out.add( offset );
}
}
}
else
{
super.addCollisionBoxesToList( w, x, y, z, bb, out, e );
super.addCollisionBoxesToList( w, pos, state, bb, out, e );
}
}
@Override
@SideOnly( Side.CLIENT )
public final AxisAlignedBB getSelectedBoundingBoxFromPool( World w, int x, int y, int z )
public AxisAlignedBB getSelectedBoundingBox(
World w,
BlockPos pos )
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
if( collisionHandler != null )
{
@ -267,7 +303,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
final LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, Minecraft.getMinecraft().thePlayer, true );
AxisAlignedBB br = null;
double lastDist = 0;
@ -276,7 +312,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
{
this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b );
MovingObjectPosition r = super.collisionRayTrace( w, pos, ld.a, ld.b );
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
@ -298,15 +334,21 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
if( br != null )
{
br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z );
br = AxisAlignedBB.fromBounds( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos.getY(), br.maxZ + pos.getZ() );
return br;
}
}
final AxisAlignedBB b = AxisAlignedBB.getBoundingBox( 16d, 16d, 16d, 0d, 0d, 0d );
AxisAlignedBB b = null; // new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) )
for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, false ) )
{
if ( b == null )
{
b = bx;
continue;
}
final double minX = Math.min( b.minX, bx.minX );
final double minY = Math.min( b.minY, bx.minY );
final double minZ = Math.min( b.minZ, bx.minZ );
@ -314,15 +356,18 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
final double maxY = Math.max( b.maxY, bx.maxY );
final double maxZ = Math.max( b.maxZ, bx.maxZ );
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
b = AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ );
}
b.setBounds( b.minX + x, b.minY + y, b.minZ + z, b.maxX + x, b.maxY + y, b.maxZ + z );
if ( b == null )
b = new AxisAlignedBB( 16d, 16d, 16d, 0d, 0d, 0d );
else
b = AxisAlignedBB.fromBounds( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX+ pos.getX(), b.maxY + pos.getY(), b.maxZ + pos.getZ() );
return b;
}
return super.getSelectedBoundingBoxFromPool( w, x, y, z );
return super.getSelectedBoundingBox( w, pos );
}
@Override
@ -332,13 +377,17 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
}
@Override
public MovingObjectPosition collisionRayTrace( World w, int x, int y, int z, Vec3 a, Vec3 b )
public MovingObjectPosition collisionRayTrace(
World w,
BlockPos pos,
Vec3 a,
Vec3 b )
{
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
final ICustomCollision collisionHandler = this.getCustomCollision( w, pos );
if( collisionHandler != null )
{
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, pos, null, true );
MovingObjectPosition br = null;
double lastDist = 0;
@ -347,7 +396,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
{
this.setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b );
MovingObjectPosition r = super.collisionRayTrace( w, pos, a, b );
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
@ -375,14 +424,14 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
}
this.setBlockBounds( 0, 0, 0, 1, 1, 1 );
return super.collisionRayTrace( w, x, y, z, a, b );
return super.collisionRayTrace( w, pos, a, b );
}
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated( World w, BlockPos pos, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
@SuppressWarnings( "unchecked" )
@ -396,56 +445,39 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
{
return this.isInventory;
}
@Override
public int getComparatorInputOverride( World w, int x, int y, int z, int s )
public int getComparatorInputOverride(
World worldIn,
BlockPos pos )
{
return 0;
}
@Override
@SideOnly( Side.CLIENT )
public void registerBlockIcons( IIconRegister iconRegistry )
{
final BlockRenderInfo info = this.getRendererInstance();
final FlippableIcon topIcon;
final FlippableIcon bottomIcon;
final FlippableIcon sideIcon;
final FlippableIcon eastIcon;
final FlippableIcon westIcon;
final FlippableIcon southIcon;
final FlippableIcon northIcon;
this.blockIcon = topIcon = this.optionalIcon( iconRegistry, this.getTextureName(), null );
bottomIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
sideIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Side", topIcon );
eastIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "East", sideIcon );
westIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "West", sideIcon );
southIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Front", sideIcon );
northIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Back", sideIcon );
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
}
@Override
public final boolean isNormalCube( IBlockAccess world, int x, int y, int z )
public boolean isNormalCube(
IBlockAccess world,
BlockPos pos )
{
return this.isFullSize;
}
public IOrientable getOrientable( IBlockAccess w, int x, int y, int z )
public IOrientable getOrientable( IBlockAccess w, BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
return ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
return ( (IOrientableBlock) this ).getOrientable( w, pos );
}
return null;
}
@Override
public final boolean rotateBlock( World w, int x, int y, int z, ForgeDirection axis )
public boolean rotateBlock(
World w,
BlockPos pos,
EnumFacing axis )
{
final IOrientable rotatable = this.getOrientable( w, x, y, z );
final IOrientable rotatable = this.getOrientable( w, pos );
if( rotatable != null && rotatable.canBeRotated() )
{
@ -456,15 +488,15 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
}
else
{
ForgeDirection forward = rotatable.getForward();
ForgeDirection up = rotatable.getUp();
EnumFacing forward = rotatable.getForward();
EnumFacing up = rotatable.getUp();
for( int rs = 0; rs < 4; rs++ )
{
forward = Platform.rotateAround( forward, axis );
up = Platform.rotateAround( up, axis );
if( this.isValidOrientation( w, x, y, z, forward, up ) )
if( this.isValidOrientation( w, pos, forward, up ) )
{
rotatable.setOrientation( forward, up );
return true;
@ -473,7 +505,7 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
}
}
return super.rotateBlock( w, x, y, z, axis );
return super.rotateBlock( w, pos, axis );
}
protected boolean hasCustomRotation()
@ -481,51 +513,20 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return false;
}
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
protected void customRotateBlock( IOrientable rotatable, EnumFacing axis )
{
}
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
{
return true;
}
@Override
public ForgeDirection[] getValidRotations( World w, int x, int y, int z )
public EnumFacing[] getValidRotations( World w, BlockPos pos )
{
return new ForgeDirection[0];
}
@SideOnly( Side.CLIENT )
private FlippableIcon optionalIcon( IIconRegister ir, String name, IIcon substitute )
{
// if the input is an flippable IIcon find the original.
while( substitute instanceof FlippableIcon )
{
substitute = ( (FlippableIcon) substitute ).getOriginal();
}
if( substitute != null )
{
try
{
ResourceLocation resLoc = new ResourceLocation( name );
resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", "textures/blocks", resLoc.getResourcePath(), ".png" ) );
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
if( res != null )
{
return new FlippableIcon( ir.registerIcon( name ) );
}
}
catch( Throwable e )
{
return new FlippableIcon( substitute );
}
}
return new FlippableIcon( ir.registerIcon( name ) );
return new EnumFacing[0];
}
@SideOnly( Side.CLIENT )
@ -534,78 +535,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
super.getSubBlocks( item, tabs, itemStacks );
}
int mapRotation( IBlockAccess w, int x, int y, int z, int s )
{
final IOrientable ori = this.getOrientable( w, x, y, z );
if( ori != null && ori.canBeRotated() )
{
return this.mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal();
}
return s;
}
public ForgeDirection mapRotation( IOrientable ori, ForgeDirection dir )
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
// case NORTH: return northIcon;
// case SOUTH: return southIcon;
// case WEST: return sideIcon;
// case EAST: return sideIcon;
final ForgeDirection forward = ori.getForward();
final ForgeDirection up = ori.getUp();
ForgeDirection west = ForgeDirection.UNKNOWN;
if( forward == null || up == null )
{
return dir;
}
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
for( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS )
{
if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
{
west = dx;
}
}
if( dir == forward )
{
return ForgeDirection.SOUTH;
}
if( dir == forward.getOpposite() )
{
return ForgeDirection.NORTH;
}
if( dir == up )
{
return ForgeDirection.UP;
}
if( dir == up.getOpposite() )
{
return ForgeDirection.DOWN;
}
if( dir == west )
{
return ForgeDirection.WEST;
}
if( dir == west.getOpposite() )
{
return ForgeDirection.EAST;
}
return ForgeDirection.UNKNOWN;
}
@SideOnly( Side.CLIENT )
public void setRenderStateByMeta( int itemDamage )
{
@ -632,4 +561,137 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
return this.hasSubtypes;
}
public EnumFacing mapRotation(
IOrientable ori,
EnumFacing dir )
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
// case NORTH: return northIcon;
// case SOUTH: return southIcon;
// case WEST: return sideIcon;
// case EAST: return sideIcon;
final EnumFacing forward = ori.getForward();
final EnumFacing up = ori.getUp();
EnumFacing west = null;
if( forward == null || up == null )
{
return dir;
}
int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
for( EnumFacing dx : EnumFacing.VALUES )
{
if( dx.getFrontOffsetX() == west_x && dx.getFrontOffsetY() == west_y && dx.getFrontOffsetZ() == west_z )
{
west = dx;
}
}
if ( west == null )
return dir;
if( dir == forward )
{
return EnumFacing.SOUTH;
}
if( dir == forward.getOpposite() )
{
return EnumFacing.NORTH;
}
if( dir == up )
{
return EnumFacing.UP;
}
if( dir == up.getOpposite() )
{
return EnumFacing.DOWN;
}
if( dir == west )
{
return EnumFacing.WEST;
}
if( dir == west.getOpposite() )
{
return EnumFacing.EAST;
}
return null;
}
@SideOnly( Side.CLIENT )
public void registerBlockIcons(
TextureMap clientHelper,
String name )
{
final BlockRenderInfo info = this.getRendererInstance();
final FlippableIcon blockIcon;
final FlippableIcon topIcon;
final FlippableIcon bottomIcon;
final FlippableIcon sideIcon;
final FlippableIcon eastIcon;
final FlippableIcon westIcon;
final FlippableIcon southIcon;
final FlippableIcon northIcon;
blockIcon = topIcon = this.optionalIcon( clientHelper, this.getTextureName(), null );
bottomIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Bottom", topIcon );
sideIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Side", topIcon );
eastIcon = this.optionalIcon( clientHelper, this.getTextureName() + "East", sideIcon );
westIcon = this.optionalIcon( clientHelper, this.getTextureName() + "West", sideIcon );
southIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Front", sideIcon );
northIcon = this.optionalIcon( clientHelper, this.getTextureName() + "Back", sideIcon );
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
}
@SideOnly( Side.CLIENT )
private FlippableIcon optionalIcon( TextureMap ir, String name, IAESprite substitute )
{
// if the input is an flippable IAESprite find the original.
while( substitute instanceof FlippableIcon )
{
substitute = ( (FlippableIcon) substitute ).getOriginal();
}
if( substitute != null )
{
try
{
ResourceLocation resLoc = new ResourceLocation( AppEng.MOD_ID, String.format( "%s/%s%s", "textures/blocks", name, ".png" ) );
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
if( res != null )
{
return new FlippableIcon( new BaseIcon( ir.registerSprite( new ResourceLocation(AppEng.MOD_ID, "blocks/" + name ) ) ) );
}
}
catch( Throwable e )
{
return new FlippableIcon( substitute );
}
}
ResourceLocation resLoc = new ResourceLocation(AppEng.MOD_ID, "blocks/" + name );
return new FlippableIcon(new BaseIcon( ir.registerSprite( resLoc ) ) );
}
String textureName;
public void setBlockTextureName( String texture )
{
textureName = texture;
}
private String getTextureName()
{
return textureName;
}
}

View File

@ -22,26 +22,23 @@ package appeng.block;
import java.util.List;
import net.minecraft.block.Block;
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.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.misc.BlockLightDetector;
import appeng.block.misc.BlockSkyCompass;
import appeng.block.networking.BlockWireless;
import appeng.client.render.ItemRenderer;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class AEBaseItemBlock extends ItemBlock
@ -54,11 +51,6 @@ public class AEBaseItemBlock extends ItemBlock
super( id );
this.blockType = (AEBaseBlock) id;
this.hasSubtypes = this.blockType.hasSubtypes;
if( Platform.isClient() )
{
MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.INSTANCE );
}
}
@Override
@ -96,12 +88,21 @@ public class AEBaseItemBlock extends ItemBlock
{
return this.blockType.getUnlocalizedName( is );
}
@Override
public boolean placeBlockAt( ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata )
public boolean placeBlockAt(
ItemStack stack,
EntityPlayer player,
World w,
BlockPos pos,
EnumFacing side,
float hitX,
float hitY,
float hitZ,
IBlockState newState )
{
ForgeDirection up = ForgeDirection.UNKNOWN;
ForgeDirection forward = ForgeDirection.UNKNOWN;
EnumFacing up = null;
EnumFacing forward = null;
IOrientable ori = null;
@ -109,31 +110,31 @@ public class AEBaseItemBlock extends ItemBlock
{
if( this.blockType instanceof BlockLightDetector )
{
up = ForgeDirection.getOrientation( side );
if( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
up = side;
if( up == EnumFacing.UP || up == EnumFacing.DOWN )
{
forward = ForgeDirection.SOUTH;
forward = EnumFacing.SOUTH;
}
else
{
forward = ForgeDirection.UP;
forward = EnumFacing.UP;
}
}
else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass )
{
forward = ForgeDirection.getOrientation( side );
if( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
forward = side;
if( forward == EnumFacing.UP || forward == EnumFacing.DOWN )
{
up = ForgeDirection.SOUTH;
up = EnumFacing.SOUTH;
}
else
{
up = ForgeDirection.UP;
up = EnumFacing.UP;
}
}
else
{
up = ForgeDirection.UP;
up = EnumFacing.UP;
byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
@ -141,53 +142,53 @@ public class AEBaseItemBlock extends ItemBlock
{
default:
case 0:
forward = ForgeDirection.SOUTH;
forward = EnumFacing.SOUTH;
break;
case 1:
forward = ForgeDirection.WEST;
forward = EnumFacing.WEST;
break;
case 2:
forward = ForgeDirection.NORTH;
forward = EnumFacing.NORTH;
break;
case 3:
forward = ForgeDirection.EAST;
forward = EnumFacing.EAST;
break;
}
if( player.rotationPitch > 65 )
{
up = forward.getOpposite();
forward = ForgeDirection.UP;
forward = EnumFacing.UP;
}
else if( player.rotationPitch < -65 )
{
up = forward.getOpposite();
forward = ForgeDirection.DOWN;
forward = EnumFacing.DOWN;
}
}
}
if( this.blockType instanceof IOrientableBlock )
{
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, x, y, z );
up = ForgeDirection.getOrientation( side );
forward = ForgeDirection.SOUTH;
if( up.offsetY == 0 )
ori = ( (IOrientableBlock) this.blockType ).getOrientable( w, pos );
up = side;
forward = EnumFacing.SOUTH;
if( up.getFrontOffsetY() == 0 )
{
forward = ForgeDirection.UP;
forward = EnumFacing.UP;
}
}
if( !this.blockType.isValidOrientation( w, x, y, z, forward, up ) )
if( !this.blockType.isValidOrientation( w, pos, forward, up ) )
{
return false;
}
if( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
if( super.placeBlockAt( stack, player, w, pos, side, hitX, hitY, hitZ, newState ) )
{
if( this.blockType instanceof AEBaseTileBlock && !( this.blockType instanceof BlockLightDetector ) )
{
AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( w, x, y, z );
AEBaseTile tile = ( (AEBaseTileBlock) this.blockType ).getTileEntity( w, pos );
ori = tile;
if( tile == null )
@ -197,8 +198,7 @@ public class AEBaseItemBlock extends ItemBlock
if( ori.canBeRotated() && !this.blockType.hasCustomRotation() )
{
if( ori.getForward() == null || ori.getUp() == null || // null
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
if( ori.getForward() == null || ori.getUp() == null )
{
ori.setOrientation( forward, up );
}

View File

@ -26,10 +26,8 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.config.AccessRestriction;
import appeng.api.config.PowerUnits;
import appeng.api.definitions.IBlockDefinition;

View File

@ -1,12 +0,0 @@
package appeng.block;
import net.minecraft.block.Block;
import net.minecraft.item.ItemSlab;
public class AEBaseItemBlockSlab extends ItemSlab {
public AEBaseItemBlockSlab(Block block, AEBaseSlabBlock singleSlab, AEBaseSlabBlock doubleSlab, Boolean isDoubleSlab)
{
super( block, singleSlab, doubleSlab, isDoubleSlab );
}
}

View File

@ -1,129 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.SlabBlockFeatureHandler;
public class AEBaseSlabBlock extends BlockSlab implements IAEFeature
{
private final IFeatureHandler features;
private final AEBaseBlock block;
private final int meta;
private AEBaseSlabBlock slabs;
private AEBaseSlabBlock doubleSlabs;
private final String name;
public AEBaseSlabBlock( AEBaseBlock block, int meta, EnumSet<AEFeature> features, boolean isDoubleSlab, String name )
{
super( isDoubleSlab, block.getMaterial() );
this.block = block;
this.meta = meta;
this.name = name;
this.setBlockName( "appliedenergistics2." + name );
this.setHardness( block.getBlockHardness( null, 0, 0, 0 ) );
this.setResistance( block.getExplosionResistance( null ) * 5.0F / 3.0F );
this.setStepSound( block.stepSound );
this.useNeighborBrightness = true;
if (!field_150004_a) this.doubleSlabs = new AEBaseSlabBlock( block, meta, features, true, name + ".double" ).setSlabs(this);
this.features = !field_150004_a ? new SlabBlockFeatureHandler( features, this ) : null;
}
public AEBaseSlabBlock setSlabs(AEBaseSlabBlock slabs)
{
this.slabs = slabs;
return this;
}
public AEBaseSlabBlock slabs()
{
return slabs;
}
public AEBaseSlabBlock doubleSlabs()
{
return doubleSlabs;
}
@Override
public IFeatureHandler handler()
{
return this.features;
}
@Override
public void postInit()
{
// Override to do stuff
}
@Override
public IIcon getIcon(int dir, int meta)
{
return block.getIcon( dir, this.meta );
}
@Override
public String func_150002_b(int p_150002_1_)
{
return this.getUnlocalizedName();
}
@Override
public void registerBlockIcons(IIconRegister reg) { }
@Override
public Item getItemDropped(int meta, Random rand, int fortune)
{
return this.field_150004_a ? Item.getItemFromBlock(this.slabs) : Item.getItemFromBlock(this);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
AEBaseSlabBlock block = (AEBaseSlabBlock) world.getBlock(x, y, z);
if (block == null) return null;
if (block.field_150004_a) block = this.slabs;
int meta = world.getBlockMetadata(x, y, z) & 7;
return new ItemStack(block, 1, meta);
}
public String name()
{
return name;
}
}

View File

@ -21,27 +21,26 @@ package appeng.block;
import java.util.EnumSet;
import com.google.common.base.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import appeng.core.features.AEFeature;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.StairBlockFeatureHandler;
import com.google.common.base.Optional;
public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
{
private final IFeatureHandler features;
protected AEBaseStairBlock( Block block, int meta, EnumSet<AEFeature> features )
protected AEBaseStairBlock( Block block, EnumSet<AEFeature> features, String type )
{
super( block, meta );
super( block.getDefaultState() );
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>absent() );
this.setBlockName( block.getUnlocalizedName() );
this.features = new StairBlockFeatureHandler( features, this, Optional.<String>of(type) );
setUnlocalizedName( block.getUnlocalizedName() );
this.setLightOpacity( 0 );
}

View File

@ -26,25 +26,23 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
import appeng.api.implementations.tiles.IColorableTile;
@ -61,6 +59,9 @@ import appeng.tile.storage.TileSkyChest;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature, ITileEntityProvider
{
@ -94,6 +95,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
this.setTileProvider( this.hasBlockTileEntity() );
}
// update Block value.
private void setTileProvider( boolean b )
{
@ -112,13 +114,19 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
@Nullable
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, int x, int y, int z )
{
return getTileEntity( w, new BlockPos(x,y,z) );
}
@Nullable
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, BlockPos pos )
{
if( !this.hasBlockTileEntity() )
{
return null;
}
final TileEntity te = w.getTileEntity( x, y, z );
final TileEntity te = w.getTileEntity( pos );
if( this.tileEntityType.isInstance( te ) )
{
return (T) te;
@ -150,51 +158,58 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
}
@Override
public void breakBlock( World w, int x, int y, int z, Block a, int b )
public void breakBlock(
World w,
BlockPos pos,
IBlockState state )
{
final AEBaseTile te = this.getTileEntity( w, x, y, z );
final AEBaseTile te = this.getTileEntity( w,pos );
if( te != null )
{
final ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
if( te.dropItems() )
{
te.getDrops( w, x, y, z, drops );
te.getDrops( w, pos, drops );
}
else
{
te.getNoDrops( w, x, y, z, drops );
te.getNoDrops( w, pos, drops );
}
// Cry ;_; ...
Platform.spawnDrops( w, x, y, z, drops );
Platform.spawnDrops( w, pos, drops );
}
// super will remove the TE, as it is not an instance of BlockContainer
super.breakBlock( w, x, y, z, a, b );
super.breakBlock( w, pos, state );
}
@Override
public final ForgeDirection[] getValidRotations( World w, int x, int y, int z )
public final EnumFacing[] getValidRotations( World w, BlockPos pos )
{
final AEBaseTile obj = this.getTileEntity( w, x, y, z );
final AEBaseTile obj = this.getTileEntity( w, pos );
if( obj != null && obj.canBeRotated() )
{
return ForgeDirection.VALID_DIRECTIONS;
return EnumFacing.VALUES;
}
return super.getValidRotations( w, x, y, z );
return super.getValidRotations( w, pos );
}
@Override
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
public boolean recolorBlock(
World world,
BlockPos pos,
EnumFacing side,
EnumDyeColor color )
{
final TileEntity te = this.getTileEntity( world, x, y, z );
final TileEntity te = this.getTileEntity( world, pos );
if( te instanceof IColorableTile )
{
final IColorableTile ct = (IColorableTile) te;
final AEColor c = ct.getColor();
final AEColor newColor = AEColor.values()[colour];
final AEColor newColor = AEColor.values()[color.getMetadata()];
if( c != newColor )
{
@ -204,13 +219,15 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
return false;
}
return super.recolourBlock( world, x, y, z, side, colour );
return super.recolorBlock( world, pos, side, color);
}
@Override
public int getComparatorInputOverride( World w, int x, int y, int z, int s )
public int getComparatorInputOverride(
World w,
BlockPos pos )
{
final TileEntity te = this.getTileEntity( w, x, y, z );
final TileEntity te = this.getTileEntity( w, pos );
if( te instanceof IInventory )
{
return Container.calcRedstoneFromInventory( (IInventory) te );
@ -219,41 +236,59 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
}
@Override
public boolean onBlockEventReceived( World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_ )
public boolean onBlockEventReceived(
World worldIn,
BlockPos pos,
IBlockState state,
int eventID,
int eventParam )
{
super.onBlockEventReceived( p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_ );
final TileEntity tileentity = p_149696_1_.getTileEntity( p_149696_2_, p_149696_3_, p_149696_4_ );
return tileentity != null ? tileentity.receiveClientEvent( p_149696_5_, p_149696_6_ ) : false;
super.onBlockEventReceived( worldIn, pos, state ,eventID, eventParam);
final TileEntity tileentity = worldIn.getTileEntity( pos );
return tileentity != null ? tileentity.receiveClientEvent( eventID, eventParam ) : false;
}
@Override
public void onBlockPlacedBy( World w, int x, int y, int z, EntityLivingBase player, ItemStack is )
public void onBlockPlacedBy(
World w,
BlockPos pos,
IBlockState state,
EntityLivingBase placer,
ItemStack is )
{
if( is.hasDisplayName() )
{
final TileEntity te = this.getTileEntity( w, x, y, z );
final TileEntity te = this.getTileEntity( w, pos );
if( te instanceof AEBaseTile )
{
( (AEBaseTile) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() );
( (AEBaseTile) w.getTileEntity( pos ) ).setName( is.getDisplayName() );
}
}
}
@Override
public final boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onBlockActivated(
World w,
BlockPos pos,
IBlockState state,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player != null )
{
final ItemStack is = player.inventory.getCurrentItem();
if( is != null )
{
if( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
if( Platform.isWrench( player, is, pos ) && player.isSneaking() )
{
final Block id = w.getBlock( x, y, z );
final Block id = w.getBlockState( pos ).getBlock();
if( id != null )
{
final AEBaseTile tile = this.getTileEntity( w, x, y, z );
final ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
final AEBaseTile tile = this.getTileEntity( w, pos );
final ItemStack[] drops = Platform.getBlockDrops( w, pos );
if( tile == null )
{
@ -278,11 +313,11 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
}
}
if( id.removedByPlayer( w, player, x, y, z, false ) )
if( id.removedByPlayer( w, pos, player, false ) )
{
final List<ItemStack> l = Lists.newArrayList( drops );
Platform.spawnDrops( w, x, y, z, l );
w.setBlockToAir( x, y, z );
Platform.spawnDrops( w, pos, l );
w.setBlockToAir( pos );
}
}
return false;
@ -293,7 +328,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
final IMemoryCard memoryCard = (IMemoryCard) is.getItem();
if( player.isSneaking() )
{
final AEBaseTile t = this.getTileEntity( w, x, y, z );
final AEBaseTile t = this.getTileEntity( w, pos );
if( t != null )
{
final String name = this.getUnlocalizedName();
@ -312,7 +347,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
final NBTTagCompound data = memoryCard.getData( is );
if( this.getUnlocalizedName().equals( name ) )
{
final AEBaseTile t = this.getTileEntity( w, x, y, z );
final AEBaseTile t = this.getTileEntity( w, pos );
t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
}
@ -326,25 +361,25 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
}
}
return this.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
return this.onActivated( w, pos, player, side, hitX, hitY, hitZ );
}
@Override
public IOrientable getOrientable( IBlockAccess w, int x, int y, int z )
public IOrientable getOrientable( IBlockAccess w, BlockPos pos )
{
return this.getTileEntity( w, x, y, z );
return this.getTileEntity( w, pos );
}
@Override
public ICustomCollision getCustomCollision( World w, int x, int y, int z )
public ICustomCollision getCustomCollision( World w, BlockPos pos )
{
final AEBaseTile te = this.getTileEntity( w, x, y, z );
final AEBaseTile te = this.getTileEntity( w, pos );
if( te instanceof ICustomCollision )
{
return (ICustomCollision) te;
}
return super.getCustomCollision( w, x, y, z );
return super.getCustomCollision( w, pos );
}
}

View File

@ -20,8 +20,6 @@ package appeng.block;
import net.minecraft.block.material.Material;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class AEDecorativeBlock extends AEBaseBlock
@ -31,15 +29,4 @@ public class AEDecorativeBlock extends AEBaseBlock
super( mat );
}
@Override
public int getRenderType()
{
return 0;
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
{
return super.unmappedGetIcon( w, x, y, z, s );
}
}

View File

@ -0,0 +1,33 @@
package appeng.block;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.property.IUnlistedProperty;
public final class UnlistedBlockAccess implements IUnlistedProperty<IBlockAccess>
{
@Override
public String getName()
{
return "ba";
}
@Override
public boolean isValid(
final IBlockAccess value )
{
return true;
}
@Override
public Class<IBlockAccess> getType()
{
return IBlockAccess.class;
}
@Override
public String valueToString(
final IBlockAccess value )
{
return null;
}
}

View File

@ -0,0 +1,33 @@
package appeng.block;
import net.minecraft.util.BlockPos;
import net.minecraftforge.common.property.IUnlistedProperty;
public final class UnlistedBlockPos implements IUnlistedProperty<BlockPos>
{
@Override
public String getName()
{
return "pos";
}
@Override
public boolean isValid(
final BlockPos value )
{
return true;
}
@Override
public Class<BlockPos> getType()
{
return BlockPos.class;
}
@Override
public String valueToString(
final BlockPos value )
{
return null;
}
}

View File

@ -22,19 +22,18 @@ package appeng.block.crafting;
import java.util.List;
import net.minecraft.block.Block;
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.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.IAESprite;
import appeng.tile.crafting.TileCraftingMonitorTile;
@ -42,6 +41,7 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
{
public BlockCraftingMonitor()
{
super( CraftingUnitType.MONITOR );
this.setTileEntity( TileCraftingMonitorTile.class );
}
@ -52,24 +52,19 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
}
@Override
public IIcon getIcon( int direction, int metadata )
public IAESprite getIcon(
EnumFacing side,
IBlockState state )
{
if( direction != ForgeDirection.SOUTH.ordinal() )
if( side != EnumFacing.SOUTH )
{
for( Block craftingUnitBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
{
return craftingUnitBlock.getIcon( direction, metadata );
return ( (BlockCraftingUnit)craftingUnitBlock ).getIcon( side, state );
}
}
switch( metadata )
{
default:
case 0:
return super.getIcon( 0, 0 );
case FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
}
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
}
@Override

View File

@ -24,19 +24,18 @@ import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.crafting.TileCraftingStorageTile;
public class BlockCraftingStorage extends BlockCraftingUnit
{
public BlockCraftingStorage()
public BlockCraftingStorage( CraftingUnitType type )
{
super(type );
this.setTileEntity( TileCraftingStorageTile.class );
}
@ -47,29 +46,29 @@ public class BlockCraftingStorage extends BlockCraftingUnit
}
@Override
public IIcon getIcon( int direction, int metadata )
public appeng.client.texture.IAESprite getIcon(net.minecraft.util.EnumFacing side, net.minecraft.block.state.IBlockState state)
{
switch( metadata & ( ~4 ) )
boolean formed = (boolean)state.getValue( FORMED );
switch( this.type )
{
default:
case 0:
return super.getIcon( 0, 0 );
case 1:
return ExtraBlockTextures.BlockCraftingStorage4k.getIcon();
case 2:
return ExtraBlockTextures.BlockCraftingStorage16k.getIcon();
case 3:
return ExtraBlockTextures.BlockCraftingStorage64k.getIcon();
case FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
case 1 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage4kFit.getIcon();
case 2 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
case 3 | FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
case STORAGE_1K:
return formed ?
super.getIcon( side,state ) :
ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
case STORAGE_4K:
return formed ?
ExtraBlockTextures.BlockCraftingStorage4k.getIcon() :
ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
case STORAGE_16K:
return formed ?
ExtraBlockTextures.BlockCraftingStorage16k.getIcon() :
ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
case STORAGE_64K:
return formed ?
ExtraBlockTextures.BlockCraftingStorage64k.getIcon() :
ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
}
}

View File

@ -24,17 +24,20 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCraftingCPU;
@ -44,16 +47,49 @@ import appeng.core.sync.GuiBridge;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class BlockCraftingUnit extends AEBaseTileBlock
{
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool FORMED = PropertyBool.create("formed");
public static final int FLAG_FORMED = 8;
public BlockCraftingUnit()
final public CraftingUnitType type;
public static enum CraftingUnitType
{
super( Material.iron );
UNIT, ACCELERATOR, STORAGE_1K,STORAGE_4K, STORAGE_16K, STORAGE_64K, MONITOR
};
this.hasSubtypes = true;
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
public int getMetaFromState(
IBlockState state )
{
boolean p = (boolean)state.getValue( POWERED );
boolean f = (boolean)state.getValue( FORMED );
return (p ? 1 : 0) | (f?2 : 0);
}
@Override
public IBlockState getStateFromMeta( int meta )
{
return getDefaultState().withProperty( POWERED, ( meta & 1 ) == 1 ? true : false ).withProperty( FORMED, ( meta & 2 ) == 2 ? true : false );
}
public BlockCraftingUnit( CraftingUnitType type )
{
super( Material.iron, Optional.of(type.name()) );
this.type = type;
this.setTileEntity( TileCraftingTile.class );
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
}
@ -65,26 +101,34 @@ public class BlockCraftingUnit extends AEBaseTileBlock
}
@Override
public IIcon getIcon( int direction, int metadata )
public appeng.client.texture.IAESprite getIcon(EnumFacing side, IBlockState state)
{
switch( metadata )
if ( type == CraftingUnitType.ACCELERATOR )
{
default:
case 0:
return super.getIcon( 0, 0 );
case 1:
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
case FLAG_FORMED:
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
case 1 | FLAG_FORMED:
if ( (boolean)state.getValue( FORMED ) )
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
}
if ( (boolean)state.getValue( FORMED ) )
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
return super.getIcon( side,state );
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
{
TileCraftingTile tg = this.getTileEntity( w, x, y, z );
@Override
public boolean onBlockActivated(
World w,
BlockPos pos,
IBlockState state,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
TileCraftingTile tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
{
if( Platform.isClient() )
@ -92,7 +136,7 @@ public class BlockCraftingUnit extends AEBaseTileBlock
return true;
}
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CRAFTING_CPU );
return true;
}
@ -108,23 +152,18 @@ public class BlockCraftingUnit extends AEBaseTileBlock
}
@Override
public void setRenderStateByMeta( int itemDamage )
public void breakBlock(
World w,
BlockPos pos,
IBlockState state )
{
IIcon front = this.getIcon( ForgeDirection.SOUTH.ordinal(), itemDamage );
IIcon other = this.getIcon( ForgeDirection.NORTH.ordinal(), itemDamage );
this.getRendererInstance().setTemporaryRenderIcons( other, other, front, other, other, other );
}
@Override
public void breakBlock( World w, int x, int y, int z, Block a, int b )
{
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
TileCraftingTile cp = this.getTileEntity( w, pos );
if( cp != null )
{
cp.breakCluster();
}
super.breakBlock( w, x, y, z, a, b );
super.breakBlock( w, pos, state );
}
@Override
@ -144,25 +183,23 @@ public class BlockCraftingUnit extends AEBaseTileBlock
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
protected IProperty[] getAEStates()
{
TileCraftingTile cp = this.getTileEntity( w, x, y, z );
return new IProperty[]{POWERED, FORMED };
}
@Override
public void onNeighborBlockChange(
World worldIn,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TileCraftingTile cp = this.getTileEntity( worldIn, pos );
if( cp != null )
{
cp.updateMultiBlock();
}
}
@Override
public int damageDropped( int meta )
{
return meta & 3;
}
@Override
public int getDamageValue( World w, int x, int y, int z )
{
int meta = w.getBlockMetadata( x, y, z );
return this.damageDropped( meta );
}
}

View File

@ -22,13 +22,15 @@ package appeng.block.crafting;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockAssembler;
@ -41,8 +43,6 @@ import appeng.util.Platform;
public class BlockMolecularAssembler extends AEBaseTileBlock
{
public static boolean booleanAlphaPass = false;
public BlockMolecularAssembler()
{
super( Material.iron );
@ -54,18 +54,10 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
}
@Override
public int getRenderBlockPass()
{
return 1;
public boolean canRenderInLayer(net.minecraft.util.EnumWorldBlockLayer layer) {
return layer == EnumWorldBlockLayer.CUTOUT_MIPPED;
}
@Override
public boolean canRenderInPass( int pass )
{
booleanAlphaPass = pass == 1;
return pass == 0 || pass == 1;
}
@Override
@SideOnly( Side.CLIENT )
public Class<? extends BaseBlockRender> getRenderer()
@ -74,12 +66,20 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onBlockActivated(
World w,
BlockPos pos,
IBlockState state,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
TileMolecularAssembler tg = this.getTileEntity( w, x, y, z );
TileMolecularAssembler tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_MAC );
return true;
}
return false;

View File

@ -21,7 +21,6 @@ package appeng.block.crafting;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.block.AEBaseItemBlock;
import appeng.core.AEConfig;

View File

@ -23,14 +23,15 @@ import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.tiles.ICrankable;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
@ -60,17 +61,24 @@ public class BlockCrank extends AEBaseTileBlock
{
return RenderBlockCrank.class;
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player instanceof FakePlayer || player == null )
{
this.dropCrank( w, x, y, z );
this.dropCrank( w, pos );
return true;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
AEBaseTile tile = this.getTileEntity( w, pos );
if( tile instanceof TileCrank )
{
if( ( (TileCrank) tile ).power() )
@ -82,78 +90,93 @@ public class BlockCrank extends AEBaseTileBlock
return true;
}
private void dropCrank( World world, int x, int y, int z )
private void dropCrank( World world, BlockPos pos )
{
world.func_147480_a( x, y, z, true ); // w.destroyBlock( x, y, z, true );
world.markBlockForUpdate( x, y, z );
world.destroyBlock( pos, true ); // w.destroyBlock( x, y, z, true );
world.markBlockForUpdate( pos );
}
@Override
public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase placer, ItemStack itemStack )
public void onBlockPlacedBy(
World world,
BlockPos pos,
IBlockState state,
EntityLivingBase placer,
ItemStack stack )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
AEBaseTile tile = this.getTileEntity( world, pos );
if( tile != null )
{
ForgeDirection mnt = this.findCrankable( world, x, y, z );
ForgeDirection forward = ForgeDirection.UP;
if( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
EnumFacing mnt = this.findCrankable( world, pos );
EnumFacing forward = EnumFacing.UP;
if( mnt == EnumFacing.UP || mnt == EnumFacing.DOWN )
{
forward = ForgeDirection.SOUTH;
forward = EnumFacing.SOUTH;
}
tile.setOrientation( forward, mnt.getOpposite() );
}
else
{
this.dropCrank( world, x, y, z );
this.dropCrank( world, pos );
}
}
@Override
public boolean isValidOrientation( World world, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation(
World w,
BlockPos pos,
EnumFacing forward,
EnumFacing up )
{
TileEntity te = world.getTileEntity( x, y, z );
return !( te instanceof TileCrank ) || this.isCrankable( world, x, y, z, up.getOpposite() );
TileEntity te = w.getTileEntity( pos );
return !( te instanceof TileCrank ) || this.isCrankable( w, pos, up.getOpposite() );
}
private ForgeDirection findCrankable( World world, int x, int y, int z )
private EnumFacing findCrankable( World world, BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.isCrankable( world, x, y, z, dir ) )
if( this.isCrankable( world, pos, dir ) )
{
return dir;
}
}
return ForgeDirection.UNKNOWN;
return null;
}
private boolean isCrankable( World world, int x, int y, int z, ForgeDirection offset )
private boolean isCrankable( World world, BlockPos pos, EnumFacing offset )
{
TileEntity te = world.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
BlockPos o = pos.offset( offset);
TileEntity te = world.getTileEntity( o );
return te instanceof ICrankable && ( (ICrankable) te ).canCrankAttach( offset.getOpposite() );
}
@Override
public void onNeighborBlockChange( World world, int x, int y, int z, Block block )
public void onNeighborBlockChange(
World world,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
AEBaseTile tile = this.getTileEntity( world, pos );
if( tile != null )
{
if( !this.isCrankable( world, x, y, z, tile.getUp().getOpposite() ) )
if( !this.isCrankable( world, pos, tile.getUp().getOpposite() ) )
{
this.dropCrank( world, x, y, z );
this.dropCrank( world, pos );
}
}
else
{
this.dropCrank( world, x, y, z );
this.dropCrank( world, pos );
}
}
@Override
public boolean canPlaceBlockAt( World world, int x, int y, int z )
public boolean canPlaceBlockAt( World world, BlockPos pos )
{
return this.findCrankable( world, x, y, z ) != ForgeDirection.UNKNOWN;
return this.findCrankable( world, pos ) != null;
}
}

View File

@ -22,10 +22,12 @@ package appeng.block.grindstone;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@ -46,12 +48,34 @@ public class BlockGrinder extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onBlockActivated(
World worldIn,
BlockPos pos,
IBlockState state,
EntityPlayer playerIn,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
TileGrinder tg = this.getTileEntity( w, x, y, z );
// TODO Auto-generated method stub
return super.onBlockActivated( worldIn, pos, state, playerIn, side, hitX, hitY, hitZ );
}
@Override
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
TileGrinder tg = this.getTileEntity( w, pos );
if( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_GRINDER );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_GRINDER );
return true;
}
return false;

View File

@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@ -45,19 +46,26 @@ public class BlockCellWorkbench extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileCellWorkbench tg = this.getTileEntity( w, x, y, z );
TileCellWorkbench tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELL_WORKBENCH );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CELL_WORKBENCH );
}
return true;
}

View File

@ -25,17 +25,18 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCharger;
@ -69,7 +70,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@ -78,7 +86,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
if( Platform.isServer() )
{
TileCharger tc = this.getTileEntity( w, x, y, z );
TileCharger tc = this.getTileEntity( w, pos );
if( tc != null )
{
tc.activate( player );
@ -87,10 +95,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
return true;
}
@Override
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
@ -102,7 +114,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
return;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
AEBaseTile tile = this.getTileEntity( w, pos );
if( tile instanceof TileCharger )
{
TileCharger tc = (TileCharger) tile;
@ -117,7 +129,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
{
if( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
@ -126,27 +138,31 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
TileCharger tile = this.getTileEntity( w, x, y, z );
TileCharger tile = this.getTileEntity( w, pos );
if( tile != null )
{
double twoPixels = 2.0 / 16.0;
ForgeDirection up = tile.getUp();
ForgeDirection forward = tile.getForward();
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
EnumFacing up = tile.getUp();
EnumFacing forward = tile.getForward();
AEAxisAlignedBB bb = AEAxisAlignedBB.fromBounds( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
if( up.offsetX != 0 )
if( up.getFrontOffsetX() != 0 )
{
bb.minX = 0;
bb.maxX = 1;
}
if( up.offsetY != 0 )
if( up.getFrontOffsetY() != 0 )
{
bb.minY = 0;
bb.maxY = 1;
}
if( up.offsetZ != 0 )
if( up.getFrontOffsetZ() != 0 )
{
bb.minZ = 0;
bb.maxZ = 1;
@ -176,14 +192,19 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( bb );
return Collections.singletonList( bb.getBoundingBox() );
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
}
@Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
out.add( AxisAlignedBB.fromBounds( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}

View File

@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@ -45,7 +46,14 @@ public class BlockCondenser extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@ -54,10 +62,10 @@ public class BlockCondenser extends AEBaseTileBlock
if( Platform.isServer() )
{
TileCondenser tc = this.getTileEntity( w, x, y, z );
TileCondenser tc = this.getTileEntity( w, pos );
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CONDENSER );
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CONDENSER );
return true;
}
}

View File

@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockInscriber;
@ -53,21 +54,28 @@ public class BlockInscriber extends AEBaseTileBlock
{
return RenderBlockInscriber.class;
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileInscriber tg = this.getTileEntity( w, x, y, z );
TileInscriber tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INSCRIBER );
}
return true;
}

View File

@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
@ -54,19 +55,26 @@ public class BlockInterface extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileInterface tg = this.getTileEntity( w, x, y, z );
TileInterface tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INTERFACE );
}
return true;
}
@ -80,11 +88,11 @@ public class BlockInterface extends AEBaseTileBlock
}
@Override
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
protected void customRotateBlock( IOrientable rotatable, EnumFacing axis )
{
if( rotatable instanceof TileInterface )
{
( (TileInterface) rotatable ).setSide( axis );
( (TileInterface) rotatable ).setSide( AEPartLocation.fromFacing( axis ) );
}
}
}

View File

@ -25,20 +25,19 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzTorch;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
@ -46,14 +45,13 @@ import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileLightDetector;
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock,ICustomCollision
{
public BlockLightDetector()
{
super( Material.circuits );
this.setLightLevel( 0.9375F );
this.setLightOpacity( 0 );
this.isFullSize = false;
this.isOpaque = false;
@ -63,22 +61,49 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
public int getMetaFromState(
IBlockState state )
{
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, x, y, z ) ).isReady() )
return 0;
}
@Override
public IBlockState getStateFromMeta(
int meta )
{
return getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{ BlockTorch.FACING };
}
@Override
public int isProvidingWeakPower(
IBlockAccess w,
BlockPos pos,
IBlockState state,
EnumFacing side )
{
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, pos ) ).isReady() )
{
return ( (World) w ).getBlockLightValue( x, y, z ) - 6;
return ( (World) w ).getLightFromNeighbors( pos ) - 6;
}
return 0;
}
@Override
public void onNeighborChange( IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ )
public void onNeighborChange(
IBlockAccess world,
BlockPos pos,
BlockPos neighbor )
{
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
super.onNeighborChange( world, pos, neighbor );
TileLightDetector tld = this.getTileEntity( world, x, y, z );
TileLightDetector tld = this.getTileEntity( world, pos );
if( tld != null )
{
tld.updateLight();
@ -86,8 +111,11 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World worldIn,
BlockPos pos,
IBlockState state,
Random rand )
{
// cancel out lightning
}
@ -99,58 +127,76 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation(
World w,
BlockPos pos,
EnumFacing forward,
EnumFacing up )
{
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
return this.canPlaceAt( w, pos, up.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
return Collections.singletonList( AxisAlignedBB.fromBounds( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
return Collections.singletonList( AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
}
@Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{/*
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
*/
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
EnumFacing up = this.getOrientable( w, pos ).getUp();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt(
World w,
BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@ -165,8 +211,8 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
{
return new MetaRotation( w, x, y, z );
return new MetaRotation( w, pos,true );
}
}

View File

@ -26,16 +26,17 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.MaterialLiquid;
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.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockPaint;
@ -58,6 +59,12 @@ public class BlockPaint extends AEBaseTileBlock
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@ -70,23 +77,32 @@ public class BlockPaint extends AEBaseTileBlock
{
// do nothing
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool( World world, int x, int y, int z )
public AxisAlignedBB getCollisionBoundingBox(
World worldIn,
BlockPos pos,
IBlockState state )
{
return null;
}
@Override
public boolean canCollideCheck( int metadata, boolean isHoldingRightClick )
public boolean canCollideCheck(
IBlockState state,
boolean hitIfLiquid )
{
return false;
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
TilePaint tp = this.getTileEntity( w, pos );
if( tp != null )
{
@ -95,30 +111,42 @@ public class BlockPaint extends AEBaseTileBlock
}
@Override
public Item getItemDropped( int meta, Random random, int fortune )
public Item getItemDropped(
IBlockState state,
Random rand,
int fortune )
{
return null;
}
@Override
public void dropBlockAsItemWithChance( World world, int x, int y, int z, int meta, float chance, int fortune )
public void dropBlockAsItemWithChance(
World worldIn,
BlockPos pos,
IBlockState state,
float chance,
int fortune )
{
}
@Override
public void fillWithRain( World w, int x, int y, int z )
public void fillWithRain(
World w,
BlockPos pos )
{
if( Platform.isServer() )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
}
@Override
public int getLightValue( IBlockAccess w, int x, int y, int z )
public int getLightValue(
IBlockAccess w,
BlockPos pos )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
TilePaint tp = this.getTileEntity( w, pos );
if( tp != null )
{
@ -129,14 +157,19 @@ public class BlockPaint extends AEBaseTileBlock
}
@Override
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
public boolean isAir(
IBlockAccess world,
BlockPos pos )
{
return true;
}
@Override
public boolean isAir( IBlockAccess world, int x, int y, int z )
public boolean isReplaceable(
World worldIn,
BlockPos pos )
{
return true;
}
}

View File

@ -24,16 +24,11 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
@ -41,12 +36,11 @@ import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.features.AEFeature;
import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileQuartzGrowthAccelerator;
import appeng.util.Platform;
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock
{
public BlockQuartzGrowthAccelerator()
@ -64,42 +58,50 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
return;
}
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, x, y, z );
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos );
if( cga != null && cga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = r.nextFloat() - 0.5F;
double d1 = r.nextFloat() - 0.5F;
ForgeDirection up = cga.getUp();
ForgeDirection forward = cga.getForward();
ForgeDirection west = Platform.crossProduct( forward, up );
EnumFacing up = cga.getUp();
EnumFacing forward = cga.getForward();
EnumFacing west = Platform.crossProduct( forward, up );
double rx = 0.5 + x;
double ry = 0.5 + y;
double rz = 0.5 + z;
double rx = 0.5 + pos.getX();
double ry = 0.5 + pos.getY();
double rz = 0.5 + pos.getZ();
double dx = 0;
double dz = 0;
rx += up.offsetX * d0;
ry += up.offsetY * d0;
rz += up.offsetZ * d0;
rx += up.getFrontOffsetX() * d0;
ry += up.getFrontOffsetY() * d0;
rz += up.getFrontOffsetZ() * d0;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
switch( r.nextInt( 4 ) )
{
case 0:
dx = 0.6;
dz = d1;
if( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) )
BlockPos pt = new BlockPos( x + west.getFrontOffsetX(), y + west.getFrontOffsetY(), z + west.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@ -107,7 +109,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
case 1:
dx = d1;
dz += 0.6;
if( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ) )
pt = new BlockPos( x + forward.getFrontOffsetX(), y + forward.getFrontOffsetY(), z + forward.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@ -115,7 +118,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
case 2:
dx = d1;
dz = -0.6;
if( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ) )
pt = new BlockPos( x - forward.getFrontOffsetX(), y - forward.getFrontOffsetY(), z - forward.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@ -123,35 +127,25 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
case 3:
dx = -0.6;
dz = d1;
if( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) )
pt = new BlockPos( x - west.getFrontOffsetX(), y - west.getFrontOffsetY(), z - west.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
break;
}
rx += dx * west.offsetX;
ry += dx * west.offsetY;
rz += dx * west.offsetZ;
rx += dx * west.getFrontOffsetX();
ry += dx * west.getFrontOffsetY();
rz += dx * west.getFrontOffsetZ();
rx += dz * forward.offsetX;
ry += dz * forward.offsetY;
rz += dz * forward.offsetZ;
rx += dz * forward.getFrontOffsetX();
ry += dz * forward.getFrontOffsetY();
rz += dz * forward.getFrontOffsetZ();
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
@Override
public boolean usesMetadata()
{
return true;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
return new MetaRotation( w, x, y, z );
}
}

View File

@ -25,17 +25,19 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
@ -61,6 +63,26 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
this.isFullSize = false;
this.isOpaque = false;
}
@Override
public int getMetaFromState(
IBlockState state )
{
return 0;
}
@Override
public IBlockState getStateFromMeta(
int meta )
{
return getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{ BlockTorch.FACING };
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
@ -69,38 +91,43 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
{
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
return this.canPlaceAt( w, pos, up.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
BlockPos test = pos.offset( dir );
return w.isSideSolid( test, dir.getOpposite(), false );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, BlockPos pos, Entity e, boolean isVisual )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
return Collections.singletonList( AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
return Collections.singletonList( AxisAlignedBB.fromBounds( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
}
@Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
public void addCollidingBlockToList( World w, BlockPos pos, AxisAlignedBB bb, List out, Entity e )
{/*
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
*/
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
@ -112,15 +139,15 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
return;
}
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
for( int bolts = 0; bolts < 3; bolts++ )
{
if( CommonHelper.proxy.shouldAddParticles( r ) )
{
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
@ -128,28 +155,31 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
EnumFacing up = this.getOrientable( w, pos ).getUp();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt( World w, BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@ -164,8 +194,8 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
{
return new MetaRotation( w, x, y, z );
return new MetaRotation( w, pos,true );
}
}

View File

@ -23,9 +23,11 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RendererSecurity;
@ -46,21 +48,34 @@ public class BlockSecurity extends AEBaseTileBlock
this.setFeature( EnumSet.of( AEFeature.Security ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererSecurity.class;
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileSecurity tg = this.getTileEntity( w, x, y, z );
TileSecurity tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isClient() )
@ -68,7 +83,7 @@ public class BlockSecurity extends AEBaseTileBlock
return true;
}
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SECURITY );
return true;
}
return false;

View File

@ -25,17 +25,12 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockSkyCompass;
@ -63,58 +58,50 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
{
return Blocks.iron_block.getIcon( direction, metadata );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
// :P
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
TileSkyCompass sc = this.getTileEntity( w, pos );
if( sc != null )
{
return false;
}
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
return this.canPlaceAt( w, pos, forward.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
ForgeDirection up = sc.getForward();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
TileSkyCompass sc = this.getTileEntity( w, pos );
EnumFacing up = sc.getForward();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt(
World w,
BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@ -123,12 +110,16 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
TileSkyCompass tile = this.getTileEntity( w, x, y, z );
TileSkyCompass tile = this.getTileEntity( w, pos );
if( tile != null )
{
ForgeDirection forward = tile.getForward();
EnumFacing forward = tile.getForward();
double minX = 0;
double minY = 0;
@ -179,14 +170,19 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ ) );
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
}
@Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
}
}

View File

@ -26,25 +26,22 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderTinyTNT;
import appeng.client.texture.FullIcon;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityIds;
@ -72,7 +69,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderTinyTNT.class;
return null;
}
@Override
@ -83,78 +80,86 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public IIcon getIcon( int direction, int metadata )
{
return new FullIcon( Blocks.tnt.getIcon( direction, metadata ) );
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
{
this.startFuse( w, x, y, z, player );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, player );
w.setBlockToAir( pos );
player.getCurrentEquippedItem().damageItem( 1, player );
return true;
}
else
{
return super.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
return super.onActivated( w, pos, player, side, hitX, hitY, hitZ );
}
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
// no images required.
}
public void startFuse( World w, int x, int y, int z, EntityLivingBase igniter )
public void startFuse( World w, BlockPos pos, EntityLivingBase igniter )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, igniter );
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter );
w.spawnEntityInWorld( primedTinyTNTEntity );
w.playSoundAtEntity( primedTinyTNTEntity, "game.tnt.primed", 1.0F, 1.0F );
}
}
@Override
public void onBlockAdded( World w, int x, int y, int z )
public void onBlockAdded(
World w,
BlockPos pos,
IBlockState state )
{
super.onBlockAdded( w, x, y, z );
super.onBlockAdded( w, pos, state );
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onBlockDestroyedByExplosion( World w, int x, int y, int z, Explosion exp )
public void onBlockExploded(
World w,
BlockPos pos,
Explosion exp )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
}
@Override
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity entity )
public void onEntityCollidedWithBlock(
World w,
BlockPos pos,
Entity entity )
{
if( entity instanceof EntityArrow && !w.isRemote )
{
@ -162,8 +167,8 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
if( entityarrow.isBurning() )
{
this.startFuse( w, x, y, z, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
w.setBlockToAir( pos );
}
}
}
@ -175,14 +180,23 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
@Override
public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List<AxisAlignedBB> out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
out.add( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
}

View File

@ -23,14 +23,17 @@ import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.IAESprite;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@ -49,14 +52,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
this.setHardness( 4.2F );
this.setFeature( EnumSet.of( AEFeature.PowerGen ) );
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
public appeng.client.texture.IAESprite getIcon(IBlockAccess w, BlockPos pos, EnumFacing side)
{
IIcon ico = super.getIcon( w, x, y, z, s );
TileVibrationChamber tvc = this.getTileEntity( w, x, y, z );
IAESprite ico = super.getIcon( w, pos, side );
TileVibrationChamber tvc = this.getTileEntity( w, pos );
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( AEPartLocation.SOUTH ) )
{
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
}
@ -65,7 +68,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@ -74,10 +84,10 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
if( Platform.isServer() )
{
TileVibrationChamber tc = this.getTileEntity( w, x, y, z );
TileVibrationChamber tc = this.getTileEntity( w, pos );
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
return true;
}
}
@ -86,47 +96,51 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
}
@Override
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
return;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
AEBaseTile tile = this.getTileEntity( w, pos );
if( tile instanceof TileVibrationChamber )
{
TileVibrationChamber tc = (TileVibrationChamber) tile;
if( tc.isOn )
{
float f1 = x + 0.5F;
float f2 = y + 0.5F;
float f3 = z + 0.5F;
float f1 = pos.getX() + 0.5F;
float f2 = pos.getY() + 0.5F;
float f3 = pos.getZ() + 0.5F;
ForgeDirection forward = tc.getForward();
ForgeDirection up = tc.getUp();
EnumFacing forward = tc.getForward();
EnumFacing up = tc.getUp();
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
f1 += forward.offsetX * 0.6;
f2 += forward.offsetY * 0.6;
f3 += forward.offsetZ * 0.6;
f1 += forward.getFrontOffsetX() * 0.6;
f2 += forward.getFrontOffsetY() * 0.6;
f3 += forward.getFrontOffsetZ() * 0.6;
float ox = r.nextFloat();
float oy = r.nextFloat() * 0.2f;
f1 += up.offsetX * ( -0.3 + oy );
f2 += up.offsetY * ( -0.3 + oy );
f3 += up.offsetZ * ( -0.3 + oy );
f1 += up.getFrontOffsetX() * ( -0.3 + oy );
f2 += up.getFrontOffsetY() * ( -0.3 + oy );
f3 += up.getFrontOffsetZ() * ( -0.3 + oy );
f1 += west_x * ( 0.3 * ox - 0.15 );
f2 += west_y * ( 0.3 * ox - 0.15 );
f3 += west_z * ( 0.3 * ox - 0.15 );
w.spawnParticle( "smoke", f1, f2, f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( "flame", f1, f2, f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( EnumParticleTypes.SMOKE_NORMAL, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
w.spawnParticle( EnumParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
}
}
}

View File

@ -24,40 +24,33 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
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;
import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection;
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
import appeng.api.parts.IPart;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.parts.IPartHost;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BusRenderHelper;
import appeng.client.render.blocks.RendererCableBus;
import appeng.client.texture.ExtraBlockTextures;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.CommonHelper;
@ -72,13 +65,11 @@ import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.transformer.annotations.Integration.Interface;
import appeng.transformer.annotations.Integration.Method;
import appeng.util.Platform;
@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
// TODO: MFR INTEGRATION
//@Interface( iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR" )
public class BlockCableBus extends AEBaseTileBlock // implements IRedNetConnection
{
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
@ -88,7 +79,6 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
* Immibis MB Support.
*/
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
int myColorMultiplier = 0xffffff;
public BlockCableBus()
{
@ -102,43 +92,41 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
@Override
public void randomDisplayTick( World world, int x, int y, int z, Random r )
public void randomDisplayTick(
World worldIn,
BlockPos pos,
IBlockState state,
Random rand )
{
this.cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
this.cb( worldIn, pos ).randomDisplayTick( worldIn, pos, rand );
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block meh )
public void onNeighborChange(
IBlockAccess w,
BlockPos pos,
BlockPos neighbor )
{
this.cb( w, x, y, z ).onNeighborChanged();
this.cb( w, pos ).onNeighborChanged();
}
@Override
public Item getItemDropped( int i, Random r, int k )
public Item getItemDropped(
IBlockState state,
Random rand,
int fortune )
{
return null;
}
@Override
public int getRenderBlockPass()
public int isProvidingWeakPower(
IBlockAccess w,
BlockPos pos,
IBlockState state,
EnumFacing side )
{
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
{
return 1;
}
return 0;
}
@Override
public int colorMultiplier( IBlockAccess world, int x, int y, int z )
{
return this.myColorMultiplier;
}
@Override
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
{
return this.cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
return this.cb( w, pos ).isProvidingWeakPower( side.getOpposite() ); // TODO: IS OPPOSITE!?
}
@Override
@ -148,104 +136,113 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
@Override
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity e )
public void onEntityCollidedWithBlock(
World w,
BlockPos pos,
IBlockState state,
Entity entityIn )
{
this.cb( w, x, y, z ).onEntityCollision( e );
this.cb( w, pos ).onEntityCollision( entityIn );
}
@Override
public int isProvidingStrongPower( IBlockAccess w, int x, int y, int z, int side )
public int isProvidingStrongPower(
IBlockAccess w,
BlockPos pos,
IBlockState state,
EnumFacing side )
{
return this.cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
return this.cb( w, pos ).isProvidingStrongPower( side.getOpposite() ); // TODO: IS OPPOSITE!?
}
@Override
public int getLightValue( IBlockAccess world, int x, int y, int z )
public int getLightValue(
IBlockAccess world,
BlockPos pos )
{
Block block = world.getBlock( x, y, z );
if( block != null && block != this )
IBlockState block = world.getBlockState( pos );
if( block != null && block.getBlock() != this )
{
return block.getLightValue( world, x, y, z );
return block.getBlock().getLightValue( world, pos );
}
if( block == null )
{
return 0;
}
return this.cb( world, x, y, z ).getLightValue();
return this.cb( world, pos ).getLightValue();
}
@Override
public boolean isLadder( IBlockAccess world, int x, int y, int z, EntityLivingBase entity )
public boolean isLadder( IBlockAccess world, BlockPos pos, EntityLivingBase entity )
{
return this.cb( world, x, y, z ).isLadder( entity );
return this.cb( world, pos ).isLadder( entity );
}
@Override
public boolean isSideSolid( IBlockAccess w, int x, int y, int z, ForgeDirection side )
public boolean isSideSolid( IBlockAccess w, BlockPos pos, EnumFacing side )
{
return this.cb( w, x, y, z ).isSolidOnSide( side );
return this.cb( w, pos ).isSolidOnSide( side );
}
@Override
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
public boolean isReplaceable(
World w,
BlockPos pos )
{
return this.cb( world, x, y, z ).isEmpty();
return this.cb( w, pos ).isEmpty();
}
@SuppressWarnings( "deprecation" )
@Override
public boolean removedByPlayer( World world, EntityPlayer player, int x, int y, int z )
public boolean removedByPlayer(
World world,
BlockPos pos,
EntityPlayer player,
boolean willHarvest )
{
if( player.capabilities.isCreativeMode )
{
AEBaseTile tile = this.getTileEntity( world, x, y, z );
AEBaseTile tile = this.getTileEntity( world, pos );
if( tile != null )
{
tile.disableDrops();
}
// maybe ray trace?
}
return super.removedByPlayer( world, player, x, y, z );
return super.removedByPlayer( world, pos, player, willHarvest );
}
@Override
public boolean canConnectRedstone( IBlockAccess w, int x, int y, int z, int side )
public boolean canConnectRedstone(
IBlockAccess w,
BlockPos pos,
EnumFacing side )
{
switch( side )
{
case -1:
case 4:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
case 0:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
case 1:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
case 2:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
case 3:
return this.cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
}
return false;
if ( side == null )
side = EnumFacing.UP;
return this.cb( w, pos ).canConnectRedstone( EnumSet.of( side ) );
}
@Override
public boolean canRenderInPass( int pass )
public boolean canRenderInLayer(
EnumWorldBlockLayer layer )
{
BusRenderHelper.INSTANCE.setPass( pass );
if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
{
return true;
return layer == EnumWorldBlockLayer.CUTOUT || layer == EnumWorldBlockLayer.TRANSLUCENT;
}
return pass == 0;
return layer == EnumWorldBlockLayer.CUTOUT;
}
@Override
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
public ItemStack getPickBlock(
MovingObjectPosition target,
World world,
BlockPos pos )
{
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 );
Vec3 v3 = target.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() );
SelectedPart sp = this.cb( world, pos ).selectPart( v3 );
if( sp.part != null )
{
@ -263,15 +260,17 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
@SideOnly( Side.CLIENT )
public boolean addHitEffects( World world, MovingObjectPosition target, EffectRenderer effectRenderer )
{
Object object = this.cb( world, target.blockX, target.blockY, target.blockZ );
Object object = this.cb( world, target.getBlockPos() );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
// TODO HIT EFFECTS
/*
for( AEPartLocation side : AEPartLocation.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
TextureAtlasSprite ico = this.getIcon( p );
if( ico == null )
{
@ -302,24 +301,29 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
}
}
*/
}
return true;
}
@Override
@SideOnly( Side.CLIENT )
public boolean addDestroyEffects( World world, int x, int y, int z, int meta, EffectRenderer effectRenderer )
public boolean addDestroyEffects(
World world,
BlockPos pos,
EffectRenderer effectRenderer )
{
Object object = this.cb( world, x, y, z );
Object object = this.cb( world, pos );
if( object instanceof IPartHost )
{
IPartHost host = (IPartHost) object;
for( ForgeDirection side : ForgeDirection.values() )
// TODO DESTROY EFFECTS
/*
for( AEPartLocation side : AEPartLocation.values() )
{
IPart p = host.getPart( side );
IIcon ico = this.getIcon( p );
TextureAtlasSprite ico = this.getIcon( p );
if( ico == null )
{
@ -346,52 +350,28 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
}
}
*/
}
return true;
}
@Override
public void onNeighborChange( IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
if( Platform.isServer() )
{
this.cb( w, x, y, z ).onNeighborChanged();
this.cb( w, pos ).onNeighborChanged();
}
}
private IIcon getIcon( IPart p )
private ICableBusContainer cb( IBlockAccess w, BlockPos pos )
{
if( p == null )
{
return null;
}
try
{
IIcon ico = p.getBreakingTexture();
if( ico != null )
{
return ico;
}
}
catch( Throwable t )
{
// nothing.
}
ItemStack is = p.getItemStack( PartItemStack.Network );
if( is == null || is.getItem() == null )
{
return null;
}
return is.getItem().getIcon( is, 0 );
}
private ICableBusContainer cb( IBlockAccess w, int x, int y, int z )
{
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
ICableBusContainer out = null;
if( te instanceof TileCableBus )
@ -413,46 +393,38 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
return this.getIcon( s, 0 );
return this.cb( w, pos ).activate( player, new Vec3( hitX, hitY, hitZ ) );
}
@Override
public IIcon getIcon( int direction, int metadata )
public boolean recolorBlock(
World world,
BlockPos pos,
EnumFacing side,
EnumDyeColor color )
{
IIcon i = super.getIcon( direction, metadata );
if( i != null )
{
return i;
}
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
return this.recolorBlock( world, pos, side, color, null );
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
{
return this.cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
}
@Override
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
{
return this.recolourBlock( world, x, y, z, side, colour, null );
}
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who )
public boolean recolorBlock(
World world,
BlockPos pos,
EnumFacing side,
EnumDyeColor color,
EntityPlayer who )
{
try
{
return this.cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
return this.cb( world, pos ).recolourBlock( side, AEColor.values()[ color.ordinal() ], who );
}
catch( Throwable ignored )
{}
@ -467,9 +439,9 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
@Override
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, int x, int y, int z )
public <T extends AEBaseTile> T getTileEntity( IBlockAccess w, BlockPos pos )
{
TileEntity te = w.getTileEntity( x, y, z );
TileEntity te = w.getTileEntity( pos );
if( noTesrTile.isInstance( te ) )
{
@ -504,15 +476,13 @@ public class BlockCableBus extends AEBaseTileBlock implements IRedNetConnection
}
}
@Override
@Method( iname = "MFR" )
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, ForgeDirection side )
{
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
}
public void setRenderColor( int color )
{
this.myColorMultiplier = color;
}
/*
* // TODO MFR INTEGRATION
@Override
@Method( iname = "MFR" )
public RedNetConnectionType getConnectionType( World world, int x, int y, int z, AEPartLocation side )
{
return this.cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( AEPartLocation.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
}
*/
}

Some files were not shown because too many files have changed in this diff Show More