Java Code Examples for net.minecraft.block.state.IBlockState#getMaterial()
The following examples show how to use
net.minecraft.block.state.IBlockState#getMaterial() .
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: EntityDabSquirrel.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void fall(float distance, float damageMultiplier) { if (distance > 1.0F) { this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F); } int i = MathHelper.ceil((distance * 0.5F - 3.0F) * damageMultiplier); if (i > 0) { this.attackEntityFrom(DamageSource.FALL, i); if (this.isBeingRidden()) { for (Entity entity : this.getRecursivePassengers()) { entity.attackEntityFrom(DamageSource.FALL, i); } } BlockPos pos = new BlockPos(this.posX, this.posY - 0.2D - this.prevRotationYaw, this.posZ); IBlockState iblockstate = this.world.getBlockState(pos); Block block = iblockstate.getBlock(); if (iblockstate.getMaterial() != Material.AIR && !this.isSilent()) { SoundType soundtype = block.getSoundType(block.getDefaultState(), this.world, pos, this); this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, soundtype.getStepSound(), this.getSoundCategory(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); } } }
Example 2
Source File: ToolSword.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && tool.equals("sword")) || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.GOURD || block.getMaterial() == Material.VINE || block.getMaterial() == Material.WEB || block.getMaterial() == Material.CLOTH || block.getMaterial() == Material.CARPET || block.getMaterial() == Material.PLANTS || block.getMaterial() == Material.CACTUS || block.getMaterial() == Material.CAKE || block.getMaterial() == Material.TNT || block.getMaterial() == Material.SPONGE; }
Example 3
Source File: ItemEnderSword.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public float getDestroySpeed(ItemStack stack, IBlockState state) { if (this.isToolBroken(stack)) { return 0.2f; } if (state.getBlock() == Blocks.WEB) { return 15.0f; } Material material = state.getMaterial(); if (material == Material.PLANTS || material == Material.VINE || material == Material.CORAL || material == Material.LEAVES || material == Material.GOURD) { return 1.5f; } return 1.0f; }
Example 4
Source File: ToolSense.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { return block.getMaterial() == Material.PLANTS || block.getMaterial() == Material.LEAVES || block.getMaterial() == Material.VINE || block.getBlock() instanceof BlockCrops; }
Example 5
Source File: MixinRenderGlobal.java From Valkyrien-Skies with Apache License 2.0 | 5 votes |
private void drawSelectionBoxOriginal(EntityPlayer player, RayTraceResult movingObjectPositionIn, int execute, float partialTicks) { if (execute == 0 && movingObjectPositionIn.typeOfHit == RayTraceResult.Type.BLOCK) { GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.glLineWidth(2.0F); GlStateManager.disableTexture2D(); GlStateManager.depthMask(false); BlockPos blockpos = movingObjectPositionIn.getBlockPos(); IBlockState iblockstate = this.world.getBlockState(blockpos); if (iblockstate.getMaterial() != Material.AIR && this.world.getWorldBorder() .contains(blockpos)) { double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; drawSelectionBoundingBox(iblockstate.getSelectedBoundingBox(this.world, blockpos) .grow(0.0020000000949949026D).offset(-d0, -d1, -d2), 0.0F, 0.0F, 0.0F, 0.4F); } GlStateManager.depthMask(true); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } }
Example 6
Source File: ToolPickaxe.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && tool.equals("pickaxe")) || block.getMaterial() == Material.ROCK || block.getMaterial() == Material.IRON || block.getMaterial() == Material.ANVIL || block.getMaterial() == Material.GLASS; }
Example 7
Source File: ToolRenderHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void drawBlockDamageTexture(Minecraft mc, Tessellator tessellator, Entity viewEntity, float partialTicks, List<BlockPos> blocksToRender, int partialBlockDamage) { double d3 = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks; double d4 = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks; double d5 = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks; BufferBuilder bufferBuilder = tessellator.getBuffer(); BlockRendererDispatcher rendererDispatcher = mc.getBlockRendererDispatcher(); mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); preRenderDamagedBlocks(); bufferBuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); bufferBuilder.setTranslation(-d3, -d4, -d5); bufferBuilder.noColor(); for (BlockPos blockPos : blocksToRender) { IBlockState blockState = mc.world.getBlockState(blockPos); TileEntity tileEntity = mc.world.getTileEntity(blockPos); boolean hasBreak = tileEntity != null && tileEntity.canRenderBreaking(); if (!hasBreak && blockState.getMaterial() != Material.AIR) { TextureAtlasSprite textureAtlasSprite = this.destroyBlockIcons[partialBlockDamage]; rendererDispatcher.renderBlockDamage(blockState, blockPos, textureAtlasSprite, mc.world); } } tessellator.draw(); bufferBuilder.setTranslation(0.0D, 0.0D, 0.0D); postRenderDamagedBlocks(); }
Example 8
Source File: BlockWaterHyacinth.java From Production-Line with MIT License | 5 votes |
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); Material material = iblockstate.getMaterial(); return material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL) == 0 || material == Material.ICE; } else { return false; } }
Example 9
Source File: EntityAIHarvestTofuFarmland.java From TofuCraftReload with MIT License | 4 votes |
/** * Keep ticking a continuous task that has already been started */ public void updateTask() { super.updateTask(); this.villager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.villager.getVerticalFaceSpeed()); if (this.getIsAboveDestination()) { World world = this.villager.world; BlockPos blockpos = this.destinationBlock.up(); IBlockState iblockstate = world.getBlockState(blockpos); Block block = iblockstate.getBlock(); if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate)) { world.destroyBlock(blockpos, true); } else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR) { InventoryBasic inventorybasic = this.villager.getVillagerInventory(); for (int i = 0; i < inventorybasic.getSizeInventory(); ++i) { ItemStack itemstack = inventorybasic.getStackInSlot(i); boolean flag = false; if (!itemstack.isEmpty()) { if (itemstack.getItem() == Items.WHEAT_SEEDS) { world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3); flag = true; } else if (itemstack.getItem() == Items.POTATO) { world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3); flag = true; } else if (itemstack.getItem() == Items.CARROT) { world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3); flag = true; } else if (itemstack.getItem() == Items.BEETROOT_SEEDS) { world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3); flag = true; } else if (itemstack.getItem() instanceof net.minecraftforge.common.IPlantable) { if(((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlantType(world,blockpos) == net.minecraftforge.common.EnumPlantType.Crop) { world.setBlockState(blockpos, ((net.minecraftforge.common.IPlantable)itemstack.getItem()).getPlant(world,blockpos),3); flag = true; } } } if (flag) { itemstack.shrink(1); if (itemstack.isEmpty()) { inventorybasic.setInventorySlotContents(i, ItemStack.EMPTY); } break; } } } this.currentTask = -1; this.runDelay = 10; } }
Example 10
Source File: WorldGenApricotTrees.java From TofuCraftReload with MIT License | 4 votes |
public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + 4; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < worldIn.getHeight()) { if (!this.isReplaceable(worldIn, blockpos$mutableblockpos.setPos(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { IBlockState state = worldIn.getBlockState(position.down()); if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, BlockLoader.APRICOT_SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { state.getBlock().onPlantGrow(state, worldIn, position.down(), position); for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { int i4 = i3 - (position.getY() + i); int j1 = 1 - i4 / 2; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { int l1 = k1 - position.getX(); for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { int j2 = i2 - position.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { BlockPos blockpos = new BlockPos(k1, i3, i2); state = worldIn.getBlockState(blockpos); if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, blockpos, BlockLoader.APRICOT_LEAVE.getDefaultState()); } } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); state = worldIn.getBlockState(upN); if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), Blocks.LOG.getDefaultState()); } } return true; } else { return false; } } } else { return false; } }
Example 11
Source File: ToolAxe.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { String tool = block.getBlock().getHarvestTool(block); return (tool != null && tool.equals("axe")) || block.getMaterial() == Material.WOOD; }
Example 12
Source File: EntityOwl.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
private boolean isOnLeaves() { IBlockState bs = world.getBlockState(getPosition().down()); return bs.getMaterial() == Material.LEAVES; }
Example 13
Source File: ChunkProviderCavePlanet.java From AdvancedRocketry with MIT License | 4 votes |
public void buildSurfaces(int p_185937_1_, int p_185937_2_, ChunkPrimer primer) { if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, primer, this.world)) return; int i = this.world.getSeaLevel() + 1; double d0 = 0.03125D; this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.03125D, 0.03125D, 1.0D); this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_185937_1_ * 16, 109, p_185937_2_ * 16, 16, 1, 16, 0.03125D, 1.0D, 0.03125D); this.depthBuffer = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.depthBuffer, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, 0.0625D, 0.0625D, 0.0625D); for (int j = 0; j < 16; ++j) { for (int k = 0; k < 16; ++k) { boolean flag = this.slowsandNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; boolean flag1 = this.gravelNoise[j + k * 16] + this.rand.nextDouble() * 0.2D > 0.0D; int l = (int)(this.depthBuffer[j + k * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D); int i1 = -1; IBlockState iblockstate = this.fillblock; IBlockState iblockstate1 = this.fillblock; for (int j1 = 127; j1 >= 0; --j1) { IBlockState iblockstate2 = primer.getBlockState(k, j1, j); if (iblockstate2.getBlock() != null && iblockstate2.getMaterial() != Material.AIR) { if (iblockstate2 == fillblock) { if (i1 == -1) { if (l <= 0) { iblockstate = AIR; iblockstate1 = this.fillblock; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.fillblock; iblockstate1 = this.fillblock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { iblockstate = oceanBlock; } i1 = l; if (j1 >= i - 1) { primer.setBlockState(k, j1, j, iblockstate); } else { primer.setBlockState(k, j1, j, iblockstate1); } } else if (i1 > 0) { --i1; primer.setBlockState(k, j1, j, iblockstate1); } } } else { i1 = -1; } } } } }
Example 14
Source File: BlockRiceCrop.java From Sakura_mod with MIT License | 4 votes |
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { return state.getMaterial() == Material.WATER; }
Example 15
Source File: ItemBasicLaserGun.java From AdvancedRocketry with MIT License | 4 votes |
public boolean canHarvestBlock(IBlockState blockIn) { Block block = blockIn.getBlock(); if (block == Blocks.OBSIDIAN) { return this.toolMaterial.getHarvestLevel() == 3; } else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE) { if (block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK) { if (block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE) { if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE) { if (block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE) { if (block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE) { Material material = blockIn.getMaterial(); return material == Material.ROCK ? true : (material == Material.IRON ? true : material == Material.ANVIL); } else { return this.toolMaterial.getHarvestLevel() >= 2; } } else { return this.toolMaterial.getHarvestLevel() >= 1; } } else { return this.toolMaterial.getHarvestLevel() >= 1; } } else { return this.toolMaterial.getHarvestLevel() >= 2; } } else { return this.toolMaterial.getHarvestLevel() >= 2; } } else { return this.toolMaterial.getHarvestLevel() >= 2; } }
Example 16
Source File: BlockRice.java From TofuCraftReload with MIT License | 4 votes |
@Override protected boolean canSustainBush(IBlockState state) { return state.getMaterial() == Material.WATER; }
Example 17
Source File: BlockRice.java From TofuCraftReload with MIT License | 4 votes |
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { return state.getMaterial() == Material.WATER; }
Example 18
Source File: BiomeCanyon.java From Traverse-Legacy-1-12-2 with MIT License | 4 votes |
@Override public void genTerrainBlocks(World worldIn, Random rand, ChunkPrimer chunkPrimerIn, int x, int z, double noiseVal) { int i = worldIn.getSeaLevel(); IBlockState iblockstate = this.topBlock; IBlockState iblockstate1 = this.fillerBlock; int j = -1; int k = (int) (noiseVal / 3.0D + 3.0D + rand.nextDouble() * 0.25D); int l = x & 15; int i1 = z & 15; BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int j1 = 255; j1 >= 0; --j1) { if (j1 <= rand.nextInt(5)) { chunkPrimerIn.setBlockState(i1, j1, l, BEDROCK); } else { IBlockState iblockstate2 = chunkPrimerIn.getBlockState(i1, j1, l); if (iblockstate2.getMaterial() == Material.AIR) { j = -1; } else if (iblockstate2.getBlock() == Blocks.STONE) { if (j == -1) { if (k <= 0) { iblockstate = AIR; iblockstate1 = STONE; } else if (j1 >= i - 4 && j1 <= i + 1) { iblockstate = this.topBlock; iblockstate1 = this.fillerBlock; } if (j1 < i && (iblockstate == null || iblockstate.getMaterial() == Material.AIR)) { if (this.getTemperature(blockpos$mutableblockpos.setPos(x, j1, z)) < 0.15F) { iblockstate = ICE; } else { iblockstate = WATER; } } j = k; if (j1 >= i - 1) { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate); } else if (j1 < i - 7 - k) { iblockstate = AIR; iblockstate1 = STONE; chunkPrimerIn.setBlockState(i1, j1, l, GRAVEL); } else { chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); } } else if (j > 0) { --j; chunkPrimerIn.setBlockState(i1, j1, l, iblockstate1); if (j == 0 && iblockstate1.getBlock() == Blocks.SAND && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = iblockstate1.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? RED_SANDSTONE : SANDSTONE; } if (j == 0 && iblockstate == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate = redRock; } if (j == 0 && iblockstate1 == redRock && k > 1) { j = rand.nextInt(4) + Math.max(0, j1 - 63); iblockstate1 = redRock; } } } } } }
Example 19
Source File: ToolBranchCutter.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean canMineBlock(IBlockState block, ItemStack stack) { return block.getMaterial() == Material.LEAVES; }
Example 20
Source File: ItemEnderTool.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public float getDestroySpeed(ItemStack stack, IBlockState state) { if (this.isToolBroken(stack)) { return 0.2f; } ToolType tool = ToolType.fromStack(stack); if (this.isCreativeLikeBreakingEnabled(stack) && this.canHarvestBlock(state, stack)) { return 1600f; } // Allow instant mine of leaves with the axe if (state.getMaterial() == Material.LEAVES && tool.equals(ToolType.AXE)) { // This seems to be enough to instant mine leaves even when jumping/flying return 100.0f; } float eff = this.efficiencyOnProperMaterial; // 34 is the minimum to allow instant mining with just Efficiency V (= no beacon/haste) on cobble, // 124 is the minimum for iron blocks @ hardness 5.0f (which is about the highest of "normal" blocks), 1474 on obsidian. // So maybe around 160 might be ok? I don't want insta-mining on obsidian, but all other types of "rock". if (PowerStatus.fromStack(stack) == PowerStatus.POWERED) { if (EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation("efficiency"), stack) >= 5) { eff = 124.0f; } // This is enough to give instant mining for sandstone and netherrack without any Efficiency enchants. else { eff = 24.0f; } } //if (ForgeHooks.isToolEffective(stack, block, meta)) if (state.getBlock().isToolEffective(tool.getToolClass(), state)) { //System.out.println("getStrVsBlock(); isToolEffective() true: " + eff); return eff; } if (this.canHarvestBlock(state, stack)) { //System.out.println("getStrVsBlock(); canHarvestBlock() true: " + eff); return eff; } //System.out.println("getStrVsBlock(); not effective: " + super.getStrVsBlock(stack, block, meta)); return super.getDestroySpeed(stack, state); }