Models for lamps

This commit is contained in:
drcrazy 2019-05-02 11:31:07 +03:00
parent 2794c813eb
commit 48198dbcb3
13 changed files with 244 additions and 183 deletions

View file

@ -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, 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(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(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; return shapes;
} }
@ -102,6 +102,13 @@ public class BlockAlarm extends BaseTileBlock {
world.setBlockState(pos, state, 3); world.setBlockState(pos, state, 3);
} }
// BaseTileBlock
@Nullable
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileAlarm();
}
// Block // Block
@Override @Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) { 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); return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
} }
@Nullable
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
return new TileAlarm();
}
@Override @Override
public EnumBlockRenderType getRenderType(IBlockState state) { public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL; return EnumBlockRenderType.MODEL;

View file

@ -24,12 +24,14 @@
package techreborn.blocks.lighting; package techreborn.blocks.lighting;
import javax.annotation.Nullable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.BooleanProperty; import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
@ -72,13 +74,14 @@ public class BlockLamp extends BaseTileBlock {
} }
private VoxelShape[] GenCuboidShapes(double depth, double width) { private VoxelShape[] GenCuboidShapes(double depth, double width) {
double culling = (16.0D - width) / 2 ;
VoxelShape[] shapes = { VoxelShape[] shapes = {
Block.makeCuboidShape(width, 1.0 - depth, width, 1.0 - width, 1.0D, 1.0 - width), Block.makeCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
Block.makeCuboidShape(width, 0.0D, width, 1.0 - width, depth, 1.0 - width), Block.makeCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
Block.makeCuboidShape(width, width, 1.0 - depth, 1.0 - width, 1.0 - width, 1.0D), Block.makeCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
Block.makeCuboidShape(width, width, 0.0D, 1.0 - width, 1.0 - width, depth), Block.makeCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
Block.makeCuboidShape(1.0 - depth, width, width, 1.0D, 1.0 - width, 1.0 - width), Block.makeCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
Block.makeCuboidShape(0.0D, width, width, depth, 1.0 - width, 1.0 - width), Block.makeCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
}; };
return shapes; return shapes;
} }
@ -118,10 +121,16 @@ public class BlockLamp extends BaseTileBlock {
builder.add(FACING, ACTIVE); builder.add(FACING, ACTIVE);
} }
@Nullable
@Override @Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { public IBlockState getStateForPlacement(BlockItemUseContext context) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack); for (EnumFacing enumfacing : context.getNearestLookingDirections()) {
setFacing(placer.getHorizontalFacing().getOpposite(), worldIn, pos); IBlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite());
if (iblockstate.isValidPosition(context.getWorld(), context.getPos())) {
return iblockstate;
}
}
return null;
} }
@Override @Override

View file

@ -388,8 +388,8 @@ public class TRContent {
ALARM(new BlockAlarm()), ALARM(new BlockAlarm()),
CHUNK_LOADER(new BlockChunkLoader()), CHUNK_LOADER(new BlockChunkLoader()),
LAMP_INCANDESCENT(new BlockLamp(14, 4, 0.625, 0.25)), LAMP_INCANDESCENT(new BlockLamp(14, 4, 10, 8)),
LAMP_LED(new BlockLamp(15, 1, 0.0625, 0.125)), LAMP_LED(new BlockLamp(15, 1, 1, 12)),
PLAYER_DETECTOR(new BlockPlayerDetector()); PLAYER_DETECTOR(new BlockPlayerDetector());
public final String name; public final String name;

View file

@ -0,0 +1,16 @@
{
"variants": {
"facing=north,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent", "x": 90 },
"facing=south,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent", "x": 270 },
"facing=west,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent", "x": 90, "y": 270 },
"facing=east,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent", "x": 90, "y": 90 },
"facing=down,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent", "x": 180 },
"facing=up,active=false": { "model": "techreborn:block/machines/lighting/lamp_incandescent" },
"facing=north,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on", "x": 90 },
"facing=south,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on", "x": 270 },
"facing=west,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on", "x": 90, "y": 270 },
"facing=east,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on", "x": 90, "y": 90 },
"facing=down,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on", "x": 180 },
"facing=up,active=true": { "model": "techreborn:block/machines/lighting/lamp_incandescent_on"}
}
}

View file

@ -0,0 +1,16 @@
{
"variants": {
"facing=north,active=false": { "model": "techreborn:block/machines/lighting/lamp_led", "x": 90 },
"facing=south,active=false": { "model": "techreborn:block/machines/lighting/lamp_led", "x": 270 },
"facing=west,active=false": { "model": "techreborn:block/machines/lighting/lamp_led", "x": 90, "y": 270 },
"facing=east,active=false": { "model": "techreborn:block/machines/lighting/lamp_led", "x": 90, "y": 90 },
"facing=down,active=false": { "model": "techreborn:block/machines/lighting/lamp_led", "x": 180 },
"facing=up,active=false": { "model": "techreborn:block/machines/lighting/lamp_led" },
"facing=north,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on", "x": 90 },
"facing=south,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on", "x": 270 },
"facing=west,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on", "x": 90, "y": 270 },
"facing=east,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on", "x": 90, "y": 90 },
"facing=down,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on", "x": 180 },
"facing=up,active=true": { "model": "techreborn:block/machines/lighting/lamp_led_on"}
}
}

View file

@ -1,38 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"model": "techreborn:lamp_incandescent",
"textures": {
"particle": "#lamp"
}
},
"variants": {
"inventory": {
"model": "techreborn:lamp_incandescent",
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp"
}
},
"facing": {
"down": { "x": 180 },
"up": { "transform": "forge:default-block" },
"north": { "x": 90 },
"south": { "x": 270 },
"west": { "x": 90, "y": 270 },
"east": { "x": 90, "y": 90 }
},
"active": {
"true": {
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp_lit"
}
},
"false": {
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp"
}
}
}
}
}

View file

@ -1,38 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"transform": "forge:default-block",
"model": "techreborn:lamp_led",
"textures": {
"particle": "#lamp"
}
},
"variants": {
"inventory": {
"model": "techreborn:lamp_led",
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp"
}
},
"facing": {
"down": { "x": 180 },
"up": { "transform": "forge:default-block" },
"north": { "x": 90 },
"south": { "x": 270 },
"west": { "x": 90, "y": 270 },
"east": { "x": 90, "y": 90 }
},
"active": {
"true": {
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp_lit"
}
},
"false": {
"textures": {
"lamp": "techreborn:blocks/machines/lighting/lamp"
}
}
}
}
}

View file

@ -18,7 +18,7 @@
} }
}, },
"textures": { "textures": {
"0": "#lamp" "0": "techreborn:block/machines/lighting/lamp"
}, },
"elements": [ "elements": [
{ {

View file

@ -0,0 +1,51 @@
{
"parent": "block/block",
"display": {
"thirdperson_righthand": {
"rotation": [ 75, 45, 0 ],
"translation": [ 0, 2.5, 2],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 35, 0 ],
"translation": [ 0, 4.3, 0 ],
"scale": [ 0.60, 0.60, 0.60 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 225, 0 ],
"translation": [ 0, 4.2, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
}
},
"textures": {
"0": "techreborn:block/machines/lighting/lamp_lit"
},
"elements": [
{
"name": "Lamp",
"from": [ 5, 0, 5 ],
"to": [ 11, 2, 11 ],
"faces": {
"down": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"up": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"north": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"south": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"west": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"east": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] }
}
},
{
"name": "Lamp",
"from": [ 4, 2, 4 ],
"to": [ 12, 10, 12 ],
"faces": {
"down": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"up": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"north": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"south": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"west": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"east": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] }
}
}
]
}

View file

@ -18,7 +18,7 @@
} }
}, },
"textures": { "textures": {
"0": "#lamp" "0": "techreborn:block/machines/lighting/lamp"
}, },
"elements": [ "elements": [
{ {

View file

@ -0,0 +1,38 @@
{
"parent": "block/block",
"display": {
"thirdperson_righthand": {
"rotation": [ 75, 45, 0 ],
"translation": [ 0, 2.5, 2],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 35, 0 ],
"translation": [ 0, 5.5, 0 ],
"scale": [ 0.60, 0.60, 0.60 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 225, 0 ],
"translation": [ 0, 4.2, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
}
},
"textures": {
"0": "techreborn:block/machines/lighting/lamp_lit"
},
"elements": [
{
"name": "Lamp",
"from": [ 2, 0, 2 ],
"to": [ 14, 1, 14 ],
"faces": {
"down": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
"up": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
"north": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
"south": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
"west": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
"east": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] }
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"parent": "techreborn:block/machines/lighting/lamp_incandescent"
}

View file

@ -0,0 +1,3 @@
{
"parent": "techreborn:block/machines/lighting/lamp_led"
}