Velocity on blocks?

Discussion in 'Plugin Development' started by CookCreeperz, Feb 24, 2013.

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

    CookCreeperz

    When a snowball hits, I want to make an explosion 5 blocks around, and turn the blocks into sand but still have their texture, then they fall back down in different locations. Any ideas on where I should start?
     
  2. Offline

    gamerzap

    Listen to ProjectileHitEvent, get the world and generate an explosion at the location where the projectile hits if it is a snowball, spawn FallingBlock's at the location of the destroyed blocks, and then set their velocities and type-ids. Have fun!
     
  3. Offline

    CookCreeperz

    :D Thanks!

    What would I put in for the byte? And how can I get the blocks it hit?

    Code:
            @EventHandler
            public void OnProjectileHi1t(ProjectileHitEvent e){
                Entity e1 = e.getEntity();
                Location loc = e1.getLocation();
                if(e1 instanceof Egg){
                    Bukkit.getWorld("world").createExplosion(loc, 3.0f);
                    FallingBlock blo = Bukkit.getWorld("world").spawnFallingBlock(loc, something, (byte) 1);
                    Vector v = blo.getVelocity();
                    v.multiply(4.0F);
    Im lost already LOL

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

    gamerzap

    I'm not sure... you might need to listen to the EntityExplosionEvent and get the blocklist, but I don't know how you would check to see if the snowball created it... maybe check if the explosion power is 3.0?
     
  5. Offline

    CookCreeperz

    Ok. well how could I just make dirt fly up a couple blocks where the explosion was?

    Bump

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

    ZeusAllMighty11

    You could get the location of blocks around where the snowball hit, on ProjectileHitEvent

    Just do a simple iteration over blocks around the hit location, and use World.getBlockAt() method
     
  7. Offline

    CookCreeperz

    Ok. Got iterator. How would I get the blocks around the projectile's hit point?
    Code so far:

    Code:
            @EventHandler
            public void OnProjectileHi1t(ProjectileHitEvent e){
                Entity e1 = e.getEntity();
                Location loc = e1.getLocation();
                if(e1 instanceof Egg){
                    List<Block> rblocks = Arrays.asList(loc.getBlock());
                    Iterator<Block> it = rblocks.iterator();
                    while(it.hasNext()){
                        Block block1 = it.next();
                        block1.breakNaturally();
                    }
                }
     
            }
    }
    How do I get the nearby blocks and then spawn them as falling and launch them 4 blocks in the air?

    Got this, now how would I turn them into falling blocks and launch them?????
    Code:
            @EventHandler
            public void OnProjectileHi1t(ProjectileHitEvent e){
                Entity e1 = e.getEntity();
                Location loc = e1.getLocation();
                if(e1 instanceof Egg){
                    int radius = 5;
                    for(int x = -radius; x <= radius; x++) {
                        for(int y = -radius; y <= radius; y++) {
                            for(int z = -radius; z <= radius; z++) {
                                Block blocks = loc.getBlock().getRelative(x,y,z);
                    List<Block> rblocks = Arrays.asList(loc.getBlock().getRelative(x,y,z));
                    Iterator<Block> it = rblocks.iterator();
                    while(it.hasNext()){
                        Block block1 = it.next();
                        Bukkit.getServer().getWorld("world").spawnFallingBlock(loc, blocks, (byte) 1);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  8. Offline

    ZeusAllMighty11

    Store the type of block, and then spawn falling block entities with the type from each block stored, and set a velocity to them?
     
  9. Offline

    CookCreeperz

    pseudo? Kinda new to java :p not really sure how to do that
     
  10. Offline

    ZeusAllMighty11

    I don't even know if my method will work, or if it's too much work or whatever


    But to store, you can store the material of the blocks with block.getType() and store it in some kind of array or set or whatever

    And to set a velocity

    entity.setVelocity(new Vector(x,y,z));
     
  11. Offline

    CookCreeperz

    How to get I get the blocks from the list? What type of list? Dosen't let me change a blocks velocity. Code:
    Code:
            @EventHandler
            public void OnProjectileHi1t(ProjectileHitEvent e){
                Entity e1 = e.getEntity();
                Location loc = e1.getLocation();
                if(e1 instanceof Egg){               
                    int radius = 2;
                    for(int x = -radius; x <= radius; x++) {
                        for(int y = -radius; y <= radius; y++) {
                            for(int z = -radius; z <= radius; z++) {
                                Block blocks = loc.getBlock().getRelative(x,y,z);
                    List<Block> rblocks = Arrays.asList(loc.getBlock().getRelative(x,y,z));
                    Iterator<Block> it = rblocks.iterator();
                    while(it.hasNext()){
                        Block block1 = it.next();
                        Bukkit.getServer().getWorld("world");
     
  12. are you trying to create the explode effect from smash? (game made by the same guy of minez)
     
  13. Offline

    CookCreeperz

    Sorta
    Yeah.
     
  14. Offline

    chasechocolate

    Loop through the affected blocks, and use the code to spawn falling blocks and launch them up with:
    Code:java
    1. fallingBlock.setVelocity(new Vector(0, 0.4, 0));
     
  15. Offline

    CookCreeperz

    Man i've been trying for hours. What am I doing wrong????
    Code:
    @EventHandler
                    public void OnProjectileHi1t(ProjectileHitEvent e){
                        Entity e1 = e.getEntity();
                        Location loc = e1.getLocation();
                        if(e1 instanceof Egg){             
                            int radius = 2;
                            for(int x = -radius; x <= radius; x++) {
                                for(int y = -radius; y <= radius; y++) {
                                    for(int z = -radius; z <= radius; z++) {
                                        Block blocks = loc.getBlock().getRelative(x,y,z);
                            List<Block> rblocks = Arrays.asList(loc.getBlock().getRelative(x,y,z));
                            Iterator<Block> it = rblocks.iterator();
                            while(it.hasNext()){
                                Block block1 = it.next();
                                block1.breakNaturally(null);
                               
                                Bukkit.getServer().getWorld("world").spawnFallingBlock((Location) blocks, block1.getType(), (byte) 1);
     
  16. Offline

    chasechocolate

    CookCreeperz You're never setting the velocity, and you're casting Location to blocks.
     
  17. Offline

    CookCreeperz

    Doesn't let me cast to location
     
  18. Offline

    fireblast709

    Because a Block is not a Location. How about this:
    Code:
    @EventHandler
    public void OnProjectileHi1t(ProjectileHitEvent e)
    {
        Entity e1 = e.getEntity();
        Location loc = e1.getLocation();
        if(e1 instanceof Egg)
        {             
            int radius = 2;
            Material type;
            FallingBlock falling;
            Vector v;
            for(int x = -radius; x <= radius; x++) 
            {
                for(int y = -radius; y <= radius; y++) 
                {
                    for(int z = -radius; z <= radius; z++) 
                    {
                        v = new Vector(x,y,z);
                        if(v.length() < radius)
                        {
                            Block block = loc.getBlock().getRelative(x,y,z);
                            type = block.getType();
                            block.breakNaturally();
                            falling = Bukkit.getServer().getWorld("world").spawnFallingBlock(block.getLocation(), type, (byte) 1);
                            falling.setVelocity(v.normalize());
                        }
                    }
                }
            }
        }
    }
     
  19. Offline

    CookCreeperz

    crashes my minecraft?
     
  20. Offline

    stirante

    Bad luck brian xD

    We could do more if you would post stack trace.
     
  21. Offline

    CookCreeperz

    Code:
     
          Minecraft has crashed!     
          ----------------------     
     
    Minecraft has stopped running because it encountered a problem; Unexpected error
     
    A full error report has been saved to C:\Users\Jordan\AppData\Roaming\.minecraft\crash-reports\crash-2013-02-26_20.26.05-client.txt - Please include a copy of that file (Not this screen!) if you report this crash to anyone; without it, they will not be able to help fix the crash :(
     
     
     
    --- BEGIN ERROR REPORT f3d6a92 --------
    Full report at:
    C:\Users\Jordan\AppData\Roaming\.minecraft\crash-reports\crash-2013-02-26_20.26.05-client.txt
    Please show that file to Mojang, NOT just this screen!
     
    Generated 2/26/13 8:26 PM
     
    -- Head --
    Stacktrace:
        at tz.a(Unknown Source)
        at T.a(Unknown Source)
        at T.a(Unknown Source)
        at nk.a(Unknown Source)
        at nk.a(Unknown Source)
        at mN.a(Unknown Source)
        at mF.a(Unknown Source)
     
    -- Affected level --
    Details:
        Level name: MpServer
        All players: 1 total; [lI['CookCreeperz'/299, l='MpServer', x=-245.27, y=73.62, z=251.54]]
        Chunk stats: MultiplayerChunkCache: 441
        Level seed: 0
        Level generator: ID 00 - default, ver 1. Features enabled: false
        Level generator options:
        Level spawn location: World: (-256,64,244), Chunk: (at 0,4,4 in -16,15; contains blocks -256,0,240 to -241,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
        Level time: 36290 game time, 36290 day time
        Level dimension: 0
        Level storage version: 0x00000 - Unknown?
        Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
        Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
        Forced entities: 131 total; [lI['CookCreeperz'/299, l='MpServer', x=-245.27, y=73.62, z=251.54], zH['Zombie'/258, l='MpServer', x=-172.75, y=47.00, z=258.66], zH['Zombie'/259, l='MpServer', x=-167.00, y=19.00, z=310.34], zH['Zombie'/260, l='MpServer', x=-167.00, y=19.00, z=310.34], zl['Falling Block'/516, l='MpServer', x=-254.50, y=73.50, z=253.50], zm['item.tile.dirt'/517, l='MpServer', x=-253.28, y=72.13, z=251.72], zl['Falling Block'/518, l='MpServer', x=-253.50, y=71.50, z=251.50], zm['item.tile.dirt'/519, l='MpServer', x=-253.69, y=72.13, z=252.69], zm['item.tile.dirt'/512, l='MpServer', x=-254.38, y=73.13, z=253.28], zl['Falling Block'/513, l='MpServer', x=-254.50, y=72.50, z=253.50], zl['Falling Block'/514, l='MpServer', x=-254.50, y=73.50, z=251.50], zl['Falling Block'/515, l='MpServer', x=-254.50, y=73.50, z=252.50], zl['Falling Block'/524, l='MpServer', x=-253.50, y=72.50, z=252.50], zl['Falling Block'/525, l='MpServer', x=-253.50, y=72.50, z=253.50], zl['Falling Block'/526, l='MpServer', x=-253.50, y=73.50, z=251.50], zl['Falling Block'/527, l='MpServer', x=-253.50, y=73.50, z=252.50], zl['Falling Block'/520, l='MpServer', x=-253.50, y=71.50, z=252.50], zm['item.tile.dirt'/521, l='MpServer', x=-253.75, y=72.13, z=253.41], zl['Falling Block'/522, l='MpServer', x=-253.50, y=71.50, z=253.50], zl['Falling Block'/523, l='MpServer', x=-253.50, y=72.50, z=251.50], zH['Zombie'/318, l='MpServer', x=-194.50, y=36.00, z=331.50], zl['Falling Block'/533, l='MpServer', x=-252.50, y=71.50, z=252.50], zm['item.tile.dirt'/532, l='MpServer', x=-252.63, y=72.13, z=252.47], zl['Falling Block'/535, l='MpServer', x=-252.50, y=71.50, z=253.50], zm['item.tile.dirt'/534, l='MpServer', x=-252.72, y=72.13, z=253.69], zm['item.tile.dirt'/529, l='MpServer', x=-252.81, y=72.13, z=251.34], zl['Falling Block'/528, l='MpServer', x=-253.50, y=73.50, z=253.50], zl['Falling Block'/531, l='MpServer', x=-252.50, y=71.50, z=251.50], zm['item.item.seeds'/530, l='MpServer', x=-252.28, y=72.81, z=251.19], zl['Falling Block'/541, l='MpServer', x=-252.50, y=73.50, z=253.50], zl['Falling Block'/540, l='MpServer', x=-252.50, y=73.50, z=252.50], zl['Falling Block'/537, l='MpServer', x=-252.50, y=72.50, z=252.50], zl['Falling Block'/536, l='MpServer', x=-252.50, y=72.50, z=251.50], zl['Falling Block'/539, l='MpServer', x=-252.50, y=73.50, z=251.50], zl['Falling Block'/538, l='MpServer', x=-252.50, y=72.50, z=253.50], zs['Creeper'/341, l='MpServer', x=-221.50, y=21.00, z=277.50], zD['Skeleton'/332, l='MpServer', x=-183.50, y=46.00, z=230.50], zD['Skeleton'/333, l='MpServer', x=-180.50, y=46.00, z=226.50], zH['Zombie'/123, l='MpServer', x=-315.66, y=44.00, z=250.63], zH['Zombie'/122, l='MpServer', x=-304.31, y=17.00, z=224.22], yf['Chicken'/137, l='MpServer', x=-264.47, y=62.00, z=221.44], zH['Zombie'/139, l='MpServer', x=-287.22, y=52.00, z=256.50], zs['Creeper'/138, l='MpServer', x=-273.69, y=57.00, z=241.30], zH['Zombie'/140, l='MpServer', x=-281.00, y=14.00, z=285.53], yg['Cow'/129, l='MpServer', x=-300.50, y=72.00, z=197.50], zH['Zombie'/131, l='MpServer', x=-294.38, y=56.00, z=251.03], yg['Cow'/130, l='MpServer', x=-297.72, y=70.00, z=198.69], zs['Creeper'/132, l='MpServer', x=-297.97, y=62.00, z=253.56], zH['Zombie'/154, l='MpServer', x=-240.50, y=40.00, z=194.50], zH['Zombie'/155, l='MpServer', x=-244.09, y=58.00, z=202.84], zm['item.item.rottenFlesh'/156, l='MpServer', x=-250.38, y=19.13, z=222.88], zH['Zombie'/157, l='MpServer', x=-240.84, y=25.00, z=212.22], zH['Zombie'/158, l='MpServer', x=-245.03, y=59.00, z=203.56], yf['Chicken'/159, l='MpServer', x=-247.53, y=72.00, z=248.53], yg['Cow'/149, l='MpServer', x=-269.44, y=63.00, z=186.38], zD['Skeleton'/150, l='MpServer', x=-258.50, y=21.00, z=198.50], yg['Cow'/151, l='MpServer', x=-270.50, y=63.00, z=218.27], zs['Creeper'/441, l='MpServer', x=-221.41, y=20.00, z=172.00], zF['Spider'/443, l='MpServer', x=-221.50, y=20.00, z=174.50], zF['Spider'/445, l='MpServer', x=-188.84, y=44.00, z=235.16], zs['Creeper'/446, l='MpServer', x=-182.97, y=36.00, z=241.59], zs['Creeper'/447, l='MpServer', x=-183.93, y=44.00, z=232.78], zH['Zombie'/163, l='MpServer', x=-244.47, y=19.00, z=299.34], zH['Zombie'/162, l='MpServer', x=-244.47, y=19.00, z=299.34], zH['Zombie'/161, l='MpServer', x=-249.16, y=21.00, z=293.59], yg['Cow'/160, l='MpServer', x=-240.75, y=71.00, z=246.84], zH['Zombie'/186, l='MpServer', x=-235.03, y=26.00, z=232.38], zH['Zombie'/187, l='MpServer', x=-234.00, y=26.00, z=233.56], zH['Zombie'/184, l='MpServer', x=-226.97, y=61.00, z=219.03], zH['Zombie'/185, l='MpServer', x=-238.69, y=23.00, z=227.84], zm['item.item.rottenFlesh'/190, l='MpServer', x=-234.59, y=22.13, z=294.09], zH['Zombie'/188, l='MpServer', x=-228.56, y=27.00, z=237.50], yf['Chicken'/189, l='MpServer', x=-230.38, y=69.00, z=243.68], zH['Zombie'/178, l='MpServer', x=-239.66, y=21.00, z=196.75], zm['item.item.rottenFlesh'/179, l='MpServer', x=-228.19, y=66.13, z=197.59], zH['Zombie'/177, l='MpServer', x=-234.94, y=22.00, z=197.53], yg['Cow'/182, l='MpServer', x=-236.59, y=58.00, z=222.28], zm['item.item.rottenFlesh'/183, l='MpServer', x=-237.56, y=59.13, z=217.59], zm['item.item.rottenFlesh'/180, l='MpServer', x=-228.72, y=66.13, z=193.97], yg['Cow'/181, l='MpServer', x=-239.38, y=64.00, z=192.41], zD['Skeleton'/204, l='MpServer', x=-213.31, y=18.00, z=314.06], yX['Squid'/201, l='MpServer', x=-212.05, y=58.09, z=259.34], yg['Cow'/200, l='MpServer', x=-214.50, y=71.00, z=212.69], zH['Zombie'/203, l='MpServer', x=-209.53, y=26.00, z=275.09], zs['Creeper'/202, l='MpServer', x=-217.50, y=26.00, z=283.50], yg['Cow'/199, l='MpServer', x=-212.84, y=69.00, z=199.78], zm['item.item.rottenFlesh'/198, l='MpServer', x=-208.34, y=38.13, z=193.13], zH['Zombie'/195, l='MpServer', x=-216.47, y=20.00, z=173.75], zH['Zombie'/194, l='MpServer', x=-216.47, y=20.00, z=173.75], zH['Zombie'/220, l='MpServer', x=-202.69, y=42.00, z=239.72], zH['Zombie'/221, l='MpServer', x=-205.59, y=44.00, z=236.94], zE['Slime'/222, l='MpServer', x=-193.86, y=38.00, z=240.69], yd['Bat'/461, l='MpServer', x=-194.88, y=37.42, z=228.16], zH['Zombie'/223, l='MpServer', x=-194.00, y=13.00, z=275.94], yg['Cow'/216, l='MpServer', x=-204.09, y=60.00, z=221.94], zH['Zombie'/217, l='MpServer', x=-189.50, y=23.00, z=231.09], zH['Zombie'/218, l='MpServer', x=-202.78, y=20.00, z=229.66], zH['Zombie'/219, l='MpServer', x=-201.09, y=28.00, z=237.53], zH['Zombie'/212, l='MpServer', x=-206.09, y=18.00, z=192.31], zm['item.item.rottenFlesh'/213, l='MpServer', x=-207.88, y=38.13, z=196.91], zm['item.item.rottenFlesh'/214, l='MpServer', x=-199.72, y=63.13, z=192.22], yg['Cow'/215, l='MpServer', x=-192.22, y=63.00, z=199.28], zm['item.item.rottenFlesh'/210, l='MpServer', x=-196.16, y=18.13, z=191.94], zs['Creeper'/448, l='MpServer', x=-241.50, y=32.00, z=221.50], zH['Zombie'/211, l='MpServer', x=-199.94, y=18.00, z=188.41], zl['Falling Block'/508, l='MpServer', x=-254.50, y=71.50, z=253.50], zl['Falling Block'/509, l='MpServer', x=-254.50, y=72.50, z=251.50], zm['item.tile.dirt'/510, l='MpServer', x=-254.81, y=73.13, z=252.75], zl['Falling Block'/511, l='MpServer', x=-254.50, y=72.50, z=252.50], zl['Falling Block'/504, l='MpServer', x=-254.50, y=71.50, z=251.50], zH['Zombie'/234, l='MpServer', x=-194.25, y=37.00, z=320.06], zm['item.tile.dirt'/505, l='MpServer', x=-254.56, y=72.13, z=252.69], zH['Zombie'/233, l='MpServer', x=-185.91, y=35.00, z=324.50], zl['Falling Block'/506, l='MpServer', x=-254.50, y=71.50, z=252.50], zm['item.tile.dirt'/507, l='MpServer', x=-254.44, y=72.13, z=253.19], zs['Creeper'/230, l='MpServer', x=-204.53, y=35.00, z=310.06], zH['Zombie'/229, l='MpServer', x=-197.84, y=23.00, z=315.69], Aa['unknown'/502, l='MpServer', x=-254.75, y=72.58, z=252.95], zH['Zombie'/228, l='MpServer', x=-197.84, y=23.00, z=315.69], zm['item.tile.dirt'/503, l='MpServer', x=-254.56, y=72.13, z=251.44], zH['Zombie'/227, l='MpServer', x=-202.25, y=28.00, z=274.84], zH['Zombie'/226, l='MpServer', x=-192.78, y=30.00, z=276.06], zH['Zombie'/225, l='MpServer', x=-197.34, y=12.00, z=273.44], zH['Zombie'/224, l='MpServer', x=-203.91, y=12.00, z=276.31], zH['Zombie'/250, l='MpServer', x=-177.53, y=48.00, z=267.09], zH['Zombie'/251, l='MpServer', x=-177.63, y=23.00, z=296.31], zH['Zombie'/248, l='MpServer', x=-191.13, y=47.00, z=234.03], zH['Zombie'/249, l='MpServer', x=-191.13, y=47.00, z=234.03], zH['Zombie'/246, l='MpServer', x=-189.50, y=21.00, z=227.31], zH['Zombie'/247, l='MpServer', x=-185.50, y=27.00, z=229.06], zH['Zombie'/245, l='MpServer', x=-186.25, y=49.00, z=187.13]]
        Retry entities: 0 total; []
    Stacktrace:
        at lF.a(Unknown Source)
        at net.minecraft.client.Minecraft.a(Unknown Source)
        at net.minecraft.client.Minecraft.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
     
    -- System Details --
    Details:
        Minecraft Version: 1.4.6
        Operating System: Windows 7 (amd64) version 6.1
        Java Version: 1.7.0_10, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 367394600 bytes (350 MB) / 514523136 bytes (490 MB) up to 954466304 bytes (910 MB)
        JVM Flags: 2 total; -Xms512m -Xmx1024m
        AABB Pool Size: 9778 (547568 bytes; 0 MB) allocated, 1348 (75488 bytes; 0 MB) used
        Suspicious classes: [net.minecraft.client.a]
        IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
        LWJGL: 2.4.2
        OpenGL: GeForce GTX 660 Ti/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation
        Is Modded: Very likely; Jar signature invalidated
        Type: Client (map_client.txt)
        Texture Pack: Default
        Profiler Position: N/A (disabled)
        Vec3 Pool Size: 1021 (57176 bytes; 0 MB) allocated, 293 (16408 bytes; 0 MB) used
     
    java.lang.NullPointerException
        at tz.a(Unknown Source)
        at T.a(Unknown Source)
        at T.a(Unknown Source)
        at nk.a(Unknown Source)
        at nk.a(Unknown Source)
        at mN.a(Unknown Source)
        at mF.a(Unknown Source)
        at mF.b(Unknown Source)
        at net.minecraft.client.Minecraft.aY(Unknown Source)
        at net.minecraft.client.Minecraft.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
    --- END ERROR REPORT db157590 ----------
     
    
     
  22. Offline

    fireblast709

    It seems it has something to do with a bow shooting sound, so I doubt it has something to do with my code directly
     
  23. Offline

    stirante

    tz class is ItemEgg. Method 'a' is onItemRightClick and it looks like that:
    Code:
            if (!par3EntityPlayer.capabilities.isCreativeMode)
            {
                --par1ItemStack.stackSize;
            }
     
            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
     
            if (!par2World.isRemote)
            {
                par2World.spawnEntityInWorld(new EntityEgg(par2World, par3EntityPlayer));
            }
     
            return par1ItemStack;
    par1ItemStack, par3EntityPlayer or par2World is null. What code exactly done that?
     
  24. Offline

    CookCreeperz

    How am I going to fix this?

    No, happened with my earlier code.

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

    CookCreeperz

  26. Offline

    CookCreeperz

    It works! But only if you throw it down a hole????
    Digi
     
  27. CookCreeperz
    I don't understand what you mean by that.
    You should post your current code and explain how it does not work properly.
     
  28. Offline

    CookCreeperz

    Code:
            @EventHandler
            public void OnProjectileHi1t(ProjectileHitEvent e)
            {
              Entity e1 = e.getEntity();
              Location loc = e1.getLocation();
                if(e1 instanceof Egg)
                {                           
                  int radius = 2;
                    Material type;
                    FallingBlock falling;
                    Vector v;
                    for(int x = -radius; x <= radius; x++)
                    {
                        for(int y = -radius; y <= radius; y++)
                      {
                            for(int z = -radius; z <= radius; z++)
                          {
                                v = new Vector(x,y,z);
                              if(v.length() < radius)
                              {
                                    Block block = loc.getBlock().getRelative(x,y,z);
                                  type = block.getType();
                                    falling = Bukkit.getServer().getWorld("world").spawnFallingBlock(block.getLocation(), type, (byte) 1);
                                    falling.setVelocity(new Vector(0f, 1f, 1f).normalize());
                              }
                            }
                    }
                    }
                }
                }
    }
    It only works if you throw the egg down a hole, such as a ladder. Everything else with the blocks is working.
     
  29. First of all: Bukkit.getServer().getWorld("world") That's really bad, use entity's or block's world.

    I tried to test your code and it seems it's doing something because throwing an egg anywhere just crashes my game, so I can't help further.
     
  30. Offline

    CookCreeperz

    Dang.
     
Thread Status:
Not open for further replies.

Share This Page