Java Code Examples for net.minecraft.block.Block

The following examples show how to use net.minecraft.block.Block. These examples are extracted from open source projects. 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 Project: GardenCollection   Source File: BlockPotteryTable.java    License: MIT License 6 votes vote down vote up
private void setBlockDirection (World world, int x, int y, int z) {
    if (!world.isRemote) {
        Block blockZNeg = world.getBlock(x, y, z - 1);
        Block blockZPos = world.getBlock(x, y, z + 1);
        Block blockXNeg = world.getBlock(x - 1, y, z);
        Block blockXPos = world.getBlock(x + 1, y, z);

        byte dir = 3;
        if (blockZNeg.func_149730_j() && !blockZPos.func_149730_j())
            dir = 3;
        if (blockZPos.func_149730_j() && !blockZNeg.func_149730_j())
            dir = 2;
        if (blockXNeg.func_149730_j() && !blockXPos.func_149730_j())
            dir = 5;
        if (blockXPos.func_149730_j() && !blockXNeg.func_149730_j())
            dir = 4;

        world.setBlockMetadataWithNotify(x, y, z, dir, 2);
    }
}
 
Example 2
@Override
public void dropMyStuff() 
{
    if (MoCreatures.isServer())
    {
        dropArmor();
        MoCTools.dropSaddle(this, worldObj);
        
        if (getIsChested())
        {
           MoCTools.dropInventory(this, localchest);
           MoCTools.dropCustomItem(this, this.worldObj, new ItemStack(Block.chest, 1));
           setIsChested(false);
        }
    }
    
}
 
Example 3
private static FillerEntry createSimpleFiller(String stringDeclaration) {
    if (stringDeclaration.startsWith("block:")) {
        Block block = OreConfigUtils.getBlockByName(stringDeclaration.substring(6));
        return FillerEntry.createSimpleFiller(block.getDefaultState());

    } else if (stringDeclaration.startsWith("fluid:")) {
        String fluidName = stringDeclaration.substring(6);
        Fluid fluid = FluidRegistry.getFluid(fluidName);
        Preconditions.checkNotNull(fluid, "Fluid not found with name %s", fluidName);
        Preconditions.checkNotNull(fluid.getBlock(), "Block is not defined for fluid %s", fluidName);
        return FillerEntry.createSimpleFiller(fluid.getBlock().getDefaultState());

    } else if (stringDeclaration.startsWith("ore:")) {
        Map<StoneType, IBlockState> blockStateMap = OreConfigUtils.getOreStateMap(stringDeclaration);
        return new OreFilterEntry(blockStateMap);

    } else if (stringDeclaration.startsWith("ore_dict:")) {
        String oreDictName = stringDeclaration.substring(9);
        IBlockState firstBlock = OreConfigUtils.getOreDictBlocks(oreDictName).get(0);
        return FillerEntry.createSimpleFiller(firstBlock);

    } else {
        throw new IllegalArgumentException("Unknown string block state declaration: " + stringDeclaration);
    }
}
 
Example 4
public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door, boolean isRightHinge) {
    BlockPos blockpos = pos.offset(facing.rotateY());
    BlockPos blockpos1 = pos.offset(facing.rotateYCCW());
    int i = (worldIn.getBlockState(blockpos1).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).isNormalCube() ? 1 : 0);
    int j = (worldIn.getBlockState(blockpos).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).isNormalCube() ? 1 : 0);
    boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door;
    boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door;

    if ((!flag || flag1) && j <= i) {
        if (flag1 && !flag || j < i) {
            isRightHinge = false;
        }
    }
    else {
        isRightHinge = true;
    }

    BlockPos blockpos2 = pos.up();
    boolean flag2 = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos2);
    IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, isRightHinge ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(BlockDoor.POWERED, Boolean.valueOf(flag2)).withProperty(BlockDoor.OPEN, Boolean.valueOf(flag2));
    worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
    worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
    worldIn.notifyNeighborsOfStateChange(pos, door, false);
    worldIn.notifyNeighborsOfStateChange(blockpos2, door, false);
}
 
Example 5
@SubscribeEvent
public static void onMissingMappingEventBlocks(RegistryEvent.MissingMappings<Block> event)
{
    List<Mapping<Block>> list = event.getMappings();
    Map<String, String> renameMap = TileEntityID.getMap();

    for (Mapping<Block> mapping : list)
    {
        ResourceLocation oldLoc = mapping.key;
        String newName = renameMap.get(oldLoc.toString());

        if (newName != null)
        {
            Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(newName));

            if (block != null && block != Blocks.AIR)
            {
                mapping.remap(block);
                EnderUtilities.logger.info("Re-mapped block '{}' => '{}'", oldLoc, newName);
            }
        }
    }
}
 
Example 6
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example 7
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
	if (blck == null || !(blck instanceof BlockTexturedOre))
		return false;
	BlockTexturedOre block = (BlockTexturedOre) blck;

	if (block.currentPass == 0) {
		if (block.icon != null) {
			renderer.overrideBlockTexture = block.icon;
			renderer.renderStandardBlock(block, x, y, z);
			renderer.overrideBlockTexture = null;
		} else if (block.base != null) {
			renderer.renderBlockByRenderType(block.base, x, y, z);
		}
	} else {
		renderer.setRenderBounds(bot, bot, bot, top, top, top);
		renderer.renderStandardBlock(block, x, y, z);
	}

	return true;
}
 
Example 8
Source Project: GardenCollection   Source File: BlockLattice.java    License: MIT License 6 votes vote down vote up
private boolean isNeighborHardConnection (IBlockAccess world, int x, int y, int z, Block block, ForgeDirection side) {
    if (block.getMaterial().isOpaque() && block.renderAsNormalBlock())
        return true;

    if (block.isSideSolid(world, x, y, z, side.getOpposite()))
        return true;

    if (block == this)
        return true;

    if (side == ForgeDirection.DOWN || side == ForgeDirection.UP) {
        if (block instanceof BlockFence || block instanceof net.minecraft.block.BlockFence)
            return true;
    }

    return false;
}
 
Example 9
Source Project: GardenCollection   Source File: BlockGardenContainer.java    License: MIT License 6 votes vote down vote up
@Override
public void breakBlock (World world, int x, int y, int z, Block block, int data) {
    TileEntityGarden te = getTileEntity(world, x, y, z);

    if (te != null) {
        ItemStack substrate = te.getSubstrateSource();
        if (substrate == null)
            substrate = te.getSubstrate();
        if (substrate != null) {
            if (Block.getBlockFromItem(substrate.getItem()) != Blocks.water) {
                ItemStack item = substrate.copy();
                item.stackSize = 1;
                dropBlockAsItem(world, x, y, z, item);
            }
        }
    }

    super.breakBlock(world, x, y, z, block, data);
}
 
Example 10
private void checkForPlantsAndFarm(World worldObj, int x, int y, int z, int plantCheckRange){
    if(grateRange > 0 && worldObj.getTotalWorldTime() % 5 == 0) {
        if(plantCheckX < x - plantCheckRange || plantCheckZ < z - plantCheckRange) {
            plantCheckX = x - plantCheckRange;
            plantCheckZ = z - plantCheckRange;
        }

        if(plantCheckX != x || plantCheckZ != z) { // we know that we're no plant, avoid getBlock
            Block b = worldObj.getBlock(plantCheckX, y, plantCheckZ);
            NetworkHandler.sendToAllAround(new PacketSpawnParticle("reddust", plantCheckX + 0.5, y + 0.5, plantCheckZ + 0.5, 0, 0, 0), worldObj);
            if(b instanceof BlockPneumaticPlantBase) {
                ((BlockPneumaticPlantBase)b).attemptFarmByAirGrate(worldObj, plantCheckX, y, plantCheckZ);
            }
        }

        if(plantCheckZ++ >= z + plantCheckRange) {
            plantCheckZ = z - plantCheckRange;
            if(plantCheckX++ >= x + plantCheckRange) {
                plantCheckX = x - plantCheckRange;
            }
        }
    }
}
 
Example 11
Source Project: Valkyrien-Skies   Source File: BlockPhysicsDetails.java    License: Apache License 2.0 5 votes vote down vote up
private static void onSync() {
    Arrays.stream(VSConfig.blockMass)
        .map(str -> str.split("="))
        .filter(arr -> arr.length == 2)
        .map(arr -> Pair.of(Block.getBlockFromName(arr[0]), Double.parseDouble(arr[1])))
        .forEach(pair -> blockToMass.put(pair.getLeft(), pair.getRight()));
}
 
Example 12
public VortexDigInfo(int dimId, int oX, int oY, int oZ, int tX, int tY, int tZ, Block blockInstance, int meta, int tickDuration) {
    this.dimId = dimId;
    this.oX = oX;
    this.oY = oY;
    this.oZ = oZ;
    this.tX = tX;
    this.tY = tY;
    this.tZ = tZ;
    this.blockInstance = blockInstance;
    this.meta = meta;
    this.tickCap = tickDuration;
}
 
Example 13
Source Project: EnderStorage   Source File: BlockEnderStorage.java    License: MIT License 5 votes vote down vote up
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileFrequencyOwner) {
        ((TileFrequencyOwner) tile).onNeighborChange(fromPos);
    }
}
 
Example 14
Source Project: AdvancedRocketry   Source File: PlanetEventHandler.java    License: MIT License 5 votes vote down vote up
@SubscribeEvent
public void blockPlaceEvent(RightClickBlock event) {
	EnumFacing direction = event.getFace();
	if(!event.getWorld().isRemote && direction != null  && event.getEntityPlayer() != null  && AtmosphereHandler.getOxygenHandler(event.getWorld().provider.getDimension()) != null &&
			!AtmosphereHandler.getOxygenHandler(event.getWorld().provider.getDimension()).getAtmosphereType(event.getPos().offset(direction)).allowsCombustion()) {

		if(event.getEntityPlayer().getHeldItem(event.getHand()) != null) {
			if(event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Item.getItemFromBlock(Blocks.TORCH) && 
					event.getWorld().getBlockState(event.getPos()).isSideSolid(event.getWorld(), event.getPos(), direction)) {
				event.setCanceled(true);
				event.getWorld().setBlockState(event.getPos().offset(direction), AdvancedRocketryBlocks.blockUnlitTorch.getDefaultState().withProperty(BlockTorch.FACING, direction));
			}
			else if(zmaster587.advancedRocketry.api.Configuration.torchBlocks.contains(Block.getBlockFromItem(event.getEntityPlayer().getHeldItem(event.getHand()).getItem())) )
				event.setCanceled(true);
			else if(event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.FLINT_AND_STEEL || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.FIRE_CHARGE|| event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.BLAZE_POWDER || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.BLAZE_ROD || event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == Items.LAVA_BUCKET)
				event.setCanceled(true);
		}
	}

	if(!event.getWorld().isRemote && event.getItemStack() != null && event instanceof PlayerInteractEvent.RightClickBlock && event.getItemStack().getItem() == Items.BED && event.getWorld().provider instanceof WorldProviderPlanet) {
		AdvancedRocketryItems.itemAstroBed.onItemUse( event.getEntityPlayer(),  event.getEntityPlayer().world, event.getPos(), event.getHand(), event.getFace(), 0, 0, 0);
		event.setCanceled(true);
	}

	if(!event.getWorld().isRemote && event.getItemStack() != null && event.getItemStack().getItem() == Item.getItemFromBlock(AdvancedRocketryBlocks.blockGenericSeat) && event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.TNT) {
		ARAchivements.BEER.trigger((EntityPlayerMP) event.getEntityPlayer());
	}
}
 
Example 15
Source Project: seppuku   Source File: InteractModule.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void sendPacket(EventSendPacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        if (event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) {
            if (this.clicked) {
                this.clicked = false;
                return;
            }
            final CPacketPlayerTryUseItemOnBlock packet = (CPacketPlayerTryUseItemOnBlock) event.getPacket();
            final Minecraft mc = Minecraft.getMinecraft();
            if (mc.currentScreen == null) {
                final Block block = mc.world.getBlockState(packet.getPos()).getBlock();
                if (block.onBlockActivated(mc.world, packet.getPos(), mc.world.getBlockState(packet.getPos()), mc.player, packet.getHand(), packet.getDirection(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ())) {
                    return;
                }

                final BlockPos usable = findUsableBlock(packet.getHand(), packet.getDirection(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ());
                if (usable != null) {
                    mc.player.swingArm(packet.getHand());
                    mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(usable, packet.getDirection(), packet.getHand(), packet.getFacingX(), packet.getFacingY(), packet.getFacingZ()));
                    this.clicked = true;
                }else{
                    final Entity usableEntity = findUsableEntity(packet.getHand());
                    if(usableEntity != null) {
                        mc.player.connection.sendPacket(new CPacketUseEntity(usableEntity, packet.getHand()));
                        this.clicked = true;
                    }
                }
            }
        }
    }
}
 
Example 16
@SubscribeEvent
public void registerBlocks(RegistryEvent.Register<Block> event) {
    gpsBlock = new GPSBlock().setTranslationKey("gpsblock")
        .setRegistryName(MOD_ID, "gpsblock")
        .setCreativeTab(ValkyrienSkiesMod.VS_CREATIVE_TAB);

    event.getRegistry().register(gpsBlock);
}
 
Example 17
Source Project: Translocators   Source File: BlockCraftingGrid.java    License: MIT License 5 votes vote down vote up
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    BlockCoord beneath = new BlockCoord(x, y, z).offset(0);
    if (!world.isSideSolid(beneath.x, beneath.y, beneath.z, ForgeDirection.UP)) {
        dropBlockAsItem(world, x, y, z, 0, 0);
        world.setBlockToAir(x, y, z);
    }
}
 
Example 18
Source Project: AgriCraft   Source File: MethodGetCurrentSoil.java    License: MIT License 5 votes vote down vote up
@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()};
}
 
Example 19
private void checkSurroundings() {
    this.surroundingKnowledge = 0;
    for (int xx = -SURROUNDINGS_SEARCH_XZ; xx <= SURROUNDINGS_SEARCH_XZ; xx++) {
        for (int zz = -SURROUNDINGS_SEARCH_XZ;  zz <= SURROUNDINGS_SEARCH_XZ;  zz++) {

            lblYLoop:
            for (int yy = -SURROUNDINGS_SEARCH_Y; yy <= SURROUNDINGS_SEARCH_Y; yy++) {
                int absX = xx + xCoord;
                int absY = yy + yCoord;
                int absZ = zz + zCoord;
                Block at = worldObj.getBlock(absX, absY, absZ);
                int meta = worldObj.getBlockMetadata(absX, absY, absZ);
                TileEntity te = worldObj.getTileEntity(absX, absY, absZ);
                if(at.equals(Blocks.bookshelf)) {
                    this.surroundingKnowledge += 1;
                } else if(te != null && te instanceof IKnowledgeProvider) {
                    this.surroundingKnowledge += ((IKnowledgeProvider) te).getProvidedKnowledge(worldObj, absX, absY, absZ);
                } else if(at instanceof IKnowledgeProvider) {
                    this.surroundingKnowledge += ((IKnowledgeProvider) at).getProvidedKnowledge(worldObj, absX, absY, absZ);
                } else {
                    for (BlockSnapshot sn : knowledgeIncreaseMap.keySet()) {
                        if(sn.block.equals(at) && sn.metadata == meta) {
                            this.surroundingKnowledge += knowledgeIncreaseMap.get(sn);
                            continue lblYLoop;
                        }
                    }
                }
            }
        }
    }
}
 
Example 20
Source Project: GardenCollection   Source File: DecorativePotRenderer.java    License: MIT License 5 votes vote down vote up
@Override
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    if (!(block instanceof BlockDecorativePot))
        return false;

    return renderWorldBlock(world, x, y, z, (BlockDecorativePot) block, modelId, renderer);
}
 
Example 21
boolean matchGroup(World world, int originX, int originY, int originZ){
	for (BlockCoord offset : allowedBlocks.keySet()){
		Block block = world.getBlock(originX + offset.x, originY + offset.y, originZ + offset.z);
		int meta = world.getBlockMetadata(originX + offset.x, originY + offset.y, originZ + offset.z);
		ArrayList<BlockDec> positionReplacements = allowedBlocks.get(offset);
		boolean valid = false;
		for (BlockDec bd : positionReplacements){
			if (bd.block == block && (bd.meta == -1 || bd.meta == meta)){
				valid = true;
			}
		}
		if (!valid) return false;
	}
	return true;
}
 
Example 22
Source Project: GardenCollection   Source File: ModBlocks.java    License: MIT License 5 votes vote down vote up
public static UniqueMetaIdentifier getUniqueMetaID (Block block, int meta) {
    String name = GameData.getBlockRegistry().getNameForObject(block);
    if (name == null) {
        FMLLog.log(GardenContainers.MOD_ID, Level.WARN, "Tried to make a UniqueMetaIdentifier from an invalid block");
        return null;
    }

    return new UniqueMetaIdentifier(name, meta);
}
 
Example 23
Source Project: TofuCraftReload   Source File: TileEntityProcessorBase.java    License: MIT License 5 votes vote down vote up
@Override
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState) {
    if (oldState.getBlock() == newState.getBlock()) {
        return false;
    }
    if (oldState.getBlock().getClass() == Block.class) {
        return true;
    }
    return oldState.getBlock().getClass() != newState.getBlock().getClass();
}
 
Example 24
private boolean setBlock(Coord pos, MetaBlock block, int flags, boolean fillAir, boolean replaceSolid){
	
	MetaBlock currentBlock = getBlock(pos);
	
	if(currentBlock.getBlock() == Blocks.CHEST) return false;
	if(currentBlock.getBlock() == Blocks.TRAPPED_CHEST) return false;
	if(currentBlock.getBlock() == Blocks.MOB_SPAWNER) return false;
	
	//boolean isAir = world.isAirBlock(pos.getBlockPos());
	boolean isAir = currentBlock.getBlock() == Blocks.AIR;
	
	if(!fillAir && isAir) return false;
	if(!replaceSolid && !isAir)	return false;
	
	try{
		world.setBlockState(pos.getBlockPos(), block.getState(), flags);
	} catch(NullPointerException npe){
		//ignore it.
	}
	
	Block type = block.getBlock();
	Integer count = stats.get(type);
	if(count == null){
		stats.put(type, 1);	
	} else {
		stats.put(type, count + 1);
	}
	
	return true;
	
}
 
Example 25
Source Project: Chisel   Source File: Carving.java    License: GNU General Public License v2.0 5 votes vote down vote up
public CarvingVariation addVariation(String name, Block block, int metadata, int order)
{
    CarvingGroup group = getGroup(name);

    CarvingGroup blockGroup = carvingGroupsByVariation.get(key(block, metadata));
    if(blockGroup != null || blockGroup == group)
        return null;

    CarvingVariation variation = new CarvingVariation(block, metadata, order);
    group.variations.add(variation);
    Collections.sort(group.variations);
    carvingGroupsByVariation.put(key(block, metadata), group);

    return variation;
}
 
Example 26
Source Project: GardenCollection   Source File: BlockLightChain.java    License: MIT License 5 votes vote down vote up
public BlockLightChain (String blockName) {
    super(Material.iron);

    setBlockName(blockName);
    setHardness(2.5f);
    setResistance(5f);
    setStepSound(Block.soundTypeMetal);
    setBlockBounds(.5f - .0625f, 0, .5f - .0625f, .5f + .0625f, 1, .5f + .0625f);
    setBlockTextureName(GardenStuff.MOD_ID + ":chain_light");
    setCreativeTab(ModCreativeTabs.tabGardenCore);
    setBlockBounds(0, 0, 0, 1, 1, 1);
}
 
Example 27
Source Project: Logistics-Pipes-2   Source File: LPWorldGen.java    License: MIT License 5 votes vote down vote up
public OreGen(String name, IBlockState state, int maxVeinSize, Block replaceTarget, int minY, int maxY, int chunkOccurence, int weight) {
	this.name = name;
	this.ore = new WorldGenMinable(state, maxVeinSize, BlockMatcher.forBlock(replaceTarget));
	this.minY = minY;
	this.maxY = maxY;
	this.chunkOccurence = chunkOccurence;
	this. weight = weight;
}
 
Example 28
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
    if(world instanceof World && !world.isRemote) {
        TileEntity te = world.getTileEntity(x, y, z);
        if(te instanceof TileEntityBase) {
            ((TileEntityBase)te).onNeighborBlockUpdate();
        }
    }
}
 
Example 29
@Override
public int getOpacity(ExtendedBlockStorage section, int x, int y, int z) {
    int combined = getCombinedId4Data(section, x, y, z);
    if (combined == 0) {
        return 0;
    }
    Block block = Block.getBlockById(FaweCache.getId(combined));
    return block.getLightOpacity();
}
 
Example 30
Source Project: mobycraft   Source File: StructureBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private static void fill(World world, BlockPos start, BlockPos end,
		Block material) {
	int startX = start.getX();
	int endX = end.getX();
	int startY = start.getY();
	int endY = end.getY();
	int startZ = start.getZ();
	int endZ = end.getZ();

	int[] intSwitchArray = new int[2];

	if (endX < startX) {
		intSwitchArray = switchNumbers(startX, endX);
		startX = intSwitchArray[0];
		endX = intSwitchArray[1];
	}

	if (endY < startY) {
		intSwitchArray = switchNumbers(startY, endY);
		startY = intSwitchArray[0];
		endY = intSwitchArray[1];
	}

	if (endZ < startZ) {
		intSwitchArray = switchNumbers(startZ, endZ);
		startZ = intSwitchArray[0];
		endZ = intSwitchArray[1];
	}

	for (int x = startX; x < endX + 1; x++) {
		for (int y = startY; y < endY + 1; y++) {
			for (int z = startZ; z < endZ + 1; z++) {
				world.setBlockState(new BlockPos(x, y, z),
						material.getDefaultState());
			}
		}
	}
}