Walls render in inventory now
Includes a bit of cleanup and fixes pickblock on Pillars and Caps
This commit is contained in:
parent
78b035d0fd
commit
a62e377801
|
@ -37,18 +37,8 @@ public class BlockDemonWallBase extends BlockStringWall implements IVariantProvi
|
||||||
{
|
{
|
||||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||||
|
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < names.length; i++)
|
||||||
{
|
ret.add(Pair.of(i, "east=false,north=false,south=false,type=" + names[i] + ",up=true,west=false"));
|
||||||
boolean up = (i & 1) == 0;
|
|
||||||
boolean north = (i & 2) == 2;
|
|
||||||
boolean south = (i & 4) == 4;
|
|
||||||
boolean east = (i & 8) == 8;
|
|
||||||
boolean west = (i & 16) == 16;
|
|
||||||
for (int j = 0; j < names.length; j++)
|
|
||||||
{
|
|
||||||
ret.add(new ImmutablePair<Integer, String>(i * names.length + j, "up=" + (up ? "true" : "false") + ",north=" + (north ? "true" : "false") + ",south=" + (south ? "true" : "false") + ",east=" + (east ? "true" : "false") + ",west=" + (west ? "true" : "false") + ",type=" + names[j]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.Rotation;
|
import net.minecraft.util.Rotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||||
|
@ -30,35 +31,40 @@ public class BlockStringPillar extends BlockString
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta)
|
public IBlockState getStateFromMeta(int meta)
|
||||||
{
|
{
|
||||||
IBlockState iblockstate = getBlockState().getBaseState().withProperty(this.getStringProp(), this.getValues().get(meta % 5));
|
IBlockState state = getBlockState().getBaseState().withProperty(this.getStringProp(), this.getValues().get(meta % 5));
|
||||||
|
|
||||||
switch (meta / 5)
|
switch (meta / 5)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X);
|
state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.X);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
iblockstate = iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z);
|
state = state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Z);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
iblockstate.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
state.withProperty(BlockRotatedPillar.AXIS, EnumFacing.Axis.Y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iblockstate;
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
||||||
|
{
|
||||||
|
return new ItemStack(this, 1, damageDropped(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state)
|
public int getMetaFromState(IBlockState state)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = this.getValues().indexOf(state.getValue(this.getStringProp()));
|
||||||
i = this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
|
||||||
|
|
||||||
switch ((EnumFacing.Axis) state.getValue(BlockRotatedPillar.AXIS))
|
switch (state.getValue(BlockRotatedPillar.AXIS))
|
||||||
{
|
{
|
||||||
case X:
|
case X:
|
||||||
i = i + 5;
|
i = i + 5;
|
||||||
|
@ -72,7 +78,7 @@ public class BlockStringPillar extends BlockString
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean rotateBlock(net.minecraft.world.World world, BlockPos pos, EnumFacing axis)
|
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis)
|
||||||
{
|
{
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
for (IProperty<?> prop : state.getProperties().keySet())
|
for (IProperty<?> prop : state.getProperties().keySet())
|
||||||
|
@ -123,7 +129,7 @@ public class BlockStringPillar extends BlockString
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createStackedBlock(IBlockState state)
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
{
|
{
|
||||||
return new ItemStack(Item.getItemFromBlock(this), 1, this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp()))));
|
return new ItemStack(this, 1, damageDropped(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,6 +141,6 @@ public class BlockStringPillar extends BlockString
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state)
|
public int damageDropped(IBlockState state)
|
||||||
{
|
{
|
||||||
return this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
return this.getValues().indexOf(state.getValue(this.getStringProp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,14 @@ import net.minecraft.block.properties.PropertyDirection;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.Mirror;
|
import net.minecraft.util.Mirror;
|
||||||
import net.minecraft.util.Rotation;
|
import net.minecraft.util.Rotation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||||
|
@ -33,38 +35,33 @@ public class BlockStringPillarCap extends BlockString
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getStateFromMeta(int meta)
|
public IBlockState getStateFromMeta(int meta)
|
||||||
{
|
{
|
||||||
IBlockState iblockstate = getBlockState().getBaseState().withProperty(this.getStringProp(), this.getValues().get(meta % 2));
|
IBlockState state = getBlockState().getBaseState().withProperty(this.getStringProp(), this.getValues().get(meta % 2));
|
||||||
|
return state.withProperty(FACING, EnumFacing.getFront(meta / 2));
|
||||||
int index = meta / 2;
|
|
||||||
EnumFacing facing = EnumFacing.getFront(index);
|
|
||||||
iblockstate = iblockstate.withProperty(FACING, facing);
|
|
||||||
|
|
||||||
return iblockstate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(IBlockState state)
|
public int getMetaFromState(IBlockState state)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = this.getValues().indexOf(state.getValue(this.getStringProp()));
|
||||||
i = this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
return i + 2 * state.getValue(FACING).getIndex();
|
||||||
|
}
|
||||||
|
|
||||||
EnumFacing facing = (EnumFacing) state.getValue(FACING);
|
@Override
|
||||||
int index = facing.getIndex();
|
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
||||||
i = i + 2 * index;
|
{
|
||||||
|
return new ItemStack(this, 1, damageDropped(state));
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState withRotation(IBlockState state, Rotation rot)
|
public IBlockState withRotation(IBlockState state, Rotation rot)
|
||||||
{
|
{
|
||||||
return state.withProperty(FACING, rot.rotate((EnumFacing) state.getValue(FACING)));
|
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
||||||
{
|
{
|
||||||
return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING)));
|
return state.withRotation(mirrorIn.toRotation(state.getValue(FACING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,19 +79,18 @@ public class BlockStringPillarCap extends BlockString
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createStackedBlock(IBlockState state)
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
{
|
{
|
||||||
return new ItemStack(Item.getItemFromBlock(this), 1, this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp()))));
|
return new ItemStack(this, 1, damageDropped(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||||
{
|
{
|
||||||
System.out.println("Facing: " + facing);
|
|
||||||
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, facing);
|
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, facing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state)
|
public int damageDropped(IBlockState state)
|
||||||
{
|
{
|
||||||
return this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
return this.getValues().indexOf(state.getValue(this.getStringProp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,22 +63,22 @@ public class BlockStringWall extends BlockString
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (((Boolean) state.getValue(NORTH)).booleanValue())
|
if (state.getValue(NORTH))
|
||||||
{
|
{
|
||||||
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
|
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Boolean) state.getValue(EAST)).booleanValue())
|
if (state.getValue(EAST))
|
||||||
{
|
{
|
||||||
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
|
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Boolean) state.getValue(SOUTH)).booleanValue())
|
if (state.getValue(SOUTH))
|
||||||
{
|
{
|
||||||
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
|
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Boolean) state.getValue(WEST)).booleanValue())
|
if (state.getValue(WEST))
|
||||||
{
|
{
|
||||||
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
|
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
|
||||||
}
|
}
|
||||||
|
@ -104,27 +104,27 @@ public class BlockStringWall extends BlockString
|
||||||
|
|
||||||
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
|
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
IBlockState worldState = worldIn.getBlockState(pos);
|
||||||
Block block = iblockstate.getBlock();
|
Block block = worldState.getBlock();
|
||||||
return block == Blocks.BARRIER ? false : (block != this && !(block instanceof BlockFenceGate) ? (iblockstate.getMaterial().isOpaque() && iblockstate.isFullCube() ? iblockstate.getMaterial() != Material.GOURD : false) : true);
|
return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || ((worldState.getMaterial().isOpaque() && worldState.isFullCube()) && worldState.getMaterial() != Material.GOURD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
|
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side)
|
||||||
{
|
{
|
||||||
return side == EnumFacing.DOWN ? super.shouldSideBeRendered(blockState, blockAccess, pos, side) : true;
|
return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
boolean flag = this.canConnectTo(worldIn, pos.north());
|
boolean canNorth = this.canConnectTo(worldIn, pos.north());
|
||||||
boolean flag1 = this.canConnectTo(worldIn, pos.east());
|
boolean canEast = this.canConnectTo(worldIn, pos.east());
|
||||||
boolean flag2 = this.canConnectTo(worldIn, pos.south());
|
boolean canSouth = this.canConnectTo(worldIn, pos.south());
|
||||||
boolean flag3 = this.canConnectTo(worldIn, pos.west());
|
boolean canWest = this.canConnectTo(worldIn, pos.west());
|
||||||
boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3;
|
boolean flag4 = canNorth && !canEast && canSouth && !canWest || !canNorth && canEast && !canSouth && canWest;
|
||||||
return state.withProperty(UP, Boolean.valueOf(!flag4 || !worldIn.isAirBlock(pos.up()))).withProperty(NORTH, Boolean.valueOf(flag)).withProperty(EAST, Boolean.valueOf(flag1)).withProperty(SOUTH, Boolean.valueOf(flag2)).withProperty(WEST, Boolean.valueOf(flag3));
|
return state.withProperty(UP, !flag4 || !worldIn.isAirBlock(pos.up())).withProperty(NORTH, canNorth).withProperty(EAST, canEast).withProperty(SOUTH, canSouth).withProperty(WEST, canWest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,12 +142,12 @@ public class BlockStringWall extends BlockString
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack createStackedBlock(IBlockState state)
|
protected ItemStack createStackedBlock(IBlockState state)
|
||||||
{
|
{
|
||||||
return new ItemStack(Item.getItemFromBlock(this), 1, this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp()))));
|
return new ItemStack(this, 1, damageDropped(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(IBlockState state)
|
public int damageDropped(IBlockState state)
|
||||||
{
|
{
|
||||||
return this.getValues().indexOf(String.valueOf(state.getValue(this.getStringProp())));
|
return this.getValues().indexOf(state.getValue(this.getStringProp()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue