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
@@ -20,67 +20,54 @@ package appeng.block.solids;
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.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import appeng.block.AEBaseBlock;
import appeng.core.WorldSettings;
import appeng.core.features.AEFeature;
import appeng.helpers.LocationRotation;
import appeng.helpers.NullRotation;
import appeng.util.Platform;
import com.google.common.base.Optional;
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
public class BlockSkyStone extends AEBaseBlock
{
private static final float BLOCK_RESISTANCE = 150.0f;
private static final double BREAK_SPEAK_SCALAR = 0.1;
private static final double BREAK_SPEAK_THRESHOLD = 7.0;
@SideOnly( Side.CLIENT )
private IIcon block;
@SideOnly( Side.CLIENT )
private IIcon brick;
@SideOnly( Side.CLIENT )
private IIcon smallBrick;
public BlockSkyStone()
public static enum SkystoneType {
stone,block,brick,smallbrick
};
SkystoneType type;
public BlockSkyStone( SkystoneType type )
{
super( Material.rock );
super( Material.rock, Optional.of( type.name()) );
this.setHardness( 50 );
this.hasSubtypes = true;
this.blockResistance = BLOCK_RESISTANCE;
this.setHarvestLevel( "pickaxe", 3, 0 );
if ( type == SkystoneType.stone )
this.setHarvestLevel( "pickaxe", 3 );
this.setFeature( EnumSet.of( AEFeature.Core ) );
this.type = type;
MinecraftForge.EVENT_BUS.register( this );
}
@SubscribeEvent
public void breakFaster( PlayerEvent.BreakSpeed event )
{
if( event.block == this && event.entityPlayer != null )
if( event.state.getBlock() == this && event.entityPlayer != null )
{
ItemStack is = event.entityPlayer.inventory.getCurrentItem();
int level = -1;
@@ -90,7 +77,7 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
level = is.getItem().getHarvestLevel( is, "pickaxe" );
}
if( event.metadata > 0 || level >= 3 || event.originalSpeed > BREAK_SPEAK_THRESHOLD )
if( type != SkystoneType.stone || level >= 3 || event.originalSpeed > BREAK_SPEAK_THRESHOLD )
{
event.newSpeed /= BREAK_SPEAK_SCALAR;
}
@@ -98,121 +85,40 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
}
@Override
public int damageDropped( int meta )
public void onBlockAdded(
World w,
BlockPos pos,
IBlockState state )
{
return meta;
}
@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
public void onBlockAdded( World w, int x, int y, int z )
{
super.onBlockAdded( w, x, y, z );
super.onBlockAdded( w, pos, state );
if( Platform.isServer() )
{
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
WorldSettings.getInstance().getCompass().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
}
}
@Override
public boolean usesMetadata()
{
return false;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
if( w.getBlockMetadata( x, y, z ) == 0 )
{
return new LocationRotation( w, x, y, z );
}
return new NullRotation();
}
@Override
public String getUnlocalizedName( ItemStack is )
{
if( is.getItemDamage() == 1 )
switch(type)
{
return this.getUnlocalizedName() + ".Block";
case block: return this.getUnlocalizedName() + ".Block";
case brick: return this.getUnlocalizedName() + ".Brick";
case smallbrick: return this.getUnlocalizedName() + ".SmallBrick";
default: return this.getUnlocalizedName();
}
if( is.getItemDamage() == 2 )
{
return this.getUnlocalizedName() + ".Brick";
}
if( is.getItemDamage() == 3 )
{
return this.getUnlocalizedName() + ".SmallBrick";
}
return this.getUnlocalizedName();
}
@Override
@SideOnly( Side.CLIENT )
public void registerBlockIcons( IIconRegister ir )
public void breakBlock(
World w,
BlockPos pos,
IBlockState state )
{
super.registerBlockIcons( ir );
this.block = ir.registerIcon( this.getTextureName() + ".Block" );
this.brick = ir.registerIcon( this.getTextureName() + ".Brick" );
this.smallBrick = ir.registerIcon( this.getTextureName() + ".SmallBrick" );
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
{
if( metadata == 1 )
{
return this.block;
}
if( metadata == 2 )
{
return this.brick;
}
if( metadata == 3 )
{
return this.smallBrick;
}
return super.getIcon( direction, metadata );
}
@Override
public void setRenderStateByMeta( int metadata )
{
this.getRendererInstance().setTemporaryRenderIcon( this.getIcon( 0, metadata ) );
}
@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 ) );
itemStacks.add( new ItemStack( item, 1, 2 ) );
itemStacks.add( new ItemStack( item, 1, 3 ) );
}
@Override
public void breakBlock( World w, int x, int y, int z, Block b, int metadata )
{
super.breakBlock( w, x, y, z, b, metadata );
super.breakBlock( w, pos, state );
if( Platform.isServer() )
{
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
WorldSettings.getInstance().getCompass().updateArea( w, pos.getX(), pos.getY(), pos.getZ() );
}
}
}