Make an item go invisible.

Started by Ima-builder on

Topic category: Help with modding (Java Edition)

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make an item go invisible.

Hi, I am trying to make a super invisibility potion (with a stack size of 16) , where even the potion disappears, I thought about swiping out the potion with a dummy invisible item but I'm not quite Shure how to do that (preferably with block coding).

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you know how to code? If…
Wed, 06/17/2020 - 18:45

Do you know how to code? If so, I can help you, it is not to hard.

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If I have a reference chart…
Wed, 06/17/2020 - 19:02

If I have a reference chart I can do basic stuff.

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@SubscribeEvent public…
Wed, 06/17/2020 - 19:14
    @SubscribeEvent
    public void renderPlayerPre(RenderPlayerEvent.Pre event)
    {
        if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true)
        {
            event.setCanceled(true);
        }
    }

Okay, well, this is an example of how I completely cancel the rendering of the player. Now, you can change the NBT, or however, you are checking for "complete invisibility". 

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
what would I have to change…
Wed, 06/17/2020 - 20:43

what would I have to change if I want to slap this in the middle of a procedure?

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You would place it, not in…
Wed, 06/17/2020 - 20:46

You would place it, not in the procedure! But inside of the class. Perhaps you should post code.

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator…
Wed, 06/17/2020 - 20:50

package net.mcreator.smokebombs.procedures;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import net.minecraft.potion.Effects;
import net.minecraft.potion.EffectInstance;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;

import net.mcreator.smokebombs.SmokeBombsModElements;

@SmokeBombsModElements.ModElement.Tag
public class SplashSmokeBombPotionStartedappliedProcedure extends SmokeBombsModElements.ModElement {
    public SplashSmokeBombPotionStartedappliedProcedure(SmokeBombsModElements instance) {
        super(instance, 2);
    }

    public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
        if (dependencies.get("entity") == null) {
            System.err.println("Failed to load dependency entity for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        if (dependencies.get("itemstack") == null) {
            System.err.println("Failed to load dependency itemstack for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        if (dependencies.get("world") == null) {
            System.err.println("Failed to load dependency world for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        Entity entity = (Entity) dependencies.get("entity");
        ItemStack itemstack = (ItemStack) dependencies.get("itemstack");
        World world = (World) dependencies.get("world");
        double X = 0;
        double Y = 0;
        double Z = 0;
        double Tic = 0;
        double BombNum = 0;
        ((itemstack)).shrink((int) 1);
        Tic = (double) 0;
        X = (double) (entity.getPosX());
        Y = (double) (entity.getPosY());
        Z = (double) (entity.getPosZ());
        while (((Tic) < 80)) {
            Tic = (double) ((Tic) + 1);
            if (world instanceof ServerWorld) {
                ((ServerWorld) world).spawnParticle(ParticleTypes.CLOUD, (X), (Y), (Z), (int) 500, 1, 1, 1, 0.01);
            }
            if (world instanceof ServerWorld) {
                ((ServerWorld) world).spawnParticle(ParticleTypes.CLOUD, (X), ((Y) + 1), (Z), (int) 500, 1, 1, 1, 0.01);
            }
        }
        if (entity instanceof LivingEntity)
            ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SPEED, (int) 200, (int) 1, (false), (false)));
        if (entity instanceof LivingEntity)
            ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.INVISIBILITY, (int) 200, (int) 1, (false), (false)));
        if (entity instanceof PlayerEntity)
            ((PlayerEntity) entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);
    }
}
 

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator…
Wed, 06/17/2020 - 20:52
package net.mcreator.smokebombs.procedures;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import net.minecraft.potion.Effects;
import net.minecraft.potion.EffectInstance;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;

import net.mcreator.smokebombs.SmokeBombsModElements;

@SmokeBombsModElements.ModElement.Tag
public class SplashSmokeBombPotionStartedappliedProcedure extends SmokeBombsModElements.ModElement {
    public SplashSmokeBombPotionStartedappliedProcedure(SmokeBombsModElements instance) {
        super(instance, 2);
    }

    public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
        if (dependencies.get("entity") == null) {
            System.err.println("Failed to load dependency entity for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        if (dependencies.get("itemstack") == null) {
            System.err.println("Failed to load dependency itemstack for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        if (dependencies.get("world") == null) {
            System.err.println("Failed to load dependency world for procedure SplashSmokeBombPotionStartedapplied!");
            return;
        }
        Entity entity = (Entity) dependencies.get("entity");
        ItemStack itemstack = (ItemStack) dependencies.get("itemstack");
        World world = (World) dependencies.get("world");
        double X = 0;
        double Y = 0;
        double Z = 0;
        double Tic = 0;
        double BombNum = 0;
        ((itemstack)).shrink((int) 1);
        Tic = (double) 0;
        X = (double) (entity.getPosX());
        Y = (double) (entity.getPosY());
        Z = (double) (entity.getPosZ());
        while (((Tic) < 80)) {
            Tic = (double) ((Tic) + 1);
            if (world instanceof ServerWorld) {
                ((ServerWorld) world).spawnParticle(ParticleTypes.CLOUD, (X), (Y), (Z), (int) 500, 1, 1, 1, 0.01);
            }
            if (world instanceof ServerWorld) {
                ((ServerWorld) world).spawnParticle(ParticleTypes.CLOUD, (X), ((Y) + 1), (Z), (int) 500, 1, 1, 1, 0.01);
            }
        }
        if (entity instanceof LivingEntity)
            ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SPEED, (int) 200, (int) 1, (false), (false)));
        if (entity instanceof LivingEntity)
            ((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.INVISIBILITY, (int) 200, (int) 1, (false), (false)));
        if (entity instanceof PlayerEntity)
            ((PlayerEntity) entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);
    }

    @SubscribeEvent
    public void renderPlayerPre(RenderPlayerEvent.Pre event)
    {
        if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true)
        {
            event.setCanceled(true);
        }
    }
}

Make sure you create the corresponding NBT or condition. Otherwise it won't work!

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry for being such a noob…
Wed, 06/17/2020 - 21:06

Sorry for being such a noob but, what would creating the corresponding NBT or condition entail?

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay, so you see the check; …
Wed, 06/17/2020 - 21:12

Okay, so you see the check;

        if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true)
        {
            event.setCanceled(true);
        }

in;

    @SubscribeEvent
    public void renderPlayerPre(RenderPlayerEvent.Pre event)
    {
        if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true)
        {
            event.setCanceled(true);
        }
    }

 

If you get rid of that check, the player will always be invisible. So we need to check if the player is supposed to be invisible (NBT works fine).

 

So when you want your entity to be invisible use the line;

event.getPlayer().getPersistentData().putBoolean("cancelrendering", true)

And the opposite;

event.getPlayer().getPersistentData().putBoolean("cancelrendering", false)

 

Now there are issues (sided) that may come up. Just don't worry about that for now.

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It gave me this error.
Wed, 06/17/2020 - 21:52

It gave me this error.

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't see it
Wed, 06/17/2020 - 21:55

I can't see it

Last seen on 04:25, 19. Mar 2023
Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
the link? or can't see it on…
Wed, 06/17/2020 - 21:56

the link? or can't see it on discord?

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't see it on discord,…
Wed, 06/17/2020 - 21:58

I can't see it on discord, can you use imgur? Or just post the console