Started by
FreeDom
on
Topic category: Help with Minecraft modding (Java Edition)
Hello everyone! I want to make a workbench 2 blocks wide. what is the best way to do it?
of course, I have an idea to determine which way the block is turned (for example, to the north), then calculate the coordinates of the second block (for example, the x-1 coordinate) and put the 2 block of the workbench on these coordinates.
here is a piece of code(bedrock is here only for the test):
@ElementsGnidamod.ModElement.Tag
public class ProcedureTestWeavingTableBlockAdded extends ElementsGnidamod.ModElement {
public ProcedureTestWeavingTableBlockAdded(ElementsGnidamod instance) {
super(instance, 19);
}
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 TestWeavingTableBlockAdded!");
return;
}
if (dependencies.get("y") == null) {
System.err.println("Failed to load dependency y for procedure TestWeavingTableBlockAdded!");
return;
}
if (dependencies.get("z") == null) {
System.err.println("Failed to load dependency z for procedure TestWeavingTableBlockAdded!");
return;
}
if (dependencies.get("world") == null) {
System.err.println("Failed to load dependency world for procedure TestWeavingTableBlockAdded!");
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");
double u = 0;
String v = "";
boolean p = false;
u = (double) x;
if (((new Object() {
public EnumFacing getEnumFacing(BlockPos pos) {
try {
IBlockState _bs = world.getBlockState(pos);
for (IProperty<?> prop : _bs.getProperties().keySet()) {
if (prop.getName().equals("facing"))
return _bs.getValue((PropertyDirection) prop);
}
return EnumFacing.NORTH;
} catch (Exception e) {
return EnumFacing.NORTH;
}
}
}.getEnumFacing(new BlockPos((int) x, (int) y, (int) z))) == EnumFacing.NORTH)) {
if (((world.getBlockState(new BlockPos((int) ((u) - 1), (int) y, (int) z))).getBlock() == Blocks.AIR.getDefaultState().getBlock())) {
world.setBlockState(new BlockPos((int) ((u) - 1), (int) y, (int) z), Blocks.BEDROCK.getDefaultState(), 3);
} else if (((world.getBlockState(new BlockPos((int) ((u) + 1), (int) y, (int) z))).getBlock() == Blocks.AIR.getDefaultState()
.getBlock())) {
world.setBlockToAir(new BlockPos((int) x, (int) y, (int) z));
world.setBlockState(new BlockPos((int) ((u) + 1), (int) y, (int) z), BlockTestWeavingTable.block.getDefaultState(), 3);
world.setBlockState(new BlockPos((int) x, (int) y, (int) z), Blocks.BEDROCK.getDefaultState(), 3);
} else {world.setBlockToAir(new BlockPos((int) x, (int) y, (int) z));}}}}
so do it for the east, south and west.
maybe there is some way to do it differently?
Edited by FreeDom on Mon, 06/13/2022 - 09:51