- 4
- 0
Добрый день. Я на форуме не так давно, да и разработкой модов увлёкся совсем недавно. Решил написать свой простенький мод, в нём есть руда. Сделал блок, сделал дроп, настроил. Но вот в мире не хочет генерироваться никак. Поскольку с самим языком Java и API майнкрафта в частности знаком недостаточно глубоко, код генерации мира брал с вики майнкрафта. Eclipse ошибок не выдаёт, майнкрафт запускается без проблем. Синтаксических ошибок, вроде как, нет.
Прошу помочь, буду очень признателен.
P.s. проверял все три мира, ни в одном руда не генерируется
Строки в главном классе:
Класс с генерацией руды:
Прошу помочь, буду очень признателен.
P.s. проверял все три мира, ни в одном руда не генерируется
Строки в главном классе:
Java:
package com.fhalo.fhmod;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.oredict.OreDictionary;
public class Main {
public static Block orepalladium;
public static Block orepalladiumnether;
public static Block orepalladiumender;
public static Item crystalpalladium;
public static WorldGen worldgen;
@EventHandler
public void preLoad(FMLPreInitializationEvent event)
{
orepalladium = new OrePalladium();
GameRegistry.registerBlock(orepalladium, "orepalladium");
orepalladiumnether = new OrePalladiumNether();
GameRegistry.registerBlock(orepalladiumnether, "orepalladiumnether");
orepalladiumender = new OrePalladiumEnder();
GameRegistry.registerBlock(orepalladiumender, "orepalladiumender");
worldgen = new WorldGen();
GameRegistry.registerWorldGenerator(worldgen, 0);
crystalpalladium = new CrystalPalladium();
GameRegistry.registerItem(crystalpalladium, "crystalpalladium");
}
}
Класс с генерацией руды:
Java:
package com.fhalo.fhmod;
import java.util.Random;
import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
public class WorldGen implements IWorldGenerator {
@Override
public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
generateOverworld(rand, chunkX, chunkZ, world);
generateNether(rand, chunkX, chunkZ, world);
generateEnd(rand, chunkX, chunkZ, world);
}
private void generateOverworld(Random rand, int chunkX, int chunkZ, World world) {
generateOverworld(world, rand, chunkX * 16, chunkZ * 16);
}
private void generateNether(Random rand, int chunkX, int chunkZ, World world) {
generateNether(world, rand, chunkX * 16, chunkZ * 16);
}
private void generateEnd(Random rand, int chunkX, int chunkZ, World world) {
generateEnd(world, rand, chunkX * 16, chunkZ * 16);
}
public void generateOverworld(World world, Random rand, int blockXPos, int blockZPos) {
addOreSpawn(Main.orepalladium, Blocks.stone, world, rand, blockXPos, blockZPos, 16, 16, 1, 2, 1, 1, 10, 20, 30);
}
public void generateNether(World world, Random rand, int blockXPos, int blockZPos) {
addOreSpawn(Main.orepalladiumnether, Blocks.netherrack, world, rand, blockXPos, blockZPos, 16, 16, 1, 2, 1, 1, 10, 0, 40);
}
public void generateEnd(World world, Random rand, int blockXPos, int blockZPos) {
addOreSpawn(Main.orepalladiumender, Blocks.end_stone, world, rand, blockXPos, blockZPos, 16, 16, 1, 2, 1, 1, 10, 0, 256);
}
public static void addOreSpawn(Block ore, Block replace, World world, Random rand, int blockXPos, int blockZPos, int maxX, int maxZ,
int minVeinSize, int maxVeinSize, int minVeinsPerChunk, int maxVeinsPerChunk, int chanceToSpawn, int minY, int maxY) {
if (rand.nextInt(101) < (100 - chanceToSpawn)) return;
int veins = rand.nextInt(maxVeinsPerChunk - minVeinsPerChunk + 1) + minVeinsPerChunk;
for (int i = 0; i < veins; i++) {
int posX = blockXPos + rand.nextInt(maxX);
int posY = minY + rand.nextInt(maxY - minY);
int posZ = blockZPos + rand.nextInt(maxZ);
(new WorldGenMinable(ore, minVeinSize + rand.nextInt(maxVeinSize - minVeinSize + 1),
replace)).generate(world, rand, posX, posY, posZ);
}
}
}
Последнее редактирование модератором: