mirror of
https://github.com/TeamMidnightDust/SwordBlocking.git
synced 2025-12-17 15:25:09 +01:00
Compare commits
37 Commits
v1.0.0
...
46f36864c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46f36864c2 | ||
|
|
92ba293322 | ||
|
|
1d305e8f8b | ||
|
|
a6df4e73df | ||
|
|
5119e0b3ba | ||
|
|
2a03dd78fb | ||
|
|
d91ced885d | ||
|
|
4e2fa07c15 | ||
|
|
e8c8fb7c57 | ||
|
|
0bbcf5251e | ||
|
|
bf4769bc4f | ||
|
|
0f339fd7a5 | ||
|
|
35987af8c7 | ||
|
|
b20b233595 | ||
|
|
7e2ef4d2d8 | ||
|
|
95454d1c33 | ||
|
|
68dade9453 | ||
|
|
51cbfae757 | ||
|
|
bae992c8b1 | ||
|
|
5b0e385d39 | ||
|
|
fb0c90c62a | ||
|
|
1c4389e30f | ||
|
|
013322f7ee | ||
|
|
1b39555f7e | ||
|
|
909fc4f9b0 | ||
|
|
d8ade3e4e8 | ||
|
|
f482d2e700 | ||
|
|
24a923ef16 | ||
|
|
c126a76a5e | ||
|
|
75b980f36f | ||
|
|
6cd237e087 | ||
|
|
a66be9a7be | ||
|
|
ca198eeea3 | ||
|
|
c847b0f1d0 | ||
|
|
82e910a5fa | ||
|
|
a7113cc4de | ||
|
|
d1a18cded6 |
114
build.gradle
114
build.gradle
@@ -1,80 +1,80 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.5-SNAPSHOT'
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||||
id 'maven-publish'
|
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
|
||||||
|
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
|
||||||
|
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
architectury {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
minecraft = rootProject.minecraft_version
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
|
||||||
version = project.mod_version
|
|
||||||
group = project.maven_group
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://jitpack.io" }
|
maven {
|
||||||
|
url = "https://api.modrinth.com/maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply plugin: "dev.architectury.loom"
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = "https://api.modrinth.com/maven"
|
||||||
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//to change the versions see the gradle.properties file
|
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
// The following line declares the mojmap mappings, you may use other mappings as well
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
//mappings loom.officialMojangMappings()
|
||||||
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
|
// The following line declares the yarn mappings you may select this one as well.
|
||||||
|
mappings loom.layered {
|
||||||
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
|
||||||
|
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
|
||||||
inputs.property "version", project.version
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
include "fabric.mod.json"
|
|
||||||
expand "version": project.version
|
|
||||||
}
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude "fabric.mod.json"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
allprojects {
|
||||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
apply plugin: "java"
|
||||||
|
apply plugin: "architectury-plugin"
|
||||||
|
apply plugin: "maven-publish"
|
||||||
|
|
||||||
|
archivesBaseName = rootProject.archives_base_name
|
||||||
|
version = rootProject.mod_version
|
||||||
|
group = rootProject.maven_group
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
// Add repositories to retrieve artifacts from in here.
|
||||||
|
// You should only use this when depending on other mods because
|
||||||
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
|
// for more information about repositories.
|
||||||
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
|
options.release = 21
|
||||||
}
|
}
|
||||||
|
ext {
|
||||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
releaseChangelog = {
|
||||||
// if it is present.
|
def changes = new StringBuilder()
|
||||||
// If you remove this task, sources will not be generated.
|
changes << "## SwordBlocking v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/SwordBlocking/commits/)"
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
def proc = "git log --max-count=1 --pretty=format:%s".execute()
|
||||||
classifier = "sources"
|
proc.in.eachLine { line ->
|
||||||
from sourceSets.main.allSource
|
def processedLine = line.toString()
|
||||||
|
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
|
||||||
|
changes << "\n- ${processedLine.capitalize()}"
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
from "LICENSE"
|
|
||||||
}
|
|
||||||
|
|
||||||
// configure the maven publication
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
// add all the jars that should be included when publishing to maven
|
|
||||||
artifact(remapJar) {
|
|
||||||
builtBy remapJar
|
|
||||||
}
|
|
||||||
artifact(sourcesJar) {
|
|
||||||
builtBy remapSourcesJar
|
|
||||||
}
|
}
|
||||||
|
proc.waitFor()
|
||||||
|
return changes.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// select the repositories you want to publish to
|
java {
|
||||||
repositories {
|
withSourcesJar()
|
||||||
// uncomment to publish to the local maven
|
|
||||||
// mavenLocal()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
24
common/build.gradle
Normal file
24
common/build.gradle
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
architectury {
|
||||||
|
common(rootProject.enabled_platforms.split(","))
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||||
|
// Do NOT use other classes from fabric loader
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenCommon(MavenPublication) {
|
||||||
|
artifactId = rootProject.archives_base_name
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||||
|
repositories {
|
||||||
|
// Add repositories to publish to here.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package eu.midnightdust.swordblocking;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||||
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SwordBlockingClient {
|
||||||
|
public static final String MOD_ID = "swordblocking";
|
||||||
|
public static Map<BipedEntityRenderState, LivingEntity> RENDER_STATE_TO_ENTITY_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
SwordBlockingConfig.init(MOD_ID, SwordBlockingConfig.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEntityBlocking(LivingEntity entity) {
|
||||||
|
return SwordBlockingConfig.enabled && entity.isUsingItem() && canShieldSwordBlock(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canShieldSwordBlock(LivingEntity entity) {
|
||||||
|
if (SwordBlockingConfig.enabled && (entity.getOffHandStack().getItem() instanceof ShieldItem || entity.getMainHandStack().getItem() instanceof ShieldItem)) {
|
||||||
|
Item weaponItem = entity.getOffHandStack().getItem() instanceof ShieldItem ? entity.getMainHandStack().getItem() : entity.getOffHandStack().getItem();
|
||||||
|
return weaponItem.getComponents().contains(DataComponentTypes.DAMAGE);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldHideShield(LivingEntity entity, ItemStack stack) {
|
||||||
|
return SwordBlockingConfig.enabled && (SwordBlockingConfig.alwaysHideShield && SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem)
|
||||||
|
|| (SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem && SwordBlockingClient.canShieldSwordBlock(entity));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package eu.midnightdust.swordblocking.config;
|
||||||
|
|
||||||
|
import eu.midnightdust.lib.config.MidnightConfig;
|
||||||
|
|
||||||
|
public class SwordBlockingConfig extends MidnightConfig {
|
||||||
|
@Entry public static boolean enabled = true;
|
||||||
|
@Entry public static boolean hideShield = true;
|
||||||
|
@Entry public static boolean alwaysHideShield = true;
|
||||||
|
@Entry public static boolean hideOffhandSlot = false;
|
||||||
|
@Entry public static boolean disableUseEquipAnimation = false;
|
||||||
|
@Entry public static boolean lockBlockingArmPosition = false;
|
||||||
|
@Entry public static boolean blockHitAnimation = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ShieldItem;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(BipedEntityModel.class)
|
||||||
|
public abstract class MixinBipedEntityModel<T extends BipedEntityRenderState> {
|
||||||
|
@Shadow
|
||||||
|
protected abstract void positionRightArm(T entityRenderState, BipedEntityModel.ArmPose armPose);
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract void positionLeftArm(T entityRenderState, BipedEntityModel.ArmPose armPose);
|
||||||
|
|
||||||
|
@Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;animateArms(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;F)V", shift = At.Shift.BEFORE))
|
||||||
|
private void swordBlocking$setBlockingAngles(T bipedEntityRenderState, CallbackInfo ci) {
|
||||||
|
LivingEntity livingEntity = SwordBlockingClient.RENDER_STATE_TO_ENTITY_MAP.get(bipedEntityRenderState);
|
||||||
|
if (livingEntity == null || !SwordBlockingClient.isEntityBlocking(livingEntity))
|
||||||
|
return;
|
||||||
|
if (livingEntity.getOffHandStack().getItem() instanceof ShieldItem)
|
||||||
|
this.positionRightArm(bipedEntityRenderState, BipedEntityModel.ArmPose.BLOCK);
|
||||||
|
else
|
||||||
|
this.positionLeftArm(bipedEntityRenderState, BipedEntityModel.ArmPose.BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "positionBlockingArm", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;clamp(FFF)F"))
|
||||||
|
private float swordBlocking$lockArmPosition(float value, float min, float max) {
|
||||||
|
if (SwordBlockingConfig.enabled && SwordBlockingConfig.lockBlockingArmPosition) {
|
||||||
|
return 0F;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import net.minecraft.client.item.ItemModelManager;
|
||||||
|
import net.minecraft.client.render.entity.BipedEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
|
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.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(BipedEntityRenderer.class)
|
||||||
|
public abstract class MixinBipedEntityRenderer<T extends MobEntity, S extends BipedEntityRenderState, M extends BipedEntityModel<S>> {
|
||||||
|
@Inject(method = "updateBipedRenderState", at = @At("TAIL"))
|
||||||
|
private static void swordBlocking$storeEntity(LivingEntity entity, BipedEntityRenderState state, float tickDelta, ItemModelManager itemModelResolver, CallbackInfo ci) {
|
||||||
|
SwordBlockingClient.RENDER_STATE_TO_ENTITY_MAP.put(state, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModel;
|
||||||
|
import net.minecraft.client.render.entity.model.ModelWithArms;
|
||||||
|
import net.minecraft.client.render.entity.state.ArmedEntityRenderState;
|
||||||
|
import net.minecraft.client.render.item.ItemRenderState;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Arm;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(HeldItemFeatureRenderer.class)
|
||||||
|
public abstract class MixinHeldItemFeatureRenderer<S extends ArmedEntityRenderState, M extends EntityModel<S> & ModelWithArms> {
|
||||||
|
@Redirect(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderState;isEmpty()Z"))
|
||||||
|
private boolean swordBlocking$hideShield(ItemRenderState instance, @Local(argsOnly = true) Arm arm, @Local(argsOnly = true) S entityState) {
|
||||||
|
LivingEntity livingEntity = SwordBlockingClient.RENDER_STATE_TO_ENTITY_MAP.get(entityState);
|
||||||
|
if (SwordBlockingConfig.enabled && livingEntity != null) {
|
||||||
|
ItemStack itemStack = livingEntity.getStackInHand(arm == Arm.LEFT ? Hand.OFF_HAND : Hand.MAIN_HAND);
|
||||||
|
return SwordBlockingClient.shouldHideShield(livingEntity, itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
|
import net.minecraft.client.render.VertexConsumerProvider;
|
||||||
|
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemDisplayContext;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.consume.UseAction;
|
||||||
|
import net.minecraft.util.Arm;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(HeldItemRenderer.class)
|
||||||
|
public abstract class MixinHeldItemRenderer {
|
||||||
|
@Shadow
|
||||||
|
@Final
|
||||||
|
private MinecraftClient client;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress);
|
||||||
|
|
||||||
|
@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true)
|
||||||
|
public void swordBlocking$hideShield(LivingEntity entity, ItemStack stack, ItemDisplayContext renderMode, MatrixStack matrices, VertexConsumerProvider vertexConsumer, int light, CallbackInfo ci) {
|
||||||
|
if (SwordBlockingClient.shouldHideShield(entity, stack)) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getActiveHand()Lnet/minecraft/util/Hand;", ordinal = 1))
|
||||||
|
private Hand swordBlocking$changeActiveHand(AbstractClientPlayerEntity player) {
|
||||||
|
Hand activeHand = player.getActiveHand();
|
||||||
|
if (SwordBlockingClient.isEntityBlocking(player)) {
|
||||||
|
return swordBlocking$getBlockingHand(activeHand);
|
||||||
|
} else {
|
||||||
|
return activeHand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;"))
|
||||||
|
private UseAction swordBlocking$changeItemAction(ItemStack stack, @Local(argsOnly = true) AbstractClientPlayerEntity player, @Local(argsOnly = true) Hand hand) {
|
||||||
|
UseAction defaultUseAction = stack.getUseAction();
|
||||||
|
if (SwordBlockingClient.isEntityBlocking(player)) {
|
||||||
|
return swordBlocking$getBlockingHand(player.getActiveHand()) == hand ? UseAction.BLOCK : defaultUseAction;
|
||||||
|
} else {
|
||||||
|
return defaultUseAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;applyEquipOffset(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/Arm;F)V", ordinal = 3, shift = At.Shift.AFTER))
|
||||||
|
private void swordBlocking$applySwingOffset(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack item, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci, @Local Arm arm) {
|
||||||
|
if (SwordBlockingConfig.enabled && SwordBlockingConfig.blockHitAnimation) {
|
||||||
|
applySwingOffset(matrices, arm, swingProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "resetEquipProgress", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void swordBlocking$disableEquipAnimation(Hand hand, CallbackInfo ci) {
|
||||||
|
if (SwordBlockingConfig.disableUseEquipAnimation && this.client.player != null && this.client.player.isUsingItem()) {
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
private Hand swordBlocking$getBlockingHand(Hand activeHand) {
|
||||||
|
return activeHand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ShieldItem;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
|
||||||
|
@Mixin(InGameHud.class)
|
||||||
|
public abstract class MixinInGameHud {
|
||||||
|
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getOffHandStack()Lnet/minecraft/item/ItemStack;"), method = "renderHotbarVanilla")
|
||||||
|
public ItemStack swordBlocking$hideOffHandSlot(ItemStack original) {
|
||||||
|
if (SwordBlockingConfig.enabled && SwordBlockingConfig.hideOffhandSlot && original.getItem() instanceof ShieldItem) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
} else {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package eu.midnightdust.swordblocking.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.render.entity.PlayerEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ShieldItem;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
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(PlayerEntityRenderer.class)
|
||||||
|
public abstract class MixinPlayerEntityRenderer {
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
@Inject(method = "getArmPose(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/Hand;)Lnet/minecraft/client/render/entity/model/BipedEntityModel$ArmPose;", at = @At(value = "RETURN"), cancellable = true)
|
||||||
|
private static void swordBlocking$getArmPose(PlayerEntity player, ItemStack stack, Hand hand, CallbackInfoReturnable<BipedEntityModel.ArmPose> cir) {
|
||||||
|
if (SwordBlockingConfig.enabled) {
|
||||||
|
ItemStack handStack = player.getStackInHand(hand);
|
||||||
|
ItemStack offStack = player.getStackInHand(hand.equals(Hand.MAIN_HAND) ? Hand.OFF_HAND : Hand.MAIN_HAND);
|
||||||
|
if (!SwordBlockingConfig.alwaysHideShield && (handStack.getItem() instanceof ShieldItem) && !SwordBlockingClient.canShieldSwordBlock(player))
|
||||||
|
return;
|
||||||
|
if (offStack.getItem() instanceof ShieldItem && SwordBlockingClient.isEntityBlocking(player)) {
|
||||||
|
cir.setReturnValue(BipedEntityModel.ArmPose.BLOCK);
|
||||||
|
} else if (handStack.getItem() instanceof ShieldItem && SwordBlockingConfig.hideShield && (cir.getReturnValue() == BipedEntityModel.ArmPose.ITEM || cir.getReturnValue() == BipedEntityModel.ArmPose.BLOCK)) {
|
||||||
|
cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"swordblocking.midnightconfig.title": "Sword Blocking Config",
|
||||||
|
"swordblocking.midnightconfig.enabled": "Enabled",
|
||||||
|
"swordblocking.midnightconfig.hideShield": "Hide Shield",
|
||||||
|
"swordblocking.midnightconfig.alwaysHideShield": "Always Hide Shield",
|
||||||
|
"swordblocking.midnightconfig.hideOffhandSlot": "Hide Offhand Slot",
|
||||||
|
"swordblocking.midnightconfig.hideOffhandSlot.tooltip": "Hides the offhand slot when a shield is in the offhand.",
|
||||||
|
"swordblocking.midnightconfig.disableUseEquipAnimation": "Remove the equip animation when blocking.",
|
||||||
|
"swordblocking.midnightconfig.lockBlockingArmPosition": "Disable arm moving when blocking.",
|
||||||
|
"swordblocking.midnightconfig.blockHitAnimation": "Enable block hitting animation."
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"swordblocking.midnightconfig.title": "Конфигурация Sword Blocking",
|
||||||
|
"swordblocking.midnightconfig.enabled": "Включено",
|
||||||
|
"swordblocking.midnightconfig.hideShield": "Спрятать щит",
|
||||||
|
"swordblocking.midnightconfig.alwaysHideShield": "Всегда прятать щит",
|
||||||
|
"swordblocking.midnightconfig.hideOffhandSlot": "Скрывать слот второй руки",
|
||||||
|
"swordblocking.midnightconfig.hideOffhandSlot.tooltip": "Скрывает слот второй руки, если в ней находится щит.",
|
||||||
|
"swordblocking.midnightconfig.disableUseEquipAnimation": "Удалять анимацию оснащения при блокировании.",
|
||||||
|
"swordblocking.midnightconfig.lockBlockingArmPosition": "Отключить движение руки при блокировании.",
|
||||||
|
"swordblocking.midnightconfig.blockHitAnimation": "Включить анимацию удара по блоку."
|
||||||
|
}
|
||||||
17
common/src/main/resources/swordblocking.mixins.json
Normal file
17
common/src/main/resources/swordblocking.mixins.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "eu.midnightdust.swordblocking.mixin",
|
||||||
|
"compatibilityLevel": "JAVA_17",
|
||||||
|
"client": [
|
||||||
|
"MixinBipedEntityModel",
|
||||||
|
"MixinBipedEntityRenderer",
|
||||||
|
"MixinHeldItemFeatureRenderer",
|
||||||
|
"MixinHeldItemRenderer",
|
||||||
|
"MixinInGameHud",
|
||||||
|
"MixinPlayerEntityRenderer"
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
102
fabric/build.gradle
Normal file
102
fabric/build.gradle
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.github.johnrengelman.shadow'
|
||||||
|
id "me.shedaniel.unified-publishing"
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
platformSetupLoomIde()
|
||||||
|
fabric()
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
common
|
||||||
|
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
|
||||||
|
compileClasspath.extendsFrom common
|
||||||
|
runtimeClasspath.extendsFrom common
|
||||||
|
developmentFabric.extendsFrom common
|
||||||
|
archivesBaseName = rootProject.archives_base_name + "-fabric"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
|
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||||
|
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
|
||||||
|
|
||||||
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
|
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
|
||||||
|
filesMatching("fabric.mod.json") {
|
||||||
|
expand "version": project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
exclude "architectury.common.json"
|
||||||
|
|
||||||
|
configurations = [project.configurations.shadowCommon]
|
||||||
|
archiveClassifier = "dev-shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
input.set shadowJar.archiveFile
|
||||||
|
dependsOn shadowJar
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
def commonSources = project(":common").sourcesJar
|
||||||
|
dependsOn commonSources
|
||||||
|
from commonSources.archiveFile.map { zipTree(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
components.java {
|
||||||
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unifiedPublishing {
|
||||||
|
project {
|
||||||
|
displayName = "SwordBlocking $project.version - Fabric $project.minecraft_version"
|
||||||
|
releaseType = "$project.release_type"
|
||||||
|
changelog = releaseChangelog()
|
||||||
|
gameVersions = []
|
||||||
|
gameLoaders = ["fabric","quilt"]
|
||||||
|
mainPublication remapJar
|
||||||
|
relations {
|
||||||
|
depends {
|
||||||
|
curseforge = "fabric-api"
|
||||||
|
modrinth = "fabric-api"
|
||||||
|
}
|
||||||
|
includes {
|
||||||
|
curseforge = "midnightlib"
|
||||||
|
modrinth = "midnightlib"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||||
|
if (CURSEFORGE_TOKEN != null) {
|
||||||
|
curseforge {
|
||||||
|
token = CURSEFORGE_TOKEN
|
||||||
|
id = rootProject.curseforge_id
|
||||||
|
gameVersions.addAll "Java 21", project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||||
|
if (MODRINTH_TOKEN != null) {
|
||||||
|
modrinth {
|
||||||
|
token = MODRINTH_TOKEN
|
||||||
|
id = rootProject.modrinth_id
|
||||||
|
version = "$project.version-$project.name"
|
||||||
|
gameVersions.addAll project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package eu.midnightdust.swordblocking.fabric;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
|
||||||
|
public class SwordBlockingClientFabric implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
SwordBlockingClient.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
32
fabric/src/main/resources/fabric.mod.json
Normal file
32
fabric/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "swordblocking",
|
||||||
|
"version": "${version}",
|
||||||
|
"name": "Sword Blocking",
|
||||||
|
"description": "Adds sword blocking to new versions, you just need a shield in your offhand (or ViaVersion)!",
|
||||||
|
"authors": [
|
||||||
|
"Motschen",
|
||||||
|
"TeamMidnightDust",
|
||||||
|
"lowercasebtw"
|
||||||
|
],
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://www.midnightdust.eu/",
|
||||||
|
"sources": "https://github.com/TeamMidnightDust/SwordBlocking",
|
||||||
|
"issues": "https://github.com/TeamMidnightDust/SwordBlocking/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"icon": "assets/swordblocking/icon.png",
|
||||||
|
"environment": "client",
|
||||||
|
"entrypoints": {
|
||||||
|
"client": [
|
||||||
|
"eu.midnightdust.swordblocking.fabric.SwordBlockingClientFabric"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"mixins": [
|
||||||
|
"swordblocking.mixins.json"
|
||||||
|
],
|
||||||
|
"depends": {
|
||||||
|
"fabric-api": "*",
|
||||||
|
"midnightlib": "*"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,24 @@
|
|||||||
# Done to increase the memory available to gradle.
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Game Version
|
||||||
# check these on https://fabricmc.net/use
|
minecraft_version=1.21.6
|
||||||
minecraft_version=1.16.4
|
yarn_mappings=1.21.6+build.1
|
||||||
yarn_mappings=1.16.4+build.7
|
yarn_mappings_patch_neoforge_version=1.21+build.4
|
||||||
loader_version=0.10.8
|
enabled_platforms=fabric,neoforge
|
||||||
|
|
||||||
# Mod Properties
|
|
||||||
mod_version = 1.0.0
|
|
||||||
maven_group = eu.midnightdust
|
|
||||||
archives_base_name = swordblocking
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
midnightlib_version=1.7.5+1.21.6
|
||||||
fabric_version=0.26.1+1.16
|
|
||||||
|
fabric_loader_version=0.16.14
|
||||||
|
fabric_api_version=0.127.1+1.21.6
|
||||||
|
|
||||||
|
neoforge_version=21.6.0-beta
|
||||||
|
|
||||||
|
# Information
|
||||||
|
archives_base_name=swordblocking
|
||||||
|
mod_version=2.2.2
|
||||||
|
maven_group=eu.midnightdust
|
||||||
|
release_type=release
|
||||||
|
curseforge_id=427738
|
||||||
|
modrinth_id=4q52b4lD
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
295
gradlew
vendored
Normal file → Executable file
295
gradlew
vendored
Normal file → Executable file
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,78 +17,111 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC2039,SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
(0) set -- ;;
|
|
||||||
(1) set -- "$args0" ;;
|
|
||||||
(2) set -- "$args0" "$args1" ;;
|
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=$(save "$@")
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
54
gradlew.bat
vendored
54
gradlew.bat
vendored
@@ -26,9 +26,13 @@ if "%OS%"=="Windows_NT" setlocal
|
|||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@@ -37,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -51,48 +55,36 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
111
neoforge/build.gradle
Normal file
111
neoforge/build.gradle
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.github.johnrengelman.shadow'
|
||||||
|
id "me.shedaniel.unified-publishing"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
architectury {
|
||||||
|
platformSetupLoomIde()
|
||||||
|
neoForge()
|
||||||
|
}
|
||||||
|
|
||||||
|
loom {
|
||||||
|
accessWidenerPath = project(":common").loom.accessWidenerPath
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
common {
|
||||||
|
canBeResolved = true
|
||||||
|
canBeConsumed = false
|
||||||
|
}
|
||||||
|
compileClasspath.extendsFrom common
|
||||||
|
runtimeClasspath.extendsFrom common
|
||||||
|
developmentNeoForge.extendsFrom common
|
||||||
|
|
||||||
|
// Files in this configuration will be bundled into your mod using the Shadow plugin.
|
||||||
|
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
|
||||||
|
shadowBundle {
|
||||||
|
canBeResolved = true
|
||||||
|
canBeConsumed = false
|
||||||
|
}
|
||||||
|
archivesBaseName = rootProject.archives_base_name + "-neoforge"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||||
|
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge")
|
||||||
|
|
||||||
|
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
|
||||||
|
shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge')
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property 'version', project.version
|
||||||
|
|
||||||
|
filesMatching('META-INF/neoforge.mods.toml') {
|
||||||
|
expand version: project.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
configurations = [project.configurations.shadowBundle]
|
||||||
|
archiveClassifier = 'dev-shadow'
|
||||||
|
}
|
||||||
|
|
||||||
|
remapJar {
|
||||||
|
input.set shadowJar.archiveFile
|
||||||
|
}
|
||||||
|
|
||||||
|
sourcesJar {
|
||||||
|
def commonSources = project(":common").sourcesJar
|
||||||
|
dependsOn commonSources
|
||||||
|
from commonSources.archiveFile.map { zipTree(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
components.java {
|
||||||
|
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||||
|
skip()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unifiedPublishing {
|
||||||
|
project {
|
||||||
|
displayName = "SwordBlocking $project.version - NeoForge $project.minecraft_version"
|
||||||
|
releaseType = "$project.release_type"
|
||||||
|
changelog = releaseChangelog()
|
||||||
|
gameVersions = []
|
||||||
|
gameLoaders = ["neoforge"]
|
||||||
|
mainPublication remapJar
|
||||||
|
relations {
|
||||||
|
includes {
|
||||||
|
curseforge = "midnightlib"
|
||||||
|
modrinth = "midnightlib"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
|
||||||
|
if (CURSEFORGE_TOKEN != null) {
|
||||||
|
curseforge {
|
||||||
|
token = CURSEFORGE_TOKEN
|
||||||
|
id = rootProject.curseforge_id
|
||||||
|
gameVersions.addAll "Java 21", project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
|
||||||
|
if (MODRINTH_TOKEN != null) {
|
||||||
|
modrinth {
|
||||||
|
token = MODRINTH_TOKEN
|
||||||
|
id = rootProject.modrinth_id
|
||||||
|
version = "$project.version-$project.name"
|
||||||
|
gameVersions.addAll project.minecraft_version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
loom.platform=neoforge
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package eu.midnightdust.swordblocking.neoforge;
|
||||||
|
|
||||||
|
import eu.midnightdust.swordblocking.SwordBlockingClient;
|
||||||
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
|
import static eu.midnightdust.swordblocking.SwordBlockingClient.MOD_ID;
|
||||||
|
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@Mod(value = MOD_ID, dist = Dist.CLIENT)
|
||||||
|
public class SwordBlockingClientNeoForge {
|
||||||
|
public SwordBlockingClientNeoForge() {
|
||||||
|
SwordBlockingClient.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
38
neoforge/src/main/resources/META-INF/neoforge.mods.toml
Normal file
38
neoforge/src/main/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
modLoader = "javafml"
|
||||||
|
loaderVersion = "[2,)"
|
||||||
|
#issueTrackerURL = ""
|
||||||
|
license = "MIT License"
|
||||||
|
|
||||||
|
[[mods]]
|
||||||
|
modId = "swordblocking"
|
||||||
|
version = "${version}"
|
||||||
|
displayName = "Sword Blocking"
|
||||||
|
logoFile = "icon.png"
|
||||||
|
authors = "Motschen, TeamMidnightDust, lowercasebtw"
|
||||||
|
description = '''
|
||||||
|
Adds sword blocking to new versions, you just need a shield in your offhand (or ViaVersion)!
|
||||||
|
'''
|
||||||
|
|
||||||
|
[[mixins]]
|
||||||
|
config = "swordblocking.mixins.json"
|
||||||
|
|
||||||
|
[[dependencies.visualoverhaul]]
|
||||||
|
modId = "neoforge"
|
||||||
|
mandatory = true
|
||||||
|
versionRange = "[21.0,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "BOTH"
|
||||||
|
|
||||||
|
[[dependencies.visualoverhaul]]
|
||||||
|
modId = "minecraft"
|
||||||
|
mandatory = true
|
||||||
|
versionRange = "[1.21,)"
|
||||||
|
ordering = "NONE"
|
||||||
|
side = "BOTH"
|
||||||
|
|
||||||
|
[[dependencies.visualoverhaul]]
|
||||||
|
modId = "picturesign"
|
||||||
|
mandatory = true
|
||||||
|
versionRange = "[1.0,)"
|
||||||
|
ordering = "AFTER"
|
||||||
|
side = "BOTH"
|
||||||
BIN
neoforge/src/main/resources/icon.png
Normal file
BIN
neoforge/src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
@@ -1,10 +1,15 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
maven { url "https://maven.fabricmc.net/" }
|
||||||
maven {
|
maven { url "https://maven.architectury.dev/" }
|
||||||
name = 'Fabric'
|
maven { url "https://maven.neoforged.net/releases" }
|
||||||
url = 'https://maven.fabricmc.net/'
|
|
||||||
}
|
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include("common")
|
||||||
|
include("fabric")
|
||||||
|
//include("quilt")
|
||||||
|
include("neoforge")
|
||||||
|
|
||||||
|
rootProject.name = "swordblocking"
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package eu.midnightdust.swordblocking;
|
|
||||||
|
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.SwordItem;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
|
|
||||||
public class SwordBlockingClient implements ClientModInitializer {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitializeClient() {
|
|
||||||
Registry.ITEM.forEach((item) -> {
|
|
||||||
if(item instanceof SwordItem) {
|
|
||||||
FabricModelPredicateProviderRegistry.register(item, new Identifier("blocking"), (stack, world, entity) ->
|
|
||||||
entity != null && entity.getOffHandStack().getItem().equals(Items.SHIELD) && entity.isUsingItem() ? 1.0F : 0.0F);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package eu.midnightdust.swordblocking.mixin;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
|
||||||
import net.minecraft.client.render.entity.PlayerEntityRenderer;
|
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.ShieldItem;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
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(PlayerEntityRenderer.class)
|
|
||||||
public abstract class MixinPlayerEntityRenderer {
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "getArmPose", cancellable = true)
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
private static void getArmPose(AbstractClientPlayerEntity abstractClientPlayerEntity, Hand hand, CallbackInfoReturnable<BipedEntityModel.ArmPose> cir) {
|
|
||||||
ItemStack itemStack = abstractClientPlayerEntity.getStackInHand(hand);
|
|
||||||
ItemStack itemStack2 = abstractClientPlayerEntity.getOffHandStack();
|
|
||||||
|
|
||||||
if (itemStack2.getItem() instanceof ShieldItem && abstractClientPlayerEntity.isUsingItem()) {
|
|
||||||
cir.setReturnValue(BipedEntityModel.ArmPose.BLOCK);
|
|
||||||
}
|
|
||||||
if (itemStack.getItem() instanceof ShieldItem) {
|
|
||||||
cir.setReturnValue(BipedEntityModel.ArmPose.EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/diamond_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/diamond_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/diamond_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/golden_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/golden_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/golden_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"credit": "https://github.com/FoundationGames/Parry/blob/master/src/main/resources/assets/minecraft/models/item/handheld_parry.json",
|
|
||||||
"parent": "item/handheld",
|
|
||||||
"display": {
|
|
||||||
"firstperson_righthand": {
|
|
||||||
"rotation": [ 171, 13, 165 ],
|
|
||||||
"translation": [ -2.8, -0.2, -5 ],
|
|
||||||
"scale": [ 1, 1, 1 ]
|
|
||||||
},
|
|
||||||
"firstperson_lefthand": {
|
|
||||||
"rotation": [ 171, 13, 75 ],
|
|
||||||
"translation": [ -2.8, -0.2, -5 ],
|
|
||||||
"scale": [ 1, 1, 1 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/iron_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/iron_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/iron_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/netherite_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/netherite_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/netherite_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "builtin/entity",
|
|
||||||
"gui_light": "front",
|
|
||||||
"textures": {
|
|
||||||
"particle": "block/dark_oak_planks"
|
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"thirdperson_righthand": {
|
|
||||||
"rotation": [ 0, 90, 0 ],
|
|
||||||
"translation": [ 10, 6, -4 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"thirdperson_lefthand": {
|
|
||||||
"rotation": [ 0, 90, 0 ],
|
|
||||||
"translation": [ 10, 6, 12 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"firstperson_righthand": {
|
|
||||||
"rotation": [ 0, 180, 5 ],
|
|
||||||
"translation": [ -10, 2, -10 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"firstperson_lefthand": {
|
|
||||||
"rotation": [ 0, 180, 5 ],
|
|
||||||
"translation": [ 10, 0, -10 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"gui": {
|
|
||||||
"rotation": [ 15, -25, -5 ],
|
|
||||||
"translation": [ 2, 3, 0 ],
|
|
||||||
"scale": [ 0.65, 0.65, 0.65 ]
|
|
||||||
},
|
|
||||||
"fixed": {
|
|
||||||
"rotation": [ 0, 180, 0 ],
|
|
||||||
"translation": [ -2, 4, -5],
|
|
||||||
"scale":[ 0.5, 0.5, 0.5]
|
|
||||||
},
|
|
||||||
"ground": {
|
|
||||||
"rotation": [ 0, 0, 0 ],
|
|
||||||
"translation": [ 4, 4, 2],
|
|
||||||
"scale":[ 0.25, 0.25, 0.25]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "item/shield_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "builtin/entity",
|
|
||||||
"gui_light": "front",
|
|
||||||
"textures": {
|
|
||||||
"particle": "block/dark_oak_planks"
|
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"thirdperson_righthand": {
|
|
||||||
"rotation": [ 45, 135, 0 ],
|
|
||||||
"translation": [ 3.51, 11, -2 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"thirdperson_lefthand": {
|
|
||||||
"rotation": [ 45, 135, 0 ],
|
|
||||||
"translation": [ 13.51, 3, 5 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"firstperson_righthand": {
|
|
||||||
"rotation": [ 0, 180, -5 ],
|
|
||||||
"translation": [ -15, 5, -11 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"firstperson_lefthand": {
|
|
||||||
"rotation": [ 0, 180, -5 ],
|
|
||||||
"translation": [ 5, 5, -11 ],
|
|
||||||
"scale": [ 0, 0, 0 ]
|
|
||||||
},
|
|
||||||
"gui": {
|
|
||||||
"rotation": [ 15, -25, -5 ],
|
|
||||||
"translation": [ 2, 3, 0 ],
|
|
||||||
"scale": [ 0.65, 0.65, 0.65 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/stone_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/stone_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/stone_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/wooden_sword"
|
|
||||||
},
|
|
||||||
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"predicate": {
|
|
||||||
"blocking": 1
|
|
||||||
},
|
|
||||||
"model": "minecraft:item/wooden_sword_blocking"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "minecraft:item/handheld_blocking",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "minecraft:item/wooden_sword"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"id": "swordblocking",
|
|
||||||
"version": "${version}",
|
|
||||||
|
|
||||||
"name": "Sword Blocking",
|
|
||||||
"description": "Adds sword blocking back to 1.16, you just need a shield in your offhand!",
|
|
||||||
"authors": [
|
|
||||||
"Motschen",
|
|
||||||
"TeamMidnightDust"
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"homepage": "https://www.midnightdust.eu/",
|
|
||||||
"sources": "https://github.com/TeamMidnightDust/SwordBlocking",
|
|
||||||
"issues": "https://github.com/TeamMidnightDust/SwordBlocking/issues"
|
|
||||||
},
|
|
||||||
|
|
||||||
"license": "MIT",
|
|
||||||
"icon": "assets/swordblocking/icon.png",
|
|
||||||
|
|
||||||
"environment": "client",
|
|
||||||
"entrypoints": {
|
|
||||||
"client": [
|
|
||||||
"eu.midnightdust.swordblocking.SwordBlockingClient"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
"mixins": [
|
|
||||||
"swordblocking.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
|
||||||
"fabric": "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "eu.midnightdust.swordblocking.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"client": [
|
|
||||||
"MixinPlayerEntityRenderer"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user