Development Assistance Custom FallingSand disappears.

Discussion in 'Plugin Help/Development/Requests' started by TeamSER, Jan 4, 2015.

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

    TeamSER

    Hello,

    I have been trying to make a plugin that spawns a custom fallingsand entity, which works fine, more or less. The only problem is that the custom fallingsand disappears after about half a second. What do I do to make a proper fallingsand entity that doesn't disappear?

    This is my main class:
    Main class (open)
    Code:java
    1. package p;
    2.  
    3. import net.minecraft.server.v1_7_R1.World;
    4.  
    5. import org.bukkit.Location;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class TestFire extends JavaPlugin{
    13. public void onEnable() {}
    14.  
    15. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    16. if (cmd.getName().equalsIgnoreCase("fire")) {
    17. Player player = (Player) sender;
    18. World world = ((CraftWorld) player.getWorld()).getHandle();
    19. Location loc = player.getEyeLocation();
    20. loc.add(loc.getDirection());
    21. CustomFire myFire = new CustomFire(loc, loc.getDirection());
    22. world.addEntity(myFire);
    23. }
    24. return false;
    25. }
    26.  
    27. public void onDisable() {}
    28. }


    And this is my custom fallingsand entity:
    Custom entity (open)
    Code:java
    1. package p;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
    5. import org.bukkit.util.Vector;
    6.  
    7. import net.minecraft.server.v1_7_R1.Blocks;
    8. import net.minecraft.server.v1_7_R1.EntityFallingBlock;
    9.  
    10. public class CustomFire extends EntityFallingBlock {
    11. public CustomFire(Location loc, Vector vec) {
    12. super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ(), Blocks.FIRE);
    13. this.motX = vec.getX();
    14. this.motY = vec.getY();
    15. this.motZ = vec.getZ();
    16. this.ticksLived = 20;
    17. }
    18. }
     
  2. Offline

    thepluginbros

    Register your class! :)
     
  3. Offline

    TeamSER

    Thank you for the quick reply. @thepluginbros
    Could anyone point me to a source which explains how to register entities?
    I have been trying to use
    Show Spoiler
    Code:java
    1. try {
    2. Method a = EntityTypes.class.getDeclaredMethod("a", Class.class, String.class, int.class);
    3. a.setAccessible(true);
    4. a.invoke(a, CustomFire.class, "FallingSand", 21);
    5. } catch (Exception e) {
    6. e.printStackTrace();
    7. }
    but it gives me an InvocationTargetException.
     
Thread Status:
Not open for further replies.

Share This Page