Jump to content

Projectile Explosion Causes Invisible Blocks To Appear. [1.7.10] [10.13.0.1180]


Recommended Posts

Posted

Hey guys, So I recently have been making a mod that creates an item that when used renders a custom entity and model as a throwable that explodes on contact. That part works perfectly fine without flaw, but after the explosion hits it will sometimes leave behind an invisible block in one of the crater spaces that my character can get stuck on. This block is not target able and can only be destroyed by another explosion.

Item Class:

package tutorial.generic;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;


public class ItemBlasterRifle extends Item {

public ItemBlasterRifle() {
    super();
    setCreativeTab(CreativeTabs.tabCombat);
    setUnlocalizedName("blasterRifle");
    setTextureName("rebornmod:ringv");
  }
  


public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
  {
  if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.consumeInventoryItem(Items.redstone)) {
	  par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
	  if (!par2World.isRemote)
      {
          par2World.spawnEntityInWorld(new EntityBlasterBolt(par2World, par3EntityPlayer));
      }

  }
            
      return par1ItemStack;
  }
}

 

Entity Class:

 

package tutorial.generic;


import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;


public class EntityBlasterBolt extends EntityThrowable {
private double explosionRadius = 3.0F;


public EntityBlasterBolt(World par1World) {
	super(par1World);

}

public EntityBlasterBolt(World par1World, double arg1Double, double arg2Double, double arg3Double) {
	super(par1World, arg1Double, arg2Double, arg3Double);
}

public EntityBlasterBolt(World par1World, EntityLivingBase arg1EntityLivingBase) {
	super(par1World, arg1EntityLivingBase);
}



@Override
protected void onImpact(MovingObjectPosition movObjPos)
{
	this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, true);
	this.setDead();
if (movObjPos.entityHit != null)
{
float rockDamage = 5;

movObjPos.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), rockDamage);
}
for (int i = 0; i < 4; ++i)
{
this.worldObj.spawnParticle("crit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}

if (!this.worldObj.isRemote)
{
this.setDead();
}
}



}

 

Mainmod Class:

 

package tutorial.generic;

import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; 
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


@Mod(modid="rebornmod", name="Reborn", version="1.0.0")

public class Generic {

  public static final String ID = "rebornmod";
  public static final String NAME = "Reborn";

        

   
	@Instance(value = "rebornmod")
     public static Generic instance;
        
      
        @SidedProxy(clientSide="tutorial.generic.client.ClientProxy", serverSide="tutorial.generic.CommonProxy")
        public static CommonProxy proxy;
        public static Item blasterRifle;

	        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	 	
        	
        	 		blasterRifle = new ItemBlasterRifle();
        	 		GameRegistry.registerItem(blasterRifle, "Blaster Rifle");
        int modEntityID = 0;
        	 EntityRegistry.registerModEntity(EntityBlasterBolt.class, "blasterBolt", ++modEntityID, this, 64, 10, true);
        	 proxy.registerRenderers();
        }
        
        @EventHandler
        
        public void load(FMLInitializationEvent event) {
          
       
        	
    	
          
               LanguageRegistry.addName(blasterRifle, "Vongola Ring 11");
	 proxy.registerRenderers();
        }
        
        @EventHandler
   
        public void postInit(FMLPostInitializationEvent event) {
             
        }
}

 

RenderCustomEntity Class:

 

package tutorial.generic;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;

public class RenderBlasterRifle extends Render {
@SideOnly(Side.CLIENT)
public class RenderThrowingRock extends RenderSnowball
{
public RenderThrowingRock(Item item) {
this(item, 0);
}

public RenderThrowingRock(Item item, int par2) {
super(item, par2);
}


}


private static final ResourceLocation texture = new ResourceLocation("rebornmod", "textures/entity/FireBall1.png");


private ModelBase model;

public RenderBlasterRifle() {

model = new ModelFireBall();
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {

return texture;
}

private ResourceLocation getCustomTexture(ModelFireBall entity) {

return texture;
}


@Override
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTick) {

GL11.glPushMatrix();


bindTexture(texture);


GL11.glTranslated(x, y, z);


model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);


GL11.glPopMatrix();
}
}

 

ModelCode Class:

 


package tutorial.generic;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;

public class ModelFireBall extends ModelBase
{
  //fields
    ModelRenderer Shape1;
    ModelRenderer Piece1;
    ModelRenderer Piece2;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
    ModelRenderer Shape6;
    ModelRenderer Shape7;
    ModelRenderer Shape8;
    ModelRenderer Shape9;
    ModelRenderer Shape10;
    ModelRenderer Shape11;
    ModelRenderer Shape12;
    ModelRenderer Shape13;
    ModelRenderer Shape14;
  
  public ModelFireBall()
  {
    textureWidth = 32;
    textureHeight = 32;
    
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(-1.5F, -1.5F, -1.5F, 3, 3, 3);
      Shape1.setRotationPoint(0F, 0F, 0F);
      Shape1.setTextureSize(32, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
    Piece1 = new ModelRenderer(this, "Piece1");
    Piece1.setRotationPoint(0F, 0F, 0F);
    setRotation(Piece1, 0F, 0F, 0F);
    Piece1.mirror = true;
    Piece2 = new ModelRenderer(this, "Piece2");
    Piece2.setRotationPoint(0F, 0F, 0F);
    setRotation(Piece2, 0F, 0F, 0F);
    Piece2.mirror = true;
      Shape2 = new ModelRenderer(this, 0, 0);
      Shape2.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape2.setRotationPoint(-2.333333F, 0F, 0F);
      Shape2.setTextureSize(32, 32);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 0, 0);
      Shape3.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape3.setRotationPoint(-2F, -1F, -1F);
      Shape3.setTextureSize(32, 32);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 0, 0);
      Shape4.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape4.setRotationPoint(-2F, 0.1333333F, -1.4F);
      Shape4.setTextureSize(32, 32);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 0, 0);
      Shape5.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape5.setRotationPoint(-2.533333F, -1.133333F, 0.1333333F);
      Shape5.setTextureSize(32, 32);
      Shape5.mirror = true;
      setRotation(Shape5, 0F, 0F, 0F);
      Shape6 = new ModelRenderer(this, 0, 0);
      Shape6.addBox(-1F, -1F, 0F, 2, 2, 1);
      Shape6.setRotationPoint(-0.1F, -0.1F, -2F);
      Shape6.setTextureSize(32, 32);
      Shape6.mirror = true;
      setRotation(Shape6, 0F, 0F, 0F);
      Shape7 = new ModelRenderer(this, 0, 0);
      Shape7.addBox(0F, 0F, 0F, 2, 2, 1);
      Shape7.setRotationPoint(-0.1333333F, -1.666667F, 0F);
      Shape7.setTextureSize(32, 32);
      Shape7.mirror = true;
      setRotation(Shape7, 0F, 0F, 0F);
      Shape8 = new ModelRenderer(this, 0, 0);
      Shape8.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape8.setRotationPoint(1F, 0F, -1F);
      Shape8.setTextureSize(32, 32);
      Shape8.mirror = true;
      setRotation(Shape8, 0F, 0F, 0F);
      Shape9 = new ModelRenderer(this, 0, 0);
      Shape9.addBox(0F, 0F, 0F, 2, 1, 1);
      Shape9.setRotationPoint(-1F, -2F, -1F);
      Shape9.setTextureSize(32, 32);
      Shape9.mirror = true;
      setRotation(Shape9, 0F, 0F, 0F);
      Shape10 = new ModelRenderer(this, 0, 0);
      Shape10.addBox(-0.5F, -0.4666667F, -0.5F, 1, 1, 1);
      Shape10.setRotationPoint(0F, 0F, -2F);
      Shape10.setTextureSize(32, 32);
      Shape10.mirror = true;
      setRotation(Shape10, -0.122173F, -0.0523599F, -0.3141593F);
      Shape11 = new ModelRenderer(this, 0, 0);
      Shape11.addBox(0F, 0F, 0F, 2, 2, 1);
      Shape11.setRotationPoint(-1F, 0F, 0F);
      Shape11.setTextureSize(32, 32);
      Shape11.mirror = true;
      setRotation(Shape11, 0F, 0F, 0F);
      Shape12 = new ModelRenderer(this, 0, 0);
      Shape12.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape12.setRotationPoint(0F, 1F, -0.7333333F);
      Shape12.setTextureSize(32, 32);
      Shape12.mirror = true;
      setRotation(Shape12, 0F, 0F, 0F);
      Shape13 = new ModelRenderer(this, 0, 0);
      Shape13.addBox(0F, 0F, 0F, 1, 1, 2);
      Shape13.setRotationPoint(0.567F, 0.3F, 1.3F);
      Shape13.setTextureSize(32, 32);
      Shape13.mirror = true;
      setRotation(Shape13, 0F, -0.2268928F, 0F);
      Shape14 = new ModelRenderer(this, 0, 0);
      Shape14.addBox(0F, 0F, 0F, 1, 1, 2);
      Shape14.setRotationPoint(-0.9333333F, -1.466667F, 1.466667F);
      Shape14.setTextureSize(32, 32);
      Shape14.mirror = true;
      setRotation(Shape14, 0F, 0.3490659F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    Shape1.render(f5);
    Piece1.render(f5);
    Piece2.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Shape12.render(f5);
    Shape13.render(f5);
    Shape14.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity ent)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, ent);
  }

public Item setUnlocalizedName(String string) {
// TODO Auto-generated method stub
return null;
}

}

 

ClientProxy Class:

 

package tutorial.generic.client;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import tutorial.generic.CommonProxy;
import tutorial.generic.EntityBlasterBolt;
import tutorial.generic.Generic;
import tutorial.generic.ItemBlasterRifle;
import tutorial.generic.ModelFireBall;
import tutorial.generic.RenderBlasterRifle;


public class ClientProxy extends CommonProxy {
        
        @Override
        public void registerRenderers() {
        
        	RenderingRegistry.registerEntityRenderingHandler(EntityBlasterBolt.class, new RenderBlasterRifle());
       	
        }




        }

 

 

Any and all help is welcome with open arms. If you see any extra errors then don't be afraid to notify me please. Though I have a basic understanding of java I am still learning as I go so please be patient with me and thank you so much for helping if you chose too. :) Have a great day!

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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