Skip to content

Commit

Permalink
Add waitForRedstoneLink command
Browse files Browse the repository at this point in the history
  • Loading branch information
OutCraft-Mods committed Feb 10, 2023
1 parent 76654d1 commit 02cd643
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/main/java/com/workert/robotics/Robotics.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
Expand Down Expand Up @@ -43,8 +42,6 @@ public Robotics() {

PacketList.registerPackets();

MinecraftForge.EVENT_BUS.register(this);

CodeHelper.registerDefaultCommands();
}

Expand All @@ -57,5 +54,4 @@ private static void clientSetup(final FMLClientSetupEvent event) {

MenuScreens.register(ModMenuTypes.SMASHER_BLOCK_MENU.get(), SmasherBlockScreen::new);
}

}
4 changes: 2 additions & 2 deletions src/main/java/com/workert/robotics/client/ClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;

@EventBusSubscriber(modid = Robotics.MOD_ID, value = Dist.CLIENT, bus = Bus.MOD) public class ClientHandler {
@EventBusSubscriber(modid = Robotics.MOD_ID, value = Dist.CLIENT, bus = Bus.MOD)
public class ClientHandler {

@SubscribeEvent
public static void registerEntityRenders(EntityRenderersEvent.RegisterRenderers event) {
Expand All @@ -33,5 +34,4 @@ public static void registerLayerDefinition(EntityRenderersEvent.RegisterLayerDef
event.registerLayerDefinition(CodeDroneModel.LAYER_LOCATION, CodeDroneModel::createBodyLayer);
event.registerLayerDefinition(ExtendOBootsModel.LAYER_LOCATION, ExtendOBootsModel::createBodyLayer);
}

}
18 changes: 18 additions & 0 deletions src/main/java/com/workert/robotics/helpers/CodeHelper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.workert.robotics.helpers;

import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.deployer.DeployerFakePlayer;
import com.simibubi.create.content.contraptions.components.deployer.DeployerHandler;
import com.simibubi.create.content.logistics.RedstoneLinkNetworkHandler;
import com.simibubi.create.foundation.utility.Couple;
import com.workert.robotics.Robotics;
import com.workert.robotics.entities.AbstractRobotEntity;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -208,6 +211,21 @@ public static void registerDefaultCommands() {
throw new RuntimeException(e);
}
});
CodeHelper.registerCommand("waitForRedstoneLink", (robot, arguments) -> {
if (arguments.size() < 1)
throw new IllegalArgumentException("Expected two arguments for command \"waitForRedstoneLink\"");
try {
while (Create.REDSTONE_LINK_NETWORK_HANDLER.hasAnyLoadedPower(Couple.create(
RedstoneLinkNetworkHandler.Frequency.of(
CodeHelper.getItemById(arguments.get(0)).getDefaultInstance()),
RedstoneLinkNetworkHandler.Frequency.of(
CodeHelper.getItemById(arguments.get(0)).getDefaultInstance())))) {
Thread.sleep(200);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
}

public static void runCode(AbstractRobotEntity robot, String code) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/assets/robotics/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"itemGroup.robotics": "Create Robotics",

"item.robotics.tin_ingot": "Tin ingot",
"item.robotics.tin_nugget": "Tin nugget",
"item.robotics.raw_tin": "Raw tin",
Expand All @@ -10,11 +11,13 @@
"item.robotics.miner": "Miner",
"item.robotics.code_drone": "Code Drone",
"item.robotics.extend_o_boots": "Extend-O-Boots",

"block.robotics.tin_ore": "Tin ore",
"block.robotics.deepslate_tin_ore": "Deepslate tin ore",
"block.robotics.tin_block": "Tin block",
"block.robotics.bronze_block": "Bronze block",
"block.robotics.smasher_block": "Smasher",
"block.robotics.code_editor": "Code Editor",
"description.robotics.extend_o_boots": "Ctrl + Scroll to activate"

"item.robotics.extend_o_boots.tooltip": "Ctrl + Scroll to activate"
}
9 changes: 7 additions & 2 deletions src/main/resources/assets/robotics/lang/nl_nl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"itemGroup.robotics": "Create Robotica",

"item.robotics.tin_ingot": "Tinstaaf",
"item.robotics.tin_nugget": "Tinklompje",
"item.robotics.raw_tin": "Rauwe tin",
Expand All @@ -10,11 +11,15 @@
"item.robotics.miner": "Mijner",
"item.robotics.code_drone": "Code Drone",
"item.robotics.extend_o_boots": "Uitklapbare Schoenen",

"block.robotics.tin_ore": "Tin erts",
"block.robotics.deepslate_tin_ore": "Wrevelsteen tin erts",
"block.robotics.tin_block": "Tin blok",
"block.robotics.bronze_block": "Bronzen blok",
"block.robotics.smasher_block": "Beuker",
"block.robotics.code_editor": "Code wijziger",
"description.robotics.extend_o_boots": "Ctrl + Scroll om te activeren!"
}

"description.robotics.extend_o_boots": "Ctrl + Scroll om te activeren!",

"item.robotics.code_drone.tooltip": "Test tooltip"
}
9 changes: 7 additions & 2 deletions src/main/resources/assets/robotics/lang/ru_ru.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"itemGroup.robotics": "Create Робототехника",

"item.robotics.tin_ingot": "Оловянный слиток",
"item.robotics.tin_nugget": "Кусочек олова",
"item.robotics.raw_tin": "Блок рудного олова",
Expand All @@ -10,11 +11,15 @@
"item.robotics.miner": "Робот-шахтер",
"item.robotics.code_drone": "Программируемый дрон",
"item.robotics.extend_o_boots": "Удлинённые ботинки",

"block.robotics.tin_ore": "Оловянная руда",
"block.robotics.deepslate_tin_ore": "Оловоносный глубинный сланец",
"block.robotics.tin_block": "Оловянный блок",
"block.robotics.bronze_block": "Бронзовый блок",
"block.robotics.smasher_block": "Сокрушитель",
"block.robotics.code_editor": "Редактор кода",
"description.robotics.extend_o_boots": "Ctrl + Прокрутка для активации"
}

"description.robotics.extend_o_boots": "Ctrl + Прокрутка для активации",

"item.robotics.code_drone.tooltip": "Test tooltip"
}

0 comments on commit 02cd643

Please sign in to comment.