本文整理汇总了Java中net.minecraft.item.Item.getContainerItem方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getContainerItem方法的具体用法?Java Item.getContainerItem怎么用?Java Item.getContainerItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.Item
的用法示例。
在下文中一共展示了Item.getContainerItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import net.minecraft.item.Item; //导入方法依赖的package包/类
@Override
public void update() {
boolean needsSave = false;
boolean burning = this.isBurning();
if (this.isBurning()) {
this.furnaceBurnTime--;
}
if (!this.world.isRemote) {
ItemStack fuel = this.fuel.getStackInSlot(0);
ItemStack input = this.input.getStackInSlot(0);
if (this.totalCookTime == 0 && this.canSmelt()) {
this.totalCookTime = this.getCookTime(input);
needsSave = true;
}
if (this.isBurning() || (!fuel.isEmpty() && !input.isEmpty())) {
if (!this.isBurning() && this.canSmelt()) {
this.furnaceBurnTime = this.getBurnTime(fuel);
this.currentItemBurnTime = this.furnaceBurnTime;
if (this.isBurning()) {
needsSave = true;
if (!fuel.isEmpty()) {
Item item = fuel.getItem();
fuel.shrink(1);
if (fuel.isEmpty()) {
ItemStack container = item.getContainerItem(fuel);
this.fuel.setStackInSlot(0, container);
}
}
}
}
if (this.isBurning() && this.canSmelt()) {
this.cookTime++;
if (this.cookTime >= this.totalCookTime) {
this.cookTime = 0;
this.totalCookTime = this.getCookTime(input);
this.smelt();
needsSave = true;
}
} else {
this.cookTime = 0;
}
} else if (!this.isBurning() && this.cookTime > 0) {
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime);
}
if (burning != this.isBurning()) {
needsSave = true;
CraftiniumForge.setState(this.isBurning(), this.world, this.pos);
}
}
if (needsSave) {
this.markDirty();
}
}
示例2: update
import net.minecraft.item.Item; //导入方法依赖的package包/类
/**
* Like the old updateEntity(), except more generic.
*/
public void update()
{
boolean flag = this.isBurning();
boolean flag1 = false;
if (this.isBurning())
{
--this.furnaceBurnTime;
}
if (!this.world.isRemote)
{
ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(1);
if (this.isBurning() || !itemstack.func_190926_b() && !((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
{
if (!this.isBurning() && this.canSmelt())
{
this.furnaceBurnTime = getItemBurnTime(itemstack);
this.currentItemBurnTime = this.furnaceBurnTime;
if (this.isBurning())
{
flag1 = true;
if (!itemstack.func_190926_b())
{
Item item = itemstack.getItem();
itemstack.func_190918_g(1);
if (itemstack.func_190926_b())
{
Item item1 = item.getContainerItem();
this.furnaceItemStacks.set(1, item1 == null ? ItemStack.field_190927_a : new ItemStack(item1));
}
}
}
}
if (this.isBurning() && this.canSmelt())
{
++this.cookTime;
if (this.cookTime == this.totalCookTime)
{
this.cookTime = 0;
this.totalCookTime = this.getCookTime((ItemStack)this.furnaceItemStacks.get(0));
this.smeltItem();
flag1 = true;
}
}
else
{
this.cookTime = 0;
}
}
else if (!this.isBurning() && this.cookTime > 0)
{
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.totalCookTime);
}
if (flag != this.isBurning())
{
flag1 = true;
BlockFurnace.setState(this.isBurning(), this.world, this.pos);
}
}
if (flag1)
{
this.markDirty();
}
}