Jump to content

Recommended Posts

Posted

Hello,

Would someone please tell me how to add a damage source to an entity? Whenever this entity kills someone on a server it crashes because it can't return a damage source.

 

onCollideWithPlayer method:

 

public void onCollideWithPlayer(EntityPlayer var1)
{
	Vec3 var18 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
	Vec3 var19 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
	MovingObjectPosition var4 = this.worldObj.rayTraceBlocks_do_do(var18, var19, false, true);

	if (!this.worldObj.isRemote)
	{
		float var21;

		if (this.inGround && this.shootingEntity == var1 && this.arrowShake <= 0 && var1.inventory.addItemStackToInventory(new ItemStack(Item.arrow, 1)))
		{
			this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			var1.onItemPickup(this, 1);
			this.setDead();

			if (this.knockbackStrength > 0)
			{
				var21 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

				if (var21 > 0.0F)
				{
					var4.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)var21, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)var21);
				}
			}
		}
	}

 

Posted

Post a crash report (=stacktrace) that shows the error and the code that causes the crash. (You said you posted the hitEntity method but you posted onCollideWithPlayer)

Sorry, that's what I meant :3

But the error:

 

---- Minecraft Crash Report ----

// You're mean.

 

Time: 5/13/13 10:59 PM

Description: Ticking entity

 

java.lang.NullPointerException

at net.minecraft.util.EntityDamageSource.getDeathMessage(EntityDamageSource.java:31)

at net.minecraft.util.CombatTracker.func_94546_b(CombatTracker.java:119)

at net.minecraft.entity.player.EntityPlayerMP.onDeath(EntityPlayerMP.java:376)

at net.minecraft.entity.EntityLiving.attackEntityFrom(EntityLiving.java:1126)

at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1075)

at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:453)

at blfngl.fallout.model.EntityBullet.onUpdate(EntityBullet.java:249)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2337)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:717)

at net.minecraft.world.World.updateEntity(World.java:2299)

at net.minecraft.world.World.updateEntities(World.java:2145)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:546)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:652)

at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:275)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:571)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:469)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

 

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

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

 

-- Head --

Stacktrace:

at net.minecraft.util.EntityDamageSource.getDeathMessage(EntityDamageSource.java:31)

at net.minecraft.util.CombatTracker.func_94546_b(CombatTracker.java:119)

at net.minecraft.entity.player.EntityPlayerMP.onDeath(EntityPlayerMP.java:376)

at net.minecraft.entity.EntityLiving.attackEntityFrom(EntityLiving.java:1126)

at net.minecraft.entity.player.EntityPlayer.attackEntityFrom(EntityPlayer.java:1075)

at net.minecraft.entity.player.EntityPlayerMP.attackEntityFrom(EntityPlayerMP.java:453)

at blfngl.fallout.model.EntityBullet.onUpdate(EntityBullet.java:249)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2337)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:717)

at net.minecraft.world.World.updateEntity(World.java:2299)

 

-- Entity being ticked --

Details:

Entity Type: null (blfngl.fallout.model.EntityBullet)

Entity ID: 3297

Entity Name: unknown

Entity's Exact location: -2.66, 65.52, 196.47

Entity's Block location: World: (-3,65,196), Chunk: (at 13,4,4 in -1,12; contains blocks -16,0,192 to -1,255,207), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Entity's Momentum: -35.89, -13.24, 196.41

Stacktrace:

at net.minecraft.world.World.updateEntities(World.java:2145)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:546)

 

-- Affected level --

Details:

Level name: mcpworld

All players: 2 total; [EntityPlayerMP['Player124'/3110, l='mcpworld', x=-2.50, y=64.00, z=196.50], EntityPlayerMP['Player689'/3247, l='mcpworld', x=-3.50, y=64.00, z=202.50]]

Chunk stats: ServerChunkCache: 625 Drop: 0

Level seed: 1611349139

Level generator: ID 02 - largeBiomes, ver 0. Features enabled: true

Level generator options:

Level spawn location: World: (-3,64,194), Chunk: (at 13,4,2 in -1,12; contains blocks -16,0,192 to -1,255,207), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 4020 game time, 4020 day time

Level dimension: 0

Level storage version: 0x04ABD - Anvil

Level weather: Rain time: 34638 (now: false), thunder time: 133971 (now: false)

Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false

Stacktrace:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:652)

at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:275)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:571)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:469)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

 

-- System Details --

Details:

Minecraft Version: 1.5.2

Operating System: Windows 7 (x86) version 6.1

Java Version: 1.7.0_21, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 993897304 bytes (947 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 33754 (1890224 bytes; 1 MB) allocated, 31817 (1781752 bytes; 1 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 10, tcache: 0, allocated: 3, tallocated: 71

FML: MCP v7.51 FML v5.2.2.684 Minecraft Forge 7.8.0.684 4 mods loaded, 4 mods active

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

FML{5.2.2.684} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{7.8.0.684} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

fallout{MC1.5.2 - TFMv1.7.3} [The Fallout Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Profiler Position: N/A (disabled)

Vec3 Pool Size: 3511 (196616 bytes; 0 MB) allocated, 3235 (181160 bytes; 0 MB) used

Player Count: 2 / 10; [EntityPlayerMP['Player124'/3110, l='mcpworld', x=-2.50, y=64.00, z=196.50], EntityPlayerMP['Player689'/3247, l='mcpworld', x=-3.50, y=64.00, z=202.50]]

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

Type: Dedicated Server (map_server.txt)

 

 

Posted

And the code? We need the code that causes the crash (read the stack trace, it has one of your classes in it).

Line 249:

if (var3.entityHit.attackEntityFrom(new EntityDamageSource("player", this.owner), this.damage))

 

Posted

Where is this mysterious var defined?

Horrible variable name btw, have no idea what it is :P

 

Anyways something on that line is null, I'd just set a breakpoint and check what.

But first go read up on Null pointer exceptions, when you know what null is, understanding the crash is way easier.

 

Also if you want more specific help with the code then showing the whole class or atleast the whole scoope would be helpful :P

If you guys dont get it.. then well ya.. try harder...

Posted

@Mazetar: that line doesn't have the NPE. It's just the root of the call to a method that causes the NPE ;)

I'd assume this.owner is null.

Here's the whole thing:

package blfngl.fallout.model;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;

public class EntityBullet extends Entity
{
private int xTile;
private int yTile;
private int zTile;
private int inTile;
private boolean inGround;
public int arrowShake;
public EntityLiving shootingEntity;
private int timeTillDeath;
private int flyTime;
private EntityPlayer owner;
private int damage;
private final float size = 1.0F;
EntityBullet entityBullet;
private int knockbackStrength;

public EntityBullet(World var1)
{
	super(var1);
	this.xTile = -1;
	this.yTile = -1;
	this.zTile = -1;
	this.inTile = 0;
	this.inGround = false;
	this.arrowShake = 0;
	this.flyTime = 0;
	this.setSize(1.0F, 1.0F);
}

public EntityBullet(World var1, double var2, double var4, double var6, double var8, double var10, double var12, EntityPlayer var14)
{
	super(var1);
	this.xTile = -1;
	this.yTile = -1;
	this.zTile = -1;
	this.inTile = 0;
	this.inGround = false;
	this.arrowShake = 0;
	this.flyTime = 0;
	this.setSize(1.0F, 1.0F);
	this.setPosition(var2, var4, var6);
	this.yOffset = 0.0F;
	this.setVelocity(var8, var10, var12);
	this.owner = var14;
}

public EntityBullet(World var1, double var2, double var4, double var6)
{
	super(var1);
	this.xTile = -1;
	this.yTile = -1;
	this.zTile = -1;
	this.inTile = 0;
	this.inGround = false;
	this.arrowShake = 0;
	this.flyTime = 0;
	this.setSize(1.0F, 1.0F);
	this.setPosition(var2, var4, var6);
	this.yOffset = 0.0F;
}

public EntityBullet(World var1, EntityLiving var2, int var3, int var4)
{
	super(var1);
	this.damage = var3;
	this.xTile = -1;
	this.yTile = -1;
	this.zTile = -1;
	this.inTile = 0;
	this.inGround = false;
	this.arrowShake = 0;
	this.flyTime = 0;
	this.shootingEntity = var2;
	this.setSize(1.0F, 1.0F);
	this.setLocationAndAngles(var2.posX, var2.posY + (double)var2.getEyeHeight(), var2.posZ, var2.rotationYaw, var2.rotationPitch);
	this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
	this.posY -= 0.10000000149011612D;
	this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
	this.setPosition(this.posX, this.posY, this.posZ);
	this.yOffset = 0.0F;
	this.motionX = (double)(1000.0F * -MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
	this.motionZ = (double)(1000.0F * MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
	this.motionY = (double)(1000.0F * -MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
	this.setArrowHeading(this.motionX, this.motionY, this.motionZ, 200.0F, 1.5F, var4);
}

protected void entityInit() {}

public void setArrowHeading(double var1, double var3, double var5, float var7, float var8, int var9)
{
	float var10 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
	var1 /= (double)var10;
	var3 /= (double)var10;
	var5 /= (double)var10;
	var1 += this.rand.nextGaussian() * 0.0034999998323619365D * (double)var8 * (double)var9 / 5.0D;
	var3 += this.rand.nextGaussian() * 0.0034999998323619365D * (double)var8 * (double)var9 / 5.0D;
	var5 += this.rand.nextGaussian() * 0.0034999998323619365D * (double)var8 * (double)var9 / 5.0D;
	var1 *= (double)var7;
	var3 *= (double)var7;
	var5 *= (double)var7;
	this.motionX = var1;
	this.motionY = var3;
	this.motionZ = var5;
	float var11 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
	this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(var1, var5) * 180.0D / Math.PI);
	this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(var3, (double)var11) * 180.0D / Math.PI);
	this.timeTillDeath = 0;
}

/**
 * Sets the velocity to the args. Args: x, y, z
 */
public void setVelocity(double var1, double var3, double var5)
{
	this.motionX = var1;
	this.motionY = var3;
	this.motionZ = var5;

	if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
	{
		float var7 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
		this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(var1, var5) * 180.0D / Math.PI);
		this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(var3, (double)var7) * 180.0D / Math.PI);
	}
}

/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
	super.onUpdate();

	if (this.flyTime > 1000)
	{
		this.setDead();
	}

	if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
	{
		float var1 = 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, (double)var1) * 180.0D / Math.PI);
	}

	if (this.arrowShake > 0)
	{
		--this.arrowShake;
	}

	if (this.inGround)
	{
		int var15 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

		if (var15 == this.inTile)
		{
			++this.timeTillDeath;

			if (this.timeTillDeath == 1200)
			{
				this.setDead();
			}

			return;
		}

		this.inGround = false;
		this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
		this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
		this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
		this.timeTillDeath = 0;
		this.flyTime = 0;
	}
	else
	{
		++this.flyTime;
	}

	Vec3 var16 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
	Vec3 var2 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
	MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var16, var2);
	var16 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
	var2 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

	if (var3 != null)
	{
		var2 = Vec3.createVectorHelper(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
	}

	Entity var4 = null;
	List var5 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
	double var6 = 0.0D;
	float var10;

	for (int var8 = 0; var8 < var5.size(); ++var8)
	{
		Entity var9 = (Entity)var5.get(var8);

		if (var9.canBeCollidedWith() && (var9 != this.shootingEntity || this.flyTime >= 5))
		{
			var10 = 0.3F;
			AxisAlignedBB var11 = var9.boundingBox.expand((double)var10, (double)var10, (double)var10);
			MovingObjectPosition var12 = var11.calculateIntercept(var16, var2);

			if (var12 != null)
			{
				double var13 = var16.distanceTo(var12.hitVec);

				if (var13 < var6 || var6 == 0.0D)
				{
					var4 = var9;
					var6 = var13;
				}
			}
		}
	}

	if (var4 != null)
	{
		var3 = new MovingObjectPosition(var4);
	}

	float var17;

	if (var3 != null)
	{
		if (var3.entityHit != null)
		{
			if (var3.entityHit.attackEntityFrom(new EntityDamageSource("player", this.owner), this.damage))
			{
				this.worldObj.playSoundAtEntity(this, "BulletHit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
				this.setDead();
			}
			else
			{
				this.motionX *= 0.10000000149011612D;
				this.motionY *= 0.10000000149011612D;
				this.motionZ *= 0.10000000149011612D;
				this.flyTime = 0;
				this.setDead();
			}
		}
		else
		{
			this.xTile = var3.blockX;
			this.yTile = var3.blockY;
			this.zTile = var3.blockZ;
			this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

			if (this.inTile != Block.glass.blockID && this.inTile != Block.glowStone.blockID && this.inTile != Block.leaves.blockID && this.inTile != Block.thinGlass.blockID)
			{
				this.motionX = (double)((float)(var3.hitVec.xCoord - this.posX));
				this.motionY = (double)((float)(var3.hitVec.yCoord - this.posY));
				this.motionZ = (double)((float)(var3.hitVec.zCoord - this.posZ));
				var17 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
				this.posX -= this.motionX / (double)var17 * 0.05000000074505806D;
				this.posY -= this.motionY / (double)var17 * 0.05000000074505806D;
				this.posZ -= this.motionZ / (double)var17 * 0.05000000074505806D;
				this.worldObj.playSoundAtEntity(this, "Bullet2Hit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
				this.setDead();
			}
			else
			{
				Block var10000 = Block.blocksList[this.inTile];
				this.worldObj.setBlock(this.xTile, this.yTile, this.zTile, 0);
			}
		}
	}

	this.posX += this.motionX * 3.0D;
	this.posY += this.motionY * 3.0D;
	this.posZ += this.motionZ * 3.0D;
	var17 = 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, (double)var17) * 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;
	float var18 = 0.99F;
	var10 = 0.03F;

	if (this.handleWaterMovement())
	{
		for (int var19 = 0; var19 < 4; ++var19)
		{
			float var20 = 0.25F;
			this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)var20, this.posY - this.motionY * (double)var20, this.posZ - this.motionZ * (double)var20, this.motionX, this.motionY, this.motionZ);
		}

		var18 = 0.8F;
	}

	this.motionX *= (double)var18;
	this.motionY *= (double)var18;
	this.motionZ *= (double)var18;
	this.setPosition(this.posX, this.posY, this.posZ);
}

/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound var1)
{
	var1.setShort("xTile", (short)this.xTile);
	var1.setShort("yTile", (short)this.yTile);
	var1.setShort("zTile", (short)this.zTile);
	var1.setByte("inTile", (byte)this.inTile);
	var1.setByte("shake", (byte)this.arrowShake);
	var1.setByte("inGround", (byte)(this.inGround ? 1 : 0));
}

/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound var1)
{
	this.xTile = var1.getShort("xTile");
	this.yTile = var1.getShort("yTile");
	this.zTile = var1.getShort("zTile");
	this.inTile = var1.getByte("inTile") & 255;
	this.arrowShake = var1.getByte("shake") & 255;
	this.inGround = var1.getByte("inGround") == 1;
}

/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer var1)
{
	Vec3 var18 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
	Vec3 var19 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
	MovingObjectPosition var4 = this.worldObj.rayTraceBlocks_do_do(var18, var19, false, true);

	if (!this.worldObj.isRemote)
	{
		float var21;

		if (this.inGround && this.shootingEntity == var1 && this.arrowShake <= 0 && var1.inventory.addItemStackToInventory(new ItemStack(Item.arrow, 1)))
		{
			this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			var1.onItemPickup(this, 1);
			this.setDead();

			if (this.knockbackStrength > 0)
			{
				var21 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

				if (var21 > 0.0F)
				{
					var4.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)var21, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)var21);
				}
			}
		}
	}
}

public void setKnockbackStrength(int var1)
{
	this.knockbackStrength = 2;
}

public float getShadowSize()
{
	return 0.0F;
}
}

 

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

    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I&#39;m not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
  • Topics

×
×
  • Create New...

Important Information

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