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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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