Jump to content

[1.8] Need help with Custom Projectile rendering


SteveKunG

Recommended Posts

My Laser projectile that is not rendering in game. Need help please!

 

Entity

 

package stevekung.mods.moreplanets.planets.diona.entities.projectiles;

 

import java.util.List;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.block.state.IBlockState;

import net.minecraft.enchantment.EnchantmentHelper;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.IProjectile;

import net.minecraft.entity.monster.EntityEnderman;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.network.play.server.S2BPacketChangeGameState;

import net.minecraft.potion.PotionEffect;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.BlockPos;

import net.minecraft.util.DamageSource;

import net.minecraft.util.EnumParticleTypes;

import net.minecraft.util.MathHelper;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.Vec3;

import net.minecraft.world.World;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import stevekung.mods.moreplanets.common.util.DamageSourceMP;

import stevekung.mods.moreplanets.core.init.MPPotions;

import stevekung.mods.moreplanets.planets.diona.entities.EntityEvolvedEnderman;

 

public class EntityLaserMP extends Entity implements IProjectile

{

private int xTile = -1;

private int yTile = -1;

private int zTile = -1;

public Entity shootingEntity;

private int ticksInAir;

private float damage;

 

public EntityLaserMP(World world)

{

super(world);

this.renderDistanceWeight = 10.0D;

this.setSize(0.5F, 0.5F);

}

 

public EntityLaserMP(World world, double x, double y, double z)

{

super(world);

this.renderDistanceWeight = 10.0D;

this.setSize(0.5F, 0.5F);

this.setPosition(x, y, z);

}

 

public EntityLaserMP(World world, EntityLivingBase shooter, EntityLivingBase living, float par4, float par5)

{

super(world);

this.renderDistanceWeight = 10.0D;

this.shootingEntity = shooter;

this.posY = shooter.posY + shooter.getEyeHeight() - 0.10000000149011612D;

double d0 = living.posX - shooter.posX;

double d1 = living.getEntityBoundingBox().minY + living.height / 3.0F - this.posY;

double d2 = living.posZ - shooter.posZ;

double d3 = 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(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3);

float f4 = (float)(d3 * 0.20000000298023224D);

this.setThrowableHeading(d0, d1 + f4, d2, par4, par5);

}

}

 

public EntityLaserMP(World world, EntityLivingBase shooter, float par3)

{

super(world);

this.renderDistanceWeight = 10.0D;

this.shootingEntity = shooter;

this.setSize(0.5F, 0.5F);

this.setLocationAndAngles(shooter.posX, shooter.posY + shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);

this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;

this.posY -= 0.10000000149011612D;

this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F;

this.setPosition(this.posX, this.posY, this.posZ);

this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);

this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI);

this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI);

this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);

}

 

@Override

public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)

{

float f2 = MathHelper.sqrt_double(x * x + y * y + z * z);

x /= f2;

y /= f2;

z /= f2;

x += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * inaccuracy;

y += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * inaccuracy;

z += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * inaccuracy;

x *= velocity;

y *= velocity;

z *= velocity;

this.motionX = x;

this.motionY = y;

this.motionZ = z;

float f3 = MathHelper.sqrt_double(x * x + z * z);

this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);

this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, f3) * 180.0D / Math.PI);

}

 

@Override

@SideOnly(Side.CLIENT)

public void func_180426_a(double x, double y, double z, float par4, float par5, int par6, boolean par7)

{

this.setPosition(x, y, z);

this.setRotation(par4, par5);

}

 

@Override

@SideOnly(Side.CLIENT)

public void setVelocity(double x, double y, double z)

{

this.motionX = x;

this.motionY = y;

this.motionZ = z;

 

if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)

{

float f = MathHelper.sqrt_double(x * x + z * z);

this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);

this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, f) * 180.0D / Math.PI);

this.prevRotationPitch = this.rotationPitch;

this.prevRotationYaw = this.rotationYaw;

this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);

}

}

 

@Override

public void onUpdate()

{

super.onUpdate();

 

if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)

{

float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, f) * 180.0D / Math.PI);

}

 

BlockPos pos = new BlockPos(this.xTile, this.yTile, this.zTile);

IBlockState state = this.worldObj.getBlockState(pos);

Block block = state.getBlock();

 

if (block.getMaterial() != Material.air)

{

block.setBlockBoundsBasedOnState(this.worldObj, pos);

AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, pos, state);

 

if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ)))

{

this.setDead();

}

}

 

++this.ticksInAir;

Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ);

Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

MovingObjectPosition moving = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false);

vec31 = new Vec3(this.posX, this.posY, this.posZ);

vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

 

if (moving != null)

{

vec3 = new Vec3(moving.hitVec.xCoord, moving.hitVec.yCoord, moving.hitVec.zCoord);

}

 

Entity entity = null;

List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));

double d0 = 0.0D;

int i;

float f1;

 

for (i = 0; i < list.size(); ++i)

{

Entity entity1 = (Entity)list.get(i);

 

if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))

{

f1 = 0.3F;

AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand(f1, f1, f1);

MovingObjectPosition moving1 = axisalignedbb1.calculateIntercept(vec31, vec3);

 

if (moving1 != null)

{

double d1 = vec31.distanceTo(moving1.hitVec);

 

if (d1 < d0 || d0 == 0.0D)

{

entity = entity1;

d0 = d1;

}

}

}

}

 

if (entity != null)

{

moving = new MovingObjectPosition(entity);

}

 

if (moving != null && moving.entityHit != null && moving.entityHit instanceof EntityPlayer)

{

EntityPlayer entityplayer = (EntityPlayer)moving.entityHit;

 

if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))

{

moving = null;

}

}

 

float f2;

float f3;

 

if (moving != null)

{

if (moving.entityHit != null)

{

DamageSource damagesource;

int type = this.getLaserType();

 

if (this.shootingEntity == null)

{

damagesource = DamageSourceMP.causeLaserDamage(this, this);

}

else

{

damagesource = DamageSourceMP.causeLaserDamage(this, this.shootingEntity);

}

 

if (type == 0)

{

this.damage = 6.0F;

}

if (type == 1)

{

this.damage = 10.0F;

}

if (type == 2)

{

this.damage = 7.5F;

 

if (moving.entityHit instanceof EntityLivingBase)

{

if (!this.worldObj.isRemote)

{

((EntityLivingBase)moving.entityHit).addPotionEffect(new PotionEffect(MPPotions.electro_magnetic_pulse.id, 480));

}

}

}

if (type == 3)

{

this.damage = 9.5F;

 

if (moving.entityHit instanceof EntityLivingBase)

{

if (!this.worldObj.isRemote)

{

((EntityLivingBase)moving.entityHit).addPotionEffect(new PotionEffect(MPPotions.chemical.id, 256));

}

}

}

if (moving.entityHit.attackEntityFrom(damagesource, this.damage))

{

if (moving.entityHit instanceof EntityLivingBase)

{

EntityLivingBase entitylivingbase = (EntityLivingBase)moving.entityHit;

 

if (!this.worldObj.isRemote)

{

entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);

}

if (this.shootingEntity instanceof EntityLivingBase)

{

EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);

EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);

}

if (this.shootingEntity != null && moving.entityHit != this.shootingEntity && moving.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)

{

((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));

}

}

if (!(moving.entityHit instanceof EntityEnderman) || !(moving.entityHit instanceof EntityEvolvedEnderman))

{

this.setDead();

}

}

else

{

this.motionX *= -0.10000000149011612D;

this.motionY += 0D;

this.motionZ *= -0.10000000149011612D;

this.rotationYaw += 180.0F;

this.prevRotationYaw += 180.0F;

this.ticksInAir = 0;

}

}

else

{

this.motionX = (float)(moving.hitVec.xCoord - this.posX);

this.motionY = (float)(moving.hitVec.yCoord - this.posY);

this.motionZ = (float)(moving.hitVec.zCoord - this.posZ);

f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);

f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);

this.posX -= this.motionX / f3 * 0.05000000074505806D;

this.posY += this.motionY / f2 * 0D;

this.posZ -= this.motionZ / f3 * 0.05000000074505806D;

this.setDead();

}

}

 

this.posX += this.motionX;

this.posY += this.motionY;

this.posZ += this.motionZ;

f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

 

for (this.rotationPitch = (float)(Math.atan2(this.motionY, f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)

{

}

 

while (this.rotationPitch - this.prevRotationPitch >= 180.0F)

{

this.prevRotationPitch += 360.0F;

}

 

while (this.rotationYaw - this.prevRotationYaw < -180.0F)

{

this.prevRotationYaw -= 360.0F;

}

 

while (this.rotationYaw - this.prevRotationYaw >= 180.0F)

{

this.prevRotationYaw += 360.0F;

}

 

this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;

this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;

f3 = 0.99F;

f1 = 0.05F;

 

if (this.isInWater())

{

for (int j1 = 0; j1 < 4; ++j1)

{

f3 = 0.25F;

this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX - this.motionX * f3, this.posY - this.motionY * f3, this.posZ - this.motionZ * f3, this.motionX, this.motionY, this.motionZ);

this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.fizz", 0.7F, 0.9F);

}

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

{

this.setDead();

}

}

 

this.motionX *= f3;

this.motionY += 0.0F;

this.motionZ *= f3;

this.setPosition(this.posX, this.posY, this.posZ);

this.doBlockCollisions();

}

 

@Override

public void writeEntityToNBT(NBTTagCompound nbt)

{

nbt.setShort("xTile", (short)this.xTile);

nbt.setShort("yTile", (short)this.yTile);

nbt.setShort("zTile", (short)this.zTile);

nbt.setInteger("LaserType", this.getLaserType());

}

 

@Override

public void readEntityFromNBT(NBTTagCompound nbt)

{

this.xTile = nbt.getShort("xTile");

this.yTile = nbt.getShort("yTile");

this.zTile = nbt.getShort("zTile");

this.setLaserType(nbt.getInteger("LaserType"));

}

 

@Override

protected boolean canTriggerWalking()

{

return false;

}

 

@Override

public boolean canAttackWithItem()

{

return false;

}

 

@Override

protected void entityInit()

{

this.dataWatcher.addObject(16, Byte.valueOf((byte)0));

this.dataWatcher.addObject(18, Byte.valueOf((byte)0));

}

 

public int getLaserType()

{

return this.dataWatcher.getWatchableObjectByte(18);

}

 

public void setLaserType(int type)

{

this.dataWatcher.updateObject(18, Byte.valueOf((byte)type));

}

}

 

 

Render

 

package stevekung.mods.moreplanets.planets.diona.client.render.entities.projectiles;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.renderer.GlStateManager;

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

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

import net.minecraft.entity.Entity;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import stevekung.mods.moreplanets.planets.diona.client.model.ModelLaser;

import stevekung.mods.moreplanets.planets.diona.entities.projectiles.EntityLaserMP;

 

@SideOnly(Side.CLIENT)

public class RenderLaser extends Render

{

protected ModelBase model = new ModelLaser();

 

public RenderLaser(RenderManager render)

{

super(render);

}

 

public void doRender(EntityLaserMP entity, double x, double y, double z, float par5, float partialTicks)

{

GlStateManager.pushMatrix();

GlStateManager.translate((float)x, (float)y, (float)z);

GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);

GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);

float f4 = 0.75F;

GlStateManager.scale(f4, f4, f4);

GlStateManager.scale(1.0F / f4, 1.0F / f4, 1.0F / f4);

this.bindEntityTexture(entity);

GlStateManager.scale(-1.0F, -1.0F, 1.0F);

this.model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

GlStateManager.popMatrix();

super.doRender(entity, x, y, z, par5, partialTicks);

}

 

@Override

protected ResourceLocation getEntityTexture(Entity entity)

{

return this.getEntityTexture((EntityLaserMP)entity);

}

 

protected ResourceLocation getEntityTexture(EntityLaserMP entity)

{

if (entity.getLaserType() == 0)

{

return new ResourceLocation("diona:textures/model/laser/laser.png");

}

else if (entity.getLaserType() == 1)

{

return new ResourceLocation("diona:textures/model/laser/hyper.png");

}

else if (entity.getLaserType() == 2)

{

return new ResourceLocation("diona:textures/model/laser/emp.png");

}

else if (entity.getLaserType() == 3)

{

return new ResourceLocation("diona:textures/model/laser/uranium.png");

}

return null;

}

 

@Override

public void doRender(Entity entity, double x, double y, double z, float par5, float partialTicks)

{

this.doRender((EntityLaserMP)entity, x, y, z, par5, partialTicks);

}

}

 

Link to comment
Share on other sites

 

package stevekung.mods.moreplanets.client.render;

 

import net.minecraft.client.Minecraft;

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

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.client.registry.RenderingRegistry;

import stevekung.mods.moreplanets.client.render.entities.RenderFlagMP;

import stevekung.mods.moreplanets.client.render.entities.RenderSnowballMP;

import stevekung.mods.moreplanets.common.entities.EntityFlagMP;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.RenderDionaMinionCreeper;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.RenderEvolvedEnderman;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.RenderFronisiumTNT;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.RenderSpaceWolf;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.projectiles.RenderLaser;

import stevekung.mods.moreplanets.planets.diona.client.render.entities.projectiles.RenderProjectileFronisiumTNT;

import stevekung.mods.moreplanets.planets.diona.entities.EntityDionaMinionCreeper;

import stevekung.mods.moreplanets.planets.diona.entities.EntityEvolvedEnderman;

import stevekung.mods.moreplanets.planets.diona.entities.EntityFronisiumTNT;

import stevekung.mods.moreplanets.planets.diona.entities.EntitySpaceWolf;

import stevekung.mods.moreplanets.planets.diona.entities.projectiles.EntityLaserMP;

import stevekung.mods.moreplanets.planets.diona.entities.projectiles.EntityProjectileFronisiumTNT;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderBearry;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderBerry;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderCreamCat;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderCreamGolem;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderCreamSlime;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderFronosVillager;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderGrappy;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderJellySlime;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderKiwi;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderLemonDuck;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderMarshmallow;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderMelon;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderPoisonArrow;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderStarfish;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderStrawberryChicken;

import stevekung.mods.moreplanets.planets.fronos.client.render.entities.RenderTomato;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityBearry;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityBerry;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityCreamCat;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityCreamGolem;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityCreamSlime;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityFronosVillager;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityGrappy;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityJellySlime;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityKiwi;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityLemonDuck;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityMarshmallow;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityMelon;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityStarfish;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityStrawberryChicken;

import stevekung.mods.moreplanets.planets.fronos.entities.EntityTomato;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityChocolateCreamBall;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityLemonCreamBall;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityOrangeCreamBall;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityPoisonArrow;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityStrawberryCreamBall;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityTeaCreamBall;

import stevekung.mods.moreplanets.planets.fronos.entities.projectiles.EntityVanillaCreamBall;

import stevekung.mods.moreplanets.planets.fronos.items.FronosItems;

import stevekung.mods.moreplanets.planets.kapteynb.client.render.entities.RenderUraniumBomb;

import stevekung.mods.moreplanets.planets.kapteynb.entities.EntityUraniumBomb;

import stevekung.mods.moreplanets.planets.nibiru.client.render.entities.RenderGiantWorm;

import stevekung.mods.moreplanets.planets.nibiru.client.render.entities.RenderInfectedZombie;

import stevekung.mods.moreplanets.planets.nibiru.entities.EntityGiantWorm;

import stevekung.mods.moreplanets.planets.nibiru.entities.EntityInfectedZombie;

import stevekung.mods.moreplanets.planets.polongnius.client.render.entities.RenderCheeseCow;

import stevekung.mods.moreplanets.planets.polongnius.client.render.entities.RenderCheeseSlime;

import stevekung.mods.moreplanets.planets.polongnius.client.render.entities.RenderCheeseSpore;

import stevekung.mods.moreplanets.planets.polongnius.entities.EntityCheeseCow;

import stevekung.mods.moreplanets.planets.polongnius.entities.EntityCheeseSlime;

import stevekung.mods.moreplanets.planets.polongnius.entities.projectiles.EntityCheeseSpore;

import stevekung.mods.moreplanets.planets.siriusb.client.render.entities.RenderSiriusBlaze;

import stevekung.mods.moreplanets.planets.siriusb.client.render.entities.RenderSiriusCreeper;

import stevekung.mods.moreplanets.planets.siriusb.client.render.entities.RenderSiriusMagmaCube;

import stevekung.mods.moreplanets.planets.siriusb.client.render.entities.projectiles.RenderSiriusSmallFireball;

import stevekung.mods.moreplanets.planets.siriusb.entities.EntitySiriusBlaze;

import stevekung.mods.moreplanets.planets.siriusb.entities.EntitySiriusCreeper;

import stevekung.mods.moreplanets.planets.siriusb.entities.EntitySiriusMagmaCube;

import stevekung.mods.moreplanets.planets.siriusb.entities.projectiles.EntitySiriusSmallFireball;

 

public class EntityRendererMP

{

//private static IModelPart tier3RocketModel = AdvancedModelLoader.loadModel(new ResourceLocation("galacticraftasteroids:models/tier3rocket.obj"));

 

public static void init()

{

EntityRendererMP.registerEntityRenderers();

EntityRendererMP.registerNonEntityRenderers();

}

 

private static void registerEntityRenderers()

{

RenderManager render = Minecraft.getMinecraft().getRenderManager();

 

// RenderingRegistry.registerEntityRenderingHandler(EntityDustSludgeling.class, new RenderDustSludgeling(render));

RenderingRegistry.registerEntityRenderingHandler(EntitySpaceWolf.class, new RenderSpaceWolf(render));

RenderingRegistry.registerEntityRenderingHandler(EntityEvolvedEnderman.class, new RenderEvolvedEnderman(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityDionaCreeperBoss.class, new RenderDionaCreeperBoss());

RenderingRegistry.registerEntityRenderingHandler(EntityDionaMinionCreeper.class, new RenderDionaMinionCreeper(render));

 

RenderingRegistry.registerEntityRenderingHandler(EntityCheeseCow.class, new RenderCheeseCow(render));

RenderingRegistry.registerEntityRenderingHandler(EntityCheeseSlime.class, new RenderCheeseSlime(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityCheeseCubeEyeBoss.class, new RenderCheeseCubeBoss(render));

 

// RenderingRegistry.registerEntityRenderingHandler(EntityInfectedWorm.class, new RenderInfectedWorm(render));

RenderingRegistry.registerEntityRenderingHandler(EntityGiantWorm.class, new RenderGiantWorm(render));

RenderingRegistry.registerEntityRenderingHandler(EntityInfectedZombie.class, new RenderInfectedZombie(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityInfectedEvolvedSpiderBoss.class, new RenderInfectedEvolvedSpiderBoss(render));

 

//RenderingRegistry.registerEntityRenderingHandler(EntityKoentusianVillager.class, new RenderKoentusianVillager());

// RenderingRegistry.registerEntityRenderingHandler(EntityKoentusSludgeling.class, new RenderKoentusSludgeling(render));

 

RenderingRegistry.registerEntityRenderingHandler(EntityBearry.class, new RenderBearry(render));

RenderingRegistry.registerEntityRenderingHandler(EntityBerry.class, new RenderBerry(render));

RenderingRegistry.registerEntityRenderingHandler(EntityMarshmallow.class, new RenderMarshmallow(render));

RenderingRegistry.registerEntityRenderingHandler(EntityKiwi.class, new RenderKiwi(render));

RenderingRegistry.registerEntityRenderingHandler(EntityJellySlime.class, new RenderJellySlime(render));

RenderingRegistry.registerEntityRenderingHandler(EntityCreamSlime.class, new RenderCreamSlime(render));

RenderingRegistry.registerEntityRenderingHandler(EntityLemonDuck.class, new RenderLemonDuck(render));

RenderingRegistry.registerEntityRenderingHandler(EntityStarfish.class, new RenderStarfish(render));

RenderingRegistry.registerEntityRenderingHandler(EntityMelon.class, new RenderMelon(render));

RenderingRegistry.registerEntityRenderingHandler(EntityTomato.class, new RenderTomato(render));

RenderingRegistry.registerEntityRenderingHandler(EntityGrappy.class, new RenderGrappy(render));

RenderingRegistry.registerEntityRenderingHandler(EntityCreamCat.class, new RenderCreamCat(render));

RenderingRegistry.registerEntityRenderingHandler(EntityCreamGolem.class, new RenderCreamGolem(render));

RenderingRegistry.registerEntityRenderingHandler(EntityStrawberryChicken.class, new RenderStrawberryChicken(render));

RenderingRegistry.registerEntityRenderingHandler(EntityFronosVillager.class, new RenderFronosVillager(render));

 

// RenderingRegistry.registerEntityRenderingHandler(EntityFrozenSludgeling.class, new RenderFrozenSludgeling(render));

 

RenderingRegistry.registerEntityRenderingHandler(EntitySiriusCreeper.class, new RenderSiriusCreeper(render));

RenderingRegistry.registerEntityRenderingHandler(EntitySiriusBlaze.class, new RenderSiriusBlaze(render));

RenderingRegistry.registerEntityRenderingHandler(EntitySiriusMagmaCube.class, new RenderSiriusMagmaCube(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityEvolvedSiriusBlazeBoss.class, new RenderEvolvedSiriusBlazeBoss(render));

}

 

private static void registerNonEntityRenderers()

{

RenderManager render = Minecraft.getMinecraft().getRenderManager();

 

RenderingRegistry.registerEntityRenderingHandler(EntityFlagMP.class, new RenderFlagMP(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityTier4Rocket.class, new RenderTier1Rocket(new ModelRocketMP(), "diona", "tier4_rocket"));

// RenderingRegistry.registerEntityRenderingHandler(EntityTier4RocketNoFlag.class, new RenderTier1Rocket(new ModelRocketNoFlagMP(), "diona", "tier4_rocket"));

RenderingRegistry.registerEntityRenderingHandler(EntityProjectileFronisiumTNT.class, new RenderProjectileFronisiumTNT(render));

RenderingRegistry.registerEntityRenderingHandler(EntityFronisiumTNT.class, new RenderFronisiumTNT(render));

RenderingRegistry.registerEntityRenderingHandler(EntityLaserMP.class, new RenderLaser(render));

 

// RenderingRegistry.registerEntityRenderingHandler(EntityTier5Rocket.class, new RenderTier1Rocket(new ModelRocketMP(), "polongnius", "tier5_rocket"));

// RenderingRegistry.registerEntityRenderingHandler(EntityTier5RocketNoFlag.class, new RenderTier1Rocket(new ModelRocketNoFlagMP(), "polongnius", "tier5_rocket"));

RenderingRegistry.registerEntityRenderingHandler(EntityCheeseSpore.class, new RenderCheeseSpore(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityPolongniusMeteorChunk.class, new RenderPolongniusMeteorChunk(render));

// RenderingRegistry.registerEntityRenderingHandler(EntityPolongniusMeteor.class, new RenderPolongniusMeteor(render));

 

// RenderingRegistry.registerEntityRenderingHandler(EntityTier6Rocket.class, new RenderTier1Rocket(new ModelRocketMP(), "nibiru", "tier6_rocket"));

// RenderingRegistry.registerEntityRenderingHandler(EntityTier6RocketNoFlag.class, new RenderTier1Rocket(new ModelRocketNoFlagMP(), "nibiru", "tier6_rocket"));

 

// RenderingRegistry.registerEntityRenderingHandler(EntityKoentusMeteorChunk.class, new RenderKoentusMeteorChunk());

// RenderingRegistry.registerEntityRenderingHandler(EntityKoentusMeteor.class, new RenderKoentusMeteor(render));

 

RenderingRegistry.registerEntityRenderingHandler(EntityVanillaCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 0)));

RenderingRegistry.registerEntityRenderingHandler(EntityChocolateCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 1)));

RenderingRegistry.registerEntityRenderingHandler(EntityStrawberryCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 2)));

RenderingRegistry.registerEntityRenderingHandler(EntityOrangeCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 3)));

RenderingRegistry.registerEntityRenderingHandler(EntityTeaCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 4)));

RenderingRegistry.registerEntityRenderingHandler(EntityLemonCreamBall.class, new RenderSnowballMP(render, new ItemStack(FronosItems.cream_ball, 1, 5)));

RenderingRegistry.registerEntityRenderingHandler(EntityPoisonArrow.class, new RenderPoisonArrow(render));

//RenderingRegistry.registerEntityRenderingHandler(EntityTier7Rocket.class, new RenderTier7Rocket(EntityRendererMP.tier3RocketModel, "fronos", "tier7_rocket"));

 

RenderingRegistry.registerEntityRenderingHandler(EntityUraniumBomb.class, new RenderUraniumBomb(render));

//RenderingRegistry.registerEntityRenderingHandler(EntityTier8Rocket.class, new RenderTier8Rocket(EntityRendererMP.tier3RocketModel, "kapteynb", "tier8_rocket"));

 

RenderingRegistry.registerEntityRenderingHandler(EntitySiriusSmallFireball.class, new RenderSiriusSmallFireball(render));

 

}

}

 

Link to comment
Share on other sites

1. Has the method 'doRender' been called?

2. GlStateManager.scale(-1.0F, -1.0F, 1.0F); will invert the model and would result in not rendering the inverted faces.

  Why did you scaled it -1.0?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

You should not copy-paste the code unless you know what the code does and what you are doing..

So what shape do you want?

And check if doRender code has been called. If it is not getting called, then it is regardless of the model code.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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

    • My modded minecraft world don't go past 100% on the loading screen. My backup still work, but i've made a lot of progress from the point i was that save. i have already checked online and did some suggestions i found, but nothing worked. Here is my latest log + i don´t have crash reports: https://github.com/GmsantosPT/Minecraft-mod-problems/tree/main   Pls Help, Santos
    • Please share a link to your crash report, as explained in the FAQ
    • I have a block already registered in my mod, which I have used in some worlds. The problem arises when in code, I add a property called CURRENT_AGE, when running Minecraft it freezes. In the console it doesn't appear any excpetion except that it stays in this phase: [Render thread/DEBUG] [ne.mi.co.ca.CapabilityManager/CAPABILITIES]: Attempting to automatically register: Lnet/minecraftforge/items/IItemHandler; Does anyone have an idea what it could be? I show the block and its registration public class SoulLichenBlock extends MultifaceBlock implements SimpleWaterloggedBlock, EntityBlock { public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final IntegerProperty SKILL_LEVEL = IntegerProperty.create("soullichen_level", 0, 30); public static final DirectionProperty FACE = DirectionProperty.create("soullichen_face"); public static final DirectionProperty DIRECTION = DirectionProperty.create("soullichen_direction"); public static final IntegerProperty CURRENT_AGE = BlockStateProperties.AGE_25; private final MultifaceSpreader spreader = new MultifaceSpreader(this); private final MultifaceSpreader.DefaultSpreaderConfig config = new MultifaceSpreader.DefaultSpreaderConfig(this); private LivingEntity owner; //private static final Integer MAX_AGE = 25; public SoulLichenBlock(Properties properties) { super(properties); this.registerDefaultState(this .defaultBlockState() .setValue(WATERLOGGED, Boolean.FALSE) .setValue(SKILL_LEVEL, 0) .setValue(FACE, Direction.DOWN) .setValue(DIRECTION, Direction.DOWN) .trySetValue(CURRENT_AGE, 0) ); } public static ToIntFunction<BlockState> emission(int p_181223_) { return (p_181221_) -> MultifaceBlock.hasAnyFace(p_181221_) ? p_181223_ : 0; } public static boolean hasFace(BlockState p_153901_, @NotNull Direction p_153902_) { BooleanProperty booleanproperty = getFaceProperty(p_153902_); return p_153901_.hasProperty(booleanproperty) && p_153901_.getValue(booleanproperty); } protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> stateDefinition) { stateDefinition.add(WATERLOGGED).add(SKILL_LEVEL).add(FACE).add(DIRECTION).add(CURRENT_AGE); super.createBlockStateDefinition(stateDefinition); } public @NotNull BlockState updateShape(BlockState p_153302_, @NotNull Direction p_153303_, @NotNull BlockState p_153304_, @NotNull LevelAccessor p_153305_, @NotNull BlockPos p_153306_, @NotNull BlockPos p_153307_) { if (p_153302_.getValue(WATERLOGGED)) { p_153305_.scheduleTick(p_153306_, Fluids.WATER, Fluids.WATER.getTickDelay(p_153305_)); } return super.updateShape(p_153302_, p_153303_, p_153304_, p_153305_, p_153306_, p_153307_); } @SuppressWarnings("deprecation") public @NotNull FluidState getFluidState(BlockState fluidState) { return fluidState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(fluidState); } public boolean propagatesSkylightDown(BlockState p_181225_, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos) { return p_181225_.getFluidState().isEmpty(); } public @NotNull MultifaceSpreader getSpreader() { return this.spreader; } public Optional<MultifaceSpreader.SpreadPos> spreadFromRandomFaceTowardRandomDirection( BlockState p_221620_, LevelAccessor p_221621_, BlockPos p_221622_, RandomSource p_221623_, int skillPoints, int age) { return Direction.allShuffled(p_221623_).stream().filter((p_221680_) -> { return this.config.canSpreadFrom(p_221620_, p_221680_); }).map((p_221629_) -> { return this.spreadFromFaceTowardRandomDirection(p_221620_, p_221621_, p_221622_, p_221629_, p_221623_, false, skillPoints, age); }).filter(Optional::isPresent).findFirst().orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardRandomDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, RandomSource randomSource, boolean aBoolean, int skillPoints, int age) { return Direction.allShuffled(randomSource).stream().map((direction) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, aBoolean, skillPoints, age)) .filter(Optional::isPresent) .findFirst() .orElse(Optional.empty()); } public Optional<MultifaceSpreader.SpreadPos> spreadFromFaceTowardDirection( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, Direction direction, boolean aBoolean, int skillPoints, int age) { //DevilRpg.LOGGER.debug("BEGIN ==================================== spreadFromFaceTowardDirection skillPoints {}", skillPoints); return skillPoints < 0 ? Optional.empty() : getSpreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, direction, this::canSpreadInto) .flatMap((spreadPos) -> { //DevilRpg.LOGGER.debug("END ================================ spreadFromFaceTowardDirection spreadPos {}", spreadPos); return this.spreadToFace(levelAccessor, spreadPos, aBoolean, skillPoints, direction, age); }); } public boolean canSpreadInto(BlockGetter p_221685_, BlockPos p_221686_, MultifaceSpreader.SpreadPos p_221687_) { BlockState blockstate = p_221685_.getBlockState(p_221687_.pos()); return this.stateCanBeReplaced(p_221685_, p_221686_, p_221687_.pos(), p_221687_.face(), blockstate) && isValidStateForPlacement(p_221685_, blockstate, p_221687_.pos(), p_221687_.face()); } protected boolean stateCanBeReplaced(BlockGetter p_221688_, BlockPos p_221689_, BlockPos p_221690_, Direction p_221691_, BlockState p_221692_) { return p_221692_.isAir() || p_221692_.is(this) || p_221692_.is(Blocks.WATER) && p_221692_.getFluidState().isSource(); } public Optional<MultifaceSpreader.SpreadPos> getSpreadFromFaceTowardDirection(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction face, Direction direction, MultifaceSpreader.SpreadPredicate spreadPredicate) { //DevilRpg.LOGGER.debug("--- getSpreadFromFaceTowardDirection direction.getAxis() == face.getAxis(): {}", direction.getAxis() == face.getAxis()); ArrayList<Direction> directions = new ArrayList<>(); directions.add(direction); if (direction.getAxis() == face.getAxis()) { if (direction.getAxis().isHorizontal()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isVertical()).collect(Collectors.toCollection(ArrayList::new)); } if (direction.getAxis().isVertical()) { directions = Arrays.stream(Direction.values()).filter(dir -> dir.getAxis().isHorizontal()).collect(Collectors.toCollection(ArrayList::new)); } } for (Direction directionElement : directions) { /*DevilRpg.LOGGER.debug("--->> getSpreadFromFaceTowardDirection config.isOtherBlockValidAsSource(blockState) {} || " + "hasFace(blockState, face) {} && " + "!hasFace(blockState, direction) {}", config.isOtherBlockValidAsSource(blockState), hasFace(blockState, face), !hasFace(blockState, directionElement));*/ if (config.isOtherBlockValidAsSource(blockState) || hasFace(blockState, face) && !hasFace(blockState, directionElement)) { for (MultifaceSpreader.SpreadType multifacespreader$spreadtype : config.getSpreadTypes()) { MultifaceSpreader.SpreadPos multifacespreader$spreadpos = multifacespreader$spreadtype.getSpreadPos(blockPos, directionElement, face); //DevilRpg.LOGGER.debug("--- test SpreadPos: {} direction {} face {} ", multifacespreader$spreadpos, directionElement, face); if (spreadPredicate.test(blockGetter, blockPos, multifacespreader$spreadpos)) { //DevilRpg.LOGGER.debug("--- spreadPredicate success:"); return Optional.of(multifacespreader$spreadpos); } } } } return Optional.empty(); } public boolean isValidStateForPlacement(@NotNull BlockGetter blockGetter, @NotNull BlockState blockState, @NotNull BlockPos blockPos, @NotNull Direction face) { //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 1st condition: {} && ({} || {})", this.isFaceSupported(face), !blockState.is(this), !hasFace(blockState, face)); if (this.isFaceSupported(face) && (!blockState.is(this) || !hasFace(blockState, face))) { BlockPos blockpos = blockPos.relative(face); //DevilRpg.LOGGER.debug("------ isValidStateForPlacement 2nd condition: canAttachTo {} ", secondCondition); return canAttachTo(blockGetter, face, blockpos, blockGetter.getBlockState(blockpos)); } else { return false; } } @Nullable public BlockState getStateForPlacement(@NotNull BlockState blockState, @NotNull BlockGetter blockGetter, @NotNull BlockPos blockPos, @NotNull Direction face, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("--- getStateForPlacement"); boolean isNotValidStateForPlacement = !this.isValidStateForPlacement(blockGetter, blockState, blockPos, face); //DevilRpg.LOGGER.debug("------- isNotValidStateForPlacement: {}", isNotValidStateForPlacement); if (isNotValidStateForPlacement) { return null; } else { BlockState blockstate; if (blockState.is(this)) { blockstate = blockState; } else if (this.isWaterloggable() && blockState.getFluidState().isSourceOfType(Fluids.WATER)) { blockstate = this.defaultBlockState().setValue(BlockStateProperties.WATERLOGGED, Boolean.TRUE); } else { blockstate = this.defaultBlockState(); } //DevilRpg.LOGGER.debug("------- getStateForPlacement -> blockStateResult "); return blockstate .setValue(getFaceProperty(face), Boolean.TRUE) .setValue(SKILL_LEVEL, skillPoints).setValue(FACE, face) .setValue(DIRECTION, direction) .setValue(CURRENT_AGE,age) ; } } public Optional<MultifaceSpreader.SpreadPos> spreadToFace(LevelAccessor levelAccessor, MultifaceSpreader.SpreadPos spreadPos, boolean p_221596_, int skillPoints, Direction direction, int age) { BlockState blockstate = levelAccessor.getBlockState(spreadPos.pos()); //DevilRpg.LOGGER.debug("---> spreadToFace blockstate{} direction: {}", blockstate, direction); return this.placeBlock(levelAccessor, spreadPos, blockstate, p_221596_, skillPoints, direction, age) ? Optional.of(spreadPos) : Optional.empty(); } public boolean placeBlock(LevelAccessor p_221702_, MultifaceSpreader.SpreadPos p_221703_, BlockState p_221704_, boolean p_221705_, int skillPoints, Direction direction, int age) { //DevilRpg.LOGGER.debug("---> placeBlock {} direction {} ", p_221703_, direction); BlockState blockstate = this.getStateForPlacement(p_221704_, p_221702_, p_221703_.pos(), p_221703_.face(), skillPoints, direction, age); if (blockstate != null) { if (p_221705_) { p_221702_.getChunk(p_221703_.pos()).markPosForPostprocessing(p_221703_.pos()); } //DevilRpg.LOGGER.debug("------> setBlock"); return p_221702_.setBlock(p_221703_.pos(), blockstate, 2); } else { return false; } } public long spreadFromFaceTowardAllDirections( BlockState blockState, LevelAccessor levelAccessor, BlockPos blockPos, Direction face, boolean aBoolean, int skillPoints, int age) { return Direction.stream().map((p_221656_) -> spreadFromFaceTowardDirection(blockState, levelAccessor, blockPos, face, p_221656_, aBoolean, skillPoints, age)) .filter(Optional::isPresent).count(); } private boolean isWaterloggable() { return this.stateDefinition.getProperties().contains(BlockStateProperties.WATERLOGGED); } @Override public void setPlacedBy(@NotNull Level level, @NotNull BlockPos blockPos, @NotNull BlockState blockState, @Nullable LivingEntity livingEntity, @NotNull ItemStack itemStack) { super.setPlacedBy(level, blockPos, blockState, livingEntity, itemStack); this.setOwner(livingEntity); } public LivingEntity getOwner() { return this.owner; } private void setOwner(LivingEntity livingEntity) { this.owner = livingEntity; } @Deprecated @Override public void entityInside(@NotNull BlockState blockState, @NotNull Level level, @NotNull BlockPos blockPos, @NotNull Entity entity) { if (entity instanceof LivingEntity /*&& entity.getType() != EntityType.BEE*/ && entity.getType() != ModEntities.LICHEN_SEEDBALL.get()) { entity.makeStuckInBlock(blockState, new Vec3(0.8D, 0.75D, 0.8D)); if (!level.isClientSide /*&& (entity.xOld != entity.getX() || entity.zOld != entity.getZ())*/) { // double d0 = Math.abs(entity.getX() - entity.xOld); // double d1 = Math.abs(entity.getZ() - entity.zOld); // if (d0 >= (double) 0.003F || d1 >= (double) 0.003F) { entity.hurt(level.damageSources().playerAttack((Player) owner), 1.0F); // Aplicar aceleración al movimiento double speedBoost = -0.4; // Ajusta este valor según lo rápido que quieras que sea el impulso double motionX = entity.getX() - entity.xOld; double motionZ = entity.getZ() - entity.zOld; double speed = Math.sqrt(motionX * motionX + motionZ * motionZ); //if (speed > 0.0) { entity.setDeltaMovement(entity.getDeltaMovement().multiply( (motionX / speed) * speedBoost, 0.0, (motionZ / speed) * speedBoost )); // } //} } } } @Nullable @Override public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) { return ModEntityBlocks.SOUL_LICHEN_ENTITY_BLOCK.get().create(pos, state); } @Nullable @Override public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState blockState, @NotNull BlockEntityType<T> type) { return level.isClientSide ? null : (alevel, pos, aBlockstate, blockEntity) -> { if (blockEntity instanceof SoulLichenBlockEntity soulLichenBlockEntity && alevel.getGameTime() % 5 == 0) { soulLichenBlockEntity.tick(blockState, (ServerLevel) alevel, pos, alevel.getRandom()); //DevilRpg.LOGGER.info("-------->tick. this: {}", this.getClass().getSimpleName()); } }; } }   This is the registration:   public final class ModBlocks { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, DevilRpg.MODID); ... public static final RegistryObject<SoulLichenBlock> SOUL_LICHEN_BLOCK = BLOCKS.register("soullichen", () -> new SoulLichenBlock( Block.Properties.copy(Blocks.GLOW_LICHEN).lightLevel(SoulLichenBlock.emission(7)).randomTicks() )); }  
    • If you are using AMD/ATI, check for driver updates on their website - do not update via system
    • Hi, Create a new class that extends "Block" class and you need json for it in resources/assets/modid/blockstates directory and resources/assets/modid/models. You can generate json for it using a tool like misodes model generator. Here, atleast, are blocks explained at forge docs.  Don't forge to look at vanilla code, like Magma Block is a good reference if you're trying a "green fire block".  Modid should be replaced with your actual forge mod namespace!
  • Topics

×
×
  • Create New...

Important Information

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