If I use the code template "Set mode of pin (Pin Number) to (Pin Mode)" it doesn't work (replicating the tutorial)
I need to type /link pinmode 13 output for it to work (same thing for input and input_pullup)
program is from "Setting default pin modes" https://mcreator.net/wiki/minecraft-link-mcreator-procedures
package net.mcreator.mcduino.procedures;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.common.MinecraftForge;
import net.mcreator.minecraft.link.event.LinkDeviceConnectedEvent;
import net.mcreator.minecraft.link.devices.PinMode;
import net.mcreator.minecraft.link.CurrentDevice;
import net.mcreator.mcduino.MCDuinoElements;
@MCDuinoElements.ModElement.Tag
public class DefaultPinModeProcedure extends MCDuinoElements.ModElement {
public DefaultPinModeProcedure(MCDuinoElements instance) {
super(instance, 3);
MinecraftForge.EVENT_BUS.register(this);
}
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
CurrentDevice.pinMode((int) 13, PinMode.OUT);
CurrentDevice.pinMode((int) 6, PinMode.IN_P);
CurrentDevice.pinMode((int) 5, PinMode.IN_P);
CurrentDevice.pinMode((int) 4, PinMode.IN_P);
CurrentDevice.pinMode((int) 3, PinMode.IN_P);
}
@SubscribeEvent
public void onLinkDeviceConnected(LinkDeviceConnectedEvent event) {
this.executeProcedure(new java.util.HashMap<>());
}
}
and the block that outputs to the led (arduino builtin led)
package net.mcreator.mcduino.procedures;
import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.mcreator.minecraft.link.CurrentDevice;
import net.mcreator.mcduino.MCDuinoElements;
@MCDuinoElements.ModElement.Tag
public class NightDetectorUpdateTickProcedure extends MCDuinoElements.ModElement {
public NightDetectorUpdateTickProcedure(MCDuinoElements instance) {
super(instance, 4);
}
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
if (dependencies.get("x") == null) {
System.err.println("Failed to load dependency x for procedure NightDetectorUpdateTick!");
return;
}
if (dependencies.get("y") == null) {
System.err.println("Failed to load dependency y for procedure NightDetectorUpdateTick!");
return;
}
if (dependencies.get("z") == null) {
System.err.println("Failed to load dependency z for procedure NightDetectorUpdateTick!");
return;
}
if (dependencies.get("world") == null) {
System.err.println("Failed to load dependency world for procedure NightDetectorUpdateTick!");
return;
}
int x = (int) dependencies.get("x");
int y = (int) dependencies.get("y");
int z = (int) dependencies.get("z");
World world = (World) dependencies.get("world");
CurrentDevice.digitalWrite((int) 13,
(((world.isDaytime()) && (world.canBlockSeeSky(new BlockPos((int) x, (int) y, (int) z))))) ? (byte) 1 : (byte) 0);
}
}
Issue comments
i followed the tutorial from the link above (this one https://mcreator.net/wiki/minecraft-link-mcreator-procedures).
i made a "procedure" called DefaultPinmode that runs when a new device is connected (MCreator Link: New device connected)
and sets the pins.
and for some reason it doesnt execute.
if I didn't answer the question or properly its because i have difficulty reading/writing in english.
here is the link to the zip file (google drive)
https://drive.google.com/file/d/1CSZE2Bqf73mQ1LBe1fVhyJQPi4g_0bmF/view?usp=sharing
There is a time limit on how often data can be sent to Arduino in milliseconds to prevent flooding and freezing it and this time limit prevents sending data immediately after connect and this is when you try to send pinmode data.
I am surprised no one noticed this so far.
You can check the source here: https://github.com/Pylo/MCreatorLink It is opensource :)
How did you trigger this procedure?