當前位置: 首頁>>代碼示例>>Java>>正文


Java IBlockSource.getWorld方法代碼示例

本文整理匯總了Java中net.minecraft.dispenser.IBlockSource.getWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java IBlockSource.getWorld方法的具體用法?Java IBlockSource.getWorld怎麽用?Java IBlockSource.getWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.dispenser.IBlockSource的用法示例。


在下文中一共展示了IBlockSource.getWorld方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fillContainer

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
/**
 * Picks up fluid in front of a Dispenser and fills a container with it.
 */
private ItemStack fillContainer(IBlockSource source, ItemStack stack)
{
    World world = source.getWorld();
    EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);

    ItemStack result = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
    if (result == null)
    {
        return super.dispenseStack(source, stack);
    }

    if (--stack.stackSize == 0)
    {
        stack.deserializeNBT(result.serializeNBT());
    }
    else if (((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(result) < 0)
    {
        this.dispenseBehavior.dispense(source, result);
    }

    return stack;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:DispenseFluidContainer.java

示例2: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
       World world = source.getWorld();
       BlockPos pos = source.getBlockPos();
       Vec3d pos2 = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
       Vec3d dir = this.getNearestTargetDirection(world, pos);
       if(dir == null) return null;
       IPosition ipos = new PositionImpl(pos2.x + dir.x * .75, pos2.y + dir.y * .75, pos2.z + dir.z * .75);
          double d0 = ipos.getX();
          double d1 = ipos.getY();
          double d2 = ipos.getZ();
          Random random = world.rand;
          double d3 = random.nextGaussian() * 0.05D + dir.x;
          double d4 = random.nextGaussian() * 0.05D + dir.y;
          double d5 = random.nextGaussian() * 0.05D + dir.z;
          world.spawnEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
          stack.splitStack(1);
          return stack;
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:20,代碼來源:TrackingDispenserBehavior.java

示例3: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack cartItemStack)
{
	EntityMinecartBase entityMinecartBase;
	World world = dispenser.getWorld();
	boolean cartSpawned = false;
	if(ItemStackUtils.isItemInstanceOf(cartItemStack, ItemMinecartBase.class))
	{
		ItemMinecartBase itemMinecartBase = (ItemMinecartBase)cartItemStack.getItem();
		entityMinecartBase = itemMinecartBase.getEntityFromItem(world, cartItemStack);

		if(entityMinecartBase != null)
		{
			EnumFacing enumfacing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
			BlockPos blockpos = dispenser.getBlockPos().offset(enumfacing);
			cartSpawned = itemMinecartBase.placeCart(cartItemStack, world, blockpos, entityMinecartBase);
		}
	}

	if(!cartSpawned)
	{
		cartItemStack = super.dispenseStack(dispenser, cartItemStack);
	}

	return cartItemStack;
}
 
開發者ID:BrassGoggledCoders,項目名稱:MoarCarts,代碼行數:26,代碼來源:CartDispenserBehavior.java

示例4: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  {
float y = 1.1F;
      World var3 = source.getWorld();
      IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
      EnumFacing var5 = BlockDispenser.getFacing(source.getBlockMetadata());
      
      IProjectile var6 = this.getProjectileEntity(var3, var4, stack.getItemDamage());
      if(var6 != null)
      {
      	var6.setThrowableHeading((double)var5.getFrontOffsetX(), 0.10000000149011612D*y, (double)var5.getFrontOffsetY(), this.func_82500_b(), this.func_82498_a());
      	var3.spawnEntityInWorld((Entity)var6);
      	stack.splitStack(1);
      }
      return stack;
  }
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:17,代碼來源:DispenseBombMF.java

示例5: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  {
float y = 1.1F;
      World var3 = source.getWorld();
      IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
      EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
      
      IProjectile iprojectile = this.getProjectileEntity(var3, var4, stack.getItemDamage());
      if(iprojectile != null)
      {
      	iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
      	var3.spawnEntityInWorld((Entity)iprojectile);
      	stack.splitStack(1);
      }
      return stack;
  }
 
開發者ID:TheAwesomeGem,項目名稱:MineFantasy,代碼行數:17,代碼來源:DispenseArrowMF.java

示例6: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
    World world = par1IBlockSource.getWorld();
    int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
    int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
    int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();

    if (par2ItemStack.hasTagCompound() && par2ItemStack.stackTagCompound.hasKey("ownerName")) {
        EntitySoulFragment soul = new EntitySoulFragment(world);
        soul.setPlayerName(par2ItemStack.stackTagCompound.getString("ownerName"));
        soul.setLocationAndAngles(i,j,k,0,0);
        world.spawnEntityInWorld(soul);
        System.err.println(soul);
        System.err.println(soul.playerName);
    }

    return par2ItemStack;
}
 
開發者ID:MagiciansArtificeTeam,項目名稱:Magicians-Artifice,代碼行數:20,代碼來源:DispenserSoulBehavior.java

示例7: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack) {
	if (NBTHelper.hasTag(stack, "identifier")) {
		World world = blockSource.getWorld();
		IPosition iposition = BlockDispenser.func_149939_a(blockSource);
		EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
		EntityNanoBotSwarm iprojectile = new EntityNanoBotSwarm(world, iposition.getX(), iposition.getY(), iposition.getZ());
		iprojectile.antennaIdentifier = UUID.fromString(NBTHelper.getString(stack, "identifier"));
		if (NBTHelper.hasTag(stack, "label"))
			iprojectile.label = NBTHelper.getString(stack, "label");
		iprojectile.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY()+0.1F), (double) enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
		world.spawnEntityInWorld(iprojectile);
		stack.splitStack(1);
	} else {
		return super.dispenseStack(blockSource, stack);
	}
	return stack;
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:18,代碼來源:ItemNanoSwarm.java

示例8: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    World world = source.getWorld();
    double d0 = source.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F);
    double d1 = source.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F);
    double d2 = source.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    Material material = world.getBlockState(blockpos).getMaterial();
    double d3;

    if (Material.WATER.equals(material))
    {
        d3 = 1.0D;
    }
    else
    {
        if (!Material.AIR.equals(material) || !Material.WATER.equals(world.getBlockState(blockpos.down()).getMaterial()))
        {
            return this.dispenseBehavior.dispense(source, stack);
        }

        d3 = 0.0D;
    }

    EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
    entityboat.setBoatType(this.boatType);
    entityboat.rotationYaw = enumfacing.getHorizontalAngle();
    world.spawnEntityInWorld(entityboat);
    stack.func_190918_g(1);
    return stack;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:33,代碼來源:Bootstrap.java

示例9: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    World world = source.getWorld();
    double d0 = source.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F);
    double d1 = source.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F);
    double d2 = source.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    Material material = world.getBlockState(blockpos).getMaterial();
    double d3;

    if (Material.WATER.equals(material))
    {
        d3 = 1.0D;
    }
    else
    {
        if (!Material.AIR.equals(material) || !Material.WATER.equals(world.getBlockState(blockpos.down()).getMaterial()))
        {
            return this.dispenseBehavior.dispense(source, stack);
        }

        d3 = 0.0D;
    }

    EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2);
    entityboat.setBoatType(this.boatType);
    entityboat.rotationYaw = enumfacing.getOpposite().getHorizontalAngle();
    world.spawnEntityInWorld(entityboat);
    stack.splitStack(1);
    return stack;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:36,代碼來源:Bootstrap.java

示例10: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
	EnumFacing enumfacing = source.getBlockState().getValue(BlockDispenser.FACING);
	double d0 = source.getX() + (double) enumfacing.getFrontOffsetX();
	double d1 = (double) ((float) (source.getBlockPos().getY() + enumfacing.getFrontOffsetY()) + 0.2F);
	double d2 = source.getZ() + (double) enumfacing.getFrontOffsetZ();

	EntityArmyMember entity;
	NBTTagCompound entNbt = stack.getTagCompound();
	if (entNbt != null) {
		if (entNbt.getString("SkeletonType").equals("skeleton_warrior"))
			entity = new EntitySkeletonWarrior(source.getWorld());
		else if (entNbt.getString("SkeletonType").equals("skeleton_converted"))
			entity = new EntityConvertedSkeleton(source.getWorld());
		else {
			entity = new EntityBabySkeleton(source.getWorld());
			if (!entNbt.getString("SkeletonType").equals("skeleton_baby"))
				Overlord.logError("Skeleton Type for keychain was " + entNbt.getString("SkeletonType"));
		}
		entity.readFromNBT(entNbt);

		entity.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, MathHelper.wrapDegrees(source.getWorld().rand.nextFloat() * 360.0F), 0.0F);
		entity.rotationYawHead = entity.rotationYaw;
		entity.renderYawOffset = entity.rotationYaw;
		source.getWorld().spawnEntity(entity);
		entity.playLivingSound();

		entity.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, MathHelper.wrapDegrees(source.getWorld().rand.nextFloat() * 360.0F), 0.0F);

		stack.shrink(1);
		if (stack.isEmpty())
			return new ItemStack(Overlord.keychain);
	}
	return stack;
}
 
開發者ID:The-Fireplace-Minecraft-Mods,項目名稱:Overlord,代碼行數:36,代碼來源:DispenseBehaviorKeychain.java

示例11: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
@Nonnull
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack par2ItemStack) {
	World world = source.getWorld();
	EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
	BlockPos pos = source.getBlockPos().offset(facing);
	Block block = world.getBlockState(pos).getBlock();
	if (block instanceof IPrecision) {
		boolean invert = ItemNBTHelper.getBoolean(par2ItemStack, "invertX", true);
		((IPrecision) block).adjust(world, pos, par2ItemStack, invert, facing.getOpposite());
		return par2ItemStack;
	}
	return super.dispenseStack(source, par2ItemStack);
}
 
開發者ID:TeamWizardry,項目名稱:TMT-Refraction,代碼行數:15,代碼來源:DispenserScrewDriverBehavior.java

示例12: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource at, ItemStack is) {
    World world = at.getWorld();
    IBlockState dispenserState = world.getBlockState(at.getBlockPos());
    EnumFacing enumfacing = dispenserState.getValue(BlockDispenser.FACING);
    double x = at.getX() + (double) ((float) enumfacing.getFrontOffsetX() * 1.125F);
    double y = at.getY() + (double) ((float) enumfacing.getFrontOffsetY() * 1.125F);
    double z = at.getZ() + (double) ((float) enumfacing.getFrontOffsetZ() * 1.125F);
    BlockPos target = at.getBlockPos().offset(enumfacing);
    IBlockState bs = world.getBlockState(target);
    Block block = bs.getBlock();
    double yOffset;

    if (BlockRailBase.isRailBlock(bs)) {
        yOffset = 0.0D;
    } else {
        if (block.getMaterial() != Material.air || !BlockRailBase.isRailBlock(world.getBlockState(target.down()))) {
            return this.behaviourDefaultDispenseItem.dispense(at, is);
        }

        yOffset = -1.0D;
    }

    EntityMinecart entityminecart = Core.registry.barrelCart.placeCart(null, is, at.getWorld(), new BlockPos((int) x, (int) y, (int) z));

    if (is.hasDisplayName()) {
        entityminecart.setCustomNameTag(is.getDisplayName());
    }
    return is;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:30,代碼來源:ItemMinecartDayBarrel.java

示例13: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
  World world = source.getWorld();
  // we want to place in front of the dispenser 
  //which is based on where its facing
  //changed in 1.10
  BlockPos posForPlant = UtilWorld.convertIposToBlockpos(BlockDispenser.getDispensePosition(source));
  //source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
  ItemStack returning = UtilPlantable.tryPlantSeed(world, posForPlant, stack);
  if (returning == null)
    return super.dispenseStack(source, stack);
  else
    return returning;
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:15,代碼來源:BehaviorPlantSeed.java

示例14: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{
    World world = blocksource.getWorld();
    IPosition pos = BlockDispenser.getDispensePosition(blocksource);
    EnumFacing face = BlockDispenser.getFacing(blocksource.getBlockMetadata());
    IProjectile projectile = getProjectileEntity(world, pos, itemstack);
    projectile.setThrowableHeading(face.getFrontOffsetX(), face.getFrontOffsetY() + getYVel(), face.getFrontOffsetZ(), getVelocity(), getDeviation());
    world.spawnEntityInWorld((Entity) projectile);
    itemstack.splitStack(1);
    return itemstack;
}
 
開發者ID:Archiving,項目名稱:ARKCraft-Code,代碼行數:13,代碼來源:DispenseWeaponProjectile.java

示例15: dispenseStack

import net.minecraft.dispenser.IBlockSource; //導入方法依賴的package包/類
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing var3 = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
    World var4 = par1IBlockSource.getWorld();
    double var5 = par1IBlockSource.getX() + (double)((float)var3.getFrontOffsetX() * 1.125F);
    double var7 = par1IBlockSource.getY() + (double)((float)var3.getFrontOffsetY() * 1.125F);
    double var9 = par1IBlockSource.getZ() + (double)((float)var3.getFrontOffsetZ() * 1.125F);
    int var11 = par1IBlockSource.getXInt() + var3.getFrontOffsetX();
    int var12 = par1IBlockSource.getYInt() + var3.getFrontOffsetY();
    int var13 = par1IBlockSource.getZInt() + var3.getFrontOffsetZ();
    Block var14 = var4.getBlock(var11, var12, var13);
    double var15;

    if (BlockRailBase.func_150051_a(var14))
    {
        var15 = 0.0D;
    }
    else
    {
        if (var14.getMaterial() != Material.air || !BlockRailBase.func_150051_a(var4.getBlock(var11, var12 - 1, var13)))
        {
            return this.behaviourDefaultDispenseItem.dispense(par1IBlockSource, par2ItemStack);
        }

        var15 = -1.0D;
    }

    EntityMinecart var17 = EntityMinecart.createMinecart(var4, var5, var7 + var15, var9, ((ItemMinecart)par2ItemStack.getItem()).minecartType);

    if (par2ItemStack.hasDisplayName())
    {
        var17.setMinecartName(par2ItemStack.getDisplayName());
    }

    var4.spawnEntityInWorld(var17);
    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:39,代碼來源:ItemMinecart.java


注:本文中的net.minecraft.dispenser.IBlockSource.getWorld方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。