Skip to content

Commit

Permalink
Rebase to Master and update
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Mar 13, 2017
1 parent 6c5ce7c commit 93ad46b
Show file tree
Hide file tree
Showing 43 changed files with 903 additions and 352 deletions.
2 changes: 1 addition & 1 deletion minecraft/1.11.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ forgeGradleVersion = 2.2-SNAPSHOT

packaging = jar
info.inceptionYear = 2016
info.description = The wrapper of the Nova API to the MinecraftForge 1.11 modding system.
info.description = The wrapper of the Nova API to the MinecraftForge 1.11.2 modding system.
info.organization.name = NOVA
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
* This library is free software, licensed under GNU Lesser General Public License VERSION 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* the Free Software Foundation, either VERSION 3 of the License, or
* (at your option) any later VERSION.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down Expand Up @@ -43,6 +43,7 @@
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.NovaFileResourcePack;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.NovaFolderResourcePack;
import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.NovaResourcePack;

import java.io.File;
import java.io.IOException;
Expand All @@ -52,8 +53,10 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -62,20 +65,22 @@
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import javax.json.Json;
import javax.json.stream.JsonGenerator;

public class NovaMinecraftPreloader extends DummyModContainer {
public static final String version = "0.0.1";
public static final String VERSION = "0.0.1";
private static final ModMetadata md;
public static Set<Class<?>> modClasses;
public static Map<Class<?>, File> modClassToFile;
public static List<NovaResourcePack<?>> novaResourcePacks = Collections.emptyList();

static {
md = new ModMetadata();
md.modId = "novapreloader";
md.name = "NOVA Preloader";
md.version = version;
md.version = VERSION;
}

public NovaMinecraftPreloader() {
Expand Down Expand Up @@ -293,6 +298,7 @@ public void registerResourcePacks() {
List<IResourcePack> packs = (List<IResourcePack>) resourcePackField.get(FMLClientHandler.instance());

Set<String> addedPacks = new HashSet<>();
List<NovaResourcePack<?>> novaPacks = new LinkedList<>();

classesMap.keySet().forEach(novaMod -> {
Class<?> c = classesMap.get(novaMod);
Expand All @@ -312,13 +318,15 @@ public void registerResourcePacks() {

if (!addedPacks.contains(fn)) {
addedPacks.add(fn);
packs.add(new NovaFileResourcePack(file, novaMod.id(), novaMod.domains()));
NovaFileResourcePack pack = new NovaFileResourcePack(file, novaMod.id(), novaMod.domains());
packs.add(pack);
novaPacks.add(pack);
System.out.println("Registered NOVA jar resource pack: " + fn);
}
} else {
//Add folder resource pack location. The folderLocation is the root of the project, including the packages of classes, and an assets folder inside.
String folderLocation = c.getProtectionDomain().getCodeSource().getLocation().getPath();
String classPath = c.getCanonicalName().replaceAll("\\.", "/");
String classPath = c.getCanonicalName().replace('.', '/');
folderLocation = folderLocation.replaceFirst("file:", "").replace(classPath, "").replace("/.class", "").replaceAll("%20", " ");
File folderFile = new File(folderLocation);
if (!new File(folderFile, "assets").isDirectory()) {
Expand All @@ -329,11 +337,14 @@ public void registerResourcePacks() {
modClassToFile.put(c, folderFile);

addedPacks.add(folderLocation);
packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains()));
NovaFolderResourcePack pack = new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains());
packs.add(pack);
novaPacks.add(pack);
System.out.println("Registered NOVA folder resource pack: " + folderFile.getAbsolutePath());
}
});
resourcePackField.set(FMLClientHandler.instance(), packs);
novaResourcePacks = new ArrayList<>(novaPacks);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
* This library is free software, licensed under GNU Lesser General Public License VERSION 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* the Free Software Foundation, either VERSION 3 of the License, or
* (at your option) any later VERSION.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand All @@ -24,29 +24,38 @@
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.language.LanguageManager;
import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader;
import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTileRenderer;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.backward.BWParticle;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward.FWParticle;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntityRenderer;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.backward.BWParticle;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward.FWParticle;
import nova.internal.core.Game;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
* @author Calclavia
*/
Expand All @@ -65,6 +74,49 @@ public void init(FMLInitializationEvent evt) {
RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance);
}

@Override
public void loadLanguage(LanguageManager languageManager) {
super.loadLanguage(languageManager);
ProgressManager.ProgressBar progressBar = ProgressManager.push("Loading NOVA language files",
NovaMinecraftPreloader.novaResourcePacks.size() + 1);
FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar);
fmlProgressBar.step("nova");
Minecraft.getMinecraft().getLanguageManager().getLanguages()
.stream()
.map(lang -> lang.getLanguageCode().replace('_', '-'))
.forEach(langName -> {
ResourceLocation location = new ResourceLocation("nova", langName + ".lang");
try {
Minecraft.getMinecraft().getResourceManager().getAllResources(location).forEach(resource ->
loadLanguage(languageManager, location, langName, resource.getInputStream()));
} catch (IOException ex) {
}
});
NovaMinecraftPreloader.novaResourcePacks.forEach(pack -> {
fmlProgressBar.step(pack.getID());
pack.getLanguageFiles().stream().forEach(location -> {
String resourcePath = location.getResourcePath();
String langName = resourcePath.substring(5, resourcePath.length() - 5);
try {
Minecraft.getMinecraft().getResourceManager().getAllResources(location).forEach(resource ->
loadLanguage(languageManager, location, langName, resource.getInputStream()));
} catch (IOException ex) {
}
});
});
fmlProgressBar.finish();
ProgressManager.pop(progressBar);
}

private void loadLanguage(LanguageManager languageManager, ResourceLocation location, String langName, InputStream stream) {
try {
Properties p = new Properties();
p.load(stream);
p.entrySet().stream().forEach(e -> languageManager.register(langName, e.getKey().toString(), e.getValue().toString()));
} catch (IOException ex) {
}
}

@Override
public void registerItem(FWItem item) {
super.registerItem(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraftforge.fml.common.registry.GameRegistry;
import nova.core.entity.Entity;
import nova.core.entity.EntityFactory;
import nova.core.language.LanguageManager;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTile;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTileUpdater;
Expand All @@ -46,6 +47,8 @@ public void preInit(FMLPreInitializationEvent evt) {
EntityRegistry.registerModEntity(new ResourceLocation("nova", "novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true);
}

public void loadLanguage(LanguageManager languageManager) {}

public void registerResourcePacks(Set<Class<?>> modClasses) {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

/*
* Copyright (c) 2015 NOVA, All rights reserved.
* This library is free software, licensed under GNU Lesser General Public License version 3
* This library is free software, licensed under GNU Lesser General Public License VERSION 3
*
* This file is part of NOVA.
*
* NOVA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* the Free Software Foundation, either VERSION 3 of the License, or
* (at your option) any later VERSION.
*
* NOVA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
Expand Down Expand Up @@ -53,7 +53,7 @@
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.cuboid.CuboidConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataWrapper;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory.InventoryConverter;
import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter;
Expand All @@ -73,19 +73,19 @@
* The main Nova Minecraft Wrapper loader, using Minecraft Forge.
* @author Calclavia
*/
@Mod(modid = NovaMinecraft.id, name = NovaMinecraft.name, version = NovaMinecraftPreloader.version, acceptableRemoteVersions = "*")
@Mod(modid = NovaMinecraft.MOD_ID, name = NovaMinecraft.NAME, version = NovaMinecraftPreloader.VERSION, acceptableRemoteVersions = "*")
public class NovaMinecraft {

public static final String id = "nova";
public static final String name = "NOVA";
public static final String mcId = "minecraft";
public static final String MOD_ID = "nova";
public static final String NAME = "NOVA";
public static final String GAME_ID = "minecraft";

@SidedProxy(clientSide = "nova.core.wrapper.mc.forge.v1_11_2.launcher.ClientProxy", serverSide = "nova.core.wrapper.mc.forge.v1_11_2.launcher.CommonProxy")
public static CommonProxy proxy;
@Mod.Instance(id)
@Mod.Instance(MOD_ID)
public static NovaMinecraft instance;
private static NovaLauncher launcher;
@Mod.Metadata(id)
@Mod.Metadata(MOD_ID)
private static ModMetadata modMetadata;

private static Set<ForgeLoadable> nativeConverters;
Expand Down Expand Up @@ -129,7 +129,7 @@ public void preInit(FMLPreInitializationEvent evt) {
/**
* Register native converters
*/
Game.natives().registerConverter(new DataWrapper());
Game.natives().registerConverter(new DataConverter());
Game.natives().registerConverter(new EntityConverter());
Game.natives().registerConverter(new BlockConverter());
Game.natives().registerConverter(new ItemConverter());
Expand Down Expand Up @@ -176,10 +176,11 @@ public void preInit(FMLPreInitializationEvent evt) {

// Initiate config system TODO: Storables
// launcher.getLoadedModMap().forEach((mod, loader) -> {
// Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(), mod.name()));
// Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(), mod.NAME()));
// ConfigManager.instance.sync(config, loader.getClass().getPackage().getName());
// });

proxy.loadLanguage(Game.language());
Game.language().init();
Game.render().init();
Game.blocks().init();
Expand Down Expand Up @@ -209,7 +210,7 @@ public void preInit(FMLPreInitializationEvent evt) {
* Register event handlers
*/
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
MinecraftForge.EVENT_BUS.register(new FMLEventHandler());
MinecraftForge.EVENT_BUS.register(Game.retention());
} catch (Exception e) {
System.out.println("Error during preInit");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @since 26/05/14
*/
public class MCNetworkManager extends NetworkManager {
public final String channel = NovaMinecraft.id;
public final String channel = NovaMinecraft.MOD_ID;
public final EnumMap<Side, FMLEmbeddedChannel> channelEnumMap = NetworkRegistry.INSTANCE.newChannel(channel, new ChannelHandler(), new MCPacketHandler());

public Packet<?> toMCPacket(PacketAbstract packet) {
Expand Down Expand Up @@ -112,7 +112,7 @@ public void sendToPlayer(PacketAbstract packet, EntityPlayerMP player) {

/**
* @param packet the packet to send to the players in the dimension
* @param dimId the dimension id to send to.
* @param dimId the dimension MOD_ID to send to.
*/
public void sendToAllInDimension(PacketAbstract packet, int dimId) {
this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
Expand Down Expand Up @@ -84,7 +85,7 @@ private static ItemIngredient getIngredient(Object ingredient) {
if (ingredient == null) {
return null;
} else if (ingredient instanceof ItemStack) {
return ((ItemStack) ingredient).isEmpty() ? null : ItemIngredient.forItem(net.minecraft.item.Item.REGISTRY.getNameForObject(((ItemStack) ingredient).getItem()).toString());
return ((ItemStack) ingredient).isEmpty() ? null : ItemIngredient.forItem(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(((ItemStack) ingredient).getItem())));
} else if (ingredient instanceof String) {
return ItemIngredient.forDictionary((String) ingredient);
} else if (ingredient instanceof List) {
Expand Down Expand Up @@ -237,6 +238,7 @@ public static CraftingRecipe toNova(IRecipe recipe) {
} else if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;

@SuppressWarnings({"unchecked", "rawtypes"})
Optional<ItemIngredient>[][] ingredients = new Optional[shaped.recipeHeight][shaped.recipeWidth];
for (int i = 0; i < shaped.recipeHeight; i++) {
for (int j = 0; j < shaped.recipeWidth; j++) {
Expand All @@ -251,6 +253,7 @@ public static CraftingRecipe toNova(IRecipe recipe) {
int width = ReflectionUtil.getShapedOreRecipeWidth(shaped);
int height = recipe.getRecipeSize() / width;

@SuppressWarnings({"unchecked", "rawtypes"})
Optional<ItemIngredient>[][] recipeIngredients = new Optional[height][width];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
Expand Down
Loading

0 comments on commit 93ad46b

Please sign in to comment.