dalek96 Posted March 22, 2014 Posted March 22, 2014 Hello. This is my first time modding and I can't seem to add a bullet entity ingame. It seems that whenever I test run it the item that shoots the entity does nothing on a right click. Also, I can't seem to apply textures to items/blocks, despite the fact I've checked multiple tutorials and entered the correct code. Finally, I can't seem to create a proper gun, no matter what I do. If you need the src code, tell me and I'll upload it. Quote
hotrods20 Posted March 22, 2014 Posted March 22, 2014 Can you provide your entity and gun source code along with how you are initializing your items. My first guess is you're not registering your entity. If that is the case then in your Init put: EntityRegistry.registerModEntity(MyEntity.class, "MyEntityName", 230, this, 64, 1, true); The first field is your entities class, the next is its name, the third is tracking range(the range MC will send tracking updates), an instance of your mod.class, update frequency, and just set last to true. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
dalek96 Posted March 23, 2014 Author Posted March 23, 2014 Can you provide your entity and gun source code along with how you are initializing your items. My first guess is you're not registering your entity. If that is the case then in your Init put: EntityRegistry.registerModEntity(MyEntity.class, "MyEntityName", 230, this, 64, 1, true); The first field is your entities class, the next is its name, the third is tracking range(the range MC will send tracking updates), an instance of your mod.class, update frequency, and just set last to true. Yeah, I was having problems registering the entity. Here's the src code. package Wh40k; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = Wh40k.modid, name = "Wh40k", version = "0.0.1") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class Wh40k { public static final String modid = "dalekslayer96_Wh40k"; public static Block blockAdamantium; public static Block oreAdamantium; public static Item ingotAdamantium; public static Item boltgun; public static Item powerSword; @EventHandler public void load(FMLInitializationEvent event) { blockAdamantium = new BlockAdamantiumBlock(3600, Material.rock).setUnlocalizedName("blockAdamantium"); GameRegistry.registerBlock(blockAdamantium, modid + blockAdamantium.getUnlocalizedName().substring(5)); LanguageRegistry.addName(blockAdamantium, "Block of Adamantium"); oreAdamantium = new BlockAdamantiumOre(3601, Material.rock).setUnlocalizedName("oreAdamantium"); GameRegistry.registerBlock(oreAdamantium, modid + oreAdamantium.getUnlocalizedName().substring(6)); LanguageRegistry.addName(oreAdamantium, "Adamantium Ore"); ingotAdamantium = new ItemAdamantium(16000).setUnlocalizedName("adamantiumIngot"); LanguageRegistry.addName(ingotAdamantium, "Adamantium Ingot"); boltgun = new ItemBoltgun(16001).setUnlocalizedName("boltgun"); LanguageRegistry.addName(boltgun, "Boltgun"); powerSword = new ItemPowerSword(16002).setUnlocalizedName("powerSword"); LanguageRegistry.addName(powerSword, "Power Sword"); } } As you can see I haven't registered any entities yet, because I was having problems figuring out how to. Here's the entity code (the entity was actually a gun bullet.) package Wh40k; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class EntityBolt extends EntityThrowable { public EntityBolt(World par1World) { super(par1World); } public EntityBolt(World par1World, EntityLiving par2EntityLiving) { super(par1World, par2EntityLiving); } public EntityBolt(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); } @Override protected void onImpact(MovingObjectPosition movingobjectposition) { // TODO Auto-generated method stub } } Basically this entity is meant to explode on contact with it's target. I was having problems with that too. And finally, here's the gun's code. package Wh40k; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemBoltgun extends Item { public ItemBoltgun(int id) { super(id); this.setCreativeTab(CreativeTabs.tabCombat); } @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityBolt(par2World)); } return par1ItemStack; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon(Wh40k.modid + ":" + (this.getUnlocalizedName().substring(5))); } } Quote
hotrods20 Posted March 23, 2014 Posted March 23, 2014 In the load() of your main class, add the EntityRegistry code with your entities information. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
coolAlias Posted March 23, 2014 Posted March 23, 2014 You can check out my tutorial on custom projectiles, which I adapted and updated from the original Blaster Rifle tutorial. There is some stuff from the original tutorial that I don't cover which you may still find interesting and pertinent to your situation, but mine is up to date and will at least get your projectile all sorted out and rendering correctly. Quote http://i.imgur.com/NdrFdld.png[/img]
dalek96 Posted March 25, 2014 Author Posted March 25, 2014 You can check out my tutorial on custom projectiles, which I adapted and updated from the original Blaster Rifle tutorial. There is some stuff from the original tutorial that I don't cover which you may still find interesting and pertinent to your situation, but mine is up to date and will at least get your projectile all sorted out and rendering correctly. Thanks, I'll check it out. Quote
Recommended Posts
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.