#Workspace #mod-dev

24 messages · Page 1 of 1 (latest)

shy jackal
#

#mod-dev-1
Does anyone have time today to jump in a call and help me set up my workspace for 1.21, been having issues for the past week or so and it would honestly mean a lot at this point

quick compass
#

it's unlikely people here will hop on a call

#

what problems are you facing?

shy jackal
quick compass
#

i'll need more details before i even give you an answer

shy jackal
#

Hang on let me show you my code

#

package com.example.noleatherdamage;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;

public class DamageBlockListener implements ModInitializer {
@Override
public void onInitialize() {
AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
if (entity instanceof PlayerEntity targetPlayer) {
if (isWearingFullLeather(targetPlayer) && isBlockingWithSword(targetPlayer)) {
return ActionResult.FAIL; // cancel damage
}
}
return ActionResult.PASS;
});
}

private boolean isWearingFullLeather(PlayerEntity player) {
    return isLeather(player.getEquippedStack(EquipmentSlot.HEAD).getItem()) &&
           isLeather(player.getEquippedStack(EquipmentSlot.CHEST).getItem()) &&
           isLeather(player.getEquippedStack(EquipmentSlot.LEGS).getItem()) &&
           isLeather(player.getEquippedStack(EquipmentSlot.FEET).getItem());
}

private boolean isLeather(net.minecraft.item.Item item) {
    return item instanceof ArmorItem armor && armor.getMaterial().getName().equals("leather");
}

private boolean isBlockingWithSword(PlayerEntity player) {
    return player.isBlocking() && player.getActiveItem().getItem().toString().contains("sword");
}

}

glacial cobalt
#

All steps for do 1.21.1 workspace:
Instail Java
Instail JDK Java 21
Create and instail fabric template for 1.21.1 zip
Instail inteljia
Extract template zip into any folder
Open template folder from inteljia
Enter any class like Mod Main or ModClient and choice JDK above (I'm not sure, but it only seems to appear if you have a few JDKs)
Open console and enter .\gradlew genSources or ./gradlew genSources
Wait until all load
Press shift two times, place V on "show non project files" and input smth like PistonBlock or any other class from vanila minecraft, open that class and choice sources (jar that you load when used .\gradlew genSources, optional because it's just load documentation and make code more readable)
Close inteljia and open it, launch minecraft client, if you do all right you get fabric 1.21.1 minecraft without mods.

shy jackal
#

None of these imports are working etc

glacial cobalt
#

What guide did you even watch???

shy jackal
#

YouTube

glacial cobalt
#

You should input methods instance in onInitialize that name whatever your mod name

#

For example if I has mod name: MagicCreateAddon I has class in src MagicCreateAddon that implement ModIntiliaze and I put methods on it like:
onIntiliaze() {
MagicCreateAddonBlocks.register()
}

#

MagicCreateAddonBlocks In that example it's other class that register blocks for mod.

#

But you do all code in onIntiliaze...

shy jackal
#

I see @glacial cobalt make it more clean and organized

#

But would this import the libraries if I did it this way?

glacial cobalt
#

Test your libraries with any easy code like just block without functional and texture

shy jackal
#

Actually I think this makes sense cus i dont think my logger message was printing

glacial cobalt
#

In this Minecraft Modding Tutorial, we are adding custom items to Minecraft using the Fabric API for Minecraft 1.21.

== 1.21 MODDING COURSES ==
▶️ NeoForge Modding with Minecraft 1.21.X:
https://url.kaupenjoe.net/CourseNeoForge121X
▶️ Fabric Modding with Minecraft 1.21.X:
https://url.kaupenjoe.net/CourseFabric121X
▶️ Forge Modding...

▶ Play video
glacial cobalt