Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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) {

}
}

}
}
}

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

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.