Jump to content

How do i make my own munition with a model-class and a renderer class?


Drachenbauer

Recommended Posts

Hello

 

Im trying to make a slingshot to use like the bow.

How do i create a munition-entity (based on the arrow-entity), that uses a renderer-class and a model-class?

I want to use my Angry Birds models from my living-entities for the munition too, just scale them down.

 

Actual i´m trying to reproduce, how arrows are made in the original vanilla-code and rename them as my birds

and than i thaught, i can use copies of the renderers and models, i use for my other Angry Birds, just put small numbers in the scale-method, i already use for some of them.

Here is such a renderer class:

package drachenbauer32.angrybirdsmod.entities.renderers;

import com.mojang.blaze3d.platform.GlStateManager;

import drachenbauer32.angrybirdsmod.entities.BluesEntity;
import drachenbauer32.angrybirdsmod.entities.models.BluesModel;
import drachenbauer32.angrybirdsmod.util.Reference;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.LivingRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.IRenderFactory;

@OnlyIn(Dist.CLIENT)
public class BluesRenderer extends LivingRenderer<BluesEntity, BluesModel>
{
    private static final ResourceLocation BLUES_TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/entity/blues.png");
    
    public BluesRenderer(EntityRendererManager manager)
    {
        super(manager, new BluesModel(), 0.25f);
    }
    
    @Override
    public float prepareScale(BluesEntity entitylivingbaseIn, float partialTicks)
    {
        GlStateManager.scalef(0.5F, 0.5F, 0.5F);
        return super.prepareScale(entitylivingbaseIn, partialTicks);
    }
    
    @Override
    protected ResourceLocation getEntityTexture(BluesEntity arg0)
    {
        return BLUES_TEXTURE;
    }
	
    public static class RenderFactory implements IRenderFactory<BluesEntity>
    {
        @Override
        public EntityRenderer<? super BluesEntity> createRenderFor(EntityRendererManager manager)
        {
            return new BluesRenderer(manager);
        }
    }
}

It uses a model and scales it down to half size.

But it seams like it is not compatiple to the munition-entities

 

Is there any way to use a model and a scale-factor in a renderer, that´s compatiple with a munition-entity?

Edited by Drachenbauer
Link to comment
Share on other sites

Now i try to make my own abstract renderer, that extends the EntityRenderer-class and uses a model and a scale-factor just like the LivingRenderer-class, but without any living stuff.

 

Maybe i can use any code from the LivingRenderer, but i´m not sure, wich parts of code i can remove in my variant to make it render a model without any living animations.

Link to comment
Share on other sites

now  my munition-class extends AbstactArrowEntity.

I have got a generic entity-class for my bird munitions, that´extends AbstactArrowEntity, and than i create specific entity-classes for each bird, wich extend my generic class for this.

So each bird get´s it´s own entity-, renderer- and model-class.

 

What must i do to use Red (the leader of the Angry Birds-flock) as the main munition, that can be used unlimited (much like the common arrow for the bow), and the others, if I hold them as an item in the other hand (item-stack, that decreases by one each shot, until empty)?

Edited by Drachenbauer
Link to comment
Share on other sites

This is now the actual state of my mod:

AngryBirdsMod Github

 

My sligshot extends the bow now, but i override the method onPlayerStoppedUsing and still use it´s whoole content, where i replaced "ArrowItem" with my own munition item-class.

I see no other way to make it use onmy my own stuff

 

I wonder, why my slingshot doesn´t shoot any more (makes the pose, but doesn´t change it´s testure to the pulled state.)...

Is anything at the munition not registered correct?

 

 

 

Another question:

The common arrows get different colored arrow-heads, if enchanted.

How do i make my birds get that magic glow of other enchanted items instead?

Edited by Drachenbauer
Link to comment
Share on other sites

8 hours ago, Drachenbauer said:

My sligshot extends the bow now, but i override the method onPlayerStoppedUsing and still use it´s whoole content, where i replaced "ArrowItem" with my own munition item-class.

I see no other way to make it use onmy my own stuff

...and you just ignored all advices given to you previously.

Override BowItem#isArrow and return true if the given ItemStack is your custom ammo.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

my munition does not extend ArrowItem.

So it cannot find it, if it still uses ArrowItem in it´s onPlayerStoppedUsing method.

 

And i think, if my munition-item extends ArrowItem, the bow will be able to shoot it too.

But i looked for a way to make this unable, too

Edited by Drachenbauer
Link to comment
Share on other sites

18 hours ago, Drachenbauer said:

my munition does not extend ArrowItem.

No one mentioned extending ArrowItem.

 

18 hours ago, Drachenbauer said:

So it cannot find it

Yes, which is why I've told you like 3 times to

On 7/27/2019 at 7:37 AM, DavidM said:

Override BowItem#isArrow and return true if the given ItemStack is your custom ammo.

 

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Quote

Override BowItem#isArrow and return true if the given ItemStack is your custom ammo.

I cannot understend, how this will make it use my munition, if it still uses "ArrowItem" in it´s "onPlayerStoppedUsing"-method.

And i cannot find this method in the list, that i open with Strg + Space (what´s my common way to override stuff).

And i also cannot find this method in the classes "BowItem" and "ShootableItem"

 

Are you sure, that this is the way to do it in 1.14.3?

Edited by Drachenbauer
Link to comment
Share on other sites

My bad. It is called BowItem#getInventoryAmmoPredicate in 1.14.3.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

This i already have in my class and i created my own item group tag with json file, that i use there.

I declared a Predicate for ItemStack (like i found in the ShootebleItem-class) and placed the created item group tag in it:

    public static final Predicate<ItemStack> BIRD_SHOTS = (p_220002_0_) ->
    {
        return p_220002_0_.getItem().isIn(AngryBirdsItems.BIRD_SHOTS);
    }
    ;

And then i used it for the method, you sayd:

    public Predicate<ItemStack> getInventoryAmmoPredicate()
    {
        return BIRD_SHOTS;
    }

 

But i still don´t understand, how this should be able to work, if i remove my modifications in the "onPlayerStoppedUsing"-method.

As i sayd, it uses "ArrowItem" in muptiple positions in this method (where i have placed my own munition-item), and my munition-item does not extend ArrowItem.

I already noticed any time earlyer any where, that a java-code can only use a specific java-class, if it asks for the name of a class in the direct extension-line of the class to use.

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
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 had a similar issue to what you do above. Given this is an old post, you've probably sorted this now In my case, I had Java (JDK) 22 installed. After uninstalling that and installing 17.0.11 (having both installed gives the same error), then running the startserver.bat worked for me. I managed to get to the EULA section and then start my server correctly- I hope it helps anyone else who may have this issue!
    • Make a test with another Launcher like MultiMC, AT Launcher or Technic Launcher
    • I opened up Minecraft today for the first time in a month and whenever I try and play forge I get an error 1 message. I restarted my computer, tried reinstalling both Minecraft and Forge and have updated all of my drivers. Nothing seems to work so I'm stumped. I have absolutely no mods installed ATM so I have no idea what could be causing the problem. I hope yall are able to help.   DebugLog:   [19May2024 20:33:51.600] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, dmoy18, --version, 1.20.1-forge-47.2.0, --gameDir, C:\Users\dmoyf\AppData\Roaming\.minecraft, --assetsDir, C:\Users\dmoyf\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, c083972cd92d4dd2894beb25b82ebe82, --accessToken, ????????, --clientId, MDljMzIwMjYtOTJiNS00YWUxLTk1M2EtN2ExMGExZWM0MDAw, --xuid, 2535417310772497, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\dmoyf\AppData\Roaming\.minecraft\quickPlay\java\1716168829421.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [19May2024 20:33:51.604] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 11 arch amd64 version 10.0 [19May2024 20:33:51.634] [main/DEBUG] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Found launch services [fmlclientdev,forgeclient,minecraft,forgegametestserverdev,fmlserveruserdev,fmlclient,fmldatauserdev,forgeserverdev,forgeserveruserdev,forgeclientdev,forgeclientuserdev,forgeserver,forgedatadev,fmlserver,fmlclientuserdev,fmlserverdev,forgedatauserdev,testharness,forgegametestserveruserdev] [19May2024 20:33:51.653] [main/DEBUG] [cpw.mods.modlauncher.NameMappingServiceHandler/MODLAUNCHER]: Found naming services : [srgtomcp] [19May2024 20:33:51.668] [main/DEBUG] [cpw.mods.modlauncher.LaunchPluginHandler/MODLAUNCHER]: Found launch plugins: [mixin,eventbus,slf4jfixer,object_holder_definalize,runtime_enum_extender,capability_token_subclass,accesstransformer,runtimedistcleaner] [19May2024 20:33:51.681] [main/DEBUG] [cpw.mods.modlauncher.TransformationServicesHandler/MODLAUNCHER]: Discovering transformation services [19May2024 20:33:51.688] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path GAMEDIR is C:\Users\dmoyf\AppData\Roaming\.minecraft [19May2024 20:33:51.689] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path MODSDIR is C:\Users\dmoyf\AppData\Roaming\.minecraft\mods [19May2024 20:33:51.689] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path CONFIGDIR is C:\Users\dmoyf\AppData\Roaming\.minecraft\config [19May2024 20:33:51.689] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path FMLCONFIG is C:\Users\dmoyf\AppData\Roaming\.minecraft\config\fml.toml
  • Topics

×
×
  • Create New...

Important Information

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