Models for lamps
This commit is contained in:
parent
2794c813eb
commit
48198dbcb3
13 changed files with 244 additions and 183 deletions
|
@ -79,7 +79,7 @@ public class BlockAlarm extends BaseTileBlock {
|
|||
Block.makeCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
Block.makeCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
Block.makeCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling),
|
||||
Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
};
|
||||
return shapes;
|
||||
}
|
||||
|
@ -102,6 +102,13 @@ public class BlockAlarm extends BaseTileBlock {
|
|||
world.setBlockState(pos, state, 3);
|
||||
}
|
||||
|
||||
// BaseTileBlock
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||
return new TileAlarm();
|
||||
}
|
||||
|
||||
// Block
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
|
||||
|
@ -147,12 +154,6 @@ public class BlockAlarm extends BaseTileBlock {
|
|||
return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||
return new TileAlarm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||
return EnumBlockRenderType.MODEL;
|
||||
|
|
|
@ -24,12 +24,14 @@
|
|||
|
||||
package techreborn.blocks.lighting;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
|
@ -72,13 +74,14 @@ public class BlockLamp extends BaseTileBlock {
|
|||
}
|
||||
|
||||
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
||||
double culling = (16.0D - width) / 2 ;
|
||||
VoxelShape[] shapes = {
|
||||
Block.makeCuboidShape(width, 1.0 - depth, width, 1.0 - width, 1.0D, 1.0 - width),
|
||||
Block.makeCuboidShape(width, 0.0D, width, 1.0 - width, depth, 1.0 - width),
|
||||
Block.makeCuboidShape(width, width, 1.0 - depth, 1.0 - width, 1.0 - width, 1.0D),
|
||||
Block.makeCuboidShape(width, width, 0.0D, 1.0 - width, 1.0 - width, depth),
|
||||
Block.makeCuboidShape(1.0 - depth, width, width, 1.0D, 1.0 - width, 1.0 - width),
|
||||
Block.makeCuboidShape(0.0D, width, width, depth, 1.0 - width, 1.0 - width),
|
||||
Block.makeCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||
Block.makeCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||
Block.makeCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
Block.makeCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
Block.makeCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
};
|
||||
return shapes;
|
||||
}
|
||||
|
@ -117,11 +120,17 @@ public class BlockLamp extends BaseTileBlock {
|
|||
ACTIVE = BooleanProperty.create("active");
|
||||
builder.add(FACING, ACTIVE);
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
|
||||
setFacing(placer.getHorizontalFacing().getOpposite(), worldIn, pos);
|
||||
public IBlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
for (EnumFacing enumfacing : context.getNearestLookingDirections()) {
|
||||
IBlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite());
|
||||
if (iblockstate.isValidPosition(context.getWorld(), context.getPos())) {
|
||||
return iblockstate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -388,8 +388,8 @@ public class TRContent {
|
|||
|
||||
ALARM(new BlockAlarm()),
|
||||
CHUNK_LOADER(new BlockChunkLoader()),
|
||||
LAMP_INCANDESCENT(new BlockLamp(14, 4, 0.625, 0.25)),
|
||||
LAMP_LED(new BlockLamp(15, 1, 0.0625, 0.125)),
|
||||
LAMP_INCANDESCENT(new BlockLamp(14, 4, 10, 8)),
|
||||
LAMP_LED(new BlockLamp(15, 1, 1, 12)),
|
||||
PLAYER_DETECTOR(new BlockPlayerDetector());
|
||||
|
||||
public final String name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue