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


Golang console.Text函数代码示例

本文整理汇总了Golang中github.com/thinkofdeath/steven/console.Text函数的典型用法代码示例。如果您正苦于以下问题:Golang Text函数的具体用法?Golang Text怎么用?Golang Text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: reinitBlocks

func reinitBlocks() {
	blockStateModels = map[pluginKey]*blockStateModel{}
	missingModel := findStateModel("steven", "missing_block")
	// Flatten the ids
	for _, bs := range blockSetsByID {
		if bs == nil {
			continue
		}
		for _, b := range bs.Blocks {
			br := reflect.ValueOf(b).Elem()
			// Liquids have custom rendering
			if _, ok := b.(*blockLiquid); ok || !b.Renderable() {
				continue
			}

			if model := findStateModel(b.Plugin(), b.ModelName()); model != nil {
				if variants := model.variant(b.ModelVariant()); variants != nil {
					br.FieldByName("BlockVariants").Set(
						reflect.ValueOf(variants),
					)
					continue
				}
				console.Text("Missing block variant (%s) for %s", b.ModelVariant(), b)
			} else {
				console.Text("Missing block model for %s", b)
			}
			br.FieldByName("BlockVariants").Set(
				reflect.ValueOf(missingModel.variant("normal")),
			)

		}
	}
}
开发者ID:suedadam,项目名称:steven,代码行数:33,代码来源:block.go

示例2: initBlocks

func initBlocks() {
	missingModel := findStateModel("steven", "missing_block")
	// Flatten the ids
	for _, bs := range blockSetsByID {
		if bs == nil {
			continue
		}
		for i, b := range bs.Blocks {
			br := reflect.ValueOf(b).Elem()
			br.FieldByName("Index").SetInt(int64(i))
			br.FieldByName("StevenID").SetUint(uint64(len(allBlocks)))
			allBlocks = append(allBlocks, b)
			if len(allBlocks) > math.MaxUint16 {
				panic("ran out of ids, time to do this correctly :(")
			}
			data := b.toData()
			if data != -1 {
				blocks[(bs.ID<<4)|data] = b
			}
			// Liquids have custom rendering
			if l, ok := b.(*blockLiquid); ok {
				if l.Lava {
					l.Tex = render.GetTexture("blocks/lava_still")
				} else {
					l.Tex = render.GetTexture("blocks/water_still")
				}
				continue
			}
			if !b.Renderable() {
				continue
			}

			if model := findStateModel(b.Plugin(), b.ModelName()); model != nil {
				if variants := model.variant(b.ModelVariant()); variants != nil {
					br.FieldByName("BlockVariants").Set(
						reflect.ValueOf(variants),
					)
					continue
				}
				if variants := model.matchPart(bs, b); variants != nil {
					br.FieldByName("BlockVariants").Set(
						reflect.ValueOf(variants),
					)
					continue
				}
				console.Text("Missing block variant (%s) for %s", b.ModelVariant(), b)
			} else {
				console.Text("Missing block model for %s", b)
			}
			br.FieldByName("BlockVariants").Set(
				reflect.ValueOf(missingModel.variant("normal")),
			)

		}
	}
}
开发者ID:num5,项目名称:steven,代码行数:56,代码来源:block.go

示例3: parseBlockStateVariant

func parseBlockStateVariant(plugin string, js realjson.RawMessage) *model {
	type jsType struct {
		Model  string
		X, Y   float64
		UVLock bool
		Weight *int
	}
	var data jsType
	err := json.Unmarshal(js, &data)
	if err != nil {
		console.Text("%s", err)
		return nil
	}
	var bdata jsModel
	err = loadJSON(plugin, "models/block/"+data.Model+".json", &bdata)
	if err != nil {
		return nil
	}
	bm := parseModel(plugin, &bdata)

	bm.y = data.Y
	bm.x = data.X
	bm.uvLock = data.UVLock
	if data.Weight != nil {
		bm.weight = *data.Weight
	} else {
		bm.weight = 1
	}
	return bm
}
开发者ID:ammaraskar,项目名称:steven,代码行数:30,代码来源:model.go

示例4: handleErrors

func handleErrors() {
handle:
	for {
		select {
		case err := <-Client.network.Error():
			if !connected {
				continue
			}
			connected = false

			Client.network.Close()
			console.Text("Disconnected: %s", err)
			// Reset the ready state to stop packets from being
			// sent.
			ready = false
			if err != errManualDisconnect && disconnectReason.Value == nil {
				txt := &format.TextComponent{Text: err.Error()}
				txt.Color = format.Red
				disconnectReason.Value = txt
			}

			if Client.entity != nil && Client.entityAdded {
				Client.entityAdded = false
				Client.entities.container.RemoveEntity(Client.entity)
			}

			setScreen(newServerList())
		default:
			break handle
		}
	}
}
开发者ID:suedadam,项目名称:steven,代码行数:32,代码来源:steven.go

示例5: getAssetIndex

func getAssetIndex() {
	console.Text("Getting asset index")
	defLocation := "./resources"
	resp, err := http.Get(fmt.Sprintf(assetIndexURL, assetsVersion))
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	if err := json.NewDecoder(resp.Body).Decode(&assets); err != nil {
		panic(err)
	}
	os.MkdirAll("./resources", 0777)
	f, err := os.Create(fmt.Sprintf("%s/%s.index", defLocation, assetsVersion))
	if err != nil {
		panic(err)
	}
	defer f.Close()
	json.NewEncoder(f).Encode(assets)
	console.Text("Got asset index for %s", assetsVersion)
}
开发者ID:num5,项目名称:steven,代码行数:20,代码来源:assets.go

示例6: parseModel

func parseModel(plugin string, data *jsModel) *model {
	var bm *model
	if data.Parent != "" && !strings.HasPrefix(data.Parent, "builtin/") {
		var pdata jsModel
		err := loadJSON(plugin, "models/"+data.Parent+".json", &pdata)
		if err != nil {
			console.Text("Error loading model %s: %s", data.Parent, err)
			loadJSON("steven", "models/block/missing_block.json", &pdata)
		}
		bm = parseModel(plugin, &pdata)
	} else {
		bm = &model{
			textureVars: map[string]string{},
			display:     map[string]modelDisplay{},
		}
		if strings.HasPrefix(data.Parent, "builtin/") {
			switch data.Parent {
			case "builtin/generated":
				bm.builtIn = builtInGenerated
			case "builtin/entity":
				bm.builtIn = builtInEntity
			case "builtin/compass":
				bm.builtIn = builtInCompass
			case "builtin/clock":
				bm.builtIn = builtInClock
			}
		}
	}

	if data.Textures != nil {
		for k, v := range data.Textures {
			bm.textureVars[k] = v
		}
	}

	for _, e := range data.Elements {
		bm.elements = append(bm.elements, parseBlockElement(e))
	}

	if data.AmbientOcclusion != nil {
		bm.ambientOcclusion = *data.AmbientOcclusion
		bm.aoSet = true
	} else if !bm.aoSet {
		bm.ambientOcclusion = true
	}

	if data.Display != nil {
		for k, v := range data.Display {
			bm.display[k] = v
		}
	}

	return bm
}
开发者ID:ammaraskar,项目名称:steven,代码行数:54,代码来源:model.go

示例7: handlePluginMessage

func (h handler) handlePluginMessage(channel string, r io.Reader, serverbound bool) {
	var pm reflect.Type
	var ok bool
	if serverbound {
		pm, ok = pluginMessagesServerbound[channel]
	} else {
		pm, ok = pluginMessagesClientbound[channel]
	}
	if !ok {
		console.Text("Unhandled plugin message %s", channel)
		return
	}
	p := reflect.New(pm).Interface().(pluginMessage)
	err := p.read(r)
	if err != nil {
		console.Text("Failed to handle plugin message %s: %s", channel, err)
		return
	}
	h.Handle(p)
}
开发者ID:num5,项目名称:steven,代码行数:20,代码来源:pluginmessage.go

示例8: AddPack

func AddPack(path string) {
	console.Text("Adding pack " + path)
	if err := resource.LoadZip(path); err != nil {
		fmt.Println("Failed to load pack", path)
		return
	}
	if resourcePacks.Value() != "" {
		resourcePacks.SetValue(resourcePacks.Value() + "," + path)
	} else {
		resourcePacks.SetValue(path)
	}
	reloadResources()
}
开发者ID:num5,项目名称:steven,代码行数:13,代码来源:resourcepacks.go

示例9: loadStateModel

func loadStateModel(key pluginKey) *blockStateModel {
	type partCase struct {
		When  map[string]interface{}
		Apply realjson.RawMessage
	}
	type jsType struct {
		Variants  map[string]realjson.RawMessage
		Multipart []partCase
	}

	var data jsType
	err := loadJSON(key.Plugin, fmt.Sprintf("blockstates/%s.json", key.Name), &data)
	if err != nil {
		console.Text("Error loading state %s: %s", key.Name, err)
		return nil
	}
	bs := &blockStateModel{}
	if data.Variants != nil {
		bs.variants = map[string]*blockVariants{}
		for k, v := range data.Variants {
			bs.variants[k] = parseModelList(key, v)
		}
	}
	if data.Multipart != nil {
		for _, part := range data.Multipart {
			p := &blockPart{}
			bs.multipart = append(bs.multipart, p)
			if part.When == nil {
				p.When = func(bs *BlockSet, block Block) bool { return true }
			} else if or, ok := part.When["OR"].([]interface{}); ok {
				var checks []func(bs *BlockSet, block Block) bool
				for _, rules := range or {
					checks = append(checks, parseBlockRuleList(rules.(map[string]interface{})))
				}
				p.When = func(bs *BlockSet, block Block) bool {
					for _, rule := range checks {
						if rule(bs, block) {
							return true
						}
					}
					return false
				}
			} else {
				p.When = parseBlockRuleList(part.When)
			}
			p.Apply = parseModelList(key, part.Apply)
		}
	}
	return bs
}
开发者ID:num5,项目名称:steven,代码行数:50,代码来源:model.go

示例10: loadBiomeColors

func loadBiomeColors(name string) *image.NRGBA {
	f, err := resource.Open("minecraft", fmt.Sprintf("textures/colormap/%s.png", name))
	if err != nil {
		console.Text("loading biome colors: %s", err)
		return image.NewNRGBA(image.Rect(0, 0, 256, 256))
	}
	defer f.Close()
	img, err := png.Decode(f)
	if err != nil {
		panic(err)
	}
	i, ok := img.(*image.NRGBA)
	if !ok {
		i = convertImage(img)
	}
	return i
}
开发者ID:num5,项目名称:steven,代码行数:17,代码来源:blocktint.go

示例11: RemovePack

func RemovePack(path string) {
	console.Text("Removing pack " + path)
	resource.RemovePack(path)
	var buf bytes.Buffer
	for _, pck := range strings.Split(resourcePacks.Value(), ",") {
		if pck != path {
			buf.WriteString(pck)
			buf.WriteRune(',')
		}
	}
	val := buf.String()
	if strings.HasPrefix(val, ",") {
		val = val[:len(val)-1]
	}
	resourcePacks.SetValue(val)
	reloadResources()
}
开发者ID:num5,项目名称:steven,代码行数:17,代码来源:resourcepacks.go

示例12: loadFontInfo

func loadFontInfo() {
	r, err := resource.Open("minecraft", "font/glyph_sizes.bin")
	if err != nil {
		console.Text("Error loading font info, %s", err)
		return
	}
	var data [0x10000]byte
	_, err = io.ReadFull(r, data[:])
	if err != nil {
		panic(err)
	}
	for i := range fontCharacterInfo {
		// Top nibble - start position
		// Bottom nibble - end position
		fontCharacterInfo[i].Start = int(data[i] >> 4)
		fontCharacterInfo[i].End = int(data[i]&0xF) + 1
	}
}
开发者ID:num5,项目名称:steven,代码行数:18,代码来源:font.go

示例13: loadStateModel

func loadStateModel(key pluginKey) *blockStateModel {
	type jsType struct {
		Variants map[string]realjson.RawMessage
	}

	var data jsType
	err := loadJSON(key.Plugin, fmt.Sprintf("blockstates/%s.json", key.Name), &data)
	if err != nil {
		console.Text("Error loading state %s: %s", key.Name, err)
		return nil
	}
	bs := &blockStateModel{
		variants: map[string]blockVariants{},
	}
	variants := data.Variants
	for k, v := range variants {
		var models blockVariants
		switch v[0] {
		case '[':
			var list []realjson.RawMessage
			json.Unmarshal(v, &list)
			for _, vv := range list {
				mdl := parseBlockStateVariant(key.Plugin, vv)
				if mdl != nil {
					models = append(models, precomputeModel(mdl))
				}
			}
		default:
			mdl := parseBlockStateVariant(key.Plugin, v)
			if mdl != nil {
				models = append(models, precomputeModel(mdl))
			}
		}
		bs.variants[k] = models
	}
	return bs
}
开发者ID:ammaraskar,项目名称:steven,代码行数:37,代码来源:model.go

示例14: reloadResources

func reloadResources() {
	console.Text("Bringing everything to a stop")
	for freeBuilders < maxBuilders {
		select {
		case pos := <-completeBuilders:
			freeBuilders++
			if c := chunkMap[chunkPosition{pos.X, pos.Z}]; c != nil {
				if s := c.Sections[pos.Y]; s != nil {
					s.building = false
				}
			}
		}
	}
	locale.Clear()
	render.LoadSkinBuffer()
	modelCache = map[string]*model{}
	console.Text("Reloading textures")
	render.LoadTextures()
	console.Text("Reloading biomes")
	loadBiomes()
	ui.ForceDraw()
	console.Text("Reloading blocks")
	reinitBlocks()
	console.Text("Marking chunks for rebuild")
	for _, c := range chunkMap {
		for _, s := range c.Sections {
			if s != nil {
				s.dirty = true
			}
		}
	}
	console.Text("Rebuilding static models")
	render.RefreshModels()
	console.Text("Reloading inventory")
	Client.playerInventory.Update()
}
开发者ID:num5,项目名称:steven,代码行数:36,代码来源:resourcepacks.go

示例15: ServerMessage

func (handler) ServerMessage(msg *protocol.ServerMessage) {
	console.Text("MSG(%d): %s", msg.Type, msg.Message.Value)
	Client.chat.Add(msg.Message)
}
开发者ID:suedadam,项目名称:steven,代码行数:4,代码来源:handler.go


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