• 0

    posted a message on Problem with Fishing Rod Like Item - String Doesn't Show
    EDIT: I somehow managed to solve the problem, it seems to work well now.

    I am trying to make an item that acts like fishing rod as in sticking to and pulling mobs to the user; so I wanted to start with creating a copy of fishing rod and then cut/add functionality because I don't have enough experience to create one from scratch. While it was a pain in the butt to create new ItemFishingRod, EntityFishHook and RenderFish (their names are ItemGrap, EntityGrapHook, RenderGrapHook) ; I managed to make it basically work so I can use it to catch mobs and pull them but the problem is that there is no string. The hook itself is showing well and I can modify the maths in EntityGrapHook to make it work differently but the code about the string in RenderGrapHook just doesn't work.
    Any help would be appreciated.

    Extra Information: This is the method of RenderGrapHook class that does all the work:
    public void doRenderFishHook(EntityGrapHook par1EntityGrapHook, double par2, double par4, double par6, float par8, float par9)
    {
    
    
    	 GL11.glPushMatrix();
    	 GL11.glTranslatef((float)par2, (float)par4, (float)par6);
    	 GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    	 GL11.glScalef(0.5F, 0.5F, 0.5F);
    	 byte var10 = 1;
    	 byte var11 = 2;
    	 this.loadTexture(CommonProxy.ITEMS_PNG);
    	 Tessellator var12 = Tessellator.instance;
    	 float var13 = (float)(var10 * 8 + 0) / 128.0F;
    	 float var14 = (float)(var10 * 8 + 8) / 128.0F;
    	 float var15 = (float)(var11 * 8 + 0) / 128.0F;
    	 float var16 = (float)(var11 * 8 + 8) / 128.0F;
    	 float var17 = 1.0F;
    	 float var18 = 0.5F;
    	 float var19 = 0.5F;
    	 GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    	 GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    	 var12.startDrawingQuads();
    	 var12.setNormal(0.0F, 1.0F, 0.0F);
    	 var12.addVertexWithUV((double)(0.0F - var18), (double)(0.0F - var19), 0.0D, (double)var13, (double)var16);
    	 var12.addVertexWithUV((double)(var17 - var18), (double)(0.0F - var19), 0.0D, (double)var14, (double)var16);
    	 var12.addVertexWithUV((double)(var17 - var18), (double)(1.0F - var19), 0.0D, (double)var14, (double)var15);
    	 var12.addVertexWithUV((double)(0.0F - var18), (double)(1.0F - var19), 0.0D, (double)var13, (double)var15);
    	 var12.draw();
    	 GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    	 GL11.glPopMatrix();
    	
    	 if (par1EntityGrapHook.angler != null)
    	 {
    System.out.println("Works!");
    		
    		 float var20 = par1EntityGrapHook.angler.getSwingProgress(par9);
    		 float var21 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    		 Vec3 var22 = par1EntityGrapHook.worldObj.getWorldVec3Pool().getVecFromPool(-0.5D, 0.03D, 0.8D);
    		 var22.rotateAroundX(-(par1EntityGrapHook.angler.prevRotationPitch + (par1EntityGrapHook.angler.rotationPitch - par1EntityGrapHook.angler.prevRotationPitch) * par9) * (float)Math.PI / 180.0F);
    		 var22.rotateAroundY(-(par1EntityGrapHook.angler.prevRotationYaw + (par1EntityGrapHook.angler.rotationYaw - par1EntityGrapHook.angler.prevRotationYaw) * par9) * (float)Math.PI / 180.0F);
    		 var22.rotateAroundY(var21 * 0.5F);
    		 var22.rotateAroundX(-var21 * 0.7F);
    		 double var23 = par1EntityGrapHook.angler.prevPosX + (par1EntityGrapHook.angler.posX - par1EntityGrapHook.angler.prevPosX) * (double)par9 + var22.xCoord;
    		 double var25 = par1EntityGrapHook.angler.prevPosY + (par1EntityGrapHook.angler.posY - par1EntityGrapHook.angler.prevPosY) * (double)par9 + var22.yCoord;
    		 double var27 = par1EntityGrapHook.angler.prevPosZ + (par1EntityGrapHook.angler.posZ - par1EntityGrapHook.angler.prevPosZ) * (double)par9 + var22.zCoord;
    		 double var29 = par1EntityGrapHook.angler != Minecraft.getMinecraft().thePlayer ? (double)par1EntityGrapHook.angler.getEyeHeight() : 0.0D;
    		 if (this.renderManager.options.thirdPersonView > 0 || par1EntityGrapHook.angler != Minecraft.getMinecraft().thePlayer)
    		 {
    			 float var31 = (par1EntityGrapHook.angler.prevRenderYawOffset + (par1EntityGrapHook.angler.renderYawOffset - par1EntityGrapHook.angler.prevRenderYawOffset) * par9) * (float)Math.PI / 180.0F;
    			 double var32 = (double)MathHelper.sin(var31);
    			 double var34 = (double)MathHelper.cos(var31);
    			 var23 = par1EntityGrapHook.angler.prevPosX + (par1EntityGrapHook.angler.posX - par1EntityGrapHook.angler.prevPosX) * (double)par9 - var34 * 0.35D - var32 * 0.85D;
    			 var25 = par1EntityGrapHook.angler.prevPosY + var29 + (par1EntityGrapHook.angler.posY - par1EntityGrapHook.angler.prevPosY) * (double)par9 - 0.45D;
    			 var27 = par1EntityGrapHook.angler.prevPosZ + (par1EntityGrapHook.angler.posZ - par1EntityGrapHook.angler.prevPosZ) * (double)par9 - var32 * 0.35D + var34 * 0.85D;
    		 }
    		 double var46 = par1EntityGrapHook.prevPosX + (par1EntityGrapHook.posX - par1EntityGrapHook.prevPosX) * (double)par9;
    		 double var33 = par1EntityGrapHook.prevPosY + (par1EntityGrapHook.posY - par1EntityGrapHook.prevPosY) * (double)par9 + 0.25D;
    		 double var35 = par1EntityGrapHook.prevPosZ + (par1EntityGrapHook.posZ - par1EntityGrapHook.prevPosZ) * (double)par9;
    		 double var37 = (double)((float)(var23 - var46));
    		 double var39 = (double)((float)(var25 - var33));
    		 double var41 = (double)((float)(var27 - var35));
    		 GL11.glDisable(GL11.GL_TEXTURE_2D);
    		 GL11.glDisable(GL11.GL_LIGHTING);
    		 var12.startDrawing(3);
    		 var12.setColorOpaque_I(0);
    		 byte var43 = 16;
    		 for (int var44 = 0; var44 <= var43; ++var44)
    		 {
    			 float var45 = (float)var44 / (float)var43;
    			 var12.addVertex(par2 + var37 * (double)var45, par4 + var39 * (double)(var45 * var45 + var45) * 0.5D + 0.25D, par6 + var41 * (double)var45);
    		 }
    		 var12.draw();
    		 GL11.glEnable(GL11.GL_LIGHTING);
    		 GL11.glEnable(GL11.GL_TEXTURE_2D);
    	 }
    }


    I think the part about the string is after the statement if (par1EntityGrapHook.angler != null) because I found out that it doesn't work, which brought me to the conclusion that par1EntityGrapHook.angler is always null. I put print commands everywhere and it seems the angler is really null. Angler is the player that uses the item. It is declared in EntityGrapHook. That class has three constructors:
    public EntityGrapHook(World par1World)
    {
    	 super(par1World);
    	 this.xTile = -1;
    	 this.yTile = -1;
    	 this.zTile = -1;
    	 this.inTile = 0;
    	 this.inGround = false;
    	 this.shake = 0;
    	 this.ticksInAir = 0;
    	 this.ticksCatchable = 0;
    	 this.bobber = null;
    	 this.setSize(0.25F, 0.25F);
    	 this.ignoreFrustumCheck = true;
    	
    	 System.out.println("entity one "+this.angler);
    }
    @SideOnly(Side.CLIENT)
    public EntityGrapHook(World par1World, double par2, double par4, double par6, EntityPlayer par8EntityPlayer)
    {
    	 this(par1World);
    	 this.setPosition(par2, par4, par6);
    	 this.ignoreFrustumCheck = true;
    	 this.angler = par8EntityPlayer;
    	 this.theGrap = (ItemGrap) par8EntityPlayer.getCurrentEquippedItem().getItem();
    	 this.theGrap.grapEntity = this;
    	
    	 System.out.println("entity many "+this.angler);
    }
    public EntityGrapHook(World par1World, EntityPlayer par2EntityPlayer)
    {
    super(par1World);
    	 this.xTile = -1;
    	 this.yTile = -1;
    	 this.zTile = -1;
    	 this.inTile = 0;
    	 this.inGround = false;
    	 this.shake = 0;
    	 this.ticksInAir = 0;
    	 this.ticksCatchable = 0;
    	 this.bobber = null;
    	 this.ignoreFrustumCheck = true;
    	 this.angler = par2EntityPlayer;
    	 this.theGrap = (ItemGrap) par2EntityPlayer.getCurrentEquippedItem().getItem();
    	 this.theGrap.grapEntity = this;
    	
    	 this.setSize(0.25F, 0.25F);
    	 this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + 1.62D - (double)par2EntityPlayer.yOffset, par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
    	 this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    	 this.posY -= 0.10000000149011612D;
    	 this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    	 this.setPosition(this.posX, this.posY, this.posZ);
    	 this.yOffset = 0.0F;
    	 float var3 = 0.4F;
    	 this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * var3);
    	 this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * var3);
    	 this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * var3);
    	 this.calculateVelocity(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F);
    	
    	 System.out.println("entity two "+this.angler);
    }


    There are minor differences from EntityFishHook because it couldn't work otherwise but I did not touch anything with this.angler. I put print commands to test it and found out that the constructer with two parameters is called first, it puts the parameter par2EntityPlayer's value into this.angler. This constructer is the one called in ItemGrap's onRightClick method. Printed output also shows that this angler has the right value so no problem yet. Just after this, the constructer with one parameter is called. I have no idea from where it is called but it does. And the printed output shows that this.angler is now null! After that a print command in RenderGrapHook starts to work and outputs that the angler is null repeatedly.

    I couldn't find out what the problem was so I tried to see how the original fishing rod works. I tried the same test on vanilla classes and as it goes the same for first two constructer calls, this time also the other constructer with many parameters is called and the angler is set once again to the right player value and the print command in renderer confirms this. Also the string shows perfectly of course.

    Now, these are my tests and thoughts and I might be working on a completely wrong way since I am not even sure if that piece of code actually draws the string but there is definitely a problem there. The constructor with lots of parameters is never called in my version and I don't know why.

    I am not an experience modder and definitely not a java expert so I am just stuck. Please help if you can, and thank you if you paid time to read all this post.
    Posted in: Modification Development
  • 0

    posted a message on [Mods] How to install Single Player Commands! [Easiest thing EVER!]
    I remember there being an automated installer for single player commands and even installing manually isn't hard as long as one reads the simple instructions in the thread of this mod. Also no offence but is this even called a modding tutorial?
    Posted in: Tutorials
  • 0

    posted a message on [ModLoader] Tools and Swords Tutorial - Basics, Rarity and Enchanting!
    You, sir, make great little tutorials in contrast to the ones that make tons of low quality tutorials. Thank you very much!
    Posted in: Tutorials
  • 0

    posted a message on TechGuy's Modding Tutorials
    I'm having a problem with crops. The method about fertilizing the crop with a bonemeal doesn't work. It says
    the super class doesn't have a method called "blockActivated" but we are calling it at the end of this method. I looked through the blockflower class and couldn't find that method. What should I do?
    public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
    {
    ItemStack itemstack = entityplayer.inventory.getCurrentItem();
    if(itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex)
    {
    if(itemstack.getItemDamage() == 15)
    {
            world.setBlockMetadataWithNotify(i, j, k, 8);
            itemstack.stackSize--;
            world.notifyBlockChange(i, j, k, 0);
    }
    }
    return super.blockActivated(world, i, j, k, entityplayer);
    }
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [1.3.2] SDK's Mods [v1] *Aug 18th ModLoaderMP Updated*
    Quote from Groxmapper

    The difference is the server single player is handled on is LAN, which means 'Local Area Network', In other words, you can't just invite a friend using the IP because unless they live nearby and use your network it won't work. The normal server is still needed for long-range games.

    It may be LAN but this still means when playing single player, you are actually playing on an internal server. A server is a server whether it is LAN or not. (Hamachi can also be used to create a LAN and play with distant people) By this I mean, if something works in single player and single player is a kind of server than it should work for normal servers, too. Jeb also said it would be easier to make multiplayer mods in 1.3 because the modders wouldn't have to make the mod seperately for server and client, like one mod to rule them all. That's why I still don't understand why we need to make the same mod differently for server and client, like before and so why we need to use a mod like ModLoaderMP (thanks to SDK for this great mod by the way) instead of using only one ModLoader.
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.3.2] SDK's Mods [v1] *Aug 18th ModLoaderMP Updated*
    I don't understand one thing. If there is no single player-server difference in 1.3 and single player is actually just a local host multiplayer, then every mod should work for both single and multiplayer. Does this mean there is actually no need for multiplayermp anymore? Is modloader going to work for multiplayer?
    Posted in: Minecraft Mods
  • To post a comment, please .