commit
425a8732a3
6 changed files with 154 additions and 76 deletions
|
@ -1,16 +1,22 @@
|
||||||
package techreborn.blocks;
|
package techreborn.blocks;
|
||||||
|
|
||||||
import net.minecraft.block.BlockContainer;
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
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.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
import net.minecraft.util.EnumBlockRenderType;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import prospector.shootingstar.ShootingStar;
|
import prospector.shootingstar.ShootingStar;
|
||||||
import prospector.shootingstar.model.ModelCompound;
|
import prospector.shootingstar.model.ModelCompound;
|
||||||
|
import reborncore.common.BaseTileBlock;
|
||||||
import techreborn.client.TechRebornCreativeTab;
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
import techreborn.lib.ModInfo;
|
import techreborn.lib.ModInfo;
|
||||||
import techreborn.tiles.TileAlarm;
|
import techreborn.tiles.TileAlarm;
|
||||||
|
@ -19,21 +25,82 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
//TODO: On/off variants, Placeable on walls/roofs(faces), Visible when holding in hand, and recipe.
|
//TODO: On/off variants, Placeable on walls/roofs(faces), Visible when holding in hand, and recipe.
|
||||||
|
|
||||||
public class BlockAlarm extends BlockContainer {
|
public class BlockAlarm extends BaseTileBlock {
|
||||||
|
public static PropertyDirection FACING;
|
||||||
|
public static PropertyBool ACTIVE;
|
||||||
|
|
||||||
|
private static AxisAlignedBB[] GenBoundingBoxes(double depth, double width) {
|
||||||
|
AxisAlignedBB[] dimm = {
|
||||||
|
new AxisAlignedBB(width, 1.0 - depth, width, 1.0 - width, 1.0D, 1.0 - width),
|
||||||
|
new AxisAlignedBB(width, 0.0D, width, 1.0 - width, depth, 1.0 - width),
|
||||||
|
new AxisAlignedBB(width, width, 1.0 - depth, 1.0 - width, 1.0 - width, 1.0D),
|
||||||
|
new AxisAlignedBB(width, width, 0.0D, 1.0 - width, 1.0 - width, depth),
|
||||||
|
new AxisAlignedBB(1.0 - depth, width, width, 1.0D, 1.0 - width, 1.0 - width),
|
||||||
|
new AxisAlignedBB(0.0D, width, width, depth, 1.0 - width, 1.0 - width),
|
||||||
|
};
|
||||||
|
return dimm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private AxisAlignedBB[] bbs;
|
||||||
public BlockAlarm() {
|
public BlockAlarm() {
|
||||||
super(Material.ROCK);
|
super(Material.ROCK);
|
||||||
setUnlocalizedName("techreborn.alarm");
|
setUnlocalizedName("techreborn.alarm");
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false));
|
||||||
|
this.bbs = GenBoundingBoxes(0.19, 0.81);
|
||||||
setCreativeTab(TechRebornCreativeTab.instance);
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/lighting"));
|
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/lighting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlockStateContainer createBlockState() {
|
||||||
|
FACING = PropertyDirection.create("facing");
|
||||||
|
ACTIVE = PropertyBool.create("active");
|
||||||
|
return new BlockStateContainer(this, FACING, ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state) {
|
||||||
|
int facingInt = state.getValue(FACING).getIndex();
|
||||||
|
int activeInt = state.getValue(ACTIVE) ? 8 : 0;
|
||||||
|
return facingInt + activeInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
|
Boolean active = (meta&8)==8;
|
||||||
|
EnumFacing facing = EnumFacing.getFront(meta&7);
|
||||||
|
return this.getDefaultState().withProperty(FACING, facing).withProperty(ACTIVE, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isActive(IBlockState state) {
|
||||||
|
return state.getValue(ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumFacing getFacing(IBlockState state) {
|
||||||
|
return (EnumFacing)state.getValue(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFacing(EnumFacing facing, World world, BlockPos pos) {
|
||||||
|
world.setBlockState(pos, world.getBlockState(pos).withProperty(FACING, facing));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setActive(Boolean active, World world, BlockPos pos) {
|
||||||
|
EnumFacing facing = (EnumFacing)world.getBlockState(pos).getValue(FACING);
|
||||||
|
IBlockState state = world.getBlockState(pos).withProperty(ACTIVE, active).withProperty(FACING, facing);
|
||||||
|
world.setBlockState(pos, state, 3);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||||
return new TileAlarm();
|
return new TileAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
|
||||||
|
float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
|
||||||
|
return this.getDefaultState().withProperty(FACING, facing);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumBlockRenderType getRenderType(IBlockState state) {
|
public EnumBlockRenderType getRenderType(IBlockState state) {
|
||||||
return EnumBlockRenderType.MODEL;
|
return EnumBlockRenderType.MODEL;
|
||||||
|
@ -55,8 +122,8 @@ public class BlockAlarm extends BlockContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return new AxisAlignedBB(0.19, 0.0, 0.19, 0.81, 0.18, 0.81);
|
return this.bbs[getFacing(state).getIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ public class CraftingTableRecipes extends RecipeMethods {
|
||||||
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitAdvanced", 'P', "machineBlockAdvanced");
|
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 3), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitAdvanced", 'P', "machineBlockAdvanced");
|
||||||
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitMaster", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 3));
|
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitMaster", 'P', getStack(ModBlocks.SOLAR_PANEL, 1, 3));
|
||||||
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitMaster", 'P', "machineBlockElite");
|
registerShaped(getStack(ModBlocks.SOLAR_PANEL, 1, 4), "DLD", "LDL", "CPC", 'D', "dustDiamond", 'L', getStack(ModBlocks.REINFORCED_GLASS), 'C', "circuitMaster", 'P', "machineBlockElite");
|
||||||
|
registerShaped(getStack(ModBlocks.ALARM, 1, 0), "ICI", "SRS", "ICI", 'I', "ingotIron", 'C', getMaterial("copper", Type.CABLE), 'S', getMaterial("insulatedcopper", Type.CABLE), 'R', "blockRedstone" );
|
||||||
|
|
||||||
if (!IC2Duplicates.deduplicate()) {
|
if (!IC2Duplicates.deduplicate()) {
|
||||||
registerShaped(getStack(IC2Duplicates.HVT), " H ", " M ", " H ", 'M', getStack(IC2Duplicates.MVT), 'H', getStack(IC2Duplicates.CABLE_IHV));
|
registerShaped(getStack(IC2Duplicates.HVT), " H ", " M ", " H ", 'M', getStack(IC2Duplicates.MVT), 'H', getStack(IC2Duplicates.CABLE_IHV));
|
||||||
|
|
|
@ -3,13 +3,21 @@ package techreborn.tiles;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import techreborn.blocks.BlockAlarm;
|
||||||
import techreborn.init.ModSounds;
|
import techreborn.init.ModSounds;
|
||||||
|
|
||||||
public class TileAlarm extends TileEntity implements ITickable {
|
public class TileAlarm extends TileEntity implements ITickable {
|
||||||
|
boolean state = false;
|
||||||
|
int selectedSound;
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())) {
|
if (!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())) {
|
||||||
|
BlockAlarm.setActive(true, world, pos);
|
||||||
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
|
world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
|
||||||
|
state = true;
|
||||||
|
} else if(!world.isRemote && world.getTotalWorldTime() % 25 == 0 ) {
|
||||||
|
BlockAlarm.setActive(false, world, pos);
|
||||||
|
state = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,52 @@
|
||||||
"forge_marker": 1,
|
"forge_marker": 1,
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"transform": "forge:default-block",
|
"transform": "forge:default-block",
|
||||||
"model": "techreborn:alarm"
|
"model": "techreborn:alarm",
|
||||||
|
"textures": {
|
||||||
|
"particle": "#alarm"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"variants": {
|
"variants": {
|
||||||
"inventory": {
|
"inventory": {
|
||||||
"transform": "forge:default-block",
|
"transform": "forge:default-block",
|
||||||
"model": "techreborn:alarm",
|
"model": "techreborn:alarm",
|
||||||
"textures": {}
|
"textures": {
|
||||||
|
"alarm": "techreborn:blocks/machines/lighting/alarm_off"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"normal": {
|
"facing": {
|
||||||
"transform": "forge:default-block",
|
"down": {
|
||||||
"model": "techreborn:alarm",
|
"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": {
|
"textures": {
|
||||||
"alarm": "techreborn:blocks/machines/lighting/alarm_off"
|
"alarm": "techreborn:blocks/machines/lighting/alarm_off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,54 +1,20 @@
|
||||||
{
|
{
|
||||||
"textures": {
|
"textures": {
|
||||||
"0": "techreborn:blocks/machines/lighting/alarm_off",
|
"0": "#alarm"
|
||||||
"particle": "techreborn:blocks/machines/lighting/alarm_off"
|
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"name": "cube",
|
"name": "Alarm",
|
||||||
"from": [3, 0, 3],
|
"from": [3, 0, 3],
|
||||||
"to": [13, 3, 13],
|
"to": [13, 3, 13],
|
||||||
"faces": {
|
"faces": {
|
||||||
"north": {
|
"down": { "texture": "#0", "uv": [0.0, 0.0, 1.0, 1.0] },
|
||||||
"uv": [
|
"up": { "texture": "#0", "uv": [1.0,1.0,15.0,15.0] },
|
||||||
0.37890625,
|
"north": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
|
||||||
0.5171875,
|
"south": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
|
||||||
15.240625,
|
"west": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] },
|
||||||
3.3093749999999997
|
"east": { "texture": "#0", "uv": [1.0,2.0,15.0,0.0] }
|
||||||
],
|
}
|
||||||
"texture": "#0"
|
|
||||||
},
|
|
||||||
"east": {
|
|
||||||
"uv": [
|
|
||||||
0.37890625,
|
|
||||||
0.5171875,
|
|
||||||
15.240625,
|
|
||||||
3.3093749999999997
|
|
||||||
],
|
|
||||||
"texture": "#0"
|
|
||||||
},
|
|
||||||
"south": {
|
|
||||||
"uv": [
|
|
||||||
0.37890625,
|
|
||||||
0.5171875,
|
|
||||||
15.240625,
|
|
||||||
3.3093749999999997
|
|
||||||
],
|
|
||||||
"texture": "#0"
|
|
||||||
},
|
|
||||||
"west": {
|
|
||||||
"uv": [
|
|
||||||
0.37890625,
|
|
||||||
0.5171875,
|
|
||||||
15.240625,
|
|
||||||
3.3093749999999997
|
|
||||||
],
|
|
||||||
"texture": "#0"
|
|
||||||
},
|
|
||||||
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
|
|
||||||
"down": {"uv": [5, 2, 6, 3], "texture": "#0"}
|
|
||||||
},
|
|
||||||
"type": "cube"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"animation": {
|
||||||
|
"frametime": 5
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue