use of net.minecraft.block.state.IBlockState in project Overloaded by CJ-MC-Mods.
the class PlayerInteractionUtil method removeBlock.
private static boolean removeBlock(World world, BlockPos pos, EntityPlayer player, boolean canHarvest) {
IBlockState iblockstate = world.getBlockState(pos);
boolean flag = iblockstate.getBlock().removedByPlayer(iblockstate, world, pos, player, canHarvest);
if (flag) {
iblockstate.getBlock().onBlockDestroyedByPlayer(world, pos, iblockstate);
}
return flag;
}
use of net.minecraft.block.state.IBlockState in project AgriCraft by AgriCraft.
the class MethodGetGrowthStage method onMethodCalled.
@Override
protected Object[] onMethodCalled(TileEntityCrop crop) {
IBlockState state = crop.getWorld().getBlockState(crop.getPos());
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
double growthStage = (100.00 * meta) / 7;
return new Object[] { growthStage };
}
use of net.minecraft.block.state.IBlockState in project AgriCraft by AgriCraft.
the class MethodGetCurrentSoil method onMethodCalled.
@Override
protected Object[] onMethodCalled(TileEntityCrop crop) {
IBlockState state = crop.getWorld().getBlockState(crop.getPos().add(0, -1, 0));
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
return new Object[] { (new ItemStack(block, 1, meta)).getDisplayName() };
}
use of net.minecraft.block.state.IBlockState in project AgriCraft by AgriCraft.
the class ItemMagnifyingGlass method onItemUseFirst.
//this is called when you right click with this item in hand
@Override
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (world.isRemote) {
List<String> list = new ArrayList<>();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
TileEntity te = world.getTileEntity(pos);
// Add a separator.
list.add("========== " + AgriCore.getTranslator().translate("item.agricraft:magnifying_glass.name") + " ==========");
// Add lighting information.
list.add("Brightness: (" + world.getLightFromNeighbors(pos.up()) + "/15)");
// Add block information.
if (block instanceof IAgriDisplayable) {
((IAgriDisplayable) block).addDisplayInfo(list::add);
}
// Add tile information.
if (te instanceof IAgriDisplayable) {
((IAgriDisplayable) te).addDisplayInfo(list::add);
}
// Display information.
for (String msg : list) {
player.addChatComponentMessage(new TextComponentString(msg));
}
}
return EnumActionResult.SUCCESS;
}
use of net.minecraft.block.state.IBlockState in project ConvenientAdditions by Necr0.
the class ItemCompost method tryCompostApply.
public boolean tryCompostApply(ItemStack compost, World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
Block b = state.getBlock();
//change to support applying compost on the plant instead of the soil
if (b != null && (b instanceof IPlantable)) {
pos = pos.down();
state = world.getBlockState(pos);
b = state.getBlock();
}
if (!(b == Blocks.DIRT || b == Blocks.FARMLAND || b == Blocks.GRASS || ((b == ModBlocks.compostSoilBlock || b == ModBlocks.compostSoilTilledBlock) && b.getMetaFromState(state) != 0)))
return false;
if (!world.isRemote) {
if (b == Blocks.DIRT)
world.setBlockState(pos, ModBlocks.compostSoilBlock.getDefaultState());
else if (b == Blocks.FARMLAND)
world.setBlockState(pos, ModBlocks.compostSoilTilledBlock.getDefaultState());
else if (b == Blocks.GRASS) {
if (compost.getItemDamage() == 1 && world.rand.nextFloat() < ModConfigMisc.composter_sporesMyceliumChance)
world.setBlockState(pos, Blocks.MYCELIUM.getDefaultState());
else
world.setBlockState(pos, ModBlocks.compostSoilBlock.getDefaultState(), 3);
} else if (b == ModBlocks.compostSoilBlock || b == ModBlocks.compostSoilTilledBlock) {
world.setBlockState(pos, b.getDefaultState(), 3 + 4);
}
compost.shrink(1);
}
world.playSound(null, pos, Blocks.GRASS.getSoundType().getHitSound(), SoundCategory.BLOCKS, Blocks.GRASS.getSoundType().getVolume(), Blocks.GRASS.getSoundType().getPitch());
return true;
}
Aggregations