Jump to content

Recommended Posts

Posted

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!

Posted

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!

Posted

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

Posted

 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.

Posted

 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!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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