2014-02-28 09:12:00 +01:00
|
|
|
package appeng.block.solids;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
2014-02-28 20:13:43 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
import net.minecraft.block.Block;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2014-02-28 20:13:43 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-04-04 06:12:35 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-02-28 20:13:43 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-03-01 04:45:30 +01:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2014-02-28 09:12:00 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2014-03-01 04:45:30 +01:00
|
|
|
import net.minecraft.world.World;
|
2014-03-04 05:56:08 +01:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
2014-04-04 06:12:35 +02:00
|
|
|
import rblocks.api.RotatableBlockEnable;
|
2014-02-28 09:12:00 +01:00
|
|
|
import appeng.api.util.IOrientable;
|
|
|
|
import appeng.api.util.IOrientableBlock;
|
|
|
|
import appeng.block.AEBaseBlock;
|
2014-04-04 06:12:35 +02:00
|
|
|
import appeng.core.AppEng;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.core.WorldSettings;
|
2014-02-28 09:12:00 +01:00
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.helpers.LocationRotation;
|
2014-03-22 19:27:44 +01:00
|
|
|
import appeng.helpers.NullRotation;
|
2014-07-24 00:26:23 +02:00
|
|
|
import appeng.integration.IntegrationType;
|
2014-04-04 06:12:35 +02:00
|
|
|
import appeng.integration.abstraction.IRB;
|
2014-06-17 05:43:41 +02:00
|
|
|
import appeng.util.Platform;
|
2014-03-04 05:56:08 +01:00
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2014-03-01 04:45:30 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-02-28 09:12:00 +01:00
|
|
|
|
2014-04-04 06:12:35 +02:00
|
|
|
@RotatableBlockEnable
|
2014-02-28 16:27:04 +01:00
|
|
|
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
2014-02-28 09:12:00 +01:00
|
|
|
{
|
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-03-01 04:45:30 +01:00
|
|
|
IIcon Block;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
IIcon Brick;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
IIcon SmallBrick;
|
|
|
|
|
2014-03-04 05:56:08 +01:00
|
|
|
@SubscribeEvent
|
|
|
|
public void breakFaster(PlayerEvent.BreakSpeed Ev)
|
|
|
|
{
|
2014-06-08 03:20:23 +02:00
|
|
|
if ( Ev.block == this && Ev.entityPlayer != null )
|
|
|
|
{
|
|
|
|
ItemStack is = Ev.entityPlayer.inventory.getCurrentItem();
|
|
|
|
int level = -1;
|
|
|
|
|
|
|
|
if ( is != null )
|
|
|
|
level = is.getItem().getHarvestLevel( is, "pickaxe" );
|
|
|
|
|
|
|
|
if ( Ev.metadata > 0 || level >= 3 || Ev.originalSpeed > 7.0 )
|
|
|
|
Ev.newSpeed /= 0.1;
|
|
|
|
}
|
2014-03-04 05:56:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-28 16:27:04 +01:00
|
|
|
public BlockSkyStone() {
|
|
|
|
super( BlockSkyStone.class, Material.rock );
|
2014-02-28 09:12:00 +01:00
|
|
|
setfeature( EnumSet.of( AEFeature.Core ) );
|
|
|
|
setHardness( 50 );
|
2014-03-01 04:45:30 +01:00
|
|
|
hasSubtypes = true;
|
2014-02-28 09:12:00 +01:00
|
|
|
blockResistance = 150.0f;
|
2014-03-04 05:56:08 +01:00
|
|
|
setHarvestLevel( "pickaxe", 3, 0 );
|
|
|
|
MinecraftForge.EVENT_BUS.register( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int damageDropped(int meta)
|
|
|
|
{
|
|
|
|
return meta;
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
@Override
|
2014-03-01 04:45:30 +01:00
|
|
|
public String getUnlocalizedName(ItemStack is)
|
|
|
|
{
|
2014-02-28 20:13:43 +01:00
|
|
|
if ( is.getItemDamage() == 1 )
|
2014-03-01 04:45:30 +01:00
|
|
|
return getUnlocalizedName() + ".Block";
|
|
|
|
|
|
|
|
if ( is.getItemDamage() == 2 )
|
|
|
|
return getUnlocalizedName() + ".Brick";
|
|
|
|
|
|
|
|
if ( is.getItemDamage() == 3 )
|
|
|
|
return getUnlocalizedName() + ".SmallBrick";
|
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
return getUnlocalizedName();
|
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
@Override
|
|
|
|
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
|
|
|
{
|
2014-07-24 00:26:23 +02:00
|
|
|
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RB ) )
|
2014-04-04 06:12:35 +02:00
|
|
|
{
|
|
|
|
TileEntity te = w.getTileEntity( x, y, z );
|
|
|
|
if ( te != null )
|
|
|
|
{
|
2014-07-24 00:26:23 +02:00
|
|
|
IOrientable out = ((IRB) AppEng.instance.getIntegration( IntegrationType.RB )).getOrientable( te );
|
2014-04-04 06:12:35 +02:00
|
|
|
if ( out != null )
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-01 04:45:30 +01:00
|
|
|
if ( w.getBlockMetadata( x, y, z ) == 0 )
|
2014-02-28 20:13:43 +01:00
|
|
|
return new LocationRotation( w, x, y, z );
|
2014-04-04 06:12:35 +02:00
|
|
|
|
2014-03-22 19:27:44 +01:00
|
|
|
return new NullRotation();
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-03-01 04:45:30 +01:00
|
|
|
public void registerBlockIcons(IIconRegister ir)
|
|
|
|
{
|
|
|
|
super.registerBlockIcons( ir );
|
|
|
|
Block = ir.registerIcon( getTextureName() + ".Block" );
|
|
|
|
Brick = ir.registerIcon( getTextureName() + ".Brick" );
|
|
|
|
SmallBrick = ir.registerIcon( getTextureName() + ".SmallBrick" );
|
2014-02-28 20:13:43 +01:00
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-03-01 04:45:30 +01:00
|
|
|
public IIcon getIcon(int direction, int metadata)
|
|
|
|
{
|
2014-02-28 20:13:43 +01:00
|
|
|
if ( metadata == 1 )
|
2014-03-01 04:45:30 +01:00
|
|
|
return Block;
|
|
|
|
if ( metadata == 2 )
|
|
|
|
return Brick;
|
|
|
|
if ( metadata == 3 )
|
|
|
|
return SmallBrick;
|
|
|
|
return super.getIcon( direction, metadata );
|
2014-02-28 20:13:43 +01:00
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setRenderStateByMeta(int metadata)
|
|
|
|
{
|
|
|
|
getRendererInstance().setTemporaryRenderIcon( getIcon( 0, metadata ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
ItemStack is = super.getPickBlock( target, world, x, y, z );
|
|
|
|
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
|
|
|
return is;
|
|
|
|
}
|
|
|
|
|
2014-02-28 20:13:43 +01:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2014-03-01 04:45:30 +01:00
|
|
|
public void getSubBlocks(Item i, CreativeTabs ct, List l)
|
|
|
|
{
|
|
|
|
super.getSubBlocks( i, ct, l );
|
2014-02-28 20:13:43 +01:00
|
|
|
l.add( new ItemStack( i, 1, 1 ) );
|
2014-03-01 04:45:30 +01:00
|
|
|
l.add( new ItemStack( i, 1, 2 ) );
|
|
|
|
l.add( new ItemStack( i, 1, 3 ) );
|
2014-02-28 20:13:43 +01:00
|
|
|
}
|
2014-03-01 04:45:30 +01:00
|
|
|
|
2014-03-02 09:35:11 +01:00
|
|
|
@Override
|
|
|
|
public void onBlockAdded(World w, int x, int y, int z)
|
|
|
|
{
|
|
|
|
super.onBlockAdded( w, x, y, z );
|
2014-06-17 05:43:41 +02:00
|
|
|
if ( Platform.isServer() )
|
|
|
|
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void breakBlock(World w, int x, int y, int z, Block b, int WTF)
|
|
|
|
{
|
|
|
|
super.breakBlock( w, x, y, z, b, WTF );
|
2014-06-17 05:43:41 +02:00
|
|
|
if ( Platform.isServer() )
|
|
|
|
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
2014-03-02 09:35:11 +01:00
|
|
|
}
|
|
|
|
|
2014-04-04 06:12:35 +02:00
|
|
|
// use AE2's enderer, no rotatable blocks.
|
|
|
|
int getRealRenderType()
|
|
|
|
{
|
|
|
|
return getRenderType();
|
|
|
|
}
|
|
|
|
|
2014-05-11 18:24:46 +02:00
|
|
|
@Override
|
|
|
|
public boolean usesMetadata()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-28 09:12:00 +01:00
|
|
|
}
|