From a28b6bbdc3d932a82ccb5be15f23f03b47c5a64e Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Fri, 11 Sep 2020 23:50:34 -0400 Subject: [PATCH 1/4] Overhaul mechanical saw rendering - Saws no longer use "RUNNING" blockstate - Sawblade animates based on input speed - Saws properly stop animating when inactive --- .../create/blockstates/mechanical_saw.json | 70 +++---------- .../create/models/item/mechanical_saw.json | 2 +- .../com/simibubi/create/AllBlockPartials.java | 9 +- .../jei/category/animations/AnimatedSaw.java | 9 +- .../actors/SawMovementBehaviour.java | 12 +++ .../contraptions/components/saw/SawBlock.java | 9 -- .../components/saw/SawGenerator.java | 3 +- .../components/saw/SawRenderer.java | 67 +++++++++++- .../components/saw/SawTileEntity.java | 11 -- .../structureMovement/Contraption.java | 5 - .../mechanicalArm/ArmInteractionPoint.java | 5 +- .../blade_horizontal_active.json | 19 ++++ .../blade_horizontal_inactive.json | 7 ++ .../blade_horizontal_reversed.json | 7 ++ .../mechanical_saw/blade_vertical_active.json | 18 ++++ .../blade_vertical_inactive.json | 7 ++ .../blade_vertical_reversed.json | 7 ++ .../block/mechanical_saw/horizontal.json | 10 -- .../mechanical_saw/horizontal_inactive.json | 6 -- .../models/block/mechanical_saw/item.json | 98 ++++++++++++++++++ .../models/block/mechanical_saw/vertical.json | 10 -- .../mechanical_saw/vertical_inactive.json | 6 -- .../create/textures/block/saw_reversed.png | Bin 0 -> 4854 bytes .../textures/block/saw_reversed.png.mcmeta | 6 ++ 24 files changed, 279 insertions(+), 124 deletions(-) create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_active.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_inactive.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_reversed.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_active.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_inactive.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_reversed.json delete mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/horizontal_inactive.json create mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/item.json delete mode 100644 src/main/resources/assets/create/models/block/mechanical_saw/vertical_inactive.json create mode 100644 src/main/resources/assets/create/textures/block/saw_reversed.png create mode 100644 src/main/resources/assets/create/textures/block/saw_reversed.png.mcmeta diff --git a/src/generated/resources/assets/create/blockstates/mechanical_saw.json b/src/generated/resources/assets/create/blockstates/mechanical_saw.json index 8dc2adc8f..bad1bc6d7 100644 --- a/src/generated/resources/assets/create/blockstates/mechanical_saw.json +++ b/src/generated/resources/assets/create/blockstates/mechanical_saw.json @@ -1,94 +1,48 @@ { "variants": { - "axis_along_first=false,facing=down,running=false": { - "model": "create:block/mechanical_saw/vertical_inactive", - "x": 180 - }, - "axis_along_first=true,facing=down,running=false": { - "model": "create:block/mechanical_saw/vertical_inactive", - "x": 180, - "y": 90 - }, - "axis_along_first=false,facing=up,running=false": { - "model": "create:block/mechanical_saw/vertical_inactive" - }, - "axis_along_first=true,facing=up,running=false": { - "model": "create:block/mechanical_saw/vertical_inactive", - "y": 90 - }, - "axis_along_first=false,facing=north,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 180 - }, - "axis_along_first=true,facing=north,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 180 - }, - "axis_along_first=false,facing=south,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive" - }, - "axis_along_first=true,facing=south,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive" - }, - "axis_along_first=false,facing=west,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 90 - }, - "axis_along_first=true,facing=west,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 90 - }, - "axis_along_first=false,facing=east,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 270 - }, - "axis_along_first=true,facing=east,running=false": { - "model": "create:block/mechanical_saw/horizontal_inactive", - "y": 270 - }, - "axis_along_first=false,facing=down,running=true": { + "axis_along_first=false,facing=down": { "model": "create:block/mechanical_saw/vertical", "x": 180 }, - "axis_along_first=true,facing=down,running=true": { + "axis_along_first=true,facing=down": { "model": "create:block/mechanical_saw/vertical", "x": 180, "y": 90 }, - "axis_along_first=false,facing=up,running=true": { + "axis_along_first=false,facing=up": { "model": "create:block/mechanical_saw/vertical" }, - "axis_along_first=true,facing=up,running=true": { + "axis_along_first=true,facing=up": { "model": "create:block/mechanical_saw/vertical", "y": 90 }, - "axis_along_first=false,facing=north,running=true": { + "axis_along_first=false,facing=north": { "model": "create:block/mechanical_saw/horizontal", "y": 180 }, - "axis_along_first=true,facing=north,running=true": { + "axis_along_first=true,facing=north": { "model": "create:block/mechanical_saw/horizontal", "y": 180 }, - "axis_along_first=false,facing=south,running=true": { + "axis_along_first=false,facing=south": { "model": "create:block/mechanical_saw/horizontal" }, - "axis_along_first=true,facing=south,running=true": { + "axis_along_first=true,facing=south": { "model": "create:block/mechanical_saw/horizontal" }, - "axis_along_first=false,facing=west,running=true": { + "axis_along_first=false,facing=west": { "model": "create:block/mechanical_saw/horizontal", "y": 90 }, - "axis_along_first=true,facing=west,running=true": { + "axis_along_first=true,facing=west": { "model": "create:block/mechanical_saw/horizontal", "y": 90 }, - "axis_along_first=false,facing=east,running=true": { + "axis_along_first=false,facing=east": { "model": "create:block/mechanical_saw/horizontal", "y": 270 }, - "axis_along_first=true,facing=east,running=true": { + "axis_along_first=true,facing=east": { "model": "create:block/mechanical_saw/horizontal", "y": 270 } diff --git a/src/generated/resources/assets/create/models/item/mechanical_saw.json b/src/generated/resources/assets/create/models/item/mechanical_saw.json index 1f3cf51dd..2811abfa3 100644 --- a/src/generated/resources/assets/create/models/item/mechanical_saw.json +++ b/src/generated/resources/assets/create/models/item/mechanical_saw.json @@ -1,3 +1,3 @@ { - "parent": "create:block/mechanical_saw/horizontal" + "parent": "create:block/mechanical_saw/item" } \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index 9bbae39ee..a04c4a9eb 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -45,7 +45,14 @@ public class AllBlockPartials { MECHANICAL_MIXER_HEAD = get("mechanical_mixer/head"), MECHANICAL_CRAFTER_LID = get("mechanical_crafter/lid"), MECHANICAL_CRAFTER_ARROW = get("mechanical_crafter/arrow"), MECHANICAL_CRAFTER_BELT_FRAME = get("mechanical_crafter/belt"), - MECHANICAL_CRAFTER_BELT = get("mechanical_crafter/belt_animated"), GAUGE_DIAL = get("gauge/dial"), + MECHANICAL_CRAFTER_BELT = get("mechanical_crafter/belt_animated"), + SAW_BLADE_HORIZONTAL_ACTIVE = get("mechanical_saw/blade_horizontal_active"), + SAW_BLADE_HORIZONTAL_INACTIVE = get("mechanical_saw/blade_horizontal_inactive"), + SAW_BLADE_HORIZONTAL_REVERSED = get("mechanical_saw/blade_horizontal_reversed"), + SAW_BLADE_VERTICAL_ACTIVE = get("mechanical_saw/blade_vertical_active"), + SAW_BLADE_VERTICAL_INACTIVE = get("mechanical_saw/blade_vertical_inactive"), + SAW_BLADE_VERTICAL_REVERSED = get("mechanical_saw/blade_vertical_reversed"), + GAUGE_DIAL = get("gauge/dial"), GAUGE_INDICATOR = get("gauge/indicator"), GAUGE_HEAD_SPEED = get("gauge/speedometer/head"), GAUGE_HEAD_STRESS = get("gauge/stressometer/head"), BEARING_TOP = get("bearing/top"), DRILL_HEAD = get("mechanical_drill/head"), HARVESTER_BLADE = get("mechanical_harvester/blade"), diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java index be4b7a1f3..12d0f3469 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSaw.java @@ -1,6 +1,7 @@ package com.simibubi.create.compat.jei.category.animations; import com.mojang.blaze3d.systems.RenderSystem; +import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.foundation.gui.AllGuiTextures; @@ -29,12 +30,16 @@ public class AnimatedSaw extends AnimatedKinetics { .render(); GuiGameElement.of(AllBlocks.MECHANICAL_SAW.getDefaultState() - .with(SawBlock.FACING, Direction.UP) - .with(SawBlock.RUNNING, true)) + .with(SawBlock.FACING, Direction.UP)) .rotateBlock(0, 0, 0) .scale(scale) .render(); + GuiGameElement.of(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE) + .rotateBlock(0, -90, -90) + .scale(scale) + .render(); + RenderSystem.popMatrix(); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index 39e060e39..7f0e1a778 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -1,6 +1,8 @@ package com.simibubi.create.content.contraptions.components.actors; +import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.content.contraptions.components.saw.SawBlock; +import com.simibubi.create.content.contraptions.components.saw.SawRenderer; import com.simibubi.create.content.contraptions.components.saw.SawTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.utility.BlockHelper; @@ -9,6 +11,7 @@ import com.simibubi.create.foundation.utility.TreeCutter.Tree; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.tags.BlockTags; @@ -16,6 +19,8 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.items.ItemHandlerHelper; public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @@ -62,6 +67,13 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { world.addEntity(entity); } + @Override + @OnlyIn(value = Dist.CLIENT) + public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, + IRenderTypeBuffer buffer) { + SawRenderer.renderInContraption(context, ms, msLocal, buffer); + } + @Override protected DamageSource getDamageSource() { return SawBlock.damageSourceSaw; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java index 56bbebc51..c7dade697 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawBlock.java @@ -35,13 +35,10 @@ import net.minecraft.world.World; @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault public class SawBlock extends DirectionalAxisKineticBlock implements ITE { - - public static final BooleanProperty RUNNING = BooleanProperty.create("running"); public static DamageSource damageSourceSaw = new DamageSource("create.mechanical_saw").setDamageBypassesArmor(); public SawBlock(Properties properties) { super(properties); - setDefaultState(getDefaultState().with(RUNNING, false)); } @Override @@ -53,12 +50,6 @@ public class SawBlock extends DirectionalAxisKineticBlock implements ITE builder) { - builder.add(RUNNING); - super.fillStateContainer(builder); - } - @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return AllTileEntities.SAW.create(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawGenerator.java index d369bec96..3883a3787 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawGenerator.java @@ -33,10 +33,9 @@ public class SawGenerator extends SpecialBlockStateGen { String orientation = state.get(SawBlock.FACING) .getAxis() .isVertical() ? "vertical" : "horizontal"; - String active = state.get(SawBlock.RUNNING) ? "" : "_inactive"; return prov.models() - .getExistingFile(prov.modLoc(path + orientation + active)); + .getExistingFile(prov.modLoc(path + orientation)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index daf43ee93..e467d3c2e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -7,9 +7,10 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import com.simibubi.create.foundation.utility.SuperByteBuffer; +import com.simibubi.create.foundation.utility.*; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -34,11 +35,46 @@ public class SawRenderer extends SafeTileEntityRenderer { @Override protected void renderSafe(SawTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + renderBlade(te, ms, buffer, light); renderItems(te, partialTicks, ms, buffer, light, overlay); FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay); renderShaft(te, ms, buffer, light, overlay); } + protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light){ + BlockState blockState = te.getBlockState(); + SuperByteBuffer superBuffer; + AllBlockPartials partial; + float speed = te.getSpeed(); + + ms.push(); + + if(SawBlock.isHorizontal(blockState)) { + if(speed > 0) { + partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE; + } else if(speed < 0) { + partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_REVERSED; + } else { + partial = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE; + } + } else { + if(te.getSpeed() > 0) { + partial = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE; + } else if(speed < 0) { + partial = AllBlockPartials.SAW_BLADE_VERTICAL_REVERSED; + } else { + partial = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE; + } + + if(!blockState.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE)) + MatrixStacker.of(ms).centre().rotateY(90).unCentre(); + } + superBuffer = partial.renderOnDirectional(blockState); + superBuffer.light(light).renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); + + ms.pop(); + } + protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { KineticTileEntityRenderer.renderRotatingBuffer(te, getRotatedModel(te), ms, buffer.getBuffer(RenderType.getSolid()), light); @@ -96,4 +132,33 @@ public class SawRenderer extends SafeTileEntityRenderer { return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te)); } + public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, + IRenderTypeBuffer buffer) { + MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal }; + BlockState state = context.state; + SuperByteBuffer superBuffer; + Direction facing = state.get(SawBlock.FACING); + + if(SawBlock.isHorizontal(state)) { + superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state); + } else { + superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state); + } + + for (MatrixStack m : matrixStacks) { + MatrixStacker.of(m) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)); + if(!SawBlock.isHorizontal(state)) + MatrixStacker.of(m).rotateZ(state.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); + MatrixStacker.of(m).unCentre(); + } + + superBuffer + .light(msLocal.peek() + .getModel()) + .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java index e824c1ebc..70b3cce8a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntity.java @@ -1,7 +1,5 @@ package com.simibubi.create.content.contraptions.components.saw; -import static com.simibubi.create.content.contraptions.components.saw.SawBlock.RUNNING; - import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -86,15 +84,6 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity { return false; } - @Override - public void onSpeedChanged(float prevSpeed) { - super.onSpeedChanged(prevSpeed); - boolean shouldRun = Math.abs(getSpeed()) > 1 / 64f; - boolean running = getBlockState().get(RUNNING); - if (shouldRun != running && !destroyed) - world.setBlockState(pos, getBlockState().with(RUNNING, shouldRun), 2 | 16); - } - @Override public void write(CompoundNBT compound, boolean clientPacket) { compound.put("Inventory", inventory.serializeNBT()); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index fadd0ef75..4c1169d55 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -394,8 +394,6 @@ public abstract class Contraption { protected Pair capture(World world, BlockPos pos) { BlockState blockstate = world.getBlockState(pos); - if (AllBlocks.MECHANICAL_SAW.has(blockstate)) - blockstate = blockstate.with(SawBlock.RUNNING, true); if (blockstate.getBlock() instanceof ChestBlock) blockstate = blockstate.with(ChestBlock.TYPE, ChestType.SINGLE); if (AllBlocks.ADJUSTABLE_CRATE.has(blockstate)) @@ -657,9 +655,6 @@ public abstract class Contraption { state = state.updatePostPlacement(face, world.getBlockState(targetPos.offset(face)), world, targetPos, targetPos.offset(face)); - if (AllBlocks.MECHANICAL_SAW.has(state)) - state = state.with(SawBlock.RUNNING, false); - BlockState blockState = world.getBlockState(targetPos); if (blockState.getBlockHardness(world, targetPos) == -1 || (state.getCollisionShape(world, targetPos) .isEmpty() diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index 451537bee..5e139d946 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -13,6 +13,7 @@ import com.simibubi.create.content.contraptions.components.crafter.MechanicalCra import com.simibubi.create.content.contraptions.components.deployer.DeployerBlock; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock; +import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock; import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; @@ -217,8 +218,8 @@ public abstract class ArmInteractionPoint { @Override boolean isValid(IBlockReader reader, BlockPos pos, BlockState state) { - return AllBlocks.MECHANICAL_SAW.has(state) && state.get(SawBlock.RUNNING) - && state.get(SawBlock.FACING) == Direction.UP; + return AllBlocks.MECHANICAL_SAW.has(state) && state.get(SawBlock.FACING) == Direction.UP + && ((KineticTileEntity)reader.getTileEntity(pos)).getSpeed() != 0; } } diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_active.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_active.json new file mode 100644 index 000000000..bcd0eedb6 --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_active.json @@ -0,0 +1,19 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)", + "textures": { + "stonecutter_saw": "minecraft:block/stonecutter_saw", + "stonecutter_saw_reversed" : "create:block/saw_reversed" + }, + "parent": "create:block/block", + "elements": [ + { + "name": "Blade", + "from": [ 1, 8, 11 ], + "to": [ 15, 8.062, 18 ], + "faces": { + "up": { "texture": "#stonecutter_saw", "uv": [ 1, 9, 15, 16 ], "rotation": 180 }, + "down": { "texture": "#stonecutter_saw_reversed", "uv": [ 1, 9, 15, 16 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_inactive.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_inactive.json new file mode 100644 index 000000000..d51cbecbe --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_inactive.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/mechanical_saw/blade_horizontal_active", + "textures": { + "stonecutter_saw": "create:block/static_saw", + "stonecutter_saw_reversed": "create:block/static_saw" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_reversed.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_reversed.json new file mode 100644 index 000000000..02382bef0 --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_horizontal_reversed.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/mechanical_saw/blade_horizontal_active", + "textures": { + "stonecutter_saw": "create:block/saw_reversed", + "stonecutter_saw": "minecraft:block/stonecutter_saw" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_active.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_active.json new file mode 100644 index 000000000..b540ed652 --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_active.json @@ -0,0 +1,18 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)", + "textures": { + "stonecutter_saw": "minecraft:block/stonecutter_saw", + "stonecutter_saw_reversed" : "create:block/saw_reversed" + }, + "elements": [ + { + "name": "Saw", + "from": [ 0, 8, 11 ], + "to": [ 16, 8, 19 ], + "faces": { + "up": { "texture": "#stonecutter_saw", "uv": [ 0, 8, 16, 16 ], "rotation": 180 }, + "down": { "texture": "#stonecutter_saw_reversed", "uv": [ 0, 8, 16, 16 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_inactive.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_inactive.json new file mode 100644 index 000000000..627943027 --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_inactive.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/mechanical_saw/blade_vertical_active", + "textures": { + "stonecutter_saw": "create:block/static_saw", + "stonecutter_saw_reversed": "create:block/static_saw" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_reversed.json b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_reversed.json new file mode 100644 index 000000000..56a353a4f --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/blade_vertical_reversed.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/mechanical_saw/blade_vertical_active", + "textures": { + "stonecutter_saw": "create:block/saw_reversed", + "stonecutter_saw_reversed": "minecraft:block/stonecutter_saw" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/horizontal.json b/src/main/resources/assets/create/models/block/mechanical_saw/horizontal.json index 7750da4cb..a21d7706b 100644 --- a/src/main/resources/assets/create/models/block/mechanical_saw/horizontal.json +++ b/src/main/resources/assets/create/models/block/mechanical_saw/horizontal.json @@ -5,7 +5,6 @@ "slit": "create:block/mechanical_saw_top", "gearbox_top": "create:block/gearbox_top", "encased_belt": "create:block/encased_belt", - "stonecutter_saw": "minecraft:block/stonecutter_saw", "gearbox": "create:block/gearbox", "andesite_casing_short": "create:block/andesite_casing_short" }, @@ -66,15 +65,6 @@ "south": { "texture": "#slit", "uv": [ 1, 7, 15, 9 ] } } }, - { - "name": "Blade", - "from": [ 1, 8, 11 ], - "to": [ 15, 8.062, 18 ], - "faces": { - "up": { "texture": "#stonecutter_saw", "uv": [ 1, 9, 15, 16 ], "rotation": 180 }, - "down": { "texture": "#stonecutter_saw", "uv": [ 1, 9, 15, 16 ] } - } - }, { "name": "Back", "from": [ 14, 2, 0 ], diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/horizontal_inactive.json b/src/main/resources/assets/create/models/block/mechanical_saw/horizontal_inactive.json deleted file mode 100644 index d776f1cd9..000000000 --- a/src/main/resources/assets/create/models/block/mechanical_saw/horizontal_inactive.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "create:block/mechanical_saw/horizontal", - "textures": { - "stonecutter_saw": "create:block/static_saw" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/item.json b/src/main/resources/assets/create/models/block/mechanical_saw/item.json new file mode 100644 index 000000000..79d79bb00 --- /dev/null +++ b/src/main/resources/assets/create/models/block/mechanical_saw/item.json @@ -0,0 +1,98 @@ +{ + "__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)", + "textures": { + "particle": "create:block/gearbox_top", + "slit": "create:block/mechanical_saw_top", + "stonecutter_saw": "create:block/static_saw", + "gearbox_top": "create:block/gearbox_top", + "encased_belt": "create:block/encased_belt", + "gearbox": "create:block/gearbox", + "andesite_casing_short": "create:block/andesite_casing_short" + }, + "parent": "create:block/block", + "elements": [ + { + "name": "Bottom", + "from": [ 0, 0, 0 ], + "to": [ 16, 2, 12 ], + "faces": { + "north": { "texture": "#andesite_casing_short", "uv": [ 0, 14, 16, 16 ] }, + "east": { "texture": "#andesite_casing_short", "uv": [ 4, 14, 16, 16 ] }, + "south": { "texture": "#encased_belt", "uv": [ 0, 14, 16, 16 ] }, + "west": { "texture": "#andesite_casing_short", "uv": [ 0, 14, 12, 16 ] }, + "up": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 16, 16 ] }, + "down": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 16, 16 ] } + } + }, + { + "name": "Top", + "from": [ 0, 14, 0 ], + "to": [ 16, 16, 12 ], + "faces": { + "north": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 16, 6 ] }, + "east": { "texture": "#andesite_casing_short", "uv": [ 4, 4, 16, 6 ] }, + "south": { "texture": "#encased_belt", "uv": [ 0, 0, 16, 2 ] }, + "west": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 12, 6 ] }, + "up": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 16, 16 ] }, + "down": { "texture": "#andesite_casing_short", "uv": [ 0, 4, 16, 16 ] } + } + }, + { + "name": "Back", + "from": [ 0, 2, 0 ], + "to": [ 2, 14, 2 ], + "faces": { + "north": { "texture": "#gearbox_top", "uv": [ 14, 2, 16, 14 ] }, + "east": { "texture": "#gearbox_top", "uv": [ 14, 2, 16, 14 ] }, + "south": { "texture": "#gearbox_top", "uv": [ 0, 2, 2, 14 ] }, + "west": { "texture": "#gearbox_top", "uv": [ 0, 2, 2, 14 ] } + } + }, + { + "name": "Inner", + "from": [ 0, 2, 2 ], + "to": [ 16, 14, 11 ], + "faces": { + "east": { "texture": "#andesite_casing_short", "uv": [ 2, 6, 14, 15 ], "rotation": 90 }, + "south": { "texture": "#gearbox_top", "uv": [ 0, 2, 16, 14 ] }, + "west": { "texture": "#andesite_casing_short", "uv": [ 2, 6, 14, 15 ], "rotation": 270 } + } + }, + { + "name": "SawSlit", + "from": [ 1, 7, 11.062 ], + "to": [ 15, 9, 11.062 ], + "faces": { + "south": { "texture": "#slit", "uv": [ 1, 7, 15, 9 ] } + } + }, + { + "name": "Blade", + "from": [ 1, 8, 11 ], + "to": [ 15, 8.062, 18 ], + "faces": { + "up": { "texture": "#stonecutter_saw", "uv": [ 1, 9, 15, 16 ], "rotation": 180 }, + "down": { "texture": "#stonecutter_saw", "uv": [ 1, 9, 15, 16 ] } + } + }, + { + "name": "Back", + "from": [ 14, 2, 0 ], + "to": [ 16, 14, 2 ], + "faces": { + "north": { "texture": "#gearbox_top", "uv": [ 0, 2, 2, 14 ] }, + "east": { "texture": "#gearbox_top", "uv": [ 14, 2, 16, 14 ] }, + "south": { "texture": "#gearbox_top", "uv": [ 0, 2, 2, 14 ] }, + "west": { "texture": "#gearbox_top", "uv": [ 0, 2, 2, 14 ] } + } + }, + { + "name": "Back", + "from": [ 2, 2, 1 ], + "to": [ 14, 14, 2 ], + "faces": { + "north": { "texture": "#gearbox", "uv": [ 2, 2, 14, 14 ] } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/vertical.json b/src/main/resources/assets/create/models/block/mechanical_saw/vertical.json index 931155c43..f63bcea80 100644 --- a/src/main/resources/assets/create/models/block/mechanical_saw/vertical.json +++ b/src/main/resources/assets/create/models/block/mechanical_saw/vertical.json @@ -3,7 +3,6 @@ "textures": { "gearbox_top": "create:block/gearbox_top", "gearbox": "create:block/gearbox", - "stonecutter_saw": "minecraft:block/stonecutter_saw", "andesite_casing_short": "create:block/andesite_casing_short", "mechanical_saw_top": "create:block/mechanical_saw_top", "particle": "create:block/mechanical_saw_top" @@ -57,15 +56,6 @@ "up": { "texture": "#gearbox_top", "uv": [ 0, 14, 16, 16 ], "rotation": 270 } } }, - { - "name": "Saw", - "from": [ 0, 11, 8 ], - "to": [ 16, 19, 8 ], - "faces": { - "north": { "texture": "#stonecutter_saw", "uv": [ 0, 8, 16, 16 ] }, - "south": { "texture": "#stonecutter_saw", "uv": [ 0, 8, 16, 16 ] } - } - }, { "name": "Top", "from": [ 0, 12, 2 ], diff --git a/src/main/resources/assets/create/models/block/mechanical_saw/vertical_inactive.json b/src/main/resources/assets/create/models/block/mechanical_saw/vertical_inactive.json deleted file mode 100644 index 2260d2c6c..000000000 --- a/src/main/resources/assets/create/models/block/mechanical_saw/vertical_inactive.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "create:block/mechanical_saw/vertical", - "textures": { - "stonecutter_saw": "create:block/static_saw" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/block/saw_reversed.png b/src/main/resources/assets/create/textures/block/saw_reversed.png new file mode 100644 index 0000000000000000000000000000000000000000..eef262f2ab7e62fc1ef1535a9c19293a5318c3ca GIT binary patch literal 4854 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 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/create/textures/block/saw_reversed.png.mcmeta b/src/main/resources/assets/create/textures/block/saw_reversed.png.mcmeta new file mode 100644 index 000000000..a328ca58d --- /dev/null +++ b/src/main/resources/assets/create/textures/block/saw_reversed.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 1 + } +} From 5342beacaf0868bcd71b08f8ae4007e5dc4dadb3 Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Sat, 12 Sep 2020 15:47:27 -0400 Subject: [PATCH 2/4] Conditional moving saw operation - Saws are inactive while moving backwards - Vertical moving saws can now damage entities --- .../components/actors/SawMovementBehaviour.java | 12 +++++++++++- .../contraptions/components/saw/SawRenderer.java | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index 7f0e1a778..fea857ff2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -27,7 +27,8 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public boolean isActive(MovementContext context) { - return SawBlock.isHorizontal(context.state); + return !VecHelper.isVecPointingTowards(context.relativeMotion, context.state.get(SawBlock.FACING) + .getOpposite()); } @Override @@ -35,6 +36,15 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { return new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()).scale(.65f); } + @Override + public void visitNewPosition(MovementContext context, BlockPos pos) { + super.visitNewPosition(context, pos); + if(!SawBlock.isHorizontal(context.state) && context.data.contains("BreakingPos")) { + context.data.remove("BreakingPos"); + context.stall = false; + } + } + @Override public boolean canBreak(World world, BlockPos breakingPos, BlockState state) { return super.canBreak(world, breakingPos, state) && SawTileEntity.isSawable(state); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index e467d3c2e..3d7e5ab7b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -139,10 +139,22 @@ public class SawRenderer extends SafeTileEntityRenderer { SuperByteBuffer superBuffer; Direction facing = state.get(SawBlock.FACING); + boolean horizontal = SawBlock.isHorizontal(state); + boolean backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()); + boolean moving = context.getAnimationSpeed() != 0; + boolean shouldAnimate = (context.contraption.stalled && horizontal) + || (!context.contraption.stalled && !backwards && moving); + if(SawBlock.isHorizontal(state)) { - superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state); + if(shouldAnimate) + superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state); + else + superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE.renderOn(state); } else { - superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state); + if(shouldAnimate) + superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE.renderOn(state); + else + superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state); } for (MatrixStack m : matrixStacks) { From b89710237db5cd0edc020fd1fe0e273ff34adbf3 Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Sat, 12 Sep 2020 18:44:53 -0400 Subject: [PATCH 3/4] Saws check actual verticality in contraptions --- .../components/actors/SawMovementBehaviour.java | 8 +++++++- .../content/contraptions/components/saw/SawRenderer.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index fea857ff2..d4a36f042 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -16,6 +16,7 @@ import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.tags.BlockTags; import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -39,7 +40,12 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); - if(!SawBlock.isHorizontal(context.state) && context.data.contains("BreakingPos")) { + Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); + facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); + facingVec.normalize(); + + Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + if(closestToFacing.getAxis().isVertical() && context.data.contains("BreakingPos")) { context.data.remove("BreakingPos"); context.stall = false; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 3d7e5ab7b..078863d50 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.Rotation; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; public class SawRenderer extends SafeTileEntityRenderer { @@ -139,7 +140,13 @@ public class SawRenderer extends SafeTileEntityRenderer { SuperByteBuffer superBuffer; Direction facing = state.get(SawBlock.FACING); - boolean horizontal = SawBlock.isHorizontal(state); + Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); + facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); + facingVec.normalize(); + + Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); + + boolean horizontal = closestToFacing.getAxis().isHorizontal(); boolean backwards = VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()); boolean moving = context.getAnimationSpeed() != 0; boolean shouldAnimate = (context.contraption.stalled && horizontal) From 677363f1b82a0867d476597680e1f145479d70a7 Mon Sep 17 00:00:00 2001 From: Colman Davenport Date: Tue, 13 Oct 2020 00:10:23 -0400 Subject: [PATCH 4/4] Update rendering --- .../contraptions/components/actors/SawMovementBehaviour.java | 3 +-- .../content/contraptions/components/saw/SawRenderer.java | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index d4a36f042..9add6f26f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -41,8 +41,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { public void visitNewPosition(MovementContext context, BlockPos pos) { super.visitNewPosition(context, pos); Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); - facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); - facingVec.normalize(); + facingVec = context.rotation.apply(facingVec); Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z); if(closestToFacing.getAxis().isVertical() && context.data.contains("BreakingPos")) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index 078863d50..5c6478a38 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -70,7 +70,7 @@ public class SawRenderer extends SafeTileEntityRenderer { if(!blockState.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE)) MatrixStacker.of(ms).centre().rotateY(90).unCentre(); } - superBuffer = partial.renderOnDirectional(blockState); + superBuffer = partial.renderOnDirectionalSouth(blockState); superBuffer.light(light).renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); ms.pop(); @@ -141,8 +141,7 @@ public class SawRenderer extends SafeTileEntityRenderer { Direction facing = state.get(SawBlock.FACING); Vec3d facingVec = new Vec3d(context.state.get(SawBlock.FACING).getDirectionVec()); - facingVec = VecHelper.rotate(facingVec, context.rotation.x, context.rotation.y, context.rotation.z); - facingVec.normalize(); + facingVec = context.rotation.apply(facingVec); Direction closestToFacing = Direction.getFacingFromVector(facingVec.x, facingVec.y, facingVec.z);