2010-10-15 07:22:03 +00:00
|
|
|
/*
|
2014-04-04 22:03:18 +00:00
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
2010-10-15 07:22:03 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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
|
2010-10-15 07:22:03 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* 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.
|
2010-10-15 07:22:03 +00:00
|
|
|
*
|
2014-04-04 22:03:18 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2010-10-15 07:22:03 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2010-10-15 07:22:03 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.blocks;
|
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import static com.google.common.base.Preconditions.checkNotNull;
|
|
|
|
|
2011-09-29 10:35:08 +00:00
|
|
|
import com.sk89q.worldedit.PlayerDirection;
|
2018-08-12 14:03:07 +00:00
|
|
|
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;
|
2014-04-03 04:23:14 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
import java.util.EnumMap;
|
2014-07-26 07:28:19 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2010-10-15 07:22:03 +00:00
|
|
|
/**
|
|
|
|
* Block types.
|
2018-01-03 05:35:51 +00:00
|
|
|
*
|
2018-07-05 08:15:51 +00:00
|
|
|
* {@deprecated Please use {@link com.sk89q.worldedit.world.block.BlockType }}
|
2010-10-15 07:22:03 +00:00
|
|
|
*/
|
2018-01-03 05:35:51 +00:00
|
|
|
@Deprecated
|
2018-08-12 14:03:07 +00:00
|
|
|
public class BlockType {
|
2013-11-17 21:03:37 +00:00
|
|
|
|
2018-08-12 14:03:07 +00:00
|
|
|
public static double centralTopLimit(com.sk89q.worldedit.world.block.BlockType type) {
|
|
|
|
checkNotNull(type);
|
|
|
|
return centralTopLimit(type.getDefaultState());
|
2011-09-29 10:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-12 14:03:07 +00:00
|
|
|
* 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.
|
2011-09-29 10:35:08 +00:00
|
|
|
*
|
2018-08-12 14:03:07 +00:00
|
|
|
* @param block the block
|
|
|
|
* @return the y offset
|
2011-09-29 10:35:08 +00:00
|
|
|
*/
|
2018-08-12 14:03:07 +00:00
|
|
|
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);
|
|
|
|
}
|
2011-09-29 10:35:08 +00:00
|
|
|
}
|
2011-04-21 23:40:11 +00:00
|
|
|
}
|