mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:58:35 +00:00
Migrate the logic for which pass a block goes into. Also updated it and made it use tags where possible.
This commit is contained in:
@ -56,24 +56,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
@Nullable
|
||||
private CompoundTag nbtData;
|
||||
|
||||
/**
|
||||
* Construct a block with the given ID and a data value of 0.
|
||||
*
|
||||
* @param id ID value
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(int id) {
|
||||
try {
|
||||
this.blockState = LegacyMapper.getInstance().getBlockFromLegacy(id);
|
||||
if (this.blockState == null) {
|
||||
this.blockState = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with a state.
|
||||
*
|
||||
@ -111,7 +93,15 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(int id, int data) {
|
||||
this(id);
|
||||
try {
|
||||
this.blockState = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
||||
if (this.blockState == null) {
|
||||
this.blockState = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,14 +37,12 @@ public final class BlockID {
|
||||
public static final int DEAD_BUSH = 32; // DEADBUSH
|
||||
public static final int PISTON_BASE = 33; // PISTON
|
||||
public static final int PISTON_EXTENSION = 34; // PISTON_HEAD
|
||||
public static final int PISTON_MOVING_PIECE = 36; // PISTON_EXTENSION
|
||||
public static final int YELLOW_FLOWER = 37;
|
||||
public static final int RED_FLOWER = 38;
|
||||
public static final int BROWN_MUSHROOM = 39;
|
||||
public static final int RED_MUSHROOM = 40;
|
||||
public static final int STEP = 44; // STONE_SLAB
|
||||
public static final int TORCH = 50;
|
||||
public static final int FIRE = 51;
|
||||
public static final int OAK_WOOD_STAIRS = 53; // OAK_STAIRS
|
||||
public static final int CHEST = 54;
|
||||
public static final int REDSTONE_WIRE = 55;
|
||||
@ -70,7 +68,6 @@ public final class BlockID {
|
||||
public static final int FENCE = 85;
|
||||
public static final int PUMPKIN = 86;
|
||||
public static final int SLOW_SAND = 88; // SOUL_SAND
|
||||
public static final int PORTAL = 90;
|
||||
public static final int JACKOLANTERN = 91; // LIT_PUMPKIN
|
||||
public static final int CAKE_BLOCK = 92; // CAKE
|
||||
public static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER
|
||||
@ -126,7 +123,6 @@ public final class BlockID {
|
||||
public static final int DOUBLE_PLANT = 175;
|
||||
public static final int STANDING_BANNER = 176;
|
||||
public static final int WALL_BANNER = 177;
|
||||
public static final int DAYLIGHT_SENSOR_INVERTED = 178;
|
||||
public static final int STEP2 = 182;
|
||||
public static final int SPRUCE_DOOR = 193;
|
||||
public static final int BIRCH_DOOR = 194;
|
||||
|
@ -25,9 +25,7 @@ import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Block types.
|
||||
@ -39,110 +37,6 @@ public enum BlockType {
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* HashSet for shouldPlaceLast.
|
||||
*/
|
||||
private static final Set<Integer> shouldPlaceLast = new HashSet<>();
|
||||
static {
|
||||
shouldPlaceLast.add(BlockID.SAPLING);
|
||||
shouldPlaceLast.add(BlockID.BED);
|
||||
shouldPlaceLast.add(BlockID.POWERED_RAIL);
|
||||
shouldPlaceLast.add(BlockID.DETECTOR_RAIL);
|
||||
shouldPlaceLast.add(BlockID.LONG_GRASS);
|
||||
shouldPlaceLast.add(BlockID.DEAD_BUSH);
|
||||
shouldPlaceLast.add(BlockID.YELLOW_FLOWER);
|
||||
shouldPlaceLast.add(BlockID.RED_FLOWER);
|
||||
shouldPlaceLast.add(BlockID.BROWN_MUSHROOM);
|
||||
shouldPlaceLast.add(BlockID.RED_MUSHROOM);
|
||||
shouldPlaceLast.add(BlockID.TORCH);
|
||||
shouldPlaceLast.add(BlockID.FIRE);
|
||||
shouldPlaceLast.add(BlockID.REDSTONE_WIRE);
|
||||
shouldPlaceLast.add(BlockID.CROPS);
|
||||
shouldPlaceLast.add(BlockID.LADDER);
|
||||
shouldPlaceLast.add(BlockID.MINECART_TRACKS);
|
||||
shouldPlaceLast.add(BlockID.LEVER);
|
||||
shouldPlaceLast.add(BlockID.STONE_PRESSURE_PLATE);
|
||||
shouldPlaceLast.add(BlockID.WOODEN_PRESSURE_PLATE);
|
||||
shouldPlaceLast.add(BlockID.REDSTONE_TORCH_OFF);
|
||||
shouldPlaceLast.add(BlockID.REDSTONE_TORCH_ON);
|
||||
shouldPlaceLast.add(BlockID.STONE_BUTTON);
|
||||
shouldPlaceLast.add(BlockID.SNOW);
|
||||
shouldPlaceLast.add(BlockID.PORTAL);
|
||||
shouldPlaceLast.add(BlockID.REDSTONE_REPEATER_OFF);
|
||||
shouldPlaceLast.add(BlockID.REDSTONE_REPEATER_ON);
|
||||
shouldPlaceLast.add(BlockID.TRAP_DOOR);
|
||||
shouldPlaceLast.add(BlockID.VINE);
|
||||
shouldPlaceLast.add(BlockID.LILY_PAD);
|
||||
shouldPlaceLast.add(BlockID.NETHER_WART);
|
||||
shouldPlaceLast.add(BlockID.PISTON_BASE);
|
||||
shouldPlaceLast.add(BlockID.PISTON_STICKY_BASE);
|
||||
shouldPlaceLast.add(BlockID.PISTON_EXTENSION);
|
||||
shouldPlaceLast.add(BlockID.PISTON_MOVING_PIECE);
|
||||
shouldPlaceLast.add(BlockID.COCOA_PLANT);
|
||||
shouldPlaceLast.add(BlockID.TRIPWIRE_HOOK);
|
||||
shouldPlaceLast.add(BlockID.TRIPWIRE);
|
||||
shouldPlaceLast.add(BlockID.FLOWER_POT);
|
||||
shouldPlaceLast.add(BlockID.CARROTS);
|
||||
shouldPlaceLast.add(BlockID.POTATOES);
|
||||
shouldPlaceLast.add(BlockID.WOODEN_BUTTON);
|
||||
shouldPlaceLast.add(BlockID.ANVIL); // becomes relevant with asynchronous placement
|
||||
shouldPlaceLast.add(BlockID.PRESSURE_PLATE_LIGHT);
|
||||
shouldPlaceLast.add(BlockID.PRESSURE_PLATE_HEAVY);
|
||||
shouldPlaceLast.add(BlockID.COMPARATOR_OFF);
|
||||
shouldPlaceLast.add(BlockID.COMPARATOR_ON);
|
||||
shouldPlaceLast.add(BlockID.ACTIVATOR_RAIL);
|
||||
shouldPlaceLast.add(BlockID.IRON_TRAP_DOOR);
|
||||
shouldPlaceLast.add(BlockID.CARPET);
|
||||
shouldPlaceLast.add(BlockID.DOUBLE_PLANT);
|
||||
shouldPlaceLast.add(BlockID.DAYLIGHT_SENSOR_INVERTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last (when reordering
|
||||
* blocks that are placed).
|
||||
*
|
||||
* @param id the block ID
|
||||
* @return true if the block should be placed last
|
||||
*/
|
||||
public static boolean shouldPlaceLast(int id) {
|
||||
return shouldPlaceLast.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet for shouldPlaceLast.
|
||||
*/
|
||||
private static final Set<Integer> shouldPlaceFinal = new HashSet<>();
|
||||
static {
|
||||
shouldPlaceFinal.add(BlockID.SIGN_POST);
|
||||
shouldPlaceFinal.add(BlockID.WOODEN_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.ACACIA_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.BIRCH_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.JUNGLE_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.DARK_OAK_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.SPRUCE_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.WALL_SIGN);
|
||||
shouldPlaceFinal.add(BlockID.IRON_DOOR);
|
||||
shouldPlaceFinal.add(BlockID.CACTUS);
|
||||
shouldPlaceFinal.add(BlockID.REED);
|
||||
shouldPlaceFinal.add(BlockID.CAKE_BLOCK);
|
||||
shouldPlaceFinal.add(BlockID.PISTON_EXTENSION);
|
||||
shouldPlaceFinal.add(BlockID.PISTON_MOVING_PIECE);
|
||||
shouldPlaceFinal.add(BlockID.STANDING_BANNER);
|
||||
shouldPlaceFinal.add(BlockID.WALL_BANNER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed in the final queue.
|
||||
*
|
||||
* This applies to blocks that can be attached to other blocks that have an attachment.
|
||||
*
|
||||
* @param id the type ID of the block
|
||||
* @return whether the block is in the final queue
|
||||
*/
|
||||
public static boolean shouldPlaceFinal(int id) {
|
||||
return shouldPlaceFinal.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet for centralTopLimit.
|
||||
*/
|
||||
|
@ -19,9 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.worldedit.blocks.type.BlockCategories;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Block-related utility methods.
|
||||
@ -31,6 +36,121 @@ public final class Blocks {
|
||||
private Blocks() {
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet for shouldPlaceLast.
|
||||
*/
|
||||
private static final Set<BlockType> shouldPlaceLast = new HashSet<>();
|
||||
static {
|
||||
shouldPlaceLast.addAll(BlockCategories.SAPLINGS.getBlockTypes());
|
||||
shouldPlaceLast.addAll(BlockCategories.FLOWER_POTS.getBlockTypes());
|
||||
shouldPlaceLast.addAll(BlockCategories.BUTTONS.getBlockTypes());
|
||||
shouldPlaceLast.addAll(BlockCategories.ANVIL.getBlockTypes()); // becomes relevant with asynchronous placement
|
||||
shouldPlaceLast.addAll(BlockCategories.WOODEN_PRESSURE_PLATES.getBlockTypes());
|
||||
shouldPlaceLast.addAll(BlockCategories.CARPETS.getBlockTypes());
|
||||
shouldPlaceLast.addAll(BlockCategories.RAILS.getBlockTypes());
|
||||
shouldPlaceLast.add(BlockTypes.BLACK_BED);
|
||||
shouldPlaceLast.add(BlockTypes.BLUE_BED);
|
||||
shouldPlaceLast.add(BlockTypes.BROWN_BED);
|
||||
shouldPlaceLast.add(BlockTypes.CYAN_BED);
|
||||
shouldPlaceLast.add(BlockTypes.GRAY_BED);
|
||||
shouldPlaceLast.add(BlockTypes.GREEN_BED);
|
||||
shouldPlaceLast.add(BlockTypes.LIGHT_BLUE_BED);
|
||||
shouldPlaceLast.add(BlockTypes.LIGHT_GRAY_BED);
|
||||
shouldPlaceLast.add(BlockTypes.LIME_BED);
|
||||
shouldPlaceLast.add(BlockTypes.MAGENTA_BED);
|
||||
shouldPlaceLast.add(BlockTypes.ORANGE_BED);
|
||||
shouldPlaceLast.add(BlockTypes.PINK_BED);
|
||||
shouldPlaceLast.add(BlockTypes.PURPLE_BED);
|
||||
shouldPlaceLast.add(BlockTypes.RED_BED);
|
||||
shouldPlaceLast.add(BlockTypes.WHITE_BED);
|
||||
shouldPlaceLast.add(BlockTypes.YELLOW_BED);
|
||||
shouldPlaceLast.add(BlockTypes.GRASS);
|
||||
shouldPlaceLast.add(BlockTypes.TALL_GRASS);
|
||||
shouldPlaceLast.add(BlockTypes.ROSE_BUSH);
|
||||
shouldPlaceLast.add(BlockTypes.DANDELION);
|
||||
shouldPlaceLast.add(BlockTypes.BROWN_MUSHROOM);
|
||||
shouldPlaceLast.add(BlockTypes.RED_MUSHROOM);
|
||||
shouldPlaceLast.add(BlockTypes.FERN);
|
||||
shouldPlaceLast.add(BlockTypes.LARGE_FERN);
|
||||
shouldPlaceLast.add(BlockTypes.OXEYE_DAISY);
|
||||
shouldPlaceLast.add(BlockTypes.AZURE_BLUET);
|
||||
shouldPlaceLast.add(BlockTypes.TORCH);
|
||||
shouldPlaceLast.add(BlockTypes.WALL_TORCH);
|
||||
shouldPlaceLast.add(BlockTypes.FIRE);
|
||||
shouldPlaceLast.add(BlockTypes.REDSTONE_WIRE);
|
||||
shouldPlaceLast.add(BlockTypes.CARROTS);
|
||||
shouldPlaceLast.add(BlockTypes.POTATOES);
|
||||
shouldPlaceLast.add(BlockTypes.WHEAT);
|
||||
shouldPlaceLast.add(BlockTypes.BEETROOTS);
|
||||
shouldPlaceLast.add(BlockTypes.COCOA);
|
||||
shouldPlaceLast.add(BlockTypes.LADDER);
|
||||
shouldPlaceLast.add(BlockTypes.LEVER);
|
||||
shouldPlaceLast.add(BlockTypes.REDSTONE_TORCH);
|
||||
shouldPlaceLast.add(BlockTypes.REDSTONE_WALL_TORCH);
|
||||
shouldPlaceLast.add(BlockTypes.SNOW);
|
||||
shouldPlaceLast.add(BlockTypes.PORTAL);
|
||||
shouldPlaceLast.add(BlockTypes.END_PORTAL);
|
||||
shouldPlaceLast.add(BlockTypes.REPEATER);
|
||||
shouldPlaceLast.add(BlockTypes.VINE);
|
||||
shouldPlaceLast.add(BlockTypes.LILY_PAD);
|
||||
shouldPlaceLast.add(BlockTypes.NETHER_WART);
|
||||
shouldPlaceLast.add(BlockTypes.PISTON);
|
||||
shouldPlaceLast.add(BlockTypes.STICKY_PISTON);
|
||||
shouldPlaceLast.add(BlockTypes.TRIPWIRE_HOOK);
|
||||
shouldPlaceLast.add(BlockTypes.TRIPWIRE);
|
||||
shouldPlaceLast.add(BlockTypes.STONE_PRESSURE_PLATE);
|
||||
shouldPlaceLast.add(BlockTypes.HEAVY_WEIGHTED_PRESSURE_PLATE);
|
||||
shouldPlaceLast.add(BlockTypes.LIGHT_WEIGHTED_PRESSURE_PLATE);
|
||||
shouldPlaceLast.add(BlockTypes.COMPARATOR);
|
||||
shouldPlaceLast.add(BlockTypes.IRON_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.ACACIA_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.BIRCH_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.DARK_OAK_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.JUNGLE_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.OAK_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.SPRUCE_TRAPDOOR);
|
||||
shouldPlaceLast.add(BlockTypes.DAYLIGHT_DETECTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last (when reordering
|
||||
* blocks that are placed).
|
||||
*
|
||||
* @param type the block type
|
||||
* @return true if the block should be placed last
|
||||
*/
|
||||
public static boolean shouldPlaceLast(BlockType type) {
|
||||
return shouldPlaceLast.contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet for shouldPlaceLast.
|
||||
*/
|
||||
private static final Set<BlockType> shouldPlaceFinal = new HashSet<>();
|
||||
static {
|
||||
shouldPlaceFinal.addAll(BlockCategories.DOORS.getBlockTypes());
|
||||
shouldPlaceFinal.addAll(BlockCategories.BANNERS.getBlockTypes());
|
||||
shouldPlaceFinal.add(BlockTypes.SIGN);
|
||||
shouldPlaceFinal.add(BlockTypes.WALL_SIGN);
|
||||
shouldPlaceFinal.add(BlockTypes.CACTUS);
|
||||
shouldPlaceFinal.add(BlockTypes.SUGAR_CANE);
|
||||
shouldPlaceFinal.add(BlockTypes.CAKE);
|
||||
shouldPlaceFinal.add(BlockTypes.PISTON_HEAD);
|
||||
shouldPlaceFinal.add(BlockTypes.MOVING_PISTON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed in the final queue.
|
||||
*
|
||||
* This applies to blocks that can be attached to other blocks that have an attachment.
|
||||
*
|
||||
* @param type the type of the block
|
||||
* @return whether the block is in the final queue
|
||||
*/
|
||||
public static boolean shouldPlaceFinal(BlockType type) {
|
||||
return shouldPlaceFinal.contains(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given block is in a list of base blocks.
|
||||
*
|
||||
|
Reference in New Issue
Block a user