本文整理汇总了Java中net.minecraft.tileentity.TileEntityDispenser.getDispenseSlot方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityDispenser.getDispenseSlot方法的具体用法?Java TileEntityDispenser.getDispenseSlot怎么用?Java TileEntityDispenser.getDispenseSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.tileentity.TileEntityDispenser
的用法示例。
在下文中一共展示了TileEntityDispenser.getDispenseSlot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
}
}
}
}
示例2: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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.playEvent(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
{
tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
}
}
}
}
示例3: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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.playEvent(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
}
}
}
}
示例4: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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) {}
}
}
}
}
示例5: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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);
if (itemstack != null)
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);
if (itemstack1 != null && itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
示例6: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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.playEvent(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (!itemstack.func_190926_b())
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(tileentitydispenser, iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());
if (itemstack1.func_190926_b())
{
itemstack1 = itemstack.copy();
itemstack1.func_190918_g(1);
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
示例7: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的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.playEvent(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (itemstack != null && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(worldIn, pos, tileentitydispenser, i, itemstack))
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);
if (itemstack1 != null && itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
示例8: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
/** Custom dispense routines */
@Override
protected void dispense(World worldIn, BlockPos pos) {
BlockSourceImpl src = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tile = (TileEntityDispenser)src.getBlockTileEntity();
if (tile != null) {
int i = tile.getDispenseSlot();
if (i < 0) {
worldIn.playEvent(1001, pos, 0);
} else {
// get the active item from its slot
ItemStack itemstack = tile.getStackInSlot(i);
IBehaviorDispenseItem defaultbehavior = this.getBehavior(itemstack);
// make sure it's not regular dropper behavior
if (defaultbehavior != IBehaviorDispenseItem.DEFAULT_BEHAVIOR) {
ItemStack itemstack1 = null;
// replace vanilla behavior
if(defaultbehavior instanceof BehaviorProjectileDispense) {
itemstack1 = this.dispenseProjectile((BehaviorProjectileDispense)defaultbehavior, src, itemstack);
} else if(itemstack.getItem() instanceof ItemSplashPotion || itemstack.getItem() instanceof ItemLingeringPotion) {
itemstack1 = this.dispensePotion(src, itemstack);
} else if(itemstack.getItem() instanceof ItemFireball) {
itemstack1 = this.dispenseFireball(src, itemstack);
}
// revert to vanilla on failure
if(itemstack1 == null) {
itemstack1 = defaultbehavior.dispense(src, itemstack);
}
// update the inventory
tile.setInventorySlotContents(i, itemstack1.getCount() <= 0 ? ItemStack.EMPTY : itemstack1);
}
}
}
}