Jump to content

Need help with Entity Render.


Triplitz88

Recommended Posts

Hello,

 

I've got an issue that I cannot seem to solve.

 

I've got an item that is placed on the ground that is supposed to spawn an entityliving.

 

I know the entity spawns because I can collide with it in-game but I don't think the renderer is being loaded. My debug messages inside the renderer are not showing up. I don't think the renderer is actually being loaded.

 

Here are the scripts:

 

package mod_DefenseGunPack;




import mod_DefenseGunPack.client.ClientProxy;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.block.material.Material;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemReed;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.GameRegistry;



@Mod(modid="mod_DefenseGunPack", name="mod_DefenseGunPack", version="0.0.1")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class mod_DefenseGun3x3v1
{

//public static final Block test = (new BlockDefenseGun3x3v1(250, mod_DefenseGunPack.EntityDefenseGun3x3v1.class))
//	.setHardness(0.5F) .setResistance(1F) .setBlockName("DefenseTurret3x3v1");




public static final Item DefenseGun3x3v1 = (new ItemDefenseGun3x3v1(5000)).setItemName("DefenseGun3x3v1")
.setCreativeTab(CreativeTabs.tabRedstone);



@Instance("mod_DefenseGun3x3v1")
public static mod_DefenseGun3x3v1 instance;

@SidedProxy(clientSide="mod_DefenseGunPack.client.ClientProxy", serverSide="mod_DefenseGunPack.CommonProxy")
public static CommonProxy proxy;

@PreInit
public void preInt(FMLPreInitializationEvent event) {
	// stub Method
}

@Init
public void load(FMLInitializationEvent event) {

	EntityRegistry.registerGlobalEntityID(EntityDefenseGun3x3v1.class, "DefenseGun3x3v1", EntityRegistry.findGlobalUniqueEntityId());

	GameRegistry.registerItem(DefenseGun3x3v1, "DefenseGun3x3v1");

//		LanguageRegistry.addName(DefenseGun3x3v1, "DefenseGun3x3v1");

	GameRegistry.addRecipe(new ItemStack(DefenseGun3x3v1, 3), 
			new Object[] { " # ", Character.valueOf('#'), Block.dirt});

	ClientProxy.registerRenderInformation();


}

@PostInit
public void postInit(FMLPostInitializationEvent event) {
	// stub Method
}

}

 

package mod_DefenseGunPack;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class CommonProxy implements IGuiHandler{


    public static void registerRenderInformation()
    {
    	//No rendering for servers
    }

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
		int x, int y, int z) {
	// TODO Auto-generated method stub
	return null;
}



}

 

 

package mod_DefenseGunPack.client;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.src.ModLoader;
import net.minecraftforge.client.MinecraftForgeClient;
import mod_DefenseGunPack.CommonProxy;
import mod_DefenseGunPack.EntityDefenseGun3x3v1;
import mod_DefenseGunPack.EntityDefenseGun3x3v1Renderer;

public class ClientProxy extends CommonProxy 
{
        
public static void registerRenderInformation()
{

MinecraftForgeClient.preloadTexture("/mod_DefenseGunPack/DefenseGun3x3v1.png");
        	
RenderingRegistry.registerEntityRenderingHandler(EntityDefenseGun3x3v1.class, new EntityDefenseGun3x3v1Renderer());

}

}

 

 

package mod_DefenseGunPack;

import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraft.util.ReportedException;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;

public class ItemDefenseGun3x3v1 extends Item {
private int spawnID;


public EntityPlayer PlacingPlayer;

public ItemDefenseGun3x3v1(int par1) {
	super(par1);


}

public boolean FW_CheckPlacementLocation(World par3World, int par4, int par5, int par6, int par7) {

	if (!par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity) null))
	{
		//ModLoader.getUniqueEntityId()

		if (!par3World.isAirBlock(par4, par5, par6))
		{	
				//ModLoader.getMinecraftInstance().thePlayer.addChatMessage("FW_isAirBlock = false");

				int id = par3World.getBlockId(par4, par5, par6);

				if (id == 42 || id == 45 || id == 01)
				{
					//ModLoader.getMinecraftInstance().thePlayer.addChatMessage("FW_Check = true");
					return true;
				}



		}


	}
	//ModLoader.getMinecraftInstance().thePlayer.addChatMessage("FW_Check = false");
	return false;
}




/**
 * Callback for item usage. If the item does something special on right
 * clicking, he will have one of those. Return True if something happen and
 * false if it don't. This is for ITEMS, not BLOCKS
 */
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) 
	{
	int var11 = par3World.getBlockId(par4, par5, par6);

//		par7 = 1;

	if (var11 == Block.snow.blockID) {
	par7 = 1;
	} 
	else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID) {
		if (par7 == 0) {
			--par5;
		}

		if (par7 == 1) {
			++par5;
		}

		if (par7 == 2) {
			--par6;
		}

		if (par7 == 3) {
			++par6;
		}

		if (par7 == 4) {
			--par4;
		}

		if (par7 == 5) {
			++par4;
		}
	}

	if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
		return false;
	} 
	else if (par1ItemStack.stackSize == 0) {
		return false;
	} 
//		else {
//			
//			if (
//				(FW_CheckPlacementLocation(par3World, par4 - 1, par5 - 1, par6 + 1, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4, par5 - 1, par6 + 1, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4 + 1, par5 - 1, par6 + 1, par7) == true)
//					
//				&& (FW_CheckPlacementLocation(par3World, par4 - 1, par5 - 1, par6, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4, par5 - 1, par6, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4 + 1, par5 - 1, par6, par7) == true)
//					
//				&& (FW_CheckPlacementLocation(par3World, par4 - 1, par5 - 1, par6 - 1, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4, par5 - 1, par6 - 1, par7) == true)
//				&& (FW_CheckPlacementLocation(par3World, par4 + 1, par5 - 1, par6 - 1, par7) == true)) 
//					{
//					
//						for(int i = 0; i < 3; i = i + 1) 
//						{
//						if(
//						(par3World.isAirBlock(par4 - 1, par5 + i, par6 + 1))		
//						&& (par3World.isAirBlock(par4, par5 + 1, par6 + 1))
//						&& (par3World.isAirBlock(par4 + 1, par5 + i, par6 + 1))
//						&& (par3World.isAirBlock(par4 - 1, par5 + i, par6))
//						&& (par3World.isAirBlock(par4, par5 + 1, par6))
//						&& (par3World.isAirBlock(par4 + 1, par5 + i, par6))
//						&& (par3World.isAirBlock(par4 - 1, par5 + i, par6 - 1))
//						&& (par3World.isAirBlock(par4, par5 + 1, par6 - 1))
//						&& (par3World.isAirBlock(par4 + 1, par5 + i, par6 - 1))
//						) 
//							{
//							}
//						}
//					}
//					
//					else 
//					{
//						return false;
//					}
//				}


		// (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6,
		// false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 - 1, par5,
		// par6 + 1, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6
		// + 1, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 + 1, par5,
		// par6 + 1, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 - 1, par5,
		// par6, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 + 1, par5,
		// par6, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 - 1, par5,
		// par6 - 1, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6
		// - 1, false, par7, (Entity)null))
		// && (par3World.canPlaceEntityOnSide(this.spawnID, par4 + 1, par5,
		// par6 - 1, false, par7, (Entity)null))





			EntityDefenseGun3x3v1 var35 = new EntityDefenseGun3x3v1(par3World, par4, par5, par6);

//                if (!par3World.getCollidingBoundingBoxes(var35, var35.boundingBox.expand(0.0D, 0.0D, 0.0D)).isEmpty())
//                {
//                    return par1ItemStack != null;
//                }

                if (!par3World.isRemote)
                {
                    par3World.spawnEntityInWorld(var35);
                   // ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Entity Spawned = true");
                }

                if (!par2EntityPlayer.capabilities.isCreativeMode)
                {
                    --par1ItemStack.stackSize;
                }
            




			 //				Block var12 = Block.blocksList[this.spawnID];
//				int var13 = var12.func_85104_a(par3World, par4, par5, par6, par7, par8, par9, par10, 0);
//
//				if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, this.spawnID, var13)) 
//				{
//					if (par3World.getBlockId(par4, par5, par6) == this.spawnID) {
//						Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
//						Block.blocksList[this.spawnID].func_85105_g(par3World, par4, par5, par6, var13);						
//					}
//
//					par3World.playSoundEffect((double) ((float) par4 + 0.5F),
//							(double) ((float) par5 + 0.5F),
//							(double) ((float) par6 + 0.5F),
//							var12.stepSound.getPlaceSound(),
//							(var12.stepSound.getVolume() + 1.0F) / 2.0F,
//							var12.stepSound.getPitch() * 0.8F);
//					--par1ItemStack.stackSize;
//				}


		PlacingPlayer = par2EntityPlayer;
		return true;
	}
}

 

 





package mod_DefenseGunPack;

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

public class ModelDefenseGun3x3v1 extends ModelBase
{
  //fields
    ModelRenderer Base;
    ModelRenderer BaseR;
    ModelRenderer Tower1;
    ModelRenderer Tower2;
    ModelRenderer MountR;
    ModelRenderer Gun1;
    ModelRenderer Gun2;
  
  public ModelDefenseGun3x3v1()
  {
    this.textureWidth = 256;
    this.textureHeight = 256;
    
      this.Base = new ModelRenderer(this, 0, 0);
      this.Base.addBox(0F, 0F, 0F, 44, 3, 48);
      this.Base.setRotationPoint(-22F, 21F, -24F);
      this.Base.setTextureSize(256, 256);
      this.Base.mirror = true;
      this.setRotation(this.Base, 0F, 0F, 0F);
      this.BaseR = new ModelRenderer(this, 0, 0);
      this.BaseR.addBox(0F, 0F, 0F, 29, 6, 30);
      this.BaseR.setRotationPoint(-15F, 15F, -15F);
      this.BaseR.setTextureSize(256, 256);
      this.BaseR.mirror = true;
      this.setRotation(this.BaseR, 0F, 0F, 0F);
      this.Tower1 = new ModelRenderer(this, 0, 0);
      this.Tower1.addBox(0F, 0F, 0F, 3, 20, 9);
      this.Tower1.setRotationPoint(-8F, -4.466667F, 1F);
      this.Tower1.setTextureSize(256, 256);
      this.Tower1.mirror = true;
      this.setRotation(this.Tower1, 0F, 0F, 0F);
      this.Tower2 = new ModelRenderer(this, 0, 0);
      this.Tower2.addBox(0F, 0F, 0F, 3, 20, 9);
      this.Tower2.setRotationPoint(4F, -5F, 1F);
      this.Tower2.setTextureSize(256, 256);
      this.Tower2.mirror = true;
      this.setRotation(this.Tower2, 0F, 0F, 0F);
      this.MountR = new ModelRenderer(this, 0, 0);
      this.MountR.addBox(0F, 0F, 0F, 9, 5, 5);
      this.MountR.setRotationPoint(-5F, -3F, 3F);
      this.MountR.setTextureSize(256, 256);
      this.MountR.mirror = true;
      this.setRotation(this.MountR, 0F, 0F, 0F);
      this.Gun1 = new ModelRenderer(this, 0, 0);
      this.Gun1.addBox(0F, 0F, 0F, 7, 9, 21);
      this.Gun1.setRotationPoint(-4F, -6F, 0F);
      this. Gun1.setTextureSize(256, 256);
      this.Gun1.mirror = true;
      this.setRotation(this.Gun1, 0F, 0F, 0F);
      this.Gun2 = new ModelRenderer(this, 0, 0);
      this.Gun2.addBox(0F, 0F, 0F, 5, 6, 24);
      this.Gun2.setRotationPoint(-3F, -4F, -24F);
      this.Gun2.setTextureSize(256, 256);
      this.Gun2.mirror = true;
      this.setRotation(this.Gun2, 0F, 0F, 0F);
  }
  
  @Override
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);
    this.Base.render(f5);
    this.BaseR.render(f5);
    this.Tower1.render(f5);
    this.Tower2.render(f5);
    this.MountR.render(f5);
    this.Gun1.render(f5);
    this.Gun2.render(f5);
  }
  
  public void renderModel(float f5)
  {
  this.Base.render(f5);
  this.BaseR.render(f5);
  this.Tower1.render(f5);
  this.Tower2.render(f5);
  this.MountR.render(f5);
  this.Gun1.render(f5);
  this.Gun2.render(f5);
  }
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  @Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  }

}

 

 

package mod_DefenseGunPack;


import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderEntity;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.src.ModLoader;

import org.lwjgl.opengl.GL11;

public class EntityDefenseGun3x3v1Renderer extends RenderEntity {

private ModelDefenseGun3x3v1 aModel;

public EntityDefenseGun3x3v1Renderer()
{

	System.out.println("Renderer called");
	aModel = new ModelDefenseGun3x3v1();


}



public void renderDefenseGun3x3v1(EntityDefenseGun3x3v1 par1Entity, double par2, double par4, double par6, float f, float f1)
{
      
	System.out.println("Renderer called");

	GL11.glPushMatrix(); //Open the OpenGL Console Instance
	renderOffsetAABB(par1Entity.boundingBox, par2 - par1Entity.lastTickPosX, par4 - par1Entity.lastTickPosY, par6 - par1Entity.lastTickPosZ);

	GL11.glTranslatef((float) par2 + 0.0F, (float) par4 + 0.0F, (float) par6 + 0.0F); //Translate the object
	GL11.glRotatef(180F, 0.0F, 0.0F, 0.5F);
	this.loadTexture("/mod_DefenseGunPack/DefenseGun3x3v1.png"); //Sets the Texture

	GL11.glPushMatrix(); //Open another OpenGL Instance inside the first
	this.aModel.renderModel(0.0625F);
	GL11.glPopMatrix();

	GL11.glPopMatrix();

}



@Override
public void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9) {

	System.out.println("Renderer called");

	renderDefenseGun3x3v1((EntityDefenseGun3x3v1)var1, var2, var4, var6, var8, var9);
}


public void doRenderLiving(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9)
    {
	System.out.println("Renderer called");

	this.renderDefenseGun3x3v1((EntityDefenseGun3x3v1)par1EntityLiving, par2, par4, par6, par8, par9);
    }



}

 

package mod_DefenseGunPack;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityDefenseGun3x3v1 extends EntityLiving implements IInventory
{
    private ItemStack[] DG3X3v1Contents;
    private boolean field_70279_a;
    private double field_70276_b;
    private int boatPosRotationIncrements;
    private double boatX;
    private double boatY;
    private double boatZ;
    private double boatYaw;
    private double boatPitch;
    @SideOnly(Side.CLIENT)
    private double velocityX;
    @SideOnly(Side.CLIENT)
    private double velocityY;
    @SideOnly(Side.CLIENT)
    private double velocityZ;

    public EntityDefenseGun3x3v1(World par1World)
    {
        super(par1World);
        this.field_70279_a = true;
        this.field_70276_b = 0.07D;
        this.preventEntitySpawning = true;
        this.setSize(1.5F, 0.6F);
        this.yOffset = this.height / 2.0F;
    }

    /**
     * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
     * prevent them from trampling crops
     */
    

    
    
    /**
     * random number generator for instance. Used in random item stack selection.
     */
    private Random DG3X3v1Random = new Random();
    
    
    /**
     * Returns the number of slots in the inventory.
     */
    @Override
public int getSizeInventory()
    {
        return 1;
    }

    
    
    
    
    
    
    protected boolean canTriggerWalking()
    {
        return false;
    }

    protected void entityInit()
    {

    }

    /**
     * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
     * pushable on contact, like boats or minecarts.
     */
    public AxisAlignedBB getCollisionBox(Entity par1Entity)
    {
        return par1Entity.boundingBox;
    }

    /**
     * returns the bounding box for this entity
     */
    public AxisAlignedBB getBoundingBox()
    {
        return this.boundingBox;
    }

    /**
     * Returns true if this entity should push and be pushed by other entities when colliding.
     */
    public boolean canBePushed()
    {
        return true;
    }

    public EntityDefenseGun3x3v1(World par1World, double par2, double par4, double par6)
    {
        this(par1World);
        this.setPosition(par2, par4 + (double)this.yOffset, par6);
        this.motionX = 0.0D;
        this.motionY = 0.0D;
        this.motionZ = 0.0D;
        this.prevPosX = par2;
        this.prevPosY = par4;
        this.prevPosZ = par6;
    }


    /**
     * Called when the entity is attacked.
     */
    public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
    {
        if (this.func_85032_ar())
        {
            return false;
        }
        else if (!this.worldObj.isRemote && !this.isDead)
        {
            this.setForwardDirection(-this.getForwardDirection());
            this.setTimeSinceHit(10);
            this.setDamageTaken(this.getDamageTaken() + par2 * 10);
            this.setBeenAttacked();

            if (par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode)
            {
                this.setDamageTaken(100);
            }

            if (this.getDamageTaken() > 40)
            {


                this.dropItemWithOffset(Item.boat.shiftedIndex, 1, 0.0F);
                this.setDead();
            }

            return true;
        }
        else
        {
            return true;
        }
    }

    @SideOnly(Side.CLIENT)

    /**
     * Setups the entity to do the hurt animation. Only used by packets in multiplayer.
     */
    public void performHurtAnimation()
    {
        this.setForwardDirection(-this.getForwardDirection());
        this.setTimeSinceHit(10);
        this.setDamageTaken(this.getDamageTaken() * 11);
    }

    /**
     * Returns true if other Entities should be prevented from moving through this Entity.
     */
    public boolean canBeCollidedWith()
    {
        return !this.isDead;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
     * posY, posZ, yaw, pitch
     */
    public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
    {

        this.boatX = par1;
        this.boatY = par3;
        this.boatZ = par5;
        this.boatYaw = (double)par7;
        this.boatPitch = (double)par8;
        this.motionX = this.velocityX;
        this.motionY = this.velocityY;
        this.motionZ = this.velocityZ;
    }

    @SideOnly(Side.CLIENT)

    /**
     * Sets the velocity to the args. Args: x, y, z
     */
    public void setVelocity(double par1, double par3, double par5)
    {
        this.velocityX = this.motionX = par1;
        this.velocityY = this.motionY = par3;
        this.velocityZ = this.motionZ = par5;
    }




    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    @Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
    	
    	if (getSizeInventory() > 0)
        {
            NBTTagList var2 = new NBTTagList();

            for (int var3 = 0; var3 < this.DG3X3v1Contents.length; ++var3)
            {
                if (this.DG3X3v1Contents[var3] != null)
                {
                    NBTTagCompound var4 = new NBTTagCompound();
                    var4.setByte("Slot", (byte)var3);
                    this.DG3X3v1Contents[var3].writeToNBT(var4);
                    var2.appendTag(var4);
                }
            }

            par1NBTTagCompound.setTag("Items", var2);
        }
    	
    	
    	
    }
    
    
    
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
	// TODO Auto-generated method stub
	 if (getSizeInventory() > 0)
        {
            NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
            this.DG3X3v1Contents = new ItemStack[this.getSizeInventory()];

            for (int var3 = 0; var3 < var2.tagCount(); ++var3)
            {
                NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
                int var5 = var4.getByte("Slot") & 255;

                if (var5 >= 0 && var5 < this.DG3X3v1Contents.length)
                {
                    this.DG3X3v1Contents[var5] = ItemStack.loadItemStackFromNBT(var4);
                }
            }
        }
}
    
    

    /**
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
     */
    public boolean interact(EntityPlayer par1EntityPlayer)
    {
    	return false;
    }

    /**
     * Sets the damage taken from the last hit.
     */
    public void setDamageTaken(int par1)
    {
        this.dataWatcher.updateObject(19, Integer.valueOf(par1));
    }

    @SideOnly(Side.CLIENT)
    public float getShadowSize()
    {
        return 0.0F;
    }

    /**
     * Gets the damage taken from the last hit.
     */
    public int getDamageTaken()
    {
        return this.dataWatcher.getWatchableObjectInt(19);
    }

    /**
     * Sets the time to count down from since the last time entity was hit.
     */
    public void setTimeSinceHit(int par1)
    {
        this.dataWatcher.updateObject(17, Integer.valueOf(par1));
    }

    /**
     * Gets the time since the last hit.
     */
    public int getTimeSinceHit()
    {
        return this.dataWatcher.getWatchableObjectInt(17);
    }

    /**
     * Sets the forward direction of the entity.
     */
    public void setForwardDirection(int par1)
    {
        this.dataWatcher.updateObject(18, Integer.valueOf(par1));
    }

    /**
     * Gets the forward direction of the entity.
     */
    public int getForwardDirection()
    {
        return this.dataWatcher.getWatchableObjectInt(18);
    }

    @SideOnly(Side.CLIENT)
    public void func_70270_d(boolean par1)
    {
        this.field_70279_a = par1;
    }







    /**
     * Returns the stack in slot i
     */
    @Override
public ItemStack getStackInSlot(int par1)
    {
        return this.DG3X3v1Contents[par1];
    }







    /**
     * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
     * new stack.
     */
    @Override
public ItemStack decrStackSize(int par1, int par2)
    {
        if (this.DG3X3v1Contents[par1] != null)
        {
            ItemStack var3;

            if (this.DG3X3v1Contents[par1].stackSize <= par2)
            {
                var3 = this.DG3X3v1Contents[par1];
                this.DG3X3v1Contents[par1] = null;
                this.onInventoryChanged();
                return var3;
            }
            else
            {
                var3 = this.DG3X3v1Contents[par1].splitStack(par2);

                if (this.DG3X3v1Contents[par1].stackSize == 0)
                {
                    this.DG3X3v1Contents[par1] = null;
                }

                this.onInventoryChanged();
                return var3;
            }
        }
        else
        {
            return null;
        }
    }






    /**
     * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
     * like when you close a workbench GUI.
     */
    @Override
public ItemStack getStackInSlotOnClosing(int par1)
    {
        if (this.DG3X3v1Contents[par1] != null)
        {
            ItemStack var2 = this.DG3X3v1Contents[par1];
            this.DG3X3v1Contents[par1] = null;
            return var2;
        }
        else
        {
            return null;
        }
    }






    /**
     * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
     */
    @Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
    {
        this.DG3X3v1Contents[par1] = par2ItemStack;

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
        {
            par2ItemStack.stackSize = this.getInventoryStackLimit();
        }

        this.onInventoryChanged();
    }


  public int getRandomStackFromInventory()
    {
        int var1 = -1;
        int var2 = 1;

        for (int var3 = 0; var3 < this.DG3X3v1Contents.length; ++var3)
        {
            if (this.DG3X3v1Contents[var3] != null && this.DG3X3v1Random.nextInt(var2++) == 0)
            {
                var1 = var3;
            }
        }

        return var1;
    }



    public int func_70360_a(ItemStack par1ItemStack)
    {
        for (int var2 = 0; var2 < this.DG3X3v1Contents.length; ++var2)
        {
            if (this.DG3X3v1Contents[var2] == null || this.DG3X3v1Contents[var2].itemID == 0)
            {
                this.DG3X3v1Contents[var2] = par1ItemStack;
                return var2;
            }
        }

        return -1;
    }

  
  
    /**
     * Returns the name of the inventory.
     */
    @Override
	public String getInvName()
    {
        return "container.DefenseGun3x3v1"; //$NON-NLS-1$
    }





@Override
public int getInventoryStackLimit() {
	// TODO Auto-generated method stub
	return 64;
}







@Override
public void onInventoryChanged() {
	// TODO Auto-generated method stub

}







    /**
     * Do not make give this method the name canInteractWith because it clashes with Container
     */
    @Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
    {
        return true;
    }








@Override
public void openChest() {
	// TODO Auto-generated method stub

}







@Override
public void closeChest() {
	// TODO Auto-generated method stub

}







@Override
public int getMaxHealth() {
	// TODO Auto-generated method stub
	return 5;
}

@Override
public void onUpdate()
{


}


}

 

 

Can somebody help me?

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