Issues with sand

Discussion in 'Plugin Development' started by Taco, Feb 21, 2012.

Thread Status:
Not open for further replies.
  1. Offline


    I'm not sure if this is due to unimplemented code or what, but sand is impossible to work with without a bukkit entity. I'm getting this error:

    1. Caused by: java.lang.IllegalArgumentException: Don't know how to add class net.m
    2. inecraft.server.EntityFallingBlock!
    3. at net.minecraft.server.EntityTrackerEntry.b(
    4. )
    5. at net.minecraft.server.EntityTrackerEntry.b(
    6. )
    7. at net.minecraft.server.EntityTrackerEntry.scanPlayers(EntityTrackerEntr
    9. at net.minecraft.server.EntityTracker.addEntity(
    10. at net.minecraft.server.EntityTracker.track(
    11. at net.minecraft.server.WorldManager.a(
    12. at net.minecraft.server.World.c(
    13. at net.minecraft.server.WorldServer.c(
    14. at net.minecraft.server.World.addEntity(
    15. at org.bukkit.craftbukkit.CraftWorld.spawn(
    16. at org.bukkit.craftbukkit.CraftWorld.spawn(
    17. at com.FriedTaco.taco.MorePhysics.MorePhysicsBlockListener.onBlockPiston
    18. Extend(
    19. ... 21 more

    With this code:

    1. w.spawn(b.get(i).getLocation(), FallingSand.class);

    Additionally, this code, which USED to work, produces no results:

    1. EntityFallingBlock sand = new EntityFallingBlock(cWorld,b.get(i).getX(),b.get(i).getY(),b.get(i).getZ(),id,b.get(i).getData());
    2. Entity e = sand.getBukkitEntity();
    3. e.teleport(e.getLocation().add(.5,1.5,.5));
    4. cWorld.addEntity(sand);
    5. Vector vel = sand.getBukkitEntity().getVelocity();
    6. vel.add(new Vector(0,10,0));
    7. sand.getBukkitEntity().setVelocity(vel);

    The variable cWorld there is defined as follows:

    1. net.minecraft.server.World cWorld = ((CraftWorld)event.getBlock().getWorld()).getHandle();
  2. Offline


    you could try:
    Block block = World.getBlockAt(*LOCATION* or *X,Y,Z*);
    block.setTypeId(Material.SAND, true); //the true should apply the physics to the sand
  3. Offline


    I'm trying to make the sand move upwards like it used to. Here's my old demo vid:
  4. Offline


    In that case I have no clue how to help you with that, however what I think your doing wrong with this:
    w.spawn(b.get(i).getLocation(), FallingSand.class);
    is that FallingSand is an interface not a class
  5. Offline


    That's not an issue. You can use this with no issue, and Fireball.class is also an interface.

    Fireball f = w.spawn(b.get(i).getLocation(), Fireball.class);
  6. Offline


  7. Offline


    I don't see why not. This is in spawn() on line 748-749. If I'm missing something, please point out why it can't be used.

            } else if (FallingSand.class.isAssignableFrom(clazz)) {
                entity = new EntityFallingBlock(world, x, y, z, 0, 0);
  8. Offline


    The exception is thrown in minecraft code. Minecraft expects the id field to be either 12 or 13 (sand or gravel) but craftbukkit passes 0.
  9. Offline


    That makes sense. Though why doesn't my original code (in my first post) work? It simply stopped working when the minecraft code changed from EntityFallingSand to EntityFallingBlock even though I pass in the id and data properly. I'm not asking for anyone to write the code for me, of course. I'm simply wondering where my error is.

    I've pushed my current code to my github if context helps any. Here:
  10. Offline


    Strange. That's how minecraft does it:
    I looket at the code of the bukkit methods you're calling and they shouldn't make a difference, should they?
    Maybe try it with just
    EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, x, y,z, 12, 0);
    and see if it works.

    Edit: x,y,z
  11. Offline


    I'll give that a shot when I get home today. I'll report back with my results.

    It doesn't seem to be adding the falling sand entity for some reason.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 24, 2016
  12. Offline


    Hate to bump this, but I'm still stumped.
  13. Offline


    Were you able to solve this?
  14. Offline


    Not yet.
Thread Status:
Not open for further replies.

Share This Page