use of net.minecraft.world.biome.BiomeOcean in project takumicraft by TNTModders.
the class TakumiEntityCore method register.
public static void register() {
// CREATURE_TAKUMI = EnumHelper.addCreatureType("creature_takumi", EntityTakumiAbstractCreeper.class, 100, Material.AIR, false, true);
// WATER_TAKUMI = EnumHelper.addCreatureType("water_takumi", EntityTakumiAbstractCreeper.class, 25, Material.WATER, false, false);
Biome.REGISTRY.iterator().forEachRemaining(biome -> biomes.add(biome));
biomes.remove(Biomes.HELL);
biomes.remove(Biomes.VOID);
/*List<Class> files = TakumiUtils.getListClass("com/tntmodders/takumi/entity/mobs/");*/
ArrayList<EntityHolder> entityHolders = new ArrayList<>();
for (Class clazz : CLASS_LIST) {
try {
/*ClassLoader loader = TakumiCraftCore.class.getClassLoader();
//Class clazz = loader.loadClass("com.tntmodders.takumi.entity.mobs." + file.getName().replaceAll(".class", ""));*/
ITakumiEntity entity = (ITakumiEntity) clazz.getConstructor(World.class).newInstance((World) null);
entityHolders.add(new EntityHolder(clazz, entity));
} catch (Exception e) {
// e.printStackTrace();
}
}
// List <File> files = TakumiUtils.getListFile("com/tntmodders/takumi/entity/mobs/");
/*for (File file : files) {
try {
ClassLoader loader = TakumiCraftCore.class.getClassLoader();
Class clazz = loader.loadClass("com.tntmodders.takumi.entity.mobs." + file.getName().replaceAll(".class", ""));
ITakumiEntity entity = (ITakumiEntity) clazz.getConstructor(World.class).newInstance((World) null);
entityHolders.add(new EntityHolder(clazz, entity));
} catch (Exception e) {
//e.printStackTrace();
}
}*/
entityHolders.sort(new EntityComparator());
for (EntityHolder holder : entityHolders) {
Class clazz = holder.clazz;
ITakumiEntity entity = holder.entity;
if (!entity.canRegister()) {
break;
}
ResourceLocation location = new ResourceLocation(TakumiCraftCore.MODID, entity.getRegisterName());
EntityRegistry.registerModEntity(location, clazz, location.getResourcePath(), entity.getRegisterID(), TakumiCraftCore.TakumiInstance, 64, 2, true, entity.getPrimaryColor(), entity.getSecondaryColor());
if (entity.isCustomSpawn()) {
try {
entity.customSpawn();
} catch (Exception e) {
e.printStackTrace();
}
} else if (entity.takumiRank().getSpawnWeight() != 0 && !entity.isAnimal()) {
Biome.REGISTRY.iterator().forEachRemaining(biome -> {
if (!(biome instanceof BiomeOcean) && biome != Biomes.HELL && biome != Biomes.VOID && biome != Biomes.SKY) {
EntityRegistry.addSpawn(clazz, entity.takumiRank().getSpawnWeight(), 10, 30, EnumCreatureType.MONSTER, biome);
}
});
entity.additionalSpawn();
}
if (FMLCommonHandler.instance().getSide().isClient()) {
TakumiClientCore.registerEntityRender(clazz, entity);
}
entityList.add(entity);
TakumiCraftCore.LOGGER.info("Registered entity on ID " + entity.getRegisterID() + " : " + location.getResourcePath() + " , " + entity.takumiRank().name() + " and " + entity.takumiType().name());
File packFile = FMLCommonHandler.instance().findContainerFor(TakumiCraftCore.TakumiInstance).getSource();
File oldFile = null;
String assetS = "assets/takumicraft/advancements/slay";
for (File f : TakumiUtils.getListFile(assetS)) {
if (f.getName().contains("slay_.json")) {
oldFile = f;
break;
}
}
if (oldFile != null) {
ClassLoader loader = TakumiCraftCore.class.getClassLoader();
URL url = loader.getResource(assetS);
if (!Objects.equals(url.getProtocol(), "jar")) {
String[] strings = { oldFile.getAbsolutePath().replaceAll(".json", ""), oldFile.getAbsolutePath().split("out")[0] + "src" + oldFile.getAbsolutePath().split("out")[1].replaceAll("production", "main").replaceAll("minecraft", "resources").replaceAll(".json", "") };
for (String sPath : strings) {
String sResource = sPath + entity.getRegisterName() + ".json";
File file = new File(sResource);
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
FileReader h_fr;
String buf = "";
String h_s;
try {
h_fr = new FileReader(oldFile);
BufferedReader h_br = new BufferedReader(h_fr);
while (true) {
h_s = h_br.readLine();
if (h_s == null) {
break;
}
h_s = h_s.replaceAll("minecraft:creeper", "takumicraft:" + entity.getRegisterName());
h_s = h_s.replaceAll("creeper_hoge", entity.getRegisterName());
buf = buf + h_s;
}
h_fr.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
FileWriter writer = new FileWriter(file);
writer.write(buf);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
itemRegister();
if (FMLCommonHandler.instance().getSide().isClient()) {
renderRegister();
}
}
Aggregations