From 2177b72e41e9662af761cbd6d99725f48203e9ff Mon Sep 17 00:00:00 2001 From: Dimmerworld Date: Wed, 3 Jan 2018 14:26:23 +1100 Subject: [PATCH] Animation --- .../java/techreborn/blocks/BlockAlarm.java | 7 +++---- src/main/java/techreborn/tiles/TileAlarm.java | 21 ++++++++++++------- .../blockstates/machines/lighting/alarm.json | 11 +++++++--- .../assets/techreborn/models/block/alarm.json | 5 ++--- .../machines/lighting/alarm_on.png.mcmeta | 5 +++++ 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 src/main/resources/assets/techreborn/textures/blocks/machines/lighting/alarm_on.png.mcmeta diff --git a/src/main/java/techreborn/blocks/BlockAlarm.java b/src/main/java/techreborn/blocks/BlockAlarm.java index f8c3059c4..0900e8a84 100644 --- a/src/main/java/techreborn/blocks/BlockAlarm.java +++ b/src/main/java/techreborn/blocks/BlockAlarm.java @@ -30,7 +30,7 @@ public class BlockAlarm extends BaseTileBlock { public static PropertyBool ACTIVE; private static AxisAlignedBB[] GenBoundingBoxes(double depth, double width) { - AxisAlignedBB[] bb = { + 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), @@ -38,16 +38,15 @@ public class BlockAlarm extends BaseTileBlock { 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 bb; + return dimm; } private AxisAlignedBB[] bbs; - public BlockAlarm() { super(Material.ROCK); setUnlocalizedName("techreborn.alarm"); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVE, false)); - this.bbs = GenBoundingBoxes(0.19, 0.81); + this.bbs = GenBoundingBoxes(0.19, 0.8); setCreativeTab(TechRebornCreativeTab.instance); ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/lighting")); } diff --git a/src/main/java/techreborn/tiles/TileAlarm.java b/src/main/java/techreborn/tiles/TileAlarm.java index a822b77e6..375ec9602 100644 --- a/src/main/java/techreborn/tiles/TileAlarm.java +++ b/src/main/java/techreborn/tiles/TileAlarm.java @@ -3,13 +3,20 @@ package techreborn.tiles; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; import net.minecraft.util.SoundCategory; +import techreborn.blocks.BlockAlarm; import techreborn.init.ModSounds; -public class TileAlarm extends TileEntity implements ITickable{ - @Override - public void update() { - if(!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())){ - world.playSound(null, getPos().getX(), getPos().getY(), getPos().getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F); - } - } +public class TileAlarm extends TileEntity implements ITickable { +boolean state = false; +int selectedSound; + @Override + public void update() { + if (!world.isRemote && world.getTotalWorldTime() % 25 == 0 && world.isBlockPowered(getPos())) { + BlockAlarm.setActive(true, world, pos); + state = true; + } else if(!world.isRemote && world.getTotalWorldTime() % 25 == 0 ) { + BlockAlarm.setActive(false, world, pos); + state = false; + } + } } diff --git a/src/main/resources/assets/techreborn/blockstates/machines/lighting/alarm.json b/src/main/resources/assets/techreborn/blockstates/machines/lighting/alarm.json index 4a8753a2b..b3133f448 100644 --- a/src/main/resources/assets/techreborn/blockstates/machines/lighting/alarm.json +++ b/src/main/resources/assets/techreborn/blockstates/machines/lighting/alarm.json @@ -2,13 +2,18 @@ "forge_marker": 1, "defaults": { "transform": "forge:default-block", - "model": "techreborn:alarm" + "model": "techreborn:alarm", + "textures": { + "particle": "#alarm" + } }, "variants": { "inventory": { "transform": "forge:default-block", "model": "techreborn:alarm", - "textures": {} + "textures": { + "alarm": "techreborn:blocks/machines/lighting/alarm_off" + } }, "facing": { "down": { @@ -35,7 +40,7 @@ "active": { "true": { "textures": { - "alarm": "techreborn:blocks/machines/lighting/alarm_off" + "alarm": "techreborn:blocks/machines/lighting/alarm_on" } }, "false": { diff --git a/src/main/resources/assets/techreborn/models/block/alarm.json b/src/main/resources/assets/techreborn/models/block/alarm.json index 5dafe2884..a2badfbd8 100644 --- a/src/main/resources/assets/techreborn/models/block/alarm.json +++ b/src/main/resources/assets/techreborn/models/block/alarm.json @@ -1,11 +1,10 @@ { "textures": { - "0": "techreborn:blocks/machines/lighting/alarm_off", - "particle": "techreborn:blocks/machines/lighting/alarm_off" + "0": "#alarm" }, "elements": [ { - "name": "cube", + "name": "Alarm", "from": [3, 0, 3], "to": [13, 3, 13], "faces": { diff --git a/src/main/resources/assets/techreborn/textures/blocks/machines/lighting/alarm_on.png.mcmeta b/src/main/resources/assets/techreborn/textures/blocks/machines/lighting/alarm_on.png.mcmeta new file mode 100644 index 000000000..4a650b188 --- /dev/null +++ b/src/main/resources/assets/techreborn/textures/blocks/machines/lighting/alarm_on.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 5 + } +}