Make an item go invisible.

Started by Ima-builder on

Topic category: Help with Minecraft modding (Java Edition)

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).

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator…
Thu, 06/18/2020 - 05:08
package net.mcreator.smokebombs.procedures;

import net.minecraftforge.registries.ForgeRegistries;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.ResourceLocation;
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("x") == null) {
			System.err.println("Failed to load dependency x for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z 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");
		int x = (int) dependencies.get("x");
		int y = (int) dependencies.get("y");
		int z = (int) dependencies.get("z");
		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);
		if (entity instanceof PlayerEntity)
			((PlayerEntity) entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);
		Tic = (double) 0;
		X = (double) (entity.getPosX());
		Y = (double) (entity.getPosY());
		Z = (double) (entity.getPosZ());
		world.playSound((PlayerEntity) null, x, y, z,
				(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.ghast.shoot")),
				SoundCategory.NEUTRAL, (float) 1, (float) 1);
		if (entity instanceof LivingEntity)
			((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SPEED, (int) 200, (int) 1, (false), (false)));
		entity.getPersistentData().putBoolean("superinvis", (true));
		while (((Tic) < 200)) {
			if (((Tic) < 80)) {
				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);
				}
			}
			Tic = (double) ((Tic) + 1);
		}
		entity.getPersistentData().putBoolean("superinvis", (false));
	}
}

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

 

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes the method needs to be…
Thu, 06/18/2020 - 05:10

Yes the method needs to be inside the last }

Like this;

@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("x") == null) {
			System.err.println("Failed to load dependency x for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z 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");
		int x = (int) dependencies.get("x");
		int y = (int) dependencies.get("y");
		int z = (int) dependencies.get("z");
		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);
		if (entity instanceof PlayerEntity)
			((PlayerEntity) entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);
		Tic = (double) 0;
		X = (double) (entity.getPosX());
		Y = (double) (entity.getPosY());
		Z = (double) (entity.getPosZ());
		world.playSound((PlayerEntity) null, x, y, z,
				(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.ghast.shoot")),
				SoundCategory.NEUTRAL, (float) 1, (float) 1);
		if (entity instanceof LivingEntity)
			((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SPEED, (int) 200, (int) 1, (false), (false)));
		entity.getPersistentData().putBoolean("superinvis", (true));
		while (((Tic) < 200)) {
			if (((Tic) < 80)) {
				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);
				}
			}
			Tic = (double) ((Tic) + 1);
		}
		entity.getPersistentData().putBoolean("superinvis", (false));
	}
@SubscribeEvent
    public void renderPlayerPre(RenderPlayerEvent.Pre event)
    {
        if (event.getPlayer().getPersistentData().getBoolean("superinvis") == true)
        {
            event.setCanceled(true);
        }
    }
}

 

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
import net.minecraftforge…
Thu, 06/18/2020 - 05:18
import net.minecraftforge.client.event.RenderPlayerEvent

Import that, but you have some other errors, can you post code again?

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Because I suspect you got…
Thu, 06/18/2020 - 05:19

Because I suspect you got rid of these

package net.mcreator.smokebombs.procedures;

import net.minecraftforge.registries.ForgeRegistries;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.ResourceLocation;
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;

Dont get rid of the imports

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I fixed the errors (you…
Thu, 06/18/2020 - 05:24

I fixed the errors (you cropped off some import lines), but it doesn't make me invisible now

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The speed still works right…
Thu, 06/18/2020 - 05:29

The speed still works right.

 

Two possible issues.

1. The NBT maybe not synced to the client.

2. The class may not be registered.

 

Change this;

	public SplashSmokeBombPotionStartedappliedProcedure(SmokeBombsModElements instance) {
		super(instance, 2);
	}

To this;

	public SplashSmokeBombPotionStartedappliedProcedure(SmokeBombsModElements instance) {
		super(instance, 2);
MinecraftForge.INSTANCE.register(this);
	}

I am not on my computer. So you are going to have to find the import for MinecraftForge.

 

But I believe if you delete a few letters and place them back it should pop up and auto-import.

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package net.mcreator…
Thu, 06/18/2020 - 05:30
package net.mcreator.smokebombs.procedures;

import net.minecraftforge.registries.ForgeRegistries;

import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.World;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.ResourceLocation;
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.minecraftforge.client.event.RenderPlayerEvent
;
import net.minecraftforge.eventbus.api.SubscribeEvent;

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("x") == null) {
			System.err.println("Failed to load dependency x for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure SplashSmokeBombPotionStartedapplied!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z 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");
		int x = (int) dependencies.get("x");
		int y = (int) dependencies.get("y");
		int z = (int) dependencies.get("z");
		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);
		if (entity instanceof PlayerEntity)
			((PlayerEntity) entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);
		Tic = (double) 0;
		X = (double) (entity.getPosX());
		Y = (double) (entity.getPosY());
		Z = (double) (entity.getPosZ());
		world.playSound((PlayerEntity) null, x, y, z,
				(net.minecraft.util.SoundEvent) ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.ghast.shoot")),
				SoundCategory.NEUTRAL, (float) 1, (float) 1);
		if (entity instanceof LivingEntity)
			((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SPEED, (int) 200, (int) 1, (false), (false)));
		entity.getPersistentData().putBoolean("superinvis", (true));
		while (((Tic) < 200)) {
			if (((Tic) < 80)) {
				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);
				}
			}
			Tic = (double) ((Tic) + 1);
		}
		entity.getPersistentData().putBoolean("superinvis", (false));
	}

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

 

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I didn't change anything in…
Thu, 06/18/2020 - 05:34

I didn't change anything in that code, I hadn't seen your newest post yet

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nope, nothing showed up
Thu, 06/18/2020 - 05:42

Nope, nothing showed up

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You deleted part of the…
Thu, 06/18/2020 - 05:43

You deleted part of the MinecraftForge part, right?

 

If so, I cant help you till the morning 

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No, was I supposed to?
Thu, 06/18/2020 - 05:45

No, was I supposed to?

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nvm, wait until the morning.
Thu, 06/18/2020 - 05:47

Nvm, wait until the morning.