net.minecraft.block.Block Java Examples

The following examples show how to use net.minecraft.block.Block. 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: ModuleAirGrate.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
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 #2
Source File: ItemTraverseWoodDoor.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #3
Source File: MissingMappingEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #5
Source File: MoCEntityWyvern.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: FillerConfigUtils.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #7
Source File: BlockTexturedOreRenderer.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@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 File: BlockPotteryTable.java    From GardenCollection with 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 #9
Source File: BlockLattice.java    From GardenCollection with 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 #10
Source File: BlockGardenContainer.java    From GardenCollection with 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 #11
Source File: ValkyrienSkiesOpenComputers.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@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 #12
Source File: BlockCraftingGrid.java    From Translocators with 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 #13
Source File: MultiTickEffectDispatcher.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #14
Source File: MultiblockStructureDefinition.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
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 #15
Source File: DecorativePotRenderer.java    From GardenCollection with 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 #16
Source File: ModBlocks.java    From GardenCollection with 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 #17
Source File: TileEntityProcessorBase.java    From TofuCraftReload with 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 #18
Source File: BlockRootCover.java    From GardenCollection with MIT License 5 votes vote down vote up
public BlockRootCover (String name) {
    super(Material.wood);

    setBlockName(name);
    setHardness(1.5f);
    setResistance(2.5f);
    setStepSound(Block.soundTypeWood);
    setBlockTextureName(GardenStuff.MOD_ID + ":root_cover");
    setCreativeTab(ModCreativeTabs.tabGardenCore);
}
 
Example #19
Source File: BlockEnderStorage.java    From EnderStorage with 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 #20
Source File: WorldEditor.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
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 #21
Source File: Carving.java    From Chisel with 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 #22
Source File: BlockPhysicsDetails.java    From Valkyrien-Skies with 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 #23
Source File: BlockLightChain.java    From GardenCollection with 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 #24
Source File: LPWorldGen.java    From Logistics-Pipes-2 with 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 #25
Source File: BlockPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@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 #26
Source File: ForgeQueue_All.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@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 #27
Source File: StructureBuilder.java    From mobycraft with 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());
			}
		}
	}
}
 
Example #28
Source File: BlockSpikes.java    From Artifacts with MIT License 5 votes vote down vote up
public BlockSpikes() {
	super(Material.iron);
	setResistance(5F);
	setStepSound(Block.soundTypeMetal);
	setCreativeTab(DragonArtifacts.tabGeneral);
	setHardness(2F);
}
 
Example #29
Source File: BlockDecorativePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
protected boolean isValidSubstrate (World world, int x, int y, int z, int slot, ItemStack itemStack) {
    if (itemStack == null || itemStack.getItem() == null)
        return false;

    if (Block.getBlockFromItem(itemStack.getItem()) == Blocks.netherrack)
        return true;

    return super.isValidSubstrate(world, x, y, z, slot, itemStack);
}
 
Example #30
Source File: ItemRockbreakerDrill.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
private boolean isEffectiveAgainst(Block block) {
    for (int var3 = 0; var3 < isEffective.length; var3++) {
        if (isEffective[var3] == block) {
            return true;
        }
    }
    return false;
}