本文整理匯總了Java中net.minecraft.tileentity.TileEntityHopper.getStackInSlot方法的典型用法代碼示例。如果您正苦於以下問題:Java TileEntityHopper.getStackInSlot方法的具體用法?Java TileEntityHopper.getStackInSlot怎麽用?Java TileEntityHopper.getStackInSlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.tileentity.TileEntityHopper
的用法示例。
在下文中一共展示了TileEntityHopper.getStackInSlot方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: canShellFitInHopper
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
public boolean canShellFitInHopper() {
if (worldObj.getTileEntity(xCoord, yCoord - 1, zCoord) instanceof TileEntityHopper) {
TileEntityHopper hopper = (TileEntityHopper) worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
for (int s = 0; s < hopper.getSizeInventory(); s++) {
if (hopper.getStackInSlot(s) == null) {
hopper.setInventorySlotContents(s, new ItemStack(InitItems.cartridge));
return true;
}
else if (hopper.getStackInSlot(s).getItem() == InitItems.cartridge && hopper.getStackInSlot(s).stackSize < hopper.getInventoryStackLimit()) {
hopper.getStackInSlot(s).stackSize++;
return true;
}
}
}
return false;
}
示例2: extractFuelFromHopper
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
/**
*
* @param cart
* @return true if there was a valid hopper (not necessarily if extracted an item)
*/
private boolean extractFuelFromHopper(EntityMinecart cart, BlockPos pos){
boolean foundHopper = false;
for(EnumFacing dir : EnumFacing.VALUES) {
BlockPos neighbor = pos;
for(int offsetTimes = 0; offsetTimes < (dir == EnumFacing.UP ? 2 : 1); offsetTimes++) {
neighbor = neighbor.offset(dir);
TileEntity te = cart.world.getTileEntity(neighbor);
if(te instanceof TileEntityHopper) {
EnumFacing hopperDir = cart.world.getBlockState(neighbor).getValue(BlockHopper.FACING);
if(hopperDir.getOpposite() == dir) {
TileEntityHopper hopper = (TileEntityHopper)te;
for(int i = 0; i < hopper.getSizeInventory(); i++) {
ItemStack stack = hopper.getStackInSlot(i);
if(!stack.isEmpty() && getFuelInv().isItemValidForSlot(0, stack)) {
ItemStack inserted = stack.copy();
inserted.setCount(1);
ItemStack left = ItemHandlerHelper.insertItemStacked(getEngineItemHandler(), inserted, false);
if(left.isEmpty()) {
stack.shrink(1);
hopper.markDirty();
return true;
}
}
}
foundHopper = true;
}
}
}
}
return foundHopper;
}
示例3: breakBlock
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
TileEntityHopper var7 = (TileEntityHopper)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (var7 != null)
{
for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
{
ItemStack var9 = var7.getStackInSlot(var8);
if (var9 != null)
{
float var10 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float var11 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float var12 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
while (var9.stackSize > 0)
{
int var13 = this.field_149922_a.nextInt(21) + 10;
if (var13 > var9.stackSize)
{
var13 = var9.stackSize;
}
var9.stackSize -= var13;
EntityItem var14 = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + var10), (double)((float)p_149749_3_ + var11), (double)((float)p_149749_4_ + var12), new ItemStack(var9.getItem(), var13, var9.getItemDamage()));
if (var9.hasTagCompound())
{
var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
}
float var15 = 0.05F;
var14.motionX = (double)((float)this.field_149922_a.nextGaussian() * var15);
var14.motionY = (double)((float)this.field_149922_a.nextGaussian() * var15 + 0.2F);
var14.motionZ = (double)((float)this.field_149922_a.nextGaussian() * var15);
p_149749_1_.spawnEntityInWorld(var14);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
示例4: breakBlock
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
@Override
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
TileEntityHopper tileentityhopper = (TileEntityHopper)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentityhopper != null)
{
for (int i1 = 0; i1 < tileentityhopper.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityhopper.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149922_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)this.field_149922_a.nextGaussian() * f3;
entityitem.motionY = (float)this.field_149922_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)this.field_149922_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
示例5: breakBlock
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
TileEntityHopper tileentityhopper = (TileEntityHopper)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentityhopper != null)
{
for (int i1 = 0; i1 < tileentityhopper.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityhopper.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149922_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149922_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.field_149922_a.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.field_149922_a.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.field_149922_a.nextGaussian() * f3);
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
示例6: breakBlock
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的package包/類
/**
* Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
* different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
* metadata
*/
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
{
TileEntityHopper tileentityhopper = (TileEntityHopper)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentityhopper != null)
{
for (int j1 = 0; j1 < tileentityhopper.getSizeInventory(); ++j1)
{
ItemStack itemstack = tileentityhopper.getStackInSlot(j1);
if (itemstack != null)
{
float f = this.field_94457_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_94457_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_94457_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int k1 = this.field_94457_a.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
{
k1 = itemstack.stackSize;
}
itemstack.stackSize -= k1;
EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.field_94457_a.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.field_94457_a.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.field_94457_a.nextGaussian() * f3);
par1World.spawnEntityInWorld(entityitem);
}
}
}
par1World.func_96440_m(par2, par3, par4, par5);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}