Ok, so the title isn't exactly long enough for me to say my entire problem, but basically I have a throwable entity that works like any other throwable entity, with the following as a the onImpact method:
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
EntityNetOut entity = new EntityNetOut(this.worldObj, this.posX, this.posY, this.posZ);
if (par1MovingObjectPosition.entityHit != null)
{
System.out.println( "Entity" );
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
if (!this.worldObj.isRemote)
{
entity.rotationYaw = this.rotationYaw;
entity.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
this.worldObj.spawnEntityInWorld(entity);
this.setDead();
}
}
}
basically if it hits anything it should spawn a "EntityNetOut" which is a entity that I have made, now the basic problem is that it doesn't appear to actually do it, after some effort I found that if I take away the "if (!this.worldObj.isRemote)" line it will kinda spawn, but it will have all kinds of problems (which is kinda expected). This leads me to think that it is probably a problem with client/server relations and my entity. However, after further tests, I found that the entity did in fact spawn but simply didn't effect anything, (entitynetout class:)
package kodithemaster.Pirates;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class EntityNetOut extends Entity
{
public EntityNetOut(World par1World, double x, double y, double z)
{
super(par1World);
this.setPosition(x, y, z);
this.setSize(2F, 2F);
}
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
par1EntityPlayer.setInWeb();
}
public AxisAlignedBB getCollisionBox(Entity par1Entity)
{
return null;
}
/**
* returns the bounding box for this entity
*/
public AxisAlignedBB getBoundingBox()
{
return null;
}
public void onUpdate()
{
float f = 1.0F;
List list = this.worldObj.getEntitiesWithinAABB(Entity.class, this.boundingBox.expand((double)f, (double)f, (double)f));
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
((Entity) iterator.next()).setInWeb();
}
}
@Override
protected void entityInit() {}
@Override
public void readEntityFromNBT(NBTTagCompound var1) {}
@Override
public void writeEntityToNBT(NBTTagCompound var1) {}
}
as you can see, the onUpdate method should cause surrounding entities to be slowed, however, it only does that if I have the EntityNet spawn a new one on the client side.
Additionally, if I set the EntityNet to spawn a boat, or any other vanilla entity, it works fine, which leads me to think that the problem actually has something to do with my EntityNetOut, but I don't know what would actually be wrong with it. Right now I am trying to get it to actually render properly if only spawned on the server side, after which I plan to work on actually getting it to slow things properly, so here is my Render file:
package kodithemaster.Pirates;
import net.minecraft.block.Block;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBoat;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
public class RenderNetOut extends Render
{
protected ModelBase modelNet;
private ResourceLocation tex = new ResourceLocation("koadpirates", "textures/entity/NetOut.png");
public RenderNetOut()
{
this.modelNet = new ModelNetOut();
}
public void doRender(EntityNetOut par1EntityNetOut, double par2, double par4, double par6, float par8, float par9)
{
//
//
//
// I need what goes here!!!!
//
//
//
GL11.glPushMatrix();
this.bindEntityTexture(par1EntityNetOut);
long i = (long)par1EntityNetOut.getEntityId() * 493286711L;
i = i * i * 4392167121L + i * 98761L;
float f2 = (((float)(i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
float f3 = (((float)(i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
float f4 = (((float)(i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
GL11.glTranslatef(f2, f3, f4);
double d3 = par1EntityNetOut.lastTickPosX + (par1EntityNetOut.posX - par1EntityNetOut.lastTickPosX) * (double)par9;
double d4 = par1EntityNetOut.lastTickPosY + (par1EntityNetOut.posY - par1EntityNetOut.lastTickPosY) * (double)par9;
double d5 = par1EntityNetOut.lastTickPosZ + (par1EntityNetOut.posZ - par1EntityNetOut.lastTickPosZ) * (double)par9;
double d6 = 0.30000001192092896D;
float f5 = par1EntityNetOut.prevRotationPitch + (par1EntityNetOut.rotationPitch - par1EntityNetOut.prevRotationPitch) * par9;
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F);
GL11.glScalef(-1.0F, -1.0F, 1.0F);
this.modelNet.render(par1EntityNetOut, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
}
protected ResourceLocation getEntityTexture(EntityNetOut par1Entity)
{
return tex;
}
/**
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
*/
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return this.getEntityTexture((EntityNetOut)par1Entity);
}
@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.doRender((EntityNetOut)par1Entity, par2, par4, par6, par8, par9);
}
}
(based on render minecart code I think)
So any help would be appreciated
FIXED
Thank You.