Jump to content

Mobs getting hurt in blocks


Alesimula

Recommended Posts

How i said, my mobs are getting hurt in blocks, and when they do, they stay there till they die;

 

here is an example of my mobs

 

EntityRudolph

package net.minecraft.src;

 

import net.minecraft.entity.ai.EntityAIAttackOnCollide;

import net.minecraft.entity.ai.EntityAIBreakDoor;

import net.minecraft.entity.ai.EntityAIHurtByTarget;

import net.minecraft.entity.ai.EntityAILookIdle;

import net.minecraft.entity.ai.EntityAIMoveThroughVillage;

import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;

import net.minecraft.entity.ai.EntityAINearestAttackableTarget;

import net.minecraft.entity.ai.EntityAISwimming;

import net.minecraft.entity.ai.EntityAIWander;

import net.minecraft.entity.ai.EntityAIWatchClosest;

import net.minecraft.entity.ai.EntityAIFollowParent;

import net.minecraft.entity.ai.EntityAIMate;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.passive.EntityVillager;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import net.minecraft.entity.Entity;

import net.minecraft.util.DamageSource;

import net.minecraft.entity.passive.EntityVillager;

import net.minecraft.block.Block;

import net.minecraft.entity.EntityAgeable;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.pathfinding.PathEntity;

import net.minecraft.entity.EntityLivingData;

import net.minecraft.item.ItemFood;

import java.util.Random;

 

public class EntityRudolph extends EntityGlacialAnimal{

 

    public EntityRudolph(World var1)

    {

        super(var1);

this.getNavigator().setAvoidsWater(true);

        this.tasks.addTask(0, new EntityAISwimming(this));

        this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D));

        this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, 1.0D, false));

        this.tasks.addTask(6, new EntityAIWander(this, 1.0D));

        this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

        this.tasks.addTask(7, new EntityAILookIdle(this));

this.tasks.addTask(2, new EntityAIMate(this, 1.0D));

        this.tasks.addTask(4, new EntityAIFollowParent(this, 1.0D));

        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));

this.setSize(2F, 0.6F);

    }

 

public boolean isAIEnabled()

    {

        return true;

    }

 

public boolean isChild()

    {

        return this.getGrowingAge() < 0;

    }

   

    //PERKS

  protected void func_110147_ax()

  {

  super.func_110147_ax();

  // HEALTH - default 20.0D - min 0.0D - max Double.MAX_VALUE

  this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(20.0D);

  // KNOCKBACK RESISTANCE - default 0.0D - min 0.0D - max 1.0D

  this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111128_a(0.0D);

  // SPEED - default 0.699D - min 0.0D - max Double.MAX_VALUE

  this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(1.0D);

  }

 

public static Random Rgender =new Random();

 

//GENDER (0=MALE; 1=FEMALE)

public int gender = Rgender.nextInt(2-0) + 0;

 

    /**

    * Drop 0-2 items of this living's type

    */

    protected void dropFewItems(boolean var1, int var2)

    {

        this.entityDropItem(new ItemStack(mod_Glacia.SaberToothedCatMeat.itemID, 1, 0), 0.0F);

    }

 

    /**

    * Returns the sound this mob makes while it's alive.

    */

    public String getLivingSound()

    {

        return "";

    }

 

    /**

    * Returns the sound this mob makes when it is hurt.

    */

    public String getHurtSound()

    {

        return "";

    }

 

    /**

    * Returns the sound this mob makes on death.

    */

    public String getDeathSound()

    {

        return "";

    }

 

    /**

    * Determines if an entity can be despawned, used on idle far away entities

    */

    protected boolean canDespawn()

    {

        return false;

    }

 

public EntityAgeable createChild(EntityAgeable par1EntityAgeable)

    {

        return this.spawnBabyAnimal(par1EntityAgeable);

    }

 

public EntityRudolph spawnBabyAnimal(EntityAgeable par1EntityAgeable)

    {

        return new EntityRudolph(this.worldObj);

    }

 

public EntityLivingData func_110161_a(EntityLivingData par1EntityLivingData)

    {

        par1EntityLivingData = super.func_110161_a(par1EntityLivingData);

 

        if (this.worldObj.rand.nextInt(7) == 0)

        {

            for (int i = 0; i < 2; ++i)

            {

                EntityRudolph entityrudolph = new EntityRudolph(this.worldObj);

                entityrudolph.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);

                entityrudolph.setGrowingAge(-24000);

                this.worldObj.spawnEntityInWorld(entityrudolph);

            }

        }

 

        return par1EntityLivingData;

    }

}

 

RenderRudolph

package net.minecraft.src;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.model.ModelBase;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLiving;

import net.minecraft.entity.passive.EntitySheep;

import net.minecraft.entity.passive.EntityWolf;

import net.minecraft.util.ResourceLocation;

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

import net.minecraft.entity.EntityLivingBase;

import org.lwjgl.opengl.GL11;

 

@SideOnly(Side.CLIENT)

public class RenderRudolph extends RenderLiving

{

public static final ResourceLocation RainDeer = new ResourceLocation("textures/entity/Glacia/Rudolph.png");

 

    public RenderRudolph(ModelBase par1ModelBase, float par3)

    {

        super(par1ModelBase, par3);

    }

 

    protected ResourceLocation func_110856_a(EntityLiving par1EntityLiving)

    {

        return RainDeer;

    }

 

    protected ResourceLocation func_110775_a(Entity par1Entity)

    {

        return this.func_110856_a((EntityLiving)par1Entity);

    }

}

 

 

ModelRudolph

package net.minecraft.src;

 

import net.minecraft.util.MathHelper;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.entity.Entity;

import java.util.Random;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.client.model.ModelBase;

import org.lwjgl.opengl.GL11;

 

public class ModelRudolph extends ModelBase

{

  //fields

  public ModelRenderer BodyMale;

  public ModelRenderer Neck;

  public ModelRenderer Head;

  public ModelRenderer Head2;

  public ModelRenderer Nose;

  public ModelRenderer Corn;

  public ModelRenderer Corn2;

  public ModelRenderer Tail;

  public ModelRenderer Corn3;

  public ModelRenderer Corn4;

  public ModelRenderer Leg1;

  public ModelRenderer Foot1p1;

  public ModelRenderer Foot1p2;

  public ModelRenderer Foot1p3;

  public ModelRenderer Leg2;

  public ModelRenderer Foot2p1;

  public ModelRenderer Foot2p2;

  public ModelRenderer Leg3;

  public ModelRenderer Leg4;

  public ModelRenderer Foot3p1;

  public ModelRenderer Foot2p3;

  public ModelRenderer Foot3p2;

  public ModelRenderer Foot3p3;

  public ModelRenderer Foot4p1;

  public ModelRenderer Foot4p2;

  public ModelRenderer Foot4p3;

  public ModelRenderer Ear1;

  public ModelRenderer Ear2;

  public ModelRenderer Corn5;

  public ModelRenderer Corn6;

  public ModelRenderer BodyFemale;

 

  public ModelRudolph()

  {

    textureWidth = 64;

    textureHeight = 64;

   

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

      BodyMale.addBox(0F, 0F, 0F, 8, 5, 15);

      BodyMale.setRotationPoint(-4F, 10F, -8F);

      BodyMale.setTextureSize(64, 64);

      BodyMale.mirror = true;

      setRotation(BodyMale, 0F, 0F, 0F);

      Neck = new ModelRenderer(this, 20, 20);

      Neck.addBox(0F, 0F, 0F, 4, 7, 4);

      Neck.setRotationPoint(-2F, 5F, -8.5F);

      Neck.setTextureSize(64, 64);

      Neck.mirror = true;

      setRotation(Neck, 0F, 0F, 0F);

      Head = new ModelRenderer(this, 0, 20);

      Head.addBox(0F, 0F, 0F, 5, 4, 5);

      Head.setRotationPoint(-2.5F, 2F, -9.4F);

      Head.setTextureSize(64, 64);

      Head.mirror = true;

      setRotation(Head, 0F, 0F, 0F);

      Head2 = new ModelRenderer(this, 36, 20);

      Head2.addBox(0F, 0F, 0F, 3, 2, 2);

      Head2.setRotationPoint(-1.5F, 3.9F, -11F);

      Head2.setTextureSize(64, 64);

      Head2.mirror = true;

      setRotation(Head2, 0F, 0F, 0F);

      Nose = new ModelRenderer(this, 39, 24);

      Nose.addBox(0F, 0F, 0F, 1, 1, 1);

      Nose.setRotationPoint(-0.5F, 3.8F, -11.5F);

      Nose.setTextureSize(64, 64);

      Nose.mirror = true;

      setRotation(Nose, 0F, 0F, 0F);

      Corn = new ModelRenderer(this, 46, 20);

      Corn.addBox(0F, 0F, 0F, 1, 8, 1);

      Corn.setRotationPoint(-3F, -4F, -6.5F);

      Corn.setTextureSize(64, 64);

      Corn.mirror = true;

      setRotation(Corn, 0F, 0.6320361F, -0.1289891F);

      Corn2 = new ModelRenderer(this, 46, 20);

      Corn2.addBox(0F, 0F, 0F, 1, 8, 1);

      Corn2.setRotationPoint(2F, -4F, -7.1F);

      Corn2.setTextureSize(64, 64);

      Corn2.mirror = true;

      setRotation(Corn2, 0F, -0.642054F, 0.1289973F);

  Tail = new ModelRenderer(this, 54, 0);

      Tail.addBox(0F, -0.5F, -1F, 1, 2, 2);

      Tail.setRotationPoint(0F, 11F, 7F);

      Tail.setTextureSize(64, 64);

      Tail.mirror = true;

      setRotation(Tail, 0F, 1.570796F, 3.149738F);

      Corn3 = new ModelRenderer(this, 44, 29);

      Corn3.addBox(0F, 0F, 0F, 3, 1, 1);

      Corn3.setRotationPoint(-4.9F, -3F, -5.7F);

      Corn3.setTextureSize(64, 64);

      Corn3.mirror = true;

      setRotation(Corn3, 0F, 0.4014257F, 0.3141593F);

      Corn4 = new ModelRenderer(this, 44, 29);

      Corn4.addBox(0F, 0F, 0F, 3, 1, 1);

      Corn4.setRotationPoint(1.8F, -2F, -7F);

      Corn4.setTextureSize(64, 64);

      Corn4.mirror = true;

      setRotation(Corn4, 0F, -0.4014257F, -0.2792527F);

      Foot1p1 = new ModelRenderer(this, 54, 13);

      Foot1p1.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot1p1.setRotationPoint(-0.5F, 8F, -0.3F);

      Foot1p1.setTextureSize(64, 64);

      Foot1p1.mirror = true;

      setRotation(Foot1p1, 0F, 0.1745329F, 0F);

      Foot1p2 = new ModelRenderer(this, 46, 13);

      Foot1p2.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot1p2.setRotationPoint(1.5F, 8F, -0.5F);

      Foot1p2.setTextureSize(64, 64);

      Foot1p2.mirror = true;

      setRotation(Foot1p2, 0F, -0.1745329F, 0F);

      Foot1p3 = new ModelRenderer(this, 51, 18);

      Foot1p3.addBox(0F, 0F, 0F, 2, 2, 1);

      Foot1p3.setRotationPoint(0F, 8F, 1.6F);

      Foot1p3.setTextureSize(64, 64);

      Foot1p3.mirror = true;

      setRotation(Foot1p3, 0F, 0F, 0F);

      Foot2p1 = new ModelRenderer(this, 46, 13);

      Foot2p1.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot2p1.setRotationPoint(1.5F, 8F, -0.5F);

      Foot2p1.setTextureSize(64, 64);

      Foot2p1.mirror = true;

      setRotation(Foot2p1, 0F, -0.1745329F, 0F);

      Foot2p2 = new ModelRenderer(this, 51, 18);

      Foot2p2.addBox(0F, 0F, 0F, 2, 2, 1);

      Foot2p2.setRotationPoint(0F, 8F, 1.6F);

      Foot2p2.setTextureSize(64, 64);

      Foot2p2.mirror = true;

      setRotation(Foot2p2, 0F, 0F, 0F);

      Foot3p1 = new ModelRenderer(this, 46, 13);

      Foot3p1.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot3p1.setRotationPoint(1.5F, 8F, -0.5F);

      Foot3p1.setTextureSize(64, 64);

      Foot3p1.mirror = true;

      setRotation(Foot3p1, 0F, -0.1745329F, 0F);

      Foot2p3 = new ModelRenderer(this, 54, 13);

      Foot2p3.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot2p3.setRotationPoint(-0.5F, 8F, -0.3F);

      Foot2p3.setTextureSize(64, 64);

      Foot2p3.mirror = true;

      setRotation(Foot2p3, 0F, 0.1745329F, 0F);

      Foot3p2 = new ModelRenderer(this, 54, 13);

      Foot3p2.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot3p2.setRotationPoint(-0.5F, 8F, -0.3F);

      Foot3p2.setTextureSize(64, 64);

      Foot3p2.mirror = true;

      setRotation(Foot3p2, 0F, 0.1745329F, 0F);

      Foot3p3 = new ModelRenderer(this, 51, 18);

      Foot3p3.addBox(0F, 0F, 0F, 2, 2, 1);

      Foot3p3.setRotationPoint(0F, 8F, 1.6F);

      Foot3p3.setTextureSize(64, 64);

      Foot3p3.mirror = true;

      setRotation(Foot3p3, 0F, 0F, 0F);

      Foot4p1 = new ModelRenderer(this, 46, 13);

      Foot4p1.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot4p1.setRotationPoint(1.5F, 8F, -0.5F);

      Foot4p1.setTextureSize(64, 64);

      Foot4p1.mirror = true;

      setRotation(Foot4p1, 0F, -0.1745329F, 0F);

      Foot4p2 = new ModelRenderer(this, 54, 13);

      Foot4p2.addBox(0F, 0F, 0F, 1, 2, 3);

      Foot4p2.setRotationPoint(-0.5F, 8F, -0.3F);

      Foot4p2.setTextureSize(64, 64);

      Foot4p2.mirror = true;

      setRotation(Foot4p2, 0F, 0.1745329F, 0F);

      Foot4p3 = new ModelRenderer(this, 51, 18);

      Foot4p3.addBox(0F, 0F, 0F, 2, 2, 1);

      Foot4p3.setRotationPoint(0F, 8F, 1.6F);

      Foot4p3.setTextureSize(64, 64);

      Foot4p3.mirror = true;

      setRotation(Foot4p3, 0F, 0F, 0F);

      Ear1 = new ModelRenderer(this, 36, 26);

      Ear1.addBox(0F, 0F, 0F, 1, 2, 1);

      Ear1.setRotationPoint(-2.6F, 1.1F, -5.5F);

      Ear1.setTextureSize(64, 64);

      Ear1.mirror = true;

      setRotation(Ear1, -0.2602503F, 0F, 0F);

      Ear2 = new ModelRenderer(this, 42, 26);

      Ear2.addBox(0F, 0F, 0F, 1, 2, 1);

      Ear2.setRotationPoint(1.6F, 1.1F, -5.5F);

      Ear2.setTextureSize(64, 64);

      Ear2.mirror = true;

      setRotation(Ear2, -0.2602503F, 0F, 0F);

  Leg1 = new ModelRenderer(this, 46, 0);

      Leg1.addBox(0F, 0F, 0F, 2, 10, 2);

      Leg1.setRotationPoint(1.5F, 14F, -7.5F);

      Leg1.setTextureSize(64, 64);

      Leg1.mirror = true;

  Leg1.addChild(Foot1p1);

  Leg1.addChild(Foot1p2);

  Leg1.addChild(Foot1p3);

      setRotation(Leg1, 0F, 0F, 0F);

  Leg2 = new ModelRenderer(this, 46, 0);

      Leg2.addBox(0F, 0F, 0F, 2, 10, 2);

      Leg2.setRotationPoint(-3.5F, 14F, -7.5F);

      Leg2.setTextureSize(64, 64);

      Leg2.mirror = true;

  Leg2.addChild(Foot2p1);

  Leg2.addChild(Foot2p2);

  Leg2.addChild(Foot2p3);

      setRotation(Leg2, 0F, 0F, 0F);

  Leg3 = new ModelRenderer(this, 46, 0);

      Leg3.addBox(0F, 0F, 0F, 2, 10, 2);

      Leg3.setRotationPoint(1.5F, 14F, 4.5F);

      Leg3.setTextureSize(64, 64);

      Leg3.mirror = true;

  Leg3.addChild(Foot3p1);

  Leg3.addChild(Foot3p2);

  Leg3.addChild(Foot3p3);

      setRotation(Leg3, 0F, 0F, 0F);

      Leg4 = new ModelRenderer(this, 46, 0);

      Leg4.addBox(0F, 0F, 0F, 2, 10, 2);

      Leg4.setRotationPoint(-3.5F, 14F, 4.5F);

      Leg4.setTextureSize(64, 64);

      Leg4.mirror = true;

  Leg4.addChild(Foot4p1);

  Leg4.addChild(Foot4p2);

  Leg4.addChild(Foot4p3);

      setRotation(Leg4, 0F, 0F, 0F);

  Corn5 = new ModelRenderer(this, 46, 20);

      Corn5.addBox(0F, 0F, 0F, 1, 1, 1);

      Corn5.setRotationPoint(-2F, 1.5F, -7F);

      Corn5.setTextureSize(64, 64);

      Corn5.mirror = true;

      setRotation(Corn5, 0F, 0F, 0F);

      Corn6 = new ModelRenderer(this, 46, 20);

      Corn6.addBox(0F, 0F, 0F, 1, 1, 1);

      Corn6.setRotationPoint(1F, 1.5F, -7F);

      Corn6.setTextureSize(64, 64);

      Corn6.mirror = true;

      setRotation(Corn6, 0F, 0F, 0F);

  BodyFemale = new ModelRenderer(this, 0, 31);

      BodyFemale.addBox(0F, 0F, 0F, 8, 5, 15);

      BodyFemale.setRotationPoint(-4F, 10F, -8F);

      BodyFemale.setTextureSize(64, 64);

      BodyFemale.mirror = true;

      setRotation(BodyFemale, 0F, 0F, 0F);

  }

 

  public static Random Rgender =new Random();

  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)

  {

EntityRudolph entityraindeer = (EntityRudolph)entity;

int randgender = Rgender.nextInt(2-0) + 0;

 

if (this.isChild)

    {

if (entityraindeer.gender == 0)

{

super.render(entity, f, f1, f2, f3, f4, f5);

setRotationAngles(f, f1, f2, f3, f4, f5);

float f6 = 2.0F;

GL11.glPushMatrix();

GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);

GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);

Neck.render(f5);

Head.render(f5);

Head2.render(f5);

Nose.render(f5);

Ear1.render(f5);

Ear2.render(f5);

BodyMale.render(f5);

Tail.render(f5);

Leg1.render(f5);

Leg2.render(f5);

Leg3.render(f5);

Leg4.render(f5);

GL11.glPopMatrix();

}

else

{

super.render(entity, f, f1, f2, f3, f4, f5);

setRotationAngles(f, f1, f2, f3, f4, f5);

float f6 = 2.0F;

GL11.glPushMatrix();

GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6);

GL11.glTranslatef(0.0F, 24.0F * f5, 0.0F);

Neck.render(f5);

Head.render(f5);

Head2.render(f5);

Nose.render(f5);

Ear1.render(f5);

Ear2.render(f5);

BodyFemale.render(f5);

Tail.render(f5);

Leg1.render(f5);

Leg2.render(f5);

Leg3.render(f5);

Leg4.render(f5);

GL11.glPopMatrix();

}

    }

    else

{

if (entityraindeer.gender == 0)

{

super.render(entity, f, f1, f2, f3, f4, f5);

setRotationAngles(f, f1, f2, f3, f4, f5);

BodyMale.render(f5);

Neck.render(f5);

Head.render(f5);

Head2.render(f5);

Nose.render(f5);

Corn.render(f5);

Corn2.render(f5);

Tail.render(f5);

Corn3.render(f5);

Corn4.render(f5);

Ear1.render(f5);

Ear2.render(f5);

Leg1.render(f5);

Leg2.render(f5);

Leg3.render(f5);

Leg4.render(f5);

}

else

{

super.render(entity, f, f1, f2, f3, f4, f5);

setRotationAngles(f, f1, f2, f3, f4, f5);

BodyFemale.render(f5);

Neck.render(f5);

Head.render(f5);

Head2.render(f5);

Nose.render(f5);

Corn5.render(f5);

Corn6.render(f5);

Tail.render(f5);

Ear1.render(f5);

Ear2.render(f5);

Leg1.render(f5);

Leg2.render(f5);

Leg3.render(f5);

Leg4.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);

this.Leg1.rotateAngleX = MathHelper.cos(f * 0.7F) * 1.0F * f1;

this.Leg2.rotateAngleX = MathHelper.cos(f * 0.7F + (float)Math.PI) * 1.0F * f1;

this.Leg3.rotateAngleX = MathHelper.cos(f * 0.7F) * 1.0F * f1;

this.Leg4.rotateAngleX = MathHelper.cos(f * 0.7F + (float)Math.PI) * 1.0F * f1;

this.Tail.rotateAngleX = MathHelper.cos(f * 0.7F + (float)Math.PI) * 1.0F * f1;

  }

 

}

 

Actually i don't know what to write in this signature soooo.... anyway

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
  • Topics

×
×
  • Create New...

Important Information

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