Started work on alloy furnace

This commit is contained in:
Emmanuel BENOîT 2016-06-19 10:52:38 +02:00
parent 6568048af0
commit 88676c015e
6 changed files with 303 additions and 3 deletions

View file

@ -5,7 +5,7 @@ import mmm.Mmm;
import mmm.deco.DecorativeBlocks; import mmm.deco.DecorativeBlocks;
import mmm.food.Food; import mmm.food.Food;
import mmm.materials.Materials; import mmm.materials.Materials;
import mmm.tech.tools.Tools; import mmm.tech.Tech;
import mmm.utils.UAccessors; import mmm.utils.UAccessors;
import mmm.utils.URegistry; import mmm.utils.URegistry;
import mmm.utils.USeat; import mmm.utils.USeat;
@ -23,7 +23,7 @@ public abstract class PCommon
UAccessors.preInit( ); UAccessors.preInit( );
Materials.preInit( ); Materials.preInit( );
Tools.preInit( ); Tech.preInit( );
Food.preInit( ); Food.preInit( );
DecorativeBlocks.preInit( ); DecorativeBlocks.preInit( );

View file

@ -0,0 +1,22 @@
package mmm.tech;
import mmm.tech.base.TechBase;
import mmm.tech.tools.TechTools;
public class Tech
{
static {
TechBase.preInit( );
TechTools.preInit( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -0,0 +1,231 @@
package mmm.tech.base;
import java.util.Random;
import javax.annotation.Nullable;
import mmm.utils.I_USupportBlock;
import mmm.utils.URegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TBAlloyFurnaceBlock
extends BlockContainer
{
public static final PropertyDirection FACING = BlockHorizontal.FACING;
public final boolean active;
public TBAlloyFurnaceBlock( final boolean active )
{
super( Material.ROCK );
this.active = active;
this.setCreativeTab( CreativeTabs.DECORATIONS );
this.setResistance( 17.5f );
this.setHardness( 3.5f );
this.setHarvestLevel( "pickaxe" , 0 );
URegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" );
}
// *************************************************************************************************
// TILE ENTITY
// *************************************************************************************************
@Override
public TileEntity createNewTileEntity( final World worldIn , final int meta )
{
return new TBAlloyFurnaceTileEntity( );
}
// *************************************************************************************************
// RENDERING
// *************************************************************************************************
@Override
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube( final IBlockState state )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( final IBlockState stateIn , final World worldIn , final BlockPos pos ,
final Random rand )
{
// XXX stolen from Blocks.FURNACE, will need adjustments (e.g. positions)
if ( this.active ) {
final EnumFacing enumfacing = stateIn.getValue( TBAlloyFurnaceBlock.FACING );
final double d0 = pos.getX( ) + 0.5D;
final double d1 = pos.getY( ) + rand.nextDouble( ) * 6.0D / 16.0D;
final double d2 = pos.getZ( ) + 0.5D;
final double d3 = 0.52D;
final double d4 = rand.nextDouble( ) * 0.6D - 0.3D;
if ( rand.nextDouble( ) < 0.1D ) {
worldIn.playSound( pos.getX( ) + 0.5D , pos.getY( ) , pos.getZ( ) + 0.5D ,
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE , SoundCategory.BLOCKS , 1.0F , 1.0F , false );
}
switch ( enumfacing ) {
case WEST:
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 - d3 , d1 , d2 + d4 , 0.0D , 0.0D ,
0.0D , new int[ 0 ] );
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 - d3 , d1 , d2 + d4 , 0.0D , 0.0D , 0.0D ,
new int[ 0 ] );
break;
case EAST:
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d3 , d1 , d2 + d4 , 0.0D , 0.0D ,
0.0D , new int[ 0 ] );
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d3 , d1 , d2 + d4 , 0.0D , 0.0D , 0.0D ,
new int[ 0 ] );
break;
case NORTH:
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d4 , d1 , d2 - d3 , 0.0D , 0.0D ,
0.0D , new int[ 0 ] );
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d4 , d1 , d2 - d3 , 0.0D , 0.0D , 0.0D ,
new int[ 0 ] );
break;
case SOUTH:
worldIn.spawnParticle( EnumParticleTypes.SMOKE_NORMAL , d0 + d4 , d1 , d2 + d3 , 0.0D , 0.0D ,
0.0D , new int[ 0 ] );
worldIn.spawnParticle( EnumParticleTypes.FLAME , d0 + d4 , d1 , d2 + d3 , 0.0D , 0.0D , 0.0D ,
new int[ 0 ] );
break;
default:
break;
}
}
}
// *************************************************************************************************
// ITEM
// *************************************************************************************************
@Override
@Nullable
public Item getItemDropped( final IBlockState state , final Random rand , final int fortune )
{
return TechBase.ALLOY_FURNACE_ITEM;
}
// *************************************************************************************************
// DIRECTION
// *************************************************************************************************
@Override
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
TBAlloyFurnaceBlock.FACING
} );
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
EnumFacing enumfacing = EnumFacing.getFront( meta );
if ( enumfacing.getAxis( ) == EnumFacing.Axis.Y ) {
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState( ).withProperty( TBAlloyFurnaceBlock.FACING , enumfacing );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return state.getValue( TBAlloyFurnaceBlock.FACING ).getIndex( );
}
@Override
public IBlockState onBlockPlaced( final World worldIn , final BlockPos pos , final EnumFacing facing ,
final float hitX , final float hitY , final float hitZ , final int meta , final EntityLivingBase placer )
{
return this.getDefaultState( ).withProperty( TBAlloyFurnaceBlock.FACING ,
placer.getHorizontalFacing( ).getOpposite( ) );
}
@Override
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
return state.withProperty( TBAlloyFurnaceBlock.FACING ,
rot.rotate( state.getValue( TBAlloyFurnaceBlock.FACING ) ) );
}
@Override
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
return state.withRotation( mirrorIn.toRotation( state.getValue( TBAlloyFurnaceBlock.FACING ) ) );
}
// *************************************************************************************************
// SUPPORT REQUIREMENT
// *************************************************************************************************
@Override
public void neighborChanged( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block blockIn )
{
I_USupportBlock.dropIfUnsupported( state , worldIn , pos , this );
}
@Override
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{
return super.canPlaceBlockAt( worldIn , pos ) && I_USupportBlock.check( worldIn , pos );
}
}

View file

@ -0,0 +1,12 @@
package mmm.tech.base;
import net.minecraft.tileentity.TileEntity;
public class TBAlloyFurnaceTileEntity
extends TileEntity
{
}

View file

@ -0,0 +1,35 @@
package mmm.tech.base;
import mmm.utils.URegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlockSpecial;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class TechBase
{
public static final TBAlloyFurnaceBlock ALLOY_FURNACE_BLOCK_INACTIVE;
public static final TBAlloyFurnaceBlock ALLOY_FURNACE_BLOCK_ACTIVE;
public static final Item ALLOY_FURNACE_ITEM;
static {
ALLOY_FURNACE_BLOCK_INACTIVE = new TBAlloyFurnaceBlock( false );
ALLOY_FURNACE_BLOCK_ACTIVE = new TBAlloyFurnaceBlock( true );
ALLOY_FURNACE_ITEM = new ItemBlockSpecial( TechBase.ALLOY_FURNACE_BLOCK_INACTIVE )//
.setMaxStackSize( 16 )//
.setCreativeTab( ALLOY_FURNACE_BLOCK_INACTIVE.getCreativeTabToDisplayOn( ) );
URegistry.setIdentifiers( ALLOY_FURNACE_ITEM , "tech" , "base" , "alloy_furnace" );
URegistry.addBlock( TechBase.ALLOY_FURNACE_BLOCK_INACTIVE , TechBase.ALLOY_FURNACE_ITEM );
URegistry.addBlock( TechBase.ALLOY_FURNACE_BLOCK_ACTIVE , null );
GameRegistry.registerTileEntity( TBAlloyFurnaceTileEntity.class , "mmm:tech/base/alloy_furnace" );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -6,7 +6,7 @@ import net.minecraft.init.SoundEvents;
public class Tools public class TechTools
{ {
public static final TTToolSet COPPER_TOOLS; public static final TTToolSet COPPER_TOOLS;
public static final TTArmorSet COPPER_ARMOR; public static final TTArmorSet COPPER_ARMOR;