Started by
Ima-builder
on
Topic category: Help with Minecraft modding (Java Edition)
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).
You need to import;
What about "@SubscribeEvent"
You need to import that to, I dont have access to my computer anymore. But I think you can just do imports using (CTRL I)
so... um... what would I import exactly? this:
@SubscribeEvent public void renderPlayerPre(RenderPlayerEvent.Pre event) { if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true) { event.setCanceled(true); } }
also, sorry for being so noobish
I'm on my way home, I'll give you the import in a sec
Alright, I just got home. This is what you are looking for;
Ugg... https://imgur.com/hKWtgFV
Can you post code? Something is very wrong lol
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.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.mcreator.smokebombs.SmokeBombsModElements;
@SmokeBombsModElements.ModElement.Tag
public class SB2Procedure extends SmokeBombsModElements.ModElement {
public SB2Procedure(SmokeBombsModElements instance) {
super(instance, 4);
}
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 SB2!");
return;
}
if(dependencies.get("itemstack")==null){
System.err.println("Failed to load dependency itemstack for procedure SB2!");
return;
}
if(dependencies.get("world")==null){
System.err.println("Failed to load dependency world for procedure SB2!");
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());
if(entity instanceof LivingEntity)
((LivingEntity)entity).addPotionEffect(new EffectInstance(Effects.SPEED,(int) 200,(int) 1, (false), (false)));event.getPlayer().getPersistentData().putBoolean("cancelrendering", true);if(entity instanceof PlayerEntity)
((PlayerEntity)entity).getCooldownTracker().setCooldown(((itemstack)).getItem(), (int) 200);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);
} event.getPlayer().getPersistentData().putBoolean("cancelrendering", false);
}
@SubscribeEvent
public void renderPlayerPre(RenderPlayerEvent.Pre event)
{
if (event.getPlayer().getPersistentData().getBoolean("cancelrendering") == true)
{
event.setCanceled(true);
}
}
}
1. You can't use;
or alternatively putBoolean because you aren't provided with the variable event.
But MCreators procedure provides you with the "dependency" entity.
So we can use;
2. The code is hard to read for me on the forum, so I fixed it up as best I could. But I think it may be better to set everything up first (the NBT and etc) in the MCreator Procedure editor. And then adding the RenderPlayerEvent last.
I was thinking the invisibility would get applied after the speed, then would be revoked after the while loop ends.
Sounds great! What happens when you run the code now?
With or without the special code?