Jump to content

Recommended Posts

Posted

I am making a custom enchant that makes a sword do more damage. Does anyone know how I could make this? I already have the beginning down.

package com.idtech.enchantment;
import com.idtech.Utils;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.*;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.level.Level;
public class Razor extends Enchantment {

private static EquipmentSlot[] slots = {EquipmentSlot.MAINHAND};
public static final Razor INSTANCE = (Razor) (new Razor(Rarity.RARE, EnchantmentCategory.WEAPON, slots).setRegistryName("razor"));
protected Razor(Rarity p_44676_, EnchantmentCategory p_44677_, EquipmentSlot[] p_44678_) {
super(p_44676_, p_44677_, p_44678_);
}
@ Overide
public void doPostAttack(LivingEntity pAttacker, Entity pTarget, int pLevel) {

if (!pAttacker.level.isClientSide()) {
ServerLevel world = (ServerLevel) pAttacker.level;
ServerPlayer player = ((ServerPlayer) pAttacker);
BlockPos position = pTarget.blockPosition();
if (pLevel == 5) {

}
}

}
}
}

Posted
1 hour ago, Modderuy said:

public static final Razor INSTANCE = (Razor) (new Razor(Rarity.RARE, EnchantmentCategory.WEAPON, slots).setRegistryName("razor"));

you can not create Enchantments in static initializer, you should use DeferredRegister (recommend)

1 hour ago, Modderuy said:

I am making a custom enchant that makes a sword do more damage.

you can override Enchantment#getDamageBonus, and return the additional damage you want

Posted

i did

 

@Override public void doPostAttack(LivingEntity pAttacker, Entity pTarget, int pLevel) { if (!pAttacker.level.isClientSide()) { ServerLevel world = (ServerLevel) pAttacker.level; ServerPlayer player = ((ServerPlayer) pAttacker); BlockPos position = pTarget.blockPosition(); double val = Math.random(); if (pLevel == 5) { public float getDamageBonus(0.05);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.