当前位置: 首页>>代码示例>>Golang>>正文


Golang Compound.Set方法代码示例

本文整理汇总了Golang中github.com/huin/chunkymonkey/nbt.Compound.Set方法的典型用法代码示例。如果您正苦于以下问题:Golang Compound.Set方法的具体用法?Golang Compound.Set怎么用?Golang Compound.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/huin/chunkymonkey/nbt.Compound的用法示例。


在下文中一共展示了Compound.Set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: MarshalNbt

func (inv *Inventory) MarshalNbt(tag *nbt.Compound) (err error) {
	occupiedSlots := 0
	for i := range inv.slots {
		if inv.slots[i].Count > 0 {
			occupiedSlots++
		}
	}

	itemList := &nbt.List{nbt.TagCompound, make([]nbt.ITag, 0, occupiedSlots)}
	for i := range inv.slots {
		slot := &inv.slots[i]
		if slot.Count > 0 {
			slotTag := nbt.NewCompound()
			slotTag.Set("Slot", &nbt.Byte{int8(i)})
			if err = slot.MarshalNbt(slotTag); err != nil {
				return
			}
			itemList.Value = append(itemList.Value, slotTag)
		}
	}

	tag.Set("Items", itemList)

	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:25,代码来源:inventory.go

示例2: MarshalNbt

func (music *musicTileEntity) MarshalNbt(tag *nbt.Compound) (err error) {
	if err = music.tileEntity.MarshalNbt(tag); err != nil {
		return
	}

	tag.Set("id", &nbt.String{"Music"})
	tag.Set("note", &nbt.Byte{int8(music.note)})

	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:10,代码来源:block_music.go

示例3: MarshalNbt

func (recordPlayer *recordPlayerTileEntity) MarshalNbt(tag *nbt.Compound) (err error) {
	if err = recordPlayer.tileEntity.MarshalNbt(tag); err != nil {
		return
	}

	tag.Set("id", &nbt.String{"RecordPlayer"})
	tag.Set("Record", &nbt.Int{recordPlayer.record})

	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:10,代码来源:block_recordplayer.go

示例4: MarshalNbt

func (item *Item) MarshalNbt(tag *nbt.Compound) (err error) {
	if err = item.PointObject.MarshalNbt(tag); err != nil {
		return
	}
	tag.Set("id", &nbt.String{"Item"})
	tag.Set("Item", &nbt.Compound{map[string]nbt.ITag{
		"id":     &nbt.Short{int16(item.ItemTypeId)},
		"Count":  &nbt.Byte{int8(item.Count)},
		"Damage": &nbt.Short{int16(item.Data)},
	}})
	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:12,代码来源:item.go

示例5: MarshalNbt

func (object *Object) MarshalNbt(tag *nbt.Compound) (err error) {
	objTypeName, ok := ObjNameByType[object.ObjTypeId]
	if !ok {
		return errors.New("unknown object type")
	}
	if err = object.PointObject.MarshalNbt(tag); err != nil {
		return
	}
	tag.Set("id", &nbt.String{objTypeName})
	// TODO unknown fields
	return
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:12,代码来源:object.go

示例6: MarshalNbt

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

	tag.Set("id", &nbt.String{"MobSpawner"})
	tag.Set("EntityId", &nbt.String{mobSpawner.entityMobType})
	tag.Set("Delay", &nbt.Short{int16(mobSpawner.delay)})

	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:11,代码来源:block_mobspawner.go

示例7: MarshalNbt

func (sign *signTileEntity) MarshalNbt(tag *nbt.Compound) (err error) {
	if err = sign.tileEntity.MarshalNbt(tag); err != nil {
		return
	}

	tag.Set("id", &nbt.String{"Sign"})
	tag.Set("Text1", &nbt.String{sign.text[0]})
	tag.Set("Text2", &nbt.String{sign.text[1]})
	tag.Set("Text3", &nbt.String{sign.text[2]})
	tag.Set("Text4", &nbt.String{sign.text[3]})

	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:13,代码来源:block_sign.go

示例8: MarshalNbt

func (inv *FurnaceInventory) MarshalNbt(tag *nbt.Compound) (err error) {
	tag.Set("id", &nbt.String{"Furnace"})
	tag.Set("BurnTime", &nbt.Short{int16(inv.burnTime)})
	tag.Set("CookTime", &nbt.Short{int16(inv.cookTime)})
	return inv.Inventory.MarshalNbt(tag)
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:6,代码来源:inv_furnace.go

示例9: MarshalNbt

func (mob *Mob) MarshalNbt(tag *nbt.Compound) (err error) {
	mobTypeName, ok := MobNameByType[mob.mobType]
	if !ok {
		return errors.New("unknown mob type")
	}
	if err = mob.PointObject.MarshalNbt(tag); err != nil {
		return
	}
	tag.Set("id", &nbt.String{mobTypeName})
	tag.Set("Rotation", &nbt.List{nbt.TagFloat, []nbt.ITag{
		&nbt.Float{float32(mob.look.Yaw)},
		&nbt.Float{float32(mob.look.Pitch)},
	}})
	// TODO
	tag.Set("Air", &nbt.Short{0})
	tag.Set("AttackTime", &nbt.Short{0})
	tag.Set("DeathTime", &nbt.Short{0})
	tag.Set("FallDistance", &nbt.Float{0})
	tag.Set("Fire", &nbt.Short{0})
	tag.Set("Health", &nbt.Short{0})
	tag.Set("HurtTime", &nbt.Short{0})
	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:23,代码来源:mob.go

示例10: MarshalNbt

func (inv *DispenserInventory) MarshalNbt(tag *nbt.Compound) (err error) {
	tag.Set("id", &nbt.String{"Trap"})
	return inv.Inventory.MarshalNbt(tag)
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:4,代码来源:inv_dispenser.go

示例11: MarshalNbt

func (s *Slot) MarshalNbt(tag *nbt.Compound) (err error) {
	tag.Set("id", &nbt.Short{int16(s.ItemTypeId)})
	tag.Set("Count", &nbt.Byte{int8(s.Count)})
	tag.Set("Damage", &nbt.Short{int16(s.Data)})
	return nil
}
开发者ID:huin,项目名称:chunkymonkey,代码行数:6,代码来源:slot.go


注:本文中的github.com/huin/chunkymonkey/nbt.Compound.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。