SHARE
TWEET

Minecraft Plugin change block

a guest Aug 2nd, 2017 158 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     private static void setBlock(Block blockFrom, Block blockTo) {
  2.  
  3.         blockTo.setType(blockFrom.getType());
  4.         blockTo.setData(blockFrom.getData());
  5.  
  6.         switch(blockFrom.getType()) {
  7.             case STANDING_BANNER:
  8.             case WALL_BANNER:
  9.  
  10.                 Banner toBanner = (Banner) blockTo.getState();
  11.                 Banner fromBanner = (Banner) blockFrom.getState();
  12.  
  13.                 toBanner.setBaseColor(fromBanner.getBaseColor());
  14.                 toBanner.setPatterns(fromBanner.getPatterns());
  15.                 toBanner.update();
  16.  
  17.                 break;
  18.             case BEACON:
  19.  
  20.                 Beacon toBeacon = (Beacon) blockTo.getState();
  21.                 Beacon fromBeacon = (Beacon) blockFrom.getState();
  22.  
  23.                 toBeacon.setPrimaryEffect(fromBeacon.getPrimaryEffect().getType());
  24.                 toBeacon.setSecondaryEffect(fromBeacon.getSecondaryEffect().getType());
  25.                 toBeacon.setCustomName(fromBeacon.getCustomName());
  26.                 toBeacon.setLock(fromBeacon.getLock());
  27.                 toBeacon.getInventory().setContents(fromBeacon.getInventory().getContents());
  28.                 toBeacon.update();
  29.  
  30.                 break;
  31.             case BED_BLOCK:
  32.  
  33.                 Bed toBed = (Bed) blockTo.getState();
  34.                 Bed fromBed = (Bed) blockFrom.getState();
  35.  
  36.                 toBed.setColor(fromBed.getColor());
  37.                 toBed.update();
  38.  
  39.                 break;
  40.             case BREWING_STAND:
  41.  
  42.                 BrewingStand toBrewingStand = (BrewingStand) blockTo.getState();
  43.                 BrewingStand fromBrewingStand = (BrewingStand) blockFrom.getState();
  44.  
  45.                 toBrewingStand.setBrewingTime(fromBrewingStand.getBrewingTime());
  46.                 toBrewingStand.setFuelLevel(fromBrewingStand.getFuelLevel());
  47.                 toBrewingStand.setCustomName(fromBrewingStand.getCustomName());
  48.                 toBrewingStand.getInventory().setContents(fromBrewingStand.getInventory().getContents());
  49.                 toBrewingStand.setLock(fromBrewingStand.getLock());
  50.                 toBrewingStand.update();
  51.  
  52.                 break;
  53.             case CHEST:
  54.  
  55.                 Chest toChest = (Chest) blockTo.getState();
  56.                 Chest fromChest = (Chest) blockFrom.getState();
  57.  
  58.                 toChest.setCustomName(fromChest.getCustomName());
  59.                 toChest.getInventory().setContents(fromChest.getInventory().getContents());
  60.                 toChest.setLock(fromChest.getLock());
  61.                 toChest.update();
  62.  
  63.                 break;
  64.             case COMMAND_CHAIN:
  65.             case COMMAND_REPEATING:
  66.             case COMMAND:
  67.                 CommandBlock toCommandBlock = (CommandBlock) blockTo.getState();
  68.                 CommandBlock fromCommandBlock = (CommandBlock) blockFrom.getState();
  69.  
  70.                 toCommandBlock.setCommand(fromCommandBlock.getCommand());
  71.                 toCommandBlock.setName(fromCommandBlock.getName());
  72.                 toCommandBlock.update();
  73.  
  74.                 break;
  75.             case MOB_SPAWNER:
  76.  
  77.                 CreatureSpawner toCreatureSpawner = (CreatureSpawner) blockTo.getState();
  78.                 CreatureSpawner fromCreatureSpawner = (CreatureSpawner) blockFrom.getState();
  79.  
  80.                 toCreatureSpawner.setDelay(fromCreatureSpawner.getDelay());
  81.                 toCreatureSpawner.setSpawnedType(fromCreatureSpawner.getSpawnedType());
  82.                 toCreatureSpawner.update();
  83.  
  84.                 break;
  85.             case DISPENSER:
  86.  
  87.                 Dispenser toDispenser = (Dispenser) blockTo.getState();
  88.                 Dispenser fromDispenser = (Dispenser) blockFrom.getState();
  89.  
  90.                 toDispenser.setCustomName(fromDispenser.getCustomName());
  91.                 toDispenser.setLock(fromDispenser.getLock());
  92.                 toDispenser.getInventory().setContents(fromDispenser.getInventory().getContents());
  93.                 toDispenser.update();
  94.  
  95.                 break;
  96.             case DROPPER:
  97.  
  98.                 Dropper toDropper = (Dropper) blockTo.getState();
  99.                 Dropper fromDropper = (Dropper) blockFrom.getState();
  100.  
  101.                 toDropper.setCustomName(fromDropper.getCustomName());
  102.                 toDropper.setLock(fromDropper.getLock());
  103.                 toDropper.getInventory().setContents(fromDropper.getInventory().getContents());
  104.                 toDropper.update();
  105.  
  106.                 break;
  107.             case ENCHANTMENT_TABLE:
  108.  
  109.                 EnchantingTable toEnchantmentTable = (EnchantingTable) blockTo.getState();
  110.                 EnchantingTable fromEnchantmentTable = (EnchantingTable) blockFrom.getState();
  111.  
  112.                 toEnchantmentTable.setCustomName(fromEnchantmentTable.getCustomName());
  113.                 toEnchantmentTable.update();
  114.  
  115.                 break;
  116.             case END_GATEWAY:
  117.  
  118.                 EndGateway toEndGateway = (EndGateway) blockTo.getState();
  119.                 EndGateway fromEndGateway = (EndGateway) blockFrom.getState();
  120.  
  121.                 toEndGateway.setExactTeleport(fromEndGateway.isExactTeleport());
  122.                 toEndGateway.setExitLocation(fromEndGateway.getExitLocation());
  123.                 toEndGateway.update();
  124.  
  125.  
  126.                 break;
  127.             case FLOWER_POT:
  128.  
  129.                 FlowerPot toFlower = (FlowerPot) blockTo.getState();
  130.                 FlowerPot fromFlower = (FlowerPot) blockFrom.getState();
  131.  
  132.                 toFlower.setContents(fromFlower.getContents());
  133.                 toFlower.update();
  134.  
  135.                 break;
  136.             case FURNACE:
  137.  
  138.                 Furnace toFurnace = (Furnace) blockTo.getState();
  139.                 Furnace fromFurnace = (Furnace) blockFrom.getState();
  140.  
  141.                 toFurnace.setBurnTime(fromFurnace.getBurnTime());
  142.                 toFurnace.setCookTime(fromFurnace.getCookTime());
  143.                 toFurnace.setCustomName(fromFurnace.getCustomName());
  144.                 toFurnace.setLock(fromFurnace.getLock());
  145.                 toFurnace.getInventory().setContents(fromFurnace.getInventory().getContents());
  146.                 toFurnace.update();
  147.  
  148.                 break;
  149.             case HOPPER:
  150.  
  151.                 Hopper toHopper = (Hopper) blockTo.getState();
  152.                 Hopper fromHopper = (Hopper) blockFrom.getState();
  153.  
  154.                 toHopper.setCustomName(fromHopper.getCustomName());
  155.                 toHopper.setLock(fromHopper.getLock());
  156.                 toHopper.getInventory().setContents(fromHopper.getInventory().getContents());
  157.                 toHopper.update();
  158.  
  159.                 break;
  160.             case JUKEBOX:
  161.  
  162.                 Jukebox toJukebox = (Jukebox) blockTo.getState();
  163.                 Jukebox fromJukebox = (Jukebox) blockFrom.getState();
  164.  
  165.                 toJukebox.setPlaying(fromJukebox.getPlaying());
  166.                 toJukebox.update();
  167.  
  168.                 break;
  169.             case NOTE_BLOCK:
  170.  
  171.                 NoteBlock toNoteBlock = (NoteBlock) blockTo.getState();
  172.                 NoteBlock fromNoteBlock = (NoteBlock) blockFrom.getState();
  173.  
  174.                 toNoteBlock.setNote(fromNoteBlock.getNote());
  175.                 toNoteBlock.update();
  176.  
  177.                 break;
  178.             case SIGN_POST:
  179.             case WALL_SIGN:
  180.  
  181.                 Sign toSign = (Sign) blockTo.getState();
  182.                 Sign fromSign = (Sign) blockFrom.getState();
  183.  
  184.                 for(int i = 0; i < 4; i++) {
  185.                     toSign.setLine(i, fromSign.getLine(i));
  186.                 }
  187.                 toSign.update();
  188.  
  189.                 break;
  190.             case SKULL:
  191.  
  192.                 Skull toSkull = (Skull) blockTo.getState();
  193.                 Skull fromSkull = (Skull) blockFrom.getState();
  194.  
  195.                 toSkull.setSkullType(fromSkull.getSkullType());
  196.                 toSkull.setRotation(fromSkull.getRotation());
  197.                 toSkull.setOwner(fromSkull.getOwner());
  198.                 toSkull.update();
  199.  
  200.                 break;
  201.             case BLACK_SHULKER_BOX:
  202.             case SILVER_SHULKER_BOX:
  203.             case RED_SHULKER_BOX:
  204.             case BLUE_SHULKER_BOX:
  205.             case CYAN_SHULKER_BOX:
  206.             case GRAY_SHULKER_BOX:
  207.             case LIME_SHULKER_BOX:
  208.             case PINK_SHULKER_BOX:
  209.             case BROWN_SHULKER_BOX:
  210.             case GREEN_SHULKER_BOX:
  211.             case WHITE_SHULKER_BOX:
  212.             case ORANGE_SHULKER_BOX:
  213.             case PURPLE_SHULKER_BOX:
  214.             case YELLOW_SHULKER_BOX:
  215.             case MAGENTA_SHULKER_BOX:
  216.             case LIGHT_BLUE_SHULKER_BOX:
  217.  
  218.                 ShulkerBox toShulkerBox = (ShulkerBox) blockTo.getState();
  219.                 ShulkerBox fromShulkerBox = (ShulkerBox) blockFrom.getState();
  220.  
  221.                 toShulkerBox.setCustomName(fromShulkerBox.getCustomName());
  222.                 toShulkerBox.setLock(fromShulkerBox.getLock());
  223.                 toShulkerBox.getInventory().setContents(fromShulkerBox.getInventory().getContents());
  224.                 toShulkerBox.update();
  225.  
  226.                 break;
  227.         }
  228.  
  229.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top