Java Code Examples for net.minecraft.block.state.IBlockState#getValue()
The following examples show how to use
net.minecraft.block.state.IBlockState#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockSaltPan.java From TofuCraftReload with MIT License | 6 votes |
@Override public void updateTick(World worldIn, BlockPos pos, IBlockState blockState, Random rand) { super.updateTick(worldIn, pos, blockState, rand); Stat stat = blockState.getValue(STATUS); int l = stat.getMeta(); if (stat == Stat.WATER) { float f = this.calcAdaptation(worldIn, pos); if (f > 0.0F && rand.nextInt((int) (25.0F / f) + 1) == 0) { ++l; worldIn.setBlockState(pos, this.getDefaultState().withProperty(STATUS, Stat.byMetadata(l)), 2); } } }
Example 2
Source File: CocoaHandler.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean canHandlePlant(Collection<ItemStack> items, World world, BlockPos pos, IBlockState state) { if (!WorldUtil.isBlockAir(state)) { return false; } boolean found = false; for (EnumFacing dir : EnumFacing.HORIZONTALS) { BlockPos toCheck = pos.offset(dir); IBlockState other = world.getBlockState(toCheck); if (other.getBlock() == Blocks.LOG && other.getValue(BlockOldLog.VARIANT) == EnumType.JUNGLE) { found = true; break; } } return found && items.stream().anyMatch(this::canPlantStack); }
Example 3
Source File: MetaItem1.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean onEntityItemUpdate(EntityItem itemEntity) { int damage = itemEntity.getItem().getMetadata(); if (damage >= this.metaItemOffset || itemEntity.getEntityWorld().isRemote) return false; Material material = Material.MATERIAL_REGISTRY.getObjectById(damage % 1000); OrePrefix prefix = this.orePrefixes[(damage / 1000)]; if (!purifyMap.containsKey(prefix)) return false; BlockPos blockPos = new BlockPos(itemEntity); IBlockState blockState = itemEntity.getEntityWorld().getBlockState(blockPos); int waterLevel = blockState.getBlock() instanceof BlockCauldron ? blockState.getValue(BlockCauldron.LEVEL) : 0; if (waterLevel == 0) return false; itemEntity.getEntityWorld().setBlockState(blockPos, blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1)); ItemStack replacementStack = OreDictUnifier.get(purifyMap.get(prefix), material, itemEntity.getItem().getCount()); itemEntity.setItem(replacementStack); return false; }
Example 4
Source File: MinecraftTypeHelper.java From malmo with MIT License | 6 votes |
/** Recolour the Minecraft block * @param state The block to be recoloured * @param colour The new colour * @return A new blockstate which is a recoloured version of the original */ static IBlockState applyColour(IBlockState state, Colour colour) { for (IProperty prop : state.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { net.minecraft.item.EnumDyeColor current = (net.minecraft.item.EnumDyeColor)state.getValue(prop); if (!current.getName().equalsIgnoreCase(colour.name())) { return state.withProperty(prop, EnumDyeColor.valueOf(colour.name())); } } } return state; }
Example 5
Source File: TileEntityShipHelm.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@Override void processControlMessage(PilotControlsMessage message, EntityPlayerMP sender) { double rotationDelta = 0; if (message.airshipLeft_KeyDown) { rotationDelta -= 12.5D; } if (message.airshipRight_KeyDown) { rotationDelta += 12.5D; } IBlockState blockState = this.getWorld().getBlockState(getPos()); if (blockState.getBlock() instanceof BlockShipHelm) { EnumFacing facing = blockState.getValue(BlockShipHelm.FACING); if (this.isPlayerInFront(sender, facing)) { wheelRotation += rotationDelta; } else { wheelRotation -= rotationDelta; } } double max_rotation = 720D; wheelRotation = Math.min(Math.max(wheelRotation, -max_rotation), max_rotation); }
Example 6
Source File: BlockBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override @Deprecated public float getBlockHardness(IBlockState state, World world, BlockPos pos) { if (state.getValue(CREATIVE)) { return -1f; } TileEntityBarrel te = getTileEntitySafely(world, pos, TileEntityBarrel.class); if (te != null && te.retainsContentsWhenBroken() == false && te.isOverSpillCapacity()) { return -1f; } return super.getBlockHardness(state, world, pos); }
Example 7
Source File: BlockPitKiln.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 1. Content *******************************************************************************/ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!world.isRemote && hand == EnumHand.MAIN_HAND) { int fill = state.getValue(FILL); if(player.getHeldItem(hand).getItem() == TFCItems.Straw) { if((state.getValue(FILLTYPE) == FillType.Straw && fill < 4) || fill == 0) { world.setBlockState(pos, state.withProperty(FILL, fill+1).withProperty(FILLTYPE, FillType.Straw)); player.getHeldItem(hand).shrink(1); return true; } } else if(player.getHeldItem(hand).isEmpty()) { if(state.getValue(FILLTYPE) == FillType.Straw && fill > 0) { Core.giveItem(world, player, pos, new ItemStack(TFCItems.Straw)); world.setBlockState(pos, state.withProperty(FILL, fill-1)); return true; } else if(fill == 0) { TilePitKiln te = (TilePitKiln) world.getTileEntity(pos); Core.giveItem(world, player, pos, te.getStackInSlot(0)); te.setInventorySlotContents(0, ItemStack.EMPTY); world.setBlockToAir(pos); } } } return false; }
Example 8
Source File: Frame.java From EmergingTechnology with MIT License | 5 votes |
private AxisAlignedBB getBox(IBlockState state) { switch (state.getValue(PROPERTYFACING)) { case EAST: return EAST_AABB; case WEST: return WEST_AABB; case SOUTH: return SOUTH_AABB; case NORTH: return NORTH_AABB; default: return FULL_BLOCK_AABB; } }
Example 9
Source File: BlockCloud.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public int getLightValue(@Nonnull IBlockState state, IBlockAccess world, @Nonnull BlockPos pos) { return state.getValue(HAS_LIGHT_VALUE) ? 15 : 0; }
Example 10
Source File: Collector.java From EmergingTechnology with MIT License | 4 votes |
@Override public int getMetaFromState(IBlockState state) { int meta = state.getValue(HAS_ITEMS) ? 8 : 0; return meta; }
Example 11
Source File: BlockPitKiln.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { int fill = state.getValue(FILL); return new AxisAlignedBB(0,0,0,1,0.25*fill,1); }
Example 12
Source File: BlockFuton.java From Sakura_mod with MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } if (state.getValue(PART) != EnumPartType.HEAD) { pos = pos.offset(state.getValue(FACING)); state = worldIn.getBlockState(pos); if (state.getBlock() != this) { return true; } } if (worldIn.provider.canRespawnHere() && worldIn.getBiome(pos) != Biomes.HELL) { if (state.getValue(OCCUPIED).booleanValue()) { EntityPlayer entityplayer = this.getPlayerInBlanket(worldIn, pos); if (entityplayer != null) { playerIn.sendMessage(new TextComponentTranslation("tile.bed.occupied")); return true; } state = state.withProperty(OCCUPIED, Boolean.valueOf(false)); worldIn.setBlockState(pos, state, 4); } EntityPlayer.SleepResult entityplayer$sleepresult = playerIn.trySleep(pos); if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK) { state = state.withProperty(OCCUPIED, Boolean.valueOf(true)); worldIn.setBlockState(pos, state, 4); return true; } if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_POSSIBLE_NOW) { playerIn.sendMessage(new TextComponentTranslation("tile.bed.noSleep")); } else if (entityplayer$sleepresult == EntityPlayer.SleepResult.NOT_SAFE) { playerIn.sendMessage(new TextComponentTranslation("tile.bed.notSafe")); } return true; } worldIn.setBlockToAir(pos); BlockPos blockpos = pos.offset(state.getValue(FACING).getOpposite()); if (worldIn.getBlockState(blockpos).getBlock() == this) { worldIn.setBlockToAir(blockpos); } worldIn.newExplosion(null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 5.0F, true, true); return true; }
Example 13
Source File: RotationAxleTileEntityRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public void render(TileEntityRotationAxle tileentity, double x, double y, double z, float partialTick, int destroyStage, float alpha) { this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.translate(x, y, z); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); int brightness = tileentity.getWorld().getCombinedLight(tileentity.getPos(), 0); IBlockState gearState = Minecraft.getMinecraft().world.getBlockState(tileentity.getPos()); if (gearState.getBlock() instanceof BlockRotationAxle) { EnumFacing.Axis facingAxis = gearState.getValue(BlockRotationAxle.AXIS); GlStateManager.translate(0.5, 0.5, 0.5); switch (facingAxis) { case X: // Rotates (1, 0, 0) -> (1, 0, 0) break; case Y: // Rotates (1, 0, 0) -> (0, 1, 0) GL11.glRotated(90, 0, 0, 1); break; case Z: // Rotates (1, 0, 0) -> (0, 0, 1) GL11.glRotated(-90, 0, 1, 0); break; } GL11.glRotated(Math.toDegrees(tileentity.getRenderRotationRadians(partialTick)), 1, 0, 0); GlStateManager.translate(-0.5, -0.5, -0.5); } double keyframe = 1; GibsAnimationRegistry.getAnimation("rotation_axle") .renderAnimation(keyframe, brightness); GlStateManager.popMatrix(); GlStateManager.enableLighting(); GlStateManager.resetColor(); }
Example 14
Source File: BlockWoodSupport.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); state = getActualState(state, world, pos); if(world.isRemote || !(Boolean)state.getValue(SPAN)) return; //Here we do our checks to make sure that this beam is not too long. int range = getNaturalSupportRange(world, pos, state); boolean foundColumn = false; IBlockState otherState; if(!foundColumn && (Boolean)state.getValue(NORTH_CONNECTION)) { for(int i = 1; i <= range; i++) { otherState = world.getBlockState(pos.north(i)); if(otherState.getBlock() instanceof BlockWoodSupport) { otherState = otherState.getBlock().getActualState(otherState, world, pos.north(i)); if(!(Boolean)otherState.getValue(SPAN)) {foundColumn = true; break;} } } } if(!foundColumn && (Boolean)state.getValue(SOUTH_CONNECTION)) { for(int i = 1; i <= range; i++) { otherState = world.getBlockState(pos.south(i)); if(otherState.getBlock() instanceof BlockWoodSupport) { otherState = otherState.getBlock().getActualState(otherState, world, pos.south(i)); if(!(Boolean)otherState.getValue(SPAN)) {foundColumn = true; break;} } } } if(!foundColumn && (Boolean)state.getValue(EAST_CONNECTION)) { for(int i = 1; i <= range; i++) { otherState = world.getBlockState(pos.east(i)); if(otherState.getBlock() instanceof BlockWoodSupport) { otherState = otherState.getBlock().getActualState(otherState, world, pos.east(i)); if(!(Boolean)otherState.getValue(SPAN)) {foundColumn = true; break;} } } } if(!foundColumn && (Boolean)state.getValue(WEST_CONNECTION)) { for(int i = 1; i <= range; i++) { otherState = world.getBlockState(pos.west(i)); if(otherState.getBlock() instanceof BlockWoodSupport) { otherState = otherState.getBlock().getActualState(otherState, world, pos.west(i)); if(!(Boolean)otherState.getValue(SPAN)) {foundColumn = true; break;} } } } if(!foundColumn) { world.setBlockToAir(pos); int meta = this.getMetaFromState(state); Core.dropItem(world, pos, new ItemStack(this.getItemDropped(state, world.rand, 0), 1, convertMetaToItem(meta))); } }
Example 15
Source File: BlockRotationAxle.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Nullable @Override public TileEntity createNewTileEntity(World worldIn, int meta) { IBlockState state = getStateFromMeta(meta); return new TileEntityRotationAxle(state.getValue(AXIS)); }
Example 16
Source File: ItemSnow.java From customstuff4 with GNU General Public License v3.0 | 4 votes |
@Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack)) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); BlockPos blockpos = pos; if ((facing != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos)) { blockpos = pos.offset(facing); iblockstate = worldIn.getBlockState(blockpos); block = iblockstate.getBlock(); } if (block == this.block) { int i = iblockstate.getValue(BlockSnow.LAYERS); if (i < 8) { IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, i + 1); AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, blockpos); if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(blockpos)) && worldIn.setBlockState(blockpos, iblockstate1, 10)) { SoundType soundtype = this.block.getSoundType(iblockstate1, worldIn, pos, player); worldIn.playSound(player, blockpos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); if (player instanceof EntityPlayerMP) { CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP)player, pos, itemstack); } itemstack.shrink(1); return EnumActionResult.SUCCESS; } } } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } else { return EnumActionResult.FAIL; } }
Example 17
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean causesSuffocation(IBlockState state) { return state.getValue(OPAQUE); }
Example 18
Source File: RedstoneUtil.java From Minecoprocessors with GNU General Public License v3.0 | 4 votes |
public static boolean isFrontPort(IBlockState blockState, EnumFacing side) { return blockState.getValue(BlockHorizontal.FACING) == side; }
Example 19
Source File: BlockSuperchest.java From YouTubeModdingTutorial with MIT License | 4 votes |
public static boolean isFormedSuperchestController(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); return state.getBlock() == ModBlocks.blockSuperchest && state.getValue(FORMED) != SuperchestPartIndex.UNFORMED; }
Example 20
Source File: BlockFireboxCasing.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public int getMetaFromState(IBlockState state) { return super.getMetaFromState(state) + (state.getValue(ACTIVE) ? 8 : 0); }