2015-05-23 15:02:29 +02:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
2017-04-12 16:10:13 +02:00
|
|
|
import appeng.core.features.AEFeature;
|
|
|
|
import appeng.core.features.IAEFeature;
|
|
|
|
import appeng.core.features.IFeatureHandler;
|
|
|
|
import appeng.core.features.SlabBlockFeatureHandler;
|
2015-05-23 15:02:29 +02:00
|
|
|
import net.minecraft.block.BlockSlab;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
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;
|
2015-08-06 18:31:46 +02:00
|
|
|
|
2017-04-12 16:10:13 +02:00
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.Random;
|
2015-05-23 15:02:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
public AEBaseSlabBlock( final AEBaseBlock block, final int meta, final EnumSet<AEFeature> features, final boolean isDoubleSlab, final String name )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
|
|
|
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;
|
2015-08-06 18:53:17 +02:00
|
|
|
if( !this.field_150004_a )
|
2015-08-06 18:51:55 +02:00
|
|
|
{
|
2015-08-06 18:49:57 +02:00
|
|
|
this.doubleSlabs = new AEBaseSlabBlock( block, meta, features, true, name + ".double" ).setSlabs( this );
|
2015-08-06 18:51:55 +02:00
|
|
|
}
|
2015-08-06 18:53:17 +02:00
|
|
|
this.features = !this.field_150004_a ? new SlabBlockFeatureHandler( features, this ) : null;
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
|
2015-10-08 15:42:42 +02:00
|
|
|
private AEBaseSlabBlock setSlabs( final AEBaseSlabBlock slabs )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
|
|
|
this.slabs = slabs;
|
|
|
|
return this;
|
|
|
|
}
|
2015-08-06 18:49:57 +02:00
|
|
|
|
2015-05-23 15:02:29 +02:00
|
|
|
public AEBaseSlabBlock slabs()
|
|
|
|
{
|
2015-08-06 18:53:17 +02:00
|
|
|
return this.slabs;
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
2015-08-06 18:49:57 +02:00
|
|
|
|
2015-05-23 15:02:29 +02:00
|
|
|
public AEBaseSlabBlock doubleSlabs()
|
|
|
|
{
|
2015-08-06 18:53:17 +02:00
|
|
|
return this.doubleSlabs;
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IFeatureHandler handler()
|
|
|
|
{
|
|
|
|
return this.features;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void postInit()
|
|
|
|
{
|
|
|
|
// Override to do stuff
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public IIcon getIcon( final int dir, final int meta )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
2015-08-06 18:53:17 +02:00
|
|
|
return this.block.getIcon( dir, this.meta );
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public String func_150002_b( final int p_150002_1_ )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
|
|
|
return this.getUnlocalizedName();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public void registerBlockIcons( final IIconRegister reg )
|
2015-08-06 18:49:57 +02:00
|
|
|
{
|
|
|
|
}
|
2015-05-23 15:02:29 +02:00
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public Item getItemDropped( final int meta, final Random rand, final int fortune )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
2015-08-06 18:49:57 +02:00
|
|
|
return this.field_150004_a ? Item.getItemFromBlock( this.slabs ) : Item.getItemFromBlock( this );
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-25 23:10:56 +02:00
|
|
|
public ItemStack getPickBlock( final MovingObjectPosition target, final World world, final int x, final int y, final int z )
|
2015-05-23 15:02:29 +02:00
|
|
|
{
|
2015-08-06 18:49:57 +02:00
|
|
|
AEBaseSlabBlock block = (AEBaseSlabBlock) world.getBlock( x, y, z );
|
2015-05-23 15:02:29 +02:00
|
|
|
|
2015-08-06 18:49:57 +02:00
|
|
|
if( block == null )
|
2015-08-06 18:51:55 +02:00
|
|
|
{
|
2015-08-06 18:49:57 +02:00
|
|
|
return null;
|
2015-08-06 18:51:55 +02:00
|
|
|
}
|
2015-08-06 18:49:57 +02:00
|
|
|
if( block.field_150004_a )
|
2015-08-06 18:51:55 +02:00
|
|
|
{
|
2015-08-06 18:49:57 +02:00
|
|
|
block = this.slabs;
|
2015-08-06 18:51:55 +02:00
|
|
|
}
|
2015-05-23 15:02:29 +02:00
|
|
|
|
2015-09-25 23:10:56 +02:00
|
|
|
final int meta = world.getBlockMetadata( x, y, z ) & 7;
|
2015-08-06 18:49:57 +02:00
|
|
|
return new ItemStack( block, 1, meta );
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String name()
|
|
|
|
{
|
2015-08-06 18:53:17 +02:00
|
|
|
return this.name;
|
2015-05-23 15:02:29 +02:00
|
|
|
}
|
|
|
|
}
|