mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-23 21:49:50 +00:00
Lots of blocks
This commit is contained in:
1 parent
a268149d73
commit
5cc6879ecb
128 files changed
+684
-446
No files matched your search
@@ -18,6 +18,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -32,23 +34,22 @@ public abstract class BlockCamo extends BlockMod {
|
||||
super(par2Material);
|
||||
}
|
||||
|
||||
public static boolean isValidBlock(Block block) {
|
||||
return block.isOpaqueCube(IBlockState state) || block.getRenderType() == 3;
|
||||
public static boolean isValidBlock(IBlockState state) {
|
||||
return state.isOpaqueCube() || state.getRenderType() == EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, BlockPos pos, IBlockState state, EntityPlayer par5EntityPlayer, EnumFacing par6, float par7, float par8, float par9) {
|
||||
public boolean onBlockActivated(World par1World, BlockPos pos, IBlockState state, EntityPlayer par5EntityPlayer, EnumHand hand, ItemStack currentStack, EnumFacing par6, float par7, float par8, float par9) {
|
||||
TileEntity tile = par1World.getTileEntity(pos);
|
||||
|
||||
if(tile instanceof TileCamo) {
|
||||
TileCamo camo = (TileCamo) tile;
|
||||
ItemStack currentStack = par5EntityPlayer.getCurrentEquippedItem();
|
||||
|
||||
if(currentStack == null)
|
||||
currentStack = new ItemStack(Block.getBlockFromName("air"), 1, 0);
|
||||
|
||||
boolean doChange = true;
|
||||
Block block = null;
|
||||
IBlockState testState = null;
|
||||
checkChange : {
|
||||
if(currentStack.getItem() != Item.getItemFromBlock(Block.getBlockFromName("air"))) {
|
||||
if(Item.getIdFromItem(currentStack.getItem()) == 0) {
|
||||
@@ -56,21 +57,21 @@ public abstract class BlockCamo extends BlockMod {
|
||||
break checkChange;
|
||||
}
|
||||
|
||||
block = Block.getBlockFromItem(currentStack.getItem());
|
||||
if(block == null || !isValidBlock(block) || block instanceof BlockCamo || block.getMaterial() == Material.air)
|
||||
testState = Block.getBlockFromItem(currentStack.getItem()).getStateFromMeta(currentStack.getItemDamage());
|
||||
if(testState == null || !isValidBlock(testState) || testState.getBlock() instanceof BlockCamo || testState.getMaterial() == Material.air)
|
||||
doChange = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(doChange && currentStack.getItem() != null) {
|
||||
IBlockState changeState = Block.getBlockFromItem(currentStack.getItem()).getStateFromMeta(currentStack.getItemDamage());
|
||||
if(block instanceof BlockDirectional) {
|
||||
if(testState.getBlock() instanceof BlockDirectional) {
|
||||
if (BlockDirectional.FACING.getAllowedValues().contains(par6.getOpposite())) {
|
||||
changeState = changeState.withProperty(BlockDirectional.FACING, par6.getOpposite());
|
||||
}
|
||||
}
|
||||
camo.camoState = changeState;
|
||||
par1World.markBlockForUpdate(pos);
|
||||
par1World.notifyBlockUpdate(pos, state, state, 8);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user