本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}