This commit is contained in:
nimsolated
2026-03-23 22:09:44 -07:00
parent 519ac6e06f
commit 0daca60588
11 changed files with 208 additions and 15 deletions

View File

@@ -0,0 +1,42 @@
package net.mcreator.arisrandomadditions.enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.tags.ItemTags;
import net.minecraft.resources.ResourceLocation;
import java.util.List;
public class SweetBladeEnchantmentEnchantment extends Enchantment {
private static final EnchantmentCategory ENCHANTMENT_CATEGORY = EnchantmentCategory.create("aris_random_additions_sweet_blade_enchantment",
item -> Ingredient.of(ItemTags.create(new ResourceLocation("minecraft:swords"))).test(new ItemStack(item)));
public SweetBladeEnchantmentEnchantment() {
super(Enchantment.Rarity.RARE, ENCHANTMENT_CATEGORY, new EquipmentSlot[]{EquipmentSlot.MAINHAND});
}
@Override
public int getMinCost(int level) {
return 1 + level * 10;
}
@Override
public int getMaxCost(int level) {
return 6 + level * 10;
}
@Override
public int getMaxLevel() {
return 3;
}
@Override
protected boolean checkCompatibility(Enchantment enchantment) {
return super.checkCompatibility(enchantment) && !List.of(Enchantments.FIRE_ASPECT).contains(enchantment);
}
}

View File

@@ -10,6 +10,7 @@ import net.minecraftforge.registries.DeferredRegister;
import net.minecraft.world.item.enchantment.Enchantment;
import net.mcreator.arisrandomadditions.enchantment.SweetBladeEnchantmentEnchantment;
import net.mcreator.arisrandomadditions.enchantment.SunderingEnchantmentEnchantment;
import net.mcreator.arisrandomadditions.enchantment.RuiningEnchantmentEnchantment;
import net.mcreator.arisrandomadditions.enchantment.PassiveIncomeEnchantmentEnchantment;
@@ -22,4 +23,5 @@ public class ArisRandomAdditionsModEnchantments {
public static final RegistryObject<Enchantment> RUINING_ENCHANTMENT = REGISTRY.register("ruining_enchantment", () -> new RuiningEnchantmentEnchantment());
public static final RegistryObject<Enchantment> SUNDERING_ENCHANTMENT = REGISTRY.register("sundering_enchantment", () -> new SunderingEnchantmentEnchantment());
public static final RegistryObject<Enchantment> LIFE_MENDING_ENCHANTMENT = REGISTRY.register("life_mending_enchantment", () -> new LifeMendingEnchantmentEnchantment());
public static final RegistryObject<Enchantment> SWEET_BLADE_ENCHANTMENT = REGISTRY.register("sweet_blade_enchantment", () -> new SweetBladeEnchantmentEnchantment());
}

View File

@@ -43,7 +43,7 @@ public class BedrockPickaxeItem extends PickaxeItem {
@Override
public boolean onEntitySwing(ItemStack itemstack, LivingEntity entity) {
boolean retval = super.onEntitySwing(itemstack, entity);
BedrockPickaxeEntitySwingsItemProcedure.execute(entity.level(), entity);
BedrockPickaxeEntitySwingsItemProcedure.execute(entity.level(), entity, itemstack);
return retval;
}
}

View File

@@ -8,6 +8,8 @@ import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.Entity;
@@ -22,7 +24,7 @@ import net.mcreator.arisrandomadditions.init.ArisRandomAdditionsModBlocks;
import java.util.Map;
public class BedrockPickaxeEntitySwingsItemProcedure {
public static void execute(LevelAccessor world, Entity entity) {
public static void execute(LevelAccessor world, Entity entity, ItemStack itemstack) {
if (entity == null)
return;
if (!world.isClientSide()) {
@@ -63,14 +65,26 @@ public class BedrockPickaxeEntitySwingsItemProcedure {
ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("block.stone.break")), SoundSource.BLOCKS, (float) 0.8, (float) 0.8, false);
}
}
if (world instanceof ServerLevel _level) {
ItemEntity entityToSpawn = new ItemEntity(_level,
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
new ItemStack(ArisRandomAdditionsModItems.BEDROCK_SHARD.get()));
entityToSpawn.setPickUpDelay(10);
_level.addFreshEntity(entityToSpawn);
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) != 0) {
if (world instanceof ServerLevel _level) {
ItemEntity entityToSpawn = new ItemEntity(_level,
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
new ItemStack(Blocks.BEDROCK));
entityToSpawn.setPickUpDelay(2);
_level.addFreshEntity(entityToSpawn);
}
} else {
if (world instanceof ServerLevel _level) {
ItemEntity entityToSpawn = new ItemEntity(_level,
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getY()),
(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getZ()),
new ItemStack(ArisRandomAdditionsModItems.BEDROCK_SHARD.get()));
entityToSpawn.setPickUpDelay(2);
_level.addFreshEntity(entityToSpawn);
}
}
} else if ((world.getBlockState(
new BlockPos(entity.level().clip(new ClipContext(entity.getEyePosition(1f), entity.getEyePosition(1f).add(entity.getViewVector(1f).scale(4.5)), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getBlockPos().getX(),

View File

@@ -0,0 +1,48 @@
package net.mcreator.arisrandomadditions.procedures;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerLevel;
import net.mcreator.arisrandomadditions.init.ArisRandomAdditionsModEnchantments;
import javax.annotation.Nullable;
@Mod.EventBusSubscriber
public class SweetBladeProcedureProcedure {
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event) {
if (event != null && event.getEntity() != null) {
execute(event, event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), event.getSource().getEntity());
}
}
public static void execute(LevelAccessor world, double x, double y, double z, Entity sourceentity) {
execute(null, world, x, y, z, sourceentity);
}
private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z, Entity sourceentity) {
if (sourceentity == null)
return;
if (!((sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == ItemStack.EMPTY.getItem())
&& EnchantmentHelper.getItemEnchantmentLevel(ArisRandomAdditionsModEnchantments.SWEET_BLADE_ENCHANTMENT.get(), (sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)) != 0) {
for (int index0 = 0; index0 < (sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getEnchantmentLevel(ArisRandomAdditionsModEnchantments.SWEET_BLADE_ENCHANTMENT.get()); index0++) {
if (world instanceof ServerLevel _level) {
ItemEntity entityToSpawn = new ItemEntity(_level, x, y, z, new ItemStack(Items.SWEET_BERRIES));
entityToSpawn.setPickUpDelay(10);
_level.addFreshEntity(entityToSpawn);
}
}
}
}
}

View File

@@ -1,10 +1,10 @@
modLoader="javafml"
loaderVersion="[47,)"
license="Academic Free License v3.0"
license="MIT License"
[[mods]]
modId="aris_random_additions"
version="2.0.2"
version="2.0.3"
displayName="Ari's Random Additions"
displayURL="https://mcreator.net"
logoFile="logo.png"

View File

@@ -177,6 +177,7 @@
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
"item.nims_random_bullshit.wand_of_resizing.description_0": "DISCLAIMER: Does not work with Origins that periodically reset your scale!",
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
"enchantment.aris_random_additions.sweet_blade_enchantment": "Sweet Blade",
"item.aris_random_additions.turd": "Turd",
"item.aris_random_additions.pocket_lightning.description_0": "Spawns lightning wherever it lands.",
"item.nims_random_bullshit.netherrackite_pickaxe": "Netherrackite Pickaxe",