Skip to content

Commit

Permalink
Fixes #2675: Set fullBlock correctly afterwards.
Browse files Browse the repository at this point in the history
Reduces the visibility of some methods as these should be access through the public methods of Block or the overridden ones.
Removes now useless getCheckedSubBlocks.
  • Loading branch information
yueh committed Dec 2, 2016
1 parent 12dbd17 commit d377af9
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 102 deletions.
183 changes: 87 additions & 96 deletions src/main/java/appeng/block/AEBaseBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ public abstract class AEBaseBlock extends Block

protected AxisAlignedBB boundingBox = FULL_BLOCK_AABB;

@Override
public boolean isVisuallyOpaque()
{
return this.isOpaque() && this.isFullSize();
}

protected AEBaseBlock( final Material mat )
{
super( mat );
Expand All @@ -96,13 +90,15 @@ else if( mat == Material.WOOD )
this.setLightLevel( 0 );
this.setHardness( 2.2F );
this.setHarvestLevel( "pickaxe", 0 );

// Workaround as vanilla sets it way too early.
this.fullBlock = this.isFullSize();
}

@Override
public String toString()
public final boolean isVisuallyOpaque()
{
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
return getClass().getSimpleName() + "[" + regName + "]";
return this.isOpaque() && this.isFullSize();
}

@Override
Expand All @@ -111,31 +107,12 @@ protected BlockStateContainer createBlockState()
return new BlockStateContainer( this, this.getAEStates() );
}

protected IProperty[] getAEStates()
{
return new IProperty[0];
}

public boolean isOpaque()
{
return this.isOpaque;
}

@Override
public boolean isNormalCube( IBlockState state )
public final boolean isNormalCube( IBlockState state )
{
return this.isFullSize() && this.isOpaque();
}

protected ICustomCollision getCustomCollision( final World w, final BlockPos pos )
{
if( this instanceof ICustomCollision )
{
return (ICustomCollision) this;
}
return null;
}

@Override
public AxisAlignedBB getBoundingBox( IBlockState state, IBlockAccess source, BlockPos pos )
{
Expand Down Expand Up @@ -210,7 +187,8 @@ public AxisAlignedBB getSelectedBoundingBox( IBlockState state, final World w, f

if( br != null )
{
br = new AxisAlignedBB( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos.getY(), br.maxZ + pos.getZ() );
br = new AxisAlignedBB( br.minX + pos.getX(), br.minY + pos.getY(), br.minZ + pos.getZ(), br.maxX + pos.getX(), br.maxY + pos
.getY(), br.maxZ + pos.getZ() );
return br;
}
}
Expand Down Expand Up @@ -241,7 +219,8 @@ public AxisAlignedBB getSelectedBoundingBox( IBlockState state, final World w, f
}
else
{
b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos.getZ() );
b = new AxisAlignedBB( b.minX + pos.getX(), b.minY + pos.getY(), b.minZ + pos.getZ(), b.maxX + pos.getX(), b.maxY + pos.getY(), b.maxZ + pos
.getZ() );
}

return b;
Expand Down Expand Up @@ -303,19 +282,6 @@ public RayTraceResult collisionRayTrace( final IBlockState state, final World w,
return super.collisionRayTrace( state, w, pos, a, b );
}

public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
return false;
}

@Override
@SideOnly( Side.CLIENT )
@SuppressWarnings( "unchecked" )
public final void getSubBlocks( final Item item, final CreativeTabs tabs, final List itemStacks )
{
this.getCheckedSubBlocks( item, tabs, itemStacks );
}

@Override
public boolean hasComparatorInputOverride( IBlockState state )
{
Expand All @@ -329,21 +295,11 @@ public int getComparatorInputOverride( IBlockState state, final World worldIn, f
}

@Override
public boolean isNormalCube( IBlockState state, final IBlockAccess world, final BlockPos pos )
public final boolean isNormalCube( IBlockState state, final IBlockAccess world, final BlockPos pos )
{
return this.isFullSize();
}

public IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}

@Override
public boolean rotateBlock( final World w, final BlockPos pos, final EnumFacing axis )
{
Expand Down Expand Up @@ -378,50 +334,24 @@ public boolean rotateBlock( final World w, final BlockPos pos, final EnumFacing
return super.rotateBlock( w, pos, axis );
}

protected boolean hasCustomRotation()
{
return false;
}

protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis )
{

}

public boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up )
{
return true;
}

@Override
public EnumFacing[] getValidRotations( final World w, final BlockPos pos )
{
return new EnumFacing[0];
}

@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
super.getSubBlocks( item, tabs, itemStacks );
}

public String getUnlocalizedName( final ItemStack is )
{
return this.getUnlocalizedName();
}

@Override
public void addInformation( final ItemStack is, final EntityPlayer player, final List<String> lines, final boolean advancedItemTooltips )
{

}

public boolean hasSubtypes()
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
return this.hasSubtypes;
return false;
}

public EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir )
public final EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir )
{
// case DOWN: return bottomIcon;
// case UP: return blockIcon;
Expand Down Expand Up @@ -486,36 +416,97 @@ public EnumFacing mapRotation( final IOrientable ori, final EnumFacing dir )
return null;
}

public boolean isFullSize()
@Override
public String toString()
{
return this.isFullSize;
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
return getClass().getSimpleName() + "[" + regName + "]";
}

public boolean setFullSize( final boolean isFullSize )
protected String getUnlocalizedName( final ItemStack is )
{
this.isFullSize = isFullSize;
return isFullSize;
return this.getUnlocalizedName();
}

protected boolean hasCustomRotation()
{
return false;
}

protected void customRotateBlock( final IOrientable rotatable, final EnumFacing axis )
{

}

protected IOrientable getOrientable( final IBlockAccess w, final BlockPos pos )
{
if( this instanceof IOrientableBlock )
{
IOrientableBlock orientable = (IOrientableBlock) this;
return orientable.getOrientable( w, pos );
}
return null;
}

protected boolean isValidOrientation( final World w, final BlockPos pos, final EnumFacing forward, final EnumFacing up )
{
return true;
}

protected ICustomCollision getCustomCollision( final World w, final BlockPos pos )
{
if( this instanceof ICustomCollision )
{
return (ICustomCollision) this;
}
return null;
}

protected IProperty[] getAEStates()
{
return new IProperty[0];
}

public boolean setOpaque( final boolean isOpaque )
protected boolean isOpaque()
{
return this.isOpaque;
}

protected boolean setOpaque( final boolean isOpaque )
{
this.isOpaque = isOpaque;
return isOpaque;
}

public boolean isInventory()
protected boolean hasSubtypes()
{
return this.isInventory;
return this.hasSubtypes;
}

public void setInventory( final boolean isInventory )
protected void setHasSubtypes( final boolean hasSubtypes )
{
this.isInventory = isInventory;
this.hasSubtypes = hasSubtypes;
}

public void setHasSubtypes( final boolean hasSubtypes )
protected boolean isFullSize()
{
this.hasSubtypes = hasSubtypes;
return this.isFullSize;
}

protected boolean setFullSize( final boolean isFullSize )
{
this.isFullSize = isFullSize;
return isFullSize;
}

protected boolean isInventory()
{
return this.isInventory;
}

protected void setInventory( final boolean isInventory )
{
this.isInventory = isInventory;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public IExtendedBlockState getExtendedState( IBlockState state, IBlockAccess wor

@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
itemStacks.add( new ItemStack( this, 1, 0 ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/block/networking/BlockCableBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public boolean recolorBlock( final World world, final BlockPos pos, final EnumFa

@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/appeng/block/networking/BlockEnergyCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public BlockEnergyCell()

@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
super.getCheckedSubBlocks( item, tabs, itemStacks );
super.getSubBlocks( item, tabs, itemStacks );

final ItemStack charged = new ItemStack( this, 1 );
final NBTTagCompound tag = Platform.openNbtData( charged );
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/block/paint/BlockPaint.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public BlockRenderLayer getBlockLayer()

@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/block/spatial/BlockMatrixFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public BlockMatrixFrame()

@Override
@SideOnly( Side.CLIENT )
public void getCheckedSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
public void getSubBlocks( final Item item, final CreativeTabs tabs, final List<ItemStack> itemStacks )
{
// do nothing
}
Expand Down

0 comments on commit d377af9

Please sign in to comment.