36 lines
1.3 KiB
Java
36 lines
1.3 KiB
Java
package com.thebrokenrail.scriptcraft.api.bridge;
|
|
|
|
import com.thebrokenrail.scriptcraft.core.ScriptCraftCore;
|
|
import net.minecraft.block.AbstractBlock;
|
|
import net.minecraft.block.Material;
|
|
import net.minecraft.block.MaterialColor;
|
|
|
|
import java.util.Locale;
|
|
|
|
class BlockSettingsBridges {
|
|
static void register() {
|
|
ScriptCraftCore.addBridge("BlockSettings.create", args -> {
|
|
try {
|
|
String materialID = ((String) args[0]).toUpperCase(Locale.ROOT);
|
|
Material material = (Material) Material.class.getField(materialID).get(null);
|
|
|
|
MaterialColor materialColor;
|
|
if (args[1] != null) {
|
|
String materialColorID = ((String) args[1]).toUpperCase(Locale.ROOT);
|
|
materialColor = (MaterialColor) MaterialColor.class.getField(materialColorID).get(null);
|
|
} else {
|
|
materialColor = material.getColor();
|
|
}
|
|
|
|
AbstractBlock.Settings settings = AbstractBlock.Settings.of(material, materialColor);
|
|
|
|
settings.strength(((Double) args[2]).floatValue(), ((Double) args[3]).floatValue());
|
|
|
|
return settings;
|
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
});
|
|
}
|
|
}
|