Jump to content

[solved]Code for Fly Ring


Xetapro12

Recommended Posts

What i do wrong?

 

package com.BetterArmourAndTools.blocksitems;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent;

public class FlyRing extends Item{

public FlyRing(int id){
	super();
	this.setCreativeTab(BetterArmourAndTools.rubyTab);
	this.setMaxStackSize(1);
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg){
	this.itemIcon = reg.registerIcon("BetterArmourAndTools:FlyRing");
}

public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);

	EntityPlayer player = (EntityPlayer) par3Entity;

	ItemStack flyingRingItemStack = new ItemStack(BetterArmourAndTools.FlyRing, 1, 0);

	for(i = 0; i <= 8; i++) {
	if(player.inventory.mainInventory[i] != null &amp;&amp; player.inventory.mainInventory[i].isItemEqual(flyingRingItemStack)) {
	player.capabilities.allowFlying = true;
	}else{
	player.capabilites.allowFlying = false;
	}

	if(i ==  {
	i = 0;
	}
	}
	}
}

 

NEWB! in java im sorry :/

Link to comment
Share on other sites

Right click -> Source -> Correct Indentation (its magic).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

idk i found a annother code here on the forum and its from 1.6.4 just copy it and try making it work for i trying to Check if he have FLyRing in inventory he be allowed to have CreativeFly

 

How i check for

BetterArmourAndTools.FlyRing = true then player.capabilities.allowFlying how :P

NEWB! in java im sorry :/

Link to comment
Share on other sites

You can check if the player has an Item in it's inventory with this:

player.inventory.hasItem(Item)

.

You can allow creative flying by setting

player.capabilities.allowFlying

to

true

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

package com.BetterArmourAndTools.blocksitems;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent;

public class FlyRing extends Item{

public FlyRing(int id){
	super();
	this.setCreativeTab(BetterArmourAndTools.rubyTab);
	this.setMaxStackSize(1);

	if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().ItemID == BetterArmourAndTools.FlyRing)
	{
	System.out.println("CALL");
	player.capabilities.allowFlying = true;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister reg){
	this.itemIcon = reg.registerIcon("BetterArmourAndTools:FlyRing");

}
}

 

dont think this is the best thing to doo xD

NEWB! in java im sorry :/

Link to comment
Share on other sites

What he means is you need to learn simple coding in general. For example, when reading the pastebin Diesieben made, I noticed that your public method didn't have a closing brace (}) you opened two braces and only close one.

 

You need to learn how to use simple code like diesie said before tackling things like this. If I were you, I would try a simpler language or learn how IF, AND and NOT functions work and watch a tutorial about how to use them. Learn the language and the general rules about them.

 

9 times out of 10, indentation WILL help identify a problem. To identify a problem, follow the code; it's a piece of text that should do what you want when you read it in your head and indentation will help you read it.

 

Copying and Pasting is also not learning how to code. It's cheating and you'll learn nothing that way. Try to achieve somethings on your own. For example, create a java app that calls a method that checks if a boolean is true or false and then outputs something to the console, WITHOUT googling for help and copying. Training yourself with exercises like this is what will help you learn how to code.

Link to comment
Share on other sites

What he means is you need to learn simple coding in general. For example, when reading the pastebin Diesieben made, I noticed that your public method didn't have a closing brace (}) you opened two braces and only close one.

 

You need to learn how to use simple code like diesie said before tackling things like this. If I were you, I would try a simpler language or learn how IF, AND and NOT functions work and watch a tutorial about how to use them. Learn the language and the general rules about them.

 

9 times out of 10, indentation WILL help identify a problem. To identify a problem, follow the code; it's a piece of text that should do what you want when you read it in your head and indentation will help you read it.

 

Copying and Pasting is also not learning how to code. It's cheating and you'll learn nothing that way. Try to achieve somethings on your own. For example, create a java app that calls a method that checks if a boolean is true or false and then outputs something to the console, WITHOUT googling for help and copying. Training yourself with exercises like this is what will help you learn how to code.

 

It's not about reading.

Stop modding for a while. Follow a Java tutorial and make your own app. Even if it's just a simple calculator. It is important that you create this app without any help, that is not by just copying the steps from a tutorial.

 

Then start modding again. Yes, it will take time, but that's just the way it is. Learning programming takes time.

 

I know i know i gonna stop modding :'(

NEWB! in java im sorry :/

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.