Block construction time AABB config added for horizontal blocks. Added placement config for player horizontal lookvec reference. Added credits.md.

This commit is contained in:
stfwi 2019-02-12 20:24:45 +01:00
parent 70dda8ead2
commit 6d293bde25
7 changed files with 60 additions and 33 deletions

View file

@ -38,9 +38,10 @@ import java.util.List;
public class BlockDecor extends Block
{
public final long config;
public static final long CFG_CUTOUT = 0x0000000000000001L;
public final long config; // the config combines some aspects of blocks, allowing to define different behaviour at construction time, without excessive polymorphy.
public static final long CFG_CUTOUT = 0x0000000000000001L; // cutout rendering
public static final long CFG_HORIZIONTAL = 0x0000000000000002L; // horizontal block, affects bounding box calculation at construction time
public static final long CFG_HORIZIONTAL_PLACEMENT = 0x0000000000000004L; // placed in the horizontzal direction the player is looking when placing.
public BlockDecor(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
{

View file

@ -41,15 +41,15 @@ public class BlockDecorDirected extends BlockDecor
public BlockDecorDirected(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
{
super(registryName, config, material, hardness, resistance, sound);
final boolean is_horizontal = ((config & CFG_HORIZIONTAL)!=0);
AABBs = new ArrayList<AxisAlignedBB>(Arrays.asList(
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.DOWN),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.UP),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.NORTH),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.SOUTH),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.WEST),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST)
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.DOWN, is_horizontal),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.UP, is_horizontal),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.NORTH, is_horizontal),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.SOUTH, is_horizontal),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.WEST, is_horizontal),
ModAuxiliaries.getRotatedAABB(unrotatedAABB, EnumFacing.EAST, is_horizontal),
unrotatedAABB, unrotatedAABB // Array fill to ensure that the array size covers 4 bit (meta & 0x07).
));
}
@ -108,5 +108,13 @@ public class BlockDecorDirected extends BlockDecor
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{ return this.getDefaultState().withProperty(FACING, facing); }
{
if((config & CFG_HORIZIONTAL_PLACEMENT)!=0) {
// placement in direction the player is facing
return getDefaultState().withProperty(FACING, placer.getHorizontalFacing());
} else {
// default: placement on the face the player clicking
return getDefaultState().withProperty(FACING, facing);
}
}
}

View file

@ -38,9 +38,9 @@ import java.util.List;
public class BlockDecorLadder extends BlockLadder
{
protected static final AxisAlignedBB EDLADDER_SOUTH_AABB = ModAuxiliaries.getPixeledAABB(3, 0, 0, 13, 16, 2);
protected static final AxisAlignedBB EDLADDER_EAST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.EAST);
protected static final AxisAlignedBB EDLADDER_WEST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.WEST);
protected static final AxisAlignedBB EDLADDER_NORTH_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.NORTH);
protected static final AxisAlignedBB EDLADDER_EAST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.EAST, false);
protected static final AxisAlignedBB EDLADDER_WEST_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.WEST, false);
protected static final AxisAlignedBB EDLADDER_NORTH_AABB = ModAuxiliaries.getRotatedAABB(EDLADDER_SOUTH_AABB, EnumFacing.NORTH, false);
public BlockDecorLadder(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)

View file

@ -34,22 +34,29 @@ import javax.annotation.Nonnull;
@SuppressWarnings("unused")
public class ModBlocks
{
// Full blocks
public static final BlockDecorFull CLINKER_BRICK_WALL = new BlockDecorFull("clinker_brick_block", 0, Material.ROCK, 1.5f, 20f, SoundType.STONE);
public static final BlockDecorFull SLAG_BRICK_WALL = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 1.8f, 25f, SoundType.STONE);
public static final BlockDecorFull IRON_SHEET_ROOF_FULLBLOCK = new BlockDecorFull("iron_sheet_roof_block", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
// Ladders
public static final BlockDecorLadder METAL_RUNG_LADDER = new BlockDecorLadder("metal_rung_ladder", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
public static final BlockDecorLadder METAL_RUNG_STEPS = new BlockDecorLadder("metal_rung_steps", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
public static final BlockDecorLadder TREATED_WOOD_LADDER = new BlockDecorLadder("treated_wood_ladder", 0, Material.WOOD, 1.0f, 15f, SoundType.WOOD);
// Stairs or stairs-like
public static final BlockDecorStairs CLINKER_BRICK_STAIRS = new BlockDecorStairs("clinker_brick_stairs", CLINKER_BRICK_WALL.getDefaultState());
public static final BlockDecorStairs SLAG_BRICK_STAIRS = new BlockDecorStairs("slag_brick_stairs", SLAG_BRICK_WALL.getDefaultState());
public static final BlockDecorStairs IRON_SHEET_ROOF = new BlockDecorStairs("iron_sheet_roof", IRON_SHEET_ROOF_FULLBLOCK.getDefaultState());
// Oblongs and poles
public static final BlockDecorDirected TREATED_WOOD_POLE = new BlockDecorDirected("treated_wood_pole", 0, Material.WOOD, 1.0f, 15f, SoundType.WOOD, ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16));
// Furniture
public static final BlockDecor TREATED_WOOD_TABLE = new BlockDecor("treated_wood_table", BlockDecor.CFG_CUTOUT, Material.WOOD, 1.0f, 15f, SoundType.WOOD);
public static final BlockDecorDirected TREATED_WOOD_POLE = new BlockDecorDirected(
"treated_wood_pole",
BlockDecor.CFG_CUTOUT,
Material.WOOD, 1.0f, 15f, SoundType.WOOD,
ModAuxiliaries.getPixeledAABB(5.8,5.8,0, 10.2,10.2,16)
);
public static final BlockDecor TREATED_WOOD_TABLE = new BlockDecor(
"treated_wood_table",
BlockDecor.CFG_CUTOUT,
Material.WOOD, 1.0f, 15f, SoundType.WOOD
);
private static final Block modBlocks[] = {
SLAG_BRICK_WALL,
@ -60,7 +67,7 @@ public class ModBlocks
CLINKER_BRICK_STAIRS,
SLAG_BRICK_STAIRS,
TREATED_WOOD_POLE,
TREATED_WOOD_TABLE
TREATED_WOOD_TABLE,
};
private static final Block devBlocks[] = {

View file

@ -121,15 +121,26 @@ public class ModAuxiliaries
public static final AxisAlignedBB getPixeledAABB(double x0, double y0, double z0, double x1, double y1, double z1)
{ return new AxisAlignedBB(x0/16.0, y0/16.0, z0/16.0, x1/16.0, y1/16.0, z1/16.0); }
public static final AxisAlignedBB getRotatedAABB(AxisAlignedBB bb, EnumFacing new_facing)
public static final AxisAlignedBB getRotatedAABB(AxisAlignedBB bb, EnumFacing new_facing, boolean horizontal_rotation)
{
switch(new_facing.getIndex()) {
case 0: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // D
case 1: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // U
case 2: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // N
case 3: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // S --> bb
case 4: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // W
case 5: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // E
if(!horizontal_rotation) {
switch(new_facing.getIndex()) {
case 0: return new AxisAlignedBB(1-bb.maxX, 1-bb.maxZ, 1-bb.maxY, 1-bb.minX, 1-bb.minZ, 1-bb.minY); // D
case 1: return new AxisAlignedBB(1-bb.maxX, bb.minZ, bb.minY, 1-bb.minX, bb.maxZ, bb.maxY); // U
case 2: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // N
case 3: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // S --> bb
case 4: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // W
case 5: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // E
}
} else {
switch(new_facing.getIndex()) {
case 0: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // D --> bb
case 1: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // U --> bb
case 2: return new AxisAlignedBB( bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ); // N --> bb
case 3: return new AxisAlignedBB(1-bb.maxX, bb.minY, 1-bb.maxZ, 1-bb.minX, bb.maxY, 1-bb.minZ); // S
case 4: return new AxisAlignedBB( bb.minZ, bb.minY, 1-bb.maxX, bb.maxZ, bb.maxY, 1-bb.minX); // W
case 5: return new AxisAlignedBB(1-bb.maxZ, bb.minY, bb.minX, 1-bb.minZ, bb.maxY, bb.maxX); // E
}
}
return bb;
}

View file

@ -38,7 +38,7 @@ tile.engineersdecor.iron_sheet_roof.name=Iron sheet metal roof
tile.engineersdecor.iron_sheet_roof.help=§6Well, it's a roof.
#-----------------------------------------------------------------------------------------------------------
# Poles
# Poles and supports
#-----------------------------------------------------------------------------------------------------------
tile.engineersdecor.treated_wood_pole.name=Straight treated wood pole
tile.engineersdecor.treated_wood_pole.help=§6Straight pole fragment with the diameter of a wire relay.§r\n\

View file

@ -7,7 +7,7 @@
"mcversion": "${mcversion}",
"url": "https://github.com/stfwi/engineers-decor/",
"authorList": ["wile"],
"credits": "The Forge smiths, the Modders of the World.",
"credits": "BluSunrize, malte0811, et al., the Forge Smiths, the Modders of the World.",
"logoFile": "assets/engineersdecor/logo.png",
"screenshots": [],
"useDependencyInformation": false,