public boolean generate(World worldIn, Random rand, BlockPos position) { for (; position.getY() < 128; position = position.up()) { if (worldIn.isAirBlock(position)) { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings()) { if (Blocks.vine.canPlaceBlockOnSide(worldIn, position, enumfacing)) { IBlockState iblockstate = Blocks.vine.getDefaultState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == EnumFacing.WEST)); worldIn.setBlockState(position, iblockstate, 2); break; } } } else { position = position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4)); } } return true; }
public boolean generate(World worldIn, Random rand, BlockPos position) { for (; position.getY() < 128; position = position.up()) { if (worldIn.isAirBlock(position)) { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings()) { if (Blocks.VINE.canPlaceBlockOnSide(worldIn, position, enumfacing)) { IBlockState iblockstate = Blocks.VINE.getDefaultState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == EnumFacing.WEST)); worldIn.setBlockState(position, iblockstate, 2); break; } } } else { position = position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4)); } } return true; }
private void init () { registerCompostMaterial(new ItemStack(Blocks.melon_block), defaultMaterial); registerCompostMaterial(new ItemStack(Blocks.pumpkin), defaultMaterial); registerCompostMaterial(new ItemStack(Blocks.hay_block), defaultMaterial); registerCompostMaterial(new ItemStack(Items.string), new StandardCompostMaterial(100, 0.0625f)); registerCompostMaterial(new ItemStack(Items.wheat), new StandardCompostMaterial(100, 0.125f)); registerCompostMaterial(new ItemStack(Items.reeds), new StandardCompostMaterial(150, 0.125f)); registerCompostMaterial(new ItemStack(Items.feather), new StandardCompostMaterial(50, 0.0625f)); registerCompostMaterial(new ItemStack(Items.rotten_flesh), new StandardCompostMaterial(150, 0.125f)); registerCompostMaterial(new ItemStack(Items.leather), new StandardCompostMaterial(150, 0.125f)); registerCompostMaterial("treeWood", new StandardCompostMaterial(300, 0.25f)); registerCompostMaterial("logWood", new StandardCompostMaterial(300, 0.25f)); registerCompostMaterial("treeLeaves", defaultMaterial); registerCompostMaterial("treeSapling", defaultMaterial); registerCompostMaterial("stickWood", defaultMaterial); registerCompostMaterial(IPlantable.class, defaultMaterial); registerCompostMaterial(IGrowable.class, defaultMaterial); registerCompostMaterial(BlockLeavesBase.class, defaultMaterial); registerCompostMaterial(BlockVine.class, defaultMaterial); registerCompostMaterial(ItemFood.class, defaultMaterial); }
public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockRailDetector || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.field_150444_as || block == Blocks.field_150472_an || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator || block instanceof BlockTrapDoor || block instanceof BlockHugeMushroom || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }
@SuppressWarnings("unused") private int getLadderHeight(Entity e, int offset) { int ladders = 0; for(int i = (int) e.posY; i < 256; i++){ Block var1 = mc.theWorld.getBlockState(new BlockPos(e.posX, i + offset, e.posZ)).getBlock(); if(var1 instanceof BlockAir){ break; }else if(var1 instanceof BlockLadder || var1 instanceof BlockVine){ ladders++; } return ladders; } return -1; }
public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockRailDetector || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign || block == Blocks.standing_sign || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator || block instanceof BlockTrapDoor || block instanceof BlockHugeMushroom || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }
private int placeVinesAt(World world,BlockPos p) { boolean n=false,e=false,s=false,w=false,canDo=false; if(world.getBlockState(p.north()).getMaterial().blocksMovement()){ n = true; canDo = true; } if(world.getBlockState(p.east()).getMaterial().blocksMovement()){ e = true; canDo = true; } if(world.getBlockState(p.south()).getMaterial().blocksMovement()){ s = true; canDo = true; } if(world.getBlockState(p.west()).getMaterial().blocksMovement()){ w = true; canDo = true; } if(canDo){ world.setBlockState(p, Blocks.VINE.getDefaultState() .withProperty(BlockVine.UP, false) .withProperty(BlockVine.NORTH, n) .withProperty(BlockVine.EAST, e) .withProperty(BlockVine.SOUTH, s) .withProperty(BlockVine.WEST, w)); return 1; }else{ return 0; } }
public static MetaBlock setOrientation(MetaBlock vine, Cardinal dir){ vine.withProperty(BlockVine.NORTH, Boolean.valueOf(dir == Cardinal.NORTH)); vine.withProperty(BlockVine.EAST, Boolean.valueOf(dir == Cardinal.EAST)); vine.withProperty(BlockVine.SOUTH, Boolean.valueOf(dir == Cardinal.SOUTH)); vine.withProperty(BlockVine.WEST, Boolean.valueOf(dir == Cardinal.WEST)); return vine; }
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntityMemorial te = (TileEntityMemorial) world.getTileEntity(pos); if (te != null) { ItemStack item = player.inventory.getCurrentItem(); if (item != null) { if (te.isMossy()) { if (item.getItem() instanceof ItemShears) { if (!world.isRemote) { GraveInventory.dropItem(new ItemStack(Blocks.VINE, 1), world, pos); } te.setMossy(false); return false; } } else { if (net.minecraft.block.Block.getBlockFromItem(item.getItem()) instanceof BlockVine) { te.setMossy(true); player.inventory.getCurrentItem().setCount(player.inventory.getCurrentItem().getCount() - 1); return true; } } } if (world.isRemote) { String name; String killerName; String deathText = te.getDeathTextComponent().getDeathText(); if (deathText.length() != 0) { if (te.getDeathTextComponent().isLocalized()) { name = ModGravestoneExtended.proxy.getLocalizedEntityName(te.getDeathTextComponent().getName()); if (name.length() != 0) { killerName = ModGravestoneExtended.proxy.getLocalizedEntityName(te.getDeathTextComponent().getKillerName()); if (killerName.length() == 0) { player.sendMessage(new TextComponentTranslation(deathText, new Object[]{name})); } else { player.sendMessage(new TextComponentTranslation(deathText, new Object[]{name, killerName})); } return false; } } player.sendMessage(new TextComponentTranslation(deathText)); } } } return false; }
public ItemStack getResultItem(List<ItemStack> requiredItems) { boolean isEnchanted = requiredItems.stream().anyMatch((item) -> item != null && item.getItem() instanceof ItemEnchantedBook); boolean isMossy = requiredItems.stream().anyMatch((item) -> item != null && Block.getBlockFromItem(item.getItem()) instanceof BlockVine); return this.getResultItem(isEnchanted, isMossy); }
private static EnumFacing getVineFacing(StructureConfiguration configuration, Block foundBlock, BuildBlock block, EnumFacing assumedNorth) { EnumFacing vineFacing = EnumFacing.UP; // Vines have a special property for it's "facing" if (foundBlock instanceof BlockVine || foundBlock instanceof BlockWall) { if (block.getProperty("east").getValue().equals("true")) { vineFacing = EnumFacing.EAST; } else if (block.getProperty("west").getValue().equals("true")) { vineFacing = EnumFacing.WEST; } else if (block.getProperty("south").getValue().equals("true")) { vineFacing = EnumFacing.SOUTH; } else if (block.getProperty("north").getValue().equals("true")) { vineFacing = EnumFacing.NORTH; } if (vineFacing != EnumFacing.UP) { if (configuration.houseFacing.rotateY() == assumedNorth) { vineFacing = vineFacing.rotateY(); } else if (configuration.houseFacing.getOpposite() == assumedNorth) { } else if (configuration.houseFacing.rotateYCCW() == assumedNorth) { vineFacing = vineFacing.rotateYCCW(); } else { vineFacing = vineFacing.getOpposite(); } } } return vineFacing; }
private static BlockType getBlockType(Block block) { if(block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockCocoa) { return BlockType.BED; } if(block instanceof BlockRail) { return BlockType.RAIL; } if(block instanceof BlockRailPowered || block instanceof BlockRailDetector) { return BlockType.RAIL_POWERED; } if(block instanceof BlockStairs) { return BlockType.STAIR; } if(block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign) { return BlockType.CHEST; } if(block == Blocks.standing_sign) { return BlockType.SIGNPOST; } if(block instanceof BlockDoor) { return BlockType.DOOR; } if(block instanceof BlockButton) { return BlockType.BUTTON; } if(block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator) { return BlockType.REDSTONE_REPEATER; } if(block instanceof BlockTrapDoor) { return BlockType.TRAPDOOR; } if(block instanceof BlockHugeMushroom) { return BlockType.MUSHROOM_CAP; } if(block instanceof BlockVine) { return BlockType.VINE; } if(block instanceof BlockSkull) { return BlockType.SKULL; } if(block instanceof BlockAnvil) { return BlockType.ANVIL; } if(block instanceof BlockLog) { return BlockType.LOG; } if(block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper) { return BlockType.DISPENSER; } if(block instanceof BlockTorch) { return BlockType.TORCH; } if(block instanceof BlockLever) { return BlockType.LEVER; } if(block instanceof BlockTripWireHook) { return BlockType.TRIP_WIRE_HOOK; } return null; }
public static ForgeDirection[] getValidVanillaBlockRotations(Block block) { return (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireSource || block instanceof BlockCocoa || block instanceof BlockRailPowered || block instanceof BlockDetectorRail || block instanceof BlockStairs || block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block.blockID == Block.signWall.blockID || block.blockID == Block.signPost.blockID || block instanceof BlockDoor || block instanceof BlockRail || block instanceof BlockButton || block instanceof BlockRedstoneRepeater || block instanceof BlockComparator || block instanceof BlockTrapDoor || block instanceof BlockMushroomCap || block instanceof BlockVine || block instanceof BlockSkull || block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; }