Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

null pointer exception with @Mod


DanielRuns
 Share

Recommended Posts

When I try and make a mod, the main file causes Minecraft to crash upon startup. It even crashes when this is my entire main file:

package gas.common;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.network.NetworkMod;

@Mod(modid = "GasMod", name = "Gas", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class GasMain {

}

 

Note: I've tried adding init, preinit, etc. methods to the class and it gives me the same result.

This is the Crash log http://pastebin.com/W6VSTwHs

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Use the forge provided spawn egg. Not your current hack.
    • Lol. I didn't mean the literate word. Of course I can review that in a translator. By definition that would mean "to repeatedly, or in succession tag/label/numerize/sent/release something", if related to actual code? I may as well completely expressed myself wrongly. What I mend was, when do I want to use it? Is it comparable to a "for loop", only it automatically applies numbered variables? Does it have any relation to "produce in series"? I've seen people using it, and asking for it all the time, yet I haven't had a case to use it myself. I just want to prepared, so I actually understand when I want to use it, once it shows up. I guess I'd use it when a serializer doesn't exist for a given tag/recipe/loot_table etc.?
    • Error = Required RegistryObject<?extends EntityType<?>> Provided EntityType<SKELETON>
    • What's then the problem? As uSkizzik already mentioned Forge has their own SpawnEggItem use it
    • I think the error comes from this java class even though it dosen't show any error -  package com.mahidhoni123.forgemod.items; import net.minecraft.core.BlockSource; import net.minecraft.core.Direction; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; import net.minecraft.world.level.block.DispenserBlock; import net.minecraftforge.common.util.Lazy; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.fmllegacy.RegistryObject; import java.util.ArrayList; import java.util.List; import java.util.Map; public class ModSpawnEggItem extends SpawnEggItem { protected static final List<ModSpawnEggItem> UNADDED_EGGS = new ArrayList<>(); private final Lazy<? extends EntityType<?>> entityTypeSupplier; public ModSpawnEggItem(final RegistryObject<? extends EntityType<?>> entityTypeSupplier, int p_43208_, int p_43209_, Properties p_43210_) { super(null, p_43208_, p_43209_, p_43210_); this.entityTypeSupplier = Lazy.of(entityTypeSupplier::get); UNADDED_EGGS.add(this); } public static void initSpawnEggs(){ final Map<EntityType<?>, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, null, "field_195987_b"); DefaultDispenseItemBehavior dispenseBehavior = new DefaultDispenseItemBehavior() { @Override protected ItemStack execute(BlockSource p_123385_, ItemStack p_123386_) { Direction direction = p_123385_ .getBlockState().getValue(DispenserBlock.FACING); EntityType<?> type = ((SpawnEggItem) p_123386_.getItem()).getType(p_123386_.getTag()); type.spawn(p_123385_.getLevel(), p_123386_, null, p_123385_.getPos(), MobSpawnType.DISPENSER, direction != Direction.UP, false); p_123386_.shrink(1); return p_123386_; } }; for (final SpawnEggItem spawnEgg : UNADDED_EGGS) { EGGS.put(spawnEgg.getType(null ), spawnEgg); DispenserBlock.registerBehavior(spawnEgg, dispenseBehavior); } UNADDED_EGGS.clear(); } @Override public EntityType<?> getType(CompoundTag nbt) { return this.entityTypeSupplier.get(); } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.