Merge pull request #2426 from KellenHurrey/master

Add a oc function to set the custom map of redstone over radio torches
This commit is contained in:
HbmMods 2025-09-11 16:28:07 +02:00 committed by GitHub
commit 463d020dad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,6 +17,8 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import java.util.Map;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityRadioTorchBase extends TileEntityLoadedBase implements IControlReceiver, SimpleComponent, CompatHandler.OCComponent {
@ -137,4 +139,18 @@ public class TileEntityRadioTorchBase extends TileEntityLoadedBase implements IC
customMap = args.checkBoolean(0);
return new Object[] {};
}
@Callback(direct = true, limit = 4, doc = "setCustomMapValues(value: table) -- Sets the custom signal mapping values with a table with indices corresponding to the redstone value (1-16)")
@Optional.Method(modid = "OpenComputers")
public Object[] setCustomMapValues(Context context, Arguments args){
Map values = args.checkTable(0);
for (int i = 1; i <= 16; i++){
if (values.containsKey(i) && values.get(i) instanceof String){
this.mapping[i - 1] = (String) values.get(i);
}
}
return new Object[] {};
}
}