Jump to content

Making an entity as a light source


Asweez

Recommended Posts

Is there any way to have an entity that emits light (no I don't mean like getBrightness)? Kind of like a moving glowstone? I know lightning does something like that but I don't know if that is what I'm looking for. Any ideas?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

What kind of entity are you talking about? and item entity, living entity, ect??? I do have some code I could explain to you for  a living entity.

 

Also, what version are you doing this in?

 

1.7.10

It is a throwable entity but any code would help :)

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

what this does is it takes the location of your entity and sets the light of that block to 16 (with code as is) you can change this by changing the 16 to whatever you want the light level to be.

private void addLight() {
	this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ, 16);
	this.worldObj.markBlockRangeForRenderUpdate((int) this.posX,
			(int) this.posY, (int) this.posX, 12, 12, 12);
	this.worldObj.markBlockForUpdate((int) this.posX, (int) this.posY,
			(int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY + 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY - 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX + 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX - 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ + 1);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ - 1);
}

 

to call on it put this in your LivingUpdate method:

addLight();

 

also add this to the very end of your LivingUpdate to remove the light when you remove the entity

if (this.isDead) {
this.worldObj.updateLightByType(EnumSkyBlock.Block,
		(int) this.posX, (int) this.posY, (int) this.posZ);
}

this will force the block to update its light to where it should be.

Link to comment
Share on other sites

what this does is it takes the location of your entity and sets the light of that block to 16 (with code as is) you can change this by changing the 16 to whatever you want the light level to be.

private void addLight() {
	this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ, 16);
	this.worldObj.markBlockRangeForRenderUpdate((int) this.posX,
			(int) this.posY, (int) this.posX, 12, 12, 12);
	this.worldObj.markBlockForUpdate((int) this.posX, (int) this.posY,
			(int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY + 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY - 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX + 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX - 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ + 1);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ - 1);
}

 

to call on it put this in your LivingUpdate method:

addLight();

 

also add this to the very end of your LivingUpdate to remove the light when you remove the entity

if (this.isDead) {
this.worldObj.updateLightByType(EnumSkyBlock.Block,
		(int) this.posX, (int) this.posY, (int) this.posZ);
}

this will force the block to update its light to where it should be.

Thanks! This is along the lines of what I had, I just couldn't quite get there. Could you explain what the update light by type does?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

it tells the block to update its light level based on the light level of blocks around it and the sky. for in the addLight() method, it updates the blocks around the block the entity is in to cause the light to reach out until it is at its limits. the call when the entity is dead causes the source block to check its light level based on the sky and block light sources, therefore causing it to reset.

 

to explain the code in detail

 

this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ, 16);

 

you should know what this.worldObj is. EnumSkyBlock.Block tell the server what type of light you are modifying, in this case, you are modifying block light. You really shouldn't need to change sky light because that will effect the whole world. (int) this.posX + 1, (int) this.posY, (int) this.posZ is the block position relative to the entity. 16 is the light level you are setting the block to.

 

this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX + 1, (int) this.posY, (int) this.posZ);

 

this is pretty much the same as the setLightValue method, just without the 16, and shouldn't be the same block as the setLightValue, otherwise your block light level will reset.

Link to comment
Share on other sites

Unless the entity is moving faster than 1 block per tick, then the light update lines will remove old light source blocks the entity created. Also, the light value works on all blocks. You can see the code working if you use my mod, Mo Chickens, and spawn in the glowing chicken. I made this bit of code to be the best option to giving entities light and not having to make an invisible block. Entities this should not be used on are any entities that teleport around. But you could use it if you modify the light updates to use entities previous position, which is stored by the game.

Link to comment
Share on other sites

So I tryed using that on my projectile, which just stays in place atm. I have the add light method in the onUpdate method and it doesn't light anything up. Is there anything I should change?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Ok so I set up an addLight() thing for a player tick event, and everything is working but the addLight isn't doing anything. Here is my code:

 

@SubscribeEvent
public void onTick(TickEvent.PlayerTickEvent evt){
	this.addLight(evt.player.worldObj, evt.player);
}
private void addLight(World world, EntityPlayer player) {
	world.setLightValue(EnumSkyBlock.Block, (int) player.posX,
			(int) player.posY, (int) player.posZ, 16);
	world.markBlockRangeForRenderUpdate((int) player.posX,
			(int) player.posY, (int) player.posX, 12, 12, 12);
	world.markBlockForUpdate((int) player.posX, (int) player.posY,
			(int) player.posZ);
	world.updateLightByType(EnumSkyBlock.Block, (int) player.posX,
			(int) player.posY + 1, (int) player.posZ);
	world.updateLightByType(EnumSkyBlock.Block, (int) player.posX,
			(int) player.posY - 1, (int) player.posZ);
	world.updateLightByType(EnumSkyBlock.Block,
			(int) player.posX + 1, (int) player.posY, (int) player.posZ);
	world.updateLightByType(EnumSkyBlock.Block,
			(int) player.posX - 1, (int) player.posY, (int) player.posZ);
	world.updateLightByType(EnumSkyBlock.Block, (int) player.posX,
			(int) player.posY, (int) player.posZ + 1);
	world.updateLightByType(EnumSkyBlock.Block, (int) player.posX,
			(int) player.posY, (int) player.posZ - 1);
}

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

package com.apmods.magicraft.entity;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;

import com.apmods.magicraft.main.SpellLib;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class EntitySpell extends EntityThrowable implements IProjectile{

   private int arrowShake;
   private Entity shootingEntity;
   public EntitySpell(World par1World) {
       super(par1World);
       this.setThrowableHeading(motionX, motionY, motionZ, 4.5f, 1F);
   }
   public EntitySpell(World par1World, EntityLivingBase player, int spell) {
       super(par1World, player);
       this.setSpell(spell);
       float speed = 4.5f;
       if(spell == 7){
    	   speed = 0;
       }
       this.shootingEntity = player;
       this.setThrowableHeading(motionX, motionY, motionZ, speed, 1F);
   }
   public EntitySpell(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5)
   {
       super(par1World);
       this.renderDistanceWeight = 10.0D;
       this.shootingEntity = par2EntityLivingBase;

       this.posY = par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D;
       double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX;
       double d1 = par3EntityLivingBase.boundingBox.minY + (double)(par3EntityLivingBase.height / 3.0F) - this.posY;
       double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ;
       double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);

       if (d3 >= 1.0E-7D)
       {
           float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
           float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
           double d4 = d0 / d3;
           double d5 = d2 / d3;
           this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3);
           this.yOffset = 0.0F;
           float f4 = (float)d3 * 0.2F;
           this.setThrowableHeading(d0, d1 + (double)f4, d2, par4, par5);
       }
   }

   @Override
   protected void entityInit() {
   //Spell
   this.dataWatcher.addObject(20, Integer.valueOf(1));
   
   

   }

   @Override
   public void readEntityFromNBT(NBTTagCompound nbt) {
   super.readEntityFromNBT(nbt);
   this.setSpell(nbt.getInteger("spell"));
   }

   @Override
   public void writeEntityToNBT(NBTTagCompound nbt) {
   super.writeEntityToNBT(nbt);
   nbt.setFloat("spell", this.getSpell());
   }

   @Override
   protected void onImpact(MovingObjectPosition mop) {
   Block block = this.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ);
   if(mop.entityHit != null && mop.entityHit instanceof EntityLivingBase){
	   EntityLivingBase entity = (EntityLivingBase) mop.entityHit;
	   float f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
	   int damage = 0;
	   double knockback = 0;
	   if(this.getSpell() == SpellLib.STUPEFY){
		   entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 20, 0));
		   damage = 6;
		   knockback = 0.3;
	   }
	   else if(this.getSpell() == SpellLib.AVADA_KEDAVRA){
		   damage = 100;
		   knockback = 0.2;
	   }
	   else if(this.getSpell() == SpellLib.EXPELLIARMUS){
		   damage = 1;
		   knockback = 0.2;
		   if(entity instanceof EntityPlayer){
			   EntityPlayer player = (EntityPlayer) entity;
			   ItemStack item = player.getCurrentEquippedItem();
			   if(item != null){
				   player.setCurrentItemOrArmor(0, null);
				   this.dropItem(item.getItem(), item.stackSize);
			   }
//				   this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, player.posX + rand.nextInt(), player.posY + 2, player.posZ + rand.nextInt(), item.copy()));
		   }
		   else{
			   if(entity.getEquipmentInSlot(0) != null){
				   ItemStack item = entity.getEquipmentInSlot(0);
				   if(item != null){
					   entity.setCurrentItemOrArmor(0, null);
					   this.dropItem(item.getItem(), item.stackSize);
				   }
			   }
		   }
	   }
	   else if(this.getSpell() == SpellLib.EXPULSO){
		   this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0f, true);
	   }
	   else if(this.getSpell() == SpellLib.CONFRINGO){
		   this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 3.0f, true, true);
	   }
	   else if(this.getSpell() == SpellLib.INCENDIO){
		   entity.setFire(5);
	   }
	   else if(this.getSpell() == SpellLib.AGUAMENTI){
		   entity.extinguish();
	   }
	   else if(this.getSpell() == SpellLib.ALARTE_ASCENDARE){
		   entity.addVelocity(0, 2.5, 0);
	   }
	   
	   entity.attackEntityFrom(DamageSource.magic, 1.0f * damage);
	   entity.addVelocity(this.motionX * knockback * 0.6000000238418579D / (double)f4, knockback, this.motionZ * knockback * 0.6000000238418579D / (double)f4);
   }

   else if( block != Blocks.air){
	   if(this.getSpell() == SpellLib.DURO){
		   this.worldObj.setBlock(mop.blockX, mop.blockY, mop.blockZ, Blocks.stone);
	   }
	   else if(this.getSpell() == SpellLib.EXPULSO){
		   this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0f, true);
	   }
	   else if(this.getSpell() == SpellLib.CONFRINGO){
		   this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 3.0f, true, true);
	   }
	   else if(this.getSpell() == SpellLib.INCENDIO){
		   if(mop.sideHit == 1){
			   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ, Blocks.fire);
			   Random rand = new Random();
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ) == Blocks.air){
					   this.worldObj.setBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ - 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ - 1, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX, (int)this.posY, (int)this.posZ + 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ + 1, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ + 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ + 1, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ - 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ - 1, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ + 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ + 1, Blocks.fire);
				   }
			   }
			   if(rand.nextInt(3) == 0){
				   if(this.worldObj.getBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ - 1) == Blocks.air){
				   this.worldObj.setBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ - 1, Blocks.fire);
				   }
			   }
		   }
	   }
	   else if(this.getSpell() == SpellLib.AGUAMENTI){
//			   if(mop.sideHit == 1){
//				   this.worldObj.setBlock((int)this.posX, (int)this.posY + 1, (int)this.posZ, Blocks.flowing_water);
//			   }
//			   else if(mop.sideHit == 0){
//				   this.worldObj.setBlock((int)this.posX, (int)this.posY - 1, (int)this.posZ, Blocks.flowing_water);
//			   }
//			   else if(mop.sideHit == 2){
//				   this.worldObj.setBlock((int)this.posX + 1, (int)this.posY, (int)this.posZ, Blocks.flowing_water);
//			   }
//			   else if(mop.sideHit == 4){
//				   this.worldObj.setBlock((int)this.posX - 1, (int)this.posY, (int)this.posZ, Blocks.flowing_water);
//			   }
//			   else if(mop.sideHit == 3){
//				   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ + 1, Blocks.flowing_water);
//			   }
//			   else if(mop.sideHit == 5){
//				   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ - 1, Blocks.flowing_water);
//			   }
		   this.worldObj.setBlock((int)this.posX, (int)this.posY, (int)this.posZ, Blocks.flowing_water);
	   }
	   else{
		   this.setDead();
	   }
   }
       this.setDead();
   }
   

   
   @Override
   public float getGravityVelocity(){
   return 0;
   }
   @SideOnly(Side.CLIENT)
   public int getBrightnessForRender(float par1)
   {
       return 15728880;
   }

   /**
    * Gets how bright this entity is.
    */
   public float getBrightness(float par1)
   {
       return 1.0F;
   }
public void onUpdate(){
	super.onUpdate();
//		if(this.getSpell() == SpellLib.LUMOS){
//			this.addLight();
//			if (this.isDead) {
//				this.worldObj.updateLightByType(EnumSkyBlock.Block,
//						(int) this.posX, (int) this.posY, (int) this.posZ);
//			}
//		}
	Random rand = new Random();
	if(rand.nextInt(2) == 1){
	this.worldObj.spawnParticle("enchantmenttable", this.posX + rand.nextFloat()- 0.6f, this.posY , this.posZ + rand.nextFloat() - 0.6f, rand.nextFloat() - 0.5f, 0, rand.nextFloat() - 0.5f);
	}
	else{
		this.worldObj.spawnParticle("enchantmenttable", this.posX - rand.nextFloat(), this.posY, this.posZ - rand.nextFloat(), rand.nextFloat() - 0.5f, 0, rand.nextFloat() - 0.5f);
	}
}

public void onEntityUpdate(){
	super.onEntityUpdate();
	if(this.getSpell() == SpellLib.LUMOS){
		this.addLight();
	}
}
public int getSpell(){
	return this.dataWatcher.getWatchableObjectInt(20);
}
private void setSpell(int f){
	this.dataWatcher.updateObject(20, Integer.valueOf(f));
}
private void addLight() {
	System.out.println("light");
	this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ, 16);
	this.worldObj.markBlockRangeForRenderUpdate((int) this.posX,
			(int) this.posY, (int) this.posX, 12, 12, 12);
	this.worldObj.markBlockForUpdate((int) this.posX, (int) this.posY,
			(int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY + 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY - 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX + 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX - 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ + 1);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ - 1);
}
public void setShootingEntity(EntityLivingBase entity){
	this.shootingEntity = entity;
}



}

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

Still not working, even though I made a living entity to test it:

 

package com.apmods.magicraft.entity;

import net.minecraft.entity.EntityLiving;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;

public class EntityLivingTest extends EntityLiving{

public EntityLivingTest(World p_i1594_1_) {
	super(p_i1594_1_);
	// TODO Auto-generated constructor stub
}
public void onLivingUpdate()
    {
	super.onLivingUpdate();
	addLight();
    }
private void addLight() {
	this.worldObj.setLightValue(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ, 16);
	this.worldObj.markBlockRangeForRenderUpdate((int) this.posX,
			(int) this.posY, (int) this.posX, 12, 12, 12);
	this.worldObj.markBlockForUpdate((int) this.posX, (int) this.posY,
			(int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY + 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY - 1, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX + 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block,
			(int) this.posX - 1, (int) this.posY, (int) this.posZ);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ + 1);
	this.worldObj.updateLightByType(EnumSkyBlock.Block, (int) this.posX,
			(int) this.posY, (int) this.posZ - 1);
}


}

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

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 create my mod pack,yesterday my mod pack is fine but i add one mod and error. I'm delete this mmod but minecraft is still stop on CONFIG_LOAD then I tried to delete config and restart it but again. If you can pleace help me. https://imgur.com/ngZBzuv
    • game crashes before even opening (log:https://mclo.gs/M8xvX7c)
    • I have created a custom entity that extends "TamableAnimal", but I am wanting to have it spawn in the ocean. I have it spawning right now, but it spawns way too frequently even with weight set to 1. I am guessing it is because it is rolling in the spawn pool of land animals since TameableAnimal extends Animal and is different than WaterAnimal, and since no land animals spawn in the ocean it just fills every inch up with my custom entity. I have followed basic tutorials for spawning entities with Forge, but I feel like I am missing something about how to change what spawn pool this custom entity ends up in. Is it possible to change that or do I need to refactor it to be based off of WaterAnimal to get those spawn? My biome modifier JSON file: { "type": "forge:add_spawns", "biomes": "#minecraft:is_ocean", "spawners": { "type": "darwinsmysticalmounts:water_wyvern", "weight": 20, "minCount": 1, "maxCount": 1 } } My client event: event.register(ModEntityTypes.WATER_WYVERN.get(), SpawnPlacements.Type.NO_RESTRICTIONS, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, WaterWyvernEntity::checkWaterWyvernSpawnRules, SpawnPlacementRegisterEvent.Operation.REPLACE); And the actual custom spawn rule that makes it spawn in the water: public static boolean checkWaterWyvernSpawnRules(EntityType<WaterWyvernEntity> pAnimal, LevelAccessor pLevel, MobSpawnType pSpawnType, BlockPos pPos, RandomSource pRandom) { return pPos.getY() > pLevel.getSeaLevel() - 16 && pLevel.getFluidState(pPos.below()).is(FluidTags.WATER); }  
    • Starting today, I am unable to load my modded minecraft world. Forge crash log initially said it was a specific mod called Doggy Talents, which I disabled. Then it blamed JEI, and when that was disabled it blamed another mod so I assume it's something more than a specific mod. Minecraft launcher log claims "Exit Code 1". Nothing had changed since last night when it was working fine Forge Log: https://pastebin.com/S1GiBGVJ Client Log: https://pastebin.com/aLwuGUNL  
    • I am using AMD, yes. I downloaded the website's drivers and am still having the issue. I also used the Cleanup Utility just in case. 
  • Topics

×
×
  • Create New...

Important Information

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