本文整理汇总了Java中net.minecraft.tileentity.TileEntityChest.getSizeInventory方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityChest.getSizeInventory方法的具体用法?Java TileEntityChest.getSizeInventory怎么用?Java TileEntityChest.getSizeInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.tileentity.TileEntityChest
的用法示例。
在下文中一共展示了TileEntityChest.getSizeInventory方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEmptySpace
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
private int getEmptySpace( final TileEntityChest chest, final ItemStack stack ) {
int temp = -1;
for ( int i = 0; i < chest.getSizeInventory(); i++ ) {
final ItemStack stack2 = chest.getStackInSlot( i );
if ( temp < 0 && (stack2 == null || stack2.stackSize == 0) ) {
temp = i;
} else if ( stack2 != null && stack.getItem() == stack2.getItem() && stack2.stackSize > 0
&& stack2.stackSize + stack.stackSize <= stack.getMaxStackSize() && !stack2.isItemDamaged()
&& !stack.isItemDamaged() && stack.getItemDamage() == stack2.getItemDamage() ) {
stack.stackSize += stack2.stackSize;
return i;
}
}
return temp;
}
示例2: checkRemoteStorage
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
public void checkRemoteStorage() {
if (remoteX != 0 && remoteY != 0 && remoteZ != 0 && !inventory.get(itemTradeSlot).isEmpty()) {
for (int i = itemStorageSlot1; i <= itemStorageSlot9; i++) {
if (inventory.get(i).isEmpty()) {
loadRemoteChunk(remoteX, remoteY, remoteZ);
TileEntity te = world.getTileEntity(new BlockPos(remoteX, remoteY, remoteZ));
if (te != null && te instanceof TileEntityChest) {
TileEntityChest chest = (TileEntityChest) te;
for (int j = 0; j < chest.getSizeInventory(); j++) {
if (inventory.get(i).isEmpty() && !chest.getStackInSlot(j).isEmpty()
&& chest.getStackInSlot(j).getItem() == inventory.get(itemTradeSlot).getItem()) {
inventory.set(i, chest.getStackInSlot(j));
chest.setInventorySlotContents(j, ItemStack.EMPTY);
checkSellingInventory();
}
}
}
}
}
}
}
示例3: convert
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
@Override
public boolean convert(EntityPlayer player, World world, int x, int y, int z)
{
TileEntityChest chest = (TileEntityChest)world.getTileEntity(x, y, z);
NBTTagCompound tag = new NBTTagCompound();
int newMeta = world.getBlockMetadata(x, y, z);
chest.writeToNBT(tag);
for(int i = 0; i < chest.getSizeInventory(); i++)
{
chest.setInventorySlotContents(i, null);
}
world.setBlock(x, y, z, SCContent.keypadChest, newMeta, 3);
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
((IOwnable) world.getTileEntity(x, y, z)).getOwner().set(player.getCommandSenderName(), player.getUniqueID().toString());
((TileEntityChest)world.getTileEntity(x, y, z)).readFromNBT(tag);
return true;
}
示例4: addInformation
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if(!(Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)))
list.add("Press SHIFT to see the content.");
else
{
boolean hasItems = false;
TileEntityChest chest = new TileEntityChest();
chest.readFromNBT(stack.getTagCompound());
for(int i = 0; i<chest.getSizeInventory(); i++)
{
ItemStack itemStack = chest.getStackInSlot(i);
if(itemStack != null)
{
list.add(itemStack.stackSize + "x" + itemStack.getDisplayName());
hasItems = true;
}
}
if(!hasItems)
list.add("Empty");
}
}
示例5: calculateHoardSize
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
public boolean calculateHoardSize(World world) {
// Only look for hoards in OverWorld!
if (world.provider.dimensionId != 0) {
this.player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chat.wildbill22_draco.hoardsOnlyWorkInOverWorld")));
return false;
}
hoardSize = 0;
boolean notJustCoins = false;
this.eggsInHoard.clear();
int size = hoardList.size();
for (int i = 0; i < size; i++) {
TileEntityChest chestEntity = (TileEntityChest) world.getTileEntity(hoardList.get(i).posX, hoardList.get(i).posY, hoardList.get(i).posZ);
if (chestEntity instanceof TileEntityTemporaryHoard) {
for (int j = 0; j < chestEntity.getSizeInventory(); j++) {
ItemStack itemStack = chestEntity.getStackInSlot(j);
if (itemStack != null) {
if (itemStack.getItem() != ModItems.goldCoin) {
notJustCoins = true;
if (itemStack.getItem() instanceof ItemDragonEgg) {
this.addEgg(((IDragonEggHandler)itemStack.getItem()).getEggName());
}
}
else {
hoardSize += itemStack.stackSize;
}
}
}
}
}
LogHelper.info("DragonPlayer load: Player has " + getHoardSize() + " coins.");
LogHelper.info("DragonPlayer load: Player has " + this.eggsInHoard.size() + " different eggs.");
if (hoardSize > 0) {
this.player.addStat(ModStats.firstGoldCoin, 1);
}
calculateLevel();
return notJustCoins;
}
示例6: onDeath
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
@Override
public void onDeath(DamageSource source)
{
super.onDeath(source);
if(worldObj.isRemote)return;
boolean placeChest = false;
if(!isTitan)return;
TileEntityChest chest = getLootChest();
int x = (int)posX;
int z = (int)posZ;
for(int y = (int)posY+1; y > 0; y --)
{
if(worldObj.getBlockMaterial(x, y, z).isSolid())
{
break;
}
if(tryPlaceChest(x, y, z, chest))
{
placeChest = true;
break;
}
}
if(!placeChest)
{
for(int a = 0; a < chest.getSizeInventory(); a ++)
{
ItemStack drop = chest.getStackInSlot(a);
if(drop != null)
this.entityDropItem(drop, 0);
}
}
}
示例7: locateStrongholds
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
private void locateStrongholds(EntityPlayer player, int amplifier) {
final NBTCoordinates playerLocation;
TileEntityChest closestChest = null;
float distance;
// Show direction to chests closer than this distance (up to 1000 blocks away with level 10 dragon)
float closestDistance = 10000.0F * amplifier * amplifier;
boolean foundVillagerSkull = false;
if (player != null){
playerLocation = new NBTCoordinates((int)player.posX, (int)player.posY, (int)player.posZ);
for (Object tileEntity : player.worldObj.loadedTileEntityList){
foundVillagerSkull = false;
if (tileEntity instanceof TileEntityChest){
TileEntityChest chestEntity = (TileEntityChest) tileEntity;
Object chestBlock = player.worldObj.getBlock(chestEntity.xCoord, chestEntity.yCoord, chestEntity.zCoord);
if (chestBlock instanceof BlockChest && chestEntity.yCoord < 45){
for (int j = 0; j < chestEntity.getSizeInventory(); j++) {
ItemStack itemStack = chestEntity.getStackInSlot(j);
if (itemStack != null) {
if (itemStack.getItem() == ModItems.villagerSkull) {
foundVillagerSkull = true;
break;
}
}
}
if (foundVillagerSkull) {
NBTCoordinates chestLocation = new NBTCoordinates(chestEntity.xCoord, chestEntity.yCoord, chestEntity.zCoord);
distance = chestLocation.getDistanceSquaredToChunkCoordinates(playerLocation);
if (distance < closestDistance){
closestDistance = distance;
closestChest = chestEntity;
}
}
}
}
}
if (closestChest != null){
// TODO: Animate with a beeping sound (or flashing) when pointing to chest!
LogHelper.info("Nearest chest at: " + closestChest.xCoord + "," + closestChest.yCoord + "," + closestChest.zCoord + "!");
player.addChatMessage(new ChatComponentText(
StatCollector.translateToLocal("chat.wildbill22_draco.foundPossibleStrongholdChest")));
player.addChatMessage(new ChatComponentText(
StatCollector.translateToLocalFormatted("chat.wildbill22_draco.chestIsLocated", closestChest.xCoord, closestChest.yCoord, closestChest.zCoord)));
}
else {
LogHelper.info("No stronghold chests nearby");
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chat.wildbill22_draco.noStrongholdChestsNearby")));
}
}
}
示例8: goldenEye
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
private void goldenEye(EntityPlayer player, int amplifier) {
final NBTCoordinates playerLocation;
TileEntityChest closestChest = null;
float distance;
// Show direction to chests closer than this distance (up to 1000 blocks away with level 10 dragon)
float closestDistance = 10000.0F * amplifier * amplifier;
boolean foundCoins = false;
if (player != null){
playerLocation = new NBTCoordinates((int)player.posX, (int)player.posY, (int)player.posZ);
for (Object tileEntity : player.worldObj.loadedTileEntityList){
foundCoins = false;
if (tileEntity instanceof TileEntityChest && !(tileEntity instanceof TileEntityTemporaryHoard)){
TileEntityChest chestEntity = (TileEntityChest) tileEntity;
Object chestBlock = player.worldObj.getBlock(chestEntity.xCoord, chestEntity.yCoord, chestEntity.zCoord);
if (chestBlock instanceof BlockChest){
for (int j = 0; j < chestEntity.getSizeInventory(); j++) {
ItemStack itemStack = chestEntity.getStackInSlot(j);
if (itemStack != null) {
if (itemStack.getItem() == ModItems.goldCoin) {
foundCoins = true;
break;
}
}
}
if (foundCoins) {
NBTCoordinates chestLocation = new NBTCoordinates(chestEntity.xCoord, chestEntity.yCoord, chestEntity.zCoord);
distance = chestLocation.getDistanceSquaredToChunkCoordinates(playerLocation);
if (distance < closestDistance){
closestDistance = distance;
closestChest = chestEntity;
}
}
}
}
}
if (closestChest != null){
// TODO: Animate with a beeping sound (or flashing) when pointing to chest!
LogHelper.info("Nearest chest at: " + closestChest.xCoord + "," + closestChest.yCoord + "," + closestChest.zCoord + "!");
player.addChatMessage(new ChatComponentText(
StatCollector.translateToLocalFormatted("chat.wildbill22_draco.foundGoldCoinsAt", closestChest.xCoord, closestChest.yCoord, closestChest.zCoord)));
}
else {
LogHelper.info("No gold coins found nearby");
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("chat.wildbill22_draco.noGoldCoinsFound")));
}
}
}
示例9: GenSkyblock
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
public GenSkyblock(EntityPlayer player, int i, int j, int k) {
ResinresinLoader skyBlock = new ResinresinLoader("skyBlock.resinresin");
skyBlock.generate(player.worldObj, i + -9, j, k + -9, true);
WarsMod.generateBlock(player.worldObj, i + 2, j + 65, k + -1, Blocks.SAND);
WarsMod.generateBlock(player.worldObj, i + 1, j + 65, k + -1, Blocks.SAND);
WarsMod.generateBlock(player.worldObj, i, j + 65, k + -1, Blocks.SAND);
WarsMod.generateBlock(player.worldObj, i + 3, j + 67, k + -2, Blocks.CHEST);
TileEntityChest chest2 = new TileEntityChest();
BlockPos chestPos1 = new BlockPos(i + 3, j + 67, k + -2);
player.worldObj.setTileEntity(chestPos1, chest2);
TileEntityChest tileentitychest = (TileEntityChest)player.worldObj.getTileEntity(chestPos1);
if (tileentitychest != null && tileentitychest.getSizeInventory() > 0) {
ItemStack itemstack = new ItemStack(Items.STRING, 12);
tileentitychest.setInventorySlotContents(0, itemstack);
ItemStack itemstack1 = new ItemStack(Items.BUCKET, 1);
tileentitychest.setInventorySlotContents(1, itemstack1);
ItemStack itemstack2 = new ItemStack(Items.BONE, 1);
tileentitychest.setInventorySlotContents(2, itemstack2);
ItemStack itemstack3 = new ItemStack(Items.REEDS, 1);
tileentitychest.setInventorySlotContents(3, itemstack3);
ItemStack itemstack4 = new ItemStack(Blocks.RED_MUSHROOM, 1);
tileentitychest.setInventorySlotContents(9, itemstack4);
ItemStack itemstack5 = new ItemStack(Blocks.ICE, 2);
tileentitychest.setInventorySlotContents(10, itemstack5);
ItemStack itemstack6 = new ItemStack(Items.PUMPKIN_SEEDS, 1);
tileentitychest.setInventorySlotContents(11, itemstack6);
ItemStack itemstack7 = new ItemStack(Blocks.BROWN_MUSHROOM, 1);
tileentitychest.setInventorySlotContents(18, itemstack7);
ItemStack itemstack8 = new ItemStack(Items.MELON, 1);
tileentitychest.setInventorySlotContents(19, itemstack8);
ItemStack itemstack9 = new ItemStack(Blocks.CACTUS, 1);
tileentitychest.setInventorySlotContents(20, itemstack9);
WarsMod.generateBlock(player.worldObj, i + 1, j + 1, k, Blocks.CHEST);
TileEntityChest chest3 = new TileEntityChest();
BlockPos chestPos2 = new BlockPos(i + 1, j + 1, k);
player.worldObj.setTileEntity(chestPos2, chest3);
TileEntityChest tileentitychest1 = (TileEntityChest)player.worldObj.getTileEntity(chestPos2);
if (tileentitychest1 != null && tileentitychest1.getSizeInventory() > 0) {
ItemStack itemstack15 = new ItemStack(Items.BOAT, 4);
tileentitychest1.setInventorySlotContents(0, itemstack15);
}
}
}
示例10: breakBlock
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的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_)
{
TileEntityChest var7 = (TileEntityChest)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_149955_b.nextFloat() * 0.8F + 0.1F;
float var11 = this.field_149955_b.nextFloat() * 0.8F + 0.1F;
EntityItem var14;
for (float var12 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; var9.stackSize > 0; p_149749_1_.spawnEntityInWorld(var14))
{
int var13 = this.field_149955_b.nextInt(21) + 10;
if (var13 > var9.stackSize)
{
var13 = var9.stackSize;
}
var9.stackSize -= var13;
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()));
float var15 = 0.05F;
var14.motionX = (double)((float)this.field_149955_b.nextGaussian() * var15);
var14.motionY = (double)((float)this.field_149955_b.nextGaussian() * var15 + 0.2F);
var14.motionZ = (double)((float)this.field_149955_b.nextGaussian() * var15);
if (var9.hasTagCompound())
{
var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
}
}
}
}
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_);
}
示例11: breakBlock
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的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_)
{
TileEntityChest tileentitychest = (TileEntityChest)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentitychest != null)
{
for (int i1 = 0; i1 < tileentitychest.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentitychest.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149955_b.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149955_b.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem))
{
int j1 = this.field_149955_b.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
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()));
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.field_149955_b.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.field_149955_b.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.field_149955_b.nextGaussian() * f3);
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
}
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_);
}
示例12: breakBlock
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的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)
{
TileEntityChest tileentitychest = (TileEntityChest)par1World.getBlockTileEntity(par2, par3, par4);
if (tileentitychest != null)
{
for (int j1 = 0; j1 < tileentitychest.getSizeInventory(); ++j1)
{
ItemStack itemstack = tileentitychest.getStackInSlot(j1);
if (itemstack != null)
{
float f = this.random.nextFloat() * 0.8F + 0.1F;
float f1 = this.random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = this.random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem))
{
int k1 = this.random.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
{
k1 = itemstack.stackSize;
}
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (double)((float)this.random.nextGaussian() * f3);
entityitem.motionY = (double)((float)this.random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)this.random.nextGaussian() * f3);
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
}
par1World.func_96440_m(par2, par3, par4, par5);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
示例13: dropChestContent
import net.minecraft.tileentity.TileEntityChest; //导入方法依赖的package包/类
public static void dropChestContent(Entity entity, ItemStack itemStack)
{
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
{
TileEntityChest tileEntity = getTileEntityFromItemStack(itemStack);
if (tileEntity != null)
{
double x = entity.posX;
double y = entity.posY + 1.5D;
double z = entity.posZ;
World world = entity.worldObj;
Random random = new Random();
for (int i1 = 0; i1 < tileEntity.getSizeInventory() + 1; ++i1)
{
ItemStack itemstack;
if(i1 == tileEntity.getSizeInventory())
itemstack = new ItemStack(Blocks.chest);
else
itemstack = tileEntity.getStackInSlot(i1);
if (itemstack != null)
{
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
{
int j1 = random.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (double)((float)random.nextGaussian() * f3);
entityitem.motionY = (double)((float)random.nextGaussian() * f3 + 0.2F);
entityitem.motionZ = (double)((float)random.nextGaussian() * f3);
entityitem.delayBeforeCanPickup = 20;
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
}
}
}
}