1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-11 18:00:29 +00:00

Fix BlockFaceShape not being overridden for turtles and peripherals

This meant one could perform various illogical actions to
non-full-blocks, such as connecting fences and placing paitings.

We also modify the behaviour of isOpaqueCube and isFullCube for
peripherals, only returning false for the case of modems and cables.
This commit is contained in:
SquidDev 2017-09-18 08:20:54 +01:00
parent 1c8480a329
commit 01f5d006fc
5 changed files with 82 additions and 15 deletions

View File

@ -12,6 +12,7 @@ import dan200.computercraft.shared.peripheral.modem.TileCable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockFaceShape;
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.item.Item; import net.minecraft.item.Item;
@ -251,4 +252,26 @@ public class BlockCable extends BlockPeripheralBase
{ {
return new TileCable(); return new TileCable();
} }
@Override
@Deprecated
public final boolean isOpaqueCube( IBlockState state )
{
return false;
}
@Override
@Deprecated
public final boolean isFullCube( IBlockState state )
{
return false;
}
@Nonnull
@Override
@Deprecated
public BlockFaceShape getBlockFaceShape( IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side )
{
return BlockFaceShape.UNDEFINED;
}
} }

View File

@ -16,6 +16,7 @@ import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockFaceShape;
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;
@ -612,4 +613,29 @@ public class BlockPeripheral extends BlockPeripheralBase
} }
} }
} }
@Override
@Deprecated
public final boolean isOpaqueCube( IBlockState state )
{
PeripheralType type = getPeripheralType( state );
return type == PeripheralType.DiskDrive || type == PeripheralType.Printer
|| type == PeripheralType.Monitor || type == PeripheralType.AdvancedMonitor
|| type == PeripheralType.Speaker;
}
@Override
@Deprecated
public final boolean isFullCube( IBlockState state )
{
return isOpaqueCube( state );
}
@Nonnull
@Override
@Deprecated
public BlockFaceShape getBlockFaceShape( IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side )
{
return isOpaqueCube( state ) ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
}
} }

View File

@ -31,20 +31,6 @@ public abstract class BlockPeripheralBase extends BlockDirectional
protected abstract PeripheralType getPeripheralType( IBlockState state ); protected abstract PeripheralType getPeripheralType( IBlockState state );
protected abstract TilePeripheralBase createTile( PeripheralType type ); protected abstract TilePeripheralBase createTile( PeripheralType type );
@Override
@Deprecated
public final boolean isOpaqueCube( IBlockState state )
{
return false;
}
@Override
@Deprecated
public final boolean isFullCube( IBlockState state )
{
return false;
}
@Override @Override
public final boolean canPlaceBlockOnSide( @Nonnull World world, @Nonnull BlockPos pos, EnumFacing side ) public final boolean canPlaceBlockOnSide( @Nonnull World world, @Nonnull BlockPos pos, EnumFacing side )
{ {

View File

@ -12,11 +12,12 @@ import dan200.computercraft.shared.peripheral.common.BlockPeripheralBase;
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase; import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockFaceShape;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -114,4 +115,26 @@ public class BlockAdvancedModem extends BlockPeripheralBase
{ {
return new TileAdvancedModem(); return new TileAdvancedModem();
} }
@Override
@Deprecated
public final boolean isOpaqueCube( IBlockState state )
{
return false;
}
@Override
@Deprecated
public final boolean isFullCube( IBlockState state )
{
return false;
}
@Nonnull
@Override
@Deprecated
public BlockFaceShape getBlockFaceShape( IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side )
{
return BlockFaceShape.UNDEFINED;
}
} }

View File

@ -13,6 +13,7 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockFaceShape;
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;
@ -75,6 +76,14 @@ public class BlockTurtle extends BlockComputerBase
return false; return false;
} }
@Nonnull
@Override
@Deprecated
public BlockFaceShape getBlockFaceShape( IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side )
{
return BlockFaceShape.UNDEFINED;
}
@Nonnull @Nonnull
@Override @Override
protected BlockStateContainer createBlockState() protected BlockStateContainer createBlockState()