2016-05-14 19:53:07 +02:00
|
|
|
package techreborn.blocks;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-05-15 10:53:38 +02:00
|
|
|
import net.minecraft.util.EnumBlockRenderType;
|
2016-05-14 19:53:07 +02:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import reborncore.common.util.ItemNBTHelper;
|
|
|
|
import techreborn.client.TechRebornCreativeTab;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by mark on 14/05/16.
|
|
|
|
*/
|
|
|
|
public class BlockDistributor extends Block {
|
|
|
|
|
|
|
|
AxisAlignedBB AABB = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.0625D, 0.9375D);
|
|
|
|
|
|
|
|
public BlockDistributor( ) {
|
|
|
|
super(Material.IRON);
|
|
|
|
setHardness(2f);
|
|
|
|
setUnlocalizedName("techreborn.distributor");
|
|
|
|
setCreativeTab(TechRebornCreativeTab.instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ItemStack getReleaseStack(){
|
|
|
|
ItemStack newStack = new ItemStack(Items.SHIELD);
|
2016-05-15 10:53:38 +02:00
|
|
|
ItemNBTHelper.setString(newStack, "type", "btm");
|
2016-05-14 19:53:07 +02:00
|
|
|
ItemNBTHelper.setBoolean(newStack, "vanilla", false);
|
|
|
|
return newStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
|
|
|
return NULL_AABB;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
|
|
|
return AABB;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOpaqueCube(IBlockState state)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isFullCube(IBlockState state)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
2016-05-14 20:26:04 +02:00
|
|
|
if(!entityIn.worldObj.isRemote){
|
|
|
|
if(entityIn instanceof EntityPlayer){
|
|
|
|
EntityPlayer player = (EntityPlayer) entityIn;
|
|
|
|
if(player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() == Items.SHIELD){
|
2016-05-15 10:53:38 +02:00
|
|
|
if(ItemNBTHelper.getString(player.getHeldItemOffhand(), "type", "null").equals("btm")){
|
2016-05-14 20:26:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-05-14 19:53:07 +02:00
|
|
|
player.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, getReleaseStack());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-15 10:53:38 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumBlockRenderType getRenderType(IBlockState state) {
|
|
|
|
return EnumBlockRenderType.INVISIBLE;
|
|
|
|
}
|
2016-05-14 19:53:07 +02:00
|
|
|
}
|