Posted April 14, 201411 yr For my fuel handler i need to compare 2 items. Comparing vanilla items works fine, but as soon as i try to compare custom items i get 0 energy returned. Tried to use equal as well, same result. public static int getFuelValue(ItemStack itemstack) { int fuelValue=0; if (itemstack.getItem().equals(DimensionShift.itemEnderDust)) fuelValue=1000; if (itemstack.getItem()==DimensionShift.itemEnderCrystal) fuelValue=1500; if (itemstack.getItem()==Items.ender_eye) fuelValue=800; if (itemstack.getItem()==Items.ender_pearl) fuelValue=600; if (itemstack.getItem()==Items.nether_star) fuelValue=5000; if (itemstack==new ItemStack(Blocks.dragon_egg)) fuelValue=5500; return fuelValue; } Here could be your advertisement!
April 14, 201411 yr Author Can we see your DimensionShift class? package net.dimensionshift.mod; import net.dimensionshift.mod.gui.GuiHandler; import net.dimensionshift.mod.item.ItemBasic; import net.dimensionshift.mod.particle.EntityTeleportFX; import net.dimensionshift.mod.proxies.DimensionShiftClientProxy; import net.dimensionshift.mod.proxies.DimensionShiftCommonProxy; import net.dimensionshift.mod.tileentity.TileEntitySimpleController; import net.dimensionshift.mod.world.biome.BiomeGenWasteland; import net.dimensionshift.mod.world.biome.BiomeGenWastelandHilly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.particle.EntityFX; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @Mod(modid = DimensionShift.MODID, name= "DimensionShift", version = DimensionShift.VERSION) public class DimensionShift { public static final String MODID = "dimensionshift"; //setting MODID public static final String VERSION = "Beta v0.100"; //setting MODID @Instance(MODID) public static DimensionShift instance; public static int dimensionId=9; //Proxies @SidedProxy(clientSide="net.dimensionshift.mod.proxies.DimensionShiftClientProxy", serverSide="net.dimensionshift.mod.proxies.DimensionShiftCommonProxy") public static DimensionShiftCommonProxy proxy; public static CreativeTabs tabDimensionshift = new CreativeTabs("tabDimensionshift") { @SideOnly(Side.CLIENT) public ItemStack getIconItemStack() { return new ItemStack(Items.ender_eye, 1, 0); } @Override public Item getTabIconItem() { // TODO Auto-generated method stub return null; } }; //defining Blocks public static Block blockDummy; public static Block blockEnderDirt; public static Block blockEnderGrass; public static Block blockMachineBlock; public static Block blockSimpleControllerIdle; public static Block blockSimpleControllerActive; public static Block blockSunBlockIdle; public static Block blockSunBlockActive; //defining Items public static Item itemEnderDust; public static Item itemEnderCrystal; public static Item itemEnderLense; //Biomes public static BiomeGenBase biomeWasteland; public static BiomeGenBase biomeWastelandHilly; //GUI public static final int guiIdSimpleController = 0; /* * CONFIG FILE: * */ @EventHandler public void preInit(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); // loading the configuration from its file config.load(); // saving the configuration to its file config.save(); //BLOCKS blockEnderDirt = new net.dimensionshift.mod.block.BasicBlock(Material.ground, "blockEnderDirt").setStepSound(Block.soundTypeStone).setResistance(10F); GameRegistry.registerBlock(blockEnderDirt, "blockEnderDirt"); blockDummy = new net.dimensionshift.mod.block.BlockDummy(Material.ground, "blockDummy").setStepSound(Block.soundTypeStone).setResistance(10F); GameRegistry.registerBlock(blockDummy, "blockDummy"); blockMachineBlock = new net.dimensionshift.mod.block.BasicBlock(Material.rock, "blockMachineBlock").setStepSound(Block.soundTypeMetal).setResistance(80F).setHardness(3F); GameRegistry.registerBlock(blockMachineBlock, "blockMachineBlock"); blockEnderGrass = new net.dimensionshift.mod.block.BlockEnderGrass(Material.ground, "blockEnderGrass").setStepSound(Block.soundTypeGrass); blockSimpleControllerIdle = new net.dimensionshift.mod.block.BlockSimpleController(false).setHardness(3.5F).setStepSound(Block.soundTypeMetal).setCreativeTab(DimensionShift.tabDimensionshift).setBlockName("blockSimpleController"); blockSimpleControllerActive = new net.dimensionshift.mod.block.BlockSimpleController(true).setHardness(3.5F).setStepSound(Block.soundTypeMetal).setLightLevel(0.7F).setBlockName("blockSimpleControllerActive"); GameRegistry.registerBlock(blockSimpleControllerIdle, "blockSimpleController"); GameRegistry.registerBlock(blockSimpleControllerActive, "blockSimpleControllerActive"); GameRegistry.registerTileEntity(TileEntitySimpleController.class, "tileEntitySimpleController"); blockSunBlockIdle = new net.dimensionshift.mod.block.BlockSunBlock(false).setHardness(3.5F).setStepSound(Block.soundTypeMetal).setCreativeTab(DimensionShift.tabDimensionshift).setBlockName("blockSunBlock"); blockSunBlockActive = new net.dimensionshift.mod.block.BlockSunBlock(true).setHardness(3.5F).setStepSound(Block.soundTypeMetal).setLightLevel(0.7F).setBlockName("blockSunBlockActive"); GameRegistry.registerBlock(blockSunBlockIdle, "blockSunBlock"); GameRegistry.registerBlock(blockSunBlockActive, "blockSunBlockActive"); //ITEMS final Item itemEnderDust = new ItemBasic(64, 1, "itemEnderDust"); final Item itemEnderLense = new ItemBasic(16, 1, "itemEnderLense"); final Item itemEnderCrystal = new ItemBasic(64, 1, "itemEnderCrystal"); GameRegistry.registerItem(itemEnderDust, "itemEnderDust"); GameRegistry.registerItem(itemEnderLense, "itemEnderLense"); GameRegistry.registerItem(itemEnderCrystal, "itemEnderCrystal"); NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); //BIOMES biomeWasteland=new BiomeGenWasteland(140); biomeWastelandHilly=new BiomeGenWastelandHilly(141); //DIMENSIONS DimensionManager.registerProviderType(DimensionShift.dimensionId, net.dimensionshift.mod.world.dimensions.WorldProviderDS.class, false); DimensionManager.registerDimension(DimensionShift.dimensionId, DimensionShift.dimensionId); GameRegistry.addShapelessRecipe(new ItemStack(itemEnderDust), new ItemStack(Items.redstone, 2), new ItemStack(Items.ender_pearl,2)); //EnderDust GameRegistry.addSmelting(itemEnderDust, new ItemStack(itemEnderCrystal, 1), 0.1f); //EnderCrystal GameRegistry.addRecipe(new ItemStack(itemEnderLense), " x ", "x x", //ender Lense 'x', new ItemStack(itemEnderCrystal)); GameRegistry.addRecipe(new ItemStack(blockMachineBlock), "xxx", "xyx", "xzx", //machine block 'x', new ItemStack(Items.iron_ingot), 'y', new ItemStack(itemEnderDust), 'z', new ItemStack(Items.redstone)); GameRegistry.addRecipe(new ItemStack(blockSimpleControllerIdle), "xzx", "xcx", "xyx", //Simpe controller block block 'x', new ItemStack(blockMachineBlock), 'y', new ItemStack(itemEnderDust), 'z', new ItemStack(Items.redstone), 'c', new ItemStack(itemEnderLense)); GameRegistry.addRecipe(new ItemStack(blockSunBlockIdle), "xzx", "xcx", "yyy", //machine block 'x', new ItemStack(blockMachineBlock), 'y', new ItemStack(itemEnderLense), 'z', new ItemStack(Items.redstone), 'c', new ItemStack(Blocks.glowstone)); } @EventHandler public void Init(FMLInitializationEvent e) { } @EventHandler public void PostInit(FMLInitializationEvent e) { proxy.initCapes(); } } Here could be your advertisement!
April 15, 201411 yr Hi The items don't match because they're not the same Item. //defining Items public static Item itemEnderDust; public static Item itemEnderCrystal; public static Item itemEnderLense; and then in preInit(..) final Item itemEnderDust = new ItemBasic(64, 1, "itemEnderDust"); final Item itemEnderLense = new ItemBasic(16, 1, "itemEnderLense"); final Item itemEnderCrystal = new ItemBasic(64, 1, "itemEnderCrystal"); -TGG
April 15, 201411 yr if (itemstack==new ItemStack(Blocks.dragon_egg)) fuelValue=5500; What you are saying here is "if an itemstack that was created earlier IS the item stack I just created now..." ==does not tell you if 2 objects are similar, or even have the exact same properties. It tells you if they ARE the same object.
April 15, 201411 yr Author if (itemstack==new ItemStack(Blocks.dragon_egg)) fuelValue=5500; What you are saying here is "if an itemstack that was created earlier IS the item stack I just created now..." ==does not tell you if 2 objects are similar, or even have the exact same properties. It tells you if they ARE the same object. Yeah i know that the enderegg doesn't work (just wanted to try it....) but thats not my problem. My problem is that i can't compare my custom items(ender dust, crystal...). And TGG, what do you mean with: The items don't match because they're not the same Item. Here could be your advertisement!
April 15, 201411 yr Author He meant you created a new variable instead of using the static field. oh, i had a final Item in front of them... Here could be your advertisement!
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.