Jump to content

[1.19.2] Possible Custom Entity causing crash


tal124

Recommended Posts

I have created a custom entity called Chocolate Slime, The bug has occurred since I created it, and stops when I remove it, however I see no reason for the crash, but the crash log says a lot of things that I'm unsure of how it connects.

Crash Log:

Spoiler
---- Minecraft Crash Report ----
// You're mean.

Time: 2022-09-27 16:50:38
Description: Ticking entity

java.lang.NullPointerException: Registry Object not present: forge:entity_gravity
	at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
	at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:204) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23182%23189!/:?] {re:classloading}
	at net.minecraft.world.entity.LivingEntity.travel(LivingEntity.java:2172) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.LivingEntity.aiStep(LivingEntity.java:2740) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.Mob.aiStep(Mob.java:545) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.entity.LivingEntity.tick(LivingEntity.java:2439) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.Mob.tick(Mob.java:344) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.entity.ambient.Bat.tick(Bat.java:116) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:667) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.Level.guardEntityTick(Level.java:494) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:326) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:306) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:896) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:836) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:90) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:672) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:244) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:833) [?:?] {}


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

-- Head --
Thread: Server thread
Stacktrace:
	at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
	at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:204) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23182%23189!/:?] {re:classloading}
	at net.minecraft.world.entity.LivingEntity.travel(LivingEntity.java:2172) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.LivingEntity.aiStep(LivingEntity.java:2740) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.Mob.aiStep(Mob.java:545) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.entity.LivingEntity.tick(LivingEntity.java:2439) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.world.entity.Mob.tick(Mob.java:344) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.entity.ambient.Bat.tick(Bat.java:116) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:667) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.Level.guardEntityTick(Level.java:494) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:326) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:306) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
-- Entity being ticked --
Details:
	Entity Type: minecraft:bat (net.minecraft.world.entity.ambient.Bat)
	Entity ID: 1
	Entity Name: Bat
	Entity's Exact location: -22.50, -40.00, 262.50
	Entity's Block location: World: (-23,-40,262), Section: (at 9,8,6 in -2,-3,16; chunk contains blocks -32,-64,256 to -17,319,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,-64,0 to -1,319,511)
	Entity's Momentum: 0.00, -0.07, -0.05
	Entity's Passengers: []
	Entity's Vehicle: null
Stacktrace:
	at net.minecraft.world.level.Level.guardEntityTick(Level.java:494) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.level.ServerLevel.lambda$tick$3(ServerLevel.java:326) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:53) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading}
	at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:306) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:896) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:836) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:90) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:672) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:244) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:833) [?:?] {}


-- Affected level --
Details:
	All players: 0 total; []
	Chunk stats: 2209
	Level dimension: minecraft:overworld
	Level spawn location: World: (-32,63,288), Section: (at 0,15,0 in -2,3,18; chunk contains blocks -32,-64,288 to -17,319,303), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,-64,0 to -1,319,511)
	Level time: 18 game time, 18 day time
	Level name: New World
	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
	Level weather: Rain time: 110257 (now: false), thunder time: 37588 (now: false)
	Known server brands: forge
	Level was modded: true
	Level storage version: 0x04ABD - Anvil
Stacktrace:
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:896) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:836) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:90) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:672) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:244) ~[forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1.19.2-recomp.jar%23183!/:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:833) [?:?] {}


-- System Details --
Details:
	Minecraft Version: 1.19.2
	Minecraft Version ID: 1.19.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 17.0.4, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode, sharing), Oracle Corporation
	Memory: 533706416 bytes (508 MiB) / 1707081728 bytes (1628 MiB) up to 8577351680 bytes (8180 MiB)
	CPUs: 24
	Processor Vendor: AuthenticAMD
	Processor Name: AMD Ryzen 9 3900X 12-Core Processor            
	Identifier: AuthenticAMD Family 23 Model 113 Stepping 0
	Microarchitecture: Zen 2
	Frequency (GHz): 3.79
	Number of physical packages: 1
	Number of physical CPUs: 12
	Number of logical CPUs: 24
	Graphics card #0 name: NVIDIA GeForce GTX 1080
	Graphics card #0 vendor: NVIDIA (0x10de)
	Graphics card #0 VRAM (MB): 4095.00
	Graphics card #0 deviceId: 0x1b80
	Graphics card #0 versionInfo: DriverVersion=31.0.15.1659
	Memory slot #0 capacity (MB): 16384.00
	Memory slot #0 clockSpeed (GHz): 3.60
	Memory slot #0 type: DDR4
	Memory slot #1 capacity (MB): 16384.00
	Memory slot #1 clockSpeed (GHz): 3.60
	Memory slot #1 type: DDR4
	Virtual memory max (MB): 37579.29
	Virtual memory used (MB): 29895.96
	Swap memory total (MB): 4864.00
	Swap memory used (MB): 247.20
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	Server Running: true
	Player Count: 0 / 8; []
	Data Packs: vanilla, mod:forge, mod:jei (incompatible), mod:chocolate (incompatible)
	World Generation: Stable
	Type: Integrated Server (map_client.txt)
	Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'
	Launched Version: MOD_DEV
	ModLauncher: 10.0.8+10.0.8+main.0ef7e830
	ModLauncher launch target: forgeclientuserdev
	ModLauncher naming: mcp
	ModLauncher services: 
		mixin-0.8.5.jar mixin PLUGINSERVICE 
		eventbus-6.0.3.jar eventbus PLUGINSERVICE 
		fmlloader-1.19.2-43.1.27.jar slf4jfixer PLUGINSERVICE 
		fmlloader-1.19.2-43.1.27.jar object_holder_definalize PLUGINSERVICE 
		fmlloader-1.19.2-43.1.27.jar runtime_enum_extender PLUGINSERVICE 
		fmlloader-1.19.2-43.1.27.jar capability_token_subclass PLUGINSERVICE 
		accesstransformers-8.0.4.jar accesstransformer PLUGINSERVICE 
		fmlloader-1.19.2-43.1.27.jar runtimedistcleaner PLUGINSERVICE 
		modlauncher-10.0.8.jar mixin TRANSFORMATIONSERVICE 
		modlauncher-10.0.8.jar fml TRANSFORMATIONSERVICE 
	FML Language Providers: 
		minecraft@1.0
		lowcodefml@null
		javafml@null
	Mod List: 
		forge-1.19.2-43.1.27_mapped_parchment_2022.09.18-1|Minecraft                     |minecraft                     |1.19.2              |DONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
		                                                  |Forge                         |forge                         |43.1.27             |DONE      |Manifest: NOSIGNATURE
		jei-1.19.2-forge-11.3.0.262_mapped_parchment_2022.|Just Enough Items             |jei                           |11.3.0.262          |DONE      |Manifest: NOSIGNATURE
		main                                              |Chocolate                     |chocolate                     |0.0NONE             |DONE      |Manifest: NOSIGNATURE
	Crash Report UUID: 5d8f5e20-791c-49e3-8ee4-5e4e6be793b2
	FML: 43.1
	Forge: net.minecraftforge:43.1.27

 

ChocolateSlime.class:

Spoiler
public class ChocolateSlime extends Mob implements Enemy {

    private static final EntityDataAccessor<Integer> ID_SIZE = SynchedEntityData.defineId(ChocolateSlime.class, EntityDataSerializers.INT);
    public static final int MIN_SIZE = 1;
    public static final int MAX_SIZE = 127;
    public float targetSquish;
    public float squish;
    public float oSquish;
    private boolean wasOnGround;

    public ChocolateSlime(EntityType<? extends Mob> pEntityType, Level pLevel) {
        super(pEntityType, pLevel);
        this.moveControl = new ChocolateSlime.SlimeMoveControl(this);
    }

    public static AttributeSupplier setAttributes() {
        return ChocolateSlime.createMobAttributes()
                .add(Attributes.ATTACK_DAMAGE, 3)
                .add(Attributes.MOVEMENT_SPEED, 3)
                .add(Attributes.MAX_HEALTH, 3).build();

    }

    protected void registerGoals() {
        this.goalSelector.addGoal(1, new ChocolateSlime.SlimeFloatGoal(this));
        this.goalSelector.addGoal(2, new ChocolateSlime.SlimeAttackGoal(this));
        this.goalSelector.addGoal(3, new ChocolateSlime.SlimeRandomDirectionGoal(this));
        this.goalSelector.addGoal(5, new ChocolateSlime.SlimeKeepOnJumpingGoal(this));
        this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (p_33641_) -> {
            return Math.abs(p_33641_.getY() - this.getY()) <= 4.0D;
        }));
        this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
    }

    protected void defineSynchedData() {
        super.defineSynchedData();
        this.entityData.define(ID_SIZE, 1);
    }

    @VisibleForTesting
    public void setSize(int pSize, boolean pResetHealth) {
        int i = Mth.clamp(pSize, 1, 127);
        this.entityData.set(ID_SIZE, i);
        this.reapplyPosition();
        this.refreshDimensions();
        this.getAttribute(Attributes.MAX_HEALTH).setBaseValue((double)(i * i));
        this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue((double)(0.2F + 0.1F * (float)i));
        this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue((double)i);
        if (pResetHealth) {
            this.setHealth(this.getMaxHealth());
        }

        this.xpReward = i;
    }

    public int getSize() {
        return this.entityData.get(ID_SIZE);
    }

    public void addAdditionalSaveData(CompoundTag pCompound) {
        super.addAdditionalSaveData(pCompound);
        pCompound.putInt("Size", this.getSize() - 1);
        pCompound.putBoolean("wasOnGround", this.wasOnGround);
    }

    public void readAdditionalSaveData(CompoundTag pCompound) {
        this.setSize(pCompound.getInt("Size") + 1, false);
        super.readAdditionalSaveData(pCompound);
        this.wasOnGround = pCompound.getBoolean("wasOnGround");
    }

    public boolean isTiny() {
        return this.getSize() <= 1;
    }

    protected ParticleOptions getParticleType() {
        return ParticleTypes.ITEM_SLIME;
    }

    protected boolean shouldDespawnInPeaceful() {
        return this.getSize() > 0;
    }

    public void tick() {
        this.squish += (this.targetSquish - this.squish) * 0.5F;
        this.oSquish = this.squish;
        super.tick();
        if (this.onGround && !this.wasOnGround) {
            int i = this.getSize();

            if (spawnCustomParticles()) i = 0; // don't spawn particles if it's handled by the implementation itself
            for(int j = 0; j < i * 8; ++j) {
                float f = this.random.nextFloat() * ((float)Math.PI * 2F);
                float f1 = this.random.nextFloat() * 0.5F + 0.5F;
                float f2 = Mth.sin(f) * (float)i * 0.5F * f1;
                float f3 = Mth.cos(f) * (float)i * 0.5F * f1;
                this.level.addParticle(this.getParticleType(), this.getX() + (double)f2, this.getY(), this.getZ() + (double)f3, 0.0D, 0.0D, 0.0D);
            }

            this.playSound(this.getSquishSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
            this.targetSquish = -0.5F;
        } else if (!this.onGround && this.wasOnGround) {
            this.targetSquish = 1.0F;
        }

        this.wasOnGround = this.onGround;
        this.decreaseSquish();
    }

    protected void decreaseSquish() {
        this.targetSquish *= 0.6F;
    }

    protected int getJumpDelay() {
        return this.random.nextInt(20) + 10;
    }

    public void refreshDimensions() {
        double d0 = this.getX();
        double d1 = this.getY();
        double d2 = this.getZ();
        super.refreshDimensions();
        this.setPos(d0, d1, d2);
    }

    public void onSyncedDataUpdated(EntityDataAccessor<?> pKey) {
        if (ID_SIZE.equals(pKey)) {
            this.refreshDimensions();
            this.setYRot(this.yHeadRot);
            this.yBodyRot = this.yHeadRot;
            if (this.isInWater() && this.random.nextInt(20) == 0) {
                this.doWaterSplashEffect();
            }
        }

        super.onSyncedDataUpdated(pKey);
    }

    public EntityType<? extends ChocolateSlime> getType() {
        return (EntityType<? extends ChocolateSlime>)super.getType();
    }

    public void remove(Entity.RemovalReason pReason) {
        int i = this.getSize();
        if (!this.level.isClientSide && i > 1 && this.isDeadOrDying()) {
            Component component = this.getCustomName();
            boolean flag = this.isNoAi();
            float f = (float)i / 4.0F;
            int j = i / 2;
            int k = 2 + this.random.nextInt(3);

            for(int l = 0; l < k; ++l) {
                float f1 = ((float)(l % 2) - 0.5F) * f;
                float f2 = ((float)(l / 2) - 0.5F) * f;
                ChocolateSlime slime = this.getType().create(this.level);
                if (this.isPersistenceRequired()) {
                    slime.setPersistenceRequired();
                }

                slime.setCustomName(component);
                slime.setNoAi(flag);
                slime.setInvulnerable(this.isInvulnerable());
                slime.setSize(j, true);
                slime.moveTo(this.getX() + (double)f1, this.getY() + 0.5D, this.getZ() + (double)f2, this.random.nextFloat() * 360.0F, 0.0F);
                this.level.addFreshEntity(slime);
            }
        }

        super.remove(pReason);
    }

    public void push(Entity pEntity) {
        super.push(pEntity);
        if (pEntity instanceof IronGolem && this.isDealsDamage()) {
            this.dealDamage((LivingEntity)pEntity);
        }

    }

    public void playerTouch(Player pEntity) {
        if (this.isDealsDamage()) {
            this.dealDamage(pEntity);
        }

    }

    protected void dealDamage(LivingEntity pLivingEntity) {
        if (this.isAlive()) {
            int i = this.getSize();
            if (this.distanceToSqr(pLivingEntity) < 0.6D * (double)i * 0.6D * (double)i && this.hasLineOfSight(pLivingEntity) && pLivingEntity.hurt(DamageSource.mobAttack(this), this.getAttackDamage())) {
                this.playSound(SoundEvents.SLIME_ATTACK, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
                this.doEnchantDamageEffects(this, pLivingEntity);
            }
        }

    }

    protected float getStandingEyeHeight(Pose pPose, EntityDimensions pSize) {
        return 0.625F * pSize.height;
    }

    protected boolean isDealsDamage() {
        return !this.isTiny() && this.isEffectiveAi();
    }

    protected float getAttackDamage() {
        return (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
    }

    protected SoundEvent getHurtSound(DamageSource pDamageSource) {
        return this.isTiny() ? SoundEvents.SLIME_HURT_SMALL : SoundEvents.SLIME_HURT;
    }

    protected SoundEvent getDeathSound() {
        return this.isTiny() ? SoundEvents.SLIME_DEATH_SMALL : SoundEvents.SLIME_DEATH;
    }

    protected SoundEvent getSquishSound() {
        return this.isTiny() ? SoundEvents.SLIME_SQUISH_SMALL : SoundEvents.SLIME_SQUISH;
    }

    public static boolean checkSlimeSpawnRules(EntityType<ChocolateSlime> pSlime, LevelAccessor pLevel, MobSpawnType pSpawnType, BlockPos pPos, RandomSource pRandom) {
        if (pLevel.getDifficulty() != Difficulty.PEACEFUL) {
            if (pLevel.getBiome(pPos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) && pPos.getY() > 50 && pPos.getY() < 70 && pRandom.nextFloat() < 0.5F && pRandom.nextFloat() < pLevel.getMoonBrightness() && pLevel.getMaxLocalRawBrightness(pPos) <= pRandom.nextInt(8)) {
                return checkMobSpawnRules(pSlime, pLevel, pSpawnType, pPos, pRandom);
            }

            if (!(pLevel instanceof WorldGenLevel)) {
                return false;
            }

            ChunkPos chunkpos = new ChunkPos(pPos);
            boolean flag = WorldgenRandom.seedSlimeChunk(chunkpos.x, chunkpos.z, ((WorldGenLevel)pLevel).getSeed(), 987234911L).nextInt(10) == 0;
            if (pRandom.nextInt(10) == 0 && flag && pPos.getY() < 40) {
                return checkMobSpawnRules(pSlime, pLevel, pSpawnType, pPos, pRandom);
            }
        }

        return false;
    }

    protected float getSoundVolume() {
        return 0.4F * (float)this.getSize();
    }

    public int getMaxHeadXRot() {
        return 0;
    }

    protected boolean doPlayJumpSound() {
        return this.getSize() > 0;
    }

    protected void jumpFromGround() {
        Vec3 vec3 = this.getDeltaMovement();
        this.setDeltaMovement(vec3.x, (double)this.getJumpPower(), vec3.z);
        this.hasImpulse = true;
    }

    @Nullable
    public SpawnGroupData finalizeSpawn(ServerLevelAccessor pLevel, DifficultyInstance pDifficulty, MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData, @Nullable CompoundTag pDataTag) {
        RandomSource randomsource = pLevel.getRandom();
        int i = randomsource.nextInt(3);
        if (i < 2 && randomsource.nextFloat() < 0.5F * pDifficulty.getSpecialMultiplier()) {
            ++i;
        }

        int j = 1 << i;
        this.setSize(j, true);
        return super.finalizeSpawn(pLevel, pDifficulty, pReason, pSpawnData, pDataTag);
    }

    float getSoundPitch() {
        float f = this.isTiny() ? 1.4F : 0.8F;
        return ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * f;
    }

    protected SoundEvent getJumpSound() {
        return this.isTiny() ? SoundEvents.SLIME_JUMP_SMALL : SoundEvents.SLIME_JUMP;
    }

    public EntityDimensions getDimensions(Pose pPose) {
        return super.getDimensions(pPose).scale(0.255F * (float)this.getSize());
    }

    protected boolean spawnCustomParticles() { return false; }

    static class SlimeAttackGoal extends Goal {
        private final ChocolateSlime slime;
        private int growTiredTimer;

        public SlimeAttackGoal(ChocolateSlime pSlime) {
            this.slime = pSlime;
            this.setFlags(EnumSet.of(Goal.Flag.LOOK));
        }

        public boolean canUse() {
            LivingEntity livingentity = this.slime.getTarget();
            if (livingentity == null) {
                return false;
            } else {
                return !this.slime.canAttack(livingentity) ? false : this.slime.getMoveControl() instanceof ChocolateSlime.SlimeMoveControl;
            }
        }

        public void start() {
            this.growTiredTimer = reducedTickDelay(300);
            super.start();
        }

        public boolean canContinueToUse() {
            LivingEntity livingentity = this.slime.getTarget();
            if (livingentity == null) {
                return false;
            } else if (!this.slime.canAttack(livingentity)) {
                return false;
            } else {
                return --this.growTiredTimer > 0;
            }
        }

        public boolean requiresUpdateEveryTick() {
            return true;
        }

        public void tick() {
            LivingEntity livingentity = this.slime.getTarget();
            if (livingentity != null) {
                this.slime.lookAt(livingentity, 10.0F, 10.0F);
            }

            ((ChocolateSlime.SlimeMoveControl)this.slime.getMoveControl()).setDirection(this.slime.getYRot(), this.slime.isDealsDamage());
        }
    }

    static class SlimeFloatGoal extends Goal {
        private final ChocolateSlime slime;

        public SlimeFloatGoal(ChocolateSlime pSlime) {
            this.slime = pSlime;
            this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
            pSlime.getNavigation().setCanFloat(true);
        }

        public boolean canUse() {
            return (this.slime.isInWater() || this.slime.isInLava()) && this.slime.getMoveControl() instanceof ChocolateSlime.SlimeMoveControl;
        }

        public boolean requiresUpdateEveryTick() {
            return true;
        }

        public void tick() {
            if (this.slime.getRandom().nextFloat() < 0.8F) {
                this.slime.getJumpControl().jump();
            }

            ((ChocolateSlime.SlimeMoveControl)this.slime.getMoveControl()).setWantedMovement(1.2D);
        }
    }

    static class SlimeKeepOnJumpingGoal extends Goal {
        private final ChocolateSlime slime;

        public SlimeKeepOnJumpingGoal(ChocolateSlime pSlime) {
            this.slime = pSlime;
            this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE));
        }

        public boolean canUse() {
            return !this.slime.isPassenger();
        }

        public void tick() {
            ((ChocolateSlime.SlimeMoveControl)this.slime.getMoveControl()).setWantedMovement(1.0D);
        }
    }

    static class SlimeMoveControl extends MoveControl {
        private float yRot;
        private int jumpDelay;
        private final ChocolateSlime slime;
        private boolean isAggressive;

        public SlimeMoveControl(ChocolateSlime pSlime) {
            super(pSlime);
            this.slime = pSlime;
            this.yRot = 180.0F * pSlime.getYRot() / (float)Math.PI;
        }

        public void setDirection(float pYRot, boolean pAggressive) {
            this.yRot = pYRot;
            this.isAggressive = pAggressive;
        }

        public void setWantedMovement(double pSpeed) {
            this.speedModifier = pSpeed;
            this.operation = MoveControl.Operation.MOVE_TO;
        }

        public void tick() {
            this.mob.setYRot(this.rotlerp(this.mob.getYRot(), this.yRot, 90.0F));
            this.mob.yHeadRot = this.mob.getYRot();
            this.mob.yBodyRot = this.mob.getYRot();
            if (this.operation != MoveControl.Operation.MOVE_TO) {
                this.mob.setZza(0.0F);
            } else {
                this.operation = MoveControl.Operation.WAIT;
                if (this.mob.isOnGround()) {
                    this.mob.setSpeed((float)(this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED)));
                    if (this.jumpDelay-- <= 0) {
                        this.jumpDelay = this.slime.getJumpDelay();
                        if (this.isAggressive) {
                            this.jumpDelay /= 3;
                        }

                        this.slime.getJumpControl().jump();
                        if (this.slime.doPlayJumpSound()) {
                            this.slime.playSound(this.slime.getJumpSound(), this.slime.getSoundVolume(), this.slime.getSoundPitch());
                        }
                    } else {
                        this.slime.xxa = 0.0F;
                        this.slime.zza = 0.0F;
                        this.mob.setSpeed(0.0F);
                    }
                } else {
                    this.mob.setSpeed((float)(this.speedModifier * this.mob.getAttributeValue(Attributes.MOVEMENT_SPEED)));
                }

            }
        }
    }

    static class SlimeRandomDirectionGoal extends Goal {
        private final ChocolateSlime slime;
        private float chosenDegrees;
        private int nextRandomizeTime;

        public SlimeRandomDirectionGoal(ChocolateSlime pSlime) {
            this.slime = pSlime;
            this.setFlags(EnumSet.of(Goal.Flag.LOOK));
        }

        public boolean canUse() {
            return this.slime.getTarget() == null && (this.slime.onGround || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof ChocolateSlime.SlimeMoveControl;
        }

        public void tick() {
            if (--this.nextRandomizeTime <= 0) {
                this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60));
                this.chosenDegrees = (float)this.slime.getRandom().nextInt(360);
            }

            ((ChocolateSlime.SlimeMoveControl)this.slime.getMoveControl()).setDirection(this.chosenDegrees, false);
        }
    }

}

 

Registration of Class:

Spoiler
public class ModEntities {

    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MODID);

    //Attaches the deferred register to the event bus
    public static void init() { ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus()); }

    public static final RegistryObject<EntityType<ChocolateSlime>> CHOCOLATE_SLIME = ENTITIES.register("chocolate_slime",
            ()-> EntityType.Builder.of(ChocolateSlime::new, MobCategory.MONSTER)
                    .sized(2.04F, 2.04F)
                    .build(new ResourceLocation(MODID, "chocolate_slime").toString()));

}

 

Main Rendering & Attribute Creation:

Spoiler
private void Client(final FMLClientSetupEvent event) { //I'm not really sure what is really going to go in here anymore
        // do something that can only be done on the client

        event.enqueueWork(()-> {
            /*** Block Rendering, Looks to be Deprecated? All done in the Json Files now, kinda makes my life easier ***/

            // Entity Rendering
            LOGGER.info(LOGGERMODID("Rendering Entity Layers"));
            EntityRenderers.register(ModEntities.CHOCOLATE_SLIME.get(), ChocolateSlimeRenderer::new);

            //Fluid Rendering
            //LOGGER.info(LOGGERMODID("Rendering Fluid Layers"));

        });
    }
    @SubscribeEvent
    public static void entityAttributeEvent(EntityAttributeCreationEvent event) {
        event.put(ModEntities.CHOCOLATE_SLIME.get(), ChocolateSlime.setAttributes());
    }

 

ChocolateSlimeRenderer.class:

Spoiler
@OnlyIn(Dist.CLIENT)
public class ChocolateSlimeRenderer extends MobRenderer<ChocolateSlime, SlimeModel<ChocolateSlime>> {
    private static final ResourceLocation SLIME_LOCATION = new ResourceLocation(MODID,"textures/entity/chocolate_slime.png");

    public ChocolateSlimeRenderer(EntityRendererProvider.Context p_174391_) {
        super(p_174391_, new SlimeModel<>(p_174391_.bakeLayer(ModelLayers.SLIME)), 0.25F);
        this.addLayer(new SlimeOuterLayer<>(this, p_174391_.getModelSet()));
    }

    public void render(ChocolateSlime pEntity, float pEntityYaw, float pPartialTicks, PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight) {
        this.shadowRadius = 0.25F * (float)pEntity.getSize();
        super.render(pEntity, pEntityYaw, pPartialTicks, pMatrixStack, pBuffer, pPackedLight);
    }

    protected void scale(ChocolateSlime pLivingEntity, PoseStack pMatrixStack, float pPartialTickTime) {
        float f = 0.999F;
        pMatrixStack.scale(0.999F, 0.999F, 0.999F);
        pMatrixStack.translate(0.0D, (double)0.001F, 0.0D);
        float f1 = (float)pLivingEntity.getSize();
        float f2 = Mth.lerp(pPartialTickTime, pLivingEntity.oSquish, pLivingEntity.squish) / (f1 * 0.5F + 1.0F);
        float f3 = 1.0F / (f2 + 1.0F);
        pMatrixStack.scale(f3 * f1, 1.0F / f3 * f1, f3 * f1);
    }

    public ResourceLocation getTextureLocation(ChocolateSlime pEntity) {
        return SLIME_LOCATION;
    }
}

 

 

Edited by tal124
Spoilers
Link to comment
Share on other sites

I'm going to take a guess and say you don't call your init method anywhere. If not, then you need to provide more context for your mod.

Additionally, entity renderers must be registered through `EntityRenderersEvent$RegisterRenderers#registerEntityRenderer`. Also, stick to only one method of subscribing events to the mod bus.

You should never use OnlyIn. This is an annotation specifically for internal use only by Forge.

Link to comment
Share on other sites

56 minutes ago, ChampionAsh5357 said:

I'm going to take a guess and say you don't call your init method anywhere. If not, then you need to provide more context for your mod.

Additionally, entity renderers must be registered through `EntityRenderersEvent$RegisterRenderers#registerEntityRenderer`. Also, stick to only one method of subscribing events to the mod bus.

You should never use OnlyIn. This is an annotation specifically for internal use only by Forge.

My Init Method is called in my main class, along with all of my other deferred registers.

 

My issue isn't so much that I'm unable to spawn the slime (Im not able too) but that the game CTDs after about 20 seconds of creating a new world, and instantly upon trying to enter it again.

 

I will try the entity renderer method tomorrow, and could you describe the methods of attaching the subscribing events? I've been working on this pretty much on my own, with very little guidance other than source code. So it would be very helpful

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 was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

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