Portal Effects

Discussion in 'Plugin Development' started by wowlover6877, Oct 23, 2012.

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

    wowlover6877

    Does anyone know how to give the 'nether portal' effect?
     
  2. Offline

    KeybordPiano459

    The best way would probably be to give the player the nausea potion effect.
     
  3. Offline

    wowlover6877

    KeybordPiano459
    Yes, that is a good idea, it came to mind. But how would you make the players screen to slightly glow purple, like it does when you enter a portal.
     
  4. Offline

    KeybordPiano459

    I have no idea... maybe try spawning a portal block where the player is and set it to air after a scheduler happens?
     
    bobacadodl likes this.
  5. Offline

    wowlover6877

  6. Offline

    Woobie

    What if the player is moving?
     
  7. Offline

    wowlover6877

    Woobie
    I think I'll use PlayerMoveEvent. Whenever player moves it will create a new portal
     
  8. Offline

    Woobie

    It would look a bit weird to have portal blocks following you.
     
  9. Offline

    KeybordPiano459

    I dunno, I haven't thought this through at all :p Also, if you can think of anything better, go ahead :D
     
  10. Offline

    wowlover6877

    Woobie
    KeybordPiano459
    This is what I've got so far, it makes a trail of portals blocks follow you, but then they dissapear. so no landscape griefing.
    PHP:
        @EventHandler
        
    public void CakePlace(PlayerMoveEvent e) {
            
    Location l e.getPlayer().getLocation();
            
    World w l.getWorld();
            final 
    Block b w.getBlockAt(l);
            
    b.setType(Material.PORTAL);
            
    int taskID Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask((Pluginthis, new Runnable() {
     
                public 
    void run() {
                    
    b.setType(Material.AIR);
     
     
     
                }
            }, 
    40L0);
     
        }
    Sadly, I keep getting this error every time I move:
    Code:
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:341)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:218)
        at net.minecraft.server.Packet10Flying.handle(SourceFile:136)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:282)
        at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:111)
        at net.minecraft.server.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:561)
        at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
        at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.ClassCastException: Freedom.CakeCommand cannot be cast to org.bukkit.plugin.Plugin
        at Freedom.CakeCommand.CakePlace(CakeCommand.java:24)
        at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:339)
        ... 14 more
     
  11. Offline

    Woobie

    Line 24 pls.
    EDIT: You are using repeating task, change it to delayed task!
    ---------------

    Not sure if this exists
    Code:
    player.getWorld().playEffect(player.getLocation(), Effect.PORTAL); 
     
  12. Offline

    wowlover6877

    Woobie
    It doesn't exist :( Heres line 24
    PHP:
            int taskID Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask((Pluginthis, new Runnable() {
     
  13. Offline

    KeybordPiano459

    Woobie
    Nobody can solve anything by looking at one line of code, so wowlover6877 can you point out what line in the class that you showed us is line 24? A comment would be nice. Also, could you replace the CODE tags with SYNTAX=java please?

    Sigh of course you wrote that as I was writing my post. Still go with the SYNTAX=java tags.

    I'm pretty sure you need to get rid of int taskID =.

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

    Woobie

    read my edit.
    No, you use that to stop the task if you want. Its no harm, but useless.

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

    KeybordPiano459

    Well still, try it. I've never done anything like that before.
     
  16. Offline

    wowlover6877

    KeybordPiano459
    Woobie
    I'm still getting same error. I changed the Schedules Task to this:
    Code:java
    1. Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask((Plugin) this, new Runnable() {
    2.  
    3. public void run() {
    4. b.setType(Material.AIR);
    5.  
    6.  
    7.  
    8. }
    9. }, 20L);
     
  17. Offline

    KeybordPiano459

    Change it from (Plugin)this to plugin, and at the top of your class (under public class <name>) make a constructor that says something like:
    Code:java
    1. <PluginName> plugin;
    2. public <ClassName>(<PluginName> plugin) {
    3. this.plugin = plugin;
    4. }


    Without the < and >s

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

    wowlover6877

    KeybordPiano459
    EDIT: It gets rid of the errors, but it doesn't work anymore. Theres no more portals spawning
    Code:java
    1. package Freedom;
    2.  
    3. import org.bukkit.*;
    4. import org.bukkit.block.Block;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerMoveEvent;
    8.  
    9. public class VoidCommand implements Listener {
    10. Freedom plugin;
    11.  
    12. public VoidCommand(Freedom plugin) {
    13. this.plugin = plugin;
    14. }
    15.  
    16. @EventHandler
    17. public void PortalPlace(PlayerMoveEvent e) {
    18. Location l = e.getPlayer().getLocation();
    19. World w = l.getWorld();
    20. final Block b = w.getBlockAt(l);
    21. b.setType(Material.PORTAL);
    22. Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
    23.  
    24. public void run() {
    25. b.setType(Material.AIR);
    26.  
    27.  
    28.  
    29. }
    30. }, 1L);
    31.  
    32. }
    33. }
     
  19. Offline

    KeybordPiano459

    Should work fine. Have you tested it?
     
  20. Offline

    wowlover6877

    It gets rid of errors, but doesn't spawn anymore portals.
     
  21. Offline

    Codex Arcanum

    I feel like there may be a packet for this.
     
  22. Offline

    wowlover6877

    If this is a dumb question please forgive me: How do you use packets?
     
  23. Offline

    Codex Arcanum

    No clue. Haven't had cause to use them before myself. You can probably find some source code to look at somewhere.
     
  24. Offline

    KeybordPiano459

    Sorry, then I'm not sure. Someone else help out? :p
     
  25. Offline

    perwin

    I am just looking for the same thing, to figure out how to play ender portal effect like in CommandBin is command /drunk. I found something about other packet, which plays the credits scene, here: http://forums.bukkit.org/threads/anyone-familiar-with-packets.89159/. You can use some packets this way, to apply them to players. Now I am just trying to play this effect:
    Code:
    player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 0);
    I will let you know what does it do.

    Ok, I can tell you, that these playEffect visual effects don't seem to do anything. But I found out how the /drunk command in CommandBin works:
    Code:
    player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1200, 1000));
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  26. Offline

    fireblast709

    portal effect is client side, sadly enough. And there are no packets to trigger it (not that I found so far)
     
  27. Offline

    gomeow

    Maybe you did it wrong?
    A power of 1 should do
     
  28. Offline

    shahidsaif

    okey wait soon i am coming for this Ans.
     
  29. Offline

    perwin

    No there's nothing wrong, the code I posted works.
     
  30. Offline

    fireblast709

    perwin mmmh nice and spacey :3. Never knew this effect existed (I knew the PTE existed, but not that this was the result)
     
Thread Status:
Not open for further replies.

Share This Page