当前位置: 首页>>代码示例>>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;未经允许,请勿转载。