本文整理汇总了Java中net.minecraft.inventory.InventoryBasic类的典型用法代码示例。如果您正苦于以下问题:Java InventoryBasic类的具体用法?Java InventoryBasic怎么用?Java InventoryBasic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InventoryBasic类属于net.minecraft.inventory包,在下文中一共展示了InventoryBasic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDeath
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
{
// iterate through the itemstacks in the villager's inventory
InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
// remove the stack from the inventory and spawn it in the world
ItemStack stack = inventory.getStackInSlot(i);
if (stack != ItemStack.EMPTY)
{
event.getEntityLiving().entityDropItem(stack, 0.0F);
}
}
}
}
示例2: onInventoryChanged
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
*/
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
int i = this.getHorseArmorIndexSynced();
boolean flag = this.isHorseSaddled();
this.updateHorseSlots();
if (this.ticksExisted > 20)
{
if (i == 0 && i != this.getHorseArmorIndexSynced())
{
this.playSound("mob.horse.armor", 0.5F, 1.0F);
}
else if (i != this.getHorseArmorIndexSynced())
{
this.playSound("mob.horse.armor", 0.5F, 1.0F);
}
if (!flag && this.isHorseSaddled())
{
this.playSound("mob.horse.leather", 0.5F, 1.0F);
}
}
}
示例3: EntityVillager
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public EntityVillager(World worldIn, int professionId)
{
super(worldIn);
this.villagerInventory = new InventoryBasic("Items", false, 8);
this.setProfession(professionId);
this.setSize(0.6F, 1.8F);
((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
this.tasks.addTask(1, new EntityAITradePlayer(this));
this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
this.tasks.addTask(2, new EntityAIMoveIndoors(this));
this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
this.tasks.addTask(6, new EntityAIVillagerMate(this));
this.tasks.addTask(7, new EntityAIFollowGolem(this));
this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
this.tasks.addTask(9, new EntityAIVillagerInteract(this));
this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
this.setCanPickUpLoot(true);
}
示例4: onInventoryChanged
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
*/
public void onInventoryChanged(InventoryBasic invBasic)
{
HorseArmorType horsearmortype = this.getHorseArmorType();
boolean flag = this.isHorseSaddled();
this.updateHorseSlots();
if (this.ticksExisted > 20)
{
if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType())
{
this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
}
else if (horsearmortype != this.getHorseArmorType())
{
this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
}
if (!flag && this.isHorseSaddled())
{
this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F);
}
}
}
示例5: writeInventoryBasicToNBT
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public static NBTTagCompound writeInventoryBasicToNBT(final NBTTagCompound tag, final InventoryBasic inventoryBasic) {
if (inventoryBasic.hasCustomInventoryName()) {
tag.setString("CustomName", inventoryBasic.getInventoryName());
}
final NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < inventoryBasic.getSizeInventory(); ++i) {
final ItemStack stackInSlot = inventoryBasic.getStackInSlot(i);
if (stackInSlot != null) {
final NBTTagCompound itemTag = new NBTTagCompound();
itemTag.setByte("Slot", (byte)i);
stackInSlot.writeToNBT(itemTag);
nbttaglist.appendTag((NBTBase)itemTag);
}
}
tag.setTag("Items", (NBTBase)nbttaglist);
return tag;
}
示例6: convert
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public TMultiPart convert(final World world, final BlockCoord pos) {
final Block id = world.getBlock(pos.x, pos.y, pos.z);
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
if (id != ExtraUtils.transferPipe && id != ExtraUtils.transferPipe2) {
return null;
}
if (id == ExtraUtils.transferPipe2) {
meta += 16;
}
if (meta != 9) {
return (TMultiPart)new PipePart(meta);
}
if (world.getTileEntity(pos.x, pos.y, pos.z) instanceof TileEntityFilterPipe) {
final InventoryBasic t = ((TileEntityFilterPipe)world.getTileEntity(pos.x, pos.y, pos.z)).items;
return (TMultiPart)new FilterPipePart(t);
}
return (TMultiPart)new FilterPipePart();
}
示例7: createListOfItemsInExpandableBackpack
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
private void createListOfItemsInExpandableBackpack()
{
if (!TombManyGraves.isExpandableBackpacksInstalled)
{
expandableBackpackItems = new ArrayList<>();
return;
}
NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("ExpandableBackpack");
ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
if (stack == null || stack.stackSize == 0)
{
expandableBackpackItems = new ArrayList<>();
return;
}
IInventory inventory = new InventoryBasic("temp",false,1);
inventory.setInventorySlotContents(0,stack);
expandableBackpackItems = createListFromInventory(inventory, EXPANDABLE);
}
示例8: createListOfItemsInEydamosBackpack
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
private void createListOfItemsInEydamosBackpack()
{
if (!TombManyGraves.isEydamosBackpacksInstalled)
{
eydamosBackpackItems = new ArrayList<>();
return;
}
NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("EydamosBackpack");
ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
if (stack == null || stack.stackSize == 0)
{
eydamosBackpackItems = new ArrayList<>();
return;
}
// BackpackSave instance = BackpackSave.loadBackpack(player.worldObj, stack, player, false);
//
// eydamosBackpackItems = createListFromInventory(instance, EYDAMOS);
// return;
IInventory inventory = new InventoryBasic("temp",false,1);
inventory.setInventorySlotContents(0, stack);
eydamosBackpackItems = createListFromInventory(inventory, EYDAMOS);
}
示例9: writeInventoryToNBT
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
* TileEntity, or perhaps an ItemStack.
*
* @param tag: The NBTTagCompound to write the inventory to.
* @param inventory: The inventory to write to the NBTTagCompound.
* @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
*/
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {
if (inventory.hasCustomName())
tag.setString("CustomName", inventory.getName());
final NBTTagList nbttaglist = new NBTTagList();
for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {
final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);
if (stackInSlot != null) {
final NBTTagCompound itemTag = new NBTTagCompound();
itemTag.setByte("Slot", (byte) slotCount);
stackInSlot.writeToNBT(itemTag);
nbttaglist.appendTag(itemTag);
}
}
tag.setTag("Items", nbttaglist);
return tag;
}
示例10: ContainerStorageCore
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public ContainerStorageCore(EntityPlayer player, World world, int x, int y, int z) {
this.tileEntity = ((TileEntityStorageCore) world.getTileEntity(new BlockPos(x, y, z)));
int startingY = 18;
int startingX = 8;
// the EZStorage slots
IInventory inventory = new InventoryBasic("title", false, this.rowCount() * 9);
for (int i = 0; i < this.rowCount(); i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventory, j + i * 9, startingX + j * 18, startingY + i * 18));
}
}
// the player inventory
bindPlayerInventory(player.inventory);
}
示例11: addPlayerSlots
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public void addPlayerSlots(InventoryPlayer player) {
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
}
}
for (int i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 109));
IInventory tableInventory = new InventoryBasic("Trash", false, 1) {
public void setInventorySlotContents(int index, ItemStack stack) {
}
};
this.addSlotToContainer(new Slot(tableInventory, 0, 80, 20));
}
示例12: writeInventoryToNBT
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
* TileEntity, or perhaps an ItemStack.
*
* @param tag: The NBTTagCompound to write the inventory to.
* @param inventory: The inventory to write to the NBTTagCompound.
* @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
*/
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {
if (inventory.hasCustomName()) {
tag.setString("CustomName", inventory.getName());
}
final NBTTagList nbttaglist = new NBTTagList();
for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {
final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);
if (!stackInSlot.isEmpty()) {
final NBTTagCompound itemTag = new NBTTagCompound();
itemTag.setByte("Slot", (byte) slotCount);
stackInSlot.writeToNBT(itemTag);
nbttaglist.appendTag(itemTag);
}
}
tag.setTag("Items", nbttaglist);
return tag;
}
示例13: readInventoryFromNBT
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Reads an inventory from an NBTTagCompound. Can be used to load an Inventory from a
* TileEntity or perhaps an ItemStak.
*
* @param tag: The NBTTagCompound to read the inventory data from.
* @param inventory: The inventory to set all of the inventory data to.
* @return InventoryBasic: The same instance of InventoryBasic that was passed to this
* method.
*/
public static InventoryBasic readInventoryFromNBT (NBTTagCompound tag, InventoryBasic inventory) {
if (tag.hasKey("CustomName", 8)) {
inventory.setCustomName(tag.getString("CustomName"));
}
final NBTTagList items = tag.getTagList("Items", 10);
for (int storedCount = 0; storedCount < items.tagCount(); storedCount++) {
final NBTTagCompound itemTag = items.getCompoundTagAt(storedCount);
final int slotCount = itemTag.getByte("Slot") & 0xFF;
if (slotCount >= 0 && slotCount < inventory.getSizeInventory()) {
inventory.setInventorySlotContents(slotCount, new ItemStack(itemTag));
}
}
return inventory;
}
示例14: onInventoryChanged
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
* Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
*/
public void onInventoryChanged(InventoryBasic par1InventoryBasic)
{
int var2 = this.func_110241_cb();
boolean var3 = this.isHorseSaddled();
this.func_110232_cE();
if (this.ticksExisted > 20)
{
if (var2 == 0 && var2 != this.func_110241_cb())
{
this.playSound("mob.horse.armor", 0.5F, 1.0F);
}
else if (var2 != this.func_110241_cb())
{
this.playSound("mob.horse.armor", 0.5F, 1.0F);
}
if (!var3 && this.isHorseSaddled())
{
this.playSound("mob.horse.leather", 0.5F, 1.0F);
}
}
}
示例15: EntityGreenVillager
import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public EntityGreenVillager(World worldIn, int professionId)
{
super(worldIn);
this.villagerInventory = new InventoryBasic("Items", false, 8);
this.setProfession(professionId);
this.setSize(0.6F, 1.8F);
((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
this.tasks.addTask(1, new EntityAITradeGreen(this));
this.tasks.addTask(1, new EntityAILookAtTradeGreen(this));
this.tasks.addTask(2, new EntityAIMoveIndoors(this));
this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
this.setCanPickUpLoot(true);
}