Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.minerology;
- import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
- import net.minecraftforge.fml.common.Mod;
- import net.minecraftforge.eventbus.api.SubscribeEvent;
- import net.minecraftforge.event.TickEvent.PlayerTickEvent;
- import net.minecraft.world.World;
- import net.minecraft.item.Items;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.item.ItemStack;
- import net.minecraft.inventory.EquipmentSlotType;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.entity.player.PlayerEntity;
- import net.minecraft.enchantment.Enchantments;
- import net.minecraft.enchantment.EnchantmentType;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.util.EnumParticleTypes;
- import net.minecraft.util.EnumActionResult;
- public class MagneticEnchant extends Enchantment {
- /**
- * Do not remove this constructor
- */
- public MagneticEnchant(Rarity rarityIn, EnchantmentType typeIn, EquipmentSlotType[] slots) {
- super(rarityIn, typeIn, slots);
- }
- public int getMaxLevel() {
- return 5;
- }
- public int getMinLevel() {
- return 1;
- }
- protected boolean canApplyTogetger(Enchantment ench){
- return super.canApplyTogether(ench);
- }
- public int getMinEnchantability(int enchantmentLevel) {
- return enchzntmentLevel * 10;
- }
- public getMaxEnchantability(int enchantmentLevel) {
- return thiss.getMinEnchantability(enchantmentLevel) + 15;
- }
- public static void class MagneticEquipped {
- public static void doStuff(PlayerTickEvent event) {
- PlayerEntity playerIn = event.player;
- World worldIn = playerIn.world;
- int x = (int) playerIn.getPosX();
- int y = (int) playerIn.getPosY();
- int x = (int) playerIn.getPosZ();
- ItemStack hand = playerIn.getItemStackFromSlot(EquipmentSlotType.HAND);
- int enchantLevel = EnchantmentHelper.getEnchantmentLevel(EnchantmentInit.MAGNETIC.get(), playerIn.getItemStackFromSlotType.HAND));
- int radius = 5 * enchantLevel;
- int radSq = radius * radius;
- AxisAlignedBB area = new AxisAlignedBB(player.getPosition().add(-radius, -radius, -radius), player.getPosition().add(1 + radius, 1 + radius, 1 + radius));
- List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, area, EntitySelectors.IS_ALIVE);
- if(EnchantmentHelper.getEnchantmentLevel(EnchantmentInit.MAGNETIC.get(), playerIn.getJeldItemMainhand()) > 0) {
- if (ServerHelper.isClientWorld(world)){
- for(EntityItem item : items){
- if(item.getPositionVector().squareDistanceTo(player.getPositionVector()) <= radSq){
- worlld.spawnParticile(EnumParticleTypes.CLOUD, item.posX, item.posY, item.posZ, 0, 0, 0, 0);
- }
- }
- }else {
- int itemCount = 0;
- for (EntityItem item : items){
- if(item.getPositionVector().squareDistanceTo(traceResult.hitvec) <= radSq){
- item.setPosition(player.posX, player.posY, player.posZ);
- item.setPickupDelay(0);
- itemCount++;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment