Now with 50% less json file, and fixes

This commit is contained in:
modmuss50 2016-04-25 11:10:06 +01:00
parent 61c7815f3b
commit eca6144c66
93 changed files with 2406 additions and 1877 deletions

View file

@ -62,8 +62,7 @@ public class Core
public VersionChecker versionChecker;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event)
{
public void preinit(FMLPreInitializationEvent event) throws IllegalAccessException, InstantiationException {
event.getModMetadata().version = ModInfo.MOD_VERSION;
INSTANCE = this;
FMLCommonHandler.instance().bus().register(this);
@ -87,6 +86,13 @@ public class Core
{
compatModule.preInit(event);
}
// Register ModBlocks
ModBlocks.init();
// Register Fluids
ModFluids.init();
// Register ModItems
ModItems.init();
// Entitys
EntityRegistry.registerModEntity(EntityNukePrimed.class, "nuke", 0, INSTANCE, 160, 5, true);
proxy.preInit(event);
@ -94,19 +100,12 @@ public class Core
RecipeConfigManager.load(event.getModConfigurationDirectory());
versionChecker = new VersionChecker("TechReborn", new ModInfo());
versionChecker.checkVersionThreaded();
logHelper.info("PreInitialization Complete");
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) throws IllegalAccessException, InstantiationException
{
// Register ModBlocks
ModBlocks.init();
// Register Fluids
ModFluids.init();
// Register ModItems
ModItems.init();
// Registers Chest Loot
ModLoot.init();
// Multiparts

View file

@ -57,8 +57,6 @@ public class JsonGenerator {
}
File machineBaseFile = new File(baseJsonFiles, "machineBase.json");
String machineBase = Files.toString(machineBaseFile, Charsets.UTF_8);
File machineModelBaseFile = new File(baseJsonFiles, "machineModelBase.json");
String machineModelBase = Files.toString(machineModelBaseFile, Charsets.UTF_8);
for(Object object : RebornCore.jsonDestroyer.objectsToDestroy){
if(object instanceof BlockMachineBase){
BlockMachineBase base = (BlockMachineBase) object;
@ -68,9 +66,10 @@ public class JsonGenerator {
state.delete();
}
String output = machineBase;
output = output.replaceAll("%MODEL%", "techreborn:" + base.getUnlocalizedName());
output = output.replaceAll("%OFF_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.NORTH));
output = output.replaceAll("%ON_TEXTURE%", base.getTextureNameFromState(base.getDefaultState().withProperty(BlockMachineBase.ACTIVE, true), EnumFacing.NORTH));
output = output.replaceAll("%SIDE_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.EAST));
output = output.replaceAll("%TOP_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.UP));
try {
FileOutputStream is = new FileOutputStream(state);
OutputStreamWriter osw = new OutputStreamWriter(is);
@ -80,26 +79,6 @@ public class JsonGenerator {
} catch (IOException e) {
e.printStackTrace();
}
File model = new File(blockModels, base.getUnlocalizedName() + ".json");
if(model.exists()){
model.delete();
}
String modelOutput = machineModelBase;
modelOutput = modelOutput.replaceAll("%MODEL%", base.getUnlocalizedName() );
modelOutput = modelOutput.replaceAll("%OFF_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.NORTH));
modelOutput = modelOutput.replaceAll("%ON_TEXTURE%", base.getTextureNameFromState(base.getDefaultState().withProperty(BlockMachineBase.ACTIVE, true), EnumFacing.NORTH));
modelOutput = modelOutput.replaceAll("%SIDE_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.EAST));
modelOutput = modelOutput.replaceAll("%TOP_TEXTURE%", base.getTextureNameFromState(base.getDefaultState(), EnumFacing.UP));
try {
FileOutputStream is = new FileOutputStream(model);
OutputStreamWriter osw = new OutputStreamWriter(is);
Writer w = new BufferedWriter(osw);
w.write(modelOutput);
w.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View file

@ -1,14 +1,24 @@
package techreborn.proxies;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameData;
import reborncore.RebornCore;
import reborncore.client.multiblock.MultiblockRenderEvent;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.ClientMultiBlocks;
import techreborn.client.IconSupplier;
import techreborn.client.RegisterItemJsons;
@ -44,6 +54,13 @@ public class ClientProxy extends CommonProxy
e.printStackTrace();
}
}).start();
for(Object object : RebornCore.jsonDestroyer.objectsToDestroy) {
if (object instanceof BlockMachineBase) {
BlockMachineBase base = (BlockMachineBase) object;
registerItemModel(Item.getItemFromBlock(base));
}
}
}
@Override
@ -60,6 +77,45 @@ public class ClientProxy extends CommonProxy
// TODO FIX ME
ClientRegistry.registerKeyBinding(KeyBindings.config);
ClientMultiBlocks.init();
}
protected void registerItemModel(ItemStack item, String name) {
// tell Minecraft which textures it has to load. This is resource-domain sensitive
ModelLoader.registerItemVariants(item.getItem(), new ResourceLocation(name));
// tell the game which model to use for this item-meta combination
ModelLoader.setCustomModelResourceLocation(item.getItem(), item
.getMetadata(), new ModelResourceLocation(name, "inventory"));
}
public ResourceLocation registerItemModel(Item item) {
ResourceLocation itemLocation = getItemLocation(item);
if(itemLocation == null) {
return null;
}
return registerIt(item, itemLocation);
}
public static ResourceLocation getItemLocation(Item item) {
Object o = GameData.getItemRegistry().getNameForObject(item);
if(o == null) {
return null;
}
return (ResourceLocation) o;
}
private static ResourceLocation registerIt(Item item, final ResourceLocation location) {
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(location, "inventory");
}
});
ModelLoader.registerItemVariants(item, location);
return location;
}
public class RenderManagerNuke implements IRenderFactory<EntityNukePrimed>