mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:58:35 +00:00
Copy paste/merge FAWE classes to this WorldEdit fork
- so certain people can look at the diff and complain about my sloppy code :( Signed-off-by: Jesse Boyd <jessepaleg@gmail.com>
This commit is contained in:
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a mutable "snapshot" of a block.
|
||||
*
|
||||
* <p>An instance of this block contains all the information needed to
|
||||
* accurately reproduce the block, provided that the instance was
|
||||
* made correctly. In some implementations, it may not be possible to get a
|
||||
* snapshot of blocks correctly, so, for example, the NBT data for a block
|
||||
* may be missing.</p>
|
||||
*
|
||||
* <p>A peculiar detail of this class is that it accepts {@code -1} as a
|
||||
* valid data value. This is due to legacy reasons: WorldEdit uses -1
|
||||
* as a "wildcard" block value, even though a {@link Mask} would be
|
||||
* more appropriate.</p>
|
||||
*/
|
||||
public class BaseBlock extends BlockState {
|
||||
private BlockState blockState;
|
||||
|
||||
@Nullable
|
||||
protected CompoundTag nbtData;
|
||||
|
||||
@Deprecated
|
||||
public BaseBlock() {
|
||||
this(BlockTypes.AIR.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with a state.
|
||||
* @deprecated Just use the BlockStateHolder instead
|
||||
* @param blockState The blockstate
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(BlockStateHolder blockState) {
|
||||
this(blockState, blockState.getNbtData());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BaseBlock(BlockTypes id) {
|
||||
this(id.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with the given type and default data.
|
||||
* @deprecated Just use the BlockType.getDefaultState()
|
||||
* @param blockType The block type
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(BlockType blockType) {
|
||||
this(blockType.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with the given ID, data value and NBT data structure.
|
||||
*
|
||||
* @param state The block state
|
||||
* @param nbtData NBT data, which may be null
|
||||
*/
|
||||
public BaseBlock(BlockStateHolder state, @Nullable CompoundTag nbtData) {
|
||||
super(0);
|
||||
this.blockState = state.toImmutableState();
|
||||
this.nbtData = nbtData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with the given ID and data value.
|
||||
*
|
||||
* @param id ID value
|
||||
* @param data data value
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(int id, int data) {
|
||||
this(getState(id, data));
|
||||
}
|
||||
|
||||
private static final BlockState getState(int id, int data) {
|
||||
BlockState blockState = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
||||
if (blockState == null) {
|
||||
blockState = BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
return blockState;
|
||||
}
|
||||
|
||||
protected BaseBlock(int internalId, CompoundTag nbtData) {
|
||||
this(BlockState.get(internalId), nbtData);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static BaseBlock getFromInternalId(int id, CompoundTag nbtData) {
|
||||
return new BaseBlock(id, nbtData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a clone of another block.
|
||||
*
|
||||
* @param other the other block
|
||||
*/
|
||||
@Deprecated
|
||||
public BaseBlock(BaseBlock other) {
|
||||
this(other.toImmutableState(), other.getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState toFuzzy() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get the block's data value.
|
||||
// *
|
||||
// * Broken - do not use
|
||||
// *
|
||||
// * @return data value (0-15)
|
||||
// */
|
||||
// @Deprecated
|
||||
// public int getData() {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
CompoundTag nbtData = getNbtData();
|
||||
if (nbtData == null) {
|
||||
return "";
|
||||
}
|
||||
Tag idTag = nbtData.getValue().get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
return ((StringTag) idTag).getValue();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return this.nbtData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||
this.nbtData = nbtData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the type ID and data value are equal.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof BaseBlock)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final BaseBlock otherBlock = (BaseBlock) o;
|
||||
|
||||
return this.equals(otherBlock) && Objects.equals(getNbtData(), otherBlock.getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockState toImmutableState() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInternalId() {
|
||||
return blockState.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.getNbtData() != null) {
|
||||
return getAsString() + " {" + String.valueOf(getNbtData()) + "}";
|
||||
} else {
|
||||
return getAsString();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,10 @@
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.world.NbtValued;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -57,13 +59,18 @@ public class BaseItem implements NbtValued {
|
||||
this.nbtData = tag;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public @Nullable Object getNativeItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of item.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public ItemType getType() {
|
||||
return this.itemType;
|
||||
public ItemTypes getType() {
|
||||
return (ItemTypes) this.itemType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
/**
|
||||
* List of block IDs.
|
||||
*
|
||||
* {@deprecated Please use {@link BlockTypes }}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class BlockID {
|
||||
static final int SAPLING = 6;
|
||||
static final int POWERED_RAIL = 27; // GOLDEN_RAIL
|
||||
static final int DETECTOR_RAIL = 28;
|
||||
static final int LONG_GRASS = 31; // TALLGRASS
|
||||
static final int DEAD_BUSH = 32; // DEADBUSH
|
||||
static final int PISTON_EXTENSION = 34; // PISTON_HEAD
|
||||
static final int YELLOW_FLOWER = 37;
|
||||
static final int RED_FLOWER = 38;
|
||||
static final int BROWN_MUSHROOM = 39;
|
||||
static final int RED_MUSHROOM = 40;
|
||||
static final int TORCH = 50;
|
||||
static final int REDSTONE_WIRE = 55;
|
||||
static final int CROPS = 59; // WHEAT
|
||||
static final int SIGN_POST = 63; // STANDING_SIGN
|
||||
static final int WOODEN_DOOR = 64; // WOODEN_DOOR
|
||||
static final int LADDER = 65;
|
||||
static final int MINECART_TRACKS = 66; // RAIL
|
||||
static final int WALL_SIGN = 68;
|
||||
static final int LEVER = 69;
|
||||
static final int STONE_PRESSURE_PLATE = 70;
|
||||
static final int IRON_DOOR = 71;
|
||||
static final int WOODEN_PRESSURE_PLATE = 72;
|
||||
static final int REDSTONE_TORCH_OFF = 75; // UNLIT_REDSTONE_TORCH
|
||||
static final int REDSTONE_TORCH_ON = 76; // LIT_REDSTONE_TORCH
|
||||
static final int STONE_BUTTON = 77;
|
||||
static final int CACTUS = 81;
|
||||
static final int REED = 83; // REEDS
|
||||
static final int CAKE_BLOCK = 92; // CAKE
|
||||
static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER
|
||||
static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER
|
||||
static final int TRAP_DOOR = 96; // TRAPDOOR
|
||||
static final int PUMPKIN_STEM = 104;
|
||||
static final int MELON_STEM = 105;
|
||||
static final int VINE = 106;
|
||||
static final int NETHER_WART = 115;
|
||||
static final int COCOA_PLANT = 127; // COCOA
|
||||
static final int TRIPWIRE_HOOK = 131;
|
||||
static final int TRIPWIRE = 132;
|
||||
static final int FLOWER_POT = 140;
|
||||
static final int CARROTS = 141;
|
||||
static final int POTATOES = 142;
|
||||
static final int WOODEN_BUTTON = 143;
|
||||
static final int ANVIL = 145;
|
||||
static final int PRESSURE_PLATE_LIGHT = 147; // LIGHT_WEIGHTED_PRESSURE_PLATE
|
||||
static final int PRESSURE_PLATE_HEAVY = 148; // HEAVY_WEIGHTED_PRESSURE_PLATE
|
||||
static final int COMPARATOR_OFF = 149; // UNPOWERED_COMPARATOR
|
||||
static final int COMPARATOR_ON = 150; // COMPARATOR
|
||||
static final int ACTIVATOR_RAIL = 157;
|
||||
static final int IRON_TRAP_DOOR = 167;
|
||||
static final int CARPET = 171;
|
||||
static final int DOUBLE_PLANT = 175;
|
||||
static final int STANDING_BANNER = 176;
|
||||
static final int WALL_BANNER = 177;
|
||||
static final int SPRUCE_DOOR = 193;
|
||||
static final int BIRCH_DOOR = 194;
|
||||
static final int JUNGLE_DOOR = 195;
|
||||
static final int ACACIA_DOOR = 196;
|
||||
static final int DARK_OAK_DOOR = 197;
|
||||
|
||||
private BlockID() {
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* Describes the material for a block.
|
||||
*/
|
||||
public interface BlockMaterial {
|
||||
|
||||
/**
|
||||
* Get if this block is air
|
||||
* @return
|
||||
*/
|
||||
boolean isAir();
|
||||
|
||||
/**
|
||||
* Get whether this block is a full sized cube.
|
||||
*
|
||||
* @return the value of the test
|
||||
*/
|
||||
boolean isFullCube();
|
||||
|
||||
/**
|
||||
* Get whether this block is opaque.
|
||||
*
|
||||
* @return the value of the test
|
||||
*/
|
||||
boolean isOpaque();
|
||||
|
||||
/**
|
||||
* Get whether this block emits a Redstone signal.
|
||||
*
|
||||
* @return the value of the test
|
||||
*/
|
||||
boolean isPowerSource();
|
||||
|
||||
/**
|
||||
* Get whether this block is a liquid.
|
||||
*
|
||||
* @return the value of the test
|
||||
*/
|
||||
boolean isLiquid();
|
||||
|
||||
/**
|
||||
* Get whether this block is a solid.
|
||||
*
|
||||
* @return the value of the test
|
||||
*/
|
||||
boolean isSolid();
|
||||
|
||||
/**
|
||||
* Get the hardness factor for this block.
|
||||
*
|
||||
* @return the hardness factor
|
||||
*/
|
||||
float getHardness();
|
||||
|
||||
/**
|
||||
* Get the resistance factor for this block.
|
||||
*
|
||||
* @return the resistance factor
|
||||
*/
|
||||
float getResistance();
|
||||
|
||||
/**
|
||||
* Get the slipperiness factor for this block.
|
||||
*
|
||||
* @return the slipperiness factor
|
||||
*/
|
||||
float getSlipperiness();
|
||||
|
||||
/**
|
||||
* Get the light value for this block.
|
||||
*
|
||||
* @return the light value
|
||||
*/
|
||||
int getLightValue();
|
||||
|
||||
/**
|
||||
* Get the opacity of the block
|
||||
* @return opacity
|
||||
*/
|
||||
int getLightOpacity();
|
||||
|
||||
/**
|
||||
* Get whether this block breaks when it is pushed by a piston.
|
||||
*
|
||||
* @return true if the block breaks
|
||||
*/
|
||||
boolean isFragileWhenPushed();
|
||||
|
||||
/**
|
||||
* Get whether this block can be pushed by a piston.
|
||||
*
|
||||
* @return true if the block cannot be pushed
|
||||
*/
|
||||
boolean isUnpushable();
|
||||
|
||||
/**
|
||||
* Get whether this block is ticked randomly.
|
||||
*
|
||||
* @return true if this block is ticked randomly
|
||||
*/
|
||||
boolean isTicksRandomly();
|
||||
|
||||
/**
|
||||
* Get whether this block prevents movement.
|
||||
*
|
||||
* @return true if this block blocks movement
|
||||
*/
|
||||
boolean isMovementBlocker();
|
||||
|
||||
/**
|
||||
* Get whether this block will burn.
|
||||
*
|
||||
* @return true if this block will burn
|
||||
*/
|
||||
boolean isBurnable();
|
||||
|
||||
/**
|
||||
* Get whether this block needs to be broken by a tool for maximum
|
||||
* speed.
|
||||
*
|
||||
* @return true if a tool is required
|
||||
*/
|
||||
boolean isToolRequired();
|
||||
|
||||
/**
|
||||
* Get whether this block is replaced when a block is placed over it
|
||||
* (for example, tall grass).
|
||||
*
|
||||
* @return true if the block is replaced
|
||||
*/
|
||||
boolean isReplacedDuringPlacement();
|
||||
|
||||
/**
|
||||
* Get whether this block is translucent.
|
||||
*
|
||||
* @return true if the block is translucent
|
||||
*/
|
||||
boolean isTranslucent();
|
||||
|
||||
/**
|
||||
* Gets whether the block has a container (Item container)
|
||||
*
|
||||
* @return If it has a container
|
||||
*/
|
||||
boolean hasContainer();
|
||||
}
|
@ -19,8 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.PlayerDirection;
|
||||
import com.sk89q.worldedit.registry.state.PropertyGroup;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -30,129 +38,111 @@ import java.util.Map;
|
||||
* {@deprecated Please use {@link com.sk89q.worldedit.world.block.BlockType }}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum BlockType {
|
||||
public class BlockType {
|
||||
|
||||
;
|
||||
|
||||
private static final Map<Integer, PlayerDirection> dataAttachments = new HashMap<>();
|
||||
private static final Map<Integer, PlayerDirection> nonDataAttachments = new HashMap<>();
|
||||
static {
|
||||
nonDataAttachments.put(BlockID.SAPLING, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.LONG_GRASS, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.DEAD_BUSH, PlayerDirection.DOWN);
|
||||
for (int offset = 0; offset < 16; offset += 8) {
|
||||
dataAttachments.put(typeDataKey(BlockID.PISTON_EXTENSION, offset + 0), PlayerDirection.UP);
|
||||
dataAttachments.put(typeDataKey(BlockID.PISTON_EXTENSION, offset + 1), PlayerDirection.DOWN);
|
||||
addCardinals(BlockID.PISTON_EXTENSION, offset + 2, offset + 5, offset + 3, offset + 4);
|
||||
}
|
||||
nonDataAttachments.put(BlockID.YELLOW_FLOWER, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.RED_FLOWER, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.BROWN_MUSHROOM, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.RED_MUSHROOM, PlayerDirection.DOWN);
|
||||
for (int blockId : new int[] { BlockID.TORCH, BlockID.REDSTONE_TORCH_ON, BlockID.REDSTONE_TORCH_OFF }) {
|
||||
dataAttachments.put(typeDataKey(blockId, 0), PlayerDirection.DOWN);
|
||||
dataAttachments.put(typeDataKey(blockId, 5), PlayerDirection.DOWN); // According to the minecraft wiki, this one is history. Keeping both, for now...
|
||||
addCardinals(blockId, 4, 1, 3, 2);
|
||||
}
|
||||
nonDataAttachments.put(BlockID.REDSTONE_WIRE, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.CROPS, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.SIGN_POST, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.WOODEN_DOOR, PlayerDirection.DOWN);
|
||||
addCardinals(BlockID.LADDER, 2, 5, 3, 4);
|
||||
addCardinals(BlockID.WALL_SIGN, 2, 5, 3, 4);
|
||||
for (int offset = 0; offset < 16; offset += 8) {
|
||||
addCardinals(BlockID.LEVER, offset + 4, offset + 1, offset + 3, offset + 2);
|
||||
dataAttachments.put(typeDataKey(BlockID.LEVER, offset + 5), PlayerDirection.DOWN);
|
||||
dataAttachments.put(typeDataKey(BlockID.LEVER, offset + 6), PlayerDirection.DOWN);
|
||||
dataAttachments.put(typeDataKey(BlockID.LEVER, offset + 7), PlayerDirection.UP);
|
||||
dataAttachments.put(typeDataKey(BlockID.LEVER, offset + 0), PlayerDirection.UP);
|
||||
}
|
||||
nonDataAttachments.put(BlockID.STONE_PRESSURE_PLATE, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.IRON_DOOR, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.WOODEN_PRESSURE_PLATE, PlayerDirection.DOWN);
|
||||
// redstone torches: see torches
|
||||
for (int offset = 0; offset < 16; offset += 8) {
|
||||
addCardinals(BlockID.STONE_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2);
|
||||
addCardinals(BlockID.WOODEN_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2);
|
||||
}
|
||||
dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 0), PlayerDirection.UP);
|
||||
dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 5), PlayerDirection.DOWN);
|
||||
dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 0), PlayerDirection.UP);
|
||||
dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 5), PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.CAKE_BLOCK, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_OFF, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.REDSTONE_REPEATER_ON, PlayerDirection.DOWN);
|
||||
for (int offset = 0; offset < 16; offset += 4) {
|
||||
addCardinals(BlockID.TRAP_DOOR, offset + 0, offset + 3, offset + 1, offset + 2);
|
||||
addCardinals(BlockID.IRON_TRAP_DOOR, offset + 0, offset + 3, offset + 1, offset + 2);
|
||||
}
|
||||
nonDataAttachments.put(BlockID.PUMPKIN_STEM, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.MELON_STEM, PlayerDirection.DOWN);
|
||||
// vines are complicated, but I'll list the single-attachment variants anyway
|
||||
dataAttachments.put(typeDataKey(BlockID.VINE, 0), PlayerDirection.UP);
|
||||
addCardinals(BlockID.VINE, 1, 2, 4, 8);
|
||||
nonDataAttachments.put(BlockID.NETHER_WART, PlayerDirection.DOWN);
|
||||
for (int offset = 0; offset < 16; offset += 4) {
|
||||
addCardinals(BlockID.COCOA_PLANT, offset + 0, offset + 1, offset + 2, offset + 3);
|
||||
}
|
||||
for (int offset = 0; offset < 16; offset += 4) {
|
||||
addCardinals(BlockID.TRIPWIRE_HOOK, offset + 2, offset + 3, offset + 0, offset + 1);
|
||||
}
|
||||
nonDataAttachments.put(BlockID.TRIPWIRE, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.FLOWER_POT, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.CARROTS, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.POTATOES, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.ANVIL, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.PRESSURE_PLATE_LIGHT, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.PRESSURE_PLATE_HEAVY, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.COMPARATOR_OFF, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.COMPARATOR_ON, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.CARPET, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.DOUBLE_PLANT, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.STANDING_BANNER, PlayerDirection.DOWN);
|
||||
addCardinals(BlockID.WALL_BANNER, 4, 2, 5, 3);
|
||||
nonDataAttachments.put(BlockID.SPRUCE_DOOR, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.BIRCH_DOOR, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.JUNGLE_DOOR, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.ACACIA_DOOR, PlayerDirection.DOWN);
|
||||
nonDataAttachments.put(BlockID.DARK_OAK_DOOR, PlayerDirection.DOWN);
|
||||
|
||||
// Rails are hardcoded to be attached to the block below them.
|
||||
// In addition to that, let's attach ascending rails to the block they're ascending towards.
|
||||
for (int offset = 0; offset < 16; offset += 8) {
|
||||
addCardinals(BlockID.POWERED_RAIL, offset + 3, offset + 4, offset + 2, offset + 5);
|
||||
addCardinals(BlockID.DETECTOR_RAIL, offset + 3, offset + 4, offset + 2, offset + 5);
|
||||
addCardinals(BlockID.MINECART_TRACKS, offset + 3, offset + 4, offset + 2, offset + 5);
|
||||
addCardinals(BlockID.ACTIVATOR_RAIL, offset + 3, offset + 4, offset + 2, offset + 5);
|
||||
}
|
||||
public static double centralTopLimit(com.sk89q.worldedit.world.block.BlockType type) {
|
||||
checkNotNull(type);
|
||||
return centralTopLimit(type.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the direction to the block(B) this block(A) is attached to.
|
||||
* Attached means that if block B is destroyed, block A will pop off.
|
||||
* TODO FIXME use registry
|
||||
* Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5.
|
||||
*
|
||||
* @param type the block id of block A
|
||||
* @param data the data value of block A
|
||||
* @return direction to block B
|
||||
* @param block the block
|
||||
* @return the y offset
|
||||
*/
|
||||
public static PlayerDirection getAttachment(int type, int data) {
|
||||
PlayerDirection direction = nonDataAttachments.get(type);
|
||||
if (direction != null) return direction;
|
||||
|
||||
return dataAttachments.get(typeDataKey(type, data));
|
||||
public static double centralTopLimit(BlockStateHolder block) {
|
||||
checkNotNull(block);
|
||||
switch (block.getBlockType().getTypeEnum()) {
|
||||
case BLACK_BED:
|
||||
case BLUE_BED:
|
||||
case BROWN_BED:
|
||||
case CYAN_BED:
|
||||
case GRAY_BED:
|
||||
case GREEN_BED:
|
||||
case LIGHT_BLUE_BED:
|
||||
case LIGHT_GRAY_BED:
|
||||
case LIME_BED:
|
||||
case MAGENTA_BED:
|
||||
case ORANGE_BED:
|
||||
case PINK_BED:
|
||||
case PURPLE_BED:
|
||||
case RED_BED:
|
||||
case WHITE_BED:
|
||||
case YELLOW_BED: return 0.5625;
|
||||
case BREWING_STAND: return 0.875;
|
||||
case CAKE: return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
|
||||
case CAULDRON: return 0.3125;
|
||||
case COCOA: return 0.750;
|
||||
case ENCHANTING_TABLE: return 0.75;
|
||||
case END_PORTAL_FRAME: return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
|
||||
case CREEPER_HEAD:
|
||||
case DRAGON_HEAD:
|
||||
case PISTON_HEAD:
|
||||
case PLAYER_HEAD:
|
||||
case ZOMBIE_HEAD: return 0.5;
|
||||
case CREEPER_WALL_HEAD:
|
||||
case DRAGON_WALL_HEAD:
|
||||
case PLAYER_WALL_HEAD:
|
||||
case ZOMBIE_WALL_HEAD: return 0.75;
|
||||
case ACACIA_FENCE:
|
||||
case BIRCH_FENCE:
|
||||
case DARK_OAK_FENCE:
|
||||
case JUNGLE_FENCE:
|
||||
case NETHER_BRICK_FENCE:
|
||||
case OAK_FENCE:
|
||||
case SPRUCE_FENCE: return 1.5;
|
||||
case ACACIA_SLAB:
|
||||
case BIRCH_SLAB:
|
||||
case BRICK_SLAB:
|
||||
case COBBLESTONE_SLAB:
|
||||
case DARK_OAK_SLAB:
|
||||
case DARK_PRISMARINE_SLAB:
|
||||
case JUNGLE_SLAB:
|
||||
case NETHER_BRICK_SLAB:
|
||||
case OAK_SLAB:
|
||||
case PETRIFIED_OAK_SLAB:
|
||||
case PRISMARINE_BRICK_SLAB:
|
||||
case PRISMARINE_SLAB:
|
||||
case PURPUR_SLAB:
|
||||
case QUARTZ_SLAB:
|
||||
case RED_SANDSTONE_SLAB:
|
||||
case SANDSTONE_SLAB:
|
||||
case SPRUCE_SLAB:
|
||||
case STONE_BRICK_SLAB:
|
||||
case STONE_SLAB: return 0.5;
|
||||
case LILY_PAD: return 0.015625;
|
||||
case REPEATER: return 0.125;
|
||||
case SOUL_SAND: return 0.875;
|
||||
case COBBLESTONE_WALL:
|
||||
case MOSSY_COBBLESTONE_WALL: return 1.5;
|
||||
case FLOWER_POT: return 0.375;
|
||||
case COMPARATOR: return 0.125;
|
||||
case DAYLIGHT_DETECTOR: return 0.375;
|
||||
case HOPPER: return 0.625;
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case OAK_TRAPDOOR:
|
||||
case SPRUCE_TRAPDOOR:
|
||||
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
|
||||
return 0;
|
||||
} else if ("top".equals(block.getState(PropertyKey.HALF))) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0.1875;
|
||||
}
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
|
||||
default:
|
||||
return PropertyGroup.LEVEL.get(block);
|
||||
}
|
||||
}
|
||||
|
||||
private static int typeDataKey(int type, int data) {
|
||||
return (type << 4) | (data & 0xf);
|
||||
}
|
||||
|
||||
private static void addCardinals(int type, int west, int north, int east, int south) {
|
||||
dataAttachments.put(typeDataKey(type, west), PlayerDirection.WEST);
|
||||
dataAttachments.put(typeDataKey(type, north), PlayerDirection.NORTH);
|
||||
dataAttachments.put(typeDataKey(type, east), PlayerDirection.EAST);
|
||||
dataAttachments.put(typeDataKey(type, south), PlayerDirection.SOUTH);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* The colors for wool.
|
||||
|
Reference in New Issue
Block a user