mirror of
https://github.com/TeamMidnightDust/SwordBlocking.git
synced 2025-12-15 22:45:09 +01:00
First release!
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/diamond_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/diamond_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/diamond_sword"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/golden_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/golden_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/golden_sword"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/iron_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/iron_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/iron_sword"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/netherite_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/netherite_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/netherite_sword"
|
||||
}
|
||||
}
|
||||
52
src/main/resources/assets/minecraft/models/item/shield.json
Normal file
52
src/main/resources/assets/minecraft/models/item/shield.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"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 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/stone_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/stone_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/stone_sword"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/wooden_sword"
|
||||
},
|
||||
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"blocking": 1
|
||||
},
|
||||
"model": "minecraft:item/wooden_sword_blocking"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/handheld_blocking",
|
||||
"textures": {
|
||||
"layer0": "minecraft:item/wooden_sword"
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/swordblocking/icon.png
Normal file
BIN
src/main/resources/assets/swordblocking/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
35
src/main/resources/fabric.mod.json
Normal file
35
src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"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": "*"
|
||||
}
|
||||
}
|
||||
11
src/main/resources/swordblocking.mixins.json
Normal file
11
src/main/resources/swordblocking.mixins.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "eu.midnightdust.swordblocking.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"client": [
|
||||
"MixinPlayerEntityRenderer"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user