Jump to content

quicheman

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by quicheman

  1. Hi, I'm new to modding minecraft and modding in general. I'm trying to make an item that highlights nearby mobs with the Glowing potion effect for a limited time. I've come up with the following code. It applies the potion effects to the player as desired, and I've confirmed that it also applies the Glowing effect to other mobs as desired. But the update method I've come up with doesn't seem to make the effect persist. I don't think the update method is being called, because I saw no STDOUT output from any System.out.println() statements when I put those in the update method. Any advice on how to resolve this would be greatly appreciated. Also, I'm not really sure this is the best way to go about this in general. I'm just tinkering with minecraft as I'm bored over the holidays. So if you have any advice on how to better approach this type of item in general that would also be appreciated. public class ItemMentats extends ItemBase implements ITickable { private String name; private SoundEvent sound; private SoundCategory soundCategory; private int stackSize = 8; private int duration = 2000; private float volume = 0.5f; private float pitch = 0.8f; private World world = null; private EntityPlayer player = null; private boolean isActive = false; private long startTime = 0; public ItemMentats(String name) { super(name); this.name = name; this.maxStackSize = stackSize; } public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); if(!player.capabilities.isCreativeMode) { itemstack.shrink(1); } //world.playSound(()); player.getCooldownTracker().setCooldown(this, 20); //do stuff to player if(!world.isRemote) { this.world = world; this.player = player; DoChemEffect(player, itemstack); } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack); } private void DoChemEffect(EntityPlayer player, ItemStack itemstack) { player.addPotionEffect(new PotionEffect(MobEffects.GLOWING, duration, 1)); player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, duration, 1)); player.addPotionEffect(new PotionEffect(MobEffects.LUCK, duration, 0)); player.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 100)); List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, Utils.AABBfromVector( this.player.getPositionVector().subtract(12,12,12), this.player.getPositionVector().addVector(12,12,12))); for(EntityLivingBase e : entities) { e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 20)); } isActive = true; startTime = world.getTotalWorldTime(); } @Override public void update() { long time = 0; if(world != null) time = world.getTotalWorldTime(); if(isActive && (time == startTime + duration)) isActive = false; if(isActive){ if(time % 20 == 0) { List<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, Utils.AABBfromVecs( this.player.getPositionVector().subtract(12,12,12), this.player.getPositionVector().addVector(12,12,12))); for(EntityLivingBase e : entities) { e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 20)); } } } } }
×
×
  • Create New...

Important Information

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