net.minecraft.block.BlockTorch Java Examples

The following examples show how to use net.minecraft.block.BlockTorch. 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: StructureTofuMineshaftPieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
private void placeSupport(World p_189921_1_, StructureBoundingBox p_189921_2_, int p_189921_3_, int p_189921_4_, int p_189921_5_, int p_189921_6_, int p_189921_7_, Random p_189921_8_) {
    if (this.isSupportingBox(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_7_, p_189921_6_, p_189921_5_)) {
        IBlockState iblockstate = this.getPlanksBlock();
        IBlockState iblockstate1 = this.getFenceBlock();
        IBlockState iblockstate2 = Blocks.AIR.getDefaultState();
        this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_4_, p_189921_5_, p_189921_3_, p_189921_6_ - 1, p_189921_5_, iblockstate1, iblockstate2, false);
        this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_7_, p_189921_4_, p_189921_5_, p_189921_7_, p_189921_6_ - 1, p_189921_5_, iblockstate1, iblockstate2, false);

        if (p_189921_8_.nextInt(4) == 0) {
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_6_, p_189921_5_, p_189921_3_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_7_, p_189921_6_, p_189921_5_, p_189921_7_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
        } else {
            this.fillWithBlocks(p_189921_1_, p_189921_2_, p_189921_3_, p_189921_6_, p_189921_5_, p_189921_7_, p_189921_6_, p_189921_5_, iblockstate, iblockstate2, false);
            this.randomlyPlaceBlock(p_189921_1_, p_189921_2_, p_189921_8_, 0.05F, p_189921_3_ + 1, p_189921_6_, p_189921_5_ - 1, BlockLoader.TOFUISHI_TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH));
            this.randomlyPlaceBlock(p_189921_1_, p_189921_2_, p_189921_8_, 0.05F, p_189921_3_ + 1, p_189921_6_, p_189921_5_ + 1, BlockLoader.TOFUISHI_TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH));
        }
    }
}
 
Example #2
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void run()
{
	if(!equipTorch())
	{
		ChatUtils.error("Out of torches.");
		setEnabled(false);
		return;
	}
	
	KeyBindingUtils.setPressed(mc.gameSettings.keyBindSneak, true);
	BlockUtils.placeBlockSimple(nextTorch);
	
	if(BlockUtils.getBlock(nextTorch) instanceof BlockTorch)
		lastTorch = nextTorch;
}
 
Example #3
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private boolean equipTorch()
{
	for(int slot = 0; slot < 9; slot++)
	{
		// filter out non-block items
		ItemStack stack =
			WMinecraft.getPlayer().inventory.getStackInSlot(slot);
		if(WItem.isNullOrEmpty(stack)
			|| !(stack.getItem() instanceof ItemBlock))
			continue;
		
		// filter out non-torch blocks
		Block block = Block.getBlockFromItem(stack.getItem());
		if(!(block instanceof BlockTorch))
			continue;
		
		WMinecraft.getPlayer().inventory.currentItem = slot;
		return true;
	}
	
	return false;
}
 
Example #4
Source File: AtmosphereBlob.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
/**
 * @param world
 * @param blocks Collection containing affected locations
 */
protected void runEffectOnWorldBlocks(World world, Collection<HashedBlockPosition> blocks) {
	if(!AtmosphereHandler.getOxygenHandler(world.provider.getDimension()).getDefaultAtmosphereType().allowsCombustion()) {

		List<HashedBlockPosition> list;

		synchronized (graph) {
			list = new LinkedList<HashedBlockPosition>(blocks);
		}


		for(HashedBlockPosition pos : list) {
			IBlockState state  = world.getBlockState(pos.getBlockPos());
			if(state.getBlock() == Blocks.TORCH) {
				world.setBlockState(pos.getBlockPos(), AdvancedRocketryBlocks.blockUnlitTorch.getDefaultState().withProperty(BlockTorch.FACING, state.getValue(BlockTorch.FACING)));
			}
			else if(Configuration.torchBlocks.contains(state.getBlock())) {
				EntityItem item = new EntityItem(world, pos.x, pos.y, pos.z, new ItemStack(state.getBlock()));
				world.setBlockToAir(pos.getBlockPos());
				world.spawnEntity(item);
			}
		}
	}
}
 
Example #5
Source File: PlanetEventHandler.java    From AdvancedRocketry with 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 #6
Source File: BlockThinLog.java    From GardenCollection with MIT License 5 votes vote down vote up
private int calcConnectYFlags (IBlockAccess world, int x, int y, int z) {
    Block block = world.getBlock(x, y, z);
    if (block != this)
        return 0;

    Block blockYNeg = world.getBlock(x, y - 1, z);
    boolean hardYNeg = isNeighborHardConnectionY(world, x, y - 1, z, blockYNeg, ForgeDirection.DOWN);
    boolean connectYNeg = hardYNeg || blockYNeg == this;

    Block blockYPos = world.getBlock(x, y + 1, z);
    boolean hardYPos = isNeighborHardConnectionY(world, x, y + 1, z, blockYPos, ForgeDirection.UP);
    boolean connectYPos = hardYPos || blockYPos == this|| blockYPos instanceof BlockTorch;

    return (connectYNeg ? 1 : 0) | (connectYPos ? 2 : 0) | (hardYNeg ? 4 : 0) | (hardYPos ? 8 : 0);
}
 
Example #7
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected void placeTorch(World p_189926_1_, EnumFacing p_189926_2_, int p_189926_3_, int p_189926_4_, int p_189926_5_, StructureBoundingBox p_189926_6_) {
    if (!this.field_189929_i) {
        this.setBlockState(p_189926_1_, BlockLoader.TOFUMOMEN_TORCH.getDefaultState().withProperty(BlockTorch.FACING, p_189926_2_), p_189926_3_, p_189926_4_, p_189926_5_, p_189926_6_);
    }
}
 
Example #8
Source File: BlockThinLog.java    From GardenCollection with MIT License 4 votes vote down vote up
public int calcConnectionFlags (IBlockAccess world, int x, int y, int z) {
    int flagsY = calcConnectYFlags(world, x, y, z);
    int flagsZNeg = calcConnectYFlags(world, x, y, z - 1);
    int flagsZPos = calcConnectYFlags(world, x, y, z + 1);
    int flagsXNeg = calcConnectYFlags(world, x - 1, y, z);
    int flagsXPos = calcConnectYFlags(world, x + 1, y, z);

    int connectFlagsY = flagsY & 3;
    int connectFlagsZNeg = flagsZNeg & 3;
    int connectFlagsZPos = flagsZPos & 3;
    int connectFlagsXNeg = flagsXNeg & 3;
    int connectFlagsXPos = flagsXPos & 3;

    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);

    boolean hardZNeg = isNeighborHardConnection(world, x, y, z - 1, blockZNeg, ForgeDirection.NORTH) || blockZNeg instanceof BlockTorch;
    boolean hardZPos = isNeighborHardConnection(world, x, y, z + 1, blockZPos, ForgeDirection.SOUTH) || blockZPos instanceof BlockTorch;
    boolean hardXNeg = isNeighborHardConnection(world, x - 1, y, z, blockXNeg, ForgeDirection.WEST) || blockXNeg instanceof BlockTorch;
    boolean hardXPos = isNeighborHardConnection(world, x + 1, y, z, blockXPos, ForgeDirection.EAST) || blockXPos instanceof BlockTorch;

    boolean hardConnection = (flagsY & 4) != 0;
    boolean hardConnectionZNeg = hardConnection && (flagsZNeg & 4) != 0;
    boolean hardConnectionZPos = hardConnection && (flagsZPos & 4) != 0;
    boolean hardConnectionXNeg = hardConnection && (flagsXNeg & 4) != 0;
    boolean hardConnectionXPos = hardConnection && (flagsXPos & 4) != 0;

    boolean connectZNeg = (connectFlagsY == 0 && hardZNeg)
        || (blockZNeg == this && !hardConnectionZNeg && (connectFlagsY != 3 || connectFlagsZNeg != 3));
    boolean connectZPos = (connectFlagsY == 0 && hardZPos)
        || (blockZPos == this && !hardConnectionZPos && (connectFlagsY != 3 || connectFlagsZPos != 3));
    boolean connectXNeg = (connectFlagsY == 0 && hardXNeg)
        || (blockXNeg == this && !hardConnectionXNeg && (connectFlagsY != 3 || connectFlagsXNeg != 3));
    boolean connectXPos = (connectFlagsY == 0 && hardXPos)
        || (blockXPos == this && !hardConnectionXPos && (connectFlagsY != 3 || connectFlagsXPos != 3));

    boolean connectSide = connectZNeg | connectZPos | connectXNeg | connectXPos;
    if (!connectSide && (connectFlagsY & 1) == 0) {
        if (hardZNeg)
            connectZNeg = true;
        if (hardZPos)
            connectZPos = true;
        if (hardXNeg)
            connectXNeg = true;
        if (hardXPos)
            connectXPos = true;
    }

    if (!(connectZNeg | connectZPos | connectXNeg | connectXPos))
        connectFlagsY = 3;

    if (connectFlagsY == 2 && hardZNeg)
        connectZNeg = true;
    if (connectFlagsY == 2 && hardZPos)
        connectZPos = true;
    if (connectFlagsY == 2 && hardXNeg)
        connectXNeg = true;
    if (connectFlagsY == 2 && hardXPos)
        connectXPos = true;

    return connectFlagsY | (connectZNeg ? 4 : 0) | (connectZPos ? 8 : 0) |
        (connectXNeg ? 16 : 0) | (connectXPos ? 32 : 0);
}