Jump to content

[1.7.10] [SOLVED] Attempting to Change Vanilla Animal Models


Recommended Posts

Posted

Hello! I just joined the forums. Nice to meet you all. c:

 

I have just gotten started on this project, and as I'm fairly new to Minecraft modding am running into quite a few kinks. One of the suggestions were to override the entity renderer hashmap with the model that I wanted to use.

 

However, I am getting this crash log, and I... don't even know where to begin with it, to be honest.

 

 

---- Minecraft Crash Report ----

 

// On the bright side, I bought you a teddy bear!

 

Time: 11/12/14 3:28 PM

Description: Initializing game

 

java.lang.NullPointerException: Initializing game

at ruirui.minecraft.livelyanimals.LAModelPig.<init>(LAModelPig.java:93)

at ruirui.minecraft.livelyanimals.LivelyAnimals.swapModels(LivelyAnimals.java:32)

at ruirui.minecraft.livelyanimals.LivelyAnimals.init(LivelyAnimals.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586)

at net.minecraft.client.Minecraft.run(Minecraft.java:931)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at GradleStart.bounce(GradleStart.java:107)

at GradleStart.startClient(GradleStart.java:100)

at GradleStart.main(GradleStart.java:55)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at ruirui.minecraft.livelyanimals.LAModelPig.<init>(LAModelPig.java:93)

at ruirui.minecraft.livelyanimals.LivelyAnimals.swapModels(LivelyAnimals.java:32)

at ruirui.minecraft.livelyanimals.LivelyAnimals.init(LivelyAnimals.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:586)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.run(Minecraft.java:931)

at net.minecraft.client.main.Main.main(Main.java:164)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at GradleStart.bounce(GradleStart.java:107)

at GradleStart.startClient(GradleStart.java:100)

at GradleStart.main(GradleStart.java:55)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_55, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 210489192 bytes (200 MB) / 338690048 bytes (323 MB) up to 1882718208 bytes (1795 MB)

JVM Flags: 0 total;

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.05 FML v7.10.85.1232 Minecraft Forge 10.13.2.1232 4 mods loaded, 4 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized

FML{7.10.85.1232} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1232.jar) Unloaded->Constructed->Pre-initialized->Initialized

Forge{10.13.2.1232} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1232.jar) Unloaded->Constructed->Pre-initialized->Initialized

Constants.MODID{Constants.VERSION} [Constants.MODNAME] (bin) Unloaded->Constructed->Pre-initialized->Errored

Launched Version: 1.7.10

LWJGL: 2.9.1

OpenGL: Intel® HD Graphics 4600 GL version 4.0.0 - Build 9.18.10.3071, Intel

GL Caps: Using GL 1.3 multitexturing.

Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

Anisotropic filtering is supported and maximum anisotropy is 16.

Shaders are available because OpenGL 2.1 is supported.

 

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Anisotropic Filtering: Off (1)

 

 

Here are my classes so far:

main:

 

package ruirui.minecraft.livelyanimals;

 

import net.minecraft.client.renderer.entity.RenderPig;

import net.minecraft.entity.passive.EntityPig;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.client.registry.RenderingRegistry;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

 

@Mod(modid = "Constants.MODID", name = "Constants.MODNAME", version = "Constants.VERSION")

public class LivelyAnimals {

 

@Mod.EventHandler

public void preInit(FMLPreInitializationEvent event){

 

}

 

@Mod.EventHandler

public void init(FMLInitializationEvent event){

MinecraftForge.EVENT_BUS.register(this);

swapModels();

}

 

@Mod.EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

public void swapModels() {

RenderingRegistry.registerEntityRenderingHandler(EntityPig.class, new RenderPig(new LAModelPig(), new LAModelPig(), 0.8F));

}

 

}

 

 

LAModelPig:

 

package ruirui.minecraft.livelyanimals;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class LAModelPig extends ModelBase

{

  //fields

    ModelRenderer body;

    ModelRenderer FRleg_top;

    ModelRenderer FRleg_bot;

    ModelRenderer FLleg_top;

    ModelRenderer FLleg_bot;

    ModelRenderer BRleg_top;

    ModelRenderer BRleg_bot;

    ModelRenderer BLleg_top;

    ModelRenderer BLleg_bot;

    ModelRenderer belly;

    ModelRenderer tail_base;

    ModelRenderer tail_tip;

    ModelRenderer main;

    ModelRenderer R_ear;

    ModelRenderer L_ear;

    ModelRenderer snout_top;

    ModelRenderer snout_bot;

 

  public LAModelPig()

  {

    textureWidth = 64;

    textureHeight = 64;

   

      body = new ModelRenderer(this, 0, 0);

      body.addBox(-5F, -10F, -7F, 10, 18, 10);

      body.setRotationPoint(0F, 11F, 3F);

      body.setTextureSize(64, 64);

      body.mirror = true;

      setRotation(body, 1.570796F, 0F, 0F);

      FRleg_top = new ModelRenderer(this, 40, 0);

      FRleg_top.addBox(-1.5F, 0F, -1.5F, 3, 6, 3);

      FRleg_top.setRotationPoint(-2.5F, 15F, -4.5F);

      FRleg_top.setTextureSize(64, 64);

      FRleg_top.mirror = true;

      setRotation(FRleg_top, 0F, 0F, 0F);

      FRleg_bot = new ModelRenderer(this, 40, 9);

      FRleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);

      FRleg_bot.setRotationPoint(-2.5F, 21F, -4.5F);

      FRleg_bot.setTextureSize(64, 64);

      FRleg_bot.mirror = true;

      setRotation(FRleg_bot, 0F, 0F, 0F);

      FLleg_top = new ModelRenderer(this, 40, 0);

      FLleg_top.addBox(-1.5F, 0F, -1.5F, 3, 6, 3);

      FLleg_top.setRotationPoint(2.5F, 15F, -4.5F);

      FLleg_top.setTextureSize(64, 64);

      FLleg_top.mirror = true;

      setRotation(FLleg_top, 0F, 0F, 0F);

      FLleg_bot = new ModelRenderer(this, 40, 9);

      FLleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);

      FLleg_bot.setRotationPoint(2.5F, 21F, -4.5F);

      FLleg_bot.setTextureSize(64, 64);

      FLleg_bot.mirror = true;

      setRotation(FLleg_bot, 0F, 0F, 0F);

      BRleg_top = new ModelRenderer(this, 40, 0);

      BRleg_top.addBox(-1.5F, 0F, -1.5F, 3, 6, 3);

      BRleg_top.setRotationPoint(-2.5F, 15F, 9F);

      BRleg_top.setTextureSize(64, 64);

      BRleg_top.mirror = true;

      setRotation(BRleg_top, 0F, 0F, 0F);

      BRleg_bot = new ModelRenderer(this, 40, 9);

      BRleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);

      BRleg_bot.setRotationPoint(-2.5F, 21F, 9F);

      BRleg_bot.setTextureSize(64, 64);

      BRleg_bot.mirror = true;

      setRotation(BRleg_bot, 0F, 0F, 0F);

      BLleg_top = new ModelRenderer(this, 40, 0);

      BLleg_top.addBox(-1.5F, 0F, -1.5F, 3, 6, 3);

      BLleg_top.setRotationPoint(2.473333F, 15F, 9F);

      BLleg_top.setTextureSize(64, 64);

      BLleg_top.mirror = true;

      setRotation(BLleg_top, 0F, 0F, 0F);

      BLleg_bot = new ModelRenderer(this, 40, 9);

      BLleg_bot.addBox(-1.5F, 0F, -1.5F, 3, 3, 3);

      BLleg_bot.setRotationPoint(2.5F, 21F, 9F);

      BLleg_bot.setTextureSize(64, 64);

      BLleg_bot.mirror = true;

      setRotation(BLleg_bot, 0F, 0F, 0F);

      belly = new ModelRenderer(this, 40, 15);

      belly.addBox(-3F, -4.5F, -1F, 6, 10, 3);

      belly.setRotationPoint(0F, 18F, 1.75F);

      belly.setTextureSize(64, 64);

      belly.mirror = true;

      setRotation(belly, 1.570796F, 0F, 0F);

      tail_base.mirror = true;

      tail_base = new ModelRenderer(this, 18, 44);

      tail_base.addBox(-0.5F, -0.5F, 0F, 1, 1, 3);

      tail_base.setRotationPoint(0F, 10F, 10.5F);

      tail_base.setTextureSize(64, 64);

      tail_base.mirror = true;

      setRotation(tail_base, -1.020656F, 0F, 0F);

      tail_base.mirror = false;

      tail_tip = new ModelRenderer(this, 18, 48);

      tail_tip.addBox(-0.5F, -0.5F, 0F, 1, 1, 3);

      tail_tip.setRotationPoint(0F, 12F, 12F);

      tail_tip.setTextureSize(64, 64);

      tail_tip.mirror = true;

      setRotation(tail_tip, -1.347828F, 0F, 0F);

      main = new ModelRenderer(this, 0, 28);

      main.addBox(-4F, -4F, -8F, 8, 8, 8);

      main.setRotationPoint(0F, 14F, -6F);

      main.setTextureSize(64, 64);

      main.mirror = true;

      setRotation(main, 0F, 0F, 0F);

      R_ear = new ModelRenderer(this, 32, 28);

      R_ear.addBox(-4F, -0.5F, 0F, 4, 1, 6);

      R_ear.setRotationPoint(-3F, 9F, -13F);

      R_ear.setTextureSize(64, 64);

      R_ear.mirror = true;

      setRotation(R_ear, 0.4758862F, -3.004032F, -2.379431F);

      L_ear = new ModelRenderer(this, 32, 28);

      L_ear.addBox(0F, -0.5F, 0F, 4, 1, 6);

      L_ear.setRotationPoint(3F, 9F, -13F);

      L_ear.setTextureSize(64, 64);

      L_ear.mirror = true;

      setRotation(L_ear, -2.617374F, -0.2082002F, 0.781577F);

      snout_top = new ModelRenderer(this, 0, 44);

      snout_top.addBox(-2.5F, -1.5F, -4F, 5, 3, 4);

      snout_top.setRotationPoint(0F, 15F, -14F);

      snout_top.setTextureSize(64, 64);

      snout_top.mirror = true;

      setRotation(snout_top, 0F, 0F, 0F);

      snout_bot = new ModelRenderer(this, 0, 51);

      snout_bot.addBox(-2.5F, 0F, -4F, 5, 1, 4);

      snout_bot.setRotationPoint(0F, 16.5F, -14F);

      snout_bot.setTextureSize(64, 64);

      snout_bot.mirror = true;

      setRotation(snout_bot, 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, null);

    body.render(f5);

    FRleg_top.render(f5);

    FRleg_bot.render(f5);

    FLleg_top.render(f5);

    FLleg_bot.render(f5);

    BRleg_top.render(f5);

    BRleg_bot.render(f5);

    BLleg_top.render(f5);

    BLleg_bot.render(f5);

    belly.render(f5);

    tail_base.render(f5);

    tail_tip.render(f5);

    main.render(f5);

    R_ear.render(f5);

    L_ear.render(f5);

    snout_top.render(f5);

    snout_bot.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, Entity entity)

  {

    super.setRotationAngles(f, f1, f2, f3, f4, f5, null);

  }

 

}

 

 

Thank you for your time and help!

Posted

Wow, I'm pretty surprised at how simple a change that was! How did you find that bug, if you don't mind me asking? Was it just by looking through the Model base that I made? Because I can't seem to find it in the crash log at all.

Posted

That bug has been in Techne a long time now, so we know where to look if there's a NPE in the model class.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

I see! Gotcha.

 

Also I don't want to spam up the forums, so can I get help on something unrelated? For some reason, my mcmod.info file refuses to work.

 

I have a screenshot of the file and my mod setup here.

 

Also made the silly mistake of putting my constants as string literals rather than fields of a class, but upon taking out the parentheses, my main class is unable to find the Constants class.

 

Here is how the file shows up on the console (before I took out the parentheses):

2utgo4j.png

 

And here is my (very short) Constants class from my lib folder:

 

package ruirui.minecraft.livelyanimals.lib;

 

public class Constants {

public static final String MODID = "livelyanimals";

public static final String MODNAME = "Lively Animals";

public static final String VERSION = "0.1";

}

 

 

Posted

Well, your mod setup is kinda weird. You have

java

and

resources

source folders, but they need to be

src/main/java

and

src/main/resources

. Maybe that's what's wrong.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Do you have a @Mod tag in your main mod file?

I have a similar working setup as following:

@Mod(modid = Constants.MODID, name = Constants.NAME, version = Constants.VERSION)

 

Also, is your mod in a different java project? Because I see that you got a Minecraft project AND a "LivelyAnimals" project that your files are located in.

 

Try moving the java files into the Minecraft project under "src/main/java" and the mcmod.info to "src/main/resources" (As noted by Iarsgerrits)

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Posted

Moved the files as suggested, but it still does not work unfortunately. :/

 

Oh Eclipse, you are a piece of work. I took out my files and then did refresh-dependencies to see if I could fix it that way, and now the only thing that shows up in the workspace is HerdCraft and when I go to add existing projects into the workspace, it says "No projects are found to import".

Posted

Okay, whatever. mcmod.info is pretty much the least important part of the mod anyway.

 

New problem: Can't seem to find my texture.

 

LARenderPig (same as RenderPig, just with the texture locations swapped)

 

package ruirui.minecraft.livelyanimals;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.renderer.entity.RenderLiving;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.passive.EntityPig;

import net.minecraft.util.ResourceLocation;

 

@SideOnly(Side.CLIENT)

public class LARenderPig extends RenderLiving

{

    private static final ResourceLocation saddledPigTextures = new ResourceLocation(LivelyAnimals.AID, "textures/animals/LAPig.png");

    private static final ResourceLocation pigTextures = new ResourceLocation("textures/animals/LAPig.png");

    private static final String __OBFID = "CL_00001019";

 

    public LARenderPig(ModelBase p_i1265_1_, ModelBase p_i1265_2_, float p_i1265_3_)

    {

        super(p_i1265_1_, p_i1265_3_);

        this.setRenderPassModel(p_i1265_2_);

    }

 

    /**

    * Queries whether should render the specified pass or not.

    */

    protected int shouldRenderPass(EntityPig p_77032_1_, int p_77032_2_, float p_77032_3_)

    {

        if (p_77032_2_ == 0 && p_77032_1_.getSaddled())

        {

            this.bindTexture(saddledPigTextures);

            return 1;

        }

        else

        {

            return -1;

        }

    }

 

    /**

    * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.

    */

    protected ResourceLocation getEntityTexture(EntityPig p_110775_1_)

    {

        return pigTextures;

    }

 

    /**

    * Queries whether should render the specified pass or not.

    */

    protected int shouldRenderPass(EntityLivingBase p_77032_1_, int p_77032_2_, float p_77032_3_)

    {

        return this.shouldRenderPass((EntityPig)p_77032_1_, p_77032_2_, p_77032_3_);

    }

 

    /**

    * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.

    */

    protected ResourceLocation getEntityTexture(Entity p_110775_1_)

    {

        return this.getEntityTexture((EntityPig)p_110775_1_);

    }

}

 

 

Folder layout:

ws79so.png

 

I've also tried "assets/textures/animals/LAPig.png" and "ruirui/assets/textures/animals/LAPig.png". LivelyAnimals.AID is just "livelyanimals".

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

    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
    • Okay, but does the modpack works with 1.12 or just with 1.12.2, because I need the Forge client specifically for Minecraft 1.12, not 1.12.2
    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
  • Topics

×
×
  • Create New...

Important Information

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