Jump to content

Triplitz88

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Triplitz88's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. First of all, Minecraft Forge's pastbin is throwing a 500 error. Here is a link to another: http://pastebin.com/VV0ynVMR Here is a link with several possible causes: http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html I have tried everything upwards of creating a new class and type instead of copying all the data in (Don't know enough about eclipse). I have also reinstalled everything twice. Can anyone here help me please?
  2. Hello, This is my first mod test publish. I got the following error thrown: java.lang.NoClassDefFoundError: supcom/entity/turret/Template_TurretEntity Here is the full stack trace from the MineCraft Launcher set to the forge profile: http://paste.minecraftforge.net/view/589e3fd2 Extra detail: I had an issue there I used, in the mods folder, the file path mods/supcom/... whereas in the reobf folder it was reobf/minecraft/supcom/... This caused an error to be thrown where it couldn't find the core mod class. After I made the client mods folder file path mods/minecraft/supcom that error stopped but now I am I have this one. Google search failed to pull up anything I could see that was useful. I have confirmed that both the client and client with server work as I expect when tested in eclipse. Question: What am I doing wrong here? Thanks! Edit: Thread title was incomplete.
  3. Hey all, I'm having a rather serious problem with spawning my entity. I've gotten it to work perfectly in SP but in MP the thing simply will not spawn. Here is the relevant code: package mod_DefenseGunPack; //Credits: //big help from: Zorn_Taov // // // // // // import mod_DefenseGunPack.handlers.CraftingHandler; import mod_DefenseGunPack.handlers.DG3x3_SpawnPacketHandler; import mod_DefenseGunPack.client.ClientProxy; import mod_DefenseGunPack.handlers.DG3x3_PacketHandler; import mod_DefenseGunPack.items.DG3x3_Item; import mod_DefenseGunPack.turrets.DG3x3_EntityLiving; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; 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.client.MinecraftForgeClient; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.ICraftingHandler; 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.IConnectionHandler; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.NetworkRegistry; 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_Turrets { //public static final Block test = (new BlockDefenseGun3x3v1(250, mod_DefenseGunPack.EntityDefenseGun3x3v1.class)) // .setHardness(0.5F) .setResistance(1F) .setBlockName("DefenseTurret3x3v1"); // public static IPacketHandler packetHandler; // // public static IPacketHandler packetSpawnHandler; public static Item DG3x3_Item; public void craftingRecipes() { GameRegistry.addRecipe(new ItemStack(DG3x3_Item, 1, 0), new Object[] { "##", "##", '#', Block.dirt}); } @Instance("Mod_Turrets") public static Mod_Turrets 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) { // packetHandler = new DG3x3_PacketHandler(); // packetSpawnHandler = new DG3x3_SpawnPacketHandler(); // // NetworkRegistry.instance().registerPacketHandler(); DG3x3_Item = (new DG3x3_Item(5000-256)).setItemName("DefenseGun3x3v1") .setCreativeTab(CreativeTabs.tabRedstone).setIconCoord(12, 10); craftingRecipes(); // NetworkRegistry.instance().registerChannel(packetHandler, "DG3x3"); // NetworkRegistry.instance().registerChannel(packetSpawnHandler, "DG3x3Spawn"); int DG3x3id = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(DG3x3_EntityLiving.class, "DefenseGun3x3v1", DG3x3id); EntityRegistry.registerModEntity(DG3x3_EntityLiving.class, "DefenseGun3x3v1",DG3x3id, this, 250, 5, false); GameRegistry.registerItem(DG3x3_Item, "DefenseGun3x3v1"); LanguageRegistry.addName(DG3x3_Item, "DefenseGun3x3v1"); ClientProxy.registerRenderInformation(); } @PostInit public void postInit(FMLPostInitializationEvent event) { // stub Method } } package mod_DefenseGunPack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.world.World; import cpw.mods.fml.common.INetworkHandler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod.NULL; import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.registry.GameRegistry; import mod_DefenseGunPack.handlers.DG3x3_PacketHandler; public class CommonProxy { public static void registerRenderInformation() { //No rendering for servers } } package mod_DefenseGunPack.client; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraft.client.model.ModelBase; import net.minecraft.src.ModLoader; import net.minecraftforge.client.MinecraftForgeClient; import mod_DefenseGunPack.CommonProxy; import mod_DefenseGunPack.turrets.DG3x3_EntityLiving; import mod_DefenseGunPack.turrets.renderers.DG3x3_Renderer; import mod_DefenseGunPack.turrets.models.DG3x3_Model; public class ClientProxy extends CommonProxy { public static void registerRenderInformation() { MinecraftForgeClient.preloadTexture("/mod_DefenseGunPack/DefenseGun3x3v1.png"); RenderingRegistry.registerEntityRenderingHandler(mod_DefenseGunPack.turrets.DG3x3_EntityLiving.class, new mod_DefenseGunPack.turrets.renderers.DG3x3_Renderer()); } } package mod_DefenseGunPack.items; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import mod_DefenseGunPack.turrets.DG3x3_EntityLiving; import net.minecraft.block.Block; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.DataWatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.src.ModLoader; import net.minecraft.stats.StatList; import net.minecraft.util.ReportedException; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.EntitySpawnPacket; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class DG3x3_Item extends Item { private int spawnID; public EntityPlayer PlacingPlayer; public DG3x3_Item(int par1) { super(par1); } public boolean FW_CheckPlacementLocation(World par3World, int par4, int par5, int par6, int par7) { if (!par3World.isAirBlock(par4, par5, par6)) { int id = par3World.getBlockId(par4, par5, par6); if (id == 42 || id == 45 || id == 01 || id == 02 || id == 03) { return true; } } System.out.println("Placement 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); 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; } if(spawnTurret(par4, par5, par6, new DG3x3_EntityLiving(par3World), par3World, par2EntityPlayer)) { par1ItemStack.stackSize--; return true; } par2EntityPlayer.swingItem(); return false; } } public static boolean spawnTurret(double x, double y, double z, Entity entity, World world, EntityPlayer player) { if(!world.isRemote) { entity.setPosition(x, y, z); world.spawnEntityInWorld(entity); world.playAuxSFX(2001, (int)x, (int)y, (int)z, Block.stone.blockID); return true; } return false; } } package mod_DefenseGunPack.turrets; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.List; import java.util.Random; import java.util.UUID; import mod_DefenseGunPack.Mod_Turrets; import mod_DefenseGunPack.packet.DG3x3_Packet; import mod_DefenseGunPack.projectiles.EntityExplosiveArrow; import mod_DefenseGunPack.targetfilters.FilterITurret; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.command.IEntitySelector; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.DataWatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.WatchableObject; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.DamageSource; import net.minecraft.util.ReportedException; import net.minecraft.world.World; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.EntitySpawnPacket; import cpw.mods.fml.common.network.FMLPacket; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class DG3x3_EntityLiving extends EntityLiving implements IInventory, IRangedAttackMob, IEntitySelector { private float field_70926_e; private float field_70924_f; private EntityAIArrowAttack field_85037_d = new EntityAIArrowAttack(this, 0F, 1, 25F); private EntityAIAttackOnCollide field_85038_e = new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.31F, false); private ItemStack[] DG3X3v1Contents = new ItemStack[64]; private boolean field_70279_a; private double field_70276_b; @SideOnly(Side.CLIENT) private double velocityX; @SideOnly(Side.CLIENT) private double velocityY; @SideOnly(Side.CLIENT) private double velocityZ; private EntityPlayer entityplayer; private IEntitySelector ientityselector = new FilterITurret(); public DG3x3_Packet DG3x3packet; public DataOutputStream outputStream; public DG3x3_EntityLiving(World par1World) { super(par1World); this.field_70279_a = true; this.field_70276_b = 0.07D; this.preventEntitySpawning = true; this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(2, this.field_85037_d); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 25F, 0, true, true, ientityselector)); this.func_82164_bB(); this.func_82162_bC(); System.out.println("EntitySpawn 1"); } public DG3x3_EntityLiving(World par1World, double par2, double par4, double par6, EntityPlayer player) { super(par1World); double xpos2 = par2 + 0.5; double zpos2 = par6 + 0.5; this.setPosition(xpos2, par4, zpos2); this.motionX = 0.0D; this.motionY = 0.0D; this.motionZ = 0.0D; this.prevPosX = xpos2; this.prevPosY = par4; this.prevPosZ = par6; this.height = 1.5F; this.boundingBox.setBounds(xpos2 - 1.5, par4 - 0, zpos2 - 1.5, xpos2 + 1.5, par4 + 3, zpos2 + 1.5); this.entityplayer = player; this.tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(2, this.field_85037_d); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 25F, 0, true, true, ientityselector)); System.out.println("EntitySpawn 2"); } @Override public void setAttackTarget(EntityLiving par1EntityLiving) { super.setAttackTarget(par1EntityLiving); } @SideOnly(Side.CLIENT) public float getInterestedAngle(float par1) { return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * par1) * 0.15F * (float)Math.PI; } /** * random number generator for instance. Used in random item stack selection. */ private Random DG3X3v1Random = new Random(); /** * the movespeed used for the new AI system */ @Override public float getAIMoveSpeed() { return 0; } /** * Returns the number of slots in the inventory. */ @Override public int getSizeInventory() { return 1; } public boolean isAIEnabled() { return true; } public boolean attackEntityAsMob(Entity par1Entity) { if (super.attackEntityAsMob(par1Entity)) { return true; } else { return false; } } /** * Returns the amount of damage a mob should deal. */ public int getAttackStrength(Entity par1Entity) { return 999; } protected boolean canTriggerWalking() { return false; } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(13, new Byte((byte)0)); this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); this.dataWatcher.addObject(17, Integer.valueOf(0)); this.dataWatcher.addObject(18, Integer.valueOf(0)); this.dataWatcher.addObject(19, Integer.valueOf(0)); this.dataWatcher.addObject(20, Byte.valueOf((byte)0)); } /** * 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. */ @Override public AxisAlignedBB getCollisionBox(Entity par1Entity) { return par1Entity.boundingBox; } /** * returns the bounding box for this entity */ @Override public AxisAlignedBB getBoundingBox() { return this.boundingBox; } /** * Returns true if this entity should push and be pushed by other entities when colliding. */ @Override public boolean canBePushed() { return false; } /** * 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(Mod_Turrets.DG3x3_Item.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 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; } protected void func_82164_bB() { super.func_82164_bB(); this.setCurrentItemOrArmor(0, new ItemStack(Item.bow)); } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ @Override public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); if (getSizeInventory() > 0) { NBTTagList var2 = new NBTTagList(); for (int var3 = 0; var3 < this.getSizeInventory(); ++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) { super.readEntityFromNBT(par1NBTTagCompound); 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); } } } } protected boolean canDespawn() { return false; } /** * 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) { if (getSizeInventory() > 0) { if (!this.worldObj.isRemote) { par1EntityPlayer.displayGUIChest(this); } } return true; } /** * 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); } /** * 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() { return 30; } @Override public void onLivingUpdate() { this.posX = this.prevPosX; this.posY = this.prevPosY; this.posZ = this.prevPosZ; super.onLivingUpdate(); } public void attackEntityWithRangedAttack(EntityLiving par1EntityLiving) { EntityExplosiveArrow var2 = new EntityExplosiveArrow(this.worldObj, this, par1EntityLiving, 1.6F, 12.0F); var2.setDamage(5); var2.setKnockbackStrength(3); this.func_85030_a("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.worldObj.spawnEntityInWorld(var2); } public boolean FW_CheckPlacementLocation(World par3World, int par4, int par5, int par6, int par7) { if (!par3World.isAirBlock(par4, par5, par6)) { int id = par3World.getBlockId(par4, par5, par6); if (id == 42 || id == 45 || id == 01 || id == 02 || id == 03) { return true; } } return false; } public void onUpdate() { super.onUpdate(); this.posX = this.prevPosX; this.posY = this.prevPosY; this.posZ = this.prevPosZ; this.field_70924_f = this.field_70926_e; if (this.func_70922_bv()) { this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; } else { this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; } for (int i = -1; i < 2; i = i + 1) { for (int j = -1; j < 2; j = j + 1) { if (!(FW_CheckPlacementLocation(this.worldObj, (int)this.posX + i, (int)posY - 1, (int)this.posZ + j, 0))) { this.kill(); } } } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(20) == 1; } public void func_70918_i(boolean par1) { byte var2 = this.dataWatcher.getWatchableObjectByte(20); if (par1) { this.dataWatcher.updateObject(20, Byte.valueOf((byte)1)); } else { this.dataWatcher.updateObject(20, Byte.valueOf((byte)0)); } } public void onKillEntity(EntityLiving par1EntityLiving) { super.onKillEntity(par1EntityLiving); if (this.worldObj.difficultySetting >= 2 && par1EntityLiving instanceof EntityVillager) { if (this.worldObj.difficultySetting == 2 && this.rand.nextBoolean()) { return; } this.dataWatcher.updateObject(20, Byte.valueOf((byte)0)); this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, (int)this.posX, (int)this.posY, (int)this.posZ, 0); } } @Override public boolean isEntityApplicable(Entity par1Entity) { if (par1Entity instanceof IMob) { return par1Entity instanceof IMob; } else if (par1Entity instanceof EntityLiving && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityVillager) && !(par1Entity instanceof EntityAnimal)) { return par1Entity instanceof EntityLiving; } else if (par1Entity instanceof EntitySlime) { return par1Entity instanceof EntitySlime; } else { return false; } } } Can anyone help me figure out why this is not working in MP? Thanks!
  4. I'm having a huge issue understanding just what I am supposed to do with the crafting handler. The whole system works perfectly in single player but in multi player the item will show up in the crafting-out box but cannot be moved from there into my inventory. Here is the code I have so far: package mod_DefenseGunPack; import java.util.ArrayList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.src.ModLoader; import cpw.mods.fml.common.ICraftingHandler; import cpw.mods.fml.common.Mod.Item; import cpw.mods.fml.common.modloader.BaseModProxy; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class CraftingHandlerDefenseGun3x3v1 implements ICraftingHandler { // private BaseModProxy mod; private BaseModProxy mod; public CraftingHandlerDefenseGun3x3v1(BaseModProxy mod) { this.mod = mod; } @Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { // TODO Auto-generated method stub if(item.itemID == 5000) //if item is ItemDefenseGun3x3v1 { // craftMatrix.setInventorySlotContents(5000, item); mod.takenFromCrafting(player, item, craftMatrix); //player.inventory.addItemStackToInventory(item); System.out.println("onCrafting"); } } @Override public void onSmelting(EntityPlayer player, ItemStack item) { // TODO Auto-generated method stub } } public static ICraftingHandler craftingHandlerDG3x3v1 = new CraftingHandlerDefenseGun3x3v1(proxy); @Init GameRegistry.registerCraftingHandler(craftingHandlerDG3x3v1); Can anyone tell me what I'm doing wrong and how I should be doing it? I got pointed to a guide here: http://www.minecraftforge.net/wiki/How_to_add_an_Achievement which was helpful in setting it up but not in telling it to do the right thing. Thanks!
  5. Google revealed to me that a few modders were having issues with setting the bounding box for custom entities. I played around with it for a while and I figured out. This is for those that happen to need and answer and find this thread. The bounding box is an AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ) type. The catch is, and where most people seem to be getting confused, is that the these values are not offsets from the center of the entity. These are global world coordinates. So what we would think would be boundingBox(-1, 0, -1, 1, 2, 1), assuming the box is at global coords (350, 75, 670) should really be boundingBox(350 - 1, 75 - 0, 670 - 1, 350 + 1, 75 + 2, 670 + 1). So your final script should look something like this: import net.minecraft.entity.Entity; class myEntity extends EntityLiving { //No local boundingBox variable. The game won't use it. double minX = -1 //this is the left/right direction double minY = 0 //this is the up/down direction double minZ = -1 //this is the forward/back direction double maxX = 1 //this is the left/right direction double maxY = 2 //this is the up/down direction double maxZ = 1 //this is the forward/back direction //this will produce a (2x2x2) bounding box that sits flat on the ground. public myEntity (World par1World, double par2, double par4, double par6) { super(par1World); this.boundingBox.setBounds(par 2 - minX, par4 - minY, par6 - minZ, par2 + maxX, par4 + maxY, par6 + maxZ); } //Not done yet @Override public AxisAlignedBB getCollisionBox(Entity par1Entity) { return par1Entity.boundingBox; } @Override public AxisAlignedBB getBoundingBox() { return this.boundingBox; } public boolean canBeCollidedWith() { return !this.isDead; } } //Note this code has NOT been tested nor will I help anyone debug it.
  6. 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?
×
×
  • Create New...

Important Information

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