Model for alarm

This commit is contained in:
drcrazy 2019-04-30 16:48:43 +03:00
parent b9ae05afaa
commit e01e9398ea
7 changed files with 75 additions and 55 deletions

View file

@ -29,10 +29,12 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
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;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
@ -57,7 +59,7 @@ import javax.annotation.Nullable;
import java.util.List;
public class BlockAlarm extends BaseTileBlock {
public static DirectionProperty FACING;
public static DirectionProperty FACING = BlockStateProperties.FACING;
public static BooleanProperty ACTIVE;
protected final VoxelShape[] shape;
@ -102,10 +104,21 @@ public class BlockAlarm extends BaseTileBlock {
// Block
@Override
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
FACING = DirectionProperty.create("facing", EnumFacing.Plane.HORIZONTAL);
ACTIVE = BooleanProperty.create("active");
builder.add(FACING, ACTIVE);
}
@Nullable
@Override
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;
}
@SuppressWarnings("deprecation")
@Override
@ -156,6 +169,7 @@ public class BlockAlarm extends BaseTileBlock {
@Override
public VoxelShape getShape(IBlockState state, IBlockReader worldIn, BlockPos pos) {
// TODO: Fix this
return shape[getFacing(state).getIndex()];
}
}

View file

@ -51,7 +51,7 @@ import techreborn.TechReborn;
* Created by Rushmead
*/
public abstract class BlockEnergyStorage extends BaseTileBlock {
public static DirectionProperty FACING = BlockStateProperties.FACING;;
public static DirectionProperty FACING = BlockStateProperties.FACING;
public String name;
public IMachineGuiHandler gui;

View file

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

View file

@ -1,51 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"model": "techreborn:alarm",
"textures": {
"particle": "#alarm"
}
},
"variants": {
"inventory": {
"model": "techreborn:alarm",
"textures": {
"alarm": "techreborn:blocks/machines/lighting/alarm_off"
}
},
"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": {
"alarm": "techreborn:blocks/machines/lighting/alarm_on"
}
},
"false": {
"textures": {
"alarm": "techreborn:blocks/machines/lighting/alarm_off"
}
}
}
}
}

View file

@ -18,7 +18,7 @@
}
},
"textures": {
"0": "#alarm"
"0": "techreborn:block/machines/lighting/alarm_off"
},
"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/alarm_on"
},
"elements": [
{
"name": "Alarm",
"from": [3, 0, 3],
"to": [13, 3, 13],
"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/alarm"
}