本文整理汇总了Java中net.minecraft.dispenser.IPosition类的典型用法代码示例。如果您正苦于以下问题:Java IPosition类的具体用法?Java IPosition怎么用?Java IPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPosition类属于net.minecraft.dispenser包,在下文中一共展示了IPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispense
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
@Override
public ItemStack dispense(IBlockSource block, final ItemStack stack) {
return new BehaviorProjectileDispense() {
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos) {
return new EntityLingeringPotion(world, pos.getX(), pos.getY(), pos.getZ(), stack.copy());
}
@Override
protected float func_82498_a() {
return super.func_82498_a() * 0.5F;
}
@Override
protected float func_82500_b() {
return super.func_82500_b() * 1.25F;
}
}.dispense(block, stack);
}
示例2: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的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: doDispense
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
public static void doDispense(World worldIn, ItemStack stack, int speed, EnumFacing facing, IPosition position) {
double d0 = position.getX();
double d1 = position.getY();
double d2 = position.getZ();
if (facing.getAxis() == EnumFacing.Axis.Y) {
d1 = d1 - 0.125D;
}
else {
d1 = d1 - 0.15625D;
}
EntityItem entityitem = new EntityItem(worldIn, d0, d1, d2, stack);
double d3 = worldIn.rand.nextDouble() * 0.1D + 0.2D;
entityitem.motionX = (double) facing.getFrontOffsetX() * d3;
entityitem.motionY = 0.20000000298023224D;
entityitem.motionZ = (double) facing.getFrontOffsetZ() * d3;
entityitem.motionX += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
entityitem.motionY += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
entityitem.motionZ += worldIn.rand.nextGaussian() * 0.007499999832361937D * (double) speed;
worldIn.spawnEntity(entityitem);
}
示例4: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
/**
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
World world = par1IBlockSource.getWorld();
IPosition iposition = BlockDispenser.func_149939_a(par1IBlockSource);
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
ItemStack stack = par2ItemStack.splitStack(1);
if (matchesItem(par2ItemStack)) {
// dispense item as projectile because the item matches
IProjectile iprojectile = this.getProjectileEntity(world, iposition, par2ItemStack);
iprojectile.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
world.spawnEntityInWorld((Entity) iprojectile);
} else {
// dispense item as item because it doesn't match
BehaviorDefaultDispenseItem.doDispense(world, stack, 6, enumfacing, iposition);
}
return par2ItemStack;
}
示例5: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的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;
}
示例6: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的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;
}
示例7: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的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.IPosition; //导入依赖的package包/类
/**
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
EnumFacing enumfacing = BlockTrap.getFacing(par1IBlockSource.getBlockMetadata());
IPosition iposition = BlockTrap.getIPositionFromBlockSource(par1IBlockSource);
double d0 = iposition.getX() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F);
double d1 = iposition.getY() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F);
double d2 = iposition.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 0.3F);
World world = par1IBlockSource.getWorld();
Random random = world.rand;
double d3 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetX();
double d4 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetY();
double d5 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetZ();
world.spawnEntityInWorld(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
par2ItemStack.splitStack(1);
return par2ItemStack;
}
示例9: getDispensePosition
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
/**
* Get the position where the dispenser at the given Coordinates should dispense to.
*/
public static IPosition getDispensePosition(IBlockSource coords)
{
EnumFacing enumfacing = getFacing(coords.getBlockMetadata());
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
return new PositionImpl(d0, d1, d2);
}
示例10: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
@Override
public ItemStack dispenseStack(IBlockSource block, final ItemStack stack) {
return new BehaviorProjectileDispense() {
@Override
protected IProjectile getProjectileEntity(World world, IPosition pos) {
EntityTippedArrow entity = new EntityTippedArrow(world, pos.getX(), pos.getY(), pos.getZ());
entity.canBePickedUp = 1;
entity.setEffect(TippedArrow.getEffect(stack));
return entity;
}
}.dispense(block, stack);
}
示例11: getDispensePosition
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
/**
* Get the position where the dispenser at the given Coordinates should dispense to.
*/
public static IPosition getDispensePosition(IBlockSource coords)
{
EnumFacing enumfacing = (EnumFacing)coords.getBlockState().getValue(FACING);
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
return new PositionImpl(d0, d1, d2);
}
示例12: getProjectileEntity
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
/** Get the projectile entity via reflection */
private IProjectile getProjectileEntity(BehaviorProjectileDispense standard, World world, IPosition pos, ItemStack stack) {
Method m = ACUtils.findMethod(BehaviorProjectileDispense.class, standard, new String[]{"getProjectileEntity", "func_82499_a"},
World.class, IPosition.class, ItemStack.class);
try {
return (IProjectile)m.invoke(standard, world, pos, stack);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例13: dispense
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
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.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
try{
IPosition iposition = BlockDispenser.getDispensePosition(blocksourceimpl);
BlockPos pos1 = new BlockPos(iposition.getX(), iposition.getY(), iposition.getZ());
Block block = Block.getBlockFromItem(itemstack.getItem());
if (worldIn.canBlockBePlaced(block,pos1,true,BlockPistonBase.getFacing(1),en,itemstack)){
ItemStack itemstack1 = this.dispenseStack(blocksourceimpl, itemstack, worldIn);
worldIn.playSoundEffect(iposition.getX(), iposition.getY(), iposition.getZ(), block.stepSound.getPlaceSound(), 1.0f, 1.0f);
if (block.getStateFromMeta(itemstack1.getMetadata())==worldIn.getBlockState(pos1))tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize == 0 ? null : itemstack1);
}}
catch (Exception e) {}
}
}
}
}
示例14: dispenseStack
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack,World worldIn)
{
try{
IPosition iposition = BlockDispenser.getDispensePosition(source);
ItemStack itemstack1 = stack.splitStack(1);
BlockPos pos = new BlockPos(iposition.getX(), iposition.getY(), iposition.getZ());
Block block;
block = Block.getBlockFromItem(itemstack1.getItem());
if( worldIn.canBlockBePlaced(block,pos,true,BlockPistonBase.getFacing(1),en,itemstack1)){
worldIn.setBlockState(pos, block.getStateFromMeta(itemstack1.getMetadata()));
}}
catch (Exception e) {return stack;}
return stack;
}
示例15: init
import net.minecraft.dispenser.IPosition; //导入依赖的package包/类
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
AugmentRegistry.registerAugment(new ItemStack(Items.GOLDEN_APPLE), new AugmentSlowRegen());
AugmentRegistry.registerAugment(new ItemStack(Items.GOLDEN_APPLE, 1, 1), new AugmentFastRegen());
AugmentRegistry.registerAugment(new ItemStack(Items.IRON_INGOT), new AugmentIron());
AugmentRegistry.registerAugment(new ItemStack(Blocks.OBSIDIAN), new AugmentObsidian());
AugmentRegistry.registerAugment(new ItemStack(Blocks.ANVIL), new AugmentAnvil());
AugmentRegistry.registerAugment(new ItemStack(Items.SKULL, 1, 1), new AugmentWither());
AugmentRegistry.registerAugment(new ItemStack(Items.SUGAR), new AugmentJitters());
AugmentRegistry.registerAugment(new ItemStack(skinsuit_mummy), new AugmentMummy());
OreDictionary.registerOre("book", squad_editor);
MilkRegistry.getInstance().registerMilk(new ItemStack(Items.MILK_BUCKET), new ItemStack(Items.BUCKET));
MilkRegistry.getInstance().registerMilk(new ItemStack(milk_bottle), new ItemStack(Items.GLASS_BOTTLE));
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(keychain_occupied, new DispenseBehaviorKeychain());
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(milk_bottle, new BehaviorProjectileDispense() {
@Override
@Nonnull
protected IProjectile getProjectileEntity(@Nonnull World worldIn, @Nonnull IPosition position, @Nonnull ItemStack stackIn) {
return new EntityMilkBottle(worldIn, position.getX(), position.getY(), position.getZ());
}
});
if (Loader.isModLoaded("ic2")) {
modCompat = new IC2Compat();
modCompat.init(event);
}
}