跳转至内容

[原创?][KJS6][EE.JS]较为方便地为矿物提供注册与通用配方修改的轮子

妙妙工具
4 3 144 1
  • EEJS 是N-Withe的整合包Omniworld-R的EEJS部分分支且添加了一些模组的支持,如有需要可以麻烦我或者自己写更多支持😺
    由于原仓库未标注协议,默认视为ARR,所以获得了原作者同意后才使用MIT协议。
    它可以让你优雅的编辑、统一矿物与材料。
    推荐与Almost unified一起使用!! (因为我懒得补全这部分)
    材质来自于Emendatus Enigmatica
    项目与本文使用MIT协议!!🤗

    存储库详见这里

    前置需求

    • minecraft => 1.20.1也许不止1.20.1
    • (NEO)Forge => any
    • KubeJS => 6
    • LootJS => any
    • KubeJS Mekanism 如果有Mekanism
    • KubeJS Immersive Engineering 如果有Immersive Enginnering
    • KubeJS Create 如果有Create
    • KubeJS Blood Magic 如果有Blood Magic
    • KubeJS Thermal 如果有Thermal Series
    • KubeJS-EnderIO 如果有Ender IO
    • Occultism KubeJS 如果有Occultism

    功能

    • 可自定义的容矿岩/材料
    • 便于编辑
    • 不错的兼容性

    使用文档

    注册部分

    自定义容矿岩

    添加新的定义在 EE_STRATAS ,它在 strata.js

    stone: {
    	name: "stone", // 命名材料
    	texture: "minecraft:block/stone", // 容矿岩材质
    	fill: "minecraft:stone",
    	hardness: 1.5, // 矿物硬度
    	resistance: 6, // 矿物爆炸抗性
    	tool: "pickaxe", // 工具类型
    }
    

    添加或修改 material_def.js 的开头,类似于下文
    e.g.

    let glodStratas = ["andesite", "diorite", "granite", "end_stone"];
    ...
    let EE_MATERIALS = [
        ...
    ] 
    

    自定义材料

    添加新的定义在 EE_MATERIALS ,它在 material_def.js

    * 代表非必须

    [1^]ProcessedTypes

    { 
    name: "coal", // 命名材料
    type: "dust", // 你的材料分类 -- ("dust","metal","gem")
    baseItem: "dust", //*基础类型是?
    processedTypes: ["dust","fluid"], //*处理物种类在下面的表格
    color: ["#393e46", "#2e2e2e", "#261e24", "#1f1721", "#1c1c1e"], //*你需要5种颜色才能正常生成材质
    burnTime: 1600, //*如果可以烧 / 时间单位是 tick
    strata: vanillaComplementStratas, //*容矿岩种类 -- *如果你加了"ore"类型,你需要有这条*
    fluidType:"thin" 
    //*types: "thin","thick" and "custom", if it's thin or thick it will use first color(color[0]), 
    // but custom has more configs! that need another color to color the fluid if you want, 
    // first color is the bucket color, and you need more textures named to "${name}_still" and "${name}_flowing" like vanilla.
    // 我懒得写一遍中文教程了,简单来说就是写了这个只会最多用2种颜色,三种type,只有custom会用第二种颜色然后作为材质第二次上色的颜色,第二种不写也没问题😁
    drop: {item: "minecraft:raw_iron",min: 1,max: 1,}, //*矿物掉落物
    harvestLevel: "stone", //*挖掘等级
    smallStorageBlock: true,//*存储方块合成的配方是4*4还是9*9
    gemTemplate: 1, //*纹理模板
    toolProperties: { //*工具属性 *加上了的话下面都要出现,不加就没有*
    damage: 9, // 伤害
    durability: 1800, // 耐久
    harvestLevel: 4, // 挖掘等级
    enchantValue: 24, // 附魔等级
    miningSpeed: 12 // 挖掘速度
    },
    armorProperties: { //*护甲属性 *加上了的话下面都要出现,不加就没有*
    durability: 1000, // 护甲耐久
    durabilityMultiplier: 70, // 护甲耐久乘数
    slotProtections: [4, 7, 9, 4], // 护甲部位的护甲值
    equipSound: 'minecraft:item.armor.equip_iron', // 穿戴声音
    toughness: 3.5, // 护甲抗性
    knockbackResistance: 0 // 击退减免
    }}
    

    太长不看

    clone或者下载压缩包后粘贴到kjs文件夹内后即可在material_def.jsstrata.js中添加新的材料与容矿岩,格式详见文档

    已知问题

    地物生成绝对有问题,但是我不知道怎么优雅地实现。

    画廊

    44b56256-f642-44e3-9620-d20a4f180440-image.png

  • 你的mod加载器和版本的tag呢(

  • 你的mod加载器和版本的tag呢(

    @忆然 在前置需求里(

  • 这里贴一份1.21.1版本的实现🤓 ☝


相关推荐


  • [原创][Mod]通过特定格式文字进行查找结构

    妙妙工具 forge mixin
    1
    0 赞同
    1 帖子
    76 浏览
    昨天没做东西,今天也没K
    故事的起因是有帮twf写模组时,需要用到查找结构指令显示坐标给玩家,但是玩家不一定有权限或者ftbq发送并不会sendmessage给玩家,所以有了此代码。 我也将结构查找的功能写成了一个类,可以直接拿去用。 public class StructureLocator { private static final ResourceKey<Registry<ConfiguredStructureFeature<?, ?>>> STRUCTURE_REGISTRY_KEY = Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY; /** * 根据单个结构 ResourceLocation(如 "minecraft:village" 或者自定义 mod:id)查找最近的那个点。 * * @param level 当前维度 * @param center 中心搜索点 * @param id 结构的 ResourceLocation * @param radius 搜索半径(方块数) * @param skipKnown 是否跳过已探索过的结构 * @return 如果找到,返回 Pair(结构坐标, Holder<该结构>); 找不到则 empty() */ public static Optional<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> findNearest( ServerLevel level, BlockPos center, ResourceLocation id, int radius, boolean skipKnown ) { Registry<ConfiguredStructureFeature<?, ?>> registry = level.registryAccess().registryOrThrow(STRUCTURE_REGISTRY_KEY); ResourceKey<ConfiguredStructureFeature<?, ?>> key = ResourceKey.create(STRUCTURE_REGISTRY_KEY, id); Holder<ConfiguredStructureFeature<?, ?>> holder = registry.getHolder(key).orElse(null); if (holder == null) return Optional.empty(); HolderSet<ConfiguredStructureFeature<?, ?>> holderSet = HolderSet.direct(holder); Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> result = level.getChunkSource() .getGenerator() .findNearestMapFeature(level, holderSet, center, radius, skipKnown); return Optional.ofNullable(result); } /** * 根据 TagKey(像 "#minecraft:village")来查找最近的结构。 * * @param level 当前维度 * @param center 中心搜索点 * @param tagKey 结构 TagKey(Registry.CONFIGURED_STRUCTURE_FEATURE_REGISTRY 下的 Tag) * @param radius 搜索半径 * @param skipKnown 是否跳过已探索结构 * @return 如果找到,返回 Pair(结构坐标, Holder<该结构>); 找不到则 empty() */ public static Optional<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> findNearestByTag( ServerLevel level, BlockPos center, TagKey<ConfiguredStructureFeature<?, ?>> tagKey, int radius, boolean skipKnown ) { Registry<ConfiguredStructureFeature<?, ?>> registry = level.registryAccess().registryOrThrow(STRUCTURE_REGISTRY_KEY); HolderSet<ConfiguredStructureFeature<?, ?>> holderSet = registry.getOrCreateTag(tagKey); Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> result = level.getChunkSource() .getGenerator() .findNearestMapFeature(level, holderSet, center, radius, skipKnown); return Optional.ofNullable(result); } /** * 把查到的结果格式化成一个聊天用的组件(绿色坐标 + 距离)。 * * @param structureName 你想显示的结构名称(如 "minecraft:village" 或 "#minecraft:village") * @param origin 搜索中心 * @param pair findNearest 返回的 Pair * @param translateKey 翻译 key,通常用 "commands.locate.success" */ public static Component formatLocateResult( String structureName, BlockPos origin, Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>> pair, String translateKey ) { BlockPos found = pair.getFirst(); int distance = Mth.floor( dist(origin.getX(), origin.getZ(), found.getX(), found.getZ()) ); MutableComponent coords = ComponentUtils.wrapInSquareBrackets( new TranslatableComponent("chat.coordinates", found.getX(), "~", found.getZ()) ); return new TranslatableComponent( translateKey, structureName, coords, distance ); } private static float dist(int x1, int z1, int x2, int z2) { int dx = x2 - x1, dz = z2 - z1; return Mth.sqrt((float) (dx * dx + dz * dz)); } } 这部分代码就是查找结构有关的类了,通过获取ConfiguredStructureFeature的注册表,然后再获取结构的Holder类,再给ChunkGenerator的findNearestMapFeature方法去获取到BlockPos。 @Mixin(ServerPlayer.class) public class ServerPlayerMixin { @ModifyArg(method = "sendMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/protocol/game/ClientboundChatPacket;<init>(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/ChatType;Ljava/util/UUID;)V"), index = 0) public Component modifyMessage(Component component){ MutableComponent mutableComponent = component.copy(); String message = mutableComponent.getString(); ServerPlayer serverPlayer = (ServerPlayer) (Object) this; if (message.contains("<structure>") && message.contains("</structure>")) { String structure = message.replaceAll(".*<structure>(.*?)</structure>.*", "$1"); BlockPos center = serverPlayer.blockPosition(); Optional<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> holderPair = StructureLocator.findNearest( serverPlayer.getLevel(), center, new ResourceLocation(structure), 100, false ); AtomicReference<String> replace = new AtomicReference<>(); holderPair.ifPresentOrElse(pair -> { Component component1 = StructureLocator.formatLocateResult(structure, center, pair, "commands.locate.success"); replace.set(component1.getString()); }, () -> { replace.set(new TranslatableComponent("commands.locate.failed", structure).getString()); }); Style style = component.getStyle(); mutableComponent = new TextComponent(message.replaceAll("<structure>(.*?)</structure>", "§a%s§r".formatted(replace.get()))).withStyle(style); } return mutableComponent; } } 这段mixin则是注入ServerPlayer的sendMessage方法,修改new ClientboundChatPacket(message, type, sender)的message参数,||因为我偷懒,所以没用MixinExtra||,用正则表达式进行匹配到对应的结构格式文字,然后修改原文字中的内容。 这差不多都就是本次代码的全部内容了。
  • [原创][Mod]基于opengl取色的hsv色盘屏幕

    妙妙工具 渲染
    5
    0 赞同
    5 帖子
    113 浏览
    不是客服M
    没有教程的话,哇达西?
  • 0 赞同
    3 帖子
    190 浏览
    sdjgeS
    补药在1.21.1偷走我的钱包