Jump to content

Recommended Posts

Posted

I have an item (ItemRocketLauncher) Which, onItemRightClick spawns in the EntityRocket... BUT ITS INVISIBLE

I decided to make a techne model... exported it as a model, fixed errors... still invisible.

 

Here is the code:

 

ItemRocketLauncher

package assets.battleofthebeasts.common.items;

import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import assets.battleofthebeasts.common.BattleOfTheBeastsMod;
import assets.battleofthebeasts.entity.projectiles.EntityRocket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRocketLauncher extends Item
{







public ItemRocketLauncher(int id) 
{
	super(id);
	this.setMaxStackSize(1);
	this.setCreativeTab(CreativeTabs.tabMaterials);


}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg)
{
	this.itemIcon = reg.registerIcon(BattleOfTheBeastsMod.modid + ":" + this.getUnlocalizedName());
}







@Override
 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
   if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(BattleOfTheBeastsMod.ItemWizardPower.itemID))
   {
     par2World.playSoundAtEntity(par3EntityPlayer, "fireworks.launch", 0.8F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
     if (!par2World.isRemote)
     {
       par2World.spawnEntityInWorld(new EntityRocket(par2World, par3EntityPlayer));
     }
    
   }
   return par1ItemStack;
}


  
	   
   
       

   



}

 

EntityRocket

package assets.battleofthebeasts.entity.projectiles;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import assets.battleofthebeasts.common.BattleOfTheBeastsMod;

public class EntityRocket extends EntityThrowable
{
//field_92057 = ExplosionRadius
 public int field_92057_e = 3;
 private Entity shootingEntity;
 private double speed = 0.3F;




public EntityRocket(World par1World)
   {
       super(par1World);
       this.motionX*=speed;
       this.motionY*=speed;
       this.motionZ*=speed;
       
     
      
      
   }


@Override
protected float getGravityVelocity() 
{
	return 0;
}


   public EntityRocket(World par1World, EntityPlayer par3EntityPlayer)
   {
       super(par1World, par3EntityPlayer);
   }
   public EntityRocket(World par1World, double par2, double par4, double par6)
   {
       super(par1World, par2, par4, par6);
       
   }
  
   protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
   {
   																											//| Make this true of you want to spawn fire on explosion
          																										//V
           this.worldObj.newExplosion((EntityRocket)null, this.posX, this.posY, this.posZ, (float)this.field_92057_e, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
           this.setDead();
       
   }
   
   
}

 

RenderRocket

package assets.battleofthebeasts.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import assets.battleofthebeasts.common.BattleOfTheBeastsMod;
import assets.battleofthebeasts.entity.projectiles.EntityRocket;
import assets.battleofthebeasts.models.RocketModel;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderRocket extends RenderLiving
{
   
    public static final ResourceLocation Texture = new ResourceLocation(BattleOfTheBeastsMod.modid, "/textures/entity/Rocket.png");
    public RenderRocket(RocketModel par1RocketModel, float par2)
    {
        super(par1RocketModel, par2);
    }
    
    @Override
    public void doRender(Entity entity, double d0, double d1, double d2,
     float f, float f1)
    {
    	GL11.glPushMatrix();
    	GL11.glPopMatrix();
    	GL11.glRotatef(90F, 0F, 1.0F, 0.0F);
    }
    
    protected ResourceLocation func_110832_a(EntityRocket par1EntityRocket)
    {
        return Texture;
    }

    protected ResourceLocation func_110775_a(Entity par1Entity)
    {
        return this.func_110832_a((EntityRocket)par1Entity);
    }


}

 

RocketModel

// Date: 8/18/2013 9:33:30 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX






package assets.battleofthebeasts.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class RocketModel extends ModelBase
{
  //fields
    ModelRenderer Front;
    ModelRenderer Middle;
    ModelRenderer Tip;
    ModelRenderer End;
  
  public RocketModel()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Front = new ModelRenderer(this, 2, 6);
      Front.addBox(-2F, -2F, -6F, 4, 4, 6);
      Front.setRotationPoint(0F, 0F, 0F);
      Front.setTextureSize(64, 64);
      Front.mirror = true;
      setRotation(Front, 0F, 0F, 0F);
      Middle = new ModelRenderer(this, 2, 18);
      Middle.addBox(-1F, -1F, 0F, 2, 2, 2);
      Middle.setRotationPoint(0F, 0F, 0F);
      Middle.setTextureSize(64, 64);
      Middle.mirror = true;
      setRotation(Middle, 0F, 0F, 0F);
      Tip = new ModelRenderer(this, 2, 2);
      Tip.addBox(-1F, -1F, -1F, 2, 2, 1);
      Tip.setRotationPoint(0F, 0F, -6F);
      Tip.setTextureSize(64, 64);
      Tip.mirror = true;
      setRotation(Tip, 0F, 0F, 0F);
      End = new ModelRenderer(this, 2, 24);
      End.addBox(-2F, -2F, 0F, 4, 4, 1);
      End.setRotationPoint(0F, 0F, 2F);
      End.setTextureSize(64, 64);
      End.mirror = true;
      setRotation(End, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Front.render(f5);
    Middle.render(f5);
    Tip.render(f5);
    End.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, null);
  }

}

 

Load Method (Main Class)

EntityRegistry.registerGlobalEntityID(EntityRocket.class, "Rocket", 21);
	RenderingRegistry.registerEntityRenderingHandler(EntityRocket.class, new RenderRocket(new RocketModel(), 0.1F));

Posted

public class RenderRocket extends RenderLiving
{
   
    public static final ResourceLocation Texture = new ResourceLocation(BattleOfTheBeastsMod.modid, "textures/entity/Rocket.png");
    public RenderRocket(RocketModel par1RocketModel, float par2)
    {
        super(par1RocketModel, par2);
    }
    
    @Override
    public void doRender(Entity entity, double d0, double d1, double d2,
     float f, float f1)
    {
    	GL11.glPushMatrix();
    	GL11.glPopMatrix();
    	GL11.glRotatef(90F, 0F, 1.0F, 0.0F);
    }

    protected ResourceLocation func_110775_a(Entity par1Entity)
    {
        return Texture;
    }
}

This would be better.

By the way, your doRender method doesn't render your model or anything.

You should probably call model.render(...);  ::)

Posted

 

@Override

    public void doRender(Entity entity, double d0, double d1, double d2,

    float f, float f1)

    {

    GL11.glPushMatrix();

    GL11.glPopMatrix();

    GL11.glRotatef(90F, 0F, 1.0F, 0.0F);

    }

dafuq is this ?

 

lets place this into my gl-to-english translator

 

String glCode = "GL11.glPushMatrix();
GL11.glPopMatrix();
GL11.glRotatef(90F, 0F, 1.0F, 0.0F);"
String englishOutput = GLTranslator.translateGlCode(glCode);
System.out.println(englishOutput);

console:

-save the current matrix state

-restore the latest matrix state//2 statement which togheter do absolutelly nothing

-rotate the whole world with the quaternion (90, 0, 1, 0)//yes you will mess everything up with this

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

lol... lololol.... hmm.. lolol

 

Can you show me how to call the model.render exactly?

..

lol

model.render();

yup ... :)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

STILL invisible... Here is what I have in my RenderRocket

 

RenderRocket

 

package assets.battleofthebeasts.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import assets.battleofthebeasts.common.BattleOfTheBeastsMod;
import assets.battleofthebeasts.models.RocketModel;


   
public class RenderRocket extends RenderLiving
{

    public static final ResourceLocation Texture = new ResourceLocation(BattleOfTheBeastsMod.modid, "textures/entity/Rocket.png");
    
    
    public RenderRocket(RocketModel par1RocketModel, float par2)
    {
        super(par1RocketModel, par2);
    }
    
    public static void doRender(RocketModel model, Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
    {
    	model.render(par1Entity, par2, par2, par2, par2, par2, par2);
    }

    protected ResourceLocation func_110775_a(Entity par1Entity)
    {
        return Texture;
    }



}


Posted

model.render(par1Entity, par2, par2, par2, par2, par2, par2);

dont jsut fill method with any argument you find :\ this will only appear if both you and the mob are at 0, 0, 0

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

hydroflame, I know you are one of the most helpful peeps on Forge, but I'm going to have to ask you to re-type in the entire RenderCode for me...

 

and btw,

model.render(par1Entity, par2, par2, par2, par2, par2, par2);

dont jsut fill method with any argument you find :\ this will only appear if both you and the mob are at 0, 0, 0

 

the arguments were added automatically, If i were to remove it, it will come out as an error

 

  • 2 months later...

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 know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
    • Hi here is an update. I was able to fix the code so my mod does not crash Minecraft. Please understand that I am new to modding but I honestly am having a hard time understanding how anyone can get this to work without having extensive programming and debugging experience as well as searching across the Internet, multiple gen AI bots (claude, grok, openai), and examining source code hidden in the gradle directory and in various github repositories. I guess I am wrong because clearly there are thousands of mods so maybe I am just a newbie. Ok, rant over, here is a step by step summary so others can save the 3 days it took me to figure this out.   1. First, I am using forge 54.1.0 and Minecraft 1.21.4 2. I am creating a mod to add a shotgun to Minecraft 3. After creating the mod and compiling it, I installed the .jar file to the proper directory in Minecraft and used 1.21.4-forge-54.1.0 4. The mod immediately crashed with the error: Caused by: java.lang.NullPointerException: Item id not set 5. Using the stack trace, I determined that the Exception was being thrown from the net.minecraft.world.item.Item.Properties class 6. It seems that there are no javadocs for this class, so I used IntelliJ which was able to provide a decompiled version of the class, which I then examined to see the source of the error. Side question: Are there javadocs? 7. This method, specifically, was the culprit: protected String effectiveDescriptionId() {      return this.descriptionId.get(Objects.requireNonNull(this.id, "Item id not set"));  } 8. Now my quest was to determine how to set this.id. Looking at the same source file, I determined there was another method:  public Item.Properties setId(ResourceKey<Item> pId) {             this.id = pId;             return this;   } 9. So now, I need to figure out how to call setId(). This required working backwards a bit. Starting from the constructor, I stubbed out the variable p which is of type Item.Properties public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); Rather than putting this all on one line, I split it up for readability like this: private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); Here is was the missing function, setId(), which takes a type of ResourceKey<Item>. My next problem is that due to the apparent lack of documentation (I tried searching the docs on this site) I could not determine the full import path to ResourceKey. I did some random searching on the Internet and stumbled across a Github repository which gave two clues: import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; Then I created the rk variable like this: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); And now putting it all together in order: private static ResourceKey<Item> rk = ResourceKey.create(Registries.ITEM, ResourceLocation.parse("modid:shotgunmod")); private static final Item.Properties p = new Item.Properties().useItemDescriptionPrefix().setId(rk); public static final RegistryObject<Item> SHOTGUN = ITEMS.register("shotgun", () -> new ShotgunItem(p)); This compiled and the mod no longer crashes. I still have more to do on it, but hopefully this will save someone hours. I welcome any feedback and if I missed some obvious modding resource or tutorial that has this information. If not, I might suggest we add it somewhere for people trying to write a mod that doesn't crash. Thank you !!!  
    • I will keep adding to this thread with more information in case anyone can help, or at the very least I can keep my troubleshooting organized. I decided to downgrade to 54.1.0 in the hopes that this would fix the issue but it didn't. At least now I am on a "recommended" version. The crash report did confirm my earlier post that the Exception is coming from effectiveDescriptionId(). I'll continue to see if I can find a way to set the ID manually.   Caused by: java.lang.NullPointerException: Item id not set         at java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item$Properties.effectiveDescriptionId(Item.java:465) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/net.minecraft.world.item.Item.<init>(Item.java:111) ~[forge-1.21.4-54.1.0-client.jar!/:?]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ShotgunItem.<init>(ShotgunItem.java:19) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/com.example.shotgunmod.ModItems.lambda$static$0(ModItems.java:15) ~[shotgunmod-1.0.0.jar!/:1.0.0]         at TRANSFORMER/[email protected]/net.minecraftforge.registries.DeferredRegister$EventDispatcher.lambda$handleEvent      
    • It just randomly stop working after a rebooted my dedicated server PLEASE HELP!   com.google.gson   Failed to start the minecraft server com.google.gson.JsonSyntaxException: Expected a com.google.gson.JsonObject but was com.google.gson.JsonPrimitive; at path $  
  • Topics

×
×
  • Create New...

Important Information

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