From 8a0ac4e37124722e6a1d862c86448fd1fc2dee88 Mon Sep 17 00:00:00 2001 From: Sascha T Date: Fri, 29 Jul 2022 23:27:21 +0200 Subject: [PATCH] feat:Computerized Redstone Link Push to v1.0.0-pre2. --- blockbench/computerized_redstone_link.bbmodel | 1 + build.gradle | 2 +- .../createcomputing/CreateComputingMod.java | 4 + .../saschat/createcomputing/Registries.java | 55 +++- .../de/saschat/createcomputing/Utils.java | 16 ++ .../blocks/ComputerizedRedstoneLinkBlock.java | 38 +++ .../config/CreateComputingConfigServer.java | 37 +++ .../ComputerizedRedstoneLinkPeripheral.java | 102 ++++++++ .../peripherals/handles/RedstoneHandle.java | 82 ++++++ .../tiles/ComputerizedRedstoneLinkTile.java | 238 ++++++++++++++++++ .../computerized_redstone_link.json | 7 + .../assets/createcomputing/lang/en_gb.json | 1 + .../assets/createcomputing/lang/en_us.json | 1 + .../block/computerized_redstone_link.json | 133 ++++++++++ .../item/computerized_redstone_link.json | 3 + .../resources/createcomputing.mixins.json | 5 +- .../recipes/computerized_redstone_link.json | 28 +++ 17 files changed, 747 insertions(+), 6 deletions(-) create mode 100644 blockbench/computerized_redstone_link.bbmodel create mode 100644 src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java create mode 100644 src/main/java/de/saschat/createcomputing/config/CreateComputingConfigServer.java create mode 100644 src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java create mode 100644 src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java create mode 100644 src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java create mode 100644 src/main/resources/assets/createcomputing/blockstates/computerized_redstone_link.json create mode 100644 src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json create mode 100644 src/main/resources/assets/createcomputing/models/item/computerized_redstone_link.json create mode 100644 src/main/resources/data/createcomputing/recipes/computerized_redstone_link.json diff --git a/blockbench/computerized_redstone_link.bbmodel b/blockbench/computerized_redstone_link.bbmodel new file mode 100644 index 0000000..bafdb9c --- /dev/null +++ b/blockbench/computerized_redstone_link.bbmodel @@ -0,0 +1 @@ +{"meta":{"format_version":"4.0","model_format":"java_block","box_uv":false},"name":"computerized_redstone_link","parent":"","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"resolution":{"width":16,"height":16},"elements":[{"name":"box","rescale":false,"locked":false,"from":[1,0,1],"to":[15,2,15],"autouv":0,"color":4,"origin":[0,0,0],"faces":{"north":{"uv":[0,0,14,2],"texture":1},"east":{"uv":[0,0,14,2],"texture":1},"south":{"uv":[0,0,14,2],"texture":1},"west":{"uv":[0,0,14,2],"texture":1},"up":{"uv":[1,1,15,15],"texture":2},"down":{"uv":[1,1,15,15],"texture":2}},"type":"cube","uuid":"6ab9df4b-2d79-ae67-a995-d407e4b7d2c7"},{"name":"stick","rescale":false,"locked":false,"from":[2,2,2],"to":[3,10,3],"autouv":0,"color":5,"origin":[0,0,0],"faces":{"north":{"uv":[1,2,2,10],"texture":3},"east":{"uv":[1,2,2,10],"texture":3},"south":{"uv":[1,2,2,10],"texture":3},"west":{"uv":[1,2,2,10],"texture":3},"up":{"uv":[2,1,3,2],"texture":3},"down":{"uv":[0,0,1,1]}},"type":"cube","uuid":"d08ca785-2762-01f9-742b-8dee066d3e84"},{"name":"dish","rescale":false,"locked":false,"from":[0,9,0],"to":[5,9,5],"autouv":0,"color":5,"origin":[0,0,0],"faces":{"north":{"uv":[0,0,5,0]},"east":{"uv":[0,0,5,0]},"south":{"uv":[0,0,5,0]},"west":{"uv":[0,0,5,0]},"up":{"uv":[4,0,9,5],"texture":3},"down":{"uv":[4,0,9,5],"texture":3}},"type":"cube","uuid":"4c22dbfc-d5b2-89e8-f050-ee0047022709"},{"name":"stick","rescale":false,"locked":false,"from":[8,2,2],"to":[9,10,3],"autouv":0,"color":5,"origin":[0,0,0],"faces":{"north":{"uv":[1,2,2,10],"texture":3},"east":{"uv":[1,2,2,10],"texture":3},"south":{"uv":[1,2,2,10],"texture":3},"west":{"uv":[1,2,2,10],"texture":3},"up":{"uv":[2,1,3,2],"texture":3},"down":{"uv":[0,0,1,1]}},"type":"cube","uuid":"fc51e6f3-164e-1115-fdb5-73e905ba937c"},{"name":"cube","rescale":false,"locked":false,"from":[2,-1,2],"to":[14,0,14],"autouv":0,"color":7,"origin":[0,0,0],"faces":{"north":{"uv":[0,0,12,1],"texture":4},"east":{"uv":[0,0,12,1],"texture":4},"south":{"uv":[0,0,12,1],"texture":4},"west":{"uv":[0,0,12,1],"texture":4},"up":{"uv":[0,0,12,12]},"down":{"uv":[0,0,10,10],"texture":4}},"type":"cube","uuid":"c54fec1f-a187-289c-d9ed-f15e8c0cd0a8"}],"outliner":[{"name":"antenna 1","origin":[0,0,0],"color":0,"nbt":"{}","armAnimationEnabled":false,"uuid":"388bde65-fb8b-a828-9d4c-843c267ea8da","export":true,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["fc51e6f3-164e-1115-fdb5-73e905ba937c","c54fec1f-a187-289c-d9ed-f15e8c0cd0a8"]},{"name":"antenna 1","origin":[0,0,0],"color":0,"nbt":"{}","armAnimationEnabled":false,"uuid":"8466190f-aa1e-0ffe-a0a8-ffe184a60eae","export":true,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["d08ca785-2762-01f9-742b-8dee066d3e84","4c22dbfc-d5b2-89e8-f050-ee0047022709"]},{"name":"VoxelShapes","origin":[0,0,0],"color":0,"nbt":"{}","armAnimationEnabled":false,"uuid":"45700195-9ab4-e25e-ca62-33988cc74b7d","export":true,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["6ab9df4b-2d79-ae67-a995-d407e4b7d2c7"]}],"textures":[{"path":"C:\\Users\\sasch\\Downloads\\Create-mc1.18-dev\\src\\main\\resources\\assets\\create\\textures\\block\\brass_casing_inner.png","name":"brass_casing_inner.png","folder":"block","namespace":"create","id":"0","particle":true,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"5ee7dca0-8235-14e5-d9e7-f667bf2f9d55","relative_path":"../../../../Users/sasch/Downloads/Create-mc1.18-dev/src/main/resources/assets/create/textures/block/brass_casing_inner.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAT9JREFUOE91Uz1PwzAQPTchkVKpCKQCP6BDJSSQGBmYWDrx/39DJ4oaKaldo3fJs+wL3BKfe7bfV93h9THKXP0QpGsr7b7Po9yuG/4kF3/V9U290jW+KPexv9cLTr2Xrqmkrp14H6Ufg2y6WofQY5/FHl9HBHixa6cDLL5SbJrGHV4eYlOt5Pgz6AU41FRORn+VS4hFj7kJt8gYos79iWDdVjqAInfy517S4H13p5PkjjX4Q48krunzWff19pRcwAFC4+HzEKQfvGw3bcF+QcEKldtGgQm7sPHzeZsQWI/JFwhyh/I5FRFq2gL0pMF8AcS15SgihWNgEBKKy5DlAnNuISJfoI3WStDJIz7lIEYNTe61NvM+cwHxqAfppCDl3KwmQENXeMEiSFYcG6b/QlW4QOUB73ia/huEagPGC38BXLrHrPBkj80AAAAASUVORK5CYII="},{"path":"C:\\Users\\sasch\\Downloads\\Create-mc1.18-dev\\src\\main\\resources\\assets\\create\\textures\\block\\brass_casing_side.png","name":"brass_casing_side.png","folder":"block","namespace":"create","id":"1","particle":false,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"82c1f331-ef7e-60bc-0d92-b5b64210cd0a","relative_path":"../../../../Users/sasch/Downloads/Create-mc1.18-dev/src/main/resources/assets/create/textures/block/brass_casing_side.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAWZJREFUOE+dUsFKw0AQnUnTtEnFWqFYCt7soRQRBEE89OBNEDzofwie/AC/wA/xu4QKtZU2zSbtypsw6Sa0HpzL7s57OzvvzfLr07mNKCVEI/RlrUYSZzvxaczEH29jC3QwOhXS7PO7uN/uHZXOq2X+EGIer2Tl20HLphuiukfkB15ByMyGkEeEzW1eCcC/fgzxw2VPOjBrWSSCGpdUAFuYlFpBvcCmsck7uLs4se4FACAicKkabpHJPCG+OevYpVkLLwpqsuLs7pMs19LwParuRQK0T2Yr6rabpQerOehWqeiuEwZlCa5WELLUkl/nQtIub3g8PBb3VJtr5mxhqHvYKLpyX9ckD/sHUgD61Ad4oFqVqHiVU3gAwNUYhbmh+wJcTEwKoLV9s9cCkKh/QccLj/jxum+r7rqv6p/QnF7GBKQD14Nds1d/gOl/cf3h9+er7R/+U3UZXC6YopYlfrkf/auAlvsFFk/Rq3UFaSMAAAAASUVORK5CYII="},{"path":"C:\\Users\\sasch\\Downloads\\Create-mc1.18-dev\\src\\main\\resources\\assets\\create\\textures\\block\\brass_casing.png","name":"brass_casing.png","folder":"block","namespace":"create","id":"2","particle":false,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"7b89993d-b0bf-324e-b069-b035682425fc","relative_path":"../../../../Users/sasch/Downloads/Create-mc1.18-dev/src/main/resources/assets/create/textures/block/brass_casing.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAZFJREFUOE+VUr9Lw0AUfpekKW2wVlARHEQLWqhCwX9DF+0gDuLi4CoOzp0d3ARdXAQX/5eCFapDdZR2MK0maX715F14ySUGwW95ebl3333fd8cuWlu8DD4giiVN1CxcJ8hd/3QYsHarzlfrVWhu18TQ6MOM988uVVP9xI4OQoydCXQ7g4hgs7kI7ZuOWCjrqqhagUHgc1GzwP/nx1u/CVbmy+CFHHSVgRdMwQ85FDQl7nVVEVzDLxdODzbgrWcCwwwadQOuH15goVJMCEIuhv1gGgtAMoTl+XCyvw7PPSshuH18FZIRthfGVvJ6/He0V4P3vptkcHn3lFJAx5IlOYfh2BUEg/53QnB13wVDL8RzJB1ly99k4XB3LSKgDNACEuAwec2mT0S2GyQWZIK5kh7vsdwQjGJ0pQjZClkQGci3QPePlQKldyAHXDE0QAupEDEDWQGeSMB3gYrI2sjy8kPUFTXtn3PxmBBiM+egawrkWsAQCSQ3G6Lcp95BdXnmr9ncNdtiYJoOsLOdRmL23zQAP2aU7p+Dky3/AAAAAElFTkSuQmCC"},{"path":"C:\\Users\\sasch\\Downloads\\Create-mc1.18-dev\\src\\main\\resources\\assets\\create\\textures\\block\\redstone_antenna_powered.png","name":"redstone_antenna_powered.png","folder":"block","namespace":"create","id":"3","particle":false,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"1ecdeba7-eef3-c37d-78bd-aadd28c24765","relative_path":"../../../../Users/sasch/Downloads/Create-mc1.18-dev/src/main/resources/assets/create/textures/block/redstone_antenna_powered.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAARxJREFUOE9jZGBgYPjLwPCfmYGBEcQGgYcPH/7/8uULmK2trQ0Xr62t/d/c3Azng+QZQZr/r4hnYIxYyAAyBKT574d3DF9uX2P4IyrFwC4iBjYEpLm+vp6hsbGRAdkQsGnrGRj+B0JdcO3ixf9f7t9i4Hz7kuE/vyDDJwl5BhsbG7C6pKSk//PmzUN1AUgiN9zs/+SVp8ASV69e/f/zzSuGP+/fMLAIijB8Y2aFG4CsDuZdsCYnU6X/+07fg5sMMuTjmzcM/5iZ4ZqxqQOHAYgIddX7v3r3JRSnwWxAprGpo44Btgay/w9feEzQBdjUgTVZ60n/P3rpKUEDsKkDazLXEv9/8tpLggZgU0dQE7bARBYbNQApCxMKLFzyAAsqgBGiwxhuAAAAAElFTkSuQmCC"},{"path":"C:\\Users\\sasch\\Downloads\\Create-mc1.18-dev\\src\\main\\resources\\assets\\create\\textures\\block\\filtered_detector_front.png","name":"filtered_detector_front.png","folder":"block","namespace":"create","id":"4","particle":false,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"7e722d7e-ec58-46ac-43f0-f6b09c2de9d0","relative_path":"../../../../Users/sasch/Downloads/Create-mc1.18-dev/src/main/resources/assets/create/textures/block/filtered_detector_front.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAR9JREFUOE/tUrGKg0AQfaazEwRbQbC2EGs7sRJsQ/BH0t5fXCchOYSDu07srMVCSCcItoIgpLD0mOHWxJxHSJ9pdnZ25u2beSMlSTIBgKIodEBVVfR9zycZ+ffmeZ4kYhIBBEHA93EcF7nDMDBwURQcdxyH/QVAlmUTPcRxDE3TIMvyDNK2LaIoQtM0HDMMg33btq8MyrKc6CFNU3xvt3PxBcDueITv+/wrtUR5qwxM00RVVfgIQ1AhWbuZ8Pb5BcuyUNc1xyiP/EULgkGe53gPwyv9XwDXdZk2DZNafdjCecOisO0Pp8ctCAY0RF3X52JSpOs6kEJEW8zgXwZUKWS71/1WxlUAsThrS/Nni4DlENcSnonNC/FM0W3uCwD4AQtbnxFea/9LAAAAAElFTkSuQmCC"}],"display":{"thirdperson_righthand":{"rotation":[75,45,0],"translation":[0,2.5,0],"scale":[0.375,0.375,0.375]},"thirdperson_lefthand":{"rotation":[75,45,0],"translation":[0,2.5,0],"scale":[0.375,0.375,0.375]},"firstperson_righthand":{"rotation":[0,45,0],"scale":[0.4,0.4,0.4]},"firstperson_lefthand":{"rotation":[0,225,0],"scale":[0.4,0.4,0.4]},"ground":{"translation":[0,3,0],"scale":[0.25,0.25,0.25]},"gui":{"rotation":[30,225,0],"scale":[0.625,0.625,0.625]},"fixed":{"scale":[0.5,0.5,0.5]}}} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4a6054c..ac60d3b 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ plugins { apply plugin: 'org.spongepowered.mixin' group = 'de.saschat' -version = '1.0.0-pre1' +version = '1.0.0-pre2' java { archivesBaseName = 'createcomputing' diff --git a/src/main/java/de/saschat/createcomputing/CreateComputingMod.java b/src/main/java/de/saschat/createcomputing/CreateComputingMod.java index 10d6776..0a7afa4 100644 --- a/src/main/java/de/saschat/createcomputing/CreateComputingMod.java +++ b/src/main/java/de/saschat/createcomputing/CreateComputingMod.java @@ -1,8 +1,11 @@ package de.saschat.createcomputing; import com.mojang.logging.LogUtils; +import de.saschat.createcomputing.config.CreateComputingConfigServer; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; @@ -13,6 +16,7 @@ public class CreateComputingMod { public static final Logger LOGGER = LogUtils.getLogger(); public CreateComputingMod() { + ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CreateComputingConfigServer.pair.getRight()); Registries.init(FMLJavaModLoadingContext.get().getModEventBus()); MinecraftForge.EVENT_BUS.register(this); } diff --git a/src/main/java/de/saschat/createcomputing/Registries.java b/src/main/java/de/saschat/createcomputing/Registries.java index d1b6a69..e246a34 100644 --- a/src/main/java/de/saschat/createcomputing/Registries.java +++ b/src/main/java/de/saschat/createcomputing/Registries.java @@ -1,16 +1,23 @@ package de.saschat.createcomputing; +import com.simibubi.create.Create; +import com.simibubi.create.content.logistics.IRedstoneLinkable; +import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBlockItem; +import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.repack.registrate.util.nullness.NonNullBiFunction; import de.saschat.createcomputing.blocks.ComputerizedDisplaySourceBlock; import de.saschat.createcomputing.blocks.ComputerizedDisplayTargetBlock; +import de.saschat.createcomputing.blocks.ComputerizedRedstoneLinkBlock; import de.saschat.createcomputing.blocks.TrainNetworkObserverBlock; import de.saschat.createcomputing.tiles.ComputerizedDisplaySourceTile; import de.saschat.createcomputing.tiles.ComputerizedDisplayTargetTile; +import de.saschat.createcomputing.tiles.ComputerizedRedstoneLinkTile; import de.saschat.createcomputing.tiles.TrainNetworkObserverTile; import de.saschat.createcomputing.tiles.renderer.TrainNetworkObserverRenderer; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; +import net.minecraft.commands.Commands; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; @@ -19,6 +26,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.client.event.EntityRenderersEvent; +import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -30,6 +38,8 @@ import net.minecraftforge.registries.RegistryObject; import java.util.Arrays; +import java.util.Map; +import java.util.Set; import java.util.function.Supplier; public class Registries { @@ -103,6 +113,22 @@ public ItemStack makeIcon() { COMPUTERIZED_DISPLAY_TARGET ); + // Computerized Redstone Link + public static RegistryObject COMPUTERIZED_REDSTONE_LINK = registerBlock( + "computerized_redstone_link", + ComputerizedRedstoneLinkBlock::new + ); + public static RegistryObject COMPUTERIZED_REDSTONE_LINK_ITEM = registerBlockItem( + "computerized_redstone_link", + COMPUTERIZED_REDSTONE_LINK, + new Item.Properties().tab(TAB) + ); + public static RegistryObject> COMPUTERIZED_REDSTONE_LINK_TILE = registerTile( + "computerized_redstone_link", + ComputerizedRedstoneLinkTile::new, + COMPUTERIZED_REDSTONE_LINK + ); + // Train Network Observer public static RegistryObject TRAIN_NETWORK_OBSERVER = registerBlock( "train_network_observer", @@ -125,21 +151,46 @@ public ItemStack makeIcon() { public static class RegistryEvents { @SubscribeEvent public static void fmlCommon(final FMLCommonSetupEvent blockRegistryEvent) { - // Register a new block here CreateComputingMod.LOGGER.info("Registering all Create behaviours."); Behaviours.register(); CreateComputingMod.LOGGER.info("Registered all Create behaviour."); } + @SubscribeEvent public static void fmlClient(final FMLClientSetupEvent blockRegistryEvent) { ItemBlockRenderTypes.setRenderLayer(COMPUTERIZED_DISPLAY_TARGET.get(), RenderType.cutout()); + ItemBlockRenderTypes.setRenderLayer(COMPUTERIZED_REDSTONE_LINK.get(), RenderType.cutout()); } + @SubscribeEvent public static void modRenderer(final EntityRenderersEvent.RegisterRenderers event) { event.registerBlockEntityRenderer(TRAIN_NETWORK_OBSERVER_TILE.get(), TrainNetworkObserverRenderer::new); } - public static void modData(final GatherDataEvent event) {} + public static void modData(final GatherDataEvent event) { + } } + @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) + public static class ForgeEvents { + @SubscribeEvent + public static void modCommands(final RegisterCommandsEvent event) { + System.out.println("REGISTER COMMANDS"); + event.getDispatcher().register( + Commands.literal("redstone_link").executes(context -> { + Map, Set> coupleSetMap = Create.REDSTONE_LINK_NETWORK_HANDLER.networksIn(context.getSource().getLevel()); + coupleSetMap.forEach((frequencies, iRedstoneLinkables) -> { + System.out.println("Frequency: " + frequencies.get(true).getStack().getItem().getRegistryName().toString() + ", " + frequencies.get(false).getStack().getItem().getRegistryName().toString()); + for (IRedstoneLinkable iRedstoneLinkable : iRedstoneLinkables) { + System.out.println("\tAt " + iRedstoneLinkable.getLocation().toString() + ", listening: " + iRedstoneLinkable.isListening() + ", alive: " + iRedstoneLinkable.isAlive() + ", strength: " + iRedstoneLinkable.getTransmittedStrength()); + } + }); + return 0; + }) + ); + } + + + } + // Real loading diff --git a/src/main/java/de/saschat/createcomputing/Utils.java b/src/main/java/de/saschat/createcomputing/Utils.java index d4c90ea..d4444c0 100644 --- a/src/main/java/de/saschat/createcomputing/Utils.java +++ b/src/main/java/de/saschat/createcomputing/Utils.java @@ -2,13 +2,29 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.registries.ForgeRegistries; import java.util.HashMap; import java.util.Map; public class Utils { + public static Item getByName(ResourceLocation loc) { + var itemRegistryObject = ForgeRegistries.ITEMS.getEntries().stream().filter(a -> { + return a.getValue().getRegistryName().equals(loc); + }).findFirst().orElseGet(() -> null); + if (itemRegistryObject == null) + return Items.AIR; + return itemRegistryObject.getValue(); + } + + public interface Receiver { + void receive(T a); + } public static VoxelShape rotate(Direction from, Direction to, VoxelShape shape) { VoxelShape[] buffer = new VoxelShape[]{ shape, Shapes.empty() }; diff --git a/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java new file mode 100644 index 0000000..709fddb --- /dev/null +++ b/src/main/java/de/saschat/createcomputing/blocks/ComputerizedRedstoneLinkBlock.java @@ -0,0 +1,38 @@ +package de.saschat.createcomputing.blocks; + +import com.simibubi.create.foundation.block.ITE; +import de.saschat.createcomputing.Registries; +import de.saschat.createcomputing.tiles.ComputerizedRedstoneLinkTile; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class ComputerizedRedstoneLinkBlock extends Block implements ITE { + public ComputerizedRedstoneLinkBlock() { + super(BlockBehaviour.Properties.of(Material.WOOD)); + } + + @Override + public Class getTileEntityClass() { + return ComputerizedRedstoneLinkTile.class; + } + + @Override + public BlockEntityType getTileEntityType() { + return Registries.COMPUTERIZED_REDSTONE_LINK_TILE.get(); + } + + + @Override + public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) { + return box( + 1,0,1,15,2,15 + ); + } +} diff --git a/src/main/java/de/saschat/createcomputing/config/CreateComputingConfigServer.java b/src/main/java/de/saschat/createcomputing/config/CreateComputingConfigServer.java new file mode 100644 index 0000000..ed6f898 --- /dev/null +++ b/src/main/java/de/saschat/createcomputing/config/CreateComputingConfigServer.java @@ -0,0 +1,37 @@ +package de.saschat.createcomputing.config; + +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.*; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.List; + +public class CreateComputingConfigServer { + public ConfigValue> BANNED_LINK_ITEMS; + public LongValue MAXIMUM_CONCURRENT_LINKS; + + public CreateComputingConfigServer(ForgeConfigSpec.Builder builder) { + BANNED_LINK_ITEMS = builder.comment("These are the items the computerized redstone link cannot use.").define( + "computerized_redstone_link.banned_link_items", + List.of( + new ResourceLocation("minecraft", "dragon_egg").toString(), + new ResourceLocation("minecraft", "nether_star").toString() + ) + ); + MAXIMUM_CONCURRENT_LINKS = builder.comment("This is the maximum amount of concurrent handles one computerized redstone link is allowed ot have.").defineInRange( + "computerized_redstone_link.maximum_concurrent_links", + 8, + 1, + Long.MAX_VALUE + ); + + } + + public static Pair pair = new ForgeConfigSpec.Builder() + .configure(CreateComputingConfigServer::new); + + public static CreateComputingConfigServer get() { + return pair.getLeft(); + } +} diff --git a/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java new file mode 100644 index 0000000..d1df71a --- /dev/null +++ b/src/main/java/de/saschat/createcomputing/peripherals/ComputerizedRedstoneLinkPeripheral.java @@ -0,0 +1,102 @@ +package de.saschat.createcomputing.peripherals; + +import dan200.computercraft.api.lua.LuaException; +import dan200.computercraft.api.lua.MethodResult; +import dan200.computercraft.api.peripheral.IPeripheral; +import de.saschat.createcomputing.CreateComputingMod; +import de.saschat.createcomputing.Utils; +import de.saschat.createcomputing.api.SmartPeripheral; +import de.saschat.createcomputing.config.CreateComputingConfigServer; +import de.saschat.createcomputing.peripherals.handles.RedstoneHandle; +import de.saschat.createcomputing.tiles.ComputerizedRedstoneLinkTile; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class ComputerizedRedstoneLinkPeripheral extends SmartPeripheral { + public ComputerizedRedstoneLinkTile parent; + public HashMap handles = new HashMap<>(); + + public void removeHandle(UUID hd) { + handles.values().forEach(a -> { + if (a.handle.equals(hd)) { + a.close(); + handles.remove(hd, a); + } + }); + } + + public void killHandles(UUID hd) { + handles.values().forEach(a -> { + if (a.handle.equals(hd)) { + a.close(); + handles.remove(a.handle, a); + } + }); + } + + public ComputerizedRedstoneLinkPeripheral(ComputerizedRedstoneLinkTile tile) { + this.parent = tile; + + addMethod("clearHandles", (iComputerAccess, iLuaContext, iArguments) -> { + parent.tasks.add(() -> { + handles.clear(); + parent.pairs.forEach((b,a) -> { + parent.remove(a); + }); + }); + return MethodResult.of(); + }); + addMethod("getMaxHandles", (iComputerAccess, iLuaContext, iArguments) -> { + return MethodResult.of(CreateComputingConfigServer.get().MAXIMUM_CONCURRENT_LINKS.get()); + }); + addMethod("closeHandle", (iComputerAccess, iLuaContext, iArguments) -> { + return MethodResult.of(); + }); + addMethod("getHandles", (iComputerAccess, iLuaContext, iArguments) -> { + Map hdl = new HashMap<>(); + for (Map.Entry uuidRedstoneHandleEntry : handles.entrySet()) { + hdl.put(uuidRedstoneHandleEntry.getKey().toString(), uuidRedstoneHandleEntry.getValue()); + } + return MethodResult.of(hdl); + }); + addMethod("openHandle", (iComputerAccess, iLuaContext, iArguments) -> { + String _item1 = iArguments.getString(0); + String _item2 = iArguments.getString(1); + Item item1 = Utils.getByName(new ResourceLocation(_item1)); + Item item2 = Utils.getByName(new ResourceLocation(_item2)); + if (item1 == null) + throw new LuaException(_item1 + " is not a valid item id!"); + if (item2 == null) + throw new LuaException(_item2 + " is not a valid item id!"); + if (!ComputerizedRedstoneLinkTile.checkItem(item1)) + throw new LuaException(_item1 + " is banned from the Computerized Redstone Link! This can be changed in the config."); + if (!ComputerizedRedstoneLinkTile.checkItem(item2)) + throw new LuaException(_item2 + " is banned from the Computerized Redstone Link! This can be changed in the config."); + ComputerizedRedstoneLinkTile.LinkPair pair = new ComputerizedRedstoneLinkTile.LinkPair(parent, new Item[]{item1, item2}); + pair.setFrequency(pair.items); + UUID data = parent.add(pair); + if(data == null) + throw new LuaException("You have exceeded the maximum amount of frequencies for this peripheral. The maximum can be changed in the config."); + RedstoneHandle redstoneHandle = new RedstoneHandle(this, data); + handles.put(redstoneHandle.handle, redstoneHandle); + return MethodResult.of(redstoneHandle); + }); + } + + @NotNull + @Override + public String getType() { + return new ResourceLocation(CreateComputingMod.MOD_ID, "computerized_redstone_link").toString(); + } + + @Override + public boolean equals(@Nullable IPeripheral iPeripheral) { + return false; + } +} diff --git a/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java b/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java new file mode 100644 index 0000000..8b40641 --- /dev/null +++ b/src/main/java/de/saschat/createcomputing/peripherals/handles/RedstoneHandle.java @@ -0,0 +1,82 @@ +package de.saschat.createcomputing.peripherals.handles; + +import dan200.computercraft.api.lua.IArguments; +import dan200.computercraft.api.lua.LuaException; +import dan200.computercraft.api.lua.LuaFunction; +import de.saschat.createcomputing.peripherals.ComputerizedRedstoneLinkPeripheral; +import de.saschat.createcomputing.tiles.ComputerizedRedstoneLinkTile; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; + +import java.util.Arrays; +import java.util.UUID; +import java.util.stream.Collectors; + +import static de.saschat.createcomputing.Utils.getByName; + +public class RedstoneHandle { + public ComputerizedRedstoneLinkPeripheral parent; + public UUID handle; + public boolean open = true; + public RedstoneHandle(ComputerizedRedstoneLinkPeripheral parent, UUID pair) { + this.handle = pair; + this.parent = parent; + } + + public void isOpen() throws LuaException { + if(!open) + throw new LuaException("This handle has already been closed."); + } + + + public ComputerizedRedstoneLinkTile.LinkPair getHandle() throws LuaException { + isOpen(); + ComputerizedRedstoneLinkTile.LinkPair linkPair = parent.parent.pairs.get(handle); + if(linkPair == null) + throw new LuaException("Pair has already been deleted."); + return linkPair; + } + + @LuaFunction(mainThread = true) + public final void setSignal(IArguments arguments) throws LuaException { + isOpen(); + int value = arguments.getInt(0); + System.out.println("sx: " + value); + getHandle().provideSignal(value); + } + @LuaFunction(mainThread = true) + public final int getSignal(IArguments arguments) throws LuaException { + isOpen(); + return getHandle().retrieveSignal(); + } + @LuaFunction + public final String getId() throws LuaException { + return this.handle.toString(); + } + @LuaFunction(mainThread = true) + public final void setItems(IArguments arguments) throws LuaException { + isOpen(); + String _item1 = arguments.getString(0); + String _item2 = arguments.getString(1); + Item item1 = getByName(new ResourceLocation(_item1)); + Item item2 = getByName(new ResourceLocation(_item2)); + if (item1 == null) + throw new LuaException(_item1 + " is not a valid item id!"); + if (item2 == null) + throw new LuaException(_item2 + " is not a valid item id!"); + if (!ComputerizedRedstoneLinkTile.checkItem(item1)) + throw new LuaException(_item1 + " is banned from the Computerized Redstone Link! This can be changed in the config."); + if (!ComputerizedRedstoneLinkTile.checkItem(item2)) + throw new LuaException(_item2 + " is banned from the Computerized Redstone Link! This can be changed in the config."); + getHandle().setFrequency(new Item[] {item1, item2}); + } + @LuaFunction(mainThread = true) + public final String[] getItems(IArguments arguments) throws LuaException { + return Arrays.stream(getHandle().items).map(a -> a.getRegistryName().toString()).collect(Collectors.toList()).toArray(new String[0]); + } + @LuaFunction + public final void close() { + this.open = false; + parent.removeHandle(handle); + } +} diff --git a/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java new file mode 100644 index 0000000..3e0ee02 --- /dev/null +++ b/src/main/java/de/saschat/createcomputing/tiles/ComputerizedRedstoneLinkTile.java @@ -0,0 +1,238 @@ +package de.saschat.createcomputing.tiles; + +import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkFrequencySlot; +import com.simibubi.create.foundation.tileEntity.SmartTileEntity; +import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; +import com.simibubi.create.foundation.tileEntity.behaviour.linked.LinkBehaviour; +import dan200.computercraft.shared.Capabilities; +import de.saschat.createcomputing.Registries; +import de.saschat.createcomputing.Utils; +import de.saschat.createcomputing.config.CreateComputingConfigServer; +import de.saschat.createcomputing.peripherals.ComputerizedRedstoneLinkPeripheral; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ConcurrentHashMap; + +public class ComputerizedRedstoneLinkTile extends SmartTileEntity { + public ConcurrentHashMap pairs = new ConcurrentHashMap<>(); + public List deferred = new LinkedList<>(); + public Queue tasks = new ArrayBlockingQueue<>(32); + + public LazyOptional PERIPHERAL = LazyOptional.of( + () -> new ComputerizedRedstoneLinkPeripheral(this) + ); + + public ComputerizedRedstoneLinkTile(BlockPos p_155229_, BlockState p_155230_) { + super(Registries.COMPUTERIZED_REDSTONE_LINK_TILE.get(), p_155229_, p_155230_); + } + + + int i = 0; + + @Override + public void tick() { + super.tick(); + if (!getLevel().isClientSide()) { + Runnable a; + while ((a = tasks.poll()) != null) { + a.run(); + } + } + pairs.values().forEach(linkPair -> linkPair.transmit.tick()); + pairs.values().forEach(linkPair -> linkPair.receive.tick()); + } + + public UUID add(LinkPair pair) { + if (pairs.size() >= CreateComputingConfigServer.get().MAXIMUM_CONCURRENT_LINKS.get()) + return null; + UUID uuid = UUID.randomUUID(); + pair.index = uuid; + tasks.add(() -> { + pair.transmit.initialize(); + pair.receive.initialize(); + }); + pairs.put(uuid, pair); + return uuid; + } + + public void addDeferred(LinkPair pair) { + deferred.add(pair); + } + + public void remove(LinkPair pair) { + if (PERIPHERAL.isPresent()) + PERIPHERAL.resolve().get().killHandles(pair.index); + pairs.remove(pair.index, pair); + pair.sendSignal = 0; + pair.transmit.notifySignalChange(); + pair.transmit.remove(); + pair.receive.remove(); + } + + + /* + @Override + protected void write(CompoundTag tag, boolean clientPacket) { + super.write(tag, clientPacket); + System.out.println("WRITING... " + clientPacket); + ListTag behaviours = new ListTag(); + for (LinkPair value : pairs.values()) { + behaviours.add(value.toTag()); + } + tag.put("transceivers", behaviours); + System.out.println(Utils.blowNBT(tag)); + } + + @Override + protected void read(CompoundTag tag, boolean clientPacket) { + super.read(tag, clientPacket); + System.out.println("READING... " + clientPacket); + System.out.println(Utils.blowNBT(tag)); + ListTag transceivers = tag.getList("transceivers", Tag.TAG_COMPOUND); + for (Tag transceiver : transceivers) { + LinkPair behaviour = LinkPair.fromTag(this, (CompoundTag) transceiver); + addDeferred(behaviour); + PERIPHERAL.resolve().get().handles.put(behaviour.index, new RedstoneHandle( + PERIPHERAL.resolve().get(), + behaviour.index + )); + } + + } + */ + @Override + public void addBehavioursDeferred(List behaviours) { + super.addBehavioursDeferred(behaviours); + for (LinkPair linkPair : deferred) { + pairs.put(linkPair.index, linkPair); + linkPair.registered = true; + linkPair.setFrequency(linkPair.items); + } + } + + public static boolean checkItem(Item stack) { + for (String loc : CreateComputingConfigServer.get().BANNED_LINK_ITEMS.get()) { + if (loc.equals(stack.getRegistryName().toString())) + return false; + } + return true; + } + + @Override + public void addBehaviours(List list) { + } + + private static boolean firstRun = true; + + @NotNull + @Override + public LazyOptional getCapability(@NotNull Capability cap, @Nullable Direction side) { + if (side == Direction.DOWN && cap == Capabilities.CAPABILITY_PERIPHERAL) { + return PERIPHERAL.cast(); + } + return super.getCapability(cap, side); + } + + public static class LinkPair { + private final LinkBehaviour transmit; + private final LinkBehaviour receive; + public UUID index; + + public boolean registered = false; + + public int sendSignal = 0; + public int recvSignal = 0; + ComputerizedRedstoneLinkTile parent; + + public Item[] items; + + public List> listeners = new ArrayList<>(); + + public LinkPair(ComputerizedRedstoneLinkTile parent, Item[] items) { + this.parent = parent; + Pair slots = + ValueBoxTransform.Dual.makeSlots(RedstoneLinkFrequencySlot::new); + transmit = LinkBehaviour.transmitter(parent, slots, this::getSignal); + receive = LinkBehaviour.receiver(parent, slots, this::setSignal); + this.items = items; + parent.setChanged(); + } + + /*public CompoundTag toTag() { + CompoundTag us = new CompoundTag(); + us.putUUID("index", index); + us.putByte("send", (byte) sendSignal); + us.putByte("receive", (byte) recvSignal); + us.putString("frequency.0", items[0].getRegistryName().toString()); + us.putString("frequency.1", items[1].getRegistryName().toString()); + return us; + }*/ + + public static LinkPair fromTag(ComputerizedRedstoneLinkTile parent, CompoundTag tag) { + Item[] items = new Item[]{ + Utils.getByName(new ResourceLocation(tag.getString("frequency.0"))), + Utils.getByName(new ResourceLocation(tag.getString("frequency.1"))), + }; + LinkPair pair = new LinkPair(parent, items); + pair.index = tag.getUUID("index"); + pair.setSignal(tag.getByte("send")); + pair.recvSignal = tag.getByte("receive"); + return pair; + } + + public void setFrequency(Item[] items) { + parent.tasks.add(() -> { + transmit.setFrequency(true, new ItemStack(items[0])); + transmit.setFrequency(false, new ItemStack(items[1])); + receive.setFrequency(true, new ItemStack(items[0])); + receive.setFrequency(false, new ItemStack(items[1])); + this.items = items; + }); + dirty(); + } + + public void provideSignal(int strength) { + sendSignal = strength; + dirty(); + } + + public int retrieveSignal() { + return recvSignal; + } + + private void dirty() { + if (parent.getLevel().isClientSide()) + return; + parent.tasks.add(this::_dirty); + parent.setChanged(); + } + + private void _dirty() { + transmit.notifySignalChange(); + receive.notifySignalChange(); + } + + private void setSignal(int i) { + recvSignal = i; + listeners.forEach(a -> a.receive(i)); + } + + private int getSignal() { + return sendSignal; + } + } +} diff --git a/src/main/resources/assets/createcomputing/blockstates/computerized_redstone_link.json b/src/main/resources/assets/createcomputing/blockstates/computerized_redstone_link.json new file mode 100644 index 0000000..a5f1b74 --- /dev/null +++ b/src/main/resources/assets/createcomputing/blockstates/computerized_redstone_link.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "createcomputing:block/computerized_redstone_link" + } + } +} diff --git a/src/main/resources/assets/createcomputing/lang/en_gb.json b/src/main/resources/assets/createcomputing/lang/en_gb.json index b24708c..aa5a194 100644 --- a/src/main/resources/assets/createcomputing/lang/en_gb.json +++ b/src/main/resources/assets/createcomputing/lang/en_gb.json @@ -3,5 +3,6 @@ "createcomputing.display_source.computerized_display_source": "Computer Text", "block.createcomputing.computerized_display_source": "Computerized Display Source", "block.createcomputing.computerized_display_target": "Computerized Display Target", + "block.createcomputing.computerized_redstone_link": "Computerized Redstone Link", "block.createcomputing.train_network_observer": "Train Network Observer" } diff --git a/src/main/resources/assets/createcomputing/lang/en_us.json b/src/main/resources/assets/createcomputing/lang/en_us.json index 516d588..804d5ca 100644 --- a/src/main/resources/assets/createcomputing/lang/en_us.json +++ b/src/main/resources/assets/createcomputing/lang/en_us.json @@ -3,5 +3,6 @@ "createcomputing.display_source.computerized_display_source": "Computer Text", "block.createcomputing.computerized_display_source": "Computerised Display Source", "block.createcomputing.computerized_display_target": "Computerised Display Target", + "block.createcomputing.computerized_redstone_link": "Computerised Redstone Link", "block.createcomputing.train_network_observer": "Train Network Observer" } diff --git a/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json b/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json new file mode 100644 index 0000000..7b537eb --- /dev/null +++ b/src/main/resources/assets/createcomputing/models/block/computerized_redstone_link.json @@ -0,0 +1,133 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "1": "create:block/brass_casing_side", + "2": "create:block/brass_casing", + "3": "create:block/redstone_antenna_powered", + "4": "create:block/filtered_detector_front", + "particle": "create:block/brass_casing_inner" + }, + "elements": [ + { + "name": "stick", + "from": [8, 2, 2], + "to": [9, 10, 3], + "faces": { + "north": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "east": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "south": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "west": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "up": {"uv": [2, 1, 3, 2], "texture": "#3"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} + } + }, + { + "from": [2, -1, 2], + "to": [14, 0, 14], + "faces": { + "north": {"uv": [0, 0, 12, 1], "texture": "#4"}, + "east": {"uv": [0, 0, 12, 1], "texture": "#4"}, + "south": {"uv": [0, 0, 12, 1], "texture": "#4"}, + "west": {"uv": [0, 0, 12, 1], "texture": "#4"}, + "up": {"uv": [0, 0, 12, 12], "texture": "#missing"}, + "down": {"uv": [0, 0, 10, 10], "texture": "#4"} + } + }, + { + "name": "stick", + "from": [2, 2, 2], + "to": [3, 10, 3], + "faces": { + "north": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "east": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "south": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "west": {"uv": [1, 2, 2, 10], "texture": "#3"}, + "up": {"uv": [2, 1, 3, 2], "texture": "#3"}, + "down": {"uv": [0, 0, 1, 1], "texture": "#missing"} + } + }, + { + "name": "dish", + "from": [0, 9, 0], + "to": [5, 9, 5], + "faces": { + "north": {"uv": [0, 0, 5, 0], "texture": "#missing"}, + "east": {"uv": [0, 0, 5, 0], "texture": "#missing"}, + "south": {"uv": [0, 0, 5, 0], "texture": "#missing"}, + "west": {"uv": [0, 0, 5, 0], "texture": "#missing"}, + "up": {"uv": [4, 0, 9, 5], "texture": "#3"}, + "down": {"uv": [4, 0, 9, 5], "texture": "#3"} + } + }, + { + "name": "box", + "from": [1, 0, 1], + "to": [15, 2, 15], + "faces": { + "north": {"uv": [0, 0, 14, 2], "texture": "#1"}, + "east": {"uv": [0, 0, 14, 2], "texture": "#1"}, + "south": {"uv": [0, 0, 14, 2], "texture": "#1"}, + "west": {"uv": [0, 0, 14, 2], "texture": "#1"}, + "up": {"uv": [1, 1, 15, 15], "texture": "#2"}, + "down": {"uv": [1, 1, 15, 15], "texture": "#2"} + } + } + ], + "display": { + "thirdperson_righthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "thirdperson_lefthand": { + "rotation": [75, 45, 0], + "translation": [0, 2.5, 0], + "scale": [0.375, 0.375, 0.375] + }, + "firstperson_righthand": { + "rotation": [0, 45, 0], + "scale": [0.4, 0.4, 0.4] + }, + "firstperson_lefthand": { + "rotation": [0, 225, 0], + "scale": [0.4, 0.4, 0.4] + }, + "ground": { + "translation": [0, 3, 0], + "scale": [0.25, 0.25, 0.25] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "scale": [0.5, 0.5, 0.5] + } + }, + "groups": [ + { + "name": "antenna 1", + "origin": [0, 0, 0], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [0, 1] + }, + { + "name": "antenna 1", + "origin": [0, 0, 0], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [2, 3] + }, + { + "name": "VoxelShapes", + "origin": [0, 0, 0], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [4] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/createcomputing/models/item/computerized_redstone_link.json b/src/main/resources/assets/createcomputing/models/item/computerized_redstone_link.json new file mode 100644 index 0000000..8340c21 --- /dev/null +++ b/src/main/resources/assets/createcomputing/models/item/computerized_redstone_link.json @@ -0,0 +1,3 @@ +{ + "parent": "createcomputing:block/computerized_redstone_link" +} diff --git a/src/main/resources/createcomputing.mixins.json b/src/main/resources/createcomputing.mixins.json index 0932fff..485aa7f 100644 --- a/src/main/resources/createcomputing.mixins.json +++ b/src/main/resources/createcomputing.mixins.json @@ -4,12 +4,11 @@ "package": "de.saschat.createcomputing.mixin", "compatibilityLevel": "JAVA_8", "refmap": "createcomputing.refmap.json", - "mixins": [ - ], "client": [ "TrackTargetingClientMixin" ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [] } diff --git a/src/main/resources/data/createcomputing/recipes/computerized_redstone_link.json b/src/main/resources/data/createcomputing/recipes/computerized_redstone_link.json new file mode 100644 index 0000000..99f02a6 --- /dev/null +++ b/src/main/resources/data/createcomputing/recipes/computerized_redstone_link.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "GTG", + "LBL", + " E " + ], + "key": { + "B": { + "item": "create:brass_casing" + }, + "L": { + "item": "create:redstone_link" + }, + "E": { + "item": "create:electron_tube" + }, + "G": { + "item": "create:golden_sheet" + }, + "T": { + "item": "minecraft:redstone_torch" + } + }, + "result": { + "item": "createcomputing:computerized_redstone_link" + } +}