저는 minecraft-forge mod을 만들고 있습니다. 설정 파일에 문제가 있습니다. 다른 사람들이 구성 파일에 String []을 추가 할 수 있도록 구성 # getStringList를 사용 했으므로 배열에서 블록을 가져 오는 데 사용하고 있습니다. 예를 들어 누군가가 minecraft를 작성한 경우 : gold_ore 블록 # getBlockFromName은 잘 작동하기 때문에 배열에는 그 외에 아무것도 없지만, 다음 줄에 minecraft : gold_ore와 minecraft : diamond_ore를두면, 블록 # getBlockFromName이 내가 보낸이 문자열을 읽으므로 충돌합니다. 따라서이 minecraft처럼 읽습니다 : gold_oreminecraft : diamond_ore 이름이없는 블록이 존재하지 않기 때문에 충돌이 발생합니다.) 대신에 minecraft : gold_ore와 minecraft : diamond_ore를 읽습니다. 기본적으로 해당 구성의 각 줄을 별도의 String으로 분할하거나 어떻게 든 각 줄을 개별적으로 읽는 것이 좋습니다. gold_ore와 마인 크래프트를 삭제 : 난 그냥 마인 크래프트를 입력하면 그렇게배열의 각 행을 문자열로 분할
# Configuration file
"ore generation" {
S:ore_to_gen <
minecraft:gold_ore
minecraft:diamond_ore
>
: 구성 파일과 같은 방법 이것은
public class ConfigCustomOreGen {
public static Configuration configCustomWorld;
private static File configCustomOreGenDir;
public static String oreToReplace;
public static final String WORLD = "Ore Generation";
public static void init(File oreGenDir) {
oreGenDir = new File(oreGenDir, Constants.MODID + "/" + "world");
oreGenDir.mkdir();
ConfigCustomOreGen.configCustomOreGenDir = oreGenDir;
ConfigCustomOreGen.configCustomWorld = new Configuration(new File(oreGenDir, "Custom-Ore-Generation.cfg"));
String[] oreReplace = configCustomWorld.getStringList("ore_to_gen", WORLD, EMPTY_STRING, "ore which should have custom ore gen\n");
StringBuilder strBuilder = new StringBuilder();
for (int i = 0; i < oreReplace.length; i++) {
strBuilder.append(oreReplace[i]);
}
oreToReplace = strBuilder.toString();
Constants.LOGGER.info(oreToReplace + " " + strBuilder.toString());
if (configCustomWorld.hasChanged()) {
configCustomWorld.save();
}
}
private final static String[] EMPTY_STRING = {};
}
: 일반적으로 세계의 부하와 생성 작업을 diamond_ore, 이것은 설정 클래스입니다
그리고 생성을 위해 나는 minecraft와 함께 작업했기 때문에 작동하는 사용자 지정 WorldGenMinable을 사용합니다 : gold_ore 및 광의 변수 아래에있는 모든 블록, Block # getBlockFromName이 존재하지 않는 블록 이름을 읽을 때 문제가 발생합니다.
public class CustomOreGen implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
Block ore = Block.getBlockFromName(ConfigCustomOreGen.oreToReplace);
generateOre(ore, world, random, chunkX, chunkZ, 20, 180, 8, 24, 8);
}
private void generateOre(Block ore, World world, Random random, int chunkX, int chunkZ, int minY, int maxY, int minVeinSize, int maxVeinSize, int chancesToSpawn) {
int heightRange = maxY - minY;
BlockPos blockpos = new BlockPos((chunkX * 16) + random.nextInt(16), minY + random.nextInt(heightRange), (chunkZ * 16) + random.nextInt(16));
if (world.provider.getDimension() == 0) {
for (int i = 0; i < chancesToSpawn; i++) {
WorldGenIngotterMinable generator = new WorldGenIngotterMinable(ore, minVeinSize, maxVeinSize, Blocks.AIR);
generator.generate(world, random, blockpos);
}
}
}
}
해당 구성 클래스를 패키징 하시겠습니까? – alpert