Added rebar concrete wall. Improved textures.

This commit is contained in:
stfwi 2019-02-17 22:31:47 +01:00
parent 3b2e829da2
commit 746ca98e91
13 changed files with 558 additions and 14 deletions

View file

@ -38,10 +38,13 @@ import java.util.List;
public class BlockDecor extends Block
{
public final long config; // the config combines some aspects of blocks, allowing to define different behaviour at construction time, without excessive polymorphy.
// The config combines some aspects of blocks, allowing to define different behaviour at construction time, without excessive polymorphy.
// It's an old school flag set as it is used internally only and shall not have as littlt impact on performance as possible.
public final long config;
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 static final long CFG_WALL_DOOR_CONNECTION = 0x0000000000000008L; // wall block connects to fence gates and doors.
public BlockDecor(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
{

View file

@ -25,7 +25,7 @@ public class BlockDecorFull extends BlockDecor
public BlockDecorFull(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
{
super(registryName, config, material, hardness, resistance, sound);
setLightOpacity(1);
setLightOpacity(255);
}
@Override

View file

@ -0,0 +1,180 @@
/*
* @file BlockDecorWall.java
* @author Stefan Wilhelm (wile)
* @copyright (C) 2019 Stefan Wilhelm
* @license MIT (see https://opensource.org/licenses/MIT)
*
* Wall blocks. This block is derived from vanilla BlockWall
*/
package wile.engineersdecor.blocks;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
/**
* As strange as it is, I could not properly get a block derived from BlockWall working,
* either the VARIANT made issues, or the item model was duplicated (using state mapper),
* so, this is now basically a BlockWall without the VARIANT propery. Anyway a solved issue
* in mc1.13+. Deriving from BlockDecor to have the tooltip, creativetab etc already set up.
*/
public class BlockDecorWall extends BlockDecor
{
public static final PropertyBool UP = BlockWall.UP;
public static final PropertyBool NORTH = BlockWall.NORTH;
public static final PropertyBool EAST = BlockWall.EAST;
public static final PropertyBool SOUTH = BlockWall.SOUTH;
public static final PropertyBool WEST = BlockWall.WEST;
private static final double d_0 = 0.0d;
private static final double d_1 = 1.0d;
private static final double d_a = 0.25d;
private static final double d_b = 1.0d-d_a;
private static final double d_k = 0.26d; // 0.3125D;
private static final double d_l = 1.0d-d_k;
protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[] {
new AxisAlignedBB(d_a, d_0, d_a, d_b, d_1, d_b),
new AxisAlignedBB(d_a, d_0, d_a, d_b, d_1, d_1),
new AxisAlignedBB(d_0, d_0, d_a, d_b, d_1, d_b),
new AxisAlignedBB(d_0, d_0, d_a, d_b, d_1, d_1),
new AxisAlignedBB(d_a, d_0, d_0, d_b, d_1, d_b),
new AxisAlignedBB(d_k, d_0, d_0, d_l, d_1, d_1),
new AxisAlignedBB(d_0, d_0, d_0, d_b, d_1, d_b),
new AxisAlignedBB(d_0, d_0, d_0, d_b, d_1, d_1),
new AxisAlignedBB(d_a, d_0, d_a, d_1, d_1, d_b),
new AxisAlignedBB(d_a, d_0, d_a, d_1, d_1, d_1),
new AxisAlignedBB(d_0, d_0, d_k, d_1, d_1, d_l),
new AxisAlignedBB(d_0, d_0, d_a, d_1, d_1, d_1),
new AxisAlignedBB(d_a, d_0, d_0, d_1, d_1, d_b),
new AxisAlignedBB(d_a, d_0, d_0, d_1, d_1, d_1),
new AxisAlignedBB(d_0, d_0, d_0, d_1, d_1, d_b),
new AxisAlignedBB(d_0, d_0, d_0, d_1, d_1, d_1)
};
private static final double clip_height = 1.5d;
protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[] { AABB_BY_INDEX[0].setMaxY(clip_height), AABB_BY_INDEX[1].setMaxY(clip_height), AABB_BY_INDEX[2].setMaxY(clip_height), AABB_BY_INDEX[3].setMaxY(clip_height), AABB_BY_INDEX[4].setMaxY(clip_height), AABB_BY_INDEX[5].setMaxY(clip_height), AABB_BY_INDEX[6].setMaxY(clip_height), AABB_BY_INDEX[7].setMaxY(clip_height), AABB_BY_INDEX[8].setMaxY(clip_height), AABB_BY_INDEX[9].setMaxY(clip_height), AABB_BY_INDEX[10].setMaxY(clip_height), AABB_BY_INDEX[11].setMaxY(clip_height), AABB_BY_INDEX[12].setMaxY(clip_height), AABB_BY_INDEX[13].setMaxY(clip_height), AABB_BY_INDEX[14].setMaxY(clip_height), AABB_BY_INDEX[15].setMaxY(clip_height) };
public BlockDecorWall(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound)
{
super(registryName, config, material, hardness, resistance, sound);
setDefaultState(blockState.getBaseState().withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
}
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
{ return AABB_BY_INDEX[getAABBIndex(getActualState(state, source, pos))]; }
@Override
@SuppressWarnings("deprecation")
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean isActualState)
{ addCollisionBoxToList(pos, entityBox, collidingBoxes, CLIP_AABB_BY_INDEX[getAABBIndex(isActualState ? state : getActualState(state, world, pos))]); }
@Nullable
@Override
@SuppressWarnings("deprecation")
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos)
{ return CLIP_AABB_BY_INDEX[getAABBIndex(getActualState(state, world, pos))]; }
private static int getAABBIndex(IBlockState state)
{ return ((!(state.getValue(NORTH))) ? 0 : (1<<EnumFacing.NORTH.getHorizontalIndex()))
| ((!(state.getValue( EAST))) ? 0 : (1<<EnumFacing.EAST.getHorizontalIndex()))
| ((!(state.getValue(SOUTH))) ? 0 : (1<<EnumFacing.SOUTH.getHorizontalIndex()))
| ((!(state.getValue( WEST))) ? 0 : (1<<EnumFacing.WEST.getHorizontalIndex()));
}
@Override
@SuppressWarnings("deprecation")
public boolean isFullCube(IBlockState state)
{ return false; }
@Override
@SuppressWarnings("deprecation")
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{ return false; }
@Override
@SuppressWarnings("deprecation")
public boolean isOpaqueCube(IBlockState state)
{ return false; }
@Override
@SuppressWarnings("deprecation")
public boolean isNormalCube(IBlockState state)
{ return false; }
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176253_3_)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176253_3_);
boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE_THICK || blockfaceshape == BlockFaceShape.MIDDLE_POLE && block instanceof BlockFenceGate;
return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
protected static boolean isExcepBlockForAttachWithPiston(Block b)
{ return Block.isExceptBlockForAttachWithPiston(b) || (b==Blocks.BARRIER) || (b==Blocks.MELON_BLOCK) || (b==Blocks.PUMPKIN) || (b==Blocks.LIT_PUMPKIN); }
@Override
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
{ return (side!=EnumFacing.DOWN) || (super.shouldSideBeRendered(blockState, blockAccess, pos, side)); }
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateFromMeta(int meta)
{ return getDefaultState(); }
@Override
@SuppressWarnings("deprecation")
public int getMetaFromState(IBlockState state)
{ return 0; }
@Override
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
boolean n = canWallConnectTo(worldIn, pos, EnumFacing.NORTH);
boolean e = canWallConnectTo(worldIn, pos, EnumFacing.EAST);
boolean s = canWallConnectTo(worldIn, pos, EnumFacing.SOUTH);
boolean w = canWallConnectTo(worldIn, pos, EnumFacing.WEST);
boolean straight = (n && !e && s && !w) || (!n && e && !s && w);
return state.withProperty(UP,!straight).withProperty(NORTH, n).withProperty(EAST, e).withProperty(SOUTH, s).withProperty(WEST, w);
}
@Override
protected BlockStateContainer createBlockState()
{ return new BlockStateContainer(this, new IProperty[] {UP, NORTH, EAST, WEST, SOUTH}); }
@Override
@SuppressWarnings("deprecation")
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{ return ((face!=EnumFacing.UP) && (face!=EnumFacing.DOWN)) ? (BlockFaceShape.MIDDLE_POLE_THICK) : (BlockFaceShape.CENTER_BIG); }
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
{ return canConnectTo(world, pos.offset(facing), facing.getOpposite()); }
private boolean canWallConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
{
BlockPos other = pos.offset(facing);
Block block = world.getBlockState(other).getBlock();
return block.canBeConnectedTo(world, other, facing.getOpposite()) || canConnectTo(world, other, facing.getOpposite());
}
}

View file

@ -34,18 +34,21 @@ import javax.annotation.Nonnull;
@SuppressWarnings("unused")
public class ModBlocks
{
public static final BlockDecorFull CLINKER_BRICK_WALL = new BlockDecorFull("clinker_brick_block", 0, Material.ROCK, 2f, 50f, SoundType.STONE);
public static final BlockDecorFull SLAG_BRICK_WALL = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 2f, 50f, SoundType.STONE);
public static final BlockDecorFull CLINKER_BRICK_BLOCK = new BlockDecorFull("clinker_brick_block", 0, Material.ROCK, 2f, 50f, SoundType.STONE);
public static final BlockDecorStairs CLINKER_BRICK_STAIRS = new BlockDecorStairs("clinker_brick_stairs", CLINKER_BRICK_BLOCK.getDefaultState());
public static final BlockDecorFull SLAG_BRICK_BLOCK = new BlockDecorFull("slag_brick_block", 0, Material.ROCK, 2f, 50f, SoundType.STONE);
public static final BlockDecorStairs SLAG_BRICK_STAIRS = new BlockDecorStairs("slag_brick_stairs", SLAG_BRICK_BLOCK.getDefaultState());
public static final BlockDecorFull IRON_SHEET_ROOF_FULLBLOCK = new BlockDecorFull("iron_sheet_roof_block", 0, Material.IRON, 1.8f, 25f, SoundType.METAL);
public static final BlockDecorFull REBAR_CONCRETE = new BlockDecorFull("rebar_concrete", 0, Material.ROCK, 8f, 2000f, SoundType.STONE);
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);
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());
public static final BlockDecorFull REBAR_CONCRETE_BLOCK = new BlockDecorFull("rebar_concrete", 0, Material.ROCK, 8f, 2000f, SoundType.STONE);
public static final BlockDecorStairs REBAR_CONCRETE_STAIRS = new BlockDecorStairs("rebar_concrete_stairs", REBAR_CONCRETE_BLOCK.getDefaultState());
public static final BlockDecorWall REBAR_CONCRETE_WALL = new BlockDecorWall("rebar_concrete_wall", BlockDecor.CFG_WALL_DOOR_CONNECTION, Material.ROCK, 8f, 2000f, SoundType.STONE);
public static final BlockDecorDirected TREATED_WOOD_POLE = new BlockDecorDirected(
"treated_wood_pole",
@ -53,15 +56,18 @@ public class ModBlocks
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
);
public static final BlockDecorStairs IRON_SHEET_ROOF = new BlockDecorStairs("iron_sheet_roof", IRON_SHEET_ROOF_FULLBLOCK.getDefaultState());
private static final Block modBlocks[] = {
SLAG_BRICK_WALL,
CLINKER_BRICK_WALL,
SLAG_BRICK_BLOCK,
CLINKER_BRICK_BLOCK,
METAL_RUNG_LADDER,
METAL_RUNG_STEPS,
TREATED_WOOD_LADDER,
@ -69,7 +75,9 @@ public class ModBlocks
SLAG_BRICK_STAIRS,
TREATED_WOOD_POLE,
TREATED_WOOD_TABLE,
REBAR_CONCRETE,
REBAR_CONCRETE_BLOCK,
REBAR_CONCRETE_STAIRS,
REBAR_CONCRETE_WALL,
};
private static final Block devBlocks[] = {