本文整理匯總了Java中net.minecraft.dispenser.IBlockSource類的典型用法代碼示例。如果您正苦於以下問題:Java IBlockSource類的具體用法?Java IBlockSource怎麽用?Java IBlockSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IBlockSource類屬於net.minecraft.dispenser包,在下文中一共展示了IBlockSource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispense
import net.minecraft.dispenser.IBlockSource; //導入依賴的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: dispenseArmor
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return ItemStack.field_190927_a;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.splitStack(1);
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
return stack;
}
}
示例3: 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;
}
示例4: dispenseArmor
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return null;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
--stack.stackSize;
return stack;
}
}
示例5: 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;
}
示例6: 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;
}
示例7: dispenseStack
import net.minecraft.dispenser.IBlockSource; //導入依賴的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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: dispenseArmor
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.func_189992_e().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return null;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
--stack.stackSize;
return stack;
}
}
示例13: func_82487_b
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
protected ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
EnumFacing var3 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h());
int var4 = p_82487_1_.func_82623_d() + var3.func_82601_c();
int var5 = p_82487_1_.func_82622_e() + var3.func_96559_d();
int var6 = p_82487_1_.func_82621_f() + var3.func_82599_e();
AxisAlignedBB var7 = AxisAlignedBB.func_72332_a().func_72299_a((double)var4, (double)var5, (double)var6, (double)(var4 + 1), (double)(var5 + 1), (double)(var6 + 1));
List var8 = p_82487_1_.func_82618_k().func_82733_a(EntityLivingBase.class, var7, new EntitySelectorArmoredMob(p_82487_2_));
if(var8.size() > 0) {
EntityLivingBase var9 = (EntityLivingBase)var8.get(0);
int var10 = var9 instanceof EntityPlayer?1:0;
int var11 = EntityLiving.func_82159_b(p_82487_2_);
ItemStack var12 = p_82487_2_.func_77946_l();
var12.field_77994_a = 1;
var9.func_70062_b(var11 - var10, var12);
if(var9 instanceof EntityLiving) {
((EntityLiving)var9).func_96120_a(var11, 2.0F);
}
--p_82487_2_.field_77994_a;
return p_82487_2_;
} else {
return super.func_82487_b(p_82487_1_, p_82487_2_);
}
}
示例14: func_82487_b
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
protected ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
if(p_82487_2_.func_77960_j() == 15) {
EnumFacing var3 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h());
World var4 = p_82487_1_.func_82618_k();
int var5 = p_82487_1_.func_82623_d() + var3.func_82601_c();
int var6 = p_82487_1_.func_82622_e() + var3.func_96559_d();
int var7 = p_82487_1_.func_82621_f() + var3.func_82599_e();
if(ItemDye.func_96604_a(p_82487_2_, var4, var5, var6, var7)) {
if(!var4.field_72995_K) {
var4.func_72926_e(2005, var5, var6, var7, 0);
}
} else {
this.field_96461_b = false;
}
return p_82487_2_;
} else {
return super.func_82487_b(p_82487_1_, p_82487_2_);
}
}
示例15: func_82487_b
import net.minecraft.dispenser.IBlockSource; //導入依賴的package包/類
public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) {
EnumFacing var3 = BlockDispenser.func_100009_j_(p_82487_1_.func_82620_h());
World var4 = p_82487_1_.func_82618_k();
double var5 = p_82487_1_.func_82615_a() + (double)((float)var3.func_82601_c() * 1.125F);
double var7 = p_82487_1_.func_82617_b() + (double)((float)var3.func_96559_d() * 1.125F);
double var9 = p_82487_1_.func_82616_c() + (double)((float)var3.func_82599_e() * 1.125F);
int var11 = p_82487_1_.func_82623_d() + var3.func_82601_c();
int var12 = p_82487_1_.func_82622_e() + var3.func_96559_d();
int var13 = p_82487_1_.func_82621_f() + var3.func_82599_e();
Material var14 = var4.func_72803_f(var11, var12, var13);
double var15;
if(Material.field_76244_g.equals(var14)) {
var15 = 1.0D;
} else {
if(!Material.field_76249_a.equals(var14) || !Material.field_76244_g.equals(var4.func_72803_f(var11, var12 - 1, var13))) {
return this.field_96464_b.func_82482_a(p_82487_1_, p_82487_2_);
}
var15 = 0.0D;
}
EntityBoat var17 = new EntityBoat(var4, var5, var7 + var15, var9);
var4.func_72838_d(var17);
p_82487_2_.func_77979_a(1);
return p_82487_2_;
}