真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Minecraft1.19.2Forge模組開(kāi)發(fā)11.Mixin-創(chuàng)新互聯(lián)

我們本次使用Mixin在1.19.2中制作一個(gè)屬于自己的不死圖騰。

在這里插入圖片描述

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到松桃網(wǎng)站設(shè)計(jì)與松桃網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋松桃地區(qū)。

演示效果 演示效果 演示效果

什么是Mixin? 簡(jiǎn)單來(lái)說(shuō)是通過(guò)注入一些我們的代碼,達(dá)到對(duì)MC原版內(nèi)容的修改。 詳細(xì)內(nèi)容可以參考Minecraft 17.1 Mixin 1.首先我們需要在開(kāi)發(fā)包中引入mixin的依賴,來(lái)到項(xiàng)目的build.gradle文件:

build.gradle

plugins {
    id 'eclipse'
    id 'maven-publish'
    id 'net.minecraftforge.gradle' version '5.+'
    //引入這個(gè)mixin依賴
    id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
}

version = "1.2.8-1.19"
group = "com.joy187.re8joymod"
archivesBaseName = "joy187"

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

sourceSets.main.resources { srcDir 'src/generated/resources' }

//設(shè)置你的mixin源文件名稱
mixin {
    add sourceSets.main, "re8.refmap.json"
}

minecraft {
    mappings channel: 'official', version: '1.19'

    accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

    runs {
        client {
            workingDirectory project.file('run')
            property 'mixin.env.disableRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            //客戶端中指定你資源包中的mixin文件
            arg '-mixin.config=re8.mixins.json'
            
            mods {
                re8joymod {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')
            property 'mixin.env.disableRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            //服務(wù)端中指定你資源包中的mixin文件
            arg '-mixin.config=re8.mixins.json'
            mods {
                re8joymod {
                    source sourceSets.main
                }
            }
        }

        data {
            workingDirectory project.file('run')
            property 'mixin.env.disableRefMap', 'true'
            property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
            property 'forge.logging.console.level', 'debug'
            args '--mod', 're8joymod', '--all', '--output', file('src/generated/resources/')
            //數(shù)據(jù)包中指定你資源包中的mixin文件
            arg '-mixin.config=re8.mixins.json'
            mods {
                re8joymod {
                    source sourceSets.main
                }
            }
        }
    }
}

repositories {
    mavenLocal()
    maven {
        url "https://www.cursemaven.com"
    }
    maven {
        name "Progwml6 maven"
        url "https://dvs1.progwml6.com/files/maven/"
    }
    maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' }
//    maven {
//        name "ModMaven"
//        url "https://modmaven.k-4u.nl"
//    }
    maven {
        name = "Curios API"
        url = "https://maven.theillusivec4.top/"
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.19.2-43.1.1'

    implementation fg.deobf('curse.maven:framework-549225:3873800')
    implementation fg.deobf('curse.maven:mrcrayfishs-gun-mod-289479:3874034')
    implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.19:3.1.36')
    compileOnly fg.deobf("mezz.jei:jei-1.19-common-api:11.0.0.211")
    compileOnly fg.deobf("mezz.jei:jei-1.19-forge-api:11.0.0.211")

    runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19.2-5.1.1.0")
    compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19.2-5.1.1.0:api")

    runtimeOnly fg.deobf("mezz.jei:jei-1.19-forge:11.0.0.211")
    
    //這里引入mixin依賴
    annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

jar {
    manifest {
        attributes([
                "Specification-Title": "Resident Evil 8 mod",
                "Specification-Vendor": "Joy187",
                "Specification-Version": "1",
                "Implementation-Title": "Resident Evil 8 mod",
                "Implementation-Version": project.version,
                "Implementation-Vendor" : "Joy187",
                //"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                //你資源包中的mixin配置文件
                "MixinConfigs": "re8.mixins.json"
        ])
    }
}

jar.finalizedBy('reobfJar')

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            artifact jar
        }
    }
    repositories {
        maven {
            url "file:///X:/localmaven/mcmods"
        }
    }
}
之后選擇刷新gradle項(xiàng)目:

cr0.jpg

2.重新構(gòu)建完成后我們?cè)谫Y源包中新建一個(gè)我們的mixin文件,文件名稱與上面"MixinConfigs"字段填寫的名稱一樣:

cr1.jpg

之后在文件中寫一些內(nèi)容:

re8.mixins.json

{"required": true,
    "package": "com.joy187.re8joymod.mixin",
    "compatibilityLevel": "JAVA_8",
    "minVersion": "0.8",
    "refmap": "re8.refmap.json",
    "plugin": "com.joy187.re8joymod.mixin.MixinPlugin", //注意這個(gè)地址
    "mixins": [

    ],
    "client": [

    ],
    "injectors": {"defaultRequire": 1
    }
}
3.來(lái)到Java包中,在上一步中我們聲明了一個(gè)plugin地址,按照這個(gè)路徑創(chuàng)建一個(gè)MixinPlugin文件,作為模組的mixin啟動(dòng)器:

cr2.jpg

MixinPlugin.java

package com.joy187.re8joymod.mixin;

import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class MixinPlugin implements IMixinConfigPlugin{private boolean isFrameworkInstalled;
    @Override
    public void onLoad(String mixinPackage) {try {//這個(gè)字符串對(duì)應(yīng)你的項(xiàng)目主類
            Class.forName("com.joy187.re8joymod.Main", false, this.getClass().getClassLoader());
            isFrameworkInstalled = true;
        } catch (Exception e) {isFrameworkInstalled = false;
        }
    }

    @Override
    public String getRefMapperConfig() {return null;
    }

    @Override
    public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {return isFrameworkInstalled; // this makes sure that forge's helpful mods not found screen shows up
    }

    @Override
    public void acceptTargets(SetmyTargets, SetotherTargets) {}

    @Override
    public ListgetMixins() {return null;
    }

    @Override
    public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}

    @Override
    public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {}
}
之后我們?cè)谕瑯拥陌行陆ㄒ粋€(gè)LivingEntityMixin類,作為我們的注入類:

LivingEntityMixin.json

package com.joy187.re8joymod.mixin;

import com.joy187.re8joymod.init.ItemInit;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.stats.Stats;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {//這里我們將代碼注入到checkTotemDeathProtection中,注入位置是其HEAD頭部
    @Inject(method = {"checkTotemDeathProtection"}, at = {@At("HEAD")}, cancellable = true)
    private void checkTotemDeathProtection(DamageSource source, CallbackInfoReturnableinfo) {LivingEntity livingEntity = ((LivingEntity)(Object)this);
        if (livingEntity instanceof ServerPlayer player) {ItemStack itemStack = null;
            Inventory inventory = player.getInventory();
            //在背包中找到我們的物品
            for (int i = 0; i< inventory.getContainerSize(); i++) {ItemStack stack = inventory.getItem(i);
                if (stack.getItem().equals(ItemInit.BODYGUARD.get())) {itemStack = stack;
                    break;
                }
            }
            //如果找到了,當(dāng)我們陷入瀕死之時(shí)就會(huì)使用該物品并給予玩家一個(gè)15s的生命回復(fù)效果
            if (itemStack != null) {player.awardStat(Stats.ITEM_USED.get(ItemInit.BODYGUARD.get()));
                CriteriaTriggers.USED_TOTEM.trigger(player, itemStack);
                itemStack.shrink(1);
                player.setHealth(10.0F);
                player.removeAllEffects();
                player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 300, 1));
                player.level.broadcastEntityEvent(player, (byte) 35);
                info.setReturnValue(true);
            }
        }
    }
}
把這個(gè)類的名稱放入我們之前資源包中的注入文件中:

re8.mixins.json

{"required": true,
    "package": "com.joy187.re8joymod.mixin",
    "compatibilityLevel": "JAVA_8",
    "minVersion": "0.8",
    "refmap": "re8.refmap.json",
    "plugin": "com.joy187.re8joymod.mixin.MixinPlugin",
    "mixins": [
        "LivingEntityMixin" //放在這里
    ],
    "client": [

    ],
    "injectors": {"defaultRequire": 1
    }
}
4.在ItemInit中注冊(cè)我們的物品,作為圖騰使用:

ItemInit.java

public static final RegistryObjectBODYGUARD = register("bodyguard",
            () ->new Item(new Item.Properties().tab(Main.TUTORIAL_TAB)));
在資源包中物品的名稱、模型、貼圖文件。

en_us.json

"item.re8joymod.bodyguard":"Crystal",
模型文件

bodyguard.json

{"parent": "item/generated",
  "textures": {"layer0": "re8joymod:item/bodyguard"
  }
}
貼圖文件

在這里插入圖片描述

5.啟動(dòng)游戲調(diào)試

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧


分享題目:Minecraft1.19.2Forge模組開(kāi)發(fā)11.Mixin-創(chuàng)新互聯(lián)
文章URL:http://weahome.cn/article/dpjogj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部