Most of the 1.8 Port.
This commit is contained in:
@@ -23,25 +23,14 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
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.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
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.AEApi;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyChest;
|
||||
@@ -51,37 +40,32 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockSkyChest()
|
||||
|
||||
public static enum SkyChestType
|
||||
{
|
||||
super( Material.rock );
|
||||
STONE, BLOCK
|
||||
};
|
||||
|
||||
public final SkyChestType type;
|
||||
|
||||
public BlockSkyChest( SkyChestType type )
|
||||
{
|
||||
super( Material.rock, Optional.of( type.name() ) );
|
||||
this.setTileEntity( TileSkyChest.class );
|
||||
this.isOpaque = this.isFullSize = false;
|
||||
this.lightOpacity = 0;
|
||||
this.hasSubtypes = true;
|
||||
this.setHardness( 50 );
|
||||
this.blockResistance = 150.0f;
|
||||
this.type = type;
|
||||
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped( int metadata )
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock( MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
final ItemStack is = super.getPickBlock( target, world, x, y, z, player );
|
||||
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
@@ -89,75 +73,54 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
for( Block skyStoneBlock : AEApi.instance().definitions().blocks().skyStone().maybeBlock().asSet() )
|
||||
{
|
||||
return skyStoneBlock.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
return Blocks.stone.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( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
|
||||
Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing( side ), GuiBridge.GUI_SKYCHEST );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
|
||||
World w,
|
||||
BlockPos pos,
|
||||
Entity thePlayer,
|
||||
boolean b )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void getCheckedSubBlocks( Item item, CreativeTabs tabs, List<ItemStack> itemStacks )
|
||||
{
|
||||
super.getCheckedSubBlocks( item, tabs, itemStacks );
|
||||
|
||||
itemStacks.add( new ItemStack( item, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
if( is.getItemDamage() == 1 )
|
||||
{
|
||||
return this.getUnlocalizedName() + ".Block";
|
||||
}
|
||||
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
|
||||
{
|
||||
TileSkyChest sk = this.getTileEntity( w, x, y, z );
|
||||
TileSkyChest sk = this.getTileEntity( w, pos );
|
||||
double sc = 0.06;
|
||||
ForgeDirection o = ForgeDirection.UNKNOWN;
|
||||
EnumFacing o = EnumFacing.UP;
|
||||
|
||||
if( sk != null )
|
||||
{
|
||||
o = sk.getUp();
|
||||
}
|
||||
|
||||
double offsetX = o.offsetX == 0 ? 0.06 : 0.0;
|
||||
double offsetY = o.offsetY == 0 ? 0.06 : 0.0;
|
||||
double offsetZ = o.offsetZ == 0 ? 0.06 : 0.0;
|
||||
double offsetX = o.getFrontOffsetX() == 0 ? 0.06 : 0.0;
|
||||
double offsetY = o.getFrontOffsetY() == 0 ? 0.06 : 0.0;
|
||||
double offsetZ = o.getFrontOffsetZ() == 0 ? 0.06 : 0.0;
|
||||
|
||||
return Collections.singletonList( AxisAlignedBB.getBoundingBox( Math.max( 0.0, offsetX - o.offsetX * sc ), Math.max( 0.0, offsetY - o.offsetY * sc ), Math.max( 0.0, offsetZ - o.offsetZ * sc ), Math.min( 1.0, ( 1.0 - offsetX ) - o.offsetX * sc ), Math.min( 1.0, ( 1.0 - offsetY ) - o.offsetY * sc ), Math.min( 1.0, ( 1.0 - offsetZ ) - o.offsetZ * sc ) ) );
|
||||
return Collections.singletonList( AxisAlignedBB.fromBounds( Math.max( 0.0, offsetX - o.getFrontOffsetX() * sc ), Math.max( 0.0, offsetY - o.getFrontOffsetY() * sc ), Math.max( 0.0, offsetZ - o.getFrontOffsetZ() * sc ), Math.min( 1.0, ( 1.0 - offsetX ) - o.getFrontOffsetX() * sc ), Math.min( 1.0, ( 1.0 - offsetY ) - o.getFrontOffsetY() * sc ), Math.min( 1.0, ( 1.0 - offsetZ ) - o.getFrontOffsetZ() * sc ) ) );
|
||||
}
|
||||
|
||||
|
||||
@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.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
out.add( AxisAlignedBB.fromBounds( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user