本文整理汇总了Java中net.minecraft.tileentity.TileEntityDispenser.setInventorySlotContents方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityDispenser.setInventorySlotContents方法的具体用法?Java TileEntityDispenser.setInventorySlotContents怎么用?Java TileEntityDispenser.setInventorySlotContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.tileentity.TileEntityDispenser
的用法示例。
在下文中一共展示了TileEntityDispenser.setInventorySlotContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generateDispenserContents
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public static void generateDispenserContents(Random random, List<WeightedRandomChestContent> listIn, TileEntityDispenser dispenser, int max)
{
for (int i = 0; i < max; ++i)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(random, listIn);
int j = weightedrandomchestcontent.minStackSize + random.nextInt(weightedrandomchestcontent.maxStackSize - weightedrandomchestcontent.minStackSize + 1);
if (weightedrandomchestcontent.theItemId.getMaxStackSize() >= j)
{
ItemStack itemstack1 = weightedrandomchestcontent.theItemId.copy();
itemstack1.stackSize = j;
dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), itemstack1);
}
else
{
for (int k = 0; k < j; ++k)
{
ItemStack itemstack = weightedrandomchestcontent.theItemId.copy();
itemstack.stackSize = 1;
dispenser.setInventorySlotContents(random.nextInt(dispenser.getSizeInventory()), 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)
{
tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
}
}
}
}
示例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.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);
}
}
}
}
示例5: func_149941_e
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl var5 = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser var6 = (TileEntityDispenser)var5.getBlockTileEntity();
if (var6 != null)
{
int var7 = var6.func_146017_i();
if (var7 < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack var8 = var6.getStackInSlot(var7);
IBehaviorDispenseItem var9 = this.func_149940_a(var8);
if (var9 != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack var10 = var9.dispense(var5, var8);
var6.setInventorySlotContents(var7, var10.stackSize == 0 ? null : var10);
}
}
}
}
示例6: func_150706_a
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public static void func_150706_a(Random p_150706_0_, WeightedRandomChestContent[] p_150706_1_, TileEntityDispenser p_150706_2_, int p_150706_3_)
{
for (int var4 = 0; var4 < p_150706_3_; ++var4)
{
WeightedRandomChestContent var5 = (WeightedRandomChestContent)WeightedRandom.getRandomItem(p_150706_0_, p_150706_1_);
int var6 = var5.theMinimumChanceToGenerateItem + p_150706_0_.nextInt(var5.theMaximumChanceToGenerateItem - var5.theMinimumChanceToGenerateItem + 1);
if (var5.theItemId.getMaxStackSize() >= var6)
{
ItemStack var7 = var5.theItemId.copy();
var7.stackSize = var6;
p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), var7);
}
else
{
for (int var9 = 0; var9 < var6; ++var9)
{
ItemStack var8 = var5.theItemId.copy();
var8.stackSize = 1;
p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), var8);
}
}
}
}
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:25,代码来源:WeightedRandomChestContent.java
示例7: func_149941_e
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.func_146017_i();
if (l < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例8: dispense
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
protected void dispense(World par1World, int par2, int par3, int par4)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(par1World, par2, par3, par4);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.getRandomStackFromInventory();
if (l < 0)
{
par1World.playAuxSFX(1001, par2, par3, par4, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehaviorForItemStack(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例9: dropperInsertHook
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public static boolean dropperInsertHook(World world, BlockPos pos, TileEntityDispenser dropper, int slot, ItemStack stack)
{
EnumFacing enumfacing = world.getBlockState(pos).getValue(BlockDropper.FACING);
BlockPos offsetPos = pos.offset(enumfacing);
TileEntity tileEntity = world.getTileEntity(offsetPos);
if (tileEntity == null)
return true;
if (!tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, enumfacing.getOpposite()))
return true;
IItemHandler capability = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, enumfacing.getOpposite());
ItemStack result = ItemHandlerHelper.insertItem(capability, ItemHandlerHelper.copyStackWithSize(stack, 1), false);
if (result == null)
{
result = stack.copy();
if (--result.stackSize == 0)
{
result = null;
}
}
else
{
result = stack.copy();
}
dropper.setInventorySlotContents(slot, result);
dropper.markDirty();
return false;
}
示例10: 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) {}
}
}
}
}
示例11: func_149941_e
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.func_146017_i();
if (l < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例12: generateDispenserContents
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public static void generateDispenserContents(Random p_150706_0_, WeightedRandomChestContent[] p_150706_1_, TileEntityDispenser p_150706_2_, int p_150706_3_)
{
for (int j = 0; j < p_150706_3_; ++j)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(p_150706_0_, p_150706_1_);
int k = weightedrandomchestcontent.theMinimumChanceToGenerateItem + p_150706_0_.nextInt(weightedrandomchestcontent.theMaximumChanceToGenerateItem - weightedrandomchestcontent.theMinimumChanceToGenerateItem + 1);
ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_150706_0_, p_150706_2_);
for (ItemStack item : stacks)
{
p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), item);
}
}
}
示例13: generateDispenserContents
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
/**
* Generates the Dispenser contents.
*/
public static void generateDispenserContents(Random par0Random, WeightedRandomChestContent[] par1ArrayOfWeightedRandomChestContent, TileEntityDispenser par2TileEntityDispenser, int par3)
{
for (int j = 0; j < par3; ++j)
{
WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent);
ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(par0Random, par2TileEntityDispenser);
for (ItemStack item : stacks)
{
par2TileEntityDispenser.setInventorySlotContents(par0Random.nextInt(par2TileEntityDispenser.getSizeInventory()), item);
}
}
}
示例14: setItemDispenser
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
private void setItemDispenser(int x, int z, int y, int metaDir, ItemStack itemstack) {
int[] pt = getIJKPt(x, z, y);
world.setBlock(pt[0], pt[1], pt[2], Blocks.dispenser, 0, 2);
world.setBlockMetadataWithNotify(pt[0], pt[1], pt[2], LADDER_DIR_TO_META[orientDirToBDir(metaDir)], 3);
try {
TileEntityDispenser tileentitychest = (TileEntityDispenser) world.getTileEntity(pt[0], pt[1], pt[2]);
if (itemstack != null && tileentitychest != null)
tileentitychest.setInventorySlotContents(random.nextInt(tileentitychest.getSizeInventory()), itemstack);
} catch (Exception e) {
wgt.master.logOrPrint("Error filling dispenser: " + e.toString(), "ERROR");
e.printStackTrace();
}
}
示例15: add
import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public static void add(IWorldEditor editor, Coord pos, int slot, ItemStack item){
TileEntity te = editor.getTileEntity(pos);
if(te == null) return;
if(!(te instanceof TileEntityDispenser)) return;
TileEntityDispenser dispenser = (TileEntityDispenser) te;
dispenser.setInventorySlotContents(slot, item);
}