Issues with sand

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

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

    Taco

    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:

    Code:java
    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(EntityTrackerEntry.java:348
    4. )
    5. at net.minecraft.server.EntityTrackerEntry.b(EntityTrackerEntry.java:191
    6. )
    7. at net.minecraft.server.EntityTrackerEntry.scanPlayers(EntityTrackerEntr
    8. y.java:232)
    9. at net.minecraft.server.EntityTracker.addEntity(EntityTracker.java:97)
    10. at net.minecraft.server.EntityTracker.track(EntityTracker.java:69)
    11. at net.minecraft.server.WorldManager.a(WorldManager.java:16)
    12. at net.minecraft.server.World.c(World.java:920)
    13. at net.minecraft.server.WorldServer.c(WorldServer.java:175)
    14. at net.minecraft.server.World.addEntity(World.java:913)
    15. at org.bukkit.craftbukkit.CraftWorld.spawn(CraftWorld.java:861)
    16. at org.bukkit.craftbukkit.CraftWorld.spawn(CraftWorld.java:695)
    17. at com.FriedTaco.taco.MorePhysics.MorePhysicsBlockListener.onBlockPiston
    18. Extend(MorePhysicsBlockListener.java:67)
    19. ... 21 more


    With this code:

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



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

    Code:java
    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:

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

    Jogy34

    you could try:
    Code:
    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

    Taco

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

    Jogy34

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

    Taco

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

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

    darklust

  7. Offline

    Taco

    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.

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

    Shamebot

    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

    Taco

    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: https://github.com/FriedTaco/MorePhysics/tree/master/MorePhysics/src/com/FriedTaco/taco/MorePhysics
     
  10. Offline

    Shamebot

    Strange. That's how minecraft does it: https://github.com/Bukkit/CraftBukk.../java/net/minecraft/server/BlockSand.java#L32
    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
    Code:
    EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, x, y,z, 12, 0);
    world.addEntity(entityfallingblock);
    and see if it works.

    Edit: x,y,z
     
  11. Offline

    Taco

    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

    Taco

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

    matejdro

    Were you able to solve this?
     
  14. Offline

    Taco

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

Share This Page