diff --git a/src/main/java/paulevs/betternether/blocks/BlockOre.java b/src/main/java/paulevs/betternether/blocks/BlockOre.java index f278a89aa..6a3040e7d 100644 --- a/src/main/java/paulevs/betternether/blocks/BlockOre.java +++ b/src/main/java/paulevs/betternether/blocks/BlockOre.java @@ -32,10 +32,6 @@ public BlockOre(Item drop, int minCount, int maxCount, int experience, int minin ); } - private static Item dropper(){ - return NetherItems.AGAVE_LEAF; - } - @Override public void addTags(List> blockTags, List> itemTags) { blockTags.add(NamedMineableTags.PICKAXE); diff --git a/src/main/java/paulevs/betternether/enchantments/ObsidianBreaker.java b/src/main/java/paulevs/betternether/enchantments/ObsidianBreaker.java new file mode 100644 index 000000000..406002098 --- /dev/null +++ b/src/main/java/paulevs/betternether/enchantments/ObsidianBreaker.java @@ -0,0 +1,57 @@ +package paulevs.betternether.enchantments; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.DiggerItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import paulevs.betternether.registry.NetherBlocks; +import ru.bclib.api.tag.CommonBlockTags; + +public class ObsidianBreaker extends Enchantment { + public ObsidianBreaker() { + super(Rarity.VERY_RARE, EnchantmentCategory.DIGGER, EquipmentSlot.values()); + } + + @Override + public int getMaxLevel() { + return 3; + } + + @Override + public boolean isCurse() { + return true; + } + + @Override + public boolean isTreasureOnly() { + return true; + } + + @Override + public boolean isTradeable() { + return false; + } + + @Override + public boolean isDiscoverable() { + return false; + } + + public static float getDestroySpeedMultiplier(BlockState state, float baseSpeed, float level){ + if ((state.is(CommonBlockTags.NETHER_STONES) + || state.is(CommonBlockTags.NETHER_PORTAL_FRAME) + || state.is(Blocks.OBSIDIAN) + || state.is(Blocks.CRYING_OBSIDIAN) + || state.is(NetherBlocks.BLUE_CRYING_OBSIDIAN) + || state.is(NetherBlocks.WEEPING_OBSIDIAN) + || state.is(NetherBlocks.BLUE_WEEPING_OBSIDIAN))) { + float speed = baseSpeed * level * 6; + return speed; + } + return baseSpeed; + } +} diff --git a/src/main/java/paulevs/betternether/enchantments/RubyFire.java b/src/main/java/paulevs/betternether/enchantments/RubyFire.java new file mode 100644 index 000000000..5ca2a32b4 --- /dev/null +++ b/src/main/java/paulevs/betternether/enchantments/RubyFire.java @@ -0,0 +1,161 @@ +package paulevs.betternether.enchantments; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TieredItem; +import net.minecraft.world.item.crafting.BlastingRecipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; +import paulevs.betternether.items.NetherArmor; +import paulevs.betternether.items.materials.BNToolMaterial; +import paulevs.betternether.registry.NetherEnchantments; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +public class RubyFire extends Enchantment { + private static final EquipmentSlot[] ARMOR_SLOTS = new EquipmentSlot[] {EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; + + public RubyFire() { + super(Rarity.VERY_RARE, EnchantmentCategory.BREAKABLE, ARMOR_SLOTS); + } + + @Override + public boolean canEnchant(ItemStack itemStack) { + if (itemStack == null) return false; + final Item i = itemStack.getItem(); + + if (i instanceof TieredItem t) { + return t.getTier() == BNToolMaterial.NETHER_RUBY; + } + + return i instanceof NetherArmor; + } + + @Override + public boolean isCurse() { + return true; + } + + @Override + public boolean isTreasureOnly() { + return true; + } + + @Override + public boolean isTradeable() { + return false; + } + + @Override + public boolean isDiscoverable() { + return false; + } + + @Override + public void doPostHurt(LivingEntity player, Entity entity, int i) { + final Random random = player.getRandom(); + Map.Entry entry = EnchantmentHelper.getRandomItemWith(NetherEnchantments.RUBY_FIRE, player); + if (shouldHit(i, random)) { + if (entity != null) { + entity.hurt(DamageSource.indirectMagic(entity, entity), getDamage(i, random)); + entity.setRemainingFireTicks(100 + 50 * random.nextInt(3)); + if (entity instanceof LivingEntity living){ + living.knockback(1 + random.nextFloat(2.0f), player.getX() - living.getX(), player.getZ() - living.getZ()); + } + } + + if (entry != null) { + entry.getValue() + .hurtAndBreak(1, player, livingEntity -> livingEntity.broadcastBreakEvent(entry.getKey())); + } + } + } + + private static boolean shouldHit(int i, Random random) { + if (i <= 0) return false; + return random.nextFloat() < 0.20f * i; + } + + private static int getDamage(int i, Random random) { + if (i > 10) return i - 10; + return 2 + random.nextInt(5); + } + + + private static Map FIRE_CONVERSIONS = new HashMap<>(); + public static final ThreadLocal> convertedDrops = ThreadLocal.withInitial(ArrayList::new); + + public static boolean getDrops(BlockState brokenBlock, ServerLevel level, BlockPos blockPos, Player player, ItemStack breakingItem) { + final int fireLevel = EnchantmentHelper.getItemEnchantmentLevel(NetherEnchantments.RUBY_FIRE, breakingItem); + if (fireLevel > 0) { + if (FIRE_CONVERSIONS.isEmpty()) buildConversionTable(level); + + boolean didConvert = false; + int xpDrop = 0; + final List drops = Block.getDrops(brokenBlock, level, blockPos, null, player, breakingItem); + convertedDrops.get().clear(); + + for (ItemStack stack : drops){ + BlastingRecipe result = FIRE_CONVERSIONS.get(stack.getItem()); + if (result != null) { + didConvert = true; + final ItemStack resultStack = result.getResultItem(); + xpDrop += result.getExperience(); + convertedDrops.get().add(new ItemStack(resultStack.getItem(), resultStack.getCount() * stack.getCount())); + } else { + convertedDrops.get().add(stack); + } + } + + if (didConvert) { + if (xpDrop>0){ + popExperience(level, blockPos, xpDrop); + } + convertedDrops.get().forEach(itemStack -> Block.popResource(level, blockPos, itemStack)); + brokenBlock.spawnAfterBreak(level, blockPos, breakingItem); + convertedDrops.get().clear(); + return true; + } + convertedDrops.get().clear(); + } + + return false; + } + + private static void popExperience(ServerLevel level, BlockPos blockPos, int amount) { + if (level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { + ExperienceOrb.award(level, Vec3.atCenterOf(blockPos), amount); + } + } + + private static void buildConversionTable(ServerLevel level) { + final List recipes = level.getRecipeManager() + .getAllRecipesFor(RecipeType.BLASTING); + for (BlastingRecipe r : recipes) { + for (Ingredient ingredient : r.getIngredients()) { + for (ItemStack stack : ingredient.getItems()) { + FIRE_CONVERSIONS.put(stack.getItem(), r); + } + } + } + } +} diff --git a/src/main/java/paulevs/betternether/interfaces/InitialStackStateProvider.java b/src/main/java/paulevs/betternether/interfaces/InitialStackStateProvider.java new file mode 100644 index 000000000..7946f5e12 --- /dev/null +++ b/src/main/java/paulevs/betternether/interfaces/InitialStackStateProvider.java @@ -0,0 +1,7 @@ +package paulevs.betternether.interfaces; + +import net.minecraft.world.item.ItemStack; + +public interface InitialStackStateProvider { + public void initializeState(ItemStack stack); +} diff --git a/src/main/java/paulevs/betternether/items/NetherArmor.java b/src/main/java/paulevs/betternether/items/NetherArmor.java index 30f43e50d..a7f16e8d3 100644 --- a/src/main/java/paulevs/betternether/items/NetherArmor.java +++ b/src/main/java/paulevs/betternether/items/NetherArmor.java @@ -2,11 +2,34 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNArmorMaterial; +import paulevs.betternether.registry.NetherEnchantments; import paulevs.betternether.registry.NetherItems; import ru.bclib.items.BaseArmorItem; -public class NetherArmor extends BaseArmorItem { +import java.util.HashMap; +import java.util.Map; + +public class NetherArmor extends BaseArmorItem implements InitialStackStateProvider { public NetherArmor(ArmorMaterial material, EquipmentSlot slot) { super(material, slot, NetherItems.defaultSettings()); } + + static final Map DEFAULT_RUBY_ENCHANTS; + + @Override + public void initializeState(ItemStack stack) { + if (material== BNArmorMaterial.NETHER_RUBY) { + EnchantmentHelper.setEnchantments(DEFAULT_RUBY_ENCHANTS, stack); + } + } + + static { + DEFAULT_RUBY_ENCHANTS = new HashMap<>(); + DEFAULT_RUBY_ENCHANTS.put(NetherEnchantments.RUBY_FIRE, 1); + } } diff --git a/src/main/java/paulevs/betternether/items/NetherAxe.java b/src/main/java/paulevs/betternether/items/NetherAxe.java index bb610402f..cffab34c9 100644 --- a/src/main/java/paulevs/betternether/items/NetherAxe.java +++ b/src/main/java/paulevs/betternether/items/NetherAxe.java @@ -5,15 +5,19 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNArmorMaterial; +import paulevs.betternether.items.materials.BNToolMaterial; import paulevs.betternether.registry.NetherItems; import ru.bclib.interfaces.TagProvider; import ru.bclib.items.tool.BaseAxeItem; import java.util.List; -public class NetherAxe extends BaseAxeItem { +public class NetherAxe extends BaseAxeItem implements InitialStackStateProvider { public NetherAxe(Tier material) { super(material, 1, -2.8F, NetherItems.defaultSettings().fireResistant()); } @@ -22,4 +26,11 @@ public NetherAxe(Tier material) { public float getDestroySpeed(ItemStack stack, BlockState state) { return super.getDestroySpeed(stack, state); } + + @Override + public void initializeState(ItemStack stack) { + if (getTier()== BNToolMaterial.NETHER_RUBY) { + EnchantmentHelper.setEnchantments(NetherArmor.DEFAULT_RUBY_ENCHANTS, stack); + } + } } diff --git a/src/main/java/paulevs/betternether/items/NetherHoe.java b/src/main/java/paulevs/betternether/items/NetherHoe.java index b25960d8d..8b260e7fb 100644 --- a/src/main/java/paulevs/betternether/items/NetherHoe.java +++ b/src/main/java/paulevs/betternether/items/NetherHoe.java @@ -5,15 +5,18 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNToolMaterial; import paulevs.betternether.registry.NetherItems; import ru.bclib.interfaces.TagProvider; import ru.bclib.items.tool.BaseHoeItem; import java.util.List; -public class NetherHoe extends BaseHoeItem { +public class NetherHoe extends BaseHoeItem implements InitialStackStateProvider { public NetherHoe(Tier material) { super(material, 1, -2.8F, NetherItems.defaultSettings().fireResistant()); @@ -23,4 +26,11 @@ public NetherHoe(Tier material) { public float getDestroySpeed(ItemStack stack, BlockState state) { return super.getDestroySpeed(stack, state); } + + @Override + public void initializeState(ItemStack stack) { + if (getTier()== BNToolMaterial.NETHER_RUBY) { + EnchantmentHelper.setEnchantments(NetherArmor.DEFAULT_RUBY_ENCHANTS, stack); + } + } } diff --git a/src/main/java/paulevs/betternether/items/NetherPickaxe.java b/src/main/java/paulevs/betternether/items/NetherPickaxe.java index 5aaec1b6e..c2f18494b 100644 --- a/src/main/java/paulevs/betternether/items/NetherPickaxe.java +++ b/src/main/java/paulevs/betternether/items/NetherPickaxe.java @@ -2,29 +2,36 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import paulevs.betternether.registry.NetherBlocks; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNToolMaterial; +import paulevs.betternether.registry.NetherEnchantments; import paulevs.betternether.registry.NetherItems; -import ru.bclib.api.tag.CommonBlockTags; import ru.bclib.items.tool.BasePickaxeItem; -public class NetherPickaxe extends BasePickaxeItem { +import java.util.HashMap; +import java.util.Map; + +public class NetherPickaxe extends BasePickaxeItem implements InitialStackStateProvider { public NetherPickaxe(Tier material) { super(material, 1, -2.8F, NetherItems.defaultSettings().fireResistant()); } - + @Override - public float getDestroySpeed(ItemStack stack, BlockState state) { - if ((state.is(CommonBlockTags.NETHER_STONES) - || state.is(CommonBlockTags.NETHER_PORTAL_FRAME) - || state.is(Blocks.OBSIDIAN) - || state.is(Blocks.CRYING_OBSIDIAN) - || state.is(NetherBlocks.BLUE_CRYING_OBSIDIAN) - || state.is(NetherBlocks.WEEPING_OBSIDIAN) - || state.is(NetherBlocks.BLUE_WEEPING_OBSIDIAN)) && this.getTier().getLevel() > 2) { - return super.getDestroySpeed(stack, state) * 10; + public void initializeState(ItemStack stack) { + Map defaultEnchants = new HashMap<>(); + + int obsidianLevel = 0; + if (this.getTier()== BNToolMaterial.CINCINNASITE_DIAMOND) obsidianLevel = 3; + else if (this.getTier()== BNToolMaterial.NETHER_RUBY) { + obsidianLevel = 2; + defaultEnchants.put(NetherEnchantments.RUBY_FIRE, 1); + } + + if (obsidianLevel>0) { + defaultEnchants.put(NetherEnchantments.OBSIDIAN_BREAKER, obsidianLevel); + EnchantmentHelper.setEnchantments(defaultEnchants, stack); } - return super.getDestroySpeed(stack, state); } } diff --git a/src/main/java/paulevs/betternether/items/NetherShovel.java b/src/main/java/paulevs/betternether/items/NetherShovel.java index cbc465fc2..42d808fe2 100644 --- a/src/main/java/paulevs/betternether/items/NetherShovel.java +++ b/src/main/java/paulevs/betternether/items/NetherShovel.java @@ -2,11 +2,14 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.block.state.BlockState; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNToolMaterial; import paulevs.betternether.registry.NetherItems; import ru.bclib.items.tool.BaseShovelItem; -public class NetherShovel extends BaseShovelItem { +public class NetherShovel extends BaseShovelItem implements InitialStackStateProvider { public NetherShovel(Tier material) { super(material, 1, -2.8F, NetherItems.defaultSettings().fireResistant()); } @@ -15,4 +18,11 @@ public NetherShovel(Tier material) { public float getDestroySpeed(ItemStack stack, BlockState state) { return super.getDestroySpeed(stack, state); } + + @Override + public void initializeState(ItemStack stack) { + if (getTier()== BNToolMaterial.NETHER_RUBY) { + EnchantmentHelper.setEnchantments(NetherArmor.DEFAULT_RUBY_ENCHANTS, stack); + } + } } diff --git a/src/main/java/paulevs/betternether/items/NetherSword.java b/src/main/java/paulevs/betternether/items/NetherSword.java index 3616d5715..6fc26f184 100644 --- a/src/main/java/paulevs/betternether/items/NetherSword.java +++ b/src/main/java/paulevs/betternether/items/NetherSword.java @@ -1,11 +1,22 @@ package paulevs.betternether.items; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import paulevs.betternether.interfaces.InitialStackStateProvider; +import paulevs.betternether.items.materials.BNToolMaterial; import paulevs.betternether.registry.NetherItems; import ru.bclib.items.tool.BaseSwordItem; -public class NetherSword extends BaseSwordItem { +public class NetherSword extends BaseSwordItem implements InitialStackStateProvider { public NetherSword(Tier material, int attackDamage, float attackSpeed) { super(material, attackDamage, attackSpeed, NetherItems.defaultSettings().fireResistant()); } + + @Override + public void initializeState(ItemStack stack) { + if (getTier()== BNToolMaterial.NETHER_RUBY) { + EnchantmentHelper.setEnchantments(NetherArmor.DEFAULT_RUBY_ENCHANTS, stack); + } + } } diff --git a/src/main/java/paulevs/betternether/mixin/common/BlockBehaviourMixin.java b/src/main/java/paulevs/betternether/mixin/common/BlockBehaviourMixin.java new file mode 100644 index 000000000..bd45c1ecd --- /dev/null +++ b/src/main/java/paulevs/betternether/mixin/common/BlockBehaviourMixin.java @@ -0,0 +1,38 @@ +package paulevs.betternether.mixin.common; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.OreBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootContext.Builder; +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; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import paulevs.betternether.enchantments.RubyFire; +import paulevs.betternether.registry.NetherEnchantments; + +import java.util.List; + +@Mixin(Block.class) +public class BlockBehaviourMixin { + + + @Inject(method="dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)V", at=@At("HEAD"), cancellable = true) + private static void bn_getDrops(BlockState brokenBlock, Level level, BlockPos blockPos, BlockEntity blockEntity, Entity breakingEntity, ItemStack breakingItem, CallbackInfo ci) { + if ((level instanceof ServerLevel server) && (breakingEntity instanceof Player player)){ + if (RubyFire.getDrops(brokenBlock, server, blockPos, player, breakingItem)){ + ci.cancel(); + } + } + } +} diff --git a/src/main/java/paulevs/betternether/mixin/common/DiggerItemMixin.java b/src/main/java/paulevs/betternether/mixin/common/DiggerItemMixin.java new file mode 100644 index 000000000..0f7cd2a55 --- /dev/null +++ b/src/main/java/paulevs/betternether/mixin/common/DiggerItemMixin.java @@ -0,0 +1,23 @@ +package paulevs.betternether.mixin.common; + +import net.minecraft.world.item.DiggerItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.block.state.BlockState; +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; +import paulevs.betternether.enchantments.ObsidianBreaker; +import paulevs.betternether.registry.NetherEnchantments; + +@Mixin(DiggerItem.class) +public class DiggerItemMixin { + @Inject(method="getDestroySpeed", at=@At(value="RETURN"), cancellable = true) + void bn_getDestroySpeed(ItemStack stack, BlockState state, CallbackInfoReturnable cir){ + final int obsidianLevel = EnchantmentHelper.getItemEnchantmentLevel(NetherEnchantments.OBSIDIAN_BREAKER, stack); + if (obsidianLevel>0) { + cir.setReturnValue(ObsidianBreaker.getDestroySpeedMultiplier(state, cir.getReturnValue(), obsidianLevel)); + } + } +} diff --git a/src/main/java/paulevs/betternether/mixin/common/ItemStackMixin.java b/src/main/java/paulevs/betternether/mixin/common/ItemStackMixin.java new file mode 100644 index 000000000..d88751bb9 --- /dev/null +++ b/src/main/java/paulevs/betternether/mixin/common/ItemStackMixin.java @@ -0,0 +1,22 @@ +package paulevs.betternether.mixin.common; + +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.ItemLike; +import net.minecraft.world.level.block.state.BlockState; +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; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import paulevs.betternether.interfaces.InitialStackStateProvider; + +@Mixin(ItemStack.class) +public class ItemStackMixin { + @Inject(method="(Lnet/minecraft/world/level/ItemLike;I)V", at=@At(value="INVOKE", target="Lnet/minecraft/world/item/ItemStack;updateEmptyCacheFlag()V")) + public void bn_init(ItemLike itemLike, int i, CallbackInfo ci){ + ItemStack stack = (ItemStack) (Object)this; + if (itemLike instanceof InitialStackStateProvider forced){ + forced.initializeState(stack); + } + } +} diff --git a/src/main/java/paulevs/betternether/registry/NetherEnchantments.java b/src/main/java/paulevs/betternether/registry/NetherEnchantments.java new file mode 100644 index 000000000..9a75f7a10 --- /dev/null +++ b/src/main/java/paulevs/betternether/registry/NetherEnchantments.java @@ -0,0 +1,16 @@ +package paulevs.betternether.registry; + +import net.minecraft.core.Registry; +import net.minecraft.world.item.enchantment.Enchantment; +import paulevs.betternether.BetterNether; +import paulevs.betternether.enchantments.RubyFire; +import paulevs.betternether.enchantments.ObsidianBreaker; + +public class NetherEnchantments { + public static ObsidianBreaker OBSIDIAN_BREAKER = register("obsidian_breaker", new ObsidianBreaker()); + public static RubyFire RUBY_FIRE = register("ruby_fire", new RubyFire()); + + private static T register(String name, T enchantment) { + return Registry.register(Registry.ENCHANTMENT, BetterNether.makeID(name), enchantment); + } +} diff --git a/src/main/resources/assets/betternether/lang/de_de.json b/src/main/resources/assets/betternether/lang/de_de.json index f4a9a820e..257b3172e 100644 --- a/src/main/resources/assets/betternether/lang/de_de.json +++ b/src/main/resources/assets/betternether/lang/de_de.json @@ -723,5 +723,7 @@ "advancements.betternether.city.title":"Eine glorreiche Vergangenheit", "advancements.betternether.city.description":"Finde eine längst verlassene Nether-Stadt", - "biome.betternether.upside_down_forest_cleared": "Abgestorbener Kopfüberwald" + "biome.betternether.upside_down_forest_cleared": "Abgestorbener Kopfüberwald", + "enchantment.betternether.obsidian_breaker": "Obsidiangräber", + "enchantment.betternether.ruby_fire": "Rubinfeuer" } diff --git a/src/main/resources/assets/betternether/lang/en_us.json b/src/main/resources/assets/betternether/lang/en_us.json index 6167fb46a..7986eb22c 100644 --- a/src/main/resources/assets/betternether/lang/en_us.json +++ b/src/main/resources/assets/betternether/lang/en_us.json @@ -723,5 +723,7 @@ "advancements.betternether.city.title":"A glorious Past", "advancements.betternether.city.description":"Find a long abandoned Nether City", - "biome.betternether.upside_down_forest_cleared": "Dead Upside Down Forest" + "biome.betternether.upside_down_forest_cleared": "Dead Upside Down Forest", + "enchantment.betternether.obsidian_breaker": "Obsidian Breaker", + "enchantment.betternether.ruby_fire": "Rubys' Fire" } diff --git a/src/main/resources/betternether.mixins.common.json b/src/main/resources/betternether.mixins.common.json index d1c48b50d..e863cc6f6 100644 --- a/src/main/resources/betternether.mixins.common.json +++ b/src/main/resources/betternether.mixins.common.json @@ -3,29 +3,32 @@ "package": "paulevs.betternether.mixin.common", "compatibilityLevel": "JAVA_17", "mixins": [ - "AbstractFurnaceBlockEntityMixin", - "BastionRemnantFeatureMixin", - "BoneMealMixin", - "BrewingRecipeRegistryMixin", - "ChunkSerializerMixin", - "CraftingScreenHandlerMixin", - "DefaultAttributeRegistryMixin", - "DeltaFeatureMixin", - "LeavesBlockMixin", - "MapMixin", - "MapStateMixin", - "MiningToolItemMixin", - "MushroomMixin", - "NetherFortressFeatureMixin", - "NetherWartMixin", - "PlayerEntityMixin", - "RecipeManagerAccessor", - "RecipeManagerMixin", - "BlockAgeProcessorMixin", - "LiquidBlockMixin", - "LightningRodBlockMixin", - "StructureFeaturesAcessor" - ], + "AbstractFurnaceBlockEntityMixin", + "BastionRemnantFeatureMixin", + "BlockAgeProcessorMixin", + "BoneMealMixin", + "BrewingRecipeRegistryMixin", + "ChunkSerializerMixin", + "CraftingScreenHandlerMixin", + "DefaultAttributeRegistryMixin", + "DeltaFeatureMixin", + "DiggerItemMixin", + "ItemStackMixin", + "LeavesBlockMixin", + "LightningRodBlockMixin", + "LiquidBlockMixin", + "MapMixin", + "MapStateMixin", + "MiningToolItemMixin", + "MushroomMixin", + "NetherFortressFeatureMixin", + "NetherWartMixin", + "BlockBehaviourMixin", + "PlayerEntityMixin", + "RecipeManagerAccessor", + "RecipeManagerMixin", + "StructureFeaturesAcessor" + ], "injectors": { "defaultRequire": 1 }