本站文本内容除另有声明外,转载时均必须注明出处,并遵守CC BY-NC-SA 3.0协议。(转载须知
本站是中文Minecraft Wiki的镜像站,与Mojang Studios、Weird Gloop没有从属关系。(免责声明

全站通知:

模块:Autovalue builders

来自我的世界地下城WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

本模块用于为挖掘爆炸创造模式物品栏窒息活塞音符盒地图等条目提供自动值项目表。

用法

依赖项

另见

实现
主要用途
分类
数据
数据名称 数据模块 缺失值的维护分类
方块ID
block id
Module:Block id values
Module:Block id values BE
Category:缺失方块ID(0)
物品ID
item id
Module:Item id values
Module:Item id values BE
Category:缺失物品ID(2)
实体ID
entity id
Module:Entity id values
Module:Entity id values BE
Category:缺失实体ID(57)
魔咒ID
enchantment id
Module:Enchantment id values
Module:Enchantment id values BE
Category:缺失魔咒ID(0)
状态效果ID
status effect id
Module:Status effect id values
Module:Status effect id values BE
Category:缺失状态效果ID(0)
生物群系ID
biome id
Module:Biome id values
Module:Biome id values BE
Category:缺失生物群系ID(0)
合适挖掘工具
breaking tool
Module:Breaking tool values
Module:Breaking tool values BE
Category:缺失合适挖掘工具(0)
硬度
hardness
Module:Hardness values
Module:Hardness values BE
Category:缺失硬度(0)
爆炸抗性
blast resistance
Module:Blast resistance values
Module:Blast resistance values BE
Category:缺失爆炸抗性(0)
材料
material
Module:Autovalue/material mapping
Module:Material values
Category:缺失材料(0)
基岩版材料
material BE
Module:Autovalue/material BE mapping
Module:Material BE values
Category:缺失基岩版材料(0)
最大堆叠
maxstack
Module:Maxstack values
Module:Maxstack values BE
Category:缺失最大堆叠(0)
稀有度
rarity
Module:Autovalue/rarity mapping
Module:Rarity values
Module:Rarity values BE
创造标签页
creative tab
Module:Autovalue/creative tab mapping
Module:Creative tab values
Category:缺失创造标签页(2)
创造分类
creative category
Module:Autovalue/creative category mapping
Module:Creative category values
Category:缺失创造分类(2)
窒息生物
suffocating
Module:Suffocating values
Module:Suffocating values BE
Category:缺失窒息生物(0)
红石导体
redstone conductor
Module:Redstone conductor values
Module:Redstone conductor values BE
Category:缺失红石导体(0)
可替代
replaceable
Module:Replaceable values
Module:Replaceable values BE
Category:缺失可替代(0)
固体方块
solid
Module:Solid values
Module:Solid values BE
Category:缺失固体方块(0)
引燃几率
flame odds
Module:Flame odds values
Module:Flame odds values BE
Category:缺失引燃几率(0)
烧毁几率
burn odds
Module:Burn odds values
Module:Burn odds values BE
Category:缺失烧毁几率(0)
熔岩可燃性
lava flammable
Module:Lava flammable values
Module:Lava flammable values BE
Category:缺失熔岩可燃性(0)
活塞推动行为
push reaction
Module:Autovalue/push reaction mapping
Module:Push reaction values
Module:Push reaction values BE
Category:缺失活塞推动行为(0)
地图颜色
map color
Module:Autovalue/map color mapping
Module:Map color values
Module:Map color values BE
Category:缺失地图颜色(0)
乐器
instrument
Module:Autovalue/instrument mapping
Module:Instrument values
Module:Instrument values BE
Category:缺失乐器(0)
阻力系数
friction
Module:Friction values
Module:Friction values BE
速度乘数
speed factor
Module:Speed factor values
Module:Speed factor values BE
耐久度
durability
Module:Durability values
Module:Durability values BE
烧炼时间
burn duration
Module:Burn duration values
Module:Burn duration values BE
食物属性
food properties
Module:Food properties values
Module:Food properties values BE
生物类型
mob type
Module:Autovalue/mob type mapping
Module:Mob type values
Category:缺失生物类型(0)
???
mob category
Module:Autovalue/mob category mapping
Module:Mob category values

entity family
Module:Autovalue/entity family mapping
Module:Entity family values
Category:缺失族(0)
种群控制
population control
Module:Autovalue/population control mapping
Module:Population control values
Category:缺失种群控制(0)
魔咒附魔台可用性
enchantment enchanting table applicable
Module:Autovalue/enchantment enchanting table applicable mapping
Module:Autovalue/enchantment enchanting table applicable mapping BE
Module:Enchantment enchanting table applicable values
Module:Enchantment enchanting table applicable values BE
Category:缺失魔咒附魔台可用性(0)
魔咒铁砧可用性
enchantment avnil applicable
Module:Autovalue/enchantment avnil applicable mapping
Module:Autovalue/enchantment avnil applicable mapping BE
Module:Enchantment avnil applicable values
Module:Enchantment avnil applicable values BE
Category:缺失魔咒铁砧可用性(0)
魔咒类别
enchantment category
Module:Autovalue/enchantment category mapping
Module:Enchantment category values
Category:缺失魔咒类别(0)
魔咒附魔等级
enchantment cost
Module:Enchantment cost values
Module:Enchantment cost values BE
Category:缺失魔咒附魔等级(0)
魔咒出现条件
enchantment flag
Module:Autovalue/enchantment flag mapping
Module:Enchantment flag values
Category:缺失魔咒出现条件(0)
魔咒不共存魔咒
enchantment incompatible
Module:Autovalue/enchantment incompatible mapping
Module:Enchantment incompatible values
Category:缺失魔咒不共存魔咒(0)
魔咒最大等级
enchantment max level
Module:Enchantment max level values Category:缺失魔咒最大等级(0)
魔咒稀有度
enchantment rarity
Module:Autovalue/enchantment rarity mapping
Module:Enchantment rarity values
Category:缺失魔咒稀有度(0)
local p = {}
local Autovalue = require( [[Module:Autovalue]] )
local ProcessArgs = require( [[Module:ProcessArgs]] )

function p.allGroups()
	local groups = mw.loadData('Module:Autovalue/groups')
	local lines = {}
	table.insert(lines, '{| class="wikitable"')
	table.insert(lines, '|+ 集合')
	table.insert(lines, '! 集合名称')
	table.insert(lines, '! 包含的项目')
	for k, v in pairs( groups ) do
		table.insert(lines, '|-')
		table.insert(lines, '| [[' .. k .. ']]')
		local codes = {}
		for i, str in ipairs( v ) do
			if str:find('^[a-z0-9_]+$') then
				table.insert(codes, '<code>' .. str .. '</code>')
			else
				table.insert(codes, '<code>[[' .. str .. ']]</code>')
			end
		end
		table.insert(lines, '| ' .. table.concat(codes))
	end
	table.insert(lines, '|}')
	return table.concat(lines, '\n')
end

local function tableKeys(targetTable)
	local entries = {}
	for k, v in pairs( targetTable ) do
		table.insert(entries, k)
	end
	return entries
end

local function tableValues(targetTable)
	local entries = {}
	for k, v in pairs( targetTable ) do
		table.insert(entries, v)
	end
	return entries
end

local function joinObjectTable(...)
	local entries = {}
	for i = 1, select('#', ... ) do
		local t = select(i, ... )
		for k, v in pairs( t ) do
			entries[k] = v
		end
	end
	return entries
end

local function joinArrayTable(...)
	local entries = {}
	for i = 1, select('#', ... ) do
		local t = select(i, ... )
		for i, v in ipairs( t ) do
			table.insert(entries, v)
		end
	end
	return entries
end


local function arrayTableDuplicate(targetTable)
	local entries = {}
	local seenValues = {}
	for i, v in ipairs( targetTable ) do
		if not seenValues[v] then
			seenValues[v] = true
			table.insert(entries, v)
		end
	end
	return entries
end

function p.allEnrties(name)
	return arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData(name)),
		tableKeys(mw.loadData(name..' BE'))
		))
end

local beExtraBlocks = {
	'下界反应核',
	'发光的黑曜石',
	'切石机(MATTIS)',
	'reserved6',
	'客户端请求占位符方块',
	'数据更新方块',
	'未知方块',
	'隐形基岩',
	'允许方块',
	'拒绝方块',
	'边界',
	'相机',
	'红色火把',
	'绿色火把',
	'蓝色火把',
	'紫色火把',
	'元素',
	'强化玻璃',
	'染色强化玻璃',
	'强化玻璃板',
	'染色强化玻璃板',
	'元素构造器',
	'化合物创建器',
	'实验台',
	'材料分解器',
	'加热块',
	'水下火把',
	'黑板',
}

local beExtraItems = {
	'荧光棒',
	'相片',
	'公文包',
	'冰弹',
	'漂白剂',
	'气球',
	'烟花棒',
	'超级肥料',
	'化合物',
	'药物',
	'生成NPC',
	'生成智能体',
}

local function allBlocks()
	return arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData('Module:Block id values')),
		beExtraBlocks
		))
end

local function allItems()
	return arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData('Module:Item id values')),
		beExtraBlocks,
		beExtraItems
		))
end

local function allNames()
	return arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData('Module:Autovalue/groups')),
		tableKeys(mw.loadData('Module:Block id values')),
		tableKeys(mw.loadData('Module:Item id values')),
		beExtraBlocks,
		beExtraItems
		))
end

function p.knownName(name)
	local allNamesTable = allNames()
	for i, v in ipairs(allNamesTable) do
		if name == v then
			return true
		end
	end
	return false
end

function p.knownBlockName(name)
	local allNamesTable = arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData('Module:Autovalue/groups')),
		tableKeys(mw.loadData('Module:Block id values')),
		beExtraBlocks
		))
	for i, v in ipairs(allNamesTable) do
		if name == v then
			return true
		end
	end
	return false
end

function p.allBlocks(f)
	local args = f
	local frame = mw.getCurrentFrame()
	if f == frame then
		args = ProcessArgs.merge(true)
	end
	local argJoin = args['join'] or ', '
	
	--return table.concat(p.allEnrties('Module:Block id values'), argJoin)
	return table.concat(allBlocks(), argJoin)
end

function p.allItems(f)
	local args = f
	local frame = mw.getCurrentFrame()
	if f == frame then
		args = ProcessArgs.merge(true)
	end
	local argJoin = args['join'] or ','

	--return table.concat(p.allEnrties('Module:Item id values'), argJoin)
	return table.concat(allItems(), argJoin)
end

function p.blastResistanceTable(f)
	local argNocat = false
	--local entries = p.allEnrties('Module:Block id values')
	local entries = tableKeys(mw.loadData('Module:Block id values'))
	local rows = {}
	for i, v in ipairs( entries ) do
		table.insert(rows, {
			name = v,
			rawValue = Autovalue.getRawValue(v, 'blast resistance', false) or Autovalue.getRawValue(v, 'blast resistance', true) or -1,
			readsValue = Autovalue.getValue(v, 'blast resistance', 'content', argNocat, false, false),
			only = nil,
		})
	end
	table.sort(rows, function(r1, r2)
		return r1.rawValue > r2.rawValue
	end)
	local resultTable = {
		' {| class="wikitable collapsible sortable collapsed" data-sort-type="number" data-description="方块的爆炸抗性"',
		'! 方块',
		'! 爆炸抗性',
	}
	for i, row in ipairs( rows ) do
		local blocklink, spriteCat = require( [[Module:Sprite]] ).link({
			require( [[Module:Reverselink]] ).xlink(row.name),
			['data'] = 'BlockSprite'
		})
		local only = ''
		if row.only then
			only = mw.getCurrentFrame():expandTemplate { title = 'Only', args = { row.only } }
		end
		table.insert(resultTable, '|-')
		table.insert(resultTable, '| '..blocklink..only..spriteCat)
		table.insert(resultTable, '| data-sort-value="'..row.rawValue..'" | '..row.readsValue)
	end
	table.insert(resultTable, '|}')
	return table.concat(resultTable, '\n')
end

function p.reverseautolink()
	local generatedLinks = {}
	local links = joinObjectTable(
		mw.loadData('Module:Autolink/Block'),
		mw.loadData('Module:Autolink/Item')
		)
	for k, v in pairs( links ) do
		local name
		if type(v) == 'table' then
			name = v[1]
		else
			name = v
		end
		local point = string.find(name, '|', 1)
		if point ~= nil then
			name = string.sub(name, point + 1, string.len(name))
		end
		generatedLinks[name] = string.gsub(k, "%f[%a].", string.upper)
	end
	return generatedLinks
end

function p.missingReverselink()
	local Reverselink = require( [[Module:Reverselink]] )
	local allNames = arrayTableDuplicate(joinArrayTable(
		tableKeys(mw.loadData('Module:Block id values')),
		tableKeys(mw.loadData('Module:Item id values')),
		beExtraBlocks,
		beExtraItems
		))
	local noRlinkNames = {}
	local noRlinkNoIdeaNames = {}
	local rautolinks = p.reverseautolink()
	for i, v in ipairs( allNames ) do
		local rlinkName = Reverselink.xlink(v)
		if v == rlinkName then
			local possiblelink = rautolinks[v]
			if possiblelink then
				table.insert(noRlinkNames, '\t[\''..v..'\'] = \''..possiblelink..'\',')
			else
				table.insert(noRlinkNoIdeaNames, '\t[\''..v..'\'] = \''..'??????'..'\',')
			end
		end
	end
	return '<pre>'..table.concat(noRlinkNames, '\n')..'</pre><pre>'..table.concat(noRlinkNoIdeaNames, '\n')..'</pre>'
end

return p