Saving the Type ID of a block and resetting another block on that location to the block saved

Discussion in 'Plugin Development' started by Minesuchtiiii, Jan 4, 2019.

Thread Status:
Not open for further replies.
  1. So I want to replace a block for some seconds with another one. after this the new block should be changed back to the old block. The code I'll post worked in 1.12 but somehow in the API version 1.13 it doesn't work anymore.

                          final Location loc = target.getLocation();
                          final int times = Integer.valueOf((int)loc.getY() + 1).intValue();
                          for (int i = 0; i < times; i++) {
                            Location blocksloc = loc.getBlock().getRelative(0, -i, 0).getLocation();
                            this.plugin.nummer.put(Integer.valueOf(i), Integer.valueOf(blocksloc.getBlock().getTypeId())); //<-- getTypeID red underlined
                            Location unten = loc.getBlock().getRelative(0, -i, 0).getLocation();
                            this.plugin.blöcke.put(Integer.valueOf(i), unten);
    Location log = (Location)VoidCommand.this.plugin.blöcke.get(Integer.valueOf(VoidCommand.this.a));
                                log.getWorld().getBlockAt(log).setTypeId(((Integer)VoidCommand.this.plugin.nummer.get(Integer.valueOf(VoidCommand.this.a))).intValue()); //<--- setTypeID red underlined

    Anyone knows how to change the code so it works in 1.13 again?

  2. Offline



    It looks like getTypeID() was removed in 1.13 (because of the red line you mentioned). You should be able to solve this by using getType() and setType() instead of getTypeID() and setTypeID(). Notice that getType() returns a Material, but getTypeID() returns an integer, so you will need to change your code a little.
Thread Status:
Not open for further replies.

Share This Page