Java Code Examples for net.minecraft.util.math.BlockPos

The following are top voted examples for showing how to use net.minecraft.util.math.BlockPos. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: MeeCreeps   File: WorkerHelper.java   Source Code and License 6 votes vote down vote up
@Override
public boolean findItemOnGroundOrInChest(Predicate<ItemStack> matcher, int maxAmount, String message, String... parameters) {
    List<BlockPos> meeCreepChests = findMeeCreepChests(worker.getSearchBox());
    if (meeCreepChests.isEmpty()) {
        if (!findItemOnGround(worker.getSearchBox(), matcher, this::pickup)) {
            if (!findInventoryContainingMost(worker.getSearchBox(), matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
                showMessage(message, parameters);
                return false;
            }
        }
    } else {
        if (!findInventoryContainingMost(meeCreepChests, matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
            showMessage(message, parameters);
            return false;
        }
    }
    return true;
}
 
Example 2
Project: CustomWorldGen   File: BlockFlowerPot.java   Source Code and License 6 votes vote down vote up
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

    if (tileentityflowerpot != null)
    {
        ItemStack itemstack = tileentityflowerpot.getFlowerItemStack();

        if (itemstack != null)
        {
            return itemstack;
        }
    }

    return new ItemStack(Items.FLOWER_POT);
}
 
Example 3
Project: CustomWorldGen   File: BlockPortal.java   Source Code and License 6 votes vote down vote up
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);

    if (enumfacing$axis == EnumFacing.Axis.X)
    {
        BlockPortal.Size blockportal$size = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.X);

        if (!blockportal$size.isValid() || blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
    else if (enumfacing$axis == EnumFacing.Axis.Z)
    {
        BlockPortal.Size blockportal$size1 = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.Z);

        if (!blockportal$size1.isValid() || blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
}
 
Example 4
Project: ThermionicsWorld   File: ChunkProviderNeo.java   Source Code and License 6 votes vote down vote up
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
	if (pos==null) return ImmutableList.of();
	
	if (creatureType == EnumCreatureType.MONSTER) {
           //if (this.genNetherBridge.isInsideStructure(pos)) {
           //    return this.genNetherBridge.getSpawnList();
           //}

           if (this.genNetherBridge.isPositionInStructure(this.world, pos) && this.world.getBlockState(pos.down()).getBlock() == Blocks.NETHER_BRICK) {
               return this.genNetherBridge.getSpawnList();
           }
           
           return Biomes.HELL.getSpawnableList(EnumCreatureType.MONSTER); //TODO: Replace with actual-biome lists.
	}
	return ImmutableList.of();

	//Biome biome = this.world.getBiome(pos);
	//return biome.getSpawnableList(creatureType);
}
 
Example 5
Project: CustomWorldGen   File: EntityMinecart.java   Source Code and License 6 votes vote down vote up
/**
 * Moved to allow overrides.
 * This code handles minecart movement and speed capping when on a rail.
 */
public void moveMinecartOnRail(BlockPos pos)
{
    double mX = this.motionX;
    double mZ = this.motionZ;

    if (this.isBeingRidden())
    {
        mX *= 0.75D;
        mZ *= 0.75D;
    }

    double max = this.getMaxSpeed();
    mX = MathHelper.clamp_double(mX, -max, max);
    mZ = MathHelper.clamp_double(mZ, -max, max);
    this.moveEntity(mX, 0.0D, mZ);
}
 
Example 6
Project: Backmemed   File: BlockDispenser.java   Source Code and License 6 votes vote down vote up
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playEvent(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
            {
                tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
            }
        }
    }
}
 
Example 7
Project: uniquecrops   File: Wafflonia.java   Source Code and License 6 votes vote down vote up
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (this.getAge(state) >= getMaxAge())
		return;
	
	int friends = 0;
	
	Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
	Iterator it = getBox.iterator();
	while (it.hasNext()) {
		BlockPos looppos = (BlockPos)it.next();
		Block loopblock = world.getBlockState(looppos).getBlock();
		if (loopblock != null && !world.isAirBlock(looppos) && loopblock == UCBlocks.cropWafflonia) {
			if (!world.isRemote)
				friends++;
		}
	}
	if ((friends != 0 && friends % 4 != 0) || friends == 0)
		return;
	
	super.updateTick(world, pos, state, rand);
}
 
Example 8
Project: CustomWorldGen   File: WorldGenVines.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 9
Project: craftsman   File: LinePts.java   Source Code and License 6 votes vote down vote up
private List<BlockPos> xDominant(BlockPos start, BlockPos end) {
    int x = start.getX();
    int y = start.getY();
    int z = start.getZ();
    
    int yd = ay - (ax >> 1);
    int zd = az - (ax >> 1);
    
    List<BlockPos> posLt = new ArrayList<>();
    do {
        posLt.add(new BlockPos(x, y, z));
        if(yd >= 0) {
            y += sy;
            yd -= ax;
        }
        if(zd >= 0) {
            z += sz;
            zd -= ax;                    
        }
        x += sx;
        yd += ay;
        zd += az;
    } while(x != end.getX());
    return posLt;
}
 
Example 10
Project: UniversalRemote   File: ItemUniversalRemote.java   Source Code and License 6 votes vote down vote up
private int computeEnergyCost(EntityPlayer player, int blockDim, BlockPos pos)
  {
  	// check fuel type
  	if (UniversalRemoteConfiguration.fuel.fuelType.equals(UniversalRemoteConfiguration.FuelType.Energy.toString()) &&
  			UniversalRemoteConfiguration.fuel.energy.energyCapacity > 0)
{

	if (player.dimension == blockDim) {

		return Math.min(UniversalRemoteConfiguration.fuel.energy.energyCostMax, (int)(Math.sqrt(player.getDistanceSq(pos)) * UniversalRemoteConfiguration.fuel.energy.energyCostPerBlock));

	} else {

		return UniversalRemoteConfiguration.fuel.energy.energyCostMax;

	}

} else {
	return 0;
}
  }
 
Example 11
Project: Firma   File: TreeGeneric.java   Source Code and License 6 votes vote down vote up
@Override
public boolean generateTree(World worldIn, Random rand, BlockPos pos) {
	filler.leaf = leaf;
	// Check light levels
	if(worldIn.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = rand.nextInt(heightVar) + height;
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(worldIn,pos.add(0,h,0))){
			return false;
		}
	}
	// Place central trunk
	for(int y = 0; y<h; y++){
		fill(worldIn, pos.add(0, y, 0));
	}
	filler.fillLeaves(worldIn, pos.add(0,h-1,0), rand);
	
	return false;
}
 
Example 12
Project: Backmemed   File: BlockEnchantmentTable.java   Source Code and License 6 votes vote down vote up
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityEnchantmentTable)
        {
            playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
        }

        return true;
    }
}
 
Example 13
Project: CustomWorldGen   File: WorldGenHugeTrees.java   Source Code and License 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(World worldIn, BlockPos layerCenter, int width)
{
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j)
    {
        for (int k = -width; k <= width + 1; ++k)
        {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
            {
                BlockPos blockpos = layerCenter.add(j, 0, k);
                IBlockState state = worldIn.getBlockState(blockpos);

                if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos))
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 14
Project: Bewitchment   File: CropKelp.java   Source Code and License 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
	BlockPos I = pos.add(-1, 0, -1);
	BlockPos F = pos.add(1, 1, 1);
	for (BlockPos blockPos : BlockPos.getAllInBox(I, F)) {
		Block block = worldIn.getBlockState(blockPos).getBlock();
		if (block != this && block != Blocks.WATER && block != Blocks.FLOWING_WATER) {
			checkAndDropBlock(worldIn, pos, state);
			break;
		}
	}
	if (!canBlockStay(worldIn, pos, state) || !canSustainBush(worldIn.getBlockState(pos.down()))) {
		checkAndDropBlock(worldIn, pos, state);
	}
}
 
Example 15
Project: ExPetrum   File: BlockFarmland.java   Source Code and License 5 votes vote down vote up
@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
{
	super.onNeighborChange(world, pos, neighbor);
	if (world instanceof World)
	{
		World w = (World) world;
		if (this.canFall(w, world.getBlockState(pos), pos, neighbor))
		{
			w.setBlockState(pos, ExPBlocks.soil.getDefaultState().withProperty(DIRT_CLASS, world.getBlockState(pos).getValue(DIRT_CLASS)));
		}
	}
}
 
Example 16
Project: Backmemed   File: BlockLiquid.java   Source Code and License 5 votes vote down vote up
public int getPackedLightmapCoords(IBlockState state, IBlockAccess source, BlockPos pos)
{
    int i = source.getCombinedLight(pos, 0);
    int j = source.getCombinedLight(pos.up(), 0);
    int k = i & 255;
    int l = j & 255;
    int i1 = i >> 16 & 255;
    int j1 = j >> 16 & 255;
    return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
}
 
Example 17
Project: pnc-repressurized   File: BlockPressureTube.java   Source Code and License 5 votes vote down vote up
@Override
public boolean rotateBlock(World world, EntityPlayer player, BlockPos pos, EnumFacing side) {
    TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(getTE(world, pos));
    if (player.isSneaking()) {
        TubeModule module = getLookedModule(world, pos, player);
        if (module != null) {
            // detach and drop the module as an item
            if (!player.capabilities.isCreativeMode) {
                List<ItemStack> drops = module.getDrops();
                for (ItemStack drop : drops) {
                    EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
                    entity.setItem(drop);
                    world.spawnEntity(entity);
                    entity.onCollideWithPlayer(player);
                }
            }
            tube.setModule(null, module.getDirection());
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        } else {
            // drop the pipe as an item
            if (!player.capabilities.isCreativeMode) dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
            world.setBlockToAir(pos);
        }
    } else {
        // close (or reopen) this side of the pipe
        Pair<Boolean, EnumFacing> lookData = getLookedTube(world, pos, player);
        if (lookData != null) {
            boolean isCore = lookData.getLeft();
            EnumFacing sideHit = lookData.getRight();
            tube.sidesClosed[sideHit.ordinal()] = !tube.sidesClosed[sideHit.ordinal()];
            neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
            world.notifyNeighborsOfStateChange(pos, this, true);
        }
    }
    return true;
}
 
Example 18
Project: CustomWorldGen   File: ForgeHooks.java   Source Code and License 5 votes vote down vote up
public static boolean isLivingOnLadder(IBlockState state, World world, BlockPos pos, EntityLivingBase entity)
{
    boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator());
    if (isSpectator) return false;
    if (!ForgeModContainer.fullBoundingBoxLadders)
    {
        return state != null && state.getBlock().isLadder(state, world, pos, entity);
    }
    else
    {
        AxisAlignedBB bb = entity.getEntityBoundingBox();
        int mX = MathHelper.floor_double(bb.minX);
        int mY = MathHelper.floor_double(bb.minY);
        int mZ = MathHelper.floor_double(bb.minZ);
        for (int y2 = mY; y2 < bb.maxY; y2++)
        {
            for (int x2 = mX; x2 < bb.maxX; x2++)
            {
                for (int z2 = mZ; z2 < bb.maxZ; z2++)
                {
                    BlockPos tmp = new BlockPos(x2, y2, z2);
                    state = world.getBlockState(tmp);
                    if (state.getBlock().isLadder(state, world, tmp, entity))
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
 
Example 19
Project: SimpleTubes   File: PacketDisplacerGuiColor.java   Source Code and License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
	int dim = buf.readInt();
	BlockPos pos = BlockPos.fromLong(buf.readLong());

	World world = SimpleTubes.proxy.getWorld(dim);
	this.tile = world.getTileEntity(pos);

	if (this.col == null)
		this.col = new int[buf.readInt()];
	
	if (this.col != null)
		for (int i = 0; i < this.col.length; i++)
			this.col[i] = buf.readInt();
}
 
Example 20
Project: CharcoalPit   File: BlockPotteryKiln.java   Source Code and License 5 votes vote down vote up
@Override
public float getBlockHardness(IBlockState blockState, World worldIn, BlockPos pos) {
	switch((EnumKilnTypes)blockState.getValue(TYPE)){
	case EMPTY:return 0.6F;
	case THATCH:return 0.6F;
	case WOOD:return 2F;
	case ACTIVE:return 2F;
	case COMPLETE:return 0.6F;
	default:return 1F;
	}
}
 
Example 21
Project: Backmemed   File: EntityEvoker.java   Source Code and License 5 votes vote down vote up
protected void func_190868_j()
{
    for (int i = 0; i < 3; ++i)
    {
        BlockPos blockpos = (new BlockPos(EntityEvoker.this)).add(-2 + EntityEvoker.this.rand.nextInt(5), 1, -2 + EntityEvoker.this.rand.nextInt(5));
        EntityVex entityvex = new EntityVex(EntityEvoker.this.world);
        entityvex.moveToBlockPosAndAngles(blockpos, 0.0F, 0.0F);
        entityvex.onInitialSpawn(EntityEvoker.this.world.getDifficultyForLocation(blockpos), (IEntityLivingData)null);
        entityvex.func_190658_a(EntityEvoker.this);
        entityvex.func_190651_g(blockpos);
        entityvex.func_190653_a(20 * (30 + EntityEvoker.this.rand.nextInt(90)));
        EntityEvoker.this.world.spawnEntityInWorld(entityvex);
    }
}
 
Example 22
Project: Backmemed   File: EntityAnimal.java   Source Code and License 5 votes vote down vote up
/**
 * Checks if the entity's current position is a valid location to spawn this entity.
 */
public boolean getCanSpawnHere()
{
    int i = MathHelper.floor(this.posX);
    int j = MathHelper.floor(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor(this.posZ);
    BlockPos blockpos = new BlockPos(i, j, k);
    return this.world.getBlockState(blockpos.down()).getBlock() == this.spawnableBlock && this.world.getLight(blockpos) > 8 && super.getCanSpawnHere();
}
 
Example 23
Project: uniquecrops   File: ItemSeedsUC.java   Source Code and License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	
	IBlockState state = world.getBlockState(pos);
	if (SeedBehavior.canPlantCrop(stack, player, world, pos, side, cropBlock)) {
		--stack.stackSize;
		return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.PASS;
}
 
Example 24
Project: VanillaExtras   File: BlockBreaker.java   Source Code and License 5 votes vote down vote up
@Override
public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) {
	TileEntityBlockBreaker te = (TileEntityBlockBreaker) world.getTileEntity(pos);
	ItemStackHandler handler = (ItemStackHandler) te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
			null);
	return Utils.calculateRedstone(handler);
}
 
Example 25
Project: ExPetrum   File: CropEvent.java   Source Code and License 5 votes vote down vote up
public WaterConsumption(IExPCrop crop, World w, BlockPos at, long l, ImmutableCalendar c, float f, long l1, IFarmland of)
{
	super(crop, w, at, l, c);
	this.waterConsumed = f;
	this.ticksWaterConsumedFor = l1;
	this.farmland = of;
}
 
Example 26
Project: Backmemed   File: EntityLivingBase.java   Source Code and License 5 votes vote down vote up
protected void frostWalk(BlockPos pos)
{
    int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FROST_WALKER, this);

    if (i > 0)
    {
        EnchantmentFrostWalker.freezeNearby(this, this.world, pos, i);
    }
}
 
Example 27
Project: Backmemed   File: Block.java   Source Code and License 5 votes vote down vote up
@Deprecated
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
{
	if(Hacks.findMod(Freecam.class).isEnabled())
		return NULL_AABB;
	else
		return blockState.getBoundingBox(worldIn, pos);
}
 
Example 28
Project: pnc-repressurized   File: BlockElevatorBase.java   Source Code and License 5 votes vote down vote up
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
    super.onBlockAdded(world, pos, state);
    TileEntityElevatorBase elevatorBase = getCoreTileEntity(world, pos);
    if (elevatorBase != null) {
        elevatorBase.updateMaxElevatorHeight();
    }
}
 
Example 29
Project: harshencastle   File: BloodCollector.java   Source Code and License 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
		EnumFacing facing, float hitX, float hitY, float hitZ) {
	boolean flag = false;
	if(worldIn.getBlockState(pos).getBlock() instanceof BloodVessel)
	{
		TileEntityBloodVessel vessel = ((TileEntityBloodVessel)worldIn.getTileEntity(pos));
		switch (hand) {
		case MAIN_HAND:
			int tileEntityRemove = player.isSneaking() ? getNBT(player.getHeldItem(hand)).getInteger("Blood") : 1;
			if(vessel.canAdd(tileEntityRemove) && remove(player, hand, tileEntityRemove))
				vessel.change(tileEntityRemove);
			else if(vessel.canAdd(vessel.getPossibleAdd()) && remove(player, hand, vessel.getPossibleAdd()))
				vessel.change(vessel.getPossibleAdd());
			break;
		default:
			int tileEntityRemoveOffHand = player.isSneaking() ? Math.min(vessel.getPossibleRemove(), 50 - getNBT(player.getHeldItem(hand)).getInteger("Blood")) : 1;
			if(vessel.canRemove(tileEntityRemoveOffHand) && fill(player, hand, tileEntityRemoveOffHand))
				vessel.change(-tileEntityRemoveOffHand);
			break;
		}
	}
	else if(!flag && player.isSneaking() && worldIn.getBlockState(pos.offset(facing).down()).isSideSolid(worldIn, pos, EnumFacing.UP) && remove(player, hand, 1))
	{	
		worldIn.setBlockState(pos.offset(facing), HarshenBlocks.BLOOD_BLOCK.getDefaultState(), 3);
		worldIn.getBlockState(pos.offset(facing)).getBlock().onBlockAdded(worldIn, pos.offset(facing), worldIn.getBlockState(pos.offset(facing))); 
		worldIn.playSound(pos.getX(), pos.getY(), pos.getZ(), HarshenSounds.BLOOD_COLLECTOR_USE, SoundCategory.BLOCKS, 1f, new Random().nextFloat(), false);
	}
	return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
 
Example 30
Project: rezolve   File: RemoteShellGuiContainer.java   Source Code and License 5 votes vote down vote up
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {

    super.drawGuiContainerForegroundLayer(mouseX, mouseY);
    
    int rfBarX = 231;
    int rfBarY = 20;
    int rfBarHeight = 88;
    int rfBarWidth = 14;
    
    int usedHeight = rfBarHeight - (int)(this.entity.getEnergyStored(EnumFacing.DOWN) / (double)this.entity.getMaxEnergyStored(EnumFacing.DOWN) * rfBarHeight);
    Gui.drawRect(rfBarX, rfBarY, rfBarX + rfBarWidth, rfBarY + usedHeight, 0xFF000000);

    DatabaseServerEntity db = this.entity.getDatabase();
	this.nameField.setVisible(this.selectedMachine != null && db != null);
	
    if (this.selectedMachine != null) {
    	BlockPos pos = this.selectedMachine;
    	ItemStack stack = getItemFromBlock(this.entity, pos);
    	
    	if (stack != null) {
	    	String name = stack.getDisplayName();
	    	String stackName = stack.getDisplayName();
	    	String position = pos.getX()+", "+pos.getY()+", "+pos.getZ();
	    	
	    	if (!this.nameField.getVisible()) {
	    		this.fontRendererObj.drawString(stackName, 10, 126, 0xFF000000);
	    		this.fontRendererObj.drawString(position, 10, 141, 0xFF666666);
	    	} else {
	    		this.fontRendererObj.drawString(stackName, 10, 141, 0xFF666666);
	    		this.fontRendererObj.drawString(position, 10, 153, 0xFF666666);
	    	}
    	}
    } else {

   		this.fontRendererObj.drawString("Right click a machine for info.", 10, 126, 0xFF666666);
    }
}
 
Example 31
Project: Backmemed   File: BiomePlains.java   Source Code and License 5 votes vote down vote up
public BlockFlower.EnumFlowerType pickRandomFlower(Random rand, BlockPos pos)
{
    double d0 = GRASS_COLOR_NOISE.getValue((double)pos.getX() / 200.0D, (double)pos.getZ() / 200.0D);

    if (d0 < -0.8D)
    {
        int j = rand.nextInt(4);

        switch (j)
        {
            case 0:
                return BlockFlower.EnumFlowerType.ORANGE_TULIP;

            case 1:
                return BlockFlower.EnumFlowerType.RED_TULIP;

            case 2:
                return BlockFlower.EnumFlowerType.PINK_TULIP;

            case 3:
            default:
                return BlockFlower.EnumFlowerType.WHITE_TULIP;
        }
    }
    else if (rand.nextInt(3) > 0)
    {
        int i = rand.nextInt(3);
        return i == 0 ? BlockFlower.EnumFlowerType.POPPY : (i == 1 ? BlockFlower.EnumFlowerType.HOUSTONIA : BlockFlower.EnumFlowerType.OXEYE_DAISY);
    }
    else
    {
        return BlockFlower.EnumFlowerType.DANDELION;
    }
}
 
Example 32
Project: CustomWorldGen   File: WorldEvent.java   Source Code and License 5 votes vote down vote up
public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List<SpawnListEntry> oldList)
{
    super(world);
    this.pos = pos;
    this.type = type;
    if (oldList != null)
    {
        this.list = new ArrayList<SpawnListEntry>(oldList);
    }
    else
    {
        this.list = new ArrayList<SpawnListEntry>();
    }
}
 
Example 33
Project: Backmemed   File: EntityWitherSkull.java   Source Code and License 5 votes vote down vote up
/**
 * Explosion resistance of a block relative to this entity
 */
public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn)
{
    float f = super.getExplosionResistance(explosionIn, worldIn, pos, blockStateIn);
    Block block = blockStateIn.getBlock();

    if (this.isInvulnerable() && EntityWither.canDestroyBlock(block))
    {
        f = Math.min(0.8F, f);
    }

    return f;
}
 
Example 34
Project: Got-Wood   File: BlockTreeTap.java   Source Code and License 5 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) {
  EnumFacing enumfacing = facing.getOpposite();

  if(enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) {
    enumfacing = placer.getHorizontalFacing().getOpposite();
  }
  
  return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
Example 35
Project: Adventurers-Toolbox   File: MessageExtraBlockBreak.java   Source Code and License 5 votes vote down vote up
public MessageExtraBlockBreak(int entityID, BlockPos[] positions, int progress) {
	this.entityID = entityID;
	this.numBlocks = positions.length;
	this.progress = progress;
	this.positions = new int[numBlocks][3];
	
	for (int i = 0; i < numBlocks; i++) {
		BlockPos pos = positions[i];
		this.positions[i][0] = pos.getX();
		this.positions[i][1] = pos.getY();
		this.positions[i][2] = pos.getZ();
	}
}
 
Example 36
Project: Backmemed   File: BlockLever.java   Source Code and License 5 votes vote down vote up
private boolean checkCanSurvive(World p_181091_1_, BlockPos p_181091_2_, IBlockState p_181091_3_)
{
    if (this.canPlaceBlockAt(p_181091_1_, p_181091_2_))
    {
        return true;
    }
    else
    {
        this.dropBlockAsItem(p_181091_1_, p_181091_2_, p_181091_3_, 0);
        p_181091_1_.setBlockToAir(p_181091_2_);
        return false;
    }
}
 
Example 37
Project: PurificatiMagicae   File: BlockAbstractWallIfTablet.java   Source Code and License 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos)
{
    EnumFacing face = state.getValue(HorizontalFacingController.FACING_H);
    if (!canAttachToBlock(world, pos.offset(face.getOpposite()), face))
    {
        dropBlockAsItem(world, pos, state, 0);
        world.setBlockToAir(pos);
    }
}
 
Example 38
Project: Wurst-MC-1.12   File: ChestEspMod.java   Source Code and License 5 votes vote down vote up
public void closeChest(Container chest)
{
	if(openChest == null)
		return;
	
	boolean empty = true;
	for(int i = 0; i < chest.inventorySlots.size() - 36; i++)
		if(!WItem.isNull(chest.inventorySlots.get(i).getStack()))
		{
			empty = false;
			break;
		}
	
	BlockPos pos = openChest.getPos();
	if(empty)
	{
		if(!emptyChests.contains(pos))
			emptyChests.add(pos);
		
		nonEmptyChests.remove(pos);
	}else
	{
		if(!nonEmptyChests.contains(pos))
			nonEmptyChests.add(pos);
		
		emptyChests.remove(pos);
	}
	
	openChest = null;
}
 
Example 39
Project: Machines-and-Stuff   File: BlockBaseGenerator.java   Source Code and License 5 votes vote down vote up
public static void setState(boolean active, World worldIn, BlockPos pos) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    TileEntity tileentity = worldIn.getTileEntity(pos);
    worldIn.setBlockState(pos, iblockstate.getBlock().getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)).withProperty(isActive, active), 3);
    
    if(tileentity != null) {
        tileentity.validate();
        worldIn.setTileEntity(pos, tileentity);
        PacketHandler.INSTANCE.sendToAllAround(new MessageGenerator(tileentity), new NetworkRegistry.TargetPoint(worldIn.provider.getDimension(), tileentity.getPos().getX(), tileentity.getPos().getY(), tileentity.getPos().getZ(), 128d));
    }
}
 
Example 40
Project: CustomWorldGen   File: ForgeHooksClient.java   Source Code and License 5 votes vote down vote up
public static void orientBedCamera(IBlockAccess world, BlockPos pos, IBlockState state, Entity entity)
{
    Block block = state.getBlock();

    if (block != null && block.isBed(state, world, pos, entity))
    {
        glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F);
    }
}