From 005a9e3177fef435834d911bd8920ff2b866f78d Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 3 Feb 2020 00:31:55 +0100 Subject: [PATCH] Analog Gearshifting - Added the analog belt pulley, an encased belt with adjustable speed transfer - Added an analog redstone lever - Fixed motor values jumping inconsistently - Stabilized Rotation propagation a little - Formatted numbers shown when wearing goggles - Kinetic blocks no longer convey weak redstone power to neighbours - Removed obsolete overlay text for rainbow debug - Fixed Deployers not updating placed/removed fluids consistently - Fixed Crash when entities placed by a deployer drop loot --- .../java/com/simibubi/create/AllBlocks.java | 27 ++-- .../com/simibubi/create/AllTileEntities.java | 18 +-- .../com/simibubi/create/ClientEvents.java | 1 - .../foundation/utility/WrappedWorld.java | 25 ++-- .../modules/contraptions/KineticDebugger.java | 34 ++--- .../contraptions/RotationPropagator.java | 15 +- .../deployer/DeployerTileEntity.java | 33 ++--- .../components/motor/MotorBlock.java | 15 +- .../components/motor/MotorTileEntity.java | 2 +- .../redstone/AnalogLeverBlock.java | 130 ++++++++++++++++++ .../redstone/AnalogLeverTileEntity.java | 72 ++++++++++ .../AnalogLeverTileEntityRenderer.java | 52 +++++++ .../relays/encased/AdjustablePulleyBlock.java | 64 +++++++++ .../encased/AdjustablePulleyTileEntity.java | 69 ++++++++++ .../relays/encased/EncasedBeltBlock.java | 18 ++- .../relays/encased/EncasedShaftBlock.java | 5 + .../relays/encased/GearshiftBlock.java | 2 +- .../gauge/GaugeInformationRenderer.java | 87 ++++++++---- .../create/blockstates/adjustable_pulley.json | 59 ++++++++ .../create/blockstates/analog_lever.json | 28 ++++ .../blockstates/analog_lever_handle.json | 5 + .../blockstates/analog_lever_indicator.json | 5 + .../resources/assets/create/lang/en_us.json | 2 + .../adjustable_pulley/end_horizontal.json | 7 + .../block/adjustable_pulley/end_vertical.json | 7 + .../models/block/adjustable_pulley/item.json | 6 + .../adjustable_pulley/middle_horizontal.json | 7 + .../adjustable_pulley/middle_vertical.json | 7 + .../powered/end_horizontal.json | 7 + .../powered/end_vertical.json | 7 + .../powered/middle_horizontal.json | 7 + .../powered/middle_vertical.json | 7 + .../adjustable_pulley/powered/single.json | 7 + .../block/adjustable_pulley/single.json | 7 + .../models/block/analog_lever/body.json | 30 ++++ .../models/block/analog_lever/handle.json | 31 +++++ .../models/block/analog_lever/indicator.json | 28 ++++ .../models/block/analog_lever/item.json | 81 +++++++++++ .../create/models/item/adjustable_pulley.json | 3 + .../create/models/item/analog_lever.json | 3 + .../textures/block/adjustable_pulley_off.png | Bin 0 -> 506 bytes .../textures/block/adjustable_pulley_on.png | Bin 0 -> 522 bytes .../create/textures/block/analog_lever.png | Bin 0 -> 630 bytes .../loot_tables/blocks/adjustable_pulley.json | 19 +++ .../loot_tables/blocks/analog_lever.json | 19 +++ .../contraptions/adjustable_pulley.json | 29 ++++ .../contraptions/analog_lever.json | 25 ++++ 47 files changed, 997 insertions(+), 115 deletions(-) create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverBlock.java create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntity.java create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyBlock.java create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyTileEntity.java create mode 100644 src/main/resources/assets/create/blockstates/adjustable_pulley.json create mode 100644 src/main/resources/assets/create/blockstates/analog_lever.json create mode 100644 src/main/resources/assets/create/blockstates/analog_lever_handle.json create mode 100644 src/main/resources/assets/create/blockstates/analog_lever_indicator.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/end_horizontal.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/end_vertical.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/item.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/middle_horizontal.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/middle_vertical.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_horizontal.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_vertical.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_horizontal.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_vertical.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/powered/single.json create mode 100644 src/main/resources/assets/create/models/block/adjustable_pulley/single.json create mode 100644 src/main/resources/assets/create/models/block/analog_lever/body.json create mode 100644 src/main/resources/assets/create/models/block/analog_lever/handle.json create mode 100644 src/main/resources/assets/create/models/block/analog_lever/indicator.json create mode 100644 src/main/resources/assets/create/models/block/analog_lever/item.json create mode 100644 src/main/resources/assets/create/models/item/adjustable_pulley.json create mode 100644 src/main/resources/assets/create/models/item/analog_lever.json create mode 100644 src/main/resources/assets/create/textures/block/adjustable_pulley_off.png create mode 100644 src/main/resources/assets/create/textures/block/adjustable_pulley_on.png create mode 100644 src/main/resources/assets/create/textures/block/analog_lever.png create mode 100644 src/main/resources/data/create/loot_tables/blocks/adjustable_pulley.json create mode 100644 src/main/resources/data/create/loot_tables/blocks/analog_lever.json create mode 100644 src/main/resources/data/create/recipes/crafting_shaped/contraptions/adjustable_pulley.json create mode 100644 src/main/resources/data/create/recipes/crafting_shaped/contraptions/analog_lever.json diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 727e20b5d..3afa498e8 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -37,12 +37,14 @@ import com.simibubi.create.modules.contraptions.components.saw.SawBlock; import com.simibubi.create.modules.contraptions.components.turntable.TurntableBlock; import com.simibubi.create.modules.contraptions.components.waterwheel.WaterWheelBlock; import com.simibubi.create.modules.contraptions.processing.BasinBlock; +import com.simibubi.create.modules.contraptions.redstone.AnalogLeverBlock; import com.simibubi.create.modules.contraptions.redstone.ContactBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltTunnelBlock; import com.simibubi.create.modules.contraptions.relays.elementary.CogWheelBlock; import com.simibubi.create.modules.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.modules.contraptions.relays.elementary.ShaftHalfBlock; +import com.simibubi.create.modules.contraptions.relays.encased.AdjustablePulleyBlock; import com.simibubi.create.modules.contraptions.relays.encased.ClutchBlock; import com.simibubi.create.modules.contraptions.relays.encased.EncasedBeltBlock; import com.simibubi.create.modules.contraptions.relays.encased.EncasedShaftBlock; @@ -112,10 +114,11 @@ public enum AllBlocks { LARGE_COGWHEEL(new CogWheelBlock(true)), SHAFTLESS_COGWHEEL(new RenderUtilityAxisBlock()), ENCASED_SHAFT(new EncasedShaftBlock()), - ENCASED_BELT(new EncasedBeltBlock()), + GEARBOX(new GearboxBlock()), CLUTCH(new ClutchBlock()), GEARSHIFT(new GearshiftBlock()), - GEARBOX(new GearboxBlock()), + ENCASED_BELT(new EncasedBeltBlock()), + ADJUSTABLE_PULLEY(new AdjustablePulleyBlock()), BELT(new BeltBlock()), BELT_PULLEY(new RenderUtilityAxisBlock()), MOTOR(new MotorBlock()), @@ -136,11 +139,6 @@ public enum AllBlocks { MECHANICAL_MIXER_POLE(new RenderUtilityBlock()), MECHANICAL_MIXER_HEAD(new RenderUtilityBlock()), BASIN(new BasinBlock()), - DEPLOYER(new DeployerBlock()), - DEPLOYER_POLE(new RenderUtilityBlock()), - DEPLOYER_HAND_POINTING(new RenderUtilityBlock()), - DEPLOYER_HAND_PUNCHING(new RenderUtilityBlock()), - DEPLOYER_HAND_HOLDING(new RenderUtilityBlock()), MECHANICAL_CRAFTER(new MechanicalCrafterBlock()), MECHANICAL_CRAFTER_LID(new RenderUtilityBlock()), MECHANICAL_CRAFTER_ARROW(new RenderUtilityBlock()), @@ -166,8 +164,16 @@ public enum AllBlocks { SAW(new SawBlock()), HARVESTER(new HarvesterBlock()), HARVESTER_BLADE(new HarvesterBladeBlock()), + DEPLOYER(new DeployerBlock()), + DEPLOYER_POLE(new RenderUtilityBlock()), + DEPLOYER_HAND_POINTING(new RenderUtilityBlock()), + DEPLOYER_HAND_PUNCHING(new RenderUtilityBlock()), + DEPLOYER_HAND_HOLDING(new RenderUtilityBlock()), CART_ASSEMBLER(new CartAssemblerBlock()), MINECART_ANCHOR(new MinecartAnchorBlock()), + ANALOG_LEVER(new AnalogLeverBlock()), + ANALOG_LEVER_HANDLE(new RenderUtilityBlock()), + ANALOG_LEVER_INDICATOR(new RenderUtilityBlock()), ANDESITE_CASING(new CasingBlock("andesite_casing")), COPPER_CASING(new CasingBlock("copper_casing")), @@ -211,7 +217,7 @@ public enum AllBlocks { FRAMED_GLASS(new CTGlassBlock(AllCTs.FRAMED_GLASS, false)), HORIZONTAL_FRAMED_GLASS(new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)), VERTICAL_FRAMED_GLASS(new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)), - + OAK_GLASS(new VerticalCTGlassBlock(AllCTs.OAK_GLASS, false)), SPRUCE_GLASS(new VerticalCTGlassBlock(AllCTs.SPRUCE_GLASS, false)), BIRCH_GLASS(new VerticalCTGlassBlock(AllCTs.BIRCH_GLASS, true)), @@ -219,7 +225,7 @@ public enum AllBlocks { DARK_OAK_GLASS(new VerticalCTGlassBlock(AllCTs.DARK_OAK_GLASS, false)), ACACIA_GLASS(new VerticalCTGlassBlock(AllCTs.ACACIA_GLASS, false)), IRON_GLASS(new VerticalCTGlassBlock(AllCTs.IRON_GLASS, false)), - + TILED_GLASS_PANE(new GlassPaneBlock(Properties.from(Blocks.GLASS))), FRAMED_GLASS_PANE(new CTGlassPaneBlock(FRAMED_GLASS.block)), HORIZONTAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.block)), @@ -266,7 +272,8 @@ public enum AllBlocks { DOLOMITE_BRICKS(new Block(Properties.from(DOLOMITE.block))), POLISHED_DOLOMITE(new Block(Properties.from(DOLOMITE.block))), DOLOMITE_PILLAR(new RotatedPillarBlock(Properties.from(DOLOMITE.block))), - DOLOMITE_LAYERS(new LayeredCTBlock(Properties.from(DOLOMITE.block), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)), + DOLOMITE_LAYERS( + new LayeredCTBlock(Properties.from(DOLOMITE.block), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)), VOLCANIC_ROCK(new VolcanicRockBlock()), diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 987c58bc4..2b63251d7 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -37,11 +37,14 @@ import com.simibubi.create.modules.contraptions.components.turntable.TurntableTi import com.simibubi.create.modules.contraptions.components.waterwheel.WaterWheelTileEntity; import com.simibubi.create.modules.contraptions.processing.BasinTileEntity; import com.simibubi.create.modules.contraptions.processing.BasinTileEntityRenderer; +import com.simibubi.create.modules.contraptions.redstone.AnalogLeverTileEntity; +import com.simibubi.create.modules.contraptions.redstone.AnalogLeverTileEntityRenderer; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltTileEntityRenderer; import com.simibubi.create.modules.contraptions.relays.belt.BeltTunnelTileEntity; import com.simibubi.create.modules.contraptions.relays.belt.BeltTunnelTileEntityRenderer; import com.simibubi.create.modules.contraptions.relays.elementary.ShaftTileEntity; +import com.simibubi.create.modules.contraptions.relays.encased.AdjustablePulleyTileEntity; import com.simibubi.create.modules.contraptions.relays.encased.ClutchTileEntity; import com.simibubi.create.modules.contraptions.relays.encased.EncasedShaftTileEntity; import com.simibubi.create.modules.contraptions.relays.encased.EncasedShaftTileEntityRenderer; @@ -93,6 +96,7 @@ public enum AllTileEntities { GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX), TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE), ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT), + ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY), ENCASED_FAN(EncasedFanTileEntity::new, AllBlocks.ENCASED_FAN), NOZZLE(NozzleTileEntity::new, AllBlocks.NOZZLE), CLUTCH(ClutchTileEntity::new, AllBlocks.CLUTCH), @@ -102,10 +106,7 @@ public enum AllTileEntities { BELT_TUNNEL(BeltTunnelTileEntity::new, AllBlocks.BELT_TUNNEL), MECHANICAL_PISTON(MechanicalPistonTileEntity::new, AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON), MECHANICAL_BEARING(MechanicalBearingTileEntity::new, AllBlocks.MECHANICAL_BEARING), - CHASSIS( - ChassisTileEntity::new, - AllBlocks.ROTATION_CHASSIS, - AllBlocks.TRANSLATION_CHASSIS, + CHASSIS(ChassisTileEntity::new, AllBlocks.ROTATION_CHASSIS, AllBlocks.TRANSLATION_CHASSIS, AllBlocks.TRANSLATION_CHASSIS_SECONDARY), DRILL(DrillTileEntity::new, AllBlocks.DRILL), SAW(SawTileEntity::new, AllBlocks.SAW), @@ -120,6 +121,7 @@ public enum AllTileEntities { MECHANICAL_CRAFTER(MechanicalCrafterTileEntity::new, AllBlocks.MECHANICAL_CRAFTER), SPEED_GAUGE(SpeedGaugeTileEntity::new, AllBlocks.SPEED_GAUGE), STRESS_GAUGE(StressGaugeTileEntity::new, AllBlocks.STRESS_GAUGE), + ANALOG_LEVER(AnalogLeverTileEntity::new, AllBlocks.ANALOG_LEVER), // Logistics REDSTONE_BRIDGE(RedstoneLinkTileEntity::new, AllBlocks.REDSTONE_BRIDGE), @@ -128,9 +130,7 @@ public enum AllTileEntities { EXTRACTOR(ExtractorTileEntity::new, AllBlocks.EXTRACTOR, AllBlocks.VERTICAL_EXTRACTOR), LINKED_EXTRACTOR(LinkedExtractorTileEntity::new, AllBlocks.LINKED_EXTRACTOR, AllBlocks.VERTICAL_LINKED_EXTRACTOR), TRANSPOSER(TransposerTileEntity::new, AllBlocks.TRANSPOSER, AllBlocks.VERTICAL_TRANSPOSER), - LINKED_TRANSPOSER( - LinkedTransposerTileEntity::new, - AllBlocks.LINKED_TRANSPOSER, + LINKED_TRANSPOSER(LinkedTransposerTileEntity::new, AllBlocks.LINKED_TRANSPOSER, AllBlocks.VERTICAL_LINKED_TRANSPOSER), BELT_FUNNEL(FunnelTileEntity::new, AllBlocks.BELT_FUNNEL, AllBlocks.VERTICAL_FUNNEL), ENTITY_DETECTOR(BeltObserverTileEntity::new, AllBlocks.ENTITY_DETECTOR), @@ -176,6 +176,7 @@ public enum AllTileEntities { bind(TurntableTileEntity.class, new KineticTileEntityRenderer()); bind(MotorTileEntity.class, new MotorTileEntityRenderer()); bind(EncasedShaftTileEntity.class, new EncasedShaftTileEntityRenderer()); + bind(AdjustablePulleyTileEntity.class, new EncasedShaftTileEntityRenderer()); bind(DrillTileEntity.class, new DrillTileEntityRenderer()); bind(SawTileEntity.class, new SawTileEntityRenderer()); bind(EncasedFanTileEntity.class, new EncasedFanTileEntityRenderer()); @@ -185,6 +186,7 @@ public enum AllTileEntities { bind(BeltTileEntity.class, new BeltTileEntityRenderer()); bind(WaterWheelTileEntity.class, new KineticTileEntityRenderer()); bind(HandCrankTileEntity.class, new HandCrankTileEntityRenderer()); + bind(AnalogLeverTileEntity.class, new AnalogLeverTileEntityRenderer()); bind(MechanicalPistonTileEntity.class, new MechanicalPistonTileEntityRenderer()); bind(MechanicalBearingTileEntity.class, new MechanicalBearingTileEntityRenderer()); @@ -208,7 +210,7 @@ public enum AllTileEntities { bind(BeltTunnelTileEntity.class, new BeltTunnelTileEntityRenderer()); bind(BeltObserverTileEntity.class, new BeltObserverTileEntityRenderer()); bind(FlexpeaterTileEntity.class, new FlexpeaterTileEntityRenderer()); - + // bind(LogisticalControllerTileEntity.class, new LogisticalControllerTileEntityRenderer()); // bind(LogisticiansTableTileEntity.class, new LogisticiansTableTileEntityRenderer()); } diff --git a/src/main/java/com/simibubi/create/ClientEvents.java b/src/main/java/com/simibubi/create/ClientEvents.java index 093d08585..ace18d2e0 100644 --- a/src/main/java/com/simibubi/create/ClientEvents.java +++ b/src/main/java/com/simibubi/create/ClientEvents.java @@ -78,7 +78,6 @@ public class ClientEvents { public static void onRenderHotbar() { CreateClient.schematicHandler.renderOverlay(); - KineticDebugger.renderOverlayText(); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/utility/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/WrappedWorld.java index bd5ff8f79..3c7092e7d 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/WrappedWorld.java @@ -14,7 +14,6 @@ import net.minecraft.tags.NetworkTagManager; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.EmptyTickList; import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.storage.MapData; @@ -28,30 +27,35 @@ public class WrappedWorld extends World { world.getProfiler(), world.isRemote); this.world = world; } - + @Override public World getWorld() { return world; } - + @Override public int getLight(BlockPos pos) { return 15; } - + @Override public int getLightSubtracted(BlockPos pos, int amount) { return 15 - amount; } + @Override + public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { + world.notifyBlockUpdate(pos, oldState, newState, flags); + } + @Override public ITickList getPendingBlockTicks() { - return EmptyTickList.get(); + return world.getPendingBlockTicks(); } @Override public ITickList getPendingFluidTicks() { - return EmptyTickList.get(); + return world.getPendingFluidTicks(); } @Override @@ -63,10 +67,6 @@ public class WrappedWorld extends World { return Collections.emptyList(); } - @Override - public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - } - @Override public void playSound(PlayerEntity player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { @@ -89,9 +89,10 @@ public class WrappedWorld extends World { @Override public boolean addEntity(Entity entityIn) { + entityIn.setWorld(world); return world.addEntity(entityIn); } - + @Override public void registerMapData(MapData mapDataIn) { } @@ -119,7 +120,7 @@ public class WrappedWorld extends World { public NetworkTagManager getTags() { return world.getTags(); } - + @Override public int getMaxHeight() { return 256; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java index f524efac6..d2395f80d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/KineticDebugger.java @@ -1,8 +1,5 @@ package com.simibubi.create.modules.contraptions; -import java.util.ArrayList; -import java.util.List; - import com.mojang.blaze3d.platform.GlStateManager; import com.simibubi.create.CreateClientConfig; import com.simibubi.create.foundation.utility.TessellatorHelper; @@ -33,36 +30,23 @@ public class KineticDebugger { TessellatorHelper.prepareForDrawing(); GlStateManager.disableTexture(); - GlStateManager.lineWidth(2); + GlStateManager.lineWidth(3); + GlStateManager.pushMatrix(); + GlStateManager.translated(toOutline.getX(), toOutline.getY(), toOutline.getZ()); + float f = 1 + 1 / 128f; + GlStateManager.scaled(f, f, f); - WorldRenderer.drawShape(shape, toOutline.getX(), toOutline.getY(), toOutline.getZ(), te.hasSource() ? .5f : 1, - .75f, .75f, 1); + WorldRenderer.drawShape(shape, 0, 0, 0, te.hasSource() ? .5f : 1, .75f, .75f, 1); + GlStateManager.popMatrix(); GlStateManager.lineWidth(1); GlStateManager.enableTexture(); TessellatorHelper.cleanUpAfterDrawing(); } - public static void renderOverlayText() { - if (!isActive()) - return; - KineticTileEntity te = getSelectedTE(); - if (te == null) - return; - - List info = new ArrayList<>(); - te.addDebugInformation(info); - Minecraft mc = Minecraft.getInstance(); - int x = mc.mainWindow.getScaledWidth() / 2 - 25; - int y = mc.mainWindow.getScaledHeight() / 2 + 25; - for (String text : info) { - mc.fontRenderer.drawStringWithShadow(text, x, y, 0xFFFFFF); - y += 10; - } - } - public static boolean isActive() { - return Minecraft.getInstance().gameSettings.showDebugInfo && CreateClientConfig.instance.enableRainbowDebug.get(); + return Minecraft.getInstance().gameSettings.showDebugInfo + && CreateClientConfig.instance.enableRainbowDebug.get(); } public static KineticTileEntity getSelectedTE() { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java index a160a5f7f..bb0cdb6d2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/RotationPropagator.java @@ -9,7 +9,6 @@ import static net.minecraft.state.properties.BlockStateProperties.AXIS; import java.util.LinkedList; import java.util.List; -import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateConfig; import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; @@ -26,6 +25,8 @@ import net.minecraft.world.World; public class RotationPropagator { + private static final int MAX_FLICKER_SCORE = 128; + /** * Determines the change in rotation between two attached kinetic entities. For * instance, an axis connection returns 1 while a 1-to-1 gear connection @@ -68,9 +69,9 @@ public class RotationPropagator { } // Attached Encased Belts - if (AllBlocks.ENCASED_BELT.typeOf(stateFrom) && AllBlocks.ENCASED_BELT.typeOf(stateTo)) { + if (stateFrom.getBlock() instanceof EncasedBeltBlock && stateTo.getBlock() instanceof EncasedBeltBlock) { boolean connected = EncasedBeltBlock.areBlocksConnected(stateFrom, stateTo, direction); - return connected ? 1 : 0; + return connected ? EncasedBeltBlock.getRotationSpeedModifier(from, to) : 0; } // Large Gear <-> Large Gear @@ -209,7 +210,7 @@ public class RotationPropagator { && (newSpeed != 0 && neighbourTE.speed != 0); boolean tooFast = Math.abs(newSpeed) > parameters.maxRotationSpeed.get(); - boolean speedChangedTooOften = updateTE.speedChangeCounter > 50; + boolean speedChangedTooOften = updateTE.speedChangeCounter > MAX_FLICKER_SCORE; if (tooFast || speedChangedTooOften) { world.destroyBlock(pos, true); return; @@ -307,6 +308,7 @@ public class RotationPropagator { List potentialNewSources = new LinkedList<>(); List frontier = new LinkedList<>(); frontier.add(updateTE.getPos()); + BlockPos missingSource = updateTE.hasSource() ? updateTE.getSource() : null; while (!frontier.isEmpty()) { final BlockPos pos = frontier.remove(0); @@ -316,6 +318,8 @@ public class RotationPropagator { currentTE.sendData(); for (KineticTileEntity neighbourTE : getConnectedNeighbours(currentTE)) { + if (neighbourTE.getPos().equals(missingSource)) + continue; if (!neighbourTE.hasSource()) continue; @@ -324,9 +328,8 @@ public class RotationPropagator { continue; } - if (neighbourTE.isSource()) { + if (neighbourTE.isSource()) potentialNewSources.add(neighbourTE); - } frontier.add(neighbourTE.getPos()); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java index e53a29918..54093b03b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntity.java @@ -19,14 +19,12 @@ import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.behaviour.filtering.FilteringBehaviour.SlotPositioning; import com.simibubi.create.foundation.behaviour.inventory.ExtractingBehaviour; import com.simibubi.create.foundation.item.ItemHelper; -import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.NBTHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.WrappedWorld; import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.curiosities.tools.SandPaperItem; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; @@ -59,7 +57,6 @@ import net.minecraft.util.math.RayTraceContext; import net.minecraft.util.math.RayTraceContext.BlockMode; import net.minecraft.util.math.RayTraceContext.FluidMode; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeHooks; @@ -252,7 +249,7 @@ public class DeployerTileEntity extends KineticTileEntity { Vec3d rayTarget = center.add(movementVector.scale(5 / 2f - 1 / 64f)); BlockPos clickedPos = pos.offset(direction, 2); - player.rotationYaw = AngleHelper.horizontalAngle(direction); + player.rotationYaw = direction.getHorizontalAngle(); player.rotationPitch = direction == Direction.UP ? -90 : direction == Direction.DOWN ? 90 : 0; player.setPosition(rayOrigin.x, rayOrigin.y, rayOrigin.z); @@ -386,28 +383,24 @@ public class DeployerTileEntity extends KineticTileEntity { if (item instanceof BucketItem || item instanceof SandPaperItem) { world = new WrappedWorld(world) { + boolean rayMode = false; + + @Override + public BlockRayTraceResult rayTraceBlocks(RayTraceContext context) { + rayMode = true; + BlockRayTraceResult rayTraceBlocks = super.rayTraceBlocks(context); + rayMode = false; + return rayTraceBlocks; + }; + @Override public BlockState getBlockState(BlockPos position) { - if (pos.offset(direction, 3).equals(position) || pos.offset(direction, 1).equals(position)) + if (rayMode + && (pos.offset(direction, 3).equals(position) || pos.offset(direction, 1).equals(position))) return Blocks.BEDROCK.getDefaultState(); return world.getBlockState(position); } - @Override - public void notifyBlockUpdate(BlockPos pos, BlockState oldState, BlockState newState, int flags) { - world.notifyBlockUpdate(pos, oldState, newState, flags); - } - - @Override - public ITickList getPendingBlockTicks() { - return world.getPendingBlockTicks(); - } - - @Override - public ITickList getPendingFluidTicks() { - return world.getPendingFluidTicks(); - } - }; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java index 07fa317cc..97b6e2e1c 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java @@ -75,8 +75,19 @@ public class MotorBlock extends HorizontalKineticBlock @Override public void onScroll(BlockState state, IWorld world, BlockPos pos, double delta) { withTileEntityDo(world, pos, te -> { - int d = Math.abs(te.newGeneratedSpeed) < 32 ? 4 : 16; - te.setSpeedValueLazily((int) (te.newGeneratedSpeed + delta * d)); + boolean forward = delta > 0; + int step = forward ? 1 : -1; + int currentSpeed = te.newGeneratedSpeed; + int magnitude = Math.abs(currentSpeed) - (forward == currentSpeed > 0 ? 0 : 1); + + if (magnitude >= 4) + step *= 4; + if (magnitude >= 32) + step *= 4; + if (magnitude >= 128) + step *= 4; + + te.setSpeedValueLazily(currentSpeed + step); }); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java index 85daf165f..e24f068a2 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorTileEntity.java @@ -12,7 +12,7 @@ import net.minecraft.util.math.MathHelper; public class MotorTileEntity extends GeneratingKineticTileEntity { - public static final int DEFAULT_SPEED = 64; + public static final int DEFAULT_SPEED = 16; public int newGeneratedSpeed; public int generatedSpeed; public int lastModified; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverBlock.java new file mode 100644 index 000000000..9fc69581c --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverBlock.java @@ -0,0 +1,130 @@ +package com.simibubi.create.modules.contraptions.redstone; + +import java.util.Random; + +import com.simibubi.create.foundation.block.IWithTileEntity; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.HorizontalFaceBlock; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.particles.RedstoneParticleData; +import net.minecraft.state.StateContainer.Builder; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; +import net.minecraft.util.Hand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +public class AnalogLeverBlock extends HorizontalFaceBlock implements IWithTileEntity { + + public AnalogLeverBlock() { + super(Properties.from(Blocks.LEVER)); + } + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new AnalogLeverTileEntity(); + } + + @Override + public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, + BlockRayTraceResult hit) { + if (worldIn.isRemote) { + addParticles(state, worldIn, pos, 1.0F); + return true; + } + + boolean sneak = player.isSneaking(); + AnalogLeverTileEntity te = getTileEntity(worldIn, pos); + if (te == null) + return true; + + te.changeState(sneak); + float f = .25f + ((te.state + 5) / 15f) * .5f; + worldIn.playSound((PlayerEntity) null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.2F, f); + return true; + } + + @Override + public int getWeakPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + AnalogLeverTileEntity tileEntity = getTileEntity(blockAccess, pos); + if (tileEntity == null) + return 0; + return tileEntity.state; + } + + @Override + public boolean canProvidePower(BlockState state) { + return true; + } + + @Override + public int getStrongPower(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction side) { + return getFacing(blockState) == side ? getWeakPower(blockState, blockAccess, pos, side) : 0; + } + + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + AnalogLeverTileEntity tileEntity = getTileEntity(worldIn, pos); + if (tileEntity == null) + return; + if (tileEntity.state != 0 && rand.nextFloat() < 0.25F) + addParticles(stateIn, worldIn, pos, 0.5F); + } + + @Override + public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + AnalogLeverTileEntity tileEntity = getTileEntity(worldIn, pos); + if (tileEntity != null && !isMoving && state.getBlock() != newState.getBlock()) { + if (tileEntity.state != 0) + updateNeighbors(state, worldIn, pos); + worldIn.removeTileEntity(pos); + } + } + + private static void addParticles(BlockState state, IWorld worldIn, BlockPos pos, float alpha) { + Direction direction = state.get(HORIZONTAL_FACING).getOpposite(); + Direction direction1 = getFacing(state).getOpposite(); + double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) direction.getXOffset() + + 0.2D * (double) direction1.getXOffset(); + double d1 = (double) pos.getY() + 0.5D + 0.1D * (double) direction.getYOffset() + + 0.2D * (double) direction1.getYOffset(); + double d2 = (double) pos.getZ() + 0.5D + 0.1D * (double) direction.getZOffset() + + 0.2D * (double) direction1.getZOffset(); + worldIn.addParticle(new RedstoneParticleData(1.0F, 0.0F, 0.0F, alpha), d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + + static void updateNeighbors(BlockState state, World world, BlockPos pos) { + world.notifyNeighborsOfStateChange(pos, state.getBlock()); + world.notifyNeighborsOfStateChange(pos.offset(getFacing(state).getOpposite()), state.getBlock()); + } + + @SuppressWarnings("deprecation") + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return Blocks.LEVER.getShape(state, worldIn, pos, context); + } + + @Override + protected void fillStateContainer(Builder builder) { + super.fillStateContainer(builder.add(HORIZONTAL_FACING, FACE)); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntity.java new file mode 100644 index 000000000..f4b3790c2 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntity.java @@ -0,0 +1,72 @@ +package com.simibubi.create.modules.contraptions.redstone; + +import java.util.List; + +import com.simibubi.create.AllTileEntities; +import com.simibubi.create.foundation.behaviour.base.SmartTileEntity; +import com.simibubi.create.foundation.behaviour.base.TileEntityBehaviour; +import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.util.math.MathHelper; + +public class AnalogLeverTileEntity extends SmartTileEntity { + + int state = 0; + int lastChange; + InterpolatedChasingValue clientState = new InterpolatedChasingValue().withSpeed(.2f); + + public AnalogLeverTileEntity() { + super(AllTileEntities.ANALOG_LEVER.type); + } + + @Override + public CompoundNBT write(CompoundNBT compound) { + compound.putInt("State", state); + compound.putInt("ChangeTimer", lastChange); + return super.write(compound); + } + + @Override + public void read(CompoundNBT compound) { + state = compound.getInt("State"); + lastChange = compound.getInt("ChangeTimer"); + clientState.target(state); + super.read(compound); + } + + @Override + public void tick() { + super.tick(); + if (lastChange > 0) { + lastChange--; + if (lastChange == 0) + updateOutput(); + } + if (world.isRemote) + clientState.tick(); + } + + private void updateOutput() { + AnalogLeverBlock.updateNeighbors(getBlockState(), world, pos); + } + + @Override + public void addBehaviours(List behaviours) { + } + + @Override + public boolean hasFastRenderer() { + return true; + } + + public void changeState(boolean back) { + int prevState = state; + state += back ? -1 : 1; + state = MathHelper.clamp(state, 0, 15); + if (prevState != state) + lastChange = 15; + sendData(); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java new file mode 100644 index 000000000..253804b01 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/redstone/AnalogLeverTileEntityRenderer.java @@ -0,0 +1,52 @@ +package com.simibubi.create.modules.contraptions.redstone; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.utility.AngleHelper; +import com.simibubi.create.foundation.utility.ColorHelper; +import com.simibubi.create.foundation.utility.SuperByteBuffer; + +import net.minecraft.block.BlockState; +import net.minecraft.client.renderer.BufferBuilder; +import net.minecraft.state.properties.AttachFace; +import net.minecraft.util.Direction.Axis; +import net.minecraftforge.client.model.animation.TileEntityRendererFast; + +public class AnalogLeverTileEntityRenderer extends TileEntityRendererFast { + + @Override + public void renderTileEntityFast(AnalogLeverTileEntity te, double x, double y, double z, float partialTicks, + int destroyStage, BufferBuilder buffer) { + BlockState leverState = te.getBlockState(); + if (!AllBlocks.ANALOG_LEVER.typeOf(leverState)) + return; + + int lightCoords = leverState.getPackedLightmapCoords(getWorld(), te.getPos()); + float state = te.clientState.get(partialTicks); + + // Handle + SuperByteBuffer handle = render(AllBlocks.ANALOG_LEVER_HANDLE); + float angle = (float) ((state / 15) * 90 / 180 * Math.PI); + handle.translate(-1 / 2f, -1 / 16f, -1 / 2f).rotate(Axis.X, angle).translate(1 / 2f, 1 / 16f, 1 / 2f); + transform(handle, leverState).light(lightCoords).translate(x, y, z).renderInto(buffer); + + // Indicator + int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f); + SuperByteBuffer indicator = transform(render(AllBlocks.ANALOG_LEVER_INDICATOR), leverState); + indicator.light(lightCoords).translate(x, y, z).color(color).renderInto(buffer); + } + + private SuperByteBuffer render(AllBlocks model) { + return CreateClient.bufferCache.renderGenericBlockModel(model.getDefault()); + } + + private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) { + AttachFace face = leverState.get(AnalogLeverBlock.FACE); + float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; + float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING)); + buffer.rotateCentered(Axis.X, (float) (rX / 180 * Math.PI)); + buffer.rotateCentered(Axis.Y, (float) (rY / 180 * Math.PI)); + return buffer; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyBlock.java new file mode 100644 index 000000000..c77d13c4e --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyBlock.java @@ -0,0 +1,64 @@ +package com.simibubi.create.modules.contraptions.relays.encased; + +import com.simibubi.create.foundation.block.IWithTileEntity; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.StateContainer.Builder; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; + +public class AdjustablePulleyBlock extends EncasedBeltBlock implements IWithTileEntity { + + public static BooleanProperty POWERED = BlockStateProperties.POWERED; + + public AdjustablePulleyBlock() { + setDefaultState(getDefaultState().with(POWERED, false)); + } + + @Override + protected void fillStateContainer(Builder builder) { + super.fillStateContainer(builder.add(POWERED)); + } + + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + return new AdjustablePulleyTileEntity(); + } + + @Override + public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving) { + if (oldState.getBlock() != state.getBlock()) + withTileEntityDo(worldIn, pos, AdjustablePulleyTileEntity::neighborChanged); + } + + @Override + public void updateNeighbors(BlockState stateIn, IWorld worldIn, BlockPos pos, int flags) { + super.updateNeighbors(stateIn, worldIn, pos, flags); + } + + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + return super.getStateForPlacement(context).with(POWERED, context.getWorld().isBlockPowered(context.getPos())); + } + + @Override + public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + if (worldIn.isRemote) + return; + + withTileEntityDo(worldIn, pos, AdjustablePulleyTileEntity::neighborChanged); + + boolean previouslyPowered = state.get(POWERED); + if (previouslyPowered != worldIn.isBlockPowered(pos)) + worldIn.setBlockState(pos, state.cycle(POWERED), 18); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyTileEntity.java new file mode 100644 index 000000000..1deacba3e --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/AdjustablePulleyTileEntity.java @@ -0,0 +1,69 @@ +package com.simibubi.create.modules.contraptions.relays.encased; + +import com.simibubi.create.AllTileEntities; +import com.simibubi.create.modules.contraptions.base.KineticTileEntity; + +import net.minecraft.nbt.CompoundNBT; + +public class AdjustablePulleyTileEntity extends KineticTileEntity { + + int signal; + boolean signalChanged; + + public AdjustablePulleyTileEntity() { + super(AllTileEntities.ADJUSTABLE_PULLEY.type); + signal = 0; + setLazyTickRate(40); + } + + @Override + public CompoundNBT write(CompoundNBT compound) { + compound.putInt("Signal", signal); + return super.write(compound); + } + + @Override + public void read(CompoundNBT compound) { + signal = compound.getInt("Signal"); + super.read(compound); + } + + public float getModifier() { + return getModifierForSignal(signal); + } + + public void neighborChanged() { + int power = world.getRedstonePowerFromNeighbors(pos); + if (power != signal) + signalChanged = true; + } + + @Override + public void lazyTick() { + super.lazyTick(); + neighborChanged(); + } + + @Override + public void tick() { + super.tick(); + if (signalChanged) { + signalChanged = false; + analogSignalChanged(world.getRedstonePowerFromNeighbors(pos)); + } + } + + protected void analogSignalChanged(int newSignal) { + detachKinetics(); + removeSource(); + signal = newSignal; + attachKinetics(); + } + + protected float getModifierForSignal(int newPower) { + if (newPower == 0) + return 1; + return 1 + ((newPower + 1) / 16f); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java index cf6f20cf7..b5747388e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java @@ -1,6 +1,7 @@ package com.simibubi.create.modules.contraptions.relays.encased; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; +import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; import net.minecraft.block.Block; @@ -33,6 +34,11 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { setDefaultState(getDefaultState().with(PART, Part.NONE)); } + @Override + public boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) { + return false; + } + @Override protected void fillStateContainer(Builder builder) { super.fillStateContainer(builder.add(PART, CONNECTED_ALONG_FIRST_COORDINATE)); @@ -73,7 +79,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { if (axis == faceAxis) return stateIn; - if (neighbour.getBlock() != this) { + if (!(neighbour.getBlock() instanceof EncasedBeltBlock)) { if (facingAlongFirst != connectionAlongFirst || part == Part.NONE) return stateIn; if (part == Part.MIDDLE) @@ -141,6 +147,16 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { return false; } + public static float getRotationSpeedModifier(KineticTileEntity from, KineticTileEntity to) { + float fromMod = 1; + float toMod = 1; + if (from instanceof AdjustablePulleyTileEntity) + fromMod = ((AdjustablePulleyTileEntity) from).getModifier(); + if (to instanceof AdjustablePulleyTileEntity) + toMod = ((AdjustablePulleyTileEntity) to).getModifier(); + return fromMod / toMod; + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new EncasedShaftTileEntity(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java index db6e02bb3..c8a0c4153 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java @@ -19,6 +19,11 @@ public class EncasedShaftBlock extends RotatedPillarKineticBlock { super(Properties.from(Blocks.ANDESITE)); } + @Override + public boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side) { + return false; + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new EncasedShaftTileEntity(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java index 6558663a9..6d7708c4e 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java @@ -51,8 +51,8 @@ public class GearshiftBlock extends EncasedShaftBlock { boolean previouslyPowered = state.get(POWERED); if (previouslyPowered != worldIn.isBlockPowered(pos)) { - worldIn.setBlockState(pos, state.cycle(POWERED), 2 | 16); RotationPropagator.handleRemoved(worldIn, pos, (KineticTileEntity) worldIn.getTileEntity(pos)); + worldIn.setBlockState(pos, state.cycle(POWERED), 2); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java index 742d62d9c..9a6eb4acd 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeInformationRenderer.java @@ -1,8 +1,10 @@ package com.simibubi.create.modules.contraptions.relays.gauge; +import static net.minecraft.util.text.TextFormatting.AQUA; import static net.minecraft.util.text.TextFormatting.DARK_GRAY; import static net.minecraft.util.text.TextFormatting.GRAY; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; @@ -37,6 +39,8 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(value = Dist.CLIENT) public class GaugeInformationRenderer { + private static DecimalFormat decimalFormat = new DecimalFormat("#.##"); + @SubscribeEvent public static void lookingAtBlocksThroughGogglesShowsTooltip(RenderGameOverlayEvent.Post event) { if (event.getType() != ElementType.HOTBAR) @@ -101,11 +105,20 @@ public class GaugeInformationRenderer { if (stressApplied == 0) return; - tooltip.add(spacing + Lang.translate("gui.goggles.kinetic_stats")); - tooltip.add(spacing + GRAY + Lang.translate("tooltip.stressImpact")); - String addedCapacity = TextFormatting.AQUA + "" + stressApplied + Lang.translate("generic.unit.stress") + " " - + DARK_GRAY + Lang.translate("gui.goggles.at_current_speed"); - tooltip.add(spacing + " " + addedCapacity); + String _kineticStatsTitle = Lang.translate("gui.goggles.kinetic_stats"); + String _stressImpact = Lang.translate("tooltip.stressImpact"); + String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed"); + String _stressUnit = Lang.translate("generic.unit.stress"); + String _baseValue = Lang.translate("gui.goggles.base_value"); + + tooltip.add(spacing + _kineticStatsTitle); + tooltip.add(spacing + GRAY + _stressImpact); + + String addedStress = AQUA + "" + format(stressApplied) + _stressUnit + " " + DARK_GRAY + _atCurrentSpeed; + String addedStressAtBase = GRAY + "" + format(stressApplied * te.getSpeed()) + _stressUnit + " " + DARK_GRAY + + _baseValue; + tooltip.add(spacing + " " + addedStress); + tooltip.add(spacing + " " + addedStressAtBase); } private static void addGeneratorTooltip(BlockState state, List tooltip, GeneratingKineticTileEntity te) { @@ -114,25 +127,45 @@ public class GaugeInformationRenderer { if (addedStressCapacity == 0) return; - tooltip.add(spacing + Lang.translate("gui.goggles.generator_stats")); - tooltip.add(spacing + GRAY + Lang.translate("tooltip.capacityProvided")); + String _stressUnit = Lang.translate("generic.unit.stress"); + String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed"); + String _baseValue = Lang.translate("gui.goggles.base_value"); + String _generatorStatsTitle = Lang.translate("gui.goggles.generator_stats"); + String _capacityProvided = Lang.translate("tooltip.capacityProvided"); + + if (te.speed != te.getGeneratedSpeed() && te.speed != 0) + addedStressCapacity *= (te.getGeneratedSpeed() / te.speed); + + tooltip.add(spacing + _generatorStatsTitle); + tooltip.add(spacing + GRAY + _capacityProvided); float actualSpeed = Math.abs(te.speed); float relativeCap = 0; if (actualSpeed != 0) relativeCap = addedStressCapacity * actualSpeed; - String addedCapacity = TextFormatting.AQUA + "" + addedStressCapacity + Lang.translate("generic.unit.stress") - + " " + DARK_GRAY + Lang.translate("gui.goggles.at_current_speed"); - String addedCapacityAtBase = GRAY + "" + (relativeCap) + Lang.translate("generic.unit.stress") + " " + DARK_GRAY - + Lang.translate("gui.goggles.base_value"); + String addedCapacity = AQUA + "" + format(addedStressCapacity) + _stressUnit + " " + DARK_GRAY + + _atCurrentSpeed; + String addedCapacityAtBase = GRAY + "" + format(relativeCap) + _stressUnit + " " + DARK_GRAY + _baseValue; tooltip.add(spacing + " " + addedCapacity); tooltip.add(spacing + " " + addedCapacityAtBase); } private static void addGaugeTooltip(BlockState state, List tooltip, TileEntity te) { + + String _rpmUnit = Lang.translate("generic.unit.rpm"); + String _speedGaugeTitle = Lang.translate("gui.speed_gauge.title"); + String _infoHeader = Lang.translate("gui.gauge.info_header"); + String _overStressed = Lang.translate("gui.stress_gauge.overstressed"); + String _noRotation = Lang.translate("gui.stress_gauge.no_rotation"); + String _capacity = Lang.translate("gui.stress_gauge.capacity"); + String _stressGaugeTitle = Lang.translate("gui.stress_gauge.title"); + String _stressUnit = Lang.translate("generic.unit.stress"); + String _atCurrentSpeed = Lang.translate("gui.goggles.at_current_speed"); + String _baseValue = Lang.translate("gui.goggles.base_value"); + String spacing = " "; - tooltip.add(spacing + Lang.translate("gui.gauge.info_header")); + tooltip.add(spacing + _infoHeader); if (AllBlocks.STRESS_GAUGE.typeOf(state)) { if (!(te instanceof StressGaugeTileEntity)) @@ -154,8 +187,7 @@ public class GaugeInformationRenderer { if (impactId == StressImpact.HIGH) color = TextFormatting.GOLD; - String level = TextFormatting.DARK_RED + ItemDescription.makeProgressBar(3, 2) + "" - + Lang.translate("gui.stress_gauge.overstressed"); + String level = TextFormatting.DARK_RED + ItemDescription.makeProgressBar(3, 2) + "" + _overStressed; if (impactId != null) { int index = impactId.ordinal(); level = color + ItemDescription.makeProgressBar(3, index) + stressLevels.get(index); @@ -165,25 +197,20 @@ public class GaugeInformationRenderer { float actualSpeed = stressGauge.speed; if (actualSpeed == 0) - level = DARK_GRAY + ItemDescription.makeProgressBar(3, -1) - + Lang.translate("gui.stress_gauge.no_rotation"); + level = DARK_GRAY + ItemDescription.makeProgressBar(3, -1) + _noRotation; - tooltip.add(spacing + GRAY + Lang.translate("gui.stress_gauge.title")); + tooltip.add(spacing + GRAY + _stressGaugeTitle); tooltip.add(spacing + level); if (actualSpeed != 0) { - tooltip.add(spacing + GRAY + Lang.translate("gui.stress_gauge.capacity")); + tooltip.add(spacing + GRAY + _capacity); - String capacity = color + "" + ((cap - stress) / Math.abs(actualSpeed)) - + Lang.translate("generic.unit.stress") + " " + DARK_GRAY - + Lang.translate("gui.goggles.at_current_speed"); - String capacityAtBase = GRAY + "" + (cap - stress) + Lang.translate("generic.unit.stress") + " " + DARK_GRAY - + Lang.translate("gui.goggles.base_value"); + String capacity = color + "" + format((cap - stress) / Math.abs(actualSpeed)) + _stressUnit + " " + + DARK_GRAY + _atCurrentSpeed; + String capacityAtBase = GRAY + "" + format(cap - stress) + _stressUnit + " " + DARK_GRAY + _baseValue; tooltip.add(spacing + " " + capacity); tooltip.add(spacing + " " + capacityAtBase); - } - } if (AllBlocks.SPEED_GAUGE.typeOf(state)) { @@ -201,14 +228,18 @@ public class GaugeInformationRenderer { int index = speedLevel.ordinal(); String level = color + ItemDescription.makeProgressBar(3, index) + (speedLevel != SpeedLevel.NONE ? speedLevels.get(index) : ""); - level += " (" + Math.abs(speedGauge.speed) + "" + Lang.translate("generic.unit.rpm") + ") "; + level += " (" + format(Math.abs(speedGauge.speed)) + "" + _rpmUnit + ") "; - tooltip.add(spacing + GRAY + Lang.translate("gui.speed_gauge.title")); + tooltip.add(spacing + GRAY + _speedGaugeTitle); tooltip.add(spacing + level); if (overstressed) - tooltip.add(spacing + TextFormatting.DARK_RED + Lang.translate("gui.stress_gauge.overstressed")); + tooltip.add(spacing + TextFormatting.DARK_RED + _overStressed); } } + private static String format(double d) { + return decimalFormat.format(d); + } + } diff --git a/src/main/resources/assets/create/blockstates/adjustable_pulley.json b/src/main/resources/assets/create/blockstates/adjustable_pulley.json new file mode 100644 index 000000000..10ca08d20 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/adjustable_pulley.json @@ -0,0 +1,59 @@ +{ + "variants": { + "powered=false,part=none,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/single", "y": 90 }, + "powered=false,part=none,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/single", "x": 90 }, + "powered=false,part=none,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/single" }, + "powered=false,part=none,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/single", "y": 90 }, + "powered=false,part=none,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/single", "x": 90 }, + "powered=false,part=none,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/single" }, + + "powered=false,part=start,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/end_horizontal", "x": 180 }, + "powered=false,part=start,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/end_horizontal", "x": 270 }, + "powered=false,part=middle,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/middle_horizontal" }, + "powered=false,part=middle,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/middle_horizontal", "x": 90 }, + "powered=false,part=end,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/end_horizontal" }, + "powered=false,part=end,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/end_horizontal", "x": 90 }, + + "powered=false,part=start,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/end_vertical" }, + "powered=false,part=start,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/end_vertical", "y": 270 }, + "powered=false,part=middle,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/middle_vertical" }, + "powered=false,part=middle,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/middle_vertical", "y": 90 }, + "powered=false,part=end,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/end_vertical", "y": 180 }, + "powered=false,part=end,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/end_vertical", "y": 90 }, + + "powered=false,part=start,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/end_horizontal", "x": 270, "y": 90 }, + "powered=false,part=start,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/end_horizontal", "y": 90 }, + "powered=false,part=middle,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/middle_horizontal", "x": 90, "y": 90 }, + "powered=false,part=middle,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/middle_horizontal", "y": 90 }, + "powered=false,part=end,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/end_horizontal", "x": 90, "y": 90 }, + "powered=false,part=end,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/end_horizontal", "y": 270 }, + + "powered=true,part=none,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/powered/single", "y": 90 }, + "powered=true,part=none,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/powered/single", "x": 90 }, + "powered=true,part=none,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/powered/single" }, + "powered=true,part=none,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/powered/single", "y": 90 }, + "powered=true,part=none,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/powered/single", "x": 90 }, + "powered=true,part=none,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/powered/single" }, + + "powered=true,part=start,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "x": 180 }, + "powered=true,part=start,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "x": 270 }, + "powered=true,part=middle,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/powered/middle_horizontal" }, + "powered=true,part=middle,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/powered/middle_horizontal", "x": 90 }, + "powered=true,part=end,axis_along_first=false,axis=x": { "model": "create:block/adjustable_pulley/powered/end_horizontal" }, + "powered=true,part=end,axis_along_first=true,axis=x": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "x": 90 }, + + "powered=true,part=start,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/powered/end_vertical" }, + "powered=true,part=start,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/powered/end_vertical", "y": 270 }, + "powered=true,part=middle,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/powered/middle_vertical" }, + "powered=true,part=middle,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/powered/middle_vertical", "y": 90 }, + "powered=true,part=end,axis_along_first=false,axis=y": { "model": "create:block/adjustable_pulley/powered/end_vertical", "y": 180 }, + "powered=true,part=end,axis_along_first=true,axis=y": { "model": "create:block/adjustable_pulley/powered/end_vertical", "y": 90 }, + + "powered=true,part=start,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "x": 270, "y": 90 }, + "powered=true,part=start,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "y": 90 }, + "powered=true,part=middle,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/powered/middle_horizontal", "x": 90, "y": 90 }, + "powered=true,part=middle,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/powered/middle_horizontal", "y": 90 }, + "powered=true,part=end,axis_along_first=false,axis=z": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "x": 90, "y": 90 }, + "powered=true,part=end,axis_along_first=true,axis=z": { "model": "create:block/adjustable_pulley/powered/end_horizontal", "y": 270 } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/blockstates/analog_lever.json b/src/main/resources/assets/create/blockstates/analog_lever.json new file mode 100644 index 000000000..a1c828734 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/analog_lever.json @@ -0,0 +1,28 @@ +{ + "variants": { + "face=ceiling,facing=north": { "model": "create:block/analog_lever/body", "x": 180, "y": 180 }, + "face=ceiling,facing=east": { "model": "create:block/analog_lever/body", "x": 180, "y": 270 }, + "face=ceiling,facing=south": { "model": "create:block/analog_lever/body", "x": 180}, + "face=ceiling,facing=west": { "model": "create:block/analog_lever/body", "x": 180, "y": 90 }, + "face=floor,facing=north": { "model": "create:block/analog_lever/body" }, + "face=floor,facing=east": { "model": "create:block/analog_lever/body", "y": 90 }, + "face=floor,facing=south": { "model": "create:block/analog_lever/body", "y": 180 }, + "face=floor,facing=west": { "model": "create:block/analog_lever/body", "y": 270 }, + "face=wall,facing=north": { "model": "create:block/analog_lever/body", "x": 90 }, + "face=wall,facing=east": { "model": "create:block/analog_lever/body", "x": 90, "y": 90 }, + "face=wall,facing=south": { "model": "create:block/analog_lever/body", "x": 90, "y": 180 }, + "face=wall,facing=west": { "model": "create:block/analog_lever/body", "x": 90, "y": 270 }, + "face=ceiling,facing=north": { "model": "create:block/analog_lever/body", "x": 180, "y": 180 }, + "face=ceiling,facing=east": { "model": "create:block/analog_lever/body", "x": 180, "y": 270 }, + "face=ceiling,facing=south": { "model": "create:block/analog_lever/body", "x": 180}, + "face=ceiling,facing=west": { "model": "create:block/analog_lever/body", "x": 180, "y": 90 }, + "face=floor,facing=north": { "model": "create:block/analog_lever/body" }, + "face=floor,facing=east": { "model": "create:block/analog_lever/body", "y": 90 }, + "face=floor,facing=south": { "model": "create:block/analog_lever/body", "y": 180 }, + "face=floor,facing=west": { "model": "create:block/analog_lever/body", "y": 270 }, + "face=wall,facing=north": { "model": "create:block/analog_lever/body", "x": 90 }, + "face=wall,facing=east": { "model": "create:block/analog_lever/body", "x": 90, "y": 90 }, + "face=wall,facing=south": { "model": "create:block/analog_lever/body", "x": 90, "y": 180 }, + "face=wall,facing=west": { "model": "create:block/analog_lever/body", "x": 90, "y": 270 } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/blockstates/analog_lever_handle.json b/src/main/resources/assets/create/blockstates/analog_lever_handle.json new file mode 100644 index 000000000..cb092f48c --- /dev/null +++ b/src/main/resources/assets/create/blockstates/analog_lever_handle.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "create:block/analog_lever/handle" } + } +} diff --git a/src/main/resources/assets/create/blockstates/analog_lever_indicator.json b/src/main/resources/assets/create/blockstates/analog_lever_indicator.json new file mode 100644 index 000000000..a9045f7d0 --- /dev/null +++ b/src/main/resources/assets/create/blockstates/analog_lever_indicator.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "create:block/analog_lever/indicator" } + } +} diff --git a/src/main/resources/assets/create/lang/en_us.json b/src/main/resources/assets/create/lang/en_us.json index 04287485b..12ed443e8 100644 --- a/src/main/resources/assets/create/lang/en_us.json +++ b/src/main/resources/assets/create/lang/en_us.json @@ -88,6 +88,7 @@ "block.create.encased_belt": "Encased Belt", "block.create.encased_shaft": "Encased Shaft", "block.create.encased_fan": "Encased Fan", + "block.create.adjustable_pulley": "Analog Belt Pulley", "block.create.nozzle": "Nozzle", "block.create.hand_crank": "Hand Crank", "block.create.motor": "Motor", @@ -105,6 +106,7 @@ "block.create.speed_gauge": "Speedometer", "block.create.stress_gauge": "Stress Gauge", "block.create.cart_assembler": "Cart Assembler", + "block.create.analog_lever": "Analog Lever", "block.create.sticky_mechanical_piston": "Sticky Mechanical Piston", "block.create.mechanical_piston": "Mechanical Piston", diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/end_horizontal.json b/src/main/resources/assets/create/models/block/adjustable_pulley/end_horizontal.json new file mode 100644 index 000000000..4c314e645 --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/end_horizontal.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/end_horizontal", + "textures": { + "0": "create:block/adjustable_pulley_off", + "particle": "create:block/adjustable_pulley_off" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/end_vertical.json b/src/main/resources/assets/create/models/block/adjustable_pulley/end_vertical.json new file mode 100644 index 000000000..a61e4395c --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/end_vertical.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/end_vertical", + "textures": { + "1": "create:block/adjustable_pulley_off", + "particle": "create:block/adjustable_pulley_off" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/item.json b/src/main/resources/assets/create/models/block/adjustable_pulley/item.json new file mode 100644 index 000000000..7a1d89752 --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/item.json @@ -0,0 +1,6 @@ +{ + "parent": "create:block/encased_belt/item", + "textures": { + "0": "create:block/adjustable_pulley_off" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/middle_horizontal.json b/src/main/resources/assets/create/models/block/adjustable_pulley/middle_horizontal.json new file mode 100644 index 000000000..a1ccef9be --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/middle_horizontal.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/middle_horizontal", + "textures": { + "0": "create:block/adjustable_pulley_off", + "particle": "create:block/adjustable_pulley_off" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/middle_vertical.json b/src/main/resources/assets/create/models/block/adjustable_pulley/middle_vertical.json new file mode 100644 index 000000000..44da384ec --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/middle_vertical.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/middle_vertical", + "textures": { + "0": "create:block/adjustable_pulley_off", + "particle": "create:block/adjustable_pulley_off" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_horizontal.json b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_horizontal.json new file mode 100644 index 000000000..203b7a248 --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_horizontal.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/end_horizontal", + "textures": { + "0": "create:block/adjustable_pulley_on", + "particle": "create:block/adjustable_pulley_on" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_vertical.json b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_vertical.json new file mode 100644 index 000000000..24b120f68 --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/end_vertical.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/end_vertical", + "textures": { + "1": "create:block/adjustable_pulley_on", + "particle": "create:block/adjustable_pulley_on" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_horizontal.json b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_horizontal.json new file mode 100644 index 000000000..df44b3b9a --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_horizontal.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/middle_horizontal", + "textures": { + "0": "create:block/adjustable_pulley_on", + "particle": "create:block/adjustable_pulley_on" + } +} diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_vertical.json b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_vertical.json new file mode 100644 index 000000000..e85bc9af2 --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/middle_vertical.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/middle_vertical", + "textures": { + "0": "create:block/adjustable_pulley_on", + "particle": "create:block/adjustable_pulley_on" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/powered/single.json b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/single.json new file mode 100644 index 000000000..66445a3ec --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/powered/single.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/single", + "textures": { + "0": "create:block/adjustable_pulley_on", + "particle": "create:block/adjustable_pulley_on" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/adjustable_pulley/single.json b/src/main/resources/assets/create/models/block/adjustable_pulley/single.json new file mode 100644 index 000000000..c2ba3e4be --- /dev/null +++ b/src/main/resources/assets/create/models/block/adjustable_pulley/single.json @@ -0,0 +1,7 @@ +{ + "parent": "create:block/encased_belt/single", + "textures": { + "0": "create:block/adjustable_pulley_off", + "particle": "create:block/adjustable_pulley_off" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/analog_lever/body.json b/src/main/resources/assets/create/models/block/analog_lever/body.json new file mode 100644 index 000000000..31fc05c5a --- /dev/null +++ b/src/main/resources/assets/create/models/block/analog_lever/body.json @@ -0,0 +1,30 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "4": "create:block/analog_lever", + "particle": "block/lever" + }, + "elements": [ + { + "from": [5, 0, 4], + "to": [11, 3, 12], + "faces": { + "north": {"uv": [0, 0, 3, 6], "rotation": 270, "texture": "#4"}, + "east": {"uv": [3, 6, 11, 9], "texture": "#4"}, + "south": {"uv": [11, 0, 14, 6], "rotation": 90, "texture": "#4"}, + "west": {"uv": [3, 6, 11, 9], "texture": "#4"}, + "up": {"uv": [3, 0, 11, 6], "rotation": 90, "texture": "#4"}, + "down": {"uv": [3, 10, 11, 16], "rotation": 90, "texture": "#4", "cullface": "down"} + } + } + ], + "groups": [ + { + "name": "lever", + "origin": [8, 8, 8], + "children": [0] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/analog_lever/handle.json b/src/main/resources/assets/create/models/block/analog_lever/handle.json new file mode 100644 index 000000000..10b6a24b3 --- /dev/null +++ b/src/main/resources/assets/create/models/block/analog_lever/handle.json @@ -0,0 +1,31 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "1": "block/lever", + "particle": "block/lever" + }, + "elements": [ + { + "from": [7, 0, -2], + "to": [9, 2, 8], + "rotation": {"angle": 45, "axis": "x", "origin": [8, 1, 8]}, + "faces": { + "north": {"uv": [7, 6, 9, 8], "rotation": 180, "texture": "#1"}, + "east": {"uv": [7, 6, 9, 16], "rotation": 90, "texture": "#1"}, + "south": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "west": {"uv": [7, 6, 9, 16], "rotation": 270, "texture": "#1"}, + "up": {"uv": [7, 6, 9, 16], "texture": "#1"}, + "down": {"uv": [7, 6, 9, 16], "rotation": 180, "texture": "#1"} + } + } + ], + "groups": [ + { + "name": "lever", + "origin": [8, 8, 8], + "children": [0] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/analog_lever/indicator.json b/src/main/resources/assets/create/models/block/analog_lever/indicator.json new file mode 100644 index 000000000..abc8fd036 --- /dev/null +++ b/src/main/resources/assets/create/models/block/analog_lever/indicator.json @@ -0,0 +1,28 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "4": "create:block/analog_lever", + "particle": "block/lever" + }, + "elements": [ + { + "from": [4.99, 1, 3.99], + "to": [11.01, 2, 12.01], + "faces": { + "north": {"uv": [2, 10, 3, 16], "rotation": 270, "texture": "#4"}, + "east": {"uv": [3, 9, 11.02, 10], "texture": "#4"}, + "south": {"uv": [11, 10, 12, 16], "rotation": 90, "texture": "#4"}, + "west": {"uv": [3, 9, 11.02, 10], "texture": "#4"} + } + } + ], + "groups": [ + { + "name": "lever", + "origin": [8, 8, 8], + "children": [0] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/block/analog_lever/item.json b/src/main/resources/assets/create/models/block/analog_lever/item.json new file mode 100644 index 000000000..01b9ee73e --- /dev/null +++ b/src/main/resources/assets/create/models/block/analog_lever/item.json @@ -0,0 +1,81 @@ +{ + "credit": "Made with Blockbench", + "parent": "block/block", + "ambientocclusion": false, + "textures": { + "1": "block/lever", + "4": "create:block/analog_lever", + "particle": "block/lever" + }, + "elements": [ + { + "from": [5, 0, 4], + "to": [11, 3, 12], + "faces": { + "north": {"uv": [0, 0, 3, 6], "rotation": 270, "texture": "#4"}, + "east": {"uv": [3, 6, 11, 9], "texture": "#4"}, + "south": {"uv": [11, 0, 14, 6], "rotation": 90, "texture": "#4"}, + "west": {"uv": [3, 6, 11, 9], "texture": "#4"}, + "up": {"uv": [3, 0, 11, 6], "rotation": 90, "texture": "#4"}, + "down": {"uv": [3, 10, 11, 16], "rotation": 90, "texture": "#4", "cullface": "down"} + } + }, + { + "from": [7, 0, -2], + "to": [9, 2, 8], + "rotation": {"angle": 45, "axis": "x", "origin": [8, 1, 8]}, + "faces": { + "north": {"uv": [7, 6, 9, 8], "rotation": 180, "texture": "#1"}, + "east": {"uv": [7, 6, 9, 16], "rotation": 90, "texture": "#1"}, + "south": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "west": {"uv": [7, 6, 9, 16], "rotation": 270, "texture": "#1"}, + "up": {"uv": [7, 6, 9, 16], "texture": "#1"}, + "down": {"uv": [7, 6, 9, 16], "rotation": 180, "texture": "#1"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 1.75, 2.25], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 1.75, 2.25], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [74.25, -1.5, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [74.25, -1.5, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.75, 0.75, 0.75] + }, + "head": { + "translation": [0, 14.5, 0] + }, + "fixed": { + "rotation": [-90, 0, 0], + "translation": [0, 0, -6], + "scale": [0.75, 0.75, 0.75] + } + }, + "groups": [ + { + "name": "lever", + "origin": [8, 8, 8], + "children": [0, 1] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/adjustable_pulley.json b/src/main/resources/assets/create/models/item/adjustable_pulley.json new file mode 100644 index 000000000..4ec70826b --- /dev/null +++ b/src/main/resources/assets/create/models/item/adjustable_pulley.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/adjustable_pulley/item" +} \ No newline at end of file diff --git a/src/main/resources/assets/create/models/item/analog_lever.json b/src/main/resources/assets/create/models/item/analog_lever.json new file mode 100644 index 000000000..caddaab55 --- /dev/null +++ b/src/main/resources/assets/create/models/item/analog_lever.json @@ -0,0 +1,3 @@ +{ + "parent": "create:block/analog_lever/item" +} \ No newline at end of file diff --git a/src/main/resources/assets/create/textures/block/adjustable_pulley_off.png b/src/main/resources/assets/create/textures/block/adjustable_pulley_off.png new file mode 100644 index 0000000000000000000000000000000000000000..fc29ec81a917bd5ef5621179005912ff5f008e86 GIT binary patch literal 506 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0gp*UK~y+TZBjc= z!eA7=Ut3xVlnNM;II$2X26Zy=2N*U-H$vjL2nyI2%ngMu{;dFz{ANOX2gh zw`l}C!^yqpzP`s5jgtob2gh;PFijJ7%;NmwGG!WL$JKQW;n{5Nd5)FI`ci5_KH1x<>aT((Ds2aE5%qCjHDGYRy zl7=433(!(YJ(VPMLcj6E`?`A=pn&LyC>?U8RxQ~&CxBJo>2`+x)9ZVAYr~t)-k#fK zAtpj83IZocW-CQ2sop<+zBE7DJy$6dHeL4{jBz*vdiO}=NREiWn84s1ureBTEh`V^ z0M3Iv)L3C9PQ~CHuwodQPNxOt!0Lo-_)eSy)^@i`j=P?>Gq@81!Hwm-8CEifzek4$ zJ4leS6ntDDAh!5@0D2>PNfc+td-0P++9GsKdVV-1#PS4m#al7Q_$!L*+Z#w&z9^Pk w1N)O`RRIoRLD`Pho0l2e3yxiYmDnYsUx(z#Pm=y@fB*mh07*qoM6N<$f?_Aq=l}o! literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/create/textures/block/adjustable_pulley_on.png b/src/main/resources/assets/create/textures/block/adjustable_pulley_on.png new file mode 100644 index 0000000000000000000000000000000000000000..9a05222a8143cd7e09ea6a52067b4720d1ffcd47 GIT binary patch literal 522 zcmV+l0`>igP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!TMroteEix4R>bj*sX+*|yCK%d)TzDb6o0VduSX&X#ogQTS1kc2PoSX7k*>G7Bmj}e^U=ePRBQu&Q2PgEsZ4p`qRWEK*<0gQNdv(fb) zUtaTz^CQRWynOBv4T&}aYD6C^^Hw5y_wfGwR;jfdZEh~-IA0*z;UD0APqakz6c8O) zya&{Jy=E#k3vvPf1MdpaYQV8gAl?INrkQLssvsApJEVd$^Bz!~?yuR-a5j^~ncB5} zx>UwDd~U_mQs!%F0fWl6CVt5t(<|kCS^^VxK?p?upVBS%1z49rRymR=x+x+ zS=Utz^*br9Z*P#o@TppM2J{AMR3R>5KzXgkn}-?G3x*-YnJ^@xA0oTZRLs-2P5=M^ M07*qoM6N<$f{6~>5dZ)H literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/create/textures/block/analog_lever.png b/src/main/resources/assets/create/textures/block/analog_lever.png new file mode 100644 index 0000000000000000000000000000000000000000..dea34971eed105b1bc48696d52278261706525e6 GIT binary patch literal 630 zcmV-+0*U>JP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0t-n*K~y+Tg;UFJ z(?AqGc5EkU)!HFY$3m?Ts+6!uS+OYJzy|RLw7>?bVpoYTK~(*UithkREF!fPN~9)E z;?^;3B0rMh&eUU*EZ|62XC8OXoa?z(4&EQIi?63>zuv>+`WoU?frO#4Yy`318;1D( z?I+gXy~W9w6OpJ{H46h^2-(45>))u_saEYBp18JJV$_`4X+(8Y6)&C*LSR!|zX&Q90{&IgG zx~`+uYQeNDQ35X|NfH>o59|CK)oL|6F3On+2QPMjXAfuCHAC#xd=XZBfm(7Yc-QD+ zdo6&M9h6Y`4HBQ;JZF>Wer%TSSl9~;#lHm( zKOE*0UYdlgS-$-exPT1Tb=hb%Vw|HWTHoSUJuvT6Cq;Jv#uf+Xf~VRJy9x^kfbrnx`Erf zJ8J6+^*}0ef?&0c{u1y!PdJF;1oJtg#wyV&ZBvQ1T^Bk0l2zmawrvXsQ4*t4E`u!= zBtk!vs?*J(_y(O$C(AC73-C=|=hG)UXgIcrdi?>+jSAJiDRLag5nKTH1ND3epbu%5 QzW@LL07*qoM6N<$g59hW5dZ)H literal 0 HcmV?d00001 diff --git a/src/main/resources/data/create/loot_tables/blocks/adjustable_pulley.json b/src/main/resources/data/create/loot_tables/blocks/adjustable_pulley.json new file mode 100644 index 000000000..5fed2b363 --- /dev/null +++ b/src/main/resources/data/create/loot_tables/blocks/adjustable_pulley.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "create:adjustable_pulley" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/loot_tables/blocks/analog_lever.json b/src/main/resources/data/create/loot_tables/blocks/analog_lever.json new file mode 100644 index 000000000..8d0e5288f --- /dev/null +++ b/src/main/resources/data/create/loot_tables/blocks/analog_lever.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "create:analog_lever" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crafting_shaped/contraptions/adjustable_pulley.json b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/adjustable_pulley.json new file mode 100644 index 000000000..225c1bad5 --- /dev/null +++ b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/adjustable_pulley.json @@ -0,0 +1,29 @@ +{ + "type": "crafting_shaped", + "pattern": [ + "A", + "B", + "C" + ], + "key": { + "A": { + "item": "create:electron_tube" + }, + "B": { + "item": "create:encased_belt" + }, + "C": { + "item": "create:large_cogwheel" + } + }, + "result": { + "item": "create:adjustable_pulley", + "count": 1 + }, + "conditions": [ + { + "type": "create:module", + "module": "contraptions" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/create/recipes/crafting_shaped/contraptions/analog_lever.json b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/analog_lever.json new file mode 100644 index 000000000..207e37148 --- /dev/null +++ b/src/main/resources/data/create/recipes/crafting_shaped/contraptions/analog_lever.json @@ -0,0 +1,25 @@ +{ + "type": "crafting_shaped", + "pattern": [ + "A", + "C" + ], + "key": { + "A": { + "tag": "forge:rods/wooden" + }, + "C": { + "item": "create:andesite_casing" + } + }, + "result": { + "item": "create:analog_lever", + "count": 1 + }, + "conditions": [ + { + "type": "create:module", + "module": "contraptions" + } + ] +} \ No newline at end of file