Jump to content

Explosion Leaves Behind Invisible / Non-Existant Blocks


robodude
 Share

Recommended Posts

When I create an explosion it sometimes leaves behind invisible blocks, when I reload the world the invisible blocks reappear.

Code:

			event.entityPlayer.worldObj.createExplosion(event.entityLiving.worldObj.getClosestPlayerToEntity(event.entityLiving, 50), pos.blockX, pos.blockY, pos.blockZ, 3.0F, true);

 

Extra Info:

This code is within a PlayerInteractEvent method

Link to comment
Share on other sites

I have no clue here is the entire class.

 

package com.fredtech.tutorial.wuppy;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;

public class SmiteEventHandle {

public SmiteEventHandle() {
	// TODO Auto-generated constructor stub
}

@ForgeSubscribe
public void onInteract(PlayerInteractEvent event){
	long id = 0;
	try{
		id = event.entityPlayer.getHeldItem().itemID;
	}catch(Exception e){}

	if(event.action == Action.RIGHT_CLICK_AIR && id == Wuppy.smiter.itemID)
	{

		Vec3 loc = event.entityPlayer.getLookVec();
		MovingObjectPosition pos = event.entityPlayer.rayTrace(100, 2.0F);

		//try{

		try{
		//event.entityPlayer.worldObj.spawnEntityInWorld(new net.minecraft.entity.effect.EntityLightningBolt(event.entityPlayer.worldObj, pos.blockX, pos.blockY, pos.blockZ));

		}catch(Exception e){}

		try{

		event.entityPlayer.worldObj.createExplosion(event.entityLiving.worldObj.getClosestPlayerToEntity(event.entityLiving, 50), pos.blockX, pos.blockY, pos.blockZ, 3.0F, true);
		}catch(Exception e){}


		//}catch(Exception e){}


		try{
		EntityLiving mob = (EntityLiving) pos.entityHit;
		mob.setEntityHealth(mob.getHealth() - 20);
		}catch(Exception e){}


		event.entityPlayer.sendChatToPlayer(pos.blockX + ", " + pos.blockY + ", " + pos.blockZ);





	}


}

}

Link to comment
Share on other sites

1 why so many try catch ?

 

2 is this class registered in your main mod class ? (if yes good)

 

3 try

 

if(!event.player.worldObj.isRemote){
    //code to spawn wtv you want
}

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

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