Started by
thaumiel
on
Topic category: Troubleshooting, bugs, and solutions
Hi, I've tried to build a procedure that copys all blocks in a specific region and than pastes them in a specific distance to the block where the player specifys the distance.It worked as it only was on block to copy but now it just crashes my game
the code is bellow :
package net.mcreator.spacecraft.procedures;
/* imports omitted */
public class MoveblocktestProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
double cx = 0;
double cy = 0;
double cz = 0;
cx = x;
cy = y;
cz = z;
if (getEnergyStored(world, BlockPos.containing(x, y, z), null) == 100000) {
while (cz != z + 5) {
while (cy != y + 3) {
while (cx != x + 3) {
{
BlockPos _bp = BlockPos.containing(x + new Object() {
double convert(String s) {
try {
return Double.parseDouble(s.trim());
} catch (Exception e) {
}
return 0;
}
}.convert((entity instanceof Player _entity1 && _entity1.containerMenu instanceof SpaceCraftModMenus.MenuAccessor _menu1) ? _menu1.getMenuState(0, "Space", "") : ""), cy, cx);
BlockState _bs = (world.getBlockState(BlockPos.containing(cx, cy, cz)));
BlockState _bso = world.getBlockState(_bp);
for (Property<?> _propertyOld : _bso.getProperties()) {
Property _propertyNew = _bs.getBlock().getStateDefinition().getProperty(_propertyOld.getName());
if (_propertyNew != null && _bs.getValue(_propertyNew) != null)
try {
_bs = _bs.setValue(_propertyNew, _bso.getValue(_propertyOld));
} catch (Exception e) {
}
}
world.setBlock(_bp, _bs, 3);
}
if (world instanceof ILevelExtension _ext) {
IEnergyStorage _entityStorage = _ext.getCapability(Capabilities.EnergyStorage.BLOCK, BlockPos.containing(x, y, z), null);
if (_entityStorage != null)
_entityStorage.extractEnergy(100000, false);
}
cx = cx + 1;
}
cx = 0;
cy = cz + 1;
}
cz = cz + 1;
}
} else {
if (entity instanceof Player _player && !_player.level().isClientSide())
_player.displayClientMessage(Component.literal("NO ENERGY LEFT!"), false);
}
}
public static int getEnergyStored(LevelAccessor level, BlockPos pos, Direction direction) {
if (level instanceof ILevelExtension levelExtension) {
IEnergyStorage energyStorage = levelExtension.getCapability(Capabilities.EnergyStorage.BLOCK, pos, direction);
if (energyStorage != null)
return energyStorage.getEnergyStored();
}
return 0;
}
}
please send it as an image
https://mcreator.net/forum/119611/images-wont-show-when-i-put-them