Fixed AI path issue #116. Dark Shingle Roof added (experimental).
This commit is contained in:
parent
6876063b70
commit
267233d994
64 changed files with 1045 additions and 40 deletions
|
@ -521,6 +521,8 @@ public class ModConfig
|
|||
// Cache
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@Deprecated
|
||||
private static String const_exclude_patterns = "dark_shingle_*"; // experimental
|
||||
private static final CompoundNBT server_config_ = new CompoundNBT();
|
||||
private static HashSet<String> optouts_ = new HashSet<>();
|
||||
private static boolean with_experimental_features_ = false;
|
||||
|
@ -551,6 +553,7 @@ public class ModConfig
|
|||
{
|
||||
String exc = SERVER.pattern_excludes.get().toLowerCase().replaceAll(MODID+":", "").replaceAll("[^*_,a-z0-9]", "");
|
||||
if(!exc.isEmpty()) LOGGER.info("Config pattern excludes: '" + exc + "'");
|
||||
if(!const_exclude_patterns.isEmpty()) exc += "," + const_exclude_patterns;
|
||||
String[] excl = exc.split(",");
|
||||
excludes_.clear();
|
||||
for(int i=0; i< excl.length; ++i) {
|
||||
|
|
|
@ -211,6 +211,28 @@ public class ModContent
|
|||
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static final EdRoofBlock DARK_CERAMIC_SHINGLE_ROOF = (EdRoofBlock)(new EdRoofBlock(
|
||||
DecorBlock.CFG_DEFAULT,
|
||||
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dark_shingle_roof"));
|
||||
|
||||
public static final DecorBlock.Normal DARK_CERAMIC_SHINGLE_ROOF_BLOCK = (DecorBlock.Normal)(new DecorBlock.Normal(
|
||||
DecorBlock.CFG_DEFAULT,
|
||||
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dark_shingle_roof_block"));
|
||||
|
||||
public static final EdSlabBlock DARK_CERAMIC_SHINGLE_ROOF_SLAB = (EdSlabBlock)(new EdSlabBlock(
|
||||
DecorBlock.CFG_DEFAULT,
|
||||
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dark_shingle_roof_slab"));
|
||||
|
||||
public static final EdSlabSliceBlock HALFSLAB_DARK_CERAMIC_SHINGLE_ROOF = (EdSlabSliceBlock)(new EdSlabSliceBlock(
|
||||
DecorBlock.CFG_CUTOUT,
|
||||
Block.Properties.create(Material.ROCK, MaterialColor.STONE).hardnessAndResistance(2f, 15f).sound(SoundType.STONE)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "dark_shingle_roof_slabslice"));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static final EdGroundBlock DENSE_GRIT_SAND = (EdGroundBlock)(new EdGroundBlock(
|
||||
DecorBlock.CFG_DEFAULT,
|
||||
Block.Properties.create(Material.EARTH, MaterialColor.DIRT).hardnessAndResistance(0.5f, 3f).sound(SoundType.GROUND).harvestTool(ToolType.SHOVEL)
|
||||
|
@ -281,7 +303,7 @@ public class ModContent
|
|||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_side_table"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable TREATED_WOOD_WINDOWSILL = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_FACING_PLACEMENT,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(2f, 15f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(0.5,15,10.5, 15.5,16,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "treated_wood_windowsill"));
|
||||
|
@ -295,19 +317,19 @@ public class ModContent
|
|||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable INSET_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(5.2,5.2,0, 10.8,10.8,0.3)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_inset_light"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable FLOOR_EDGE_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(5,0,0, 11,2,0.5)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_floor_edge_light"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable CEILING_EDGE_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_LOOK_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(),
|
||||
new AxisAlignedBB[]{
|
||||
Auxiliaries.getPixeledAABB( 0,15.5,0, 16,16,2.0),
|
||||
|
@ -318,7 +340,7 @@ public class ModContent
|
|||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "iron_ceiling_edge_light"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable BULB_LIGHT_IRON = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_OPPOSITE_PLACEMENT|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.IRON, MaterialColor.IRON).hardnessAndResistance(2f, 15f).sound(SoundType.METAL).func_235838_a_((state)->15).notSolid(),
|
||||
new AxisAlignedBB[]{
|
||||
Auxiliaries.getPixeledAABB(6.5,6.5,1, 9.5,9.5,4),
|
||||
|
@ -407,37 +429,37 @@ public class ModContent
|
|||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_MODLOGO = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1000f).sound(SoundType.WOOD).func_235838_a_((state)->1).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(0,0,15.6, 16,16,16.0)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_decor"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_HOTWIRE = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_hotwire"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_DANGER = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_danger"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_DEFENSE = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_defense"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_FACTORY_AREA = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(2,2,15.6, 14,14,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_factoryarea"));
|
||||
|
||||
public static final DecorBlock.DirectedWaterLoggable SIGN_EXIT = (DecorBlock.DirectedWaterLoggable)(new DecorBlock.DirectedWaterLoggable(
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL,
|
||||
DecorBlock.CFG_CUTOUT|DecorBlock.CFG_FACING_PLACEMENT|DecorBlock.CFG_HORIZIONTAL|DecorBlock.CFG_AI_PASSABLE,
|
||||
Block.Properties.create(Material.WOOD, MaterialColor.WOOD).hardnessAndResistance(1f, 1f).sound(SoundType.WOOD).notSolid(),
|
||||
Auxiliaries.getPixeledAABB(3,7,15.6, 13,13,16)
|
||||
)).setRegistryName(new ResourceLocation(ModEngineersDecor.MODID, "sign_exit"));
|
||||
|
@ -793,6 +815,10 @@ public class ModContent
|
|||
CONCRETE_WALL,
|
||||
PANZERGLASS_BLOCK,
|
||||
PANZERGLASS_SLAB,
|
||||
DARK_CERAMIC_SHINGLE_ROOF,
|
||||
DARK_CERAMIC_SHINGLE_ROOF_BLOCK,
|
||||
DARK_CERAMIC_SHINGLE_ROOF_SLAB,
|
||||
HALFSLAB_DARK_CERAMIC_SHINGLE_ROOF,
|
||||
METAL_RUNG_LADDER,
|
||||
METAL_RUNG_STEPS,
|
||||
TREATED_WOOD_LADDER,
|
||||
|
|
|
@ -37,6 +37,7 @@ public class DecorBlock
|
|||
public static final long CFG_FLIP_PLACEMENT_IF_SAME = StandardBlocks.CFG_FLIP_PLACEMENT_IF_SAME;
|
||||
public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = StandardBlocks.CFG_FLIP_PLACEMENT_SHIFTCLICK;
|
||||
public static final long CFG_STRICT_CONNECTIONS = StandardBlocks.CFG_STRICT_CONNECTIONS;
|
||||
public static final long CFG_AI_PASSABLE = StandardBlocks.CFG_AI_PASSABLE;
|
||||
public static final long CFG_HARD_IE_DEPENDENT = 0x8000000000000000L;
|
||||
|
||||
public static class Normal extends StandardBlocks.BaseBlock implements IDecorBlock
|
||||
|
|
|
@ -62,7 +62,7 @@ public class EdHatchBlock extends DecorBlock.HorizontalWaterLoggable implements
|
|||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean allowsMovement(BlockState state, IBlockReader world, BlockPos pos, PathType type)
|
||||
{ return state.get(OPEN); }
|
||||
{ return !state.get(OPEN); }
|
||||
|
||||
@Override
|
||||
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity)
|
||||
|
|
202
src/main/java/wile/engineersdecor/blocks/EdRoofBlock.java
Normal file
202
src/main/java/wile/engineersdecor/blocks/EdRoofBlock.java
Normal file
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* @file EdRoofBlock.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Roof blocks.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.pathfinding.PathType;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.properties.Half;
|
||||
import net.minecraft.state.properties.StairsShape;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import wile.engineersdecor.libmc.blocks.StandardBlocks;
|
||||
import wile.engineersdecor.libmc.detail.Auxiliaries;
|
||||
|
||||
|
||||
public class EdRoofBlock extends StandardBlocks.HorizontalWaterLoggable implements IDecorBlock
|
||||
{
|
||||
public static final EnumProperty<StairsShape> SHAPE = BlockStateProperties.STAIRS_SHAPE;
|
||||
public static final EnumProperty<Half> HALF = BlockStateProperties.HALF;
|
||||
private static final VoxelShape[][][] SHAPE_CACHE = makeShapes();
|
||||
|
||||
public EdRoofBlock(long config, Block.Properties properties)
|
||||
{
|
||||
super(config,
|
||||
properties.func_235838_a_((state)->1), // .notSolid() shade rendering again messed up
|
||||
Auxiliaries.getPixeledAABB(0, 0,0,16, 8, 16));
|
||||
setDefaultState(stateContainer.getBaseState().with(HORIZONTAL_FACING, Direction.NORTH).with(SHAPE, StairsShape.STRAIGHT).with(WATERLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext context)
|
||||
{ return SHAPE_CACHE[state.get(HALF).ordinal()][state.get(HORIZONTAL_FACING).getIndex()][state.get(SHAPE).ordinal()]; }
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
{ super.fillStateContainer(builder); builder.add(SHAPE, HALF); }
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state)
|
||||
{ return state.get(WATERLOGGED) ? Fluids.WATER.getStillFluidState(false) : super.getFluidState(state); }
|
||||
|
||||
@Override
|
||||
public boolean allowsMovement(BlockState state, IBlockReader world, BlockPos pos, PathType type)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
BlockPos pos = context.getPos();
|
||||
Direction face = context.getFace();
|
||||
BlockState state = getDefaultState()
|
||||
.with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing())
|
||||
.with(HALF, (face == Direction.DOWN) ? Half.TOP : Half.BOTTOM)
|
||||
.with(WATERLOGGED, context.getWorld().getFluidState(pos).getFluid()==Fluids.WATER);
|
||||
return state.with(SHAPE, getStairsShapeProperty(state, context.getWorld(), pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos)
|
||||
{
|
||||
if(state.get(WATERLOGGED)) world.getPendingFluidTicks().scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
return (facing.getAxis().isHorizontal()) ? (state.with(SHAPE, getStairsShapeProperty(state, world, pos))) : (super.updatePostPlacement(state, facing, facingState, world, pos, facingPos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState rotate(BlockState state, Rotation rot)
|
||||
{ return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockState mirror(BlockState state, Mirror where)
|
||||
{
|
||||
if((where==Mirror.LEFT_RIGHT) && (state.get(HORIZONTAL_FACING).getAxis()==Direction.Axis.Z)) {
|
||||
switch(state.get(SHAPE)) {
|
||||
case INNER_LEFT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.INNER_RIGHT);
|
||||
case INNER_RIGHT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.INNER_LEFT);
|
||||
case OUTER_LEFT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.OUTER_RIGHT);
|
||||
case OUTER_RIGHT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.OUTER_LEFT);
|
||||
default: return state.rotate(Rotation.CLOCKWISE_180);
|
||||
}
|
||||
} else if((where==Mirror.FRONT_BACK) && (state.get(HORIZONTAL_FACING).getAxis() == Direction.Axis.X)) {
|
||||
switch(state.get(SHAPE)) {
|
||||
case INNER_LEFT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.INNER_LEFT);
|
||||
case INNER_RIGHT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.INNER_RIGHT);
|
||||
case OUTER_LEFT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.OUTER_RIGHT);
|
||||
case OUTER_RIGHT: return state.rotate(Rotation.CLOCKWISE_180).with(SHAPE, StairsShape.OUTER_LEFT);
|
||||
case STRAIGHT: return state.rotate(Rotation.CLOCKWISE_180);
|
||||
}
|
||||
}
|
||||
return super.mirror(state, where);
|
||||
}
|
||||
|
||||
private static boolean isRoofBlock(BlockState state)
|
||||
{ return (state.getBlock() instanceof EdRoofBlock); }
|
||||
|
||||
private static boolean isOtherRoofState(BlockState state, IBlockReader world, BlockPos pos, Direction facing)
|
||||
{
|
||||
BlockState st = world.getBlockState(pos.offset(facing));
|
||||
return (!isRoofBlock(st)) || (st.get(HORIZONTAL_FACING) != state.get(HORIZONTAL_FACING));
|
||||
}
|
||||
|
||||
private static VoxelShape[][][] makeShapes()
|
||||
{
|
||||
VoxelShape[][][] shapes = new VoxelShape[2][6][5];
|
||||
for(int half_index=0; half_index<Half.values().length; ++half_index) {
|
||||
for(int direction_index=0; direction_index<Direction.values().length; ++direction_index) {
|
||||
for(int stairs_shape_index=0; stairs_shape_index<StairsShape.values().length; ++stairs_shape_index) {
|
||||
shapes[half_index][direction_index][stairs_shape_index] = makeShape(half_index, direction_index, stairs_shape_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
return shapes;
|
||||
}
|
||||
|
||||
private static VoxelShape makeShape(int half_index, int direction_index, int stairs_shape_index)
|
||||
{
|
||||
AxisAlignedBB[] straight = new AxisAlignedBB[]{
|
||||
Auxiliaries.getPixeledAABB( 0, 0, 0, 16, 4, 16),
|
||||
Auxiliaries.getPixeledAABB( 4, 4, 0, 16, 8, 16),
|
||||
Auxiliaries.getPixeledAABB( 8, 8, 0, 16, 12, 16),
|
||||
Auxiliaries.getPixeledAABB(12, 12, 0, 16, 16, 16)
|
||||
};
|
||||
AxisAlignedBB[] pyramid = new AxisAlignedBB[]{
|
||||
Auxiliaries.getPixeledAABB( 0, 0, 0, 16, 4, 16),
|
||||
Auxiliaries.getPixeledAABB( 4, 4, 4, 16, 8, 16),
|
||||
Auxiliaries.getPixeledAABB( 8, 8, 8, 16, 12, 16),
|
||||
Auxiliaries.getPixeledAABB(12, 12, 12, 16, 16, 16)
|
||||
};
|
||||
final Half half = Half.values()[half_index];
|
||||
if(half==Half.TOP) {
|
||||
straight = Auxiliaries.getMirroredAABB(straight, Axis.Y);
|
||||
pyramid = Auxiliaries.getMirroredAABB(pyramid, Axis.Y);
|
||||
}
|
||||
Direction direction = Direction.byIndex(direction_index);
|
||||
if((direction==Direction.UP) || (direction==Direction.DOWN)) return VoxelShapes.fullCube();
|
||||
direction_index = (direction.getHorizontalIndex()+1) & 0x03; // ref NORTH -> EAST for stairs compliancy.
|
||||
final StairsShape stairs = StairsShape.values()[stairs_shape_index];
|
||||
switch(stairs) {
|
||||
case STRAIGHT:
|
||||
return Auxiliaries.getUnionShape(Auxiliaries.getYRotatedAABB(straight, direction_index));
|
||||
case OUTER_LEFT:
|
||||
return Auxiliaries.getUnionShape(Auxiliaries.getYRotatedAABB(pyramid, direction_index-1));
|
||||
case OUTER_RIGHT:
|
||||
return Auxiliaries.getUnionShape(Auxiliaries.getYRotatedAABB(pyramid, direction_index));
|
||||
case INNER_LEFT:
|
||||
return Auxiliaries.getUnionShape(
|
||||
Auxiliaries.getYRotatedAABB(straight, direction_index),
|
||||
Auxiliaries.getYRotatedAABB(straight, direction_index-1)
|
||||
);
|
||||
case INNER_RIGHT:
|
||||
return Auxiliaries.getUnionShape(
|
||||
Auxiliaries.getYRotatedAABB(straight, direction_index),
|
||||
Auxiliaries.getYRotatedAABB(straight, direction_index+1)
|
||||
);
|
||||
default:
|
||||
return VoxelShapes.fullCube();
|
||||
}
|
||||
}
|
||||
|
||||
private static StairsShape getStairsShapeProperty(BlockState state, IBlockReader world, BlockPos pos)
|
||||
{
|
||||
Direction direction = state.get(HORIZONTAL_FACING);
|
||||
{
|
||||
BlockState ns = world.getBlockState(pos.offset(direction));
|
||||
if(isRoofBlock(ns) && (state.get(HALF) == ns.get(HALF))) {
|
||||
Direction nf = ns.get(HORIZONTAL_FACING);
|
||||
if(nf.getAxis() != state.get(HORIZONTAL_FACING).getAxis() && isOtherRoofState(state, world, pos, nf.getOpposite())) {
|
||||
return (nf == direction.rotateYCCW()) ? StairsShape.OUTER_LEFT : StairsShape.OUTER_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
BlockState ns = world.getBlockState(pos.offset(direction.getOpposite()));
|
||||
if(isRoofBlock(ns) && (state.get(HALF) == ns.get(HALF))) {
|
||||
Direction nf = ns.get(HORIZONTAL_FACING);
|
||||
if(nf.getAxis() != state.get(HORIZONTAL_FACING).getAxis() && isOtherRoofState(state, world, pos, nf)) {
|
||||
return (nf == direction.rotateYCCW()) ? StairsShape.INNER_LEFT : StairsShape.INNER_RIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return StairsShape.STRAIGHT;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
package wile.engineersdecor.libmc.blocks;
|
||||
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.pathfinding.PathType;
|
||||
import wile.engineersdecor.libmc.detail.Auxiliaries;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EntityType;
|
||||
|
@ -66,6 +67,7 @@ public class StandardBlocks
|
|||
public static final long CFG_FLIP_PLACEMENT_IF_SAME = 0x0000000000000100L; // placement direction flipped if an instance of the same class was clicked
|
||||
public static final long CFG_FLIP_PLACEMENT_SHIFTCLICK = 0x0000000000000200L; // placement direction flipped if player is sneaking
|
||||
public static final long CFG_STRICT_CONNECTIONS = 0x0000000000000400L; // blocks do not connect to similar blocks around (implementation details may vary a bit)
|
||||
public static final long CFG_AI_PASSABLE = 0x0000000000000800L; // does not block movement path for AI, needed for non-opaque blocks with collision shapes not thin at the bottom or one side.
|
||||
|
||||
public interface IStandardBlock
|
||||
{
|
||||
|
@ -94,7 +96,7 @@ public class StandardBlocks
|
|||
{
|
||||
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
|
||||
public final long config;
|
||||
public final VoxelShape vshape;
|
||||
private final VoxelShape vshape;
|
||||
|
||||
public BaseBlock(long conf, Block.Properties properties)
|
||||
{ this(conf, properties, Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16,16 )); }
|
||||
|
@ -134,7 +136,12 @@ public class StandardBlocks
|
|||
|
||||
@Override
|
||||
public RenderTypeHint getRenderTypeHint()
|
||||
{ return ((config & CFG_CUTOUT)!=0) ? RenderTypeHint.CUTOUT : RenderTypeHint.SOLID; }
|
||||
{
|
||||
if((config & CFG_CUTOUT)!=0) return RenderTypeHint.CUTOUT;
|
||||
if((config & CFG_MIPPED)!=0) return RenderTypeHint.CUTOUT_MIPPED;
|
||||
if((config & CFG_TRANSLUCENT)!=0) return RenderTypeHint.TRANSLUCENT;
|
||||
return RenderTypeHint.SOLID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -146,6 +153,11 @@ public class StandardBlocks
|
|||
public VoxelShape getCollisionShape(BlockState state, IBlockReader world, BlockPos pos, ISelectionContext selectionContext)
|
||||
{ return vshape; }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean allowsMovement(BlockState state, IBlockReader world, BlockPos pos, PathType type)
|
||||
{ return ((config & CFG_AI_PASSABLE)==0) ? false : super.allowsMovement(state, world, pos, type); }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package wile.engineersdecor.libmc.blocks;
|
||||
|
||||
import net.minecraft.entity.EntitySpawnPlacementRegistry;
|
||||
import net.minecraft.pathfinding.PathType;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.client.util.InputMappings;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.SharedConstants;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
|
@ -262,15 +263,47 @@ public class Auxiliaries
|
|||
|
||||
public static final AxisAlignedBB[] getRotatedAABB(AxisAlignedBB[] bbs, Direction new_facing, boolean horizontal_rotation)
|
||||
{
|
||||
AxisAlignedBB[] transformed = new AxisAlignedBB[bbs.length];
|
||||
final AxisAlignedBB[] transformed = new AxisAlignedBB[bbs.length];
|
||||
for(int i=0; i<bbs.length; ++i) transformed[i] = getRotatedAABB(bbs[i], new_facing, horizontal_rotation);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static final VoxelShape getUnionShape(AxisAlignedBB[] aabbs)
|
||||
public static final AxisAlignedBB getYRotatedAABB(AxisAlignedBB bb, int clockwise_90deg_steps)
|
||||
{
|
||||
final Direction direction_map[] = new Direction[]{Direction.NORTH,Direction.EAST,Direction.SOUTH,Direction.WEST};
|
||||
return getRotatedAABB(bb, direction_map[(clockwise_90deg_steps+4096) & 0x03], true);
|
||||
}
|
||||
|
||||
public static final AxisAlignedBB[] getYRotatedAABB(AxisAlignedBB[] bbs, int clockwise_90deg_steps)
|
||||
{
|
||||
final AxisAlignedBB[] transformed = new AxisAlignedBB[bbs.length];
|
||||
for(int i=0; i<bbs.length; ++i) transformed[i] = getYRotatedAABB(bbs[i], clockwise_90deg_steps);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static final AxisAlignedBB getMirroredAABB(AxisAlignedBB bb, Axis axis)
|
||||
{
|
||||
switch(axis) {
|
||||
case X: return new AxisAlignedBB(1-bb.maxX, bb.minY, bb.minZ, 1-bb.minX, bb.maxY, bb.maxZ);
|
||||
case Y: return new AxisAlignedBB(bb.minX, 1-bb.maxY, bb.minZ, bb.maxX, 1-bb.minY, bb.maxZ);
|
||||
case Z: return new AxisAlignedBB(bb.minX, bb.minY, 1-bb.maxZ, bb.maxX, bb.maxY, 1-bb.minZ);
|
||||
default: return bb;
|
||||
}
|
||||
}
|
||||
|
||||
public static final AxisAlignedBB[] getMirroredAABB(AxisAlignedBB[] bbs, Axis axis)
|
||||
{
|
||||
final AxisAlignedBB[] transformed = new AxisAlignedBB[bbs.length];
|
||||
for(int i=0; i<bbs.length; ++i) transformed[i] = getMirroredAABB(bbs[i], axis);
|
||||
return transformed;
|
||||
}
|
||||
|
||||
public static final VoxelShape getUnionShape(AxisAlignedBB[] ... aabb_list)
|
||||
{
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
for(AxisAlignedBB aabb: aabbs) shape = VoxelShapes.combine(shape, VoxelShapes.create(aabb), IBooleanFunction.OR);
|
||||
for(AxisAlignedBB[] aabbs:aabb_list) {
|
||||
for(AxisAlignedBB aabb: aabbs) shape = VoxelShapes.combine(shape, VoxelShapes.create(aabb), IBooleanFunction.OR);
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ public class OptionalRecipeCondition implements ICondition
|
|||
item_optouts = item_optout_provider;
|
||||
}
|
||||
|
||||
|
||||
public OptionalRecipeCondition(ResourceLocation result, List<ResourceLocation> required, List<ResourceLocation> missing, List<ResourceLocation> required_tags, List<ResourceLocation> missing_tags, boolean isexperimental, boolean result_is_tag)
|
||||
{
|
||||
all_required = required;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue