Jump to content

Entity Collide With Error


AzureusNation123

Recommended Posts

Hey

 

Ive got my portal and telepoter kinda working but whenever i touch my portal block it Crashes minecraft with this:

 

 

 

2013-02-03 15:15:26 [iNFO] [ForgeModLoader] Unloading dimension 0

2013-02-03 15:15:26 [iNFO] [ForgeModLoader] Unloading dimension -1

2013-02-03 15:15:26 [iNFO] [ForgeModLoader] Unloading dimension 1

2013-02-03 15:15:26 [iNFO] [ForgeModLoader] Unloading dimension 2

2013-02-03 15:15:26 [iNFO] [sTDERR] java.lang.ClassCastException: net.minecraft.client.particle.EntityDiggingFX cannot be cast to net.minecraft.entity.player.EntityPlayerMP

2013-02-03 15:15:26 [iNFO] [sTDERR] at skycraft.blocks.PortalBlock.onEntityCollidedWithBlock(PortalBlock.java:46)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.entity.Entity.doBlockCollisions(Entity.java:1011)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.entity.Entity.moveEntity(Entity.java:955)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.client.particle.EntityFX.onUpdate(EntityFX.java:145)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.client.particle.EffectRenderer.updateEffects(EffectRenderer.java:90)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1903)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:846)

2013-02-03 15:15:26 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:771)

2013-02-03 15:15:26 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

2013-02-03 15:15:36 [iNFO] [sTDOUT] Stopping!

2013-02-03 15:15:36 [iNFO] [sTDOUT] SoundSystem shutting down...

2013-02-03 15:15:37 [iNFO] [sTDOUT]    Author: Paul Lamb, www.paulscode.com

 

 

 

Here's my portal block code:

 

 

 

package skycraft.blocks;

 

import java.util.Iterator;

import java.util.List;

import java.util.Random;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.entity.Entity;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.item.Item;

import net.minecraft.item.ItemMonsterPlacer;

import net.minecraft.item.ItemStack;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import skycraft.SkyCraft;

import skycraft.SkyCraftBlocks;

import skycraft.core.client.ClientProxySkyCraft;

import skycraft.core.common.CommonProxySkyCraft;

import skycraft.skydimension.SkyTeleporter;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class PortalBlock extends Block

{

public PortalBlock(int id, int texture, Material material)

    {

    super(id, texture, material);

    this.setBlockName("Portal");

    this.setStepSound(Block.soundGlassFootstep);

    this.setLightValue(0.75F);

    this.setHardness(-1.0F);

    this.setCreativeTab(SkyCraft.tabSkyCraftBlocks);

    this.setTickRandomly(true);

    }

 

public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)

{

if (par5Entity.ridingEntity == null && par5Entity.riddenByEntity == null)

{

  if (par5Entity instanceof EntityPlayerMP)

  {

   

  }

  EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity;

  if (par5Entity.dimension != SkyCraft.dimension)

  {

  thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, SkyCraft.dimension, new SkyTeleporter(thePlayer.mcServer.worldServerForDimension(SkyCraft.dimension)));

  }

  else

  {

  thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new SkyTeleporter(thePlayer.mcServer.worldServerForDimension(0)));

  }

}

}

 

    public int getRenderBlockPass()

    {

        return 1;

    }

   

    public boolean isOpaqueCube()

    {

        return false;

    }

   

    public boolean renderAsNormalBlock()

    {

        return false;

    }

   

    public int quantityDropped(Random par1Random)

    {

        return 0;

    }

   

    //Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been cleared to be reused)

    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

        return null;

    }

 

    //Updates the blocks bounds based on its current state. Args: world, x, y, z

    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        if (par1IBlockAccess.getBlockId(par2 - 1, par3, par4) != this.blockID && par1IBlockAccess.getBlockId(par2 + 1, par3, par4) != this.blockID)

        {

            this.setBlockBounds(0F, 0.4F, 0F, 1F, 0.6F, 1F);

        }

        else

        {

            this.setBlockBounds(0F, 0.4F, 0F, 1F, 0.6F, 1F);

        }

    }

 

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

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

        {

            double var7 = (double)((float)par2 + par5Random.nextFloat());

            double var9 = (double)((float)par3 + par5Random.nextFloat());

            double var11 = (double)((float)par4 + par5Random.nextFloat());

            double var13 = 0.0D;

            double var15 = 0.0D;

            double var17 = 0.0D;

            int var19 = par5Random.nextInt(2) * 2 - 1;

            var13 = ((double)par5Random.nextFloat() - 0.5D) * 0.5D;

            var15 = ((double)par5Random.nextFloat() - 0.5D) * 0.5D;

            var17 = ((double)par5Random.nextFloat() - 0.5D) * 0.5D;

 

            if (par1World.getBlockId(par2 - 1, par3, par4) != this.blockID && par1World.getBlockId(par2 + 1, par3, par4) != this.blockID)

            {

                var7 = (double)par2 + 0.5D + 0.25D * (double)var19;

                var13 = (double)(par5Random.nextFloat() * 2.0F * (float)var19);

            }

            else

            {

                var11 = (double)par4 + 0.5D + 0.25D * (double)var19;

                var17 = (double)(par5Random.nextFloat() * 2.0F * (float)var19);

            }

 

        }

    }

   

    //Pistons can move block = 0

    //Pistons can move on top of block = 1

    //Pistons can't move at all = 2

    public int getMobilityFlag()

    {

        return 2;

    }

   

    //Only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem

    public int idPicked(World par1World, int par2, int par3, int par4)

    {

        return 0;

    }

   

    public String getTextureFile()

    {

        return CommonProxySkyCraft.Blocks_PNG;

    }

 

}

 

 

 

Link to comment
Share on other sites

The error you are getting is " java.lang.ClassCastException: net.minecraft.client.particle.EntityDiggingFX cannot be cast to net.minecraft.entity.player.EntityPlayerMP"

 

And from the log you see that it gets it right after this:

at skycraft.blocks.PortalBlock.onEntityCollidedWithBlock(PortalBlock.java:46)

 

So while trying to preform the onEntityCollidedWithBlock()  method in the PortalBlock file on line 46.

It caused this error.

 

Let's check line 46 of that file and see what it says? :)

 

Pasting your code into www.pastebin.com and setting Syntax Highlighting to Java, makes it a lot easier for others to read your code files :)

Here I created one for your code:

http://pastebin.com/cCsGd37f

 

 

Looking at line 46 it seems you are doing this:

EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity;

 

Which is causing the crash, since the par5Entity is NOT an EntityPlayerMP but an different Entity. And you are telling it to use that entity as a EntityPlayerMP!

 

What you need to do is to do a check before you do the rest of the code to see IF the par5Entity IS a EntityPlayerMP at all. To do this I suggest the following change:

 

if (par5Entity instanceof EntityPlayerMP)

{

  // All the code from line 46 untill line  54.

}

 

Now that I read the whole file, I notice that you ahve this check on line 42 but the code is not inside it, so you just need to move the whole code block into the if block :)

 

 

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

Link to comment
Share on other sites

One often get blind by one's own code, it's hard to see simple mistakes when it's your own code :)

You might want to check up on how a stack trace can help you with debugging, just the few lines that indicates which lines crashed it and why helps you a lot inn finding such problems ;)

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

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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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