use of net.minecraft.block.state.IBlockState in project ImmersiveEngineering by BluSunrize.
the class ItemCoresample method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (!block.isReplaceable(world, pos))
pos = pos.offset(side);
if (stack.stackSize != 0 && player.canPlayerEdit(pos, side, stack) && world.canBlockBePlaced(IEContent.blockStoneDevice, pos, false, side, null, stack)) {
IBlockState toolbox = IEContent.blockStoneDevice.getStateFromMeta(BlockTypes_StoneDevices.CORESAMPLE.getMeta());
if (world.setBlockState(pos, toolbox, 3)) {
IEContent.blockStoneDevice.onIEBlockPlacedBy(world, pos, toolbox, side, hitX, hitY, hitZ, player, stack);
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
} else
return EnumActionResult.FAIL;
}
return super.onItemUse(stack, player, world, pos, hand, side, hitX, hitY, hitZ);
}
use of net.minecraft.block.state.IBlockState in project NetherEx by LogicTechCorp.
the class EntityObsidianBoat method getBoatGlide.
@Override
public float getBoatGlide() {
AxisAlignedBB entityBoundingBox = getEntityBoundingBox();
AxisAlignedBB boundingBox = new AxisAlignedBB(entityBoundingBox.minX, entityBoundingBox.minY - 0.001D, entityBoundingBox.minZ, entityBoundingBox.maxX, entityBoundingBox.minY, entityBoundingBox.maxZ);
int i = MathHelper.floor(boundingBox.minX) - 1;
int j = MathHelper.ceil(boundingBox.maxX) + 1;
int k = MathHelper.floor(boundingBox.minY) - 1;
int l = MathHelper.ceil(boundingBox.maxY) + 1;
int i1 = MathHelper.floor(boundingBox.minZ) - 1;
int j1 = MathHelper.ceil(boundingBox.maxZ) + 1;
List<AxisAlignedBB> list = Lists.newArrayList();
float f = 0.0F;
int k1 = 0;
BlockPos.PooledMutableBlockPos mutableBlockPos = BlockPos.PooledMutableBlockPos.retain();
try {
for (int l1 = i; l1 < j; ++l1) {
for (int i2 = i1; i2 < j1; ++i2) {
int j2 = (l1 != i && l1 != j - 1 ? 0 : 1) + (i2 != i1 && i2 != j1 - 1 ? 0 : 1);
if (j2 != 2) {
for (int k2 = k; k2 < l; ++k2) {
if (j2 <= 0 || k2 != k && k2 != l - 1) {
mutableBlockPos.setPos(l1, k2, i2);
IBlockState state = world.getBlockState(mutableBlockPos);
state.addCollisionBoxToList(world, mutableBlockPos, boundingBox, list, this, false);
if (!list.isEmpty()) {
f += state.getBlock().slipperiness;
++k1;
}
list.clear();
}
}
}
}
}
} finally {
mutableBlockPos.release();
}
return f / (float) k1;
}
use of net.minecraft.block.state.IBlockState in project NetherEx by LogicTechCorp.
the class EventHandler method onCropPreGrow.
@SubscribeEvent
public static void onCropPreGrow(BlockEvent.CropGrowEvent.Pre event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
if (ConfigHandler.block.soulSand.doesNetherwartUseNewGrowthSystem && state.getBlock() == Blocks.NETHER_WART) {
if (world.getBlockState(pos.down()) == NetherExBlocks.BLOCK_SAND_SOUL_TILLED.getDefaultState().withProperty(BlockTilledSoulSand.MOISTURE, 7)) {
event.setResult(Event.Result.ALLOW);
} else {
event.setResult(Event.Result.DENY);
}
}
}
use of net.minecraft.block.state.IBlockState in project NetherEx by LogicTechCorp.
the class EventHandler method onBoneMealUse.
@SubscribeEvent
public static void onBoneMealUse(BonemealEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getBlock();
EntityPlayer player = event.getEntityPlayer();
if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() == NetherExItems.ITEM_DUST_WITHER) {
if (state.getBlock() == Blocks.NETHER_WART) {
int age = state.getValue(BlockNetherWart.AGE);
if (age < 3) {
state = state.withProperty(BlockNetherWart.AGE, age + 1);
world.setBlockState(pos, state);
event.setResult(Event.Result.ALLOW);
}
} else if (state.getBlock() instanceof IGrowable) {
IGrowable growable = (IGrowable) state.getBlock();
if (growable.canGrow(world, pos, state, world.isRemote)) {
growable.grow(world, world.rand, pos, state);
}
} else {
event.setCanceled(true);
}
}
}
use of net.minecraft.block.state.IBlockState in project NetherEx by LogicTechCorp.
the class EventHandler method onBlockBreak.
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
if (!(event.getPlayer() instanceof FakePlayer)) {
EntityPlayer player = event.getPlayer();
if (state.getBlock() == Blocks.MAGMA) {
if (ConfigHandler.block.magma.turnIntoLava) {
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) == 0) {
world.setBlockState(pos, Blocks.LAVA.getDefaultState(), 3);
player.getHeldItemMainhand().damageItem(1, player);
event.setCanceled(true);
}
}
}
if (player.dimension == -1) {
boolean canSpawn = Arrays.asList(ConfigHandler.entity.nethermite.whitelist).contains(state.getBlock().getRegistryName().toString());
if (canSpawn && world.rand.nextInt(ConfigHandler.entity.nethermite.chanceOfSpawning) == 0) {
EntityNethermite nethermite = new EntityNethermite(world);
nethermite.setPosition((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D);
world.spawnEntity(nethermite);
}
}
}
}
Aggregations