Beispiel #1
0
func (inv *FurnaceInventory) UnmarshalNbt(tag *nbt.Compound) (err os.Error) {
	if err = inv.Inventory.UnmarshalNbt(tag); err != nil {
		return
	}

	if burnTimeTag, ok := tag.Lookup("BurnTime").(*nbt.Short); !ok {
		return os.NewError("Bad or missing BurnTime tag in Furnace NBT")
	} else {
		inv.burnTime = types.Ticks(burnTimeTag.Value)

		// We don't know what the burnTimeMax was, as it is not stored, so taking
		// BurnTime for this value as well.
		inv.burnTimeMax = inv.burnTime
	}

	if cookTimeTag, ok := tag.Lookup("CookTime").(*nbt.Short); !ok {
		return os.NewError("Bad or missing CookTime tag in Furnace NBT")
	} else {
		inv.cookTime = types.Ticks(cookTimeTag.Value)
	}

	return nil
}
func (mobSpawner *mobSpawnerTileEntity) UnmarshalNbt(tag *nbt.Compound) (err os.Error) {
	if err = mobSpawner.tileEntity.UnmarshalNbt(tag); err != nil {
		return
	}

	if entityIdTag, ok := tag.Lookup("EntityId").(*nbt.String); !ok {
		return os.NewError("missing or incorrect type for MobSpawner EntityId")
	} else {
		mobSpawner.entityMobType = entityIdTag.Value
	}

	if delayTag, ok := tag.Lookup("Delay").(*nbt.Short); !ok {
		return os.NewError("missing or incorrect type for MobSpawner Delay")
	} else {
		mobSpawner.delay = types.Ticks(delayTag.Value)
	}

	return nil
}
Beispiel #3
0
package gamerules

import (
	"os"

	"chunkymonkey/types"
	"nbt"
)

const (
	furnaceSlotReagent = types.SlotId(0)
	furnaceSlotFuel    = types.SlotId(1)
	furnaceSlotOutput  = types.SlotId(2)
	furnaceNumSlots    = 3

	reactionDuration = types.Ticks(185)
	maxFuelPrg       = 255
)

type FurnaceInventory struct {
	Inventory
	burnTimeMax types.Ticks
	burnTime    types.Ticks
	cookTime    types.Ticks

	lastCurFuel           types.PrgBarValue
	lastReactionRemaining types.PrgBarValue
	ticksSinceUpdate      int
}

// NewFurnaceInventory creates a furnace inventory.