From 3d83f95d28575dc9818ac7783959e8ea99ca3df4 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 17 Dec 2016 22:52:39 +0100 Subject: [PATCH 01/61] Begin work on Minecraft 1.11 wrappers. --- minecraft/.gitignore | 1 + minecraft/1.11/.gitignore | 17 ++++ minecraft/1.11/build.gradle | 134 +++++++++++++++++++++++++++++++ minecraft/1.11/gradle.properties | 9 +++ settings.gradle | 1 + 5 files changed, 162 insertions(+) create mode 100644 minecraft/1.11/.gitignore create mode 100644 minecraft/1.11/build.gradle create mode 100644 minecraft/1.11/gradle.properties diff --git a/minecraft/.gitignore b/minecraft/.gitignore index a4c6e69be..896c508ad 100644 --- a/minecraft/.gitignore +++ b/minecraft/.gitignore @@ -3,5 +3,6 @@ !/build.gradle !/.gitignore +!/1.11 !/1.8 !/1.7 diff --git a/minecraft/1.11/.gitignore b/minecraft/1.11/.gitignore new file mode 100644 index 000000000..85be317cb --- /dev/null +++ b/minecraft/1.11/.gitignore @@ -0,0 +1,17 @@ +# Ignore All +/* + +# Sources +!/src + +# github +!/.gitignore +!/README.md + +# gradle +!/build.gradle +!/build.properties +!/settings.gradle +!/gradle.properties +!/gradlew* +!/gradle diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle new file mode 100644 index 000000000..7795ae3de --- /dev/null +++ b/minecraft/1.11/build.gradle @@ -0,0 +1,134 @@ +apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle" + +apply plugin: "com.jfrog.artifactory" +apply plugin: "com.github.johnrengelman.shadow" +apply plugin: "maven-publish" + +idea.module.name = "Core-MC-1.11" +archivesBaseName = "NOVA-Core-Wrapper-MC1.11" + +configurations { + fatJar + compile.extendsFrom fatJar +} + +dependencies { + fatJar project(":") + testCompile project(path: ':', configuration: 'wrapperTests') + + testCompile "junit:junit:4.12" + testCompile 'org.assertj:assertj-core:3.0.0' + testRuntime 'org.slf4j:slf4j-simple:1.7.10' +} + +jar { + manifest { + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePluginContainsFMLMod': 'true' + attributes 'FMLAT': 'nova_at.cfg' + } +} + +task deobfJar(type: Jar) { + from sourceSets.main.output + classifier = 'deobf' + manifest { + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePluginContainsFMLMod': 'true' + attributes 'FMLAT': 'nova_at.cfg' + } +} + +/** + * Create fat jar file with all dependencies included. + */ +task fatJar(type: Jar) { + configurations.fatJar.each {dep -> + from(project.zipTree(dep)) { + exclude 'META-INF', 'META-INF/**' + } + } + with jar + + manifest { + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePluginContainsFMLMod': 'true' + attributes 'FMLAT': 'nova_at.cfg' + } + classifier = 'fat' +} + +artifacts { + archives deobfJar + archives fatJar +} + +publishing { + publications { + main(MavenPublication) { + from components.java + + artifactId archivesBaseName + + artifact sourcesJar + artifact javadocJar + artifact deobfJar + artifact fatJar + + pom.withXml(writePom(project.properties)) + pom.withXml {xml -> + def children = xml.asNode().get("dependencies")[0] + for (child in children) { + def artifactId = child.get("artifactId")[0].value()[0] + if (artifactId.equals("forgeSrc") || artifactId.equals("forgeBin")) { + children.remove(child) + break; + } + } + } + } + } +} + +artifactory { + publish { + defaults { + publications("main") + publishPom = true + } + } +} + +apply plugin: 'forge' + +minecraft { + version = property("minecraft.version") + "-" + property("forge.version") + //mappings = 'snapshot_20161111' + runDir = "run" +} + +reobf { + reobf(fatJar) {spec -> spec.classpath = configurations.compile} +} + +runClient { + jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' +} + +runServer { + jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' +} + +processResources { + inputs.property "version", project.version + inputs.property "mcversion", project.minecraft.version + + from(sourceSets.main.resources.srcDirs) { + include 'mcmod.info' + expand 'version': project.version, 'mcversion': project.minecraft.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude 'mcmod.info' + } +} diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11/gradle.properties new file mode 100644 index 000000000..798822e89 --- /dev/null +++ b/minecraft/1.11/gradle.properties @@ -0,0 +1,9 @@ +group = nova.core + +minecraft.version = 1.11 +forge.version = 13.19.1.2189 + +packaging = jar +info.inceptionYear = 2016 +info.description = The wrapper of the Nova API to the MinecraftForge 1.11 modding system. +info.organization.name = NOVA diff --git a/settings.gradle b/settings.gradle index 5880535a0..27fdae8ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,5 @@ rootProject.name = 'NOVA-Core' +include "minecraft:1.11" include "minecraft:1.8" include "minecraft:1.7" From 6781f18dba8f6a5f667cf60561b9410491f2a4f9 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 17 Dec 2016 23:26:24 +0100 Subject: [PATCH 02/61] Fix Travis build --- minecraft/1.11/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index 7795ae3de..4ad647e4d 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -103,7 +103,7 @@ apply plugin: 'forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - //mappings = 'snapshot_20161111' + mappings = 'snapshot_20161111' runDir = "run" } From 57c013a923e9d62e12ea5133e42d3bd24bf49eb1 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 18 Dec 2016 00:19:10 +0100 Subject: [PATCH 03/61] Made it so that different Minecraft wrappers can use different ForgeGradle versions. --- minecraft/1.11/build.gradle | 5 +++-- minecraft/1.11/gradle.properties | 1 + minecraft/1.7/gradle.properties | 1 + minecraft/1.8/gradle.properties | 1 + minecraft/build.gradle | 27 +++++++++++++++------------ 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index 4ad647e4d..6f83ac975 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -99,7 +99,7 @@ artifactory { } } -apply plugin: 'forge' +apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") @@ -108,7 +108,8 @@ minecraft { } reobf { - reobf(fatJar) {spec -> spec.classpath = configurations.compile} + // TODO Figure out what this was replaced by in ForgeGrade 2.2 + //reobf(fatJar) {spec -> spec.classpath = configurations.compile} } runClient { diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11/gradle.properties index 798822e89..3d511bebd 100644 --- a/minecraft/1.11/gradle.properties +++ b/minecraft/1.11/gradle.properties @@ -2,6 +2,7 @@ group = nova.core minecraft.version = 1.11 forge.version = 13.19.1.2189 +forgeGradleVersion = 2.2-SNAPSHOT packaging = jar info.inceptionYear = 2016 diff --git a/minecraft/1.7/gradle.properties b/minecraft/1.7/gradle.properties index dd8f10841..a1a1710e1 100644 --- a/minecraft/1.7/gradle.properties +++ b/minecraft/1.7/gradle.properties @@ -2,6 +2,7 @@ group = nova.core minecraft.version = 1.7.10 forge.version = 10.13.4.1448-1.7.10 +forgeGradleVersion = 1.2-SNAPSHOT packaging = jar info.inceptionYear = 2015 diff --git a/minecraft/1.8/gradle.properties b/minecraft/1.8/gradle.properties index 0298ba764..086b9c89c 100644 --- a/minecraft/1.8/gradle.properties +++ b/minecraft/1.8/gradle.properties @@ -2,6 +2,7 @@ group = nova.core minecraft.version = 1.8 forge.version = 11.14.3.1491 +forgeGradleVersion = 1.2-SNAPSHOT packaging = jar info.inceptionYear = 2015 diff --git a/minecraft/build.gradle b/minecraft/build.gradle index 2f4e0648d..905f27d09 100644 --- a/minecraft/build.gradle +++ b/minecraft/build.gradle @@ -1,16 +1,19 @@ -buildscript{ - repositories{ - mavenCentral() - maven { - name "forge" - url "http://files.minecraftforge.net/maven" +subprojects { + buildscript { + repositories { + mavenCentral() + maven { + name "forge" + url "http://files.minecraftforge.net/maven" + } + maven { + name "sonatype" + url "https://oss.sonatype.org/content/repositories/snapshots/" + } } - maven { - name "sonatype" - url "https://oss.sonatype.org/content/repositories/snapshots/" + dependencies { + // Minecraft 1.11 requires newer ForgeGradle, while 1.7 and 1.8 require older. + classpath 'net.minecraftforge.gradle:ForgeGradle:' + property('forgeGradleVersion') } } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } } From 910986a1d92d329db3a9b68a88a03bca063e74a2 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 18 Dec 2016 11:50:14 +0100 Subject: [PATCH 04/61] Created Access Transformer --- .../1.11/src/main/resources/META-INF/nova_at.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 minecraft/1.11/src/main/resources/META-INF/nova_at.cfg diff --git a/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg b/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg new file mode 100644 index 000000000..33402846a --- /dev/null +++ b/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg @@ -0,0 +1,12 @@ +# NOVA Access Transformer configuration file + +# Resource Pack +public net.minecraft.client.resources.AbstractResourcePack field_110597_b #resourcePackFile + +# Rendering +public net.minecraft.client.particle.ParticleManager field_178932_g # particleTypes +public net.minecraft.client.renderer.block.model.ModelBakery field_177608_m # itemModelGenerator +public net.minecraft.client.renderer.block.model.ModelBakery field_177606_o # MODEL_GENERATED +public net.minecraft.client.renderer.block.model.ModelBakery field_177609_j # textureMap +public net.minecraft.client.renderer.block.model.ModelBakery field_177599_g # sprites +public net.minecraft.client.renderer.block.model.ModelBakery func_177578_a(Lnet/minecraft/client/renderer/block/model/ModelBlock;Lnet/minecraft/client/renderer/block/model/ModelRotation;Z)Lnet/minecraft/client/renderer/block/model/IBakedModel; # models From 5495584d6ae6466642e26a70c0ad40cce851e3eb Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 18 Dec 2016 18:59:43 +0100 Subject: [PATCH 05/61] Ported utilities to 1.11. TODO: Figure out what to do with what was removed in Forge 1.9. --- .../mc/forge/v1_11/util/MCInputManager.java | 50 +++ .../forge/v1_11/util/MCLanguageManager.java | 55 +++ .../mc/forge/v1_11/util/ModCreativeTab.java | 53 +++ .../v1_11/util/ObfuscationConstants.java | 38 ++ .../mc/forge/v1_11/util/ReflectionUtil.java | 331 ++++++++++++++++++ .../mc/forge/v1_11/util/WrapUtility.java | 52 +++ .../mc/forge/v1_11/util/WrapperEvent.java | 63 ++++ 7 files changed, 642 insertions(+) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java new file mode 100644 index 000000000..aecf19e06 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import nova.core.game.InputManager; +import org.lwjgl.input.Keyboard; + +/** + * The MC KeyManager + * @author Calclavia + */ +// TODO: Does not work yet. Need a full map between the input and LWGL input. +public class MCInputManager extends InputManager { + + @Override + public void mapKeys() { + // Map jlwgl input to NOVA Keys, slightly hacky but functional. + for (Key key : Key.values()) { + try { + keys.put(Keyboard.class.getDeclaredField(key.name()).getInt(null), key); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + @Override + public boolean isKeyDown(Key key) { + // TODO: Sync this withPriority server side for server-side events. Need a packet manager + return Keyboard.isKeyDown(getNativeKeyCode(key)); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java new file mode 100644 index 000000000..5b7ad087b --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import net.minecraft.util.text.translation.I18n; +import net.minecraftforge.fml.common.FMLCommonHandler; +import nova.core.util.registry.LanguageManager; +import nova.internal.core.Game; + +/** + * @deprecated Removed in Forge 1.9 + * + * @author Calclavia + */ +@Deprecated +public class MCLanguageManager extends LanguageManager { + + @Override + public void register(String language, String key, String value) { +// LanguageRegistry.instance().addStringLocalization(key, language, value); + } + + @Override + public String getCurrentLanguage() { + return FMLCommonHandler.instance().getCurrentLanguage(); + } + + @Override + public String translate(String key) { + return I18n.translateToLocal(key); + } + + @Override + public void init() { + Game.events().publish(new Init(this)); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java new file mode 100644 index 000000000..ce419e932 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * @author Calclavia + */ +public class ModCreativeTab extends CreativeTabs { + public ItemStack item; + + public ModCreativeTab(String label, Item item) { + super(label); + + this.item = new ItemStack(item); + } + + public ModCreativeTab(String label, ItemStack item) { + super(label); + + this.item = item; + } + + public ModCreativeTab(String label) { + this(label, (Item) null); + } + + @Override + public ItemStack getTabIconItem() { + return item; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java new file mode 100644 index 000000000..fe6303417 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +/** + * @author Stan Hebben + */ +public class ObfuscationConstants { + public static final String[] NBTTAGLIST_TAGLIST = { "tagList", "field_74747_a" }; + public static final String[] OREDICTIONARY_IDTOSTACK = { "idToStack" }; + public static final String[] OREDICTIONARY_IDTOSTACKUN = { "idToStackUn" }; + public static final String[] MINECRAFTSERVER_ANVILFILE = { "anvilFile", "field_71308_o" }; + public static final String[] INVENTORYCRAFTING_EVENTHANDLER = { "eventHandler", "field_70465_c" }; + public static final String[] SLOTCRAFTING_PLAYER = { "thePlayer", "field_75238_b" }; + public static final String[] STRINGTRANSLATE_INSTANCE = { "instance", "field_74817_a" }; + public static final String[] CRAFTINGMANAGER_RECIPES = { "recipes", "field_77597_b" }; + + private ObfuscationConstants() { + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java new file mode 100644 index 000000000..05d787009 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java @@ -0,0 +1,331 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import com.google.common.collect.BiMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.WeightedRandom; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.util.text.translation.LanguageMap; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.fml.common.registry.EntityRegistry; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import java.io.File; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Common class for all runtime hacks (stuff requiring reflection). It is not + * unexpected to have it break withPriority new minecraft versions and may need regular + * adjustment - as such, those have been collected here. + * @author Stan Hebben + */ +public class ReflectionUtil { + private static final Field NBTTAGLIST_TAGLIST; + private static final Field OREDICTIONARY_IDTOSTACK; + private static final Field OREDICTIONARY_IDTOSTACKUN; + private static final Field MINECRAFTSERVER_ANVILFILE; + private static final Field SHAPEDORERECIPE_WIDTH; + private static final Field INVENTORYCRAFTING_EVENTHANDLER; + private static final Field SLOTCRAFTING_PLAYER; + + private static final Field ENTITYREGISTRY_CLASSREGISTRATIONS; + private static final Field SEEDENTRY_SEED; + private static final Constructor SEEDENTRY_CONSTRUCTOR; + + static { + NBTTAGLIST_TAGLIST = getField(NBTTagList.class, ObfuscationConstants.NBTTAGLIST_TAGLIST); + OREDICTIONARY_IDTOSTACK = getField(OreDictionary.class, ObfuscationConstants.OREDICTIONARY_IDTOSTACK); + OREDICTIONARY_IDTOSTACKUN = getField(OreDictionary.class, ObfuscationConstants.OREDICTIONARY_IDTOSTACKUN); + MINECRAFTSERVER_ANVILFILE = getField(MinecraftServer.class, ObfuscationConstants.MINECRAFTSERVER_ANVILFILE); + SHAPEDORERECIPE_WIDTH = getField(ShapedOreRecipe.class, new String[] { "width" }); + INVENTORYCRAFTING_EVENTHANDLER = getField(InventoryCrafting.class, ObfuscationConstants.INVENTORYCRAFTING_EVENTHANDLER); + SLOTCRAFTING_PLAYER = getField(SlotCrafting.class, ObfuscationConstants.SLOTCRAFTING_PLAYER); + + ENTITYREGISTRY_CLASSREGISTRATIONS = getField(EntityRegistry.class, new String[] { "entityClassRegistrations" }); + + Class forgeSeedEntry = null; + try { + forgeSeedEntry = (Class) Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry"); + } catch (ClassNotFoundException ex) { + } + + SEEDENTRY_SEED = getField(forgeSeedEntry, "seed"); + + Constructor seedEntryConstructor = null; + + try { + seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class); + seedEntryConstructor.setAccessible(true); + } catch (NoSuchMethodException ex) { + Logger.getLogger(ReflectionUtil.class.getName()).log(Level.SEVERE, null, ex); + } catch (SecurityException ex) { + Logger.getLogger(ReflectionUtil.class.getName()).log(Level.SEVERE, null, ex); + } + + SEEDENTRY_CONSTRUCTOR = seedEntryConstructor; + } + + private ReflectionUtil() { + } + + public static BiMap, EntityRegistry.EntityRegistration> getEntityClassRegistrations() { + try { + return (BiMap, EntityRegistry.EntityRegistration>) ENTITYREGISTRY_CLASSREGISTRATIONS.get(EntityRegistry.instance()); + } catch (IllegalArgumentException ex) { + return null; + } catch (IllegalAccessException ex) { + return null; + } + } + + public static List getTagList(NBTTagList list) { + if (NBTTAGLIST_TAGLIST == null) { + return null; + } + try { + return (List) NBTTAGLIST_TAGLIST.get(list); + } catch (IllegalArgumentException ex) { + return null; + } catch (IllegalAccessException ex) { + return null; + } + } + + public static List getSeeds() { + return getPrivateStaticObject(ForgeHooks.class, "seedList"); + } + + /** + * @deprecated Removed in Forge 1.9 + */ + @Deprecated + public static Map getChestLoot() { + return Collections.emptyMap();//getPrivateStaticObject(ChestGenHooks.class, "chestInfo"); + } + + public static Map getTranslations() { + return getPrivateObject( + getPrivateStaticObject(I18n.class, "localizedName", "field_74839_a"), + "languageList", + "field_74816_c"); + } + + public static List> getOreIdStacks() { + try { + return (List>) OREDICTIONARY_IDTOSTACK.get(null); + } catch (IllegalAccessException ex) { + logError("ERROR - could not load ore dictionary stacks!"); + return null; + } + } + + public static List> getOreIdStacksUn() { + try { + return (List>) OREDICTIONARY_IDTOSTACKUN.get(null); + } catch (IllegalAccessException ex) { + logError("ERROR - could not load ore dictionary stacks!"); + return null; + } + } + + public static File getAnvilFile(MinecraftServer server) { + try { + return (File) MINECRAFTSERVER_ANVILFILE.get(server); + } catch (IllegalAccessException ex) { + logError("could not load anvil file!"); + return null; + } + } + + public static File getWorldDirectory(MinecraftServer server) { + if (server.isDedicatedServer()) { + return server.getFile("world"); + } else { + File worldsDir = getAnvilFile(server); + if (worldsDir == null) { + return null; + } + + return new File(worldsDir, server.getFolderName()); + } + } + + public static int getShapedOreRecipeWidth(ShapedOreRecipe recipe) { + try { + return SHAPEDORERECIPE_WIDTH.getInt(recipe); + } catch (IllegalAccessException ex) { + logError("could not load shaped ore recipe width!"); + return 3; + } + } + + public static Container getCraftingContainer(InventoryCrafting inventory) { + try { + return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory); + } catch (IllegalAccessException ex) { + logError("could not get inventory eventhandler"); + return null; + } + } + + public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) { + try { + return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot); + } catch (IllegalAccessException ex) { + logError("could not get inventory eventhandler"); + return null; + } + } + + public static LanguageMap getStringTranslateInstance() { + try { + Field field = getField(LanguageMap.class, ObfuscationConstants.STRINGTRANSLATE_INSTANCE); + return (LanguageMap) field.get(null); + } catch (IllegalAccessException ex) { + logError("could not get string translator"); + return null; + } + } + + public static ItemStack getSeedEntrySeed(Object entry) { + try { + return (ItemStack) SEEDENTRY_SEED.get(entry); + } catch (IllegalAccessException ex) { + logError("could not get SeedEntry seed"); + return null; + } + } + + public static void setCraftingRecipeList(List craftingRecipeList) { + if (!setPrivateObject( + CraftingManager.getInstance(), + craftingRecipeList, + ObfuscationConstants.CRAFTINGMANAGER_RECIPES)) { + logError("could not set crafting recipe list"); + } + } + + /*public static WeightedRandom.Item constructSeedEntry(WeightedItemStack stack) { + try { + return SEEDENTRY_CONSTRUCTOR.newInstance(MineTweakerMC.getItemStack(stack.getStack()), (int) stack.getChance()); + } catch (InstantiationException ex) { + logError("could not construct SeedEntry"); + } catch (IllegalAccessException ex) { + logError("could not construct SeedEntry"); + } catch (IllegalArgumentException ex) { + logError("could not construct SeedEntry"); + } catch (InvocationTargetException ex) { + logError("could not construct SeedEntry"); + } + + return null; + }*/ + + public static T getPrivateStaticObject(Class cls, String... names) { + for (String name : names) { + try { + Field field = cls.getDeclaredField(name); + field.setAccessible(true); + return (T) field.get(null); + } catch (NoSuchFieldException ex) { + + } catch (SecurityException ex) { + + } catch (IllegalAccessException ex) { + + } + } + + return null; + } + + public static T getPrivateObject(Object object, String... names) { + Class cls = object.getClass(); + for (String name : names) { + try { + Field field = cls.getDeclaredField(name); + field.setAccessible(true); + return (T) field.get(object); + } catch (Exception ex) { + + } + } + + return null; + } + + public static boolean setPrivateObject(Object object, Object value, String... names) { + Class cls = object.getClass(); + for (String name : names) { + try { + Field field = cls.getDeclaredField(name); + field.setAccessible(true); + field.set(object, value); + return true; + } catch (Exception ex) { + + } + } + + return false; + } + + // ####################### + // ### Private Methods ### + // ####################### + + private static Field getField(Class cls, String... names) { + for (String name : names) { + try { + Field field = cls.getDeclaredField(name); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException ex) { + } catch (SecurityException ex) { + } + } + + return null; + } + + private static void logError(String message) { + System.out.println("ERROR: " + message); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java new file mode 100644 index 000000000..5edb8daa0 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import nova.core.entity.component.Player; + +import java.util.Objects; +import java.util.Optional; + +/** + * Wrap utility methods. + * @author Calclavia + */ +public class WrapUtility { + + public static Optional getNovaPlayer(EntityPlayer player) { + // TODO: implement + return Optional.empty(); + } + + public static String getItemID(Item item, int meta) { + if (item.getHasSubtypes()) { + return Item.REGISTRY.getNameForObject(item) + ":" + meta; + } else { + return (String) Objects.toString(Item.REGISTRY.getNameForObject(item)); + } + } + + public EntityPlayer getMCPlayer(Optional player) { + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java new file mode 100644 index 000000000..c783709f0 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.util; + +import nova.core.event.BlockEvent; +import nova.core.util.Direction; +import nova.core.world.World; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * Events for wrappers to hook into + * @author Calclavia + */ +public class WrapperEvent { + + public static class RedstoneConnect extends BlockEvent { + public final Direction direction; + public boolean canConnect; + + public RedstoneConnect(World world, Vector3D position, Direction direction) { + super(world, position); + this.direction = direction; + } + } + + public static class StrongRedstone extends BlockEvent { + public final Direction direction; + public int power; + + public StrongRedstone(World world, Vector3D position, Direction direction) { + super(world, position); + this.direction = direction; + } + } + + public static class WeakRedstone extends BlockEvent { + public final Direction direction; + public int power; + + public WeakRedstone(World world, Vector3D position, Direction direction) { + super(world, position); + this.direction = direction; + } + } +} From 46c27e924d2236c47e280500a9937ff04155758b Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 20 Dec 2016 00:58:17 +0100 Subject: [PATCH 06/61] Almost complete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: Fix asm. TileEntityTransformer doesn’t yet work, causing the game to crash with: java.lang.reflect.InvocationTargetException Caused by: java.lang.NoClassDefFoundError: net/minecraft/tileentity/TileEntity Caused by: java.lang.ClassNotFoundException: net.minecraft.tileentity.TileEntity Caused by: java.lang.NullPointerException --- .../mc/forge/v1_11/NovaMinecraftCore.java | 55 +++ .../forge/v1_11/NovaMinecraftPreloader.java | 313 ++++++++++++++ .../mc/forge/v1_11/asm/StaticForwarder.java | 66 +++ .../mc/forge/v1_11/asm/lib/ASMHelper.java | 391 ++++++++++++++++++ .../forge/v1_11/asm/lib/CC_ClassWriter.java | 56 +++ .../v1_11/asm/lib/ClassHeirachyManager.java | 209 ++++++++++ .../v1_11/asm/lib/ComponentInjector.java | 194 +++++++++ .../forge/v1_11/asm/lib/InsnListPrinter.java | 237 +++++++++++ .../v1_11/asm/lib/InstructionComparator.java | 253 ++++++++++++ .../mc/forge/v1_11/asm/lib/ObfMapping.java | 239 +++++++++++ .../forge/v1_11/asm/lib/TemplateInjector.java | 131 ++++++ .../mc/forge/v1_11/asm/lib/package-info.java | 27 ++ .../asm/transformers/ChunkTransformer.java | 65 +++ .../transformers/TileEntityTransformer.java | 68 +++ .../v1_11/asm/transformers/Transformer.java | 29 ++ .../v1_11/asm/transformers/Transformers.java | 60 +++ .../forge/v1_11/depmodules/ClientModule.java | 33 ++ .../v1_11/depmodules/ComponentModule.java | 36 ++ .../v1_11/depmodules/GameInfoModule.java | 43 ++ .../mc/forge/v1_11/depmodules/KeyModule.java | 34 ++ .../v1_11/depmodules/LanguageModule.java | 34 ++ .../forge/v1_11/depmodules/NetworkModule.java | 34 ++ .../forge/v1_11/depmodules/RenderModule.java | 34 ++ .../mc/forge/v1_11/depmodules/SaveModule.java | 34 ++ .../forge/v1_11/depmodules/TickerModule.java | 67 +++ .../mc/forge/v1_11/launcher/ClientProxy.java | 151 +++++++ .../mc/forge/v1_11/launcher/CommonProxy.java | 76 ++++ .../forge/v1_11/launcher/FMLEventHandler.java | 56 +++ .../v1_11/launcher/ForgeEventHandler.java | 89 ++++ .../forge/v1_11/launcher/NovaMinecraft.java | 245 +++++++++++ .../forge/v1_11/manager/FWClientManager.java | 43 ++ .../v1_11/manager/MCRetentionManager.java | 170 ++++++++ .../v1_11/manager/config/NovaGuiConfig.java | 35 ++ .../v1_11/manager/config/NovaGuiFactory.java | 52 +++ .../mc/forge/v1_11/network/MCPacket.java | 194 +++++++++ .../network/discriminator/NovaPacket.java | 76 ++++ .../network/discriminator/PacketAbstract.java | 74 ++++ .../discriminator/PacketPlayerItem.java | 83 ++++ .../v1_11/network/netty/ChannelHandler.java | 49 +++ .../v1_11/network/netty/MCNetworkManager.java | 164 ++++++++ .../v1_11/network/netty/MCPacketHandler.java | 57 +++ .../forge/v1_11/recipes/MCCraftingGrid.java | 255 ++++++++++++ .../forge/v1_11/recipes/MCCraftingRecipe.java | 61 +++ .../recipes/MinecraftItemIngredient.java | 34 ++ .../recipes/MinecraftRecipeRegistry.java | 321 ++++++++++++++ .../forge/v1_11/recipes/NovaCraftingGrid.java | 33 ++ .../recipes/NovaCraftingGridContainer.java | 42 ++ .../v1_11/recipes/NovaCraftingRecipe.java | 74 ++++ .../forge/v1_11/recipes/RecipeConverter.java | 268 ++++++++++++ .../v1_11/recipes/ShapedRecipeBasic.java | 57 +++ .../forge/v1_11/recipes/ShapedRecipeOre.java | 64 +++ .../v1_11/recipes/ShapelessRecipeBasic.java | 65 +++ .../v1_11/recipes/ShapelessRecipeOre.java | 58 +++ .../v1_11/render/NovaFolderResourcePack.java | 92 +++++ .../forge/v1_11/render/NovaResourcePack.java | 90 ++++ .../mc/forge/v1_11/render/RenderUtility.java | 291 +++++++++++++ .../forge/v1_11/wrapper/VectorConverter.java | 47 +++ .../v1_11/wrapper/block/BlockConverter.java | 162 ++++++++ .../v1_11/wrapper/block/backward/BWBlock.java | 158 +++++++ .../wrapper/block/forward/BlockPosition.java | 76 ++++ .../v1_11/wrapper/block/forward/FWBlock.java | 369 +++++++++++++++++ .../wrapper/block/forward/FWBlockSound.java | 67 +++ .../v1_11/wrapper/block/forward/FWTile.java | 151 +++++++ .../wrapper/block/forward/FWTileLoader.java | 75 ++++ .../wrapper/block/forward/FWTileRenderer.java | 60 +++ .../wrapper/block/forward/FWTileUpdater.java | 47 +++ .../block/forward/MCBlockTransform.java | 64 +++ .../wrapper/block/forward/ProxyMaterial.java | 34 ++ .../v1_11/wrapper/block/world/BWWorld.java | 171 ++++++++ .../wrapper/block/world/WorldConverter.java | 65 +++ .../v1_11/wrapper/cuboid/CuboidConverter.java | 51 +++ .../forge/v1_11/wrapper/data/DataWrapper.java | 163 ++++++++ .../v1_11/wrapper/entity/EntityConverter.java | 91 ++++ .../wrapper/entity/backward/BWEntity.java | 121 ++++++ .../wrapper/entity/forward/BWRigidBody.java | 203 +++++++++ .../wrapper/entity/forward/FWEntity.java | 217 ++++++++++ .../entity/forward/FWEntityRenderer.java | 126 ++++++ .../entity/forward/MCEntityTransform.java | 84 ++++ .../v1_11/wrapper/inventory/BWInventory.java | 71 ++++ .../v1_11/wrapper/inventory/FWInventory.java | 150 +++++++ .../wrapper/inventory/InventoryConverter.java | 59 +++ .../mc/forge/v1_11/wrapper/item/BWItem.java | 71 ++++ .../v1_11/wrapper/item/BWItemFactory.java | 82 ++++ .../mc/forge/v1_11/wrapper/item/FWItem.java | 72 ++++ .../forge/v1_11/wrapper/item/FWItemBlock.java | 68 +++ .../v1_11/wrapper/item/FWNBTTagCompound.java | 48 +++ .../v1_11/wrapper/item/ItemConverter.java | 334 +++++++++++++++ .../wrapper/item/ItemWrapperMethods.java | 68 +++ .../item/OreDictionaryIntegration.java | 86 ++++ .../wrapper/particle/backward/BWParticle.java | 198 +++++++++ .../wrapper/particle/forward/FWParticle.java | 147 +++++++ .../particle/forward/MCParticleTransform.java | 60 +++ .../wrapper/render/BWClientRenderManager.java | 62 +++ .../forge/v1_11/wrapper/render/BWModel.java | 123 ++++++ .../v1_11/wrapper/render/BWRenderManager.java | 39 ++ .../v1_11/wrapper/render/FWEmptyModel.java | 48 +++ .../wrapper/render/FWSmartBlockModel.java | 131 ++++++ .../wrapper/render/FWSmartItemModel.java | 103 +++++ .../v1_11/wrapper/render/FWSmartModel.java | 128 ++++++ .../src/main/resources/META-INF/nova_at.cfg | 18 + .../v1_11/launcher/NovaLauncherTest.java | 77 ++++ 101 files changed, 11006 insertions(+) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java create mode 100644 minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java new file mode 100644 index 000000000..ac9c77799 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11; + +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion; +import nova.core.wrapper.mc.forge.v1_11.asm.transformers.Transformers; + +import java.util.Map; + +@MCVersion(value = "1.11") +public class NovaMinecraftCore implements IFMLLoadingPlugin { + @Override + public String[] getASMTransformerClass() { + return new String[] { Transformers.class.getName() }; + } + + @Override + public String getModContainerClass() { + return "nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader"; + } + + @Override + public String getSetupClass() { + return null; + } + + @Override + public void injectData(Map data) { + + } + + @Override + public String getAccessTransformerClass() { + return null; + } +} \ No newline at end of file diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java new file mode 100644 index 000000000..c0613c5ac --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11; + +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import net.minecraft.client.resources.AbstractResourcePack; +import net.minecraft.client.resources.FileResourcePack; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.DummyModContainer; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.LoadController; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.discovery.ASMDataTable; +import net.minecraftforge.fml.common.event.FMLConstructionEvent; +import net.minecraftforge.fml.relauncher.FMLLaunchHandler; +import net.minecraftforge.fml.relauncher.Side; +import nova.core.loader.Mod; +import nova.core.util.ClassLoaderUtil; +import nova.core.wrapper.mc.forge.v1_11.render.NovaFolderResourcePack; +import nova.core.wrapper.mc.forge.v1_11.render.NovaResourcePack; +import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; + +import java.io.File; +import java.lang.reflect.Field; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class NovaMinecraftPreloader extends DummyModContainer { + public static final String version = "0.0.1"; + private static final ModMetadata md; + public static Set> modClasses; + + static { + md = new ModMetadata(); + md.modId = "novapreloader"; + md.name = "NOVA Preloader"; + md.version = version; + } + + public NovaMinecraftPreloader() { + super(md); + } + + /** + * Dynamically generates a sound JSON file based on a resource pack's file structure. + * + * If it's a folder, then load it as a sound collection. + * A sound collection falls under the same resource name. When called to play, it will pick a random sound from the collection to play it. + * + * If it's just a sound file, then load the sound file + */ + public static String generateSoundJSON(AbstractResourcePack pack) { + JsonObject fakeSoundJSON = new JsonObject(); + + for (String domain : (Set) pack.getResourceDomains()) { + + if (pack instanceof FileResourcePack) { + //For zip resource packs + try { + ZipFile zipFile = new ZipFile(pack.resourcePackFile); + + if (zipFile.getEntry("assets/" + domain + "/sounds/") != null) { + Enumeration zipEntries = zipFile.entries(); + + while (zipEntries.hasMoreElements()) { + String zipPath = ((ZipEntry) zipEntries.nextElement()).getName(); + + String prefix = "assets/" + domain + "/sounds/"; + if (zipPath.startsWith(prefix) && !zipPath.equals(prefix)) { + String soundName = zipPath.replaceFirst(prefix, "").replaceFirst("[.][^.]+$", ""); + ZipEntry entry = zipFile.getEntry(zipPath); + + if (!soundName.contains("/")) { + JsonObject sound = new JsonObject(); + sound.addProperty("category", "ambient"); + JsonArray sounds = new JsonArray(); + + if (entry.isDirectory()) { + //Sound Collection + Enumeration zipEntries2 = zipFile.entries(); + while (zipEntries2.hasMoreElements()) { + String zipPath2 = ((ZipEntry) zipEntries2.nextElement()).getName(); + + if (zipPath2.startsWith(prefix + soundName + "/") && !zipFile.getEntry(zipPath2).isDirectory()) { + String randomSoundName = zipPath2.replaceFirst(prefix + soundName + "/", ""); + sounds.add(new JsonPrimitive(soundName + "/" + randomSoundName.replaceFirst("[.][^.]+$", ""))); + } + } + } else { + sounds.add(new JsonPrimitive(soundName)); + } + sound.add("sounds", sounds); + fakeSoundJSON.add(soundName, sound); + } + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + throw new ExceptionInInitializerError("Error generating fake sound JSON file."); + } + } else { + //For folder resource packs + //Load all sounds in the assets/domain/sounds/* + File folder = new File(pack.resourcePackFile, "assets/" + domain + "/sounds/"); + + if (folder.exists()) { + File[] listOfFiles = folder.listFiles(); + + for (int i = 0; i < listOfFiles.length; i++) { + File listedFile = listOfFiles[i]; + + JsonObject sound = new JsonObject(); + sound.addProperty("category", "ambient"); + JsonArray sounds = new JsonArray(); + + String listedName = listedFile.getName().replaceFirst("[.][^.]+$", ""); + if (listedFile.isFile()) { + sounds.add(new JsonPrimitive(listedName)); + } else if (listedFile.isDirectory()) { + for (File soundItemFile : listedFile.listFiles()) + sounds.add(new JsonPrimitive(listedName + "/" + soundItemFile.getName().replaceFirst("[.][^.]+$", ""))); + } + + sound.add("sounds", sounds); + fakeSoundJSON.add(listedName, sound); + } + } + } + } + + return fakeSoundJSON.toString(); + } + + public static String generatePackMcmeta() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("description", "NOVA mod resource pack"); + jsonObject.addProperty("pack_format", "1"); + JsonObject outerObj = new JsonObject(); + outerObj.add("pack", jsonObject); + return outerObj.toString(); + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + bus.register(this); + return true; + } + + @Subscribe + public void load(FMLConstructionEvent event) { + try { + //TODO: Use AT + //Apache Commons Hack + Field launchHandlerField = FMLLaunchHandler.class.getDeclaredField("INSTANCE"); + launchHandlerField.setAccessible(true); + FMLLaunchHandler launchHandler = (FMLLaunchHandler) launchHandlerField.get(null); + Field clField = FMLLaunchHandler.class.getDeclaredField("classLoader"); + clField.setAccessible(true); + LaunchClassLoader classLoader = (LaunchClassLoader) clField.get(launchHandler); + //Obfuscation? + Field setField = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions"); + setField.setAccessible(true); + Set classLoaderExceptions = (Set) setField.get(classLoader); + classLoaderExceptions.remove("org.apache."); + System.out.println("Successfully hacked 'org.apache' out of launcher exclusion"); + } catch (Exception e) { + throw new ClassLoaderUtil.ClassLoaderException(e); + } + + // Scan mod classes + ASMDataTable asmData = event.getASMHarvestedData(); + + modClasses = asmData + .getAll(Mod.class.getName()) + .stream() + .map(ASMDataTable.ASMData::getClassName) + .map(c -> { + try { + return Class.forName(c); + } catch (ClassNotFoundException e) { + throw new ExceptionInInitializerError(e); + } + }) + .collect(Collectors.toSet()); + + //Inject fake mod containers into FML + List fmlMods = ReflectionUtil.getPrivateObject(Loader.instance(), "mods"); + List newMods = new ArrayList<>(); + newMods.addAll(fmlMods); + modClasses.forEach(mod -> { + ModMetadata fakeMeta = new ModMetadata(); + Mod annotation = mod.getAnnotation(Mod.class); + fakeMeta.modId = annotation.id(); + fakeMeta.name = annotation.name(); + fakeMeta.version = annotation.version(); + fakeMeta.description = annotation.description(); + newMods.add(new DummyNovaMod(fakeMeta)); + }); + //TODO: Use AT + ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); + + // Register resource packs + if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { + registerResourcePacks(); + } + } + + public void registerResourcePacks() { + Map> classesMap = modClasses + .stream() + .filter(clazz -> clazz.getAnnotation(Mod.class) != null) + .collect(Collectors.toMap((clazz) -> clazz.getAnnotation(Mod.class), Function.identity())); + + try { + // The same list exists in the Minecraft class, but that can be SRG or not. + // Reflecting FML is just less work for us. (Minecraft.field_110449_ao) + Field resourcePackField = FMLClientHandler.class.getDeclaredField("resourcePackList"); + resourcePackField.setAccessible(true); + List packs = (List) resourcePackField.get(FMLClientHandler.instance()); + + Set addedPacks = new HashSet<>(); + + classesMap.keySet().forEach(novaMod -> { + Class c = classesMap.get(novaMod); + + //Add jar resource pack + String fn = c.getProtectionDomain().getCodeSource().getLocation().toExternalForm(); + + if (fn.contains("!")) { + fn = fn.substring(0, fn.indexOf('!')).replaceFirst("jar:", ""); + File file; + try { + file = new File(new URL(fn).toURI()); + } catch (MalformedURLException | URISyntaxException e) { + file = new File(fn); //This will probably not work on Windows, but we can at least try + } + + if (!addedPacks.contains(fn)) { + addedPacks.add(fn); + packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); + 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("\\.", "/"); + folderLocation = folderLocation.replaceFirst("file:", "").replace(classPath, "").replace("/.class", "").replaceAll("%20", " "); + File folderFile = new File(folderLocation); + if (!new File(folderFile, "assets").isDirectory()) { + //Try IDEA workaround. + folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); + folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); + } + + addedPacks.add(folderLocation); + packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); + System.out.println("Registered NOVA folder resource pack: " + folderFile.getAbsolutePath()); + } + }); + resourcePackField.set(FMLClientHandler.instance(), packs); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * A fake NovaMod to inject into FML. + */ + private static class DummyNovaMod extends DummyModContainer { + public DummyNovaMod(ModMetadata meta) { + super(meta); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java new file mode 100644 index 000000000..43dc0a3e9 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import nova.core.event.BlockEvent; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileLoader; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * Static forwarder forwards injected methods. + * @author Calclavia + */ +public class StaticForwarder { + + public static void chunkSetBlockEvent(Chunk chunk, BlockPos pos, IBlockState oldBlockState, IBlockState newBlockState) { + // Publish the event + Game.events().publish( + new BlockEvent.Change( + Game.natives().toNova(chunk.getWorld()), + new Vector3D((chunk.xPosition << 4) + pos.getX(), pos.getY(), (chunk.zPosition << 4) + pos.getZ()), + Game.natives().toNova(oldBlockState.getBlock()), Game.natives().toNova(newBlockState.getBlock()) + ) + ); + } + + /** + * Used to inject forwarded TileEntites + * @param data + * @param clazz + * @return + * @throws Exception + */ + public static TileEntity loadTileEntityHook(World world, NBTTagCompound data, Class clazz) throws Exception { + if (FWTile.class.isAssignableFrom(clazz)) { + return FWTileLoader.loadTile(data); + } else { + return clazz.newInstance(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java new file mode 100644 index 000000000..956054244 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import net.minecraft.launchwrapper.LaunchClassLoader; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.LocalVariableNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TryCatchBlockNode; + +import java.lang.reflect.Executable; +import java.lang.reflect.Method; +import java.security.ProtectionDomain; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.objectweb.asm.Opcodes.ARETURN; +import static org.objectweb.asm.Opcodes.DRETURN; +import static org.objectweb.asm.Opcodes.FRETURN; +import static org.objectweb.asm.Opcodes.IRETURN; +import static org.objectweb.asm.Opcodes.LRETURN; +import static org.objectweb.asm.Opcodes.RET; +import static org.objectweb.asm.Opcodes.RETURN; + +/** + * @author ChickenBones + */ +public class ASMHelper { + public static LaunchClassLoader cl = (LaunchClassLoader) ASMHelper.class.getClassLoader(); + private static Method defineClass1; + private static Method defineClass2; + + static { + try { + defineClass1 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class }); + defineClass2 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class, ProtectionDomain.class }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static MethodNode findMethod(ObfMapping methodmap, ClassNode cnode) { + for (MethodNode mnode : cnode.methods) { + if (methodmap.matches(mnode)) { + return mnode; + } + } + return null; + } + + public static FieldNode findField(ObfMapping fieldmap, ClassNode cnode) { + for (FieldNode fnode : cnode.fields) { + if (fieldmap.matches(fnode)) { + return fnode; + } + } + return null; + } + + public static ClassNode createClassNode(byte[] bytes) { + return createClassNode(bytes, 0); + } + + public static ClassNode createClassNode(byte[] bytes, int flags) { + ClassNode cnode = new ClassNode(); + ClassReader reader = new ClassReader(bytes); + reader.accept(cnode, flags); + return cnode; + } + + public static byte[] createBytes(ClassNode cnode, int flags) { + ClassWriter cw = new CC_ClassWriter(flags); + cnode.accept(cw); + return cw.toByteArray(); + } + + public static byte[] writeMethods(String name, byte[] bytes, Multimap writers) { + if (writers.containsKey(name)) { + ClassNode cnode = createClassNode(bytes); + + for (MethodWriter mw : writers.get(name)) { + MethodNode mv = findMethod(mw.method, cnode); + if (mv == null) { + mv = (MethodNode) cnode.visitMethod(mw.access, mw.method.s_name, mw.method.s_desc, null, mw.exceptions); + } + + mv.access = mw.access; + mv.instructions.clear(); + mw.write(mv); + } + + bytes = createBytes(cnode, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + } + return bytes; + } + + public static byte[] injectMethods(String name, byte[] bytes, Multimap injectors) { + if (injectors.containsKey(name)) { + ClassNode cnode = createClassNode(bytes); + + for (MethodInjector injector : injectors.get(name)) { + MethodNode method = findMethod(injector.method, cnode); + if (method == null) { + throw new RuntimeException("Method not found: " + injector.method); + } + System.out.println("Injecting into " + injector.method + "\n" + printInsnList(injector.injection)); + + List callNodes; + if (injector.before) { + callNodes = InstructionComparator.insnListFindStart(method.instructions, injector.needle); + } else { + callNodes = InstructionComparator.insnListFindEnd(method.instructions, injector.needle); + } + + if (callNodes.size() == 0) { + throw new RuntimeException("Needle not found in Haystack: " + injector.method + "\n" + printInsnList(injector.needle)); + } + + for (AbstractInsnNode node : callNodes) { + if (injector.before) { + System.out.println("Injected before: " + printInsn(node)); + method.instructions.insertBefore(node, cloneInsnList(injector.injection)); + } else { + System.out.println("Injected after: " + printInsn(node)); + method.instructions.insert(node, cloneInsnList(injector.injection)); + } + } + } + + bytes = createBytes(cnode, ClassWriter.COMPUTE_FRAMES); + } + return bytes; + } + + public static String printInsnList(InsnList list) { + InsnListPrinter p = new InsnListPrinter(); + p.visitInsnList(list); + return p.textString(); + } + + public static String printInsn(AbstractInsnNode insn) { + InsnListPrinter p = new InsnListPrinter(); + p.visitInsn(insn); + return p.textString(); + } + + public static Map cloneLabels(InsnList insns) { + HashMap labelMap = new HashMap(); + for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext()) { + if (insn.getType() == 8) { + labelMap.put((LabelNode) insn, new LabelNode()); + } + } + return labelMap; + } + + public static InsnList cloneInsnList(InsnList insns) { + return cloneInsnList(cloneLabels(insns), insns); + } + + public static InsnList cloneInsnList(Map labelMap, InsnList insns) { + InsnList clone = new InsnList(); + for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext()) { + clone.add(insn.clone(labelMap)); + } + + return clone; + } + + public static List cloneTryCatchBlocks(Map labelMap, List tcblocks) { + ArrayList clone = new ArrayList(); + for (TryCatchBlockNode node : tcblocks) { + clone.add(new TryCatchBlockNode(labelMap.get(node.start), labelMap.get(node.end), labelMap.get(node.handler), node.type)); + } + + return clone; + } + + public static List cloneLocals(Map labelMap, List locals) { + ArrayList clone = new ArrayList(); + for (LocalVariableNode node : locals) { + clone.add(new LocalVariableNode(node.name, node.desc, node.signature, labelMap.get(node.start), labelMap.get(node.end), node.index)); + } + + return clone; + } + + public static void copy(MethodNode src, MethodNode dst) { + Map labelMap = cloneLabels(src.instructions); + dst.instructions = cloneInsnList(labelMap, src.instructions); + dst.tryCatchBlocks = cloneTryCatchBlocks(labelMap, src.tryCatchBlocks); + if (src.localVariables != null) { + dst.localVariables = cloneLocals(labelMap, src.localVariables); + } + dst.visibleAnnotations = src.visibleAnnotations; + dst.invisibleAnnotations = src.invisibleAnnotations; + dst.visitMaxs(src.maxStack, src.maxLocals); + } + + public static byte[] alterMethods(String name, byte[] bytes, HashMultimap altercators) { + if (altercators.containsKey(name)) { + ClassNode cnode = createClassNode(bytes); + + for (MethodAlterator injector : altercators.get(name)) { + MethodNode method = findMethod(injector.method, cnode); + if (method == null) { + throw new RuntimeException("Method not found: " + injector.method); + } + + injector.alter(method); + } + + bytes = createBytes(cnode, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); + } + return bytes; + } + + public static int getLocal(List list, String name) { + int found = -1; + for (LocalVariableNode node : list) { + if (node.name.equals(name)) { + if (found >= 0) { + throw new RuntimeException("Duplicate local variable: " + name + " not coded to handle this scenario."); + } + + found = node.index; + } + } + return found; + } + + public static void replaceMethodCode(MethodNode original, MethodNode replacement) { + original.instructions.clear(); + if (original.localVariables != null) { + original.localVariables.clear(); + } + if (original.tryCatchBlocks != null) { + original.tryCatchBlocks.clear(); + } + replacement.accept(original); + } + + public static String printInsnList(InstructionComparator.InsnListSection subsection) { + InsnListPrinter p = new InsnListPrinter(); + p.visitInsnList(subsection); + return p.textString(); + } + + public static void removeBlock(InsnList insns, InstructionComparator.InsnListSection block) { + AbstractInsnNode insn = block.first; + while (true) { + AbstractInsnNode next = insn.getNext(); + insns.remove(insn); + if (insn == block.last) { + break; + } + insn = next; + } + } + + public static boolean isReturn(AbstractInsnNode node) { + switch (node.getOpcode()) { + case RET: + case RETURN: + case ARETURN: + case DRETURN: + case FRETURN: + case IRETURN: + case LRETURN: + return true; + + default: + return false; + } + } + + public static String[] getExceptionTypes(Executable exec) { + return Arrays.stream(exec.getExceptionTypes()).map(Type::getInternalName).toArray(s -> new String[s]); + } + + public static Class defineClass(ClassNode cn, int flags) { + try { + byte[] bytes = createBytes(cn, flags); + defineClass1.setAccessible(true); + Class clazz = (Class) defineClass1.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length); + defineClass1.setAccessible(false); + return clazz; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static Class defineClass(ClassNode cn, int flags, ProtectionDomain domain) { + if (domain == null) { + return defineClass(cn, flags); + } + try { + byte[] bytes = createBytes(cn, flags); + defineClass2.setAccessible(true); + Class clazz = (Class) defineClass2.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length, domain); + defineClass2.setAccessible(false); + return clazz; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static class CodeBlock { + public Label start = new Label(); + public Label end = new Label(); + } + + public static class ForBlock extends CodeBlock { + public Label cmp = new Label(); + public Label inc = new Label(); + public Label body = new Label(); + } + + public static abstract class MethodAlterator { + public final ObfMapping method; + + public MethodAlterator(ObfMapping method) { + this.method = method; + } + + public abstract void alter(MethodNode mv); + } + + public static abstract class MethodWriter { + public final int access; + public final ObfMapping method; + public final String[] exceptions; + + public MethodWriter(int access, ObfMapping method) { + this(access, method, null); + } + + public MethodWriter(int access, ObfMapping method, String[] exceptions) { + this.access = access; + this.method = method; + this.exceptions = exceptions; + } + + public abstract void write(MethodNode mv); + } + + public static class MethodInjector { + public final ObfMapping method; + public final InsnList needle; + public final InsnList injection; + public final boolean before; + + public MethodInjector(ObfMapping method, InsnList needle, InsnList injection, boolean before) { + this.method = method; + this.needle = needle; + this.injection = injection; + this.before = before; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java new file mode 100644 index 000000000..383fd30a0 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import org.objectweb.asm.ClassWriter; + +/** + * @author ChickenBones + */ +public class CC_ClassWriter extends ClassWriter { + private final boolean runtime; + + public CC_ClassWriter(int flags) { + this(flags, false); + } + + public CC_ClassWriter(int flags, boolean runtime) { + super(flags); + this.runtime = runtime; + } + + @Override + protected String getCommonSuperClass(String type1, String type2) { + String c = type1.replace('/', '.'); + String d = type2.replace('/', '.'); + if (ClassHeirachyManager.classExtends(d, c)) { + return type1; + } + if (ClassHeirachyManager.classExtends(c, d)) { + return type2; + } + do { + c = ClassHeirachyManager.getSuperClass(c, runtime); + } + while (!ClassHeirachyManager.classExtends(d, c)); + return c.replace('.', '/'); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java new file mode 100644 index 000000000..726369343 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import nova.internal.core.Game; +import org.objectweb.asm.tree.ClassNode; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +/** + * This is added as a class transformer if CodeChickenCore is installed. Adding it as a class + * transformer will speed evaluation up slightly by automatically caching superclasses when they are + * first loaded. + */ +public class ClassHeirachyManager implements IClassTransformer { + public static HashMap superclasses = new HashMap(); + private static LaunchClassLoader cl = (LaunchClassLoader) ClassHeirachyManager.class.getClassLoader(); + + static { + cl.addTransformerExclusion("codechicken.lib.asm"); + } + + public static String toKey(String name) { + if (ObfMapping.obfuscated) { + name = FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.', '/')).replace('/', '.'); + } + return name; + } + + public static String unKey(String name) { + if (ObfMapping.obfuscated) { + name = FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/', '.'); + } + return name; + } + + /** + * Returns true if clazz extends, either directly or indirectly, superclass. + * @param name The class in question + * @param superclass The class being extended + * @return + */ + public static boolean classExtends(String name, String superclass) { + name = toKey(name); + superclass = toKey(superclass); + + if (name.equals(superclass)) { + return true; + } + + SuperCache cache = declareClass(name); + if (cache == null)// just can't handle this + { + return false; + } + + cache.flatten(); + return cache.parents.contains(superclass); + } + + private static SuperCache declareClass(String name) { + name = toKey(name); + SuperCache cache = superclasses.get(name); + + if (cache != null) { + return cache; + } + + try { + byte[] bytes = cl.getClassBytes(unKey(name)); + if (bytes != null) { + cache = declareASM(bytes); + } + } catch (IOException e) { + Game.logger().error(e.getMessage()); + } + + if (cache != null) { + return cache; + } + + try { + cache = declareReflection(name); + } catch (ClassNotFoundException e) { + Game.logger().error(e.getMessage()); + } + + return cache; + } + + private static SuperCache declareReflection(String name) throws ClassNotFoundException { + Class aclass = Class.forName(name); + + SuperCache cache = getOrCreateCache(name); + if (aclass.isInterface()) { + cache.superclass = "java.lang.Object"; + } else if (name.equals("java.lang.Object")) { + return cache; + } else { + cache.superclass = toKey(aclass.getSuperclass().getName()); + } + + cache.add(cache.superclass); + for (Class iclass : aclass.getInterfaces()) { + cache.add(toKey(iclass.getName())); + } + + return cache; + } + + private static SuperCache declareASM(byte[] bytes) { + ClassNode node = ASMHelper.createClassNode(bytes); + String name = toKey(node.name); + + SuperCache cache = getOrCreateCache(name); + cache.superclass = toKey(node.superName.replace('/', '.')); + cache.add(cache.superclass); + for (String iclass : node.interfaces) { + cache.add(toKey(iclass.replace('/', '.'))); + } + + return cache; + } + + public static SuperCache getOrCreateCache(String name) { + SuperCache cache = superclasses.get(name); + if (cache == null) { + superclasses.put(name, cache = new SuperCache()); + } + return cache; + } + + public static String getSuperClass(String name, boolean runtime) { + name = toKey(name); + SuperCache cache = declareClass(name); + if (cache == null) { + return "java.lang.Object"; + } + + cache.flatten(); + String s = cache.superclass; + if (!runtime) { + s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s); + } + return s; + } + + @Override + public byte[] transform(String name, String tname, byte[] bytes) { + if (bytes == null) { + return null; + } + + if (!superclasses.containsKey(tname)) { + declareASM(bytes); + } + + return bytes; + } + + public static class SuperCache { + public HashSet parents = new HashSet(); + String superclass; + private boolean flattened; + + public void add(String parent) { + parents.add(parent); + } + + public void flatten() { + if (flattened) { + return; + } + + for (String s : new ArrayList(parents)) { + SuperCache c = declareClass(s); + if (c != null) { + c.flatten(); + parents.addAll(c.parents); + } + } + flattened = true; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java new file mode 100644 index 000000000..28b1ea0fa --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import nova.core.component.Component; +import nova.core.component.ComponentProvider; +import nova.core.component.Passthrough; +import nova.core.network.NetworkTarget.Side; +import nova.core.util.ClassLoaderUtil; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.ClassNode; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * The ComponentInjector is capable of creating dynamic classes that implement a + * specified super class and implement the interfaces specified by + * {@link Component} and {@link Passthrough}. + * @param + * @author Vic Nightfall + */ +public class ComponentInjector implements Opcodes { + + private Class baseClazz; + + /** + * Cache, contains already created class objects for later use + */ + private Map>, Class> cache = new HashMap<>(); + + public ComponentInjector(Class baseClazz) { + this.baseClazz = baseClazz; + } + + public synchronized T inject(ComponentProvider provider, Class[] typeArgs, Object[] args) { + try { + List components = provider.components().stream() + .filter(component -> component.getClass().getAnnotationsByType(Passthrough.class).length > 0) + .collect(Collectors.toList()); + + if (components.size() > 0) { + List> componentClazzes = components.stream().map(c -> c.getClass()).collect(Collectors.toList()); + System.out.println(Side.get() + " " + componentClazzes); + if (cache.containsKey(componentClazzes)) + // Cached class + { + return inject(cache.get(componentClazzes).getConstructor(typeArgs).newInstance(args), provider); + } else { + Class clazz = construct(componentClazzes); + cache.put(componentClazzes, clazz); + return inject(clazz.getConstructor(typeArgs).newInstance(args), provider); + } + + } else { + // No components withPriority passthrough interfaces, we can use the + // base class. + return baseClazz.getConstructor(typeArgs).newInstance(args); + } + } catch (Exception e) { + throw new ClassLoaderUtil.ClassLoaderException("Failed to construct wrapper class for " + baseClazz, e); + } + } + + private T inject(T instance, ComponentProvider provider) throws ReflectiveOperationException { + Field f = instance.getClass().getDeclaredField("$$_provider"); + f.setAccessible(true); + f.set(instance, provider); + f.setAccessible(false); + return instance; + } + + private Class construct(List> components) { + + // Map components to specified wrapped interfaces + Map, Class> intfComponentMap = new HashMap<>(); + for (Class component : components) { + for (Passthrough pt : component.getAnnotationsByType(Passthrough.class)) { + Class intf; + try { + intf = Class.forName(pt.value()); + } catch (ClassNotFoundException exec) { + throw new ClassLoaderUtil.ClassLoaderException("Invalid passthrough \"%s\" on component %s, the specified interface doesn't exist.", pt.value(), component); + } + if (!intf.isAssignableFrom(component)) { + throw new ClassLoaderUtil.ClassLoaderException("Invalid passthrough \"%s\" on component %s, the specified interface isn't implemented.", pt.value(), component); + } + if (intfComponentMap.containsKey(intf)) { + throw new ClassLoaderUtil.ClassLoaderException("Duplicate Passthrough interface found: %s (%s, %s)", pt.value(), component, intfComponentMap.get(intf)); + } + intfComponentMap.put(intf, component); + } + } + + // Create new ClassNode from cached bytes + ClassNode clazzNode = new ClassNode(); + String name = Type.getInternalName(baseClazz); + String classname = name + "_$$_NOVA_" + cache.size(); + + // Inject block field + clazzNode.visit(V1_8, ACC_PUBLIC | ACC_SUPER, classname, null, name, intfComponentMap.keySet().stream().map(Type::getInternalName).toArray(s -> new String[s])); + clazzNode.visitField(ACC_PRIVATE | ACC_FINAL, "$$_provider", Type.getDescriptor(ComponentProvider.class), null, null).visitEnd(); + + // Add constructors + for (Constructor constructor : baseClazz.getConstructors()) { + int mod = constructor.getModifiers(); + String descr = Type.getConstructorDescriptor(constructor); + + if (Modifier.isFinal(mod) || Modifier.isPrivate(mod)) { + continue; + } + MethodVisitor mv = clazzNode.visitMethod(mod, "", descr, null, ASMHelper.getExceptionTypes(constructor)); + + // Call super constructor + mv.visitCode(); + // load this + mv.visitVarInsn(ALOAD, 0); + Class[] parameters = constructor.getParameterTypes(); + for (int i = 0; i < constructor.getParameterCount(); i++) { + // variables + mv.visitVarInsn(Type.getType(parameters[i]).getOpcode(ILOAD), i + 1); + } + mv.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(baseClazz), "", descr, false); + // return + mv.visitInsn(RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + + // Add methods + for (Class intf : intfComponentMap.keySet()) { + // Create class constant + Type clazzConst = Type.getType(intf.getClass()); + + for (Method m : intf.getMethods()) { + boolean isVoid = m.getReturnType() == null; + String descr = Type.getMethodDescriptor(m); + + MethodVisitor mv = clazzNode.visitMethod(ACC_PUBLIC, m.getName(), descr, null, ASMHelper.getExceptionTypes(m)); + mv.visitCode(); + + // load block instance + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, classname, "$$_provider", Type.getDescriptor(ComponentProvider.class)); + mv.visitLdcInsn(clazzConst); + // load component instance + mv.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(ComponentProvider.class), "get", Type.getMethodDescriptor(Type.getType(Component.class), Type.getType(Class.class)), false); + + // add parameters + Class[] parameters = m.getParameterTypes(); + for (int i = 0; i < m.getParameterCount(); i++) { + mv.visitVarInsn(Type.getType(parameters[i]).getOpcode(ILOAD), i + 1); + } + + // invoke + mv.visitMethodInsn(INVOKEINTERFACE, Type.getInternalName(intf), m.getName(), descr, true); + mv.visitInsn(isVoid ? RETURN : Type.getType(m.getReturnType()).getOpcode(IRETURN)); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + } + + clazzNode.visitEnd(); + + return ASMHelper.defineClass(clazzNode, ClassWriter.COMPUTE_MAXS, baseClazz.getProtectionDomain()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java new file mode 100644 index 000000000..4a5cba910 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import org.objectweb.asm.Label; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FrameNode; +import org.objectweb.asm.tree.IincInsnNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.IntInsnNode; +import org.objectweb.asm.tree.InvokeDynamicInsnNode; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.LdcInsnNode; +import org.objectweb.asm.tree.LineNumberNode; +import org.objectweb.asm.tree.LookupSwitchInsnNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MultiANewArrayInsnNode; +import org.objectweb.asm.tree.TableSwitchInsnNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.VarInsnNode; +import org.objectweb.asm.util.Textifier; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.HashMap; + +public class InsnListPrinter extends Textifier { + private boolean buildingLabelMap = false; + + public InsnListPrinter() { + super(Opcodes.ASM5); + } + + public void visitInsnList(InsnList list) { + text.clear(); + if (labelNames == null) { + labelNames = new HashMap(); + } else { + labelNames.clear(); + } + + buildingLabelMap = true; + for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { + if (insn.getType() == 8) { + visitLabel(((LabelNode) insn).getLabel()); + } + } + + text.clear(); + buildingLabelMap = false; + + for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { + _visitInsn(insn); + } + } + + public void visitInsnList(InstructionComparator.InsnListSection subsection) { + text.clear(); + if (labelNames == null) { + labelNames = new HashMap(); + } else { + labelNames.clear(); + } + + buildingLabelMap = true; + { + AbstractInsnNode insn = subsection.first; + while (true) { + if (insn.getType() == 8) { + visitLabel(((LabelNode) insn).getLabel()); + } + if (insn == subsection.last) { + break; + } + insn = insn.getNext(); + } + } + + text.clear(); + buildingLabelMap = false; + + { + AbstractInsnNode insn = subsection.first; + while (true) { + _visitInsn(insn); + if (insn == subsection.last) { + break; + } + insn = insn.getNext(); + } + } + } + + public void visitInsn(AbstractInsnNode insn) { + text.clear(); + if (labelNames == null) { + labelNames = new HashMap(); + } else { + labelNames.clear(); + } + + _visitInsn(insn); + } + + private void _visitInsn(AbstractInsnNode insn) { + switch (insn.getType()) { + case 0: + visitInsn(insn.getOpcode()); + break; + case 1: + IntInsnNode iinsn = (IntInsnNode) insn; + visitIntInsn(iinsn.getOpcode(), iinsn.operand); + break; + case 2: + VarInsnNode vinsn = (VarInsnNode) insn; + visitVarInsn(vinsn.getOpcode(), vinsn.var); + break; + case 3: + TypeInsnNode tinsn = (TypeInsnNode) insn; + visitTypeInsn(tinsn.getOpcode(), tinsn.desc); + break; + case 4: + FieldInsnNode finsn = (FieldInsnNode) insn; + visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc); + break; + case 5: + MethodInsnNode minsn = (MethodInsnNode) insn; + visitMethodInsn(minsn.getOpcode(), minsn.owner, minsn.name, minsn.desc); + break; + case 6: + InvokeDynamicInsnNode idinsn = (InvokeDynamicInsnNode) insn; + visitInvokeDynamicInsn(idinsn.name, idinsn.desc, idinsn.bsm, idinsn.bsmArgs); + break; + case 7: + JumpInsnNode jinsn = (JumpInsnNode) insn; + visitJumpInsn(jinsn.getOpcode(), jinsn.label.getLabel()); + break; + case 8: + LabelNode linsn = (LabelNode) insn; + visitLabel(linsn.getLabel()); + break; + case 9: + LdcInsnNode ldcinsn = (LdcInsnNode) insn; + visitLdcInsn(ldcinsn.cst); + break; + case 10: + IincInsnNode iiinsn = (IincInsnNode) insn; + visitIincInsn(iiinsn.var, iiinsn.incr); + break; + case 11: + TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn; + Label[] tslables = new Label[tsinsn.labels.size()]; + for (int i = 0; i < tslables.length; i++) { + tslables[i] = tsinsn.labels.get(i).getLabel(); + } + visitTableSwitchInsn(tsinsn.min, tsinsn.max, tsinsn.dflt.getLabel(), tslables); + break; + case 12: + LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn; + Label[] lslables = new Label[lsinsn.labels.size()]; + for (int i = 0; i < lslables.length; i++) { + lslables[i] = lsinsn.labels.get(i).getLabel(); + } + int[] lskeys = new int[lsinsn.keys.size()]; + for (int i = 0; i < lskeys.length; i++) { + lskeys[i] = lsinsn.keys.get(i); + } + visitLookupSwitchInsn(lsinsn.dflt.getLabel(), lskeys, lslables); + break; + case 13: + MultiANewArrayInsnNode ainsn = (MultiANewArrayInsnNode) insn; + visitMultiANewArrayInsn(ainsn.desc, ainsn.dims); + break; + case 14: + FrameNode fnode = (FrameNode) insn; + switch (fnode.type) { + case -1: + case 0: + visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), fnode.stack.size(), fnode.stack.toArray()); + break; + case 1: + visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), 0, null); + break; + case 2: + visitFrame(fnode.type, fnode.local.size(), null, 0, null); + break; + case 3: + visitFrame(fnode.type, 0, null, 0, null); + break; + case 4: + visitFrame(fnode.type, 0, null, 1, fnode.stack.toArray()); + } + break; + case 15: + LineNumberNode lnode = (LineNumberNode) insn; + visitLineNumber(lnode.line, lnode.start.getLabel()); + break; + } + } + + @Override + public void visitLabel(Label label) { + if (!buildingLabelMap && !labelNames.containsKey(label)) { + labelNames.put(label, "LEXT" + labelNames.size()); + } + super.visitLabel(label); + } + + public String textString() { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + print(pw); + pw.flush(); + return sw.toString(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java new file mode 100644 index 000000000..df12d50f4 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.IincInsnNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.IntInsnNode; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.LdcInsnNode; +import org.objectweb.asm.tree.LineNumberNode; +import org.objectweb.asm.tree.LookupSwitchInsnNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.TableSwitchInsnNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.VarInsnNode; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; + +import static org.objectweb.asm.tree.AbstractInsnNode.FIELD_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.IINC_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.INT_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.LDC_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.METHOD_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.TYPE_INSN; +import static org.objectweb.asm.tree.AbstractInsnNode.VAR_INSN; + +public class InstructionComparator { + public static boolean varInsnEqual(VarInsnNode insn1, VarInsnNode insn2) { + return insn1.var == -1 || insn2.var == -1 || insn1.var == insn2.var; + } + + public static boolean methodInsnEqual(AbstractInsnNode absnode, int Opcode, ObfMapping method) { + return absnode.getOpcode() == Opcode && absnode instanceof MethodInsnNode && method.matches((MethodInsnNode) absnode); + } + + public static boolean methodInsnEqual(MethodInsnNode insn1, MethodInsnNode insn2) { + return insn1.owner.equals(insn2.owner) && insn1.name.equals(insn2.name) && insn1.desc.equals(insn2.desc); + } + + public static boolean fieldInsnEqual(FieldInsnNode insn1, FieldInsnNode insn2) { + return insn1.owner.equals(insn2.owner) && insn1.name.equals(insn2.name) && insn1.desc.equals(insn2.desc); + } + + public static boolean ldcInsnEqual(LdcInsnNode insn1, LdcInsnNode insn2) { + return insn1.cst.equals("~") || insn2.cst.equals("~") || insn1.cst.equals(insn2.cst); + } + + public static boolean typeInsnEqual(TypeInsnNode insn1, TypeInsnNode insn2) { + return insn1.desc.equals("~") || insn2.desc.equals("~") || insn1.desc.equals(insn2.desc); + } + + public static boolean iincInsnEqual(IincInsnNode node1, IincInsnNode node2) { + return node1.var == node2.var && node1.incr == node2.incr; + } + + public static boolean intInsnEqual(IntInsnNode node1, IntInsnNode node2) { + return node1.operand == -1 || node2.operand == -1 || node1.operand == node2.operand; + } + + public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { + if (node1.getOpcode() != node2.getOpcode()) { + return false; + } + + switch (node2.getType()) { + case VAR_INSN: + return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); + case TYPE_INSN: + return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); + case FIELD_INSN: + return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); + case METHOD_INSN: + return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); + case LDC_INSN: + return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); + case IINC_INSN: + return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); + case INT_INSN: + return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); + default: + return true; + } + } + + public static InsnList getImportantList(InsnList list) { + if (list.size() == 0) { + return list; + } + + HashMap labels = new HashMap(); + for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { + if (insn instanceof LabelNode) { + labels.put((LabelNode) insn, (LabelNode) insn); + } + } + + InsnList importantNodeList = new InsnList(); + for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { + if (insn instanceof LabelNode || insn instanceof LineNumberNode) { + continue; + } + + importantNodeList.add(insn.clone(labels)); + } + return importantNodeList; + } + + public static boolean insnListMatches(InsnList haystack, InsnList needle, int start) { + if (haystack.size() - start < needle.size()) { + return false; + } + + for (int i = 0; i < needle.size(); i++) { + if (!insnEqual(haystack.get(i + start), needle.get(i))) { + return false; + } + } + return true; + } + + public static List insnListFind(InsnList haystack, InsnList needle) { + LinkedList list = new LinkedList(); + for (int start = 0; start <= haystack.size() - needle.size(); start++) { + if (insnListMatches(haystack, needle, start)) { + list.add(start); + } + } + + return list; + } + + public static List insnListFindStart(InsnList haystack, InsnList needle) { + LinkedList callNodes = new LinkedList(); + for (int callPoint : insnListFind(haystack, needle)) { + callNodes.add(haystack.get(callPoint)); + } + return callNodes; + } + + public static List insnListFindEnd(InsnList haystack, InsnList needle) { + LinkedList callNodes = new LinkedList(); + for (int callPoint : insnListFind(haystack, needle)) { + callNodes.add(haystack.get(callPoint + needle.size() - 1)); + } + return callNodes; + } + + public static List insnListFindL(InsnList haystack, InsnList needle) { + HashSet controlFlowLabels = new HashSet(); + + for (AbstractInsnNode insn = haystack.getFirst(); insn != null; insn = insn.getNext()) { + switch (insn.getType()) { + case 8: + case 15: + break; + case 7: + JumpInsnNode jinsn = (JumpInsnNode) insn; + controlFlowLabels.add(jinsn.label); + break; + case 11: + TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn; + for (LabelNode label : tsinsn.labels) { + controlFlowLabels.add(label); + } + break; + case 12: + LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn; + for (LabelNode label : lsinsn.labels) { + controlFlowLabels.add(label); + } + break; + } + } + + LinkedList list = new LinkedList(); + nextsection: + for (int start = 0; start <= haystack.size() - needle.size(); start++) { + InsnListSection section = insnListMatchesL(haystack, needle, start, controlFlowLabels); + if (section != null) { + for (InsnListSection asection : list) { + if (asection.last == section.last) { + continue nextsection; + } + } + + list.add(section); + } + } + + return list; + } + + private static InsnListSection insnListMatchesL(InsnList haystack, InsnList needle, int start, HashSet controlFlowLabels) { + int h = start, n = 0; + for (; h < haystack.size() && n < needle.size(); h++) { + AbstractInsnNode insn = haystack.get(h); + if (insn.getType() == 15) { + continue; + } + if (insn.getType() == 8 && !controlFlowLabels.contains(insn)) { + continue; + } + + if (!insnEqual(haystack.get(h), needle.get(n))) { + return null; + } + n++; + } + if (n != needle.size()) { + return null; + } + + return new InsnListSection(haystack, start, h - 1); + } + + public static class InsnListSection { + public AbstractInsnNode first; + public AbstractInsnNode last; + + public InsnListSection(AbstractInsnNode first, AbstractInsnNode last) { + this.first = first; + this.last = last; + } + + public InsnListSection(InsnList haystack, int start, int end) { + this(haystack.get(start), haystack.get(end)); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java new file mode 100644 index 000000000..95776e95d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import com.google.common.base.Objects; +import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import nova.internal.core.Game; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.commons.Remapper; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TypeInsnNode; + +import java.io.IOException; + +/** + * @author ChickenBones + */ +public class ObfMapping { + public static final boolean obfuscated; + /** + * CCC will deal withPriority this. + */ + public static Remapper runtimeMapper = FMLDeobfuscatingRemapper.INSTANCE; + public static Remapper mcpMapper = null; + + static { + boolean obf = true; + try { + obf = ((LaunchClassLoader) ObfMapping.class.getClassLoader()).getClassBytes("net.minecraft.world.World") == null; + } catch (IOException iox) { + Game.logger().error(iox.getMessage()); + } + obfuscated = obf; + } + + public String s_owner; + public String s_name; + public String s_desc; + + public boolean runtime; + + public ObfMapping(String owner) { + this(owner, "", ""); + } + + public ObfMapping(String owner, String name, String desc) { + this.s_owner = owner; + this.s_name = name; + this.s_desc = desc; + + if (s_owner.contains(".")) { + throw new IllegalArgumentException(s_owner); + } + + if (mcpMapper != null) { + map(mcpMapper); + } + } + + public ObfMapping(ObfMapping descmap, String subclass) { + this(subclass, descmap.s_name, descmap.s_desc); + } + + public static ObfMapping fromDesc(String s) { + int lastDot = s.lastIndexOf('.'); + if (lastDot < 0) { + return new ObfMapping(s, "", ""); + } + int sep = s.indexOf('(');// methods + int sep_end = sep; + if (sep < 0) { + sep = s.indexOf(' ');// some stuffs + sep_end = sep + 1; + } + if (sep < 0) { + sep = s.indexOf(':');// fields + sep_end = sep + 1; + } + if (sep < 0) { + return new ObfMapping(s.substring(0, lastDot), s.substring(lastDot + 1), ""); + } + + return new ObfMapping(s.substring(0, lastDot), s.substring(lastDot + 1, sep), s.substring(sep_end)); + } + + public ObfMapping subclass(String subclass) { + return new ObfMapping(this, subclass); + } + + public boolean matches(MethodNode node) { + return s_name.equals(node.name) && s_desc.equals(node.desc); + } + + public boolean matches(MethodInsnNode node) { + return s_owner.equals(node.owner) && s_name.equals(node.name) && s_desc.equals(node.desc); + } + + public AbstractInsnNode toInsn(int opcode) { + if (isClass()) { + return new TypeInsnNode(opcode, s_owner); + } else if (isMethod()) { + return new MethodInsnNode(opcode, s_owner, s_name, s_desc); + } else { + return new FieldInsnNode(opcode, s_owner, s_name, s_desc); + } + } + + public void visitTypeInsn(MethodVisitor mv, int opcode) { + mv.visitTypeInsn(opcode, s_owner); + } + + public void visitMethodInsn(MethodVisitor mv, int opcode) { + mv.visitMethodInsn(opcode, s_owner, s_name, s_desc); + } + + public void visitFieldInsn(MethodVisitor mv, int opcode) { + mv.visitFieldInsn(opcode, s_owner, s_name, s_desc); + } + + public boolean isClass(String name) { + return name.replace('.', '/').equals(s_owner); + } + + public boolean matches(String name, String desc) { + return s_name.equals(name) && s_desc.equals(desc); + } + + public boolean matches(FieldNode node) { + return s_name.equals(node.name) && s_desc.equals(node.desc); + } + + public boolean matches(FieldInsnNode node) { + return s_owner.equals(node.owner) && s_name.equals(node.name) && s_desc.equals(node.desc); + } + + public String javaClass() { + return s_owner.replace('/', '.'); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof ObfMapping)) { + return false; + } + + ObfMapping desc = (ObfMapping) obj; + return s_owner.equals(desc.s_owner) && s_name.equals(desc.s_name) && s_desc.equals(desc.s_desc); + } + + @Override + public int hashCode() { + return Objects.hashCode(s_desc, s_name, s_owner); + } + + @Override + public String toString() { + if (s_name.length() == 0) { + return "[" + s_owner + "]"; + } + if (s_desc.length() == 0) { + return "[" + s_owner + "." + s_name + "]"; + } + return "[" + (isMethod() ? methodDesc() : fieldDesc()) + "]"; + } + + public String methodDesc() { + return s_owner + "." + s_name + s_desc; + } + + public String fieldDesc() { + return s_owner + "." + s_name + ":" + s_desc; + } + + public boolean isClass() { + return s_name.length() == 0; + } + + public boolean isMethod() { + return s_desc.contains("("); + } + + public boolean isField() { + return !isClass() && !isMethod(); + } + + public ObfMapping map(Remapper mapper) { + if (isMethod()) { + s_name = mapper.mapMethodName(s_owner, s_name, s_desc); + } else if (isField()) { + s_name = mapper.mapFieldName(s_owner, s_name, s_desc); + } + + s_owner = mapper.mapType(s_owner); + + if (isMethod()) { + s_desc = mapper.mapMethodDesc(s_desc); + } else if (s_desc.length() > 0) { + s_desc = mapper.mapDesc(s_desc); + } + + return this; + } + + public ObfMapping toRuntime() { + if (!runtime) { + map(runtimeMapper); + } + + runtime = true; + return this; + } + + public ObfMapping copy() { + return new ObfMapping(s_owner, s_name, s_desc); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java new file mode 100644 index 000000000..52f7fff99 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; + +import com.google.common.collect.HashBiMap; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.MethodNode; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * The template injection manager is capable of injecting default interfaces into classes. + * The default interface will have no overrides, thereby implementing the default methods. + * @author Calclavia, ChickenBones + */ +public class TemplateInjector { + + public static final TemplateInjector instance = new TemplateInjector(); + private HashBiMap templates = HashBiMap.create(); + + /** + * Registers a class to be injected by a default interface + * @param className - Class that will be injected + * @param template - Default interface used as a template to inject in the templateName + */ + public void registerTemplate(String className, Class template) { + templates.put(className, new InjectionTemplate(template.getName())); + } + + private ClassNode getClassNode(String name) { + try { + return ASMHelper.createClassNode(ASMHelper.cl.getClassBytes(name.replace('/', '.'))); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public class InjectionTemplate { + /** + * The default interface class name that acts as a template. + */ + public final String templateName; + + /** + * The methods to be injected upon inject(ClassNode cnode); + */ + public ArrayList methodImplementations = new ArrayList<>(); + + public InjectionTemplate(String templateName) { + this.templateName = templateName; + + /** + * Read the class node, scanning all the method implementations + */ + ClassNode cnode = getClassNode(templateName); + + for (MethodNode method : cnode.methods) { + methodImplementations.add(method); + method.desc = new ObfMapping(cnode.name, method.name, method.desc).toRuntime().s_desc; + } + } + + /** + * Patches the cnode withPriority the methods from this template. + * @param cnode + * @return + */ + public boolean inject(ClassNode cnode) { + + /** + * Inject the interface + */ + String interfaceByteName = templateName.replace(".", "/"); + + if (!cnode.interfaces.contains(interfaceByteName)) { + cnode.interfaces.add(interfaceByteName); + } + + boolean changed = false; + + List names = new LinkedList<>(); + + for (MethodNode method : cnode.methods) { + ObfMapping m = new ObfMapping(cnode.name, method.name, method.desc).toRuntime(); + names.add(m.s_name + m.s_desc); + } + + for (MethodNode impl : this.methodImplementations) { + //Ignore the constructor + if (!impl.name.equals("")) { + + //If the method is ALREADY implemented, then skip it. + if (names.contains(impl.name + impl.desc)) { + continue; + } + + ObfMapping mapping = new ObfMapping(cnode.name, impl.name, impl.desc).toRuntime(); + MethodNode copy = new MethodNode(impl.access, mapping.s_name, mapping.s_desc, impl.signature, + impl.exceptions == null ? null : impl.exceptions.toArray(new String[impl.exceptions.size()])); + ASMHelper.copy(impl, copy); + cnode.methods.add(impl); + changed = true; + } + } + + return changed; + } + } + +} \ No newline at end of file diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java new file mode 100644 index 000000000..136f2221c --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +/** + * ASM classes are used to help withPriority class transformations and bytecode injection. + * The ASM library is based on ChickenBone's ASM library. + * @author Calclavia + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.lib; \ No newline at end of file diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java new file mode 100644 index 000000000..e7ed4dda9 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.transformers; + +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ObfMapping; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.LineNumberNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; + +public class ChunkTransformer implements Transformer { + + @Override + public void transform(ClassNode cnode) { + System.out.println("[NOVA] Transforming Chunk class for chunkModified event."); + + //obf name: func_177436_a + MethodNode method = ASMHelper.findMethod(new ObfMapping("net/minecraft/world/chunk/Chunk", "setBlockState", "(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/block/state/IBlockState;"), cnode); + + System.out.println("[NOVA] Found method " + method.name); + + InsnList list = new InsnList(); + list.add(new VarInsnNode(ALOAD, 0)); //this + list.add(new VarInsnNode(ALOAD, 1)); //BlockPos + list.add(new VarInsnNode(ALOAD, 8)); //oldBlock IBlockState + list.add(new VarInsnNode(ALOAD, 2)); //newBlock IBlockState + list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder", "chunkSetBlockEvent", "(Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/block/state/IBlockState;)V", false)); + + AbstractInsnNode lastInsn = method.instructions.getLast(); + while (lastInsn instanceof LabelNode || lastInsn instanceof LineNumberNode) { + lastInsn = lastInsn.getPrevious(); + } + + if (ASMHelper.isReturn(lastInsn)) { + method.instructions.insertBefore(lastInsn, list); + } else { + method.instructions.insert(list); + } + + System.out.println("[NOVA] Injected instruction to method: " + method.name); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java new file mode 100644 index 000000000..9fb66f60c --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.transformers; + +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11.asm.lib.InstructionComparator; +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ObfMapping; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; + +public class TileEntityTransformer implements Transformer { + + @Override + public void transform(ClassNode cnode) { + + System.out.println("[NOVA] Transforming TileEntity class for dynamic instance injection."); + + ObfMapping obfMap = new ObfMapping("aqk", "a", "(Laid;Ldr;)Laqk;"); + ObfMapping deobfMap = new ObfMapping("net/minecraft/tileentity/TileEntity", "create", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/tileentity/TileEntity;"); + + MethodNode method = ASMHelper.findMethod(obfMap, cnode); + + if (method == null) { + System.out.println("[NOVA] Lookup " + obfMap + " failed. You are probably in a deobf environment."); + method = ASMHelper.findMethod(deobfMap, cnode); + + if (method == null) { + System.out.println("[NOVA] Lookup " + deobfMap + " failed!"); + } + } + + System.out.println("[NOVA] Transforming method " + method.name); + + ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 33, 36)); + + InsnList list = new InsnList(); + list.add(new VarInsnNode(ALOAD, 0)); // World + list.add(new VarInsnNode(ALOAD, 1)); // NBTTagCompound + list.add(new VarInsnNode(ALOAD, 4)); // Class + list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder", "loadTileEntityHook", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;Ljava/lang/Class;)Lnet/minecraft/tileentity/TileEntity;", false)); + list.add(new VarInsnNode(ASTORE, 2)); // TileEntity + + method.instructions.insert(method.instructions.get(31), list); + + System.out.println("[NOVA] Injected instruction to method: " + method.name); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java new file mode 100644 index 000000000..33fb0a284 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.transformers; + +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.ClassNode; + +public interface Transformer extends Opcodes { + + public void transform(ClassNode cnode); +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java new file mode 100644 index 000000000..fc8a1cf2f --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.asm.transformers; + +import net.minecraft.launchwrapper.IClassTransformer; +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; +import org.objectweb.asm.tree.ClassNode; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public final class Transformers implements IClassTransformer { + + private static Map> transformers = new HashMap<>(); + + public Transformers() { + registerTransformer(new ChunkTransformer(), "net.minecraft.world.chunk.Chunk"); + registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); + } + + public static void registerTransformer(Transformer transformer, String... classes) { + Objects.requireNonNull(classes); + for (String clazz : classes) { + List list = transformers.getOrDefault(clazz, new ArrayList<>()); + list.add(transformer); + transformers.put(clazz, list); + } + } + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if (transformers.containsKey(transformedName)) { + ClassNode cnode = ASMHelper.createClassNode(basicClass); + transformers.get(transformedName).forEach(t -> t.transform(cnode)); + return ASMHelper.createBytes(cnode, 0); + } + return basicClass; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java new file mode 100644 index 000000000..b87359207 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.game.ClientManager; +import nova.core.wrapper.mc.forge.v1_11.manager.FWClientManager; +import se.jbee.inject.bind.BinderModule; + +public class ClientModule extends BinderModule { + + @Override + protected void declare() { + bind(ClientManager.class).to(FWClientManager.class); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java new file mode 100644 index 000000000..ac50e1676 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.entity.component.RigidBody; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.BWRigidBody; +import se.jbee.inject.bind.BinderModule; + +/** + * @author Calclavia + */ +public class ComponentModule extends BinderModule { + + @Override + protected void declare() { + bind(RigidBody.class).to(BWRigidBody.class); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java new file mode 100644 index 000000000..f36dd9b03 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.game.GameInfo; +import se.jbee.inject.Dependency; +import se.jbee.inject.Injector; +import se.jbee.inject.Supplier; +import se.jbee.inject.bind.BinderModule; + +public class GameInfoModule extends BinderModule { + private static final GameInfo minecraft = new GameInfo("minecraft", "1.7.10"); + + @Override + protected void declare() { + bind(GameInfo.class).toSupplier(GameInfoSupplier.class); + } + + public static class GameInfoSupplier implements Supplier { + @Override + public GameInfo supply(Dependency dependency, Injector injector) { + return minecraft; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java new file mode 100644 index 000000000..70fab59d6 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.game.InputManager; +import nova.core.wrapper.mc.forge.v1_11.util.MCInputManager; +import se.jbee.inject.bind.BinderModule; + +public class KeyModule extends BinderModule { + + @Override + protected void declare() { + bind(InputManager.class).to(MCInputManager.class); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java new file mode 100644 index 000000000..af3f7a24a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.util.registry.LanguageManager; +import nova.core.wrapper.mc.forge.v1_11.util.MCLanguageManager; +import se.jbee.inject.bind.BinderModule; + +public class LanguageModule extends BinderModule { + + @Override + protected void declare() { + bind(LanguageManager.class).to(MCLanguageManager.class); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java new file mode 100644 index 000000000..1682d0905 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.network.NetworkManager; +import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import se.jbee.inject.bind.BinderModule; + +public class NetworkModule extends BinderModule { + + @Override + protected void declare() { + bind(NetworkManager.class).to(MCNetworkManager.class); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java new file mode 100644 index 000000000..e450ec8e6 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.render.RenderManager; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWClientRenderManager; +import se.jbee.inject.bind.BinderModule; + +public class RenderModule extends BinderModule { + + @Override + protected void declare() { + bind(RenderManager.class).to(BWClientRenderManager.class); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java new file mode 100644 index 000000000..339d28ede --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.core.util.registry.RetentionManager; +import nova.core.wrapper.mc.forge.v1_11.manager.MCRetentionManager; +import se.jbee.inject.bind.BinderModule; + +public class SaveModule extends BinderModule { + + @Override + protected void declare() { + bind(RetentionManager.class).to(MCRetentionManager.class); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java new file mode 100644 index 000000000..54be1bf1a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.depmodules; + +import nova.internal.core.tick.UpdateTicker; +import se.jbee.inject.Dependency; +import se.jbee.inject.Injector; +import se.jbee.inject.Supplier; +import se.jbee.inject.bind.BinderModule; +import se.jbee.inject.util.Scoped; + +/** + * @author Calclavia + */ +public class TickerModule extends BinderModule { + public static final UpdateTicker.SynchronizedTicker synchronizedTicker = new UpdateTicker.SynchronizedTicker(); + public static final UpdateTicker.ThreadTicker threadTicker = new UpdateTicker.ThreadTicker(); + public static UpdateTicker.TickingThread tickingThread; + + public TickerModule() { + super(Scoped.DEPENDENCY_TYPE); + } + + @Override + protected void declare() { + bind(UpdateTicker.SynchronizedTicker.class).toSupplier(SynchronizedTickerSupplier.class); + bind(UpdateTicker.ThreadTicker.class).toSupplier(ThreadTickerSupplier.class); + + /** + * Initiated threaded ticker + */ + tickingThread = new UpdateTicker.TickingThread(threadTicker, 20); + tickingThread.start(); + } + + public static class SynchronizedTickerSupplier implements Supplier { + @Override + public UpdateTicker.SynchronizedTicker supply(Dependency dependency, Injector injector) { + return synchronizedTicker; + } + } + + public static class ThreadTickerSupplier implements Supplier { + @Override + public UpdateTicker.ThreadTicker supply(Dependency dependency, Injector injector) { + return threadTicker; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java new file mode 100644 index 000000000..040e9ff8f --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.renderer.ItemMeshDefinition; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +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 nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileRenderer; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.FWParticle; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntityRenderer; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * @author Calclavia + */ +public class ClientProxy extends CommonProxy { + @Override + public void preInit() { + super.preInit(); + MinecraftForge.EVENT_BUS.register(RenderUtility.instance); + ClientRegistry.bindTileEntitySpecialRenderer(FWTile.class, FWTileRenderer.instance); + RenderUtility.instance.preInit(); + } + + @Override + public void init() { + super.init(); + RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance); + } + + @Override + public void registerItem(FWItem item) { + super.registerItem(item); + + //Hacks to inject custom item definition + ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { + @Override + public ModelResourceLocation getModelLocation(ItemStack stack) { + ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(item); + return new ModelResourceLocation(itemRL, "inventory"); + } + } + ); + } + + @Override + public void postRegisterBlock(FWBlock block) { + super.postRegisterBlock(block); + + //Hack to inject custom itemblock definition + Item itemFromBlock = Item.getItemFromBlock(block); + + ModelLoader.setCustomMeshDefinition(itemFromBlock, new ItemMeshDefinition() { + @Override + public ModelResourceLocation getModelLocation(ItemStack stack) { + ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(itemFromBlock); + return new ModelResourceLocation(itemRL, "inventory"); + } + } + ); + } + + @Override + public boolean isPaused() { + if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) { + GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; + if (screen != null) { + if (screen.doesGuiPauseGame()) { + return true; + } + } + } + return false; + } + + @Override + public Entity spawnParticle(net.minecraft.world.World world, EntityFactory factory) { + //Backward entity particle unwrapper + Entity build = factory.build(); + if (build instanceof BWParticle) { + Particle particle = ((BWParticle) build).createParticle(world); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle); + return Game.natives().toNova(particle); + } else { + FWParticle bwEntityFX = new FWParticle(world, factory); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX); + return bwEntityFX.wrapped; + } + } + + @Override + public Entity spawnParticle(net.minecraft.world.World world, Entity entity) { + //Backward entity particle unwrapper + if (entity instanceof BWParticle) { + Particle particle = ((BWParticle) entity).createParticle(world); + Vector3D position = entity.position(); + particle.posX = position.getX(); + particle.posY = position.getY(); + particle.posZ = position.getZ(); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle); + return Game.natives().toNova(particle); + } else { + FWParticle bwEntityFX = new FWParticle(world, entity); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX); + return bwEntityFX.wrapped; + } + } + + @Override + public EntityPlayer getClientPlayer() { + return Minecraft.getMinecraft().thePlayer; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java new file mode 100644 index 000000000..c19908bd8 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.fml.common.registry.EntityRegistry; +import net.minecraftforge.fml.common.registry.GameRegistry; +import nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.loader.Loadable; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileUpdater; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; + +import java.util.Set; +import net.minecraft.util.ResourceLocation; + +/** + * @author Calclavia + */ +public class CommonProxy implements Loadable { + @Override + public void preInit() { + GameRegistry.registerTileEntity(FWTile.class, "novaTile"); + GameRegistry.registerTileEntity(FWTileUpdater.class, "novaTileUpdater"); + EntityRegistry.registerModEntity(new ResourceLocation("novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true); + } + + public void registerResourcePacks(Set> modClasses) { + + } + + public void registerItem(FWItem item) { + + } + + public void postRegisterBlock(FWBlock block) { + + } + + public Entity spawnParticle(net.minecraft.world.World world, EntityFactory factory) { + return null; + } + + public Entity spawnParticle(net.minecraft.world.World world, Entity entity) { + return null; + } + + public boolean isPaused() { + return false; + } + + public EntityPlayer getClientPlayer() { + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java new file mode 100644 index 000000000..1089c4c0e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import nova.core.event.PlayerEvent; +import nova.internal.core.Game; + +/** + * Handles FML events and forwards them to NOVA. + * @author Calclavia + */ +public class FMLEventHandler { + @SubscribeEvent + public void playerJoin(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent evt) { + Game.events().publish(new PlayerEvent.Join(Game.natives().toNova(evt.player))); + } + + @SubscribeEvent + public void playerLeave(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent evt) { + Game.events().publish(new PlayerEvent.Leave(Game.natives().toNova(evt.player))); + } + + @SubscribeEvent + public void tickEnd(TickEvent.ServerTickEvent event) { + if (event.phase == TickEvent.Phase.END) { + Game.syncTicker().update(); + } + } + + @SubscribeEvent + public void tickEnd(TickEvent.ClientTickEvent event) { + if (event.phase == TickEvent.Phase.END) { + Game.syncTicker().update(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java new file mode 100644 index 000000000..b84f1707e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.oredict.OreDictionary; +import nova.core.item.Item; +import nova.core.item.ItemDictionary; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * @author Stan, Calclavia + */ +public class ForgeEventHandler { + + @SubscribeEvent + public void worldUnload(WorldEvent.Load evt) { + Game.events().publish(new nova.core.event.WorldEvent.Load(Game.natives().toNova(evt.getWorld()))); + } + + @SubscribeEvent + public void worldLoad(WorldEvent.Unload evt) { + Game.events().publish(new nova.core.event.WorldEvent.Unload(Game.natives().toNova(evt.getWorld()))); + } + + @SubscribeEvent + public void onOreRegister(OreDictionary.OreRegisterEvent event) { + ItemDictionary novaItemDictionary = Game.itemDictionary(); + + Item item = ItemConverter.instance().getNovaItem(event.getOre()); + if (!novaItemDictionary.get(event.getName()).contains(item)) { + novaItemDictionary.add(event.getName(), item); + } + } + + @SubscribeEvent + public void playerInteractEvent(PlayerInteractEvent event) { + if (event.getWorld() != null && event.getPos() != null) { + nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact( + Game.natives().toNova(event.getWorld()), + new Vector3D(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ()), + Game.natives().toNova(event.getEntityPlayer()), + nova.core.event.PlayerEvent.Interact.Action.values()[toNovaInteractOrdinal(event)] + ); + + Game.events().publish(evt); + + if (event instanceof RightClickBlock) { + ((RightClickBlock)event).setUseBlock(Event.Result.values()[evt.useBlock.ordinal()]); + ((RightClickBlock)event).setUseItem(Event.Result.values()[evt.useItem.ordinal()]); + } else if (event instanceof LeftClickBlock) { + ((LeftClickBlock)event).setUseBlock(Event.Result.values()[evt.useBlock.ordinal()]); + ((LeftClickBlock)event).setUseItem(Event.Result.values()[evt.useItem.ordinal()]); + } + event.setCanceled(evt.isCanceled()); + } + } + + private static int toNovaInteractOrdinal(PlayerInteractEvent event) { + if (event instanceof RightClickBlock) return 1; + else if (event instanceof LeftClickBlock) return 2; + else return 0; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java new file mode 100644 index 000000000..eeb986800 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.DummyModContainer; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.Metadata; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; +import net.minecraftforge.fml.relauncher.FMLInjectionData; +import nova.core.deps.MavenDependency; +import nova.core.event.ServerEvent; +import nova.core.loader.Loadable; +import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; +import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.ComponentModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.GameInfoModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.KeyModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.LanguageModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.NetworkModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.RenderModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.SaveModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.TickerModule; +import nova.core.wrapper.mc.forge.v1_11.recipes.MinecraftRecipeRegistry; +import nova.core.wrapper.mc.forge.v1_11.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.WorldConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.cuboid.CuboidConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.EntityConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.inventory.InventoryConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.OreDictionaryIntegration; +import nova.internal.core.Game; +import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; +import nova.internal.core.deps.DepDownloader; +import nova.internal.core.launch.InitializationException; +import nova.internal.core.launch.NovaLauncher; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * The main Nova Minecraft Wrapper loader, using Minecraft Forge. + * @author Calclavia + */ +@Mod(modid = NovaMinecraft.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"; + + @SidedProxy(clientSide = "nova.core.wrapper.mc.forge.v18.launcher.ClientProxy", serverSide = "nova.core.wrapper.mc.forge.v18.launcher.CommonProxy") + public static CommonProxy proxy; + @Mod.Instance(id) + public static NovaMinecraft instance; + private static NovaLauncher launcher; + @Metadata(id) + private static ModMetadata modMetadata; + + private static Set nativeConverters; + private static Set childModMetadata; + private static Set childModContainers; + + /** + * ORDER OF LOADING. + * + * 1. Native Loaders 2. Native Converters 3. Mods + */ + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent evt) { + try { + /** + * Search through all classes withPriority @NovaMod + */ + DependencyInjectionEntryPoint diep = new DependencyInjectionEntryPoint(); + diep.install(NetworkModule.class); + diep.install(SaveModule.class); + diep.install(TickerModule.class); + diep.install(LanguageModule.class); + diep.install(KeyModule.class); + diep.install(ClientModule.class); + diep.install(GameInfoModule.class); + diep.install(RenderModule.class); + diep.install(ComponentModule.class); + + Set> modClasses = NovaMinecraftPreloader.modClasses; + + proxy.registerResourcePacks(modClasses); + launcher = new NovaLauncher(diep, modClasses); + + Game.inject(diep); + + /** + * Register native converters + */ + Game.natives().registerConverter(new DataWrapper()); + Game.natives().registerConverter(new EntityConverter()); + Game.natives().registerConverter(new BlockConverter()); + Game.natives().registerConverter(new ItemConverter()); + Game.natives().registerConverter(new WorldConverter()); + Game.natives().registerConverter(new CuboidConverter()); + Game.natives().registerConverter(new InventoryConverter()); + Game.natives().registerConverter(new VectorConverter()); + + /** + * Initiate recipe and ore dictionary integration + */ + OreDictionaryIntegration.instance.registerOreDictionary(); + MinecraftRecipeRegistry.instance.registerRecipes(); + + /** + * Download dependencies + */ + launcher.generateDependencies(); + + try { + for (List dependencies : launcher.getNeededDeps().values()) { + for (MavenDependency dep : dependencies) { + DepDownloader.downloadDepdency(dep.getDownloadURL(), FMLInjectionData.data()[6] + "/mods/" + dep.getPath()); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + launcher.load(); + + /** + * Instantiate native loaders + */ + nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet()); + nativeConverters.stream().forEachOrdered(Loadable::preInit); + + childModMetadata = Collections.emptySet();//.stream().filter(l -> l.getClass().isAnnotationPresent(nova.core.loader.Mod.class)) + //.map(l -> ((nova.core.loader.Mod)l.getClass().getDeclaredAnnotation(nova.core.loader.Mod.class))).collect(Collectors.toSet()); + + Game.blocks().init(); + Game.items().init(); + Game.entities().init(); + Game.render().init(); + Game.language().init(); + + launcher.preInit(); + + // Initiate config system TODO: Storables + // launcher.getLoadedModMap().forEach((mod, loader) -> { + // Configuration config = new Configuration(new File(evt.getModConfigurationDirectory(), mod.name())); + // ConfigManager.instance.sync(config, loader.getClass().getPackage().getName()); + // }); + + proxy.preInit(); + + /** + * Register event handlers + */ + MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); + FMLCommonHandler.instance().bus().register(new FMLEventHandler()); + MinecraftForge.EVENT_BUS.register(Game.retention()); + } catch (Exception e) { + System.out.println("Error during preInit"); + e.printStackTrace(); + throw new InitializationException(e); + } + } + + @Mod.EventHandler + public void init(FMLInitializationEvent evt) { + try { + proxy.init(); + nativeConverters.stream().forEachOrdered(Loadable::init); + launcher.init(); + } catch (Exception e) { + System.out.println("Error during init"); + e.printStackTrace(); + throw new InitializationException(e); + } + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent evt) { + try { + Game.recipes().init(); + proxy.postInit(); + nativeConverters.stream().forEachOrdered(Loadable::postInit); + launcher.postInit(); + + if (modMetadata.childMods == null) modMetadata.childMods = new ArrayList<>(); + childModMetadata.stream().forEachOrdered((nova.core.loader.Mod m) -> { + ModMetadata forgeMetadata = new ModMetadata(); + forgeMetadata.modId = m.id(); + forgeMetadata.name = m.name(); + forgeMetadata.version = m.version(); + forgeMetadata.description = m.description(); + ModContainer modContainer = new DummyModContainer(forgeMetadata); + modMetadata.childMods.add(modContainer); // So that nova mods are shown alongside Forge mods. + }); + } catch (Exception e) { + System.out.println("Error during postInit"); + e.printStackTrace(); + throw new InitializationException(e); + } + } + + @Mod.EventHandler + public void serverStarting(FMLServerStartingEvent event) { + Game.events().publish(new ServerEvent.Start()); + } + + @Mod.EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + Game.events().publish(new ServerEvent.Stop()); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java new file mode 100644 index 000000000..f4487085d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.manager; + +import net.minecraft.client.Minecraft; +import nova.core.entity.Entity; +import nova.core.game.ClientManager; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; + +/** + * @author Calclavia + */ +public class FWClientManager extends ClientManager { + + @Override + public Entity getPlayer() { + return new BWEntity(NovaMinecraft.proxy.getClientPlayer()); + } + + @Override + public boolean isPaused() { + return Minecraft.getMinecraft().isGamePaused(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java new file mode 100644 index 000000000..81d21cc3b --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.manager; + +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import nova.core.retention.Data; +import nova.core.retention.Storable; +import nova.core.util.registry.RetentionManager; +import nova.internal.core.Game; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import net.minecraftforge.fml.server.FMLServerHandler; + +/** + * A manager that handles external file saving. + * @author Calclavia + */ +public class MCRetentionManager extends RetentionManager { + + /** + * Last time that the queueSave manager tried to queueSave a file + */ + private long lastSaveMills = 0; + + /** + * Save all storable queued + */ + public void saveAll() { + saveQueue.forEach(this::save); + saveQueue.clear(); + } + + @Override + public void save(String filename, Storable storable) { + Data saveMap = new Data(); + storable.save(saveMap); + saveFile(filename, Game.natives().toNative(saveMap)); + } + + @Override + public void load(String filename, Storable storable) { + NBTTagCompound nbt = loadFile(filename); + storable.load(Game.natives().toNova(nbt)); + } + + /** + * Saves NBT data in the world folder. + * @param file File to save data to + * @param data Data to save + * @return True on success. + */ + public boolean saveFile(File file, NBTTagCompound data) { + try { + File tempFile = new File(file.getParent(), file.getName() + "_tmp.dat"); + + CompressedStreamTools.writeCompressed(data, new FileOutputStream(tempFile)); + + if (file.exists()) { + file.delete(); + } + + tempFile.renameTo(file); + return true; + } catch (Exception e) { + System.out.println("Failed to queueSave " + file.getName() + ".dat!"); + e.printStackTrace(); + return false; + } + } + + public boolean saveFile(File saveDirectory, String filename, NBTTagCompound data) { + return saveFile(new File(saveDirectory, filename + ".dat"), data); + } + + public boolean saveFile(String filename, NBTTagCompound data) { + return saveFile(getSaveDirectory(FMLServerHandler.instance().getServer().getFolderName()), filename, data); + } + + public NBTTagCompound loadFile(File file) { + try { + if (file.exists()) { + return CompressedStreamTools.readCompressed(new FileInputStream(file)); + } else { + return new NBTTagCompound(); + } + } catch (Exception e) { + System.out.println("Failed to load " + file.getName() + ".dat!"); + e.printStackTrace(); + return null; + } + } + + /** + * Reads NBT data from the world folder. + * @param saveDirectory Directory in which the file resides + * @param filename Name of the file + * @return The NBT data + */ + public NBTTagCompound loadFile(File saveDirectory, String filename) { + return loadFile(new File(saveDirectory, filename + ".dat")); + } + + public NBTTagCompound loadFile(String filename) { + return loadFile(getSaveDirectory(FMLServerHandler.instance().getServer().getFolderName()), filename); + } + + @Override + public File getSaveDirectory() { + return getSaveDirectory(FMLServerHandler.instance().getServer().getFolderName()); + } + + public File getSaveDirectory(String worldName) { + File parent = getBaseDirectory(); + + if (FMLCommonHandler.instance().getSide().isClient()) { + parent = new File(getBaseDirectory(), "saves" + File.separator); + } + + return new File(parent, worldName + File.separator); + } + + public File getBaseDirectory() { + if (FMLCommonHandler.instance().getSide().isClient()) { + FMLClientHandler.instance().getClient(); + return FMLClientHandler.instance().getClient().mcDataDir; + } else { + return new File("."); + } + } + + @SubscribeEvent + public void worldSave(WorldEvent evt) { + //Current time milli-seconds is used to prevent the files from saving 20 times when the world loads + if (System.currentTimeMillis() - lastSaveMills > 2000) { + lastSaveMills = System.currentTimeMillis(); + saveAll(); + } + } + + @Override + public void init() { + + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java new file mode 100644 index 000000000..c045c7b35 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.manager.config; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.client.config.GuiConfig; + +/** + * @author Calclavia + */ +public class NovaGuiConfig extends GuiConfig { + public NovaGuiConfig(GuiScreen parentScreen, Configuration config, String modID) { + super(parentScreen, new ConfigElement(config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), modID, false, false, GuiConfig.getAbridgedConfigPath(config.toString())); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java new file mode 100644 index 000000000..2d7cd5345 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.manager.config; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.client.IModGuiFactory; + +import java.util.Set; + +/** + * @author Calclavia + */ +public class NovaGuiFactory implements IModGuiFactory { + @Override + public void initialize(Minecraft minecraftInstance) { + + } + + @Override + public Class mainConfigGuiClass() { + return NovaGuiConfig.class; + } + + @Override + public Set runtimeGuiCategories() { + return null; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java new file mode 100644 index 000000000..2da87aa23 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network; + +import io.netty.buffer.ByteBuf; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import nova.core.entity.component.Player; +import nova.core.network.Packet; + +/** + * Wraps ByteBuf into a NOVA Packet. + * @author Calclavia + */ +public class MCPacket implements Packet { + + public final ByteBuf buf; + public final Player player; + private int id = 0; + + public MCPacket(ByteBuf buf) { + this.buf = buf; + player = null; + } + + public MCPacket(ByteBuf buf, Player player) { + this.buf = buf; + this.player = player; + } + + @Override + public Player player() { + if (player == null) { + throw new RuntimeException("Attempt to get player in packet when it does not exist!"); + } + + return player; + } + + @Override + public int getID() { + return id; + } + + @Override + public Packet setID(int id) { + this.id = id; + return this; + } + + @Override + public Packet writeBoolean(boolean value) { + buf.writeBoolean(value); + return this; + } + + @Override + public Packet writeByte(int value) { + buf.writeByte(value); + return this; + } + + @Override + public Packet writeShort(int value) { + buf.writeShort(value); + return this; + } + + @Override + public Packet writeInt(int value) { + buf.writeInt(value); + return this; + } + + @Override + public Packet writeLong(long value) { + buf.writeLong(value); + return this; + } + + @Override + public Packet writeChar(int value) { + buf.writeChar(value); + return this; + } + + @Override + public Packet writeFloat(float value) { + buf.writeFloat(value); + return this; + } + + @Override + public Packet writeDouble(double value) { + buf.writeDouble(value); + return this; + } + + @Override + public Packet writeString(String value) { + ByteBufUtils.writeUTF8String(buf, value); + return this; + } + + @Override + public Packet writeBytes(byte[] array) { + buf.writeBytes(array); + return this; + } + + @Override + public byte[] readBytes(int length) { + byte[] array = new byte[length]; + for (int i = 0; i < length; i++) + array[i] = buf.readByte(); + return array; + } + + @Override + public boolean readBoolean() { + return buf.readBoolean(); + } + + @Override + public byte readByte() { + return buf.readByte(); + } + + @Override + public short readUnsignedByte() { + return buf.readUnsignedByte(); + } + + @Override + public short readShort() { + return buf.readShort(); + } + + @Override + public int readInt() { + return buf.readInt(); + } + + @Override + public long readUnsignedInt() { + return buf.readUnsignedInt(); + } + + @Override + public long readLong() { + return buf.readLong(); + } + + @Override + public char readChar() { + return buf.readChar(); + } + + @Override + public float readFloat() { + return buf.readFloat(); + } + + @Override + public double readDouble() { + return buf.readDouble(); + } + + @Override + public String readString() { + return ByteBufUtils.readUTF8String(buf); + } + + public void writeTo(ByteBuf other) { + other.writeBytes(buf); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java new file mode 100644 index 000000000..61b04541d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.discriminator; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import net.minecraft.entity.player.EntityPlayer; +import nova.core.entity.Entity; +import nova.core.entity.component.Player; +import nova.core.network.handler.PacketHandler; +import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; +import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.internal.core.Game; + +/** + * NOVA Packet Structure: + * + * 1. Packet Type ID + * 2. Packet Sub ID + * 3. Data + * @author Calclavia + */ +public class NovaPacket extends PacketAbstract { + + @Override + public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { + buffer.writeBytes(data); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { + data = buffer.slice(); + } + + @Override + public void handleClientSide(EntityPlayer player) { + handle(player); + } + + @Override + public void handleServerSide(EntityPlayer player) { + handle(player); + } + + public void handle(EntityPlayer player) { + try { + MCNetworkManager network = (MCNetworkManager) Game.network(); + PacketHandler packetHandler = network.getPacketType(data.readInt()); + int subId = data.readInt(); + MCPacket packet = new MCPacket(data.slice(), ((Entity) Game.natives().toNova(player)).components.get(Player.class)); + //Set the ID of the packet + packet.setID(subId); + packetHandler.read(packet); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java new file mode 100644 index 000000000..3a866fc07 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.discriminator; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import net.minecraft.entity.player.EntityPlayer; +import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; + +/** + * For custom packets extend this Class and register on Mod loading phase + *

+ * Without registering a NPE will be thrown as the {@link MCNetworkManager} won't know how to handle it + *

+ * To send this packet also look at {@link MCNetworkManager#sendToAll(PacketAbstract)} + * And other implementations there. + * @author tgame14, Calclavia + * @since 26/05/14 + */ +public abstract class PacketAbstract { + public ByteBuf data = Unpooled.buffer(); + EntityPlayer sender = null; + + /** + * Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers + * @param ctx channel context + * @param buffer the buffer to encode into + * @see net.minecraftforge.fml.common.network.ByteBufUtils + */ + public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer); + + /** + * Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers + * @param ctx channel context + * @param buffer the buffer to decode from + * @see net.minecraftforge.fml.common.network.ByteBufUtils + */ + public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer); + + /** + * Handle a packet on the client side. Note this occurs after decoding has completed. + * @param player the player reference + */ + public void handleClientSide(EntityPlayer player) { + throw new UnsupportedOperationException("Unsupported operation for Packet: " + getClass().getSimpleName()); + } + + /** + * Handle a packet on the server side. Note this occurs after decoding has completed. + * @param player the player reference + */ + public void handleServerSide(EntityPlayer player) { + throw new UnsupportedOperationException("Unsupported operation for Packet: " + getClass().getSimpleName()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java new file mode 100644 index 000000000..3d4f75858 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.discriminator; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import nova.core.network.Syncable; +import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; + +/** + * A packet handler for players who are currently holding their item. + * @author Calclavia + */ +//TODO: Move to NOVA Core +public class PacketPlayerItem extends PacketAbstract { + public int slotId; + + public PacketPlayerItem() { + + } + + public PacketPlayerItem(int slotId) { + this.slotId = slotId; + } + + public PacketPlayerItem(EntityPlayer player) { + this(player.inventory.currentItem); + } + + @Override + public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { + buffer.writeInt(slotId); + buffer.writeBytes(data); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { + slotId = buffer.readInt(); + data = buffer.slice(); + } + + @Override + public void handleClientSide(EntityPlayer player) { + ItemStack stack = player.inventory.getStackInSlot(this.slotId); + + if (stack != null && stack.getItem() instanceof Syncable) { + MCPacket mcPacket = new MCPacket(data); + mcPacket.setID(data.readInt()); + ((Syncable) stack.getItem()).read(mcPacket); + } + } + + @Override + public void handleServerSide(EntityPlayer player) { + ItemStack stack = player.inventory.getStackInSlot(this.slotId); + + if (stack != null && stack.getItem() instanceof Syncable) { + MCPacket mcPacket = new MCPacket(data); + mcPacket.setID(data.readInt()); + ((Syncable) stack.getItem()).read(mcPacket); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java new file mode 100644 index 000000000..d49859e0a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.netty; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.NovaPacket; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketPlayerItem; + +/** + * Handles the channel and discriminators. + * @author Calclavia + */ +public class ChannelHandler extends FMLIndexedMessageToMessageCodec { + public ChannelHandler() { + addDiscriminator(0, NovaPacket.class); + addDiscriminator(1, PacketPlayerItem.class); + } + + @Override + public void encodeInto(ChannelHandlerContext ctx, PacketAbstract packet, ByteBuf target) throws Exception { + packet.encodeInto(ctx, target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, PacketAbstract packet) { + packet.decodeInto(ctx, source); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java new file mode 100644 index 000000000..5c7b508ba --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.netty; + +import io.netty.buffer.Unpooled; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.network.FMLEmbeddedChannel; +import net.minecraftforge.fml.common.network.FMLOutboundHandler; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.entity.component.Player; +import nova.core.network.NetworkManager; +import nova.core.network.Syncable; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.NovaPacket; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.EnumMap; + +/** + * The implementation of NetworkManager that will be injected. + * @author Calclavia + * @since 26/05/14 + */ +public class MCNetworkManager extends NetworkManager { + public final String channel = NovaMinecraft.id; + public final EnumMap channelEnumMap = NetworkRegistry.INSTANCE.newChannel(channel, new ChannelHandler(), new MCPacketHandler()); + + public Packet toMCPacket(PacketAbstract packet) { + return channelEnumMap.get(FMLCommonHandler.instance().getEffectiveSide()).generatePacketFrom(packet); + } + + @Override + public nova.core.network.Packet newPacket() { + return new MCPacket(Unpooled.buffer()); + } + + @Override + public void sendPacket(nova.core.network.Packet packet) { + //Wrap the packet in NOVA's discriminator + PacketAbstract discriminator = new NovaPacket(); + //Write packet + discriminator.data.writeBytes(((MCPacket) packet).buf); + + if (isServer()) { + sendToAll(discriminator); + } else { + sendToServer(discriminator); + } + } + + public PacketAbstract writePacket(int id, Syncable sender) { + PacketAbstract discriminator = new NovaPacket(); + nova.core.network.Packet packet = newPacket(); + packet.setID(id); + + //Write packet + writePacket(sender, packet); + discriminator.data.writeBytes(((MCPacket) packet).buf); + return discriminator; + } + + @Override + public void sendChat(Player player, String message) { + if (player instanceof BWEntity.MCPlayer) { + ((BWEntity.MCPlayer) player).entity.addChatMessage(new TextComponentString(message)); + } + } + + @Override + public boolean isServer() { + return FMLCommonHandler.instance().getEffectiveSide().isServer(); + } + + /** + * @param packet the packet to send to the player + * @param player the player MP object + */ + public void sendToPlayer(PacketAbstract packet, EntityPlayerMP player) { + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet); + } + + /** + * @param packet the packet to send to the players in the dimension + * @param dimId the dimension id to send to. + */ + public void sendToAllInDimension(PacketAbstract packet, int dimId) { + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimId); + this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet); + } + + public void sendToAllInDimension(PacketAbstract packet, World world) { + sendToAllInDimension(packet, world.provider.getDimension()); + } + + /** + * sends to all clients connected to the server + * @param packet the packet to send. + */ + public void sendToAll(PacketAbstract packet) { + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + this.channelEnumMap.get(Side.SERVER).writeAndFlush(packet); + } + + public void sendToAllAround(PacketAbstract message, NetworkRegistry.TargetPoint point) { + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + this.channelEnumMap.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); + this.channelEnumMap.get(Side.SERVER).writeAndFlush(message); + } + + public void sendToAllAround(PacketAbstract message, World world, Vector3D point, double range) { + sendToAllAround(message, world, point.getX(), point.getY(), point.getZ(), range); + } + + public void sendToAllAround(PacketAbstract message, TileEntity tile) { + sendToAllAround(message, tile, 64); + } + + public void sendToAllAround(PacketAbstract message, TileEntity tile, double range) { + sendToAllAround(message, tile.getWorld(), tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), range); + } + + public void sendToAllAround(PacketAbstract message, World world, double x, double y, double z, double range) { + sendToAllAround(message, new NetworkRegistry.TargetPoint(world.provider.getDimension(), x, y, z, range)); + } + + @SideOnly(Side.CLIENT) + public void sendToServer(PacketAbstract packet) { + this.channelEnumMap.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + this.channelEnumMap.get(Side.CLIENT).writeAndFlush(packet); + } +} + + diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java new file mode 100644 index 000000000..994303ffe --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.network.netty; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; + +/** + * @author tgame14 + * @since 31/05/14 + */ +@ChannelHandler.Sharable +public class MCPacketHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) throws Exception { + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + + switch (FMLCommonHandler.instance().getEffectiveSide()) { + case CLIENT: + FMLClientHandler.instance().getClient().addScheduledTask(() -> packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer())); + break; + case SERVER: + FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> packet.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity)); + break; + default: + break; + } + + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java new file mode 100644 index 000000000..c81615a0e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.ItemStack; +import nova.core.entity.component.Player; +import nova.core.recipes.crafting.CraftingGrid; +import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11.util.WrapUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.internal.core.Game; + +import java.util.List; +import java.util.Optional; + +/** + * @author Stan Hebben + */ +public class MCCraftingGrid implements CraftingGrid { + private static final ThreadLocal cache = new ThreadLocal(); + private static final ThreadLocal cache2 = new ThreadLocal(); + private final IInventory inventory; + private final Optional player; + private final EntityPlayer playerOrig; + private int width; + private int height; + private nova.core.item.Item[] stacks; + private ItemStack[] original; + private int numberOfStacks; + + private MCCraftingGrid(InventoryCrafting inventory) { + this.inventory = inventory; + width = height = (int) Math.sqrt(inventory.getSizeInventory()); + stacks = new nova.core.item.Item[width * height]; + original = new ItemStack[stacks.length]; + numberOfStacks = 0; + update(); + + Container container = ReflectionUtil.getCraftingContainer(inventory); + if (container != null) { + List slots = container.inventorySlots; + if (!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) { + SlotCrafting slotCrafting = (SlotCrafting) slots.get(0); + playerOrig = ReflectionUtil.getCraftingSlotPlayer(slotCrafting); + player = WrapUtility.getNovaPlayer(playerOrig); + } else { + playerOrig = null; + player = null; + } + } else { + playerOrig = null; + player = null; + } + } + + public MCCraftingGrid(IInventory inventory, EntityPlayer player) { + this.inventory = inventory; + width = height = (int) Math.sqrt(inventory.getSizeInventory()); + stacks = new nova.core.item.Item[width * height]; + original = new ItemStack[stacks.length]; + numberOfStacks = 0; + update(); + + playerOrig = player; + this.player = WrapUtility.getNovaPlayer(player); + } + + public static MCCraftingGrid get(InventoryCrafting inventory) { + if (cache.get() == null || cache.get().inventory != inventory) { + MCCraftingGrid result = new MCCraftingGrid(inventory); + cache.set(result); + return result; + } else { + MCCraftingGrid result = cache.get(); + result.update(); + return result; + } + } + + public static MCCraftingGrid get(IInventory inventory, EntityPlayer player) { + if (cache2.get() == null || cache2.get().inventory != inventory || cache2.get().playerOrig != player) { + MCCraftingGrid result = new MCCraftingGrid(inventory, player); + cache2.set(result); + return result; + } else { + MCCraftingGrid result = cache2.get(); + result.update(); + return result; + } + } + + private void update() { + if (inventory.getSizeInventory() != original.length) { + width = height = (int) Math.sqrt(inventory.getSizeInventory()); + stacks = new nova.core.item.Item[inventory.getSizeInventory()]; + original = new ItemStack[stacks.length]; + numberOfStacks = 0; + } + + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (changed(i)) { + //System.out.println("Slot " + i + " changed"); + original[i] = inventory.getStackInSlot(i); + if (inventory.getStackInSlot(i) != null) { + if (stacks[i] == null) { + numberOfStacks++; + } + + stacks[i] = Game.natives().toNova(original[i]); + } else { + if (stacks[i] != null) { + numberOfStacks--; + } + + stacks[i] = null; + } + } + } + //System.out.println("Num stack count: " + numberOfStacks); + } + + @Override + public Optional getPlayer() { + return player; + } + + @Override + public int size() { + return width * height; + } + + @Override + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; + } + + @Override + public int countFilledStacks() { + return numberOfStacks; + } + + @Override + public Optional getStack(int i) { + return Optional.ofNullable(stacks[i]); + } + + @Override + public Optional getStack(int x, int y) { + return Optional.ofNullable(stacks[y * width + x]); + } + + @Override + public boolean setStack(int x, int y, Optional stack) { + //System.out.println("SetStack(" + x + ", " + y + ") " + stack); + + int ix = y * width + x; + if (!stack.equals(stacks[ix])) { + if (stack.isPresent()) { + inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); + + if (stacks[ix] == null) { + numberOfStacks++; + } + + stacks[ix] = stack.get(); + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; + } + } + + return true; + } + + @Override + public boolean setStack(int i, Optional stack) { + //System.out.println("SetStack(" + i + ") " + stack); + + if (stack == null) { + if (stacks[i] == null) { + return true; + } + + numberOfStacks--; + inventory.setInventorySlotContents(i, null); + stacks[i] = null; + } else { + if (stacks[i] == null) { + numberOfStacks++; + } + + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); + } + + return true; + } + + @Override + public void giveBack(nova.core.item.Item itemStack) { + playerOrig.inventory.addItemStackToInventory(ItemConverter.instance().toNative(itemStack)); + } + + @Override + public String getTopology() { + return CraftingGrid.topologySquare; + } + + @Override + public String getType() { + return CraftingGrid.typeCrafting; + } + + private boolean changed(int i) { + if (original[i] != inventory.getStackInSlot(i)) { + return true; + } + + if (original[i] != null && stacks[i].count() != original[i].func_190916_E()) { + return true; + } + + return false; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java new file mode 100644 index 000000000..8b3a53453 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.item.crafting.IRecipe; +import nova.core.item.Item; +import nova.core.recipes.crafting.CraftingGrid; +import nova.core.recipes.crafting.CraftingRecipe; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Stan Hebben + */ +public class MCCraftingRecipe implements CraftingRecipe { + private final IRecipe recipe; + + public MCCraftingRecipe(IRecipe recipe) { + this.recipe = recipe; + } + + @Override + public boolean matches(CraftingGrid craftingGrid) { + // TODO: supply world somehow? + return recipe.matches(new NovaCraftingGrid(craftingGrid), null); + } + + @Override + public Optional getCraftingResult(CraftingGrid craftingGrid) { + return Game.natives().toNova(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))); + } + + @Override + public void consumeItems(CraftingGrid craftingGrid) { + // not supported + } + + @Override + public Optional getNominalOutput() { + return Game.natives().toNova(recipe.getRecipeOutput()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java new file mode 100644 index 000000000..a0581f4c2 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import nova.core.item.Item; +import nova.core.recipes.crafting.SpecificItemIngredient; +import nova.internal.core.Game; + +/** + * @author Stan Hebben + */ +public class MinecraftItemIngredient extends SpecificItemIngredient { + public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) { + super(((Item) Game.natives().toNova(itemStack)).getID().asString()); // TODO? + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java new file mode 100644 index 000000000..d6105160a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java @@ -0,0 +1,321 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import nova.core.recipes.RecipeAddedEvent; +import nova.core.recipes.RecipeManager; +import nova.core.recipes.RecipeRemovedEvent; +import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.internal.core.Game; + +import java.util.AbstractList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.stream.Stream; + +/** + * Created by Stan on 1/02/2015. + */ +public class MinecraftRecipeRegistry { + public static final MinecraftRecipeRegistry instance = new MinecraftRecipeRegistry(); + + private final Map forwardWrappers = new HashMap<>(); + private final Map backwardWrappers = new HashMap<>(); + + private MinecraftRecipeRegistry() { + } + + public void registerRecipes() { + long startTime = System.currentTimeMillis(); + + RecipeManager recipeManager = Game.recipes(); + + List recipes = (List) CraftingManager.getInstance().getRecipeList(); + for (IRecipe recipe : recipes) { + CraftingRecipe converted = convert(recipe); + if (converted != null) { + recipeManager.addRecipe(converted); + backwardWrappers.put(recipe, converted); + forwardWrappers.put(converted, recipe); + } + } + + ReflectionUtil.setCraftingRecipeList(new RecipeListWrapper(recipes)); + + System.out.println("Initialized recipes in " + (System.currentTimeMillis() - startTime) + " ms"); + + recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); + recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); + } + + private CraftingRecipe convert(IRecipe recipe) { + return RecipeConverter.toNova(recipe); + } + + private IRecipe convert(CraftingRecipe recipe) { + return RecipeConverter.toMinecraft(recipe); + } + + private void onNOVARecipeAdded(RecipeAddedEvent e) { + CraftingRecipe recipe = e.getRecipe(); + if (forwardWrappers.containsKey(recipe)) { + return; + } + + IRecipe minecraftRecipe = convert(recipe); + + backwardWrappers.put(minecraftRecipe, recipe); + forwardWrappers.put(recipe, minecraftRecipe); + + CraftingManager.getInstance().getRecipeList().add(minecraftRecipe); + } + + private void onNOVARecipeRemoved(RecipeRemovedEvent e) { + IRecipe minecraftRecipe = forwardWrappers.get(e.getRecipe()); + + forwardWrappers.remove(e.getRecipe()); + backwardWrappers.remove(minecraftRecipe); + + CraftingManager.getInstance().getRecipeList().remove(minecraftRecipe); + } + + private void onMinecraftRecipeAdded(IRecipe recipe) { + if (backwardWrappers.containsKey(recipe)) { + return; + } + + CraftingRecipe novaRecipe = convert(recipe); + + backwardWrappers.put(recipe, novaRecipe); + forwardWrappers.put(novaRecipe, recipe); + + Game.recipes().addRecipe(novaRecipe); + } + + private void onMinecraftRecipeRemoved(IRecipe recipe) { + CraftingRecipe novaRecipe = backwardWrappers.get(recipe); + + forwardWrappers.remove(novaRecipe); + backwardWrappers.remove(recipe); + + Game.recipes().removeRecipe(novaRecipe); + } + + private class RecipeListWrapper extends AbstractList { + private final List original; + + public RecipeListWrapper(List original) { + this.original = original; + } + + @Override + public int size() { + return original.size(); + } + + @Override + public boolean isEmpty() { + return original.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return original.contains(o); + } + + @Override + public Iterator iterator() { + return original.iterator(); + } + + @Override + public void forEach(Consumer action) { + original.forEach(action); + } + + @Override + public Object[] toArray() { + return original.toArray(); + } + + @Override + public T[] toArray(T[] a) { + return original.toArray(a); + } + + @Override + public boolean add(IRecipe iRecipe) { + boolean result = original.add(iRecipe); + if (result && !backwardWrappers.containsKey(iRecipe)) { + onMinecraftRecipeAdded(iRecipe); + } + + return result; + } + + @Override + public boolean remove(Object o) { + if (!backwardWrappers.containsKey(o)) { + return false; + } + + boolean result = original.remove(o); + if (result) { + onMinecraftRecipeRemoved((IRecipe) o); + } + + return result; + } + + @Override + public boolean containsAll(Collection c) { + return original.containsAll(c); + } + + @Override + public boolean addAll(Collection c) { + boolean result = false; + for (IRecipe recipe : c) { + result |= add(recipe); + } + return result; + } + + @Override + public boolean addAll(int index, Collection c) { + for (IRecipe recipe : c) { + add(index, recipe); + index++; + } + + return !c.isEmpty(); + } + + @Override + public boolean removeAll(Collection c) { + boolean result = false; + for (Object o : c) { + result |= c.remove(o); + } + return result; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void sort(Comparator c) { + original.sort(c); + } + + @Override + public void clear() { + // one would have to be a mad scientist to use this operation... but ok + + for (IRecipe recipe : original) { + onMinecraftRecipeRemoved(recipe); + } + + original.clear(); + } + + @Override + public IRecipe get(int index) { + return original.get(index); + } + + @Override + public IRecipe set(int index, IRecipe element) { + IRecipe current = original.get(index); + onMinecraftRecipeRemoved(current); + + original.set(index, element); + onMinecraftRecipeAdded(element); + + return current; + } + + @Override + public void add(int index, IRecipe element) { + original.add(index, element); + onMinecraftRecipeAdded(element); + } + + @Override + public IRecipe remove(int index) { + IRecipe current = original.remove(index); + onMinecraftRecipeRemoved(current); + return current; + } + + @Override + public int indexOf(Object o) { + return original.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + return original.lastIndexOf(o); + } + + @Override + public ListIterator listIterator() { + return original.listIterator(); + } + + @Override + public ListIterator listIterator(int index) { + return original.listIterator(index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return new RecipeListWrapper(original.subList(fromIndex, toIndex)); + } + + @Override + public Spliterator spliterator() { + return original.spliterator(); + } + + @Override + public Stream stream() { + return original.stream(); + } + + @Override + public Stream parallelStream() { + return original.parallelStream(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java new file mode 100644 index 000000000..29d385bee --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import nova.core.recipes.crafting.CraftingGrid; + +public class NovaCraftingGrid extends InventoryCrafting { + private final CraftingGrid craftingGrid; + + public NovaCraftingGrid(CraftingGrid craftingGrid) { + super(new NovaCraftingGridContainer(craftingGrid), craftingGrid.getWidth(), craftingGrid.getHeight()); + this.craftingGrid = craftingGrid; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java new file mode 100644 index 000000000..2059423a5 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import nova.core.recipes.crafting.CraftingGrid; + +/** + * TODO: complete this class. without it, modded recipes will not work when crafted from NOVA mods. + * @author Stan Hebben + */ +public class NovaCraftingGridContainer extends Container { + private final CraftingGrid craftingGrid; + + public NovaCraftingGridContainer(CraftingGrid craftingGrid) { + this.craftingGrid = craftingGrid; + } + + @Override + public boolean canInteractWith(EntityPlayer entityPlayer) { + return true; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java new file mode 100644 index 000000000..9c33ea307 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.NonNullList; +import net.minecraft.world.World; +import nova.core.item.Item; +import nova.core.recipes.crafting.CraftingRecipe; +import nova.internal.core.Game; + +import java.util.Optional; + +public class NovaCraftingRecipe implements IRecipe { + private final CraftingRecipe recipe; + + public NovaCraftingRecipe(CraftingRecipe recipe) { + this.recipe = recipe; + } + + @Override + public boolean matches(InventoryCrafting inventoryCrafting, World world) { + return recipe.matches(MCCraftingGrid.get(inventoryCrafting)); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { + Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventoryCrafting)); + if (craftingResult.isPresent()) { + return Game.natives().toNative(craftingResult.get()); + } else { + return null; + } + } + + @Override + public int getRecipeSize() { + return 1; + } + + @Override + public ItemStack getRecipeOutput() { + Optional nominalOutput = recipe.getNominalOutput(); + if (nominalOutput.isPresent()) { + return Game.natives().toNative(nominalOutput.get()); + } + return null; + } + + @Override + public NonNullList getRemainingItems(InventoryCrafting inv) { + return NonNullList.func_191196_a(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java new file mode 100644 index 000000000..ed7564aac --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import nova.core.item.Item; +import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.recipes.crafting.ItemIngredient; +import nova.core.recipes.crafting.OreItemIngredient; +import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.recipes.crafting.SpecificItemIngredient; +import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.internal.core.Game; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +/** + * Wraps Minecraft crafting recipes to NOVA crafting recipes and vice versa. + * + * Although a naive implementation could wrap NOVA recipes into its own recipe class and forward that, mods like NEI + * won't be able to handle those recipes. Hence we wrap them into ShapedRecipes / ShapelessRecipes / ShapedOreRecipes and ShapelessOreRecipes + * as much as possible. Only when that is not possible (a rare case, in practice) the generic wrapper is used. + * + * The reverse is also done, such that mods listening to NOVA ShapedCraftingRecipes and ShapelessCraftingRecipes would be + * given the proper information and be informed of their registration, if desired. + * @author Stan Hebben + */ +public class RecipeConverter { + public static final int TYPE_ADVANCED = 0; + public static final int TYPE_ORE = 1; + public static final int TYPE_BASIC = 2; + + private RecipeConverter() { + } + + private static int getIngredientType(ItemIngredient ingredient) { + if (ingredient instanceof SpecificItemIngredient) { + return TYPE_BASIC; + } else if (ingredient instanceof OreItemIngredient) { + return TYPE_ORE; + } else { + return TYPE_ADVANCED; + } + } + + private static Object getInternal(ItemIngredient ingredient) { + if (ingredient instanceof SpecificItemIngredient) { + return wrapSpecific((SpecificItemIngredient) ingredient); + } else if (ingredient instanceof OreItemIngredient) { + return ((OreItemIngredient) ingredient).getName(); + } + + return null; + } + + private static ItemIngredient getIngredient(Object ingredient) { + if (ingredient == null) { + return null; + } else if (ingredient instanceof ItemStack) { + return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID().asString()); // TODO? + } else if (ingredient instanceof String) { + return new OreItemIngredient((String) ingredient); + } else if (ingredient instanceof List) { + String oreDictEntry = findOreDictEntryFor((List) ingredient); + if (oreDictEntry == null) { + return null; + } + + return new OreItemIngredient(oreDictEntry); + } else { + return null; + } + } + + private static String findOreDictEntryFor(List ingredient) { + for (String key : net.minecraftforge.oredict.OreDictionary.getOreNames()) { + if (net.minecraftforge.oredict.OreDictionary.getOres(key).equals(ingredient)) { + return key; + } + } + + return null; + } + + private static ItemStack wrapSpecific(SpecificItemIngredient ingredient) { + for (Item item : ingredient.getExampleItems().get()) { + return Game.natives().toNative(item.getFactory().build()); + } + + throw new AssertionError("this can't be!"); + } + + private static int getRecipeType(ItemIngredient[] ingredients) { + int type = TYPE_BASIC; + for (ItemIngredient ingredient : ingredients) { + type = Math.min(type, getIngredientType(ingredient)); + } + return type; + } + + public static IRecipe toMinecraft(CraftingRecipe recipe) { + if (recipe instanceof ShapedCraftingRecipe) { + return convert((ShapedCraftingRecipe) recipe); + } else if (recipe instanceof ShapelessCraftingRecipe) { + return convert((ShapelessCraftingRecipe) recipe); + } else { + return new NovaCraftingRecipe(recipe); + } + } + + public static IRecipe convert(ShapelessCraftingRecipe recipe) { + ItemIngredient[] ingredients = recipe.getIngredients(); + int type = getRecipeType(ingredients); + + if (type == TYPE_BASIC) { + ItemStack[] items = new ItemStack[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + } + return new ShapelessRecipeBasic(items, recipe); + } else if (type == TYPE_ORE) { + Object[] items = new Object[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = getInternal(ingredients[i]); + } + return new ShapelessRecipeOre(items, recipe); + } else { + return new NovaCraftingRecipe(recipe); + } + } + + public static IRecipe convert(ShapedCraftingRecipe recipe) { + ItemIngredient[] ingredients = recipe.getIngredients(); + int[] posx = recipe.getIngredientsX(); + int[] posy = recipe.getIngredientsY(); + + // determine recipe type + int type = getRecipeType(ingredients); + + // construct recipe + if (type == TYPE_BASIC) { + ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()]; + for (int i = 0; i < ingredients.length; i++) { + basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + } + + return new ShapedRecipeBasic(basicIngredients, recipe); + } else if (type == TYPE_ORE) { + Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()]; + for (int i = 0; i < ingredients.length; i++) { + converted[posx[i] + posy[i] * recipe.getWidth()] = getInternal(ingredients[i]); + } + + // arguments contents: + // 1) recipe patterns + // 2) characters + ingredients + + int counter = 0; + String[] parts = new String[recipe.getHeight()]; + ArrayList rarguments = new ArrayList(); + for (int i = 0; i < recipe.getHeight(); i++) { + char[] pattern = new char[recipe.getWidth()]; + for (int j = 0; j < recipe.getWidth(); j++) { + int off = i * recipe.getWidth() + j; + if (converted[off] == null) { + pattern[j] = ' '; + } else { + pattern[j] = (char) ('A' + counter); + rarguments.add(pattern[j]); + rarguments.add(converted[off]); + counter++; + } + } + parts[i] = new String(pattern); + } + + rarguments.addAll(0, Arrays.asList(parts)); + + return new ShapedRecipeOre(rarguments.toArray(), recipe); + } else { + return new NovaCraftingRecipe(recipe); + } + } + + public static CraftingRecipe toNova(IRecipe recipe) { + ItemStack recipeOutput = recipe.getRecipeOutput(); + Item output; + if (recipeOutput == null) { + output = null; + } else { + output = Game.natives().toNova(recipeOutput); + } + + if (recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + + ItemIngredient[] ingredients = new ItemIngredient[shapeless.recipeItems.size()]; + for (int i = 0; i < ingredients.length; i++) { + ingredients[i] = getIngredient(shapeless.recipeItems.get(i)); + } + + return new ShapelessCraftingRecipe(output, ingredients); + } else if (recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes) recipe; + + Optional[][] ingredients = new Optional[shaped.recipeHeight][shaped.recipeWidth]; + for (int i = 0; i < shaped.recipeHeight; i++) { + for (int j = 0; j < shaped.recipeWidth; j++) { + ingredients[i][j] = Optional.ofNullable(getIngredient(shaped.recipeItems[i * shaped.recipeWidth + j])); + } + } + + return new ShapedCraftingRecipe(output, ingredients, false); + } else if (recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + + int width = ReflectionUtil.getShapedOreRecipeWidth(shaped); + int height = recipe.getRecipeSize() / width; + + Optional[][] recipeIngredients = new Optional[height][width]; + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + recipeIngredients[i][j] = Optional.ofNullable(getIngredient(shaped.getInput()[i * width + j])); + } + } + + return new ShapedCraftingRecipe(output, recipeIngredients, false); + } else if (recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + + ItemIngredient[] ingredients = new ItemIngredient[shapeless.getRecipeSize()]; + for (int i = 0; i < ingredients.length; i++) { + ingredients[i] = getIngredient(shapeless.getInput().get(i)); + } + + return new ShapelessCraftingRecipe(output, ingredients); + } else { + return new MCCraftingRecipe(recipe); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java new file mode 100644 index 000000000..8a8f4a40a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.world.World; +import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Stan Hebben + */ +public class ShapedRecipeBasic extends ShapedRecipes { + private final ShapedCraftingRecipe recipe; + + public ShapedRecipeBasic(ItemStack[] basicInputs, ShapedCraftingRecipe recipe) { + super(recipe.getWidth(), recipe.getHeight(), basicInputs, recipe.getNominalOutput().isPresent() ? Game.natives().toNative(recipe.getNominalOutput().get()) : null); + + this.recipe = recipe; + } + + @Override + public boolean matches(InventoryCrafting inventory, World world) { + return recipe.matches(MCCraftingGrid.get(inventory)); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventory) { + Optional result = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); + if (result.isPresent()) { + return Game.natives().toNative(result.get()); + } + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java new file mode 100644 index 000000000..f7c9b1c77 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.ShapedOreRecipe; +import nova.core.item.Item; +import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Stan + */ +public class ShapedRecipeOre extends ShapedOreRecipe { + private final ShapedCraftingRecipe recipe; + + public ShapedRecipeOre(Object[] contents, ShapedCraftingRecipe recipe) { + super((ItemStack) Game.natives().toNative(recipe.getNominalOutput().get()), contents); + + this.recipe = recipe; + } + + @Override + public boolean matches(InventoryCrafting inventory, World world) { + return recipe.matches(MCCraftingGrid.get(inventory)); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventory) { + Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); + if (craftingResult.isPresent()) { + return ((ItemStack) Game.natives().toNative(craftingResult.get())).copy(); + } + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java new file mode 100644 index 000000000..60f24670d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.world.World; +import nova.core.item.Item; +import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.internal.core.Game; + +import java.util.Arrays; +import java.util.Optional; + +/** + * @author Stan + */ +public class ShapelessRecipeBasic extends ShapelessRecipes { + private final ShapelessCraftingRecipe recipe; + + public ShapelessRecipeBasic(ItemStack[] ingredients, ShapelessCraftingRecipe recipe) { + super(recipe.getNominalOutput().isPresent() ? Game.natives().toNative(recipe.getNominalOutput().get()) : null, Arrays.asList(ingredients)); + + this.recipe = recipe; + } + + @Override + public boolean matches(InventoryCrafting inventory, World world) { + return recipe.matches(MCCraftingGrid.get(inventory)); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventory) { + Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); + if (craftingResult.isPresent()) { + return Game.natives().toNative(craftingResult.get()); + } + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java new file mode 100644 index 000000000..25aed3f64 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.recipes; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import nova.core.item.Item; +import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Stan Hebben + */ +public class ShapelessRecipeOre extends ShapelessOreRecipe { + private final ShapelessCraftingRecipe recipe; + + public ShapelessRecipeOre(Object[] ingredients, ShapelessCraftingRecipe recipe) { + super((ItemStack) Game.natives().toNative(recipe.getNominalOutput().get()), ingredients); + + this.recipe = recipe; + } + + @Override + public boolean matches(InventoryCrafting inventory, World world) { + return recipe.matches(MCCraftingGrid.get(inventory)); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventory) { + Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); + if (craftingResult.isPresent()) { + return ((ItemStack) Game.natives().toNative(craftingResult.get())).copy(); + } + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java new file mode 100644 index 000000000..08c06cae6 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.render; + +import com.google.common.base.Charsets; +import net.minecraft.client.resources.FolderResourcePack; +import net.minecraft.util.ResourceLocation; +import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class NovaFolderResourcePack extends FolderResourcePack { + private final String modid; + private final String[] domains; + + public NovaFolderResourcePack(File file, String modid, String[] domains) { + super(file); + this.modid = modid; + this.domains = domains; + } + + @Override + public Set getResourceDomains() { + Set domains = new HashSet<>(); + domains.add(modid); + domains.addAll(Arrays.asList(this.domains)); + return domains; + } + + private String transform(String path) { + return path; + } + + @Override + protected InputStream getInputStreamByName(String path) throws IOException { + try { + return new BufferedInputStream(new FileInputStream(new File(this.resourcePackFile, transform(path)))); + } catch (IOException e) { + if (path.endsWith("sounds.json")) { + return new ByteArrayInputStream(NovaMinecraftPreloader.generateSoundJSON(this).getBytes(Charsets.UTF_8)); + } else if (path.equals("pack.mcmeta")) { + return new ByteArrayInputStream(NovaMinecraftPreloader.generatePackMcmeta().getBytes(Charsets.UTF_8)); + } else { + if (path.endsWith(".mcmeta")) { + return new ByteArrayInputStream("{}".getBytes()); + } + throw e; + } + } + } + + @Override + public boolean hasResourceName(String path) { + return super.hasResourceName(transform(path)); + } + + @Override + public boolean resourceExists(ResourceLocation rl) { + //Hack Sounds + if (rl.getResourcePath().endsWith("sounds.json") || rl.getResourcePath().endsWith("pack.mcmeta")) { + return true; + } + + return new File(resourcePackFile, "assets/" + rl.getResourceDomain() + "/" + rl.getResourcePath()).isFile() || new File(resourcePackFile, rl.getResourceDomain() + "/" + rl.getResourcePath().replace(".mcmeta", "")).isFile(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java new file mode 100644 index 000000000..6793348bb --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.render; + +import com.google.common.base.Charsets; +import net.minecraft.client.resources.FileResourcePack; +import net.minecraft.util.ResourceLocation; +import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public class NovaResourcePack extends FileResourcePack { + private final String modid; + private final String[] domains; + + public NovaResourcePack(File p_i1290_1_, String modid, String[] domains) { + super(p_i1290_1_); + this.modid = modid; + this.domains = domains; + } + + @Override + public Set getResourceDomains() { + HashSet domains = new HashSet<>(); + domains.add(modid); + domains.addAll(Arrays.asList(this.domains)); + return domains; + } + + private String transform(String path) { + return path.replaceFirst("assets[/\\\\]minecraft", modid); + } + + @Override + protected InputStream getInputStreamByName(String path) throws IOException { + try { + return super.getInputStreamByName(transform(path)); + } catch (IOException e) { + if (path.endsWith("sounds.json")) { + return new ByteArrayInputStream(NovaMinecraftPreloader.generateSoundJSON(this).getBytes(Charsets.UTF_8)); + } else if (path.equals("pack.mcmeta")) { + return new ByteArrayInputStream(NovaMinecraftPreloader.generatePackMcmeta().getBytes(Charsets.UTF_8)); + } else { + if (path.endsWith(".mcmeta")) { + return new ByteArrayInputStream("{}".getBytes()); + } + throw e; + } + } + } + + @Override + public boolean hasResourceName(String path) { + return super.hasResourceName(transform(path)); + } + + @Override + public boolean resourceExists(ResourceLocation rl) { + //Hack Sounds and McMeta + if (rl.getResourcePath().endsWith("sounds.json") || rl.getResourcePath().endsWith("pack.mcmeta")) { + return true; + } + + return super.resourceExists(rl); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java new file mode 100644 index 000000000..bb66e4662 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockPart; +import net.minecraft.client.renderer.block.model.BlockPartFace; +import net.minecraft.client.renderer.block.model.FaceBakery; +import net.minecraft.client.renderer.block.model.ItemModelGenerator; +import net.minecraft.client.renderer.block.model.ModelBlock; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelRotation; +import net.minecraft.client.renderer.block.model.SimpleBakedModel; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IResource; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.component.renderer.ItemRenderer; +import nova.core.component.renderer.StaticRenderer; +import nova.core.render.texture.BlockTexture; +import nova.core.render.texture.ItemTexture; +import nova.core.render.texture.Texture; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWEmptyModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWSmartBlockModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWSmartItemModel; +import nova.internal.core.Game; +import org.lwjgl.opengl.GL11; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Optional; + +import static org.lwjgl.opengl.GL11.GL_BLEND; +import static org.lwjgl.opengl.GL11.GL_FLAT; +import static org.lwjgl.opengl.GL11.GL_LINE_SMOOTH; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_POLYGON_SMOOTH; +import static org.lwjgl.opengl.GL11.GL_SMOOTH; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glDisable; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL11.glShadeModel; + +import net.minecraft.client.renderer.block.model.ItemOverrideList; + +/** + * @author Calclavia + */ +@SideOnly(Side.CLIENT) +public class RenderUtility { + + public static final ResourceLocation particleResource = new ResourceLocation("textures/particle/particles.png"); + + public static final RenderUtility instance = new RenderUtility(); + // Cruft needed to generate default item models + protected static final ItemModelGenerator ITEM_MODEL_GENERATOR = new ItemModelGenerator(); + protected static final FaceBakery FACE_BAKERY = new FaceBakery(); + // Ugly D: + protected static final ModelBlock MODEL_GENERATED = ModelBlock.deserialize( + "{\"" + + "elements\":[{" + + " \"from\": [0, 0, 0], " + + " \"to\": [16, 16, 16], " + + " \"faces\": {" + + " \"down\": {\"uv\": [0, 0, 16, 16], \"texture\":\"\"}" + + " }}]," + + " \"display\": {\n" + + " \"thirdperson_righthand\": {\n" + + " \"rotation\": [ -90, 0, 0 ],\n" + + " \"translation\": [ 0, 1, -3 ],\n" + + " \"scale\": [ 0.55, 0.55, 0.55 ]\n" + + " },\n" + + " \"firstperson_righthand\": {\n" + + " \"rotation\": [ 0, -135, 25 ],\n" + + " \"translation\": [ 0, 4, 2 ],\n" + + " \"scale\": [ 1.7, 1.7, 1.7 ]\n" + + " }\n" + + " \"firstperson_lefthand\": {\n" + + " \"rotation\": [ 0, 135, 25 ],\n" + + " \"translation\": [ 0, 4, 2 ],\n" + + " \"scale\": [ 1.7, 1.7, 1.7 ]\n" + + " }\n" + + "}}"); + //NOVA Texture to MC TextureAtlasSprite + private final HashMap textureMap = new HashMap<>(); + + /** + * Enables blending. + */ + public static void enableBlending() { + glShadeModel(GL_SMOOTH); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + /** + * Disables blending. + */ + public static void disableBlending() { + glShadeModel(GL_FLAT); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_POLYGON_SMOOTH); + glDisable(GL_BLEND); + } + + public static void enableLighting() { + RenderHelper.enableStandardItemLighting(); + } + + /** + * Disables lighting and turns glow on. + */ + public static void disableLighting() { + RenderHelper.disableStandardItemLighting(); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F); + } + + public static void disableLightmap() { + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public static void enableLightmap() { + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public TextureAtlasSprite getTexture(Texture texture) { + if (textureMap.containsKey(texture)) { + return textureMap.get(texture); + } + + //Fallback to MC texture + return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.domain + ":" + texture.getPath().replaceFirst("textures/", "").replace(".png", "")); + } + + /** + * Handles NOVA texture registration. + * @param event Event + */ + @SubscribeEvent + public void preTextureHook(TextureStitchEvent.Pre event) { + if (event.getMap() == Minecraft.getMinecraft().getTextureMapBlocks()) { + Game.render().blockTextures.forEach(t -> registerIcon(t, event)); + Game.render().itemTextures.forEach(t -> registerIcon(t, event)); + //TODO: This is HACKS. We should create custom sprite sheets for entities. + Game.render().entityTextures.forEach(t -> registerIcon(t, event)); + } + } + + public void registerIcon(Texture texture, TextureStitchEvent.Pre event) { + String resPath = (texture instanceof BlockTexture ? "blocks" : texture instanceof ItemTexture ? "items" : "entities") + "/" + texture.resource; + textureMap.put(texture, event.getMap().registerSprite(new ResourceLocation(texture.domain, resPath))); + } + + @SubscribeEvent + public void onModelBakeEvent(ModelBakeEvent event) { + //Register all blocks + Game.blocks().registry.forEach(blockFactory -> { + Object blockObj = Game.natives().toNative(blockFactory.build()); + if (blockObj instanceof FWBlock) { + FWBlock block = (FWBlock) blockObj; + ResourceLocation blockRL = (ResourceLocation) net.minecraft.block.Block.REGISTRY.getNameForObject(block); + Item itemFromBlock = Item.getItemFromBlock(block); + ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(itemFromBlock); + ModelResourceLocation blockLocation = new ModelResourceLocation(blockRL, "normal"); + ModelResourceLocation itemLocation = new ModelResourceLocation(itemRL, "inventory"); + if (block.dummy.components.has(StaticRenderer.class)) { + event.getModelRegistry().putObject(blockLocation, new FWSmartBlockModel(block.dummy, true)); + } else { + event.getModelRegistry().putObject(blockLocation, new FWEmptyModel()); + } + event.getModelRegistry().putObject(itemLocation, new FWSmartBlockModel(block.dummy, true)); + } + }); + + //Register all items + Game.items().registry.forEach(itemFactory -> { + Object stackObj = Game.natives().toNative(itemFactory.build()); + if (stackObj instanceof ItemStack) { + Item itemObj = ((ItemStack) stackObj).getItem(); + if (itemObj instanceof FWItem) { + FWItem item = (FWItem) itemObj; + ResourceLocation objRL = (ResourceLocation) Item.REGISTRY.getNameForObject(item); + ModelResourceLocation itemLocation = new ModelResourceLocation(objRL, "inventory"); + + nova.core.item.Item dummy = item.getItemFactory().build(); + + if (dummy.components.has(ItemRenderer.class)) { + Optional texture = dummy.components.get(ItemRenderer.class).texture; + + if (texture.isPresent()) { + MODEL_GENERATED.textures.put("layer0", texture.get().getResource()); + MODEL_GENERATED.name = itemLocation.toString(); + + // This is the key part, it takes the texture and makes the "3d" one wide voxel model + ModelBlock itemModel = ITEM_MODEL_GENERATOR.makeItemModel(new FakeTextureMap(dummy), MODEL_GENERATED); + + // This was taken from ModelBakery and simplified for the generation of our Items + SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(itemModel, ItemOverrideList.NONE).setTexture(getTexture(texture.get())); + for (BlockPart blockpart : (Iterable) itemModel.getElements()) { + for (EnumFacing enumfacing : (Iterable) blockpart.mapFaces.keySet()) { + BlockPartFace blockpartface = (BlockPartFace) blockpart.mapFaces.get(enumfacing); + BakedQuad bakedQuad = FACE_BAKERY.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, blockpartface, getTexture(texture.get()), enumfacing, ModelRotation.X0_Y0, blockpart.partRotation, false, blockpart.shade); + + if (blockpartface.cullFace == null || !TRSRTransformation.isInteger(ModelRotation.X0_Y0.getMatrix())) { + builder.addGeneralQuad(bakedQuad); + } else { + + builder.addFaceQuad(ModelRotation.X0_Y0.rotate(blockpartface.cullFace), bakedQuad); + } + } + } + event.getModelRegistry().putObject(itemLocation, builder.makeBakedModel()); + } else { + event.getModelRegistry().putObject(itemLocation, new FWSmartItemModel(dummy)); + } + } + } + } + }); + } + + public void preInit() { + //Load models + Game.render().modelProviders.forEach(m -> { + ResourceLocation resource = new ResourceLocation(m.domain, "models/" + m.name + "." + m.getType()); + try { + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); + m.load(res.getInputStream()); + } catch (IOException e) { + throw new RuntimeException("IO Exception reading model format", e); + } + }); + } + + private class FakeTextureMap extends TextureMap { + private final nova.core.item.Item item; + + public FakeTextureMap(nova.core.item.Item item) { + super(""); + this.item = item; + } + + @Override + public TextureAtlasSprite getAtlasSprite(String iconName) { + if (item.components.has(ItemRenderer.class)) { + ItemRenderer itemRenderer = item.components.get(ItemRenderer.class); + if (itemRenderer.texture.isPresent()) { + return RenderUtility.instance.getTexture(itemRenderer.texture.get()); + } + } + return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java new file mode 100644 index 000000000..8bc1b9487 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper; + +import net.minecraft.util.math.BlockPos; +import nova.core.nativewrapper.NativeConverter; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +public class VectorConverter implements NativeConverter { + @Override + public Class getNovaSide() { + return Vector3D.class; + } + + @Override + public Class getNativeSide() { + return BlockPos.class; + } + + @Override + public Vector3D toNova(BlockPos pos) { + return new Vector3D(pos.getX(), pos.getY(), pos.getZ()); + } + + @Override + public BlockPos toNative(Vector3D vec) { + return new BlockPos(vec.getX(), vec.getY(), vec.getZ()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java new file mode 100644 index 000000000..c60d7821a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.registry.GameRegistry; +import nova.core.block.Block; +import nova.core.block.BlockFactory; +import nova.core.block.BlockManager; +import nova.core.component.Category; +import nova.core.event.BlockEvent; +import nova.core.loader.Loadable; +import nova.core.nativewrapper.NativeConverter; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItemBlock; +import nova.internal.core.Game; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Optional; + +/** + * @author Calclavia + */ +//TODO: Should be +public class BlockConverter implements NativeConverter, Loadable { + /** + * A map of all blockFactory to MC blocks registered + */ + public final HashMap blockFactoryMap = new HashMap<>(); + + public static BlockConverter instance() { + return (BlockConverter) Game.natives().getNative(Block.class, net.minecraft.block.Block.class); + } + + @Override + public Class getNovaSide() { + return Block.class; + } + + @Override + public Class getNativeSide() { + return net.minecraft.block.Block.class; + } + + @Override + public Block toNova(net.minecraft.block.Block nativeBlock) { + //Prevent recursive wrapping + if (nativeBlock instanceof FWBlock) { + return ((FWBlock) nativeBlock).dummy; + } + + if (nativeBlock == Blocks.AIR) { + return Game.blocks().getAirBlock().build(); + } + + return new BWBlock(nativeBlock); + } + + @Override + public net.minecraft.block.Block toNative(Block novaBlock) { + //Prevent recursive wrapping + if (novaBlock instanceof BWBlock) { + return ((BWBlock) novaBlock).mcBlock; + } + + return toNative(novaBlock.getFactory()); + } + + public net.minecraft.block.Block toNative(BlockFactory blockFactory) { + return blockFactoryMap.get(blockFactory); + } + + /** + * Register all Nova blocks + */ + public void preInit() { + registerMinecraftToNOVA(); + registerNOVAToMinecraft(); + } + + private void registerMinecraftToNOVA() { + //TODO: Will this register ALL Forge mod blocks as well? + BlockManager blockManager = Game.blocks(); + net.minecraft.block.Block.REGISTRY.forEach(obj -> + blockManager.register( + new BlockFactory(net.minecraft.block.Block.REGISTRY.getNameForObject(obj).toString(), + () -> new BWBlock((net.minecraft.block.Block) obj), evt -> { + }) + ) + ); + } + + private void registerNOVAToMinecraft() { + BlockManager blockManager = Game.blocks(); + + //Register air block + BlockFactory airBlock = new BlockFactory("air", () -> new BWBlock(Blocks.AIR) { + @Override + public boolean canReplace() { + return true; + } + }, evt -> { + }); + + blockManager.register(airBlock); + + //NOTE: There should NEVER be blocks already registered in preInit() stage of a NativeConverter. + Game.events().on(BlockEvent.Register.class).bind(evt -> registerNovaBlock(evt.blockFactory)); + } + + private void registerNovaBlock(BlockFactory blockFactory) { + FWBlock blockWrapper = new FWBlock(blockFactory); + FWItemBlock itemBlockWrapper = new FWItemBlock(blockWrapper); + blockFactoryMap.put(blockFactory, blockWrapper); + GameRegistry.register(blockWrapper, new ResourceLocation(blockFactory.getID().asString())); + GameRegistry.register(itemBlockWrapper, new ResourceLocation(blockFactory.getID().asString())); + NovaMinecraft.proxy.postRegisterBlock(blockWrapper); + + if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { + //Add into creative tab + Category category = blockWrapper.dummy.components.get(Category.class); + Optional first = Arrays.stream(CreativeTabs.CREATIVE_TAB_ARRAY) + .filter(tab -> tab.getTabLabel().equals(category.name)) + .findFirst(); + if (first.isPresent()) { + blockWrapper.setCreativeTab(first.get()); + } else { + Optional item = category.item; + ModCreativeTab tab = new ModCreativeTab(category.name, item.isPresent() ? Game.natives().toNative(item.get()) : Item.getItemFromBlock(blockWrapper)); + blockWrapper.setCreativeTab(tab); + } + } + + System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java new file mode 100644 index 000000000..25664bb09 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward; + +import net.minecraft.block.BlockSnow; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import nova.core.block.Block; +import nova.core.block.component.BlockProperty; +import nova.core.block.component.LightEmitter; +import nova.core.component.misc.Collider; +import nova.core.component.transform.BlockTransform; +import nova.core.item.ItemFactory; +import nova.core.retention.Data; +import nova.core.retention.Storable; +import nova.core.retention.Store; +import nova.core.sound.Sound; +import nova.core.util.shape.Cuboid; +import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.BWWorld; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class BWBlock extends Block implements Storable { + public final net.minecraft.block.Block mcBlock; + @Store + public int metadata; + private TileEntity mcTileEntity; + + public BWBlock(net.minecraft.block.Block block) { + this.mcBlock = block; + } + + public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { + this.mcBlock = block; + + BlockTransform transform = components.add(new BlockTransform()); + transform.setWorld(world); + transform.setPosition(pos); + + components.add(new BlockProperty.Opacity().setLightTransmission(!blockState().getMaterial().blocksLight())); + + BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", mcBlock.getSoundType().getPlaceSound().getSoundName().getResourcePath())); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", mcBlock.getSoundType().getBreakSound().getSoundName().getResourcePath())); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", mcBlock.getSoundType().getStepSound().getSoundName().getResourcePath())); + + components.add(new LightEmitter()).setEmittedLevel(() -> mcBlock.getLightValue(blockState(), getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); + components.add(new Collider(this)) + .setBoundingBox(() -> { + AxisAlignedBB aabb = mcBlock.getBoundingBox(blockState(), getMcBlockAccess(), new BlockPos(x(), y(), z())); + return new Cuboid(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); + }).setOcclusionBoxes(entity -> { + List aabbs = new ArrayList<>(); + mcBlock.addCollisionBoxToList( + blockState(), + Game.natives().toNative(world()), + new BlockPos(x(), y(), z()), + Game.natives().toNative(entity.isPresent() ? entity.get().components.get(Collider.class).boundingBox.get() : Cuboid.ONE.add(pos)), + aabbs, + entity.isPresent() ? Game.natives().toNative(entity.get()) : null + ); + return aabbs.stream() + .map(aabb -> (Cuboid) Game.natives().toNova(aabb)) + .map(cuboid -> cuboid.subtract(pos)) + .collect(Collectors.toSet()); + }); + //TODO: Set selection bounds + } + + @Override + public ItemFactory getItemFactory() { + return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(mcBlock))); + } + + private IBlockAccess getMcBlockAccess() { + return ((BWWorld) world()).access; + } + + private IBlockState blockState() { + return getMcBlockAccess().getBlockState(new BlockPos(x(), y(), z())); + } + + private TileEntity getTileEntity() { + if (mcTileEntity == null && mcBlock.hasTileEntity(blockState())) { + mcTileEntity = getMcBlockAccess().getTileEntity(new BlockPos(x(), y(), z())); + } + return mcTileEntity; + } + + @Override + public boolean canReplace() { + return mcBlock.canPlaceBlockAt((net.minecraft.world.World) getMcBlockAccess(), new BlockPos(x(), y(), z())); + } + + @Override + public boolean shouldDisplacePlacement() { + if (mcBlock == Blocks.SNOW_LAYER && ((int) blockState().getValue(BlockSnow.LAYERS) < 1)) { + return false; + } + + if (mcBlock == Blocks.VINE || mcBlock == Blocks.TALLGRASS || mcBlock == Blocks.DEADBUSH || mcBlock.isReplaceable(Game.natives().toNative(world()), new BlockPos(x(), y(), z()))) { + return false; + } + return super.shouldDisplacePlacement(); + } + + @Override + public void save(Data data) { + Storable.super.save(data); + + TileEntity tileEntity = getTileEntity(); + if (tileEntity != null) { + NBTTagCompound nbt = new NBTTagCompound(); + tileEntity.writeToNBT(nbt); + data.putAll(Game.natives().toNova(nbt)); + } + } + + @Override + public void load(Data data) { + Storable.super.load(data); + + TileEntity tileEntity = getTileEntity(); + if (tileEntity != null) { + tileEntity.writeToNBT(Game.natives().toNative(data)); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java new file mode 100644 index 000000000..57c2117a3 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.world.World; + +/** + * @author Stan Hebben + */ +public final class BlockPosition { + private final World world; + private final int x; + private final int y; + private final int z; + + public BlockPosition(World world, int x, int y, int z) { + this.world = world; + this.x = x; + this.y = y; + this.z = z; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + BlockPosition that = (BlockPosition) o; + + if (x != that.x) { + return false; + } + if (y != that.y) { + return false; + } + if (z != that.z) { + return false; + } + if (!world.equals(that.world)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = world.hashCode(); + result = 31 * result + x; + result = 31 * result + y; + result = 31 * result + z; + return result; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java new file mode 100644 index 000000000..0821c3bea --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.block.SoundType; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import nova.core.block.Block; +import nova.core.block.BlockFactory; +import nova.core.block.Stateful; +import nova.core.block.component.BlockProperty; +import nova.core.block.component.LightEmitter; +import nova.core.component.Updater; +import nova.core.component.misc.Collider; +import nova.core.retention.Storable; +import nova.core.sound.Sound; +import nova.core.util.Direction; +import nova.core.util.shape.Cuboid; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * A Minecraft to Nova block wrapper + * @author Calclavia + */ +public class FWBlock extends net.minecraft.block.Block { + public final Block dummy; + /** + * Reference to the wrapper Nova block + */ + private final BlockFactory factory; + private final Class blockClass; + //TODO: Hack. Bad practice. + public IBlockAccess lastExtendedWorld; + public BlockPos lastExtendedStatePos; + private Map harvestedBlocks = new HashMap<>(); + + private static Material getMcMaterial(BlockFactory factory) { + Block dummy = factory.build(); + if (dummy.components.has(BlockProperty.Opacity.class)) { + // TODO allow color selection + return new ProxyMaterial(MapColor.GRAY, dummy.components.get(BlockProperty.Opacity.class)); + } else { + return Material.PISTON; + } + } + + public FWBlock(BlockFactory factory) { + //TODO: Hack build() method + super(getMcMaterial(factory)); + this.factory = factory; + this.dummy = factory.build(); + if (dummy.components.has(BlockProperty.BlockSound.class)) { + this.blockSoundType = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class)); + } else { + BlockProperty.BlockSound properties = dummy.components.add(new BlockProperty.BlockSound()); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", SoundType.STONE.getPlaceSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", SoundType.STONE.getStepSound().getSoundName().getResourcePath())); + this.blockSoundType = SoundType.STONE; + } + this.blockClass = dummy.getClass(); + this.setUnlocalizedName(dummy.getID().asString()); // TODO? + + // Recalculate super constructor things after loading the block properly + this.fullBlock = getDefaultState().isOpaqueCube(); + this.lightOpacity = this.fullBlock ? 255 : 0; + this.translucent = !this.fullBlock; + } + + public Block getBlockInstance(IBlockAccess access, Vector3D position) { + /** + * If this block has a TileEntity, forward the method into the Stateful + * block. Otherwise, create a new instance of the block and forward the + * methods over. + */ + if (hasTileEntity(null)) { + FWTile tileWrapper = (FWTile) access.getTileEntity(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())); + if (tileWrapper != null && tileWrapper.getBlock() != null) { + return tileWrapper.getBlock(); + } + + try { + throw new RuntimeException("Error: Block in TileWrapper is null for " + dummy); + } catch (Exception e) { + e.printStackTrace(); + } + } + return getBlockInstance((nova.core.world.World) Game.natives().toNova(access), position); + + } + + private Block getBlockInstance(nova.core.world.World world, Vector3D position) { + // TODO: Implement obj args + Block block = factory.build(); + block.components.add(new MCBlockTransform(block, world, position)); + return block; + } + + @Override + public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { + // HACK: called before block is destroyed by the player prior to the + // player getting the drops. Determine drops here. + // hack is needed because the player sets the block to air *before* + // getting the drops. woo good logic from mojang. + if (!player.capabilities.isCreativeMode) { + harvestedBlocks.put(new BlockPosition(world, pos.getX(), pos.getY(), pos.getZ()), getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + } + } + + @Override + public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + Block blockInstance; + + // see onBlockHarvested for why the harvestedBlocks hack exists + // this method will be called exactly once after destroying the block + BlockPosition position = new BlockPosition((World) world, pos.getX(), pos.getY(), pos.getZ()); + if (harvestedBlocks.containsKey(position)) { + blockInstance = harvestedBlocks.remove(position); + } else { + blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + } + + Block.DropEvent event = new Block.DropEvent(blockInstance); + blockInstance.events.publish(event); + + return new ArrayList<>( + event.drops + .stream() + .map(item -> (ItemStack) Game.natives().toNative(item)) + .collect(Collectors.toCollection(ArrayList::new)) + ); + } + + @Override + public boolean hasTileEntity(IBlockState state) { + // A block requires a TileEntity if it stores data or if it ticks. + return Storable.class.isAssignableFrom(blockClass) || Stateful.class.isAssignableFrom(blockClass) || Updater.class.isAssignableFrom(blockClass); + } + + @Override + public TileEntity createTileEntity(World world, IBlockState state) { + FWTile fwTile = FWTileLoader.loadTile(dummy.getID().asString()); // TODO? + if (lastExtendedStatePos != null) { + fwTile.block.components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ()))); + lastExtendedStatePos = null; + } + return fwTile; + } + + @Override + public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { + lastExtendedWorld = world; + lastExtendedStatePos = pos; + return super.getExtendedState(state, world, pos); + } + + @Override + public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighborBlock) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + // Minecraft does not provide the neighbor :( + Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.empty()); + blockInstance.events.publish(evt); + } + + @Override + public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(Game.natives().toNova(player))); + blockInstance.events.publish(evt); + if (evt.result) { + return super.removedByPlayer(state, world, pos, player, willHarvest); + } + return false; + } + + @Override + public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + RayTraceResult mop = player.rayTrace(10, 1); + Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player), Direction.fromOrdinal(mop.sideHit.ordinal()), new Vector3D(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord)); + blockInstance.events.publish(evt); + } + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player), Direction.fromOrdinal(side.ordinal()), new Vector3D(hitX, hitY, hitZ)); + blockInstance.events.publish(evt); + return evt.result; + } + + + @Override + public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + blockInstance.components.getOp(Collider.class).ifPresent(collider -> blockInstance.events.publish(new Collider.CollideEvent(Game.natives().toNova(entity)))); + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess access, BlockPos pos) { + Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + if (blockInstance.components.has(Collider.class)) { + Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get(); + return new AxisAlignedBB(cuboid.min.getX(), cuboid.min.getY(), cuboid.min.getZ(), cuboid.max.getX(), cuboid.max.getY(), cuboid.max.getZ()); + } + return super.getBoundingBox(state, access, pos); + } + + @Override + public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + + if (blockInstance.components.has(Collider.class)) { + Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get(); + return Game.natives().toNative(cuboid.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + } + return super.getSelectedBoundingBox(state, world, pos); + } + + @Override + public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB boundingBox, List list, Entity entity) { + Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + blockInstance.components.getOp(Collider.class).ifPresent( + collider -> { + Set boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? Game.natives().toNova(entity) : null)); + + list.addAll( + boxes + .stream() + .map(c -> c.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ()))) + .filter(c -> c.intersects((Cuboid) Game.natives().toNova(boundingBox))) + .map(cuboid -> (AxisAlignedBB) Game.natives().toNative(cuboid)) + .collect(Collectors.toList()) + ); + } + ); + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + if (dummy == null) { + // Superconstructor fix. -10 style points. + return true; + } + + Optional blockCollider = dummy.components.getOp(Collider.class); + + if (blockCollider.isPresent()) { + return blockCollider.get().isOpaqueCube.get(); + } else { + return super.isOpaqueCube(state); + } + } + + @Override + public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { + Optional blockCollider = dummy.components.getOp(Collider.class); + + if (blockCollider.isPresent()) { + return blockCollider.get().isCube.get(); + } else { + return super.isNormalCube(state, world, pos); + } + } + + @Override + public boolean isFullCube(IBlockState state) { + return isNormalCube(state); + } + + @Override + public int getLightValue(IBlockState state, IBlockAccess access, BlockPos pos) { + Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Optional opEmitter = blockInstance.components.getOp(LightEmitter.class); + + if (opEmitter.isPresent()) { + return Math.round(opEmitter.get().emittedLevel.get() * 15.0F); + } else { + return 0; + } + } + + @Override + public BlockRenderLayer getBlockLayer() { + return BlockRenderLayer.CUTOUT; + } + + @Override + public boolean canConnectRedstone(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { + Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + WrapperEvent.RedstoneConnect event = new WrapperEvent.RedstoneConnect(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); + Game.events().publish(event); + return event.canConnect; + } + + @Override + public int getWeakPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { + Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + WrapperEvent.WeakRedstone event = new WrapperEvent.WeakRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); + Game.events().publish(event); + return event.power; + } + + @Override + public int getStrongPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { + Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + WrapperEvent.StrongRedstone event = new WrapperEvent.StrongRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); + Game.events().publish(event); + return event.power; + } + + @Override + public String getUnlocalizedName() { + return super.getUnlocalizedName().replaceFirst("tile", "block"); + } + + @Override + public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { + // TODO: Maybe do something withPriority these parameters. + return (float) getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).getResistance() * 30; + } + + @Override + public float getBlockHardness(IBlockState state, World world, BlockPos pos) { + return (float) getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).getHardness() * 2; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java new file mode 100644 index 000000000..5107fc0ff --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java @@ -0,0 +1,67 @@ +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.block.SoundType; +import net.minecraft.init.SoundEvents; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; +import nova.core.block.component.BlockProperty.BlockSound; +import nova.core.sound.Sound; + +/** + * @author winsock, soniex2 + */ +public class FWBlockSound extends SoundType { + private final BlockSound blockSound; + + /** + * Construct a new FWBlockSound + * @param blockSound The BlockSound to use. + */ + public FWBlockSound(BlockSound blockSound) { + super(1f, 1f, SoundEvents.BLOCK_STONE_BREAK, SoundEvents.BLOCK_STONE_STEP, SoundEvents.BLOCK_STONE_PLACE, SoundEvents.BLOCK_STONE_HIT, SoundEvents.BLOCK_STONE_FALL); + this.blockSound = blockSound; + } + + @Override + public SoundEvent getBreakSound() { + if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.BREAK)) { + Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.BREAK); + if (sound.domain.isEmpty() && !sound.name.contains(".")) { + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("dig." + sound.name)); + return event == null ? super.getPlaceSound() : event; + } + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + return event == null ? super.getPlaceSound() : event; + } + return super.getBreakSound(); + } + + @Override + public SoundEvent getStepSound() { + if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.WALK)) { + Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.WALK); + if (sound.domain.isEmpty() && !sound.name.contains(".")) { + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("step." + sound.name)); + return event == null ? super.getPlaceSound() : event; + } + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + return event == null ? super.getPlaceSound() : event; + } + return super.getStepSound(); + } + + @Override + public SoundEvent getPlaceSound() { + if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.WALK)) { + Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.WALK); + if (sound.domain.isEmpty()) { + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.name)); + return event == null ? super.getPlaceSound() : event; + } + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + return event == null ? super.getPlaceSound() : event; + } + // By default MC uses the block break sound for block placement + return super.getPlaceSound(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java new file mode 100644 index 000000000..25f5bb98a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import nova.core.block.Block; +import nova.core.block.Stateful; +import nova.core.network.Syncable; +import nova.core.retention.Data; +import nova.core.retention.Storable; +import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.io.IOException; + +/** + * A Minecraft TileEntity to Nova block wrapper + * @author Calclavia + */ +public class FWTile extends TileEntity { + + protected String blockID; + protected Block block; + protected Data cacheData = null; + + public FWTile() { + + } + + public FWTile(String blockID) { + this.blockID = blockID; + } + + public Block getBlock() { + return block; + } + + public void setBlock(Block block) { + this.block = block; + } + + @Override + public SPacketUpdateTileEntity getUpdatePacket() { + if (block instanceof Syncable) { + return new FWPacketUpdateTileEntity(((MCNetworkManager) Game.network()).toMCPacket(((MCNetworkManager) Game.network()).writePacket(0, (Syncable) block)), + this.getPos(), this.getBlockMetadata(), this.getTileData()); + } + return null; + } + + @Override + public void validate() { + super.validate(); + block.components.getOrAdd(new MCBlockTransform(block, Game.natives().toNova(getWorld()), new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + + if (cacheData != null && block instanceof Storable) { + ((Storable) block).load(cacheData); + cacheData = null; + } + + block.events.publish(new Stateful.LoadEvent()); + } + + @Override + public void invalidate() { + block.events.publish(new Stateful.UnloadEvent()); + super.invalidate(); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setString("novaID", blockID); + + if (block != null) { + if (block instanceof Storable) { + Data data = new Data(); + ((Storable) block).save(data); + nbt.setTag("nova", Game.natives().toNative(data)); + } + } + + return nbt; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + blockID = nbt.getString("novaID"); + cacheData = Game.natives().toNova(nbt.getCompoundTag("nova")); + } + + private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { + private final Packet packet; + + public FWPacketUpdateTileEntity(Packet packet, BlockPos blockPosIn, int metadataIn, NBTTagCompound compoundIn) { + super(blockPosIn, metadataIn, compoundIn); + this.packet = packet; + } + + @Override + public void processPacket(INetHandlerPlayClient handler) { + super.processPacket(handler); + try { + this.packet.processPacket((T) handler); + } catch (ClassCastException | NoSuchMethodError e) { + // Why did Mojang incompatibly replace getDescriptionPacket() with getUpdatePacket(). + } + } + + @Override + public void writePacketData(PacketBuffer buf) throws IOException { + super.writePacketData(buf); + this.packet.writePacketData(buf); + } + + @Override + public void readPacketData(PacketBuffer buf) throws IOException { + super.readPacketData(buf); + this.packet.readPacketData(buf); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java new file mode 100644 index 000000000..0d9002636 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.nbt.NBTTagCompound; +import nova.core.block.Block; +import nova.core.block.BlockFactory; +import nova.core.component.Updater; +import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Vic Nightfall + */ +public final class FWTileLoader { + + private static ComponentInjector injector = new ComponentInjector<>(FWTile.class); + private static ComponentInjector updaterInjector = new ComponentInjector<>(FWTileUpdater.class); + + private FWTileLoader() { + } + + public static FWTile loadTile(NBTTagCompound data) { + try { + String blockID = data.getString("novaID"); + Block block = createBlock(blockID); + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); + tile.setBlock(block); + return tile; + } catch (Exception e) { + throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); + } + } + + public static FWTile loadTile(String blockID) { + try { + Block block = createBlock(blockID); + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { + String.class }, new Object[] { blockID }); + tile.setBlock(block); + return tile; + } catch (Exception e) { + throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); + } + } + + private static Block createBlock(String blockID) { + Optional blockFactory = Game.blocks().get(blockID); + if (blockFactory.isPresent()) { + return blockFactory.get().build(); + } else { + throw new RuntimeException("Error! Invalid NOVA block ID: " + blockID); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java new file mode 100644 index 000000000..a7edf4759 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.tileentity.TileEntity; +import nova.core.block.Block; +import nova.core.component.renderer.DynamicRenderer; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWModel; + +import java.util.Optional; + +import static org.lwjgl.opengl.GL11.GL_QUADS; + +/** + * @author Calclavia + */ +public class FWTileRenderer extends TileEntitySpecialRenderer { + + public static final FWTileRenderer instance = new FWTileRenderer(); + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_180535_8_, int p_180535_9_) { + Block block = ((FWTile) te).getBlock(); + Optional opRenderer = block.components.getOp(DynamicRenderer.class); + if (opRenderer.isPresent()) { + BWModel model = new BWModel(); + model.matrix.translate(x + 0.5, y + 0.5, z + 0.5); + opRenderer.get().onRender.accept(model); + bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + RenderUtility.enableBlending(); + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); + model.render(); + Tessellator.getInstance().draw(); + RenderUtility.disableBlending(); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java new file mode 100644 index 000000000..75b6bcdf7 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.util.ITickable; +import nova.core.component.Updater; + +/** + * @author Calclavia + */ +public class FWTileUpdater extends FWTile implements ITickable { + public FWTileUpdater() { + + } + + public FWTileUpdater(String blockID) { + this.blockID = blockID; + } + + /** + * Updates the block. + */ + @Override + public void update() { + if (block != null) { + ((Updater) block).update(0.05); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java new file mode 100644 index 000000000..3d4fca20e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import nova.core.block.Block; +import nova.core.component.transform.BlockTransform; +import nova.core.world.World; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * @author Calclavia + */ +public class MCBlockTransform extends BlockTransform { + + public final Block block; + public final World world; + public final Vector3D position; + + public MCBlockTransform(Block block, World world, Vector3D position) { + this.block = block; + this.world = world; + this.position = position; + } + + @Override + public Vector3D position() { + return position; + } + + @Override + public World world() { + return world; + } + + @Override + public void setWorld(World world) { + this.world.removeBlock(position); + world.setBlock(position, block.getFactory()); + } + + @Override + public void setPosition(Vector3D position) { + world.removeBlock(position); + world.setBlock(position, block.getFactory()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java new file mode 100644 index 000000000..46b2848ca --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java @@ -0,0 +1,34 @@ +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import nova.core.block.component.BlockProperty; +import nova.core.block.component.BlockProperty.Opacity; + +/** + * @author soniex2 + */ +public class ProxyMaterial extends Material { + private final Opacity opacity; + + /** + * Construct a new proxy material. + * @param color The map color. + * @param opacity The Opacity to use. + */ + public ProxyMaterial(MapColor color, Opacity opacity) { + super(color); + this.opacity = opacity; + } + + @Override + public boolean blocksLight() { + return opacity.allowsLightThrough; + } + + @Override + public boolean isOpaque() { + return opacity.allowsLightThrough; + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java new file mode 100644 index 000000000..c3395e43e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.world; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import nova.core.block.Block; +import nova.core.block.BlockFactory; +import nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.item.Item; +import nova.core.sound.Sound; +import nova.core.util.id.Identifier; +import nova.core.util.id.StringIdentifier; +import nova.core.util.shape.Cuboid; +import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.MCBlockTransform; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; + +/** + * The backwards world wrapper. + * @author Calclavia + */ +public class BWWorld extends World { + public final net.minecraft.world.IBlockAccess access; + + public BWWorld(net.minecraft.world.IBlockAccess blockAccess) { + this.access = blockAccess; + } + + public net.minecraft.world.World world() { + // Trying to access world from a IBlockAccess object! + assert access instanceof World; + return (net.minecraft.world.World) access; + } + + @Override + public void markStaticRender(Vector3D position) { + BlockPos pos = new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()); + world().markBlockRangeForRenderUpdate(pos, pos); + } + + @Override + public void markChange(Vector3D position) { + world().notifyNeighborsOfStateChange( + new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()), + access.getBlockState(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())).getBlock(), + true + ); + } + + @Override + public Optional getBlock(Vector3D position) { + net.minecraft.block.Block mcBlock = access.getBlockState(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())).getBlock(); + if (mcBlock == null || mcBlock == Blocks.AIR) { + Block airBlock = Game.blocks().getAirBlock().build(); + airBlock.components.add(new MCBlockTransform(airBlock, this, position)); + return Optional.of(airBlock); + } else if (mcBlock instanceof FWBlock) { + return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position)); + } else { + return Optional.of(new BWBlock(mcBlock, this, position)); + } + } + + @Override + public boolean setBlock(Vector3D position, BlockFactory blockFactory) { + //TODO: Do not call blockFactory.build() + net.minecraft.block.Block mcBlock = Game.natives().toNative(blockFactory.build()); + BlockPos pos = new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()); + net.minecraft.block.Block actualBlock = mcBlock != null ? mcBlock : Blocks.AIR; + IBlockState defaultState = actualBlock.getDefaultState(); + IBlockState extendedState = actualBlock.getExtendedState(defaultState, world(), pos); + return world().setBlockState(pos, extendedState); + } + + @Override + public boolean removeBlock(Vector3D position) { + return world().setBlockToAir(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())); + } + + @Override + public Entity addEntity(EntityFactory factory) { + FWEntity bwEntity = new FWEntity(world(), factory); + bwEntity.forceSpawn = true; + world().spawnEntityInWorld(bwEntity); + return bwEntity.getWrapped(); + } + + @Override + public Entity addClientEntity(EntityFactory factory) { + return NovaMinecraft.proxy.spawnParticle(world(), factory); + } + + @Override + public Entity addClientEntity(Entity entity) { + return NovaMinecraft.proxy.spawnParticle(world(), entity); + } + + @Override + public void removeEntity(Entity entity) { + net.minecraft.entity.Entity wrapper = entity.components.get(MCEntityTransform.class).wrapper; + wrapper.setDead(); + world().removeEntity(wrapper); + } + + @Override + public Set getEntities(Cuboid bound) { + return (Set) world() + .getEntitiesWithinAABB(net.minecraft.entity.Entity.class, new AxisAlignedBB(bound.min.getX(), bound.min.getY(), bound.min.getZ(), bound.max.getX(), bound.max.getY(), bound.max.getZ())) + .stream() + .map(mcEnt -> Game.natives().getNative(Entity.class, net.minecraft.entity.Entity.class).toNova((net.minecraft.entity.Entity) mcEnt)) + .collect(Collectors.toSet()); + } + + @Override + public Entity addEntity(Vector3D position, Item item) { + EntityItem entityItem = new EntityItem(world(), position.getX(), position.getY(), position.getZ(), Game.natives().toNative(item)); + world().spawnEntityInWorld(entityItem); + return Game.natives().toNova(entityItem); + } + + @Override + public Optional getEntity(String uniqueID) { + return Optional.ofNullable(Game.natives().toNova(world().getEntityByID(Integer.parseInt(uniqueID)))); + } + + @Override + public Identifier getID() { + return new StringIdentifier(world().provider.getDimensionType().getName()); + } + + @Override + public void playSoundAtPosition(Vector3D position, Sound sound) { + world().playSound(position.getX(), position.getY(), position.getZ(), SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())), SoundCategory.BLOCKS, sound.volume, sound.pitch, true); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java new file mode 100644 index 000000000..aeee56881 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.world; + +import net.minecraft.world.IBlockAccess; +import nova.core.nativewrapper.NativeConverter; +import nova.core.world.World; +import nova.internal.core.Game; + +import java.util.Optional; + +/** + * @author Calclavia + */ +public class WorldConverter implements NativeConverter { + @Override + public Class getNovaSide() { + return World.class; + } + + @Override + public Class getNativeSide() { + return IBlockAccess.class; + } + + @Override + public World toNova(IBlockAccess nativeObj) { + if (nativeObj instanceof net.minecraft.world.World) { + Optional opWorld = Game.worlds().findWorld(((net.minecraft.world.World) nativeObj).provider.getDimensionType().getName()); + if (opWorld.isPresent()) { + return opWorld.get(); + } + } + + return new BWWorld(nativeObj); + } + + @Override + public IBlockAccess toNative(World novaObj) { + if (novaObj instanceof BWWorld) { + return ((BWWorld) novaObj).world(); + } + + //TODO: Right exception? + throw new RuntimeException("Attempt to convert a world that is not a BWWorld!"); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java new file mode 100644 index 000000000..127e6ffd7 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.cuboid; + +import net.minecraft.util.math.AxisAlignedBB; +import nova.core.nativewrapper.NativeConverter; +import nova.core.util.shape.Cuboid; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * @author Calclavia + */ +public class CuboidConverter implements NativeConverter { + @Override + public Class getNovaSide() { + return Cuboid.class; + } + + @Override + public Class getNativeSide() { + return AxisAlignedBB.class; + } + + @Override + public Cuboid toNova(AxisAlignedBB aabb) { + return new Cuboid(new Vector3D(aabb.minX, aabb.minY, aabb.minZ), new Vector3D(aabb.maxX, aabb.maxY, aabb.maxZ)); + } + + @Override + public AxisAlignedBB toNative(Cuboid cuboid) { + return new AxisAlignedBB(cuboid.min.getX(), cuboid.min.getY(), cuboid.min.getZ(), cuboid.max.getX(), cuboid.max.getY(), cuboid.max.getZ()); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java new file mode 100644 index 000000000..b452e2747 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.data; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagByteArray; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; +import net.minecraft.nbt.NBTTagIntArray; +import net.minecraft.nbt.NBTTagLong; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.nbt.NBTTagString; +import nova.core.nativewrapper.NativeConverter; +import nova.core.retention.Data; +import nova.internal.core.Game; + +import java.util.Set; + +/** + * Utility that manages common NBT queueSave and load methods + * @author Calclavia + */ +public class DataWrapper implements NativeConverter { + + public static DataWrapper instance() { + return (DataWrapper) Game.natives().getNative(Data.class, NBTTagCompound.class); + } + + @Override + public Class getNovaSide() { + return Data.class; + } + + @Override + public Class getNativeSide() { + return NBTTagCompound.class; + } + + @Override + public Data toNova(NBTTagCompound nbt) { + Data data = new Data(); + if (nbt != null) { + data.className = nbt.getString("class"); + Set keys = nbt.getKeySet(); + keys.forEach(k -> data.put(k, load(nbt, k))); + } + return data; + } + + @Override + public NBTTagCompound toNative(Data data) { + if (data == null) { + return null; + } + + return toNative(new NBTTagCompound(), data); + } + + public NBTTagCompound toNative(NBTTagCompound nbt, Data data) { + if (data.className != null) { + nbt.setString("class", data.className); + } + data.forEach((k, v) -> save(nbt, k, v)); + return nbt; + } + + /** + * Saves an unknown object to NBT + * @param tag - NBTTagCompound to queueSave the tag too + * @param key - name to queueSave the object as + * @param value - the actual object + * @return the tag when done saving too i + */ + public NBTTagCompound save(NBTTagCompound tag, String key, Object value) { + if (value instanceof Boolean) { + tag.setBoolean("isBoolean", true); + tag.setBoolean(key, (boolean) value); + } else if (value instanceof Byte) { + tag.setBoolean("isBoolean", false); + tag.setByte(key, (byte) value); + } else if (value instanceof Short) { + tag.setShort(key, (short) value); + } else if (value instanceof Integer) { + tag.setInteger(key, (int) value); + } else if (value instanceof Long) { + tag.setLong(key, (long) value); + } else if (value instanceof Character) { + tag.setInteger(key, (Character) value); + } else if (value instanceof Float) { + tag.setFloat(key, (float) value); + } else if (value instanceof Double) { + tag.setDouble(key, (double) value); + } else if (value instanceof String) { + tag.setString(key, (String) value); + } else if (value instanceof Data) { + NBTTagCompound innerTag = new NBTTagCompound(); + toNative(innerTag, (Data) value); + tag.setTag(key, innerTag); + } + return tag; + } + + /** + * Reads an unknown object withPriority a known name from NBT + * @param tag - tag to read the value from + * @param key - name of the value + * @return object or suggestionValue if nothing is found + */ + public Object load(NBTTagCompound tag, String key) { + if (tag != null && key != null) { + NBTBase saveTag = tag.getTag(key); + + if (saveTag instanceof NBTTagFloat) { + return tag.getFloat(key); + } else if (saveTag instanceof NBTTagDouble) { + return tag.getDouble(key); + } else if (saveTag instanceof NBTTagInt) { + return tag.getInteger(key); + } else if (saveTag instanceof NBTTagString) { + return tag.getString(key); + } else if (saveTag instanceof NBTTagShort) { + return tag.getShort(key); + } else if (saveTag instanceof NBTTagByte) { + if (tag.getBoolean("isBoolean")) { + return tag.getBoolean(key); + } else { + return tag.getByte(key); + } + } else if (saveTag instanceof NBTTagLong) { + return tag.getLong(key); + } else if (saveTag instanceof NBTTagByteArray) { + return tag.getByteArray(key); + } else if (saveTag instanceof NBTTagIntArray) { + return tag.getIntArray(key); + } else if (saveTag instanceof NBTTagCompound) { + NBTTagCompound innerTag = tag.getCompoundTag(key); + return toNova(innerTag); + } + } + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java new file mode 100644 index 000000000..da3e8f418 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity; + +import net.minecraft.util.EnumParticleTypes; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.loader.Loadable; +import nova.core.nativewrapper.NativeConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; +import nova.internal.core.Game; + +import java.util.Optional; + +public class EntityConverter implements NativeConverter, Loadable { + + @Override + public Class getNovaSide() { + return Entity.class; + } + + @Override + public Class getNativeSide() { + return net.minecraft.entity.Entity.class; + } + + @Override + public Entity toNova(net.minecraft.entity.Entity mcEntity) { + //Prevents dual wrapping + if (mcEntity instanceof FWEntity) { + return ((FWEntity) mcEntity).getWrapped(); + } + + //TODO: Make this BWRegistry non-lazy + //Lazy registry + String id = mcEntity.getClass().getName(); + Optional entityFactory = Game.entities().get(id); + + if (entityFactory.isPresent()) { + return entityFactory.get().build(); + } else { + return Game.entities().register(id, () -> new BWEntity(mcEntity)).build(); + } + } + + @Override + public net.minecraft.entity.Entity toNative(Entity novaObj) { + MCEntityTransform transform = novaObj.components.get(MCEntityTransform.class); + + if (transform.wrapper instanceof FWEntity) { + return transform.wrapper; + } + + throw new IllegalArgumentException("Entity wrapper is invalid (where did this object come from?)"); + } + + @Override + @SideOnly(Side.CLIENT) + public void preInit() { + /** + * Backward register all particle effects + */ + //Look up for particle factory and pass it into BWParticle + for (EnumParticleTypes type : EnumParticleTypes.values()) { + Game.entities().register(Game.info().name + ":" + type.getParticleName(), () -> new BWParticle(type.getParticleID())); + } + } +} \ No newline at end of file diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java new file mode 100644 index 000000000..7ec3bffb4 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import nova.core.component.inventory.InventoryPlayer; +import nova.core.component.misc.Damageable; +import nova.core.entity.Entity; +import nova.core.entity.component.Living; +import nova.core.entity.component.Player; +import nova.core.util.id.Identifier; +import nova.core.util.id.UUIDIdentifier; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11.wrapper.inventory.BWInventory; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * A Minecraft to NOVA Entity wrapper + * @author Calclavia + */ +//TODO: Incomplete. Add more components! +public class BWEntity extends Entity { + + public net.minecraft.entity.Entity entity; + + public BWEntity(net.minecraft.entity.Entity entity) { + this.entity = entity; + components.add(new MCEntityTransform(entity)); + + components.add(new Damageable() { + @Override + public void damage(double amount, DamageType type) { + if (type == DamageType.generic) { + entity.attackEntityFrom(DamageSource.generic, (float) amount); + } + // TODO: Apply other damage source wrappers? + } + }); + + if (entity instanceof EntityLivingBase) { + if (entity instanceof EntityPlayer) { + MCPlayer player = components.add(new MCPlayer(this)); + player.faceDisplacement = () -> Vector3D.PLUS_J.scalarMultiply(entity.getEyeHeight()); + } else { + Living living = components.add(new Living()); + living.faceDisplacement = () -> Vector3D.PLUS_J.scalarMultiply(entity.getEyeHeight()); + } + } + } + + public static class MCPlayer extends Player { + public final BWEntity bwEntity; + public final EntityPlayer entity; + public final BWInventoryPlayer inventory; + + public MCPlayer(BWEntity bwEntity) { + this.bwEntity = bwEntity; + this.entity = (EntityPlayer) bwEntity.entity; + this.inventory = new BWInventoryPlayer(entity); + } + + @Override + public Entity entity() { + return bwEntity; + } + + @Override + public String getUsername() { + return entity.getGameProfile().getName(); + } + + @Override + public Identifier getID() { + return new UUIDIdentifier(entity.getGameProfile().getId()); + } + + @Override + public InventoryPlayer getInventory() { + return inventory; + } + + @Override + public String getDisplayName() { + return entity.getDisplayName().getUnformattedText(); + } + } + + public static class BWInventoryPlayer extends BWInventory implements InventoryPlayer { + public final EntityPlayer entity; + + public BWInventoryPlayer(EntityPlayer entity) { + super(entity.inventory); + this.entity = entity; + } + + @Override + public int getHeldSlot() { + return entity.inventory.currentItem; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java new file mode 100644 index 000000000..c268f66cf --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; + +import net.minecraft.entity.MoverType; +import nova.core.entity.Entity; +import nova.core.entity.component.RigidBody; +import nova.core.util.math.RotationUtil; +import nova.core.util.math.Vector3DUtil; +import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * Based on the Euler Integration because Minecraft stores the following values: + * + * Position + * Velocity + * @author Calclavia + */ +public class BWRigidBody extends RigidBody { + private double mass = 1; + + /** + * Translation + */ + private double drag = 0; + + private Vector3D gravity = new Vector3D(0, -9.81, 0); + + /** + * Rotation + */ + private double angularDrag = 0; + private Rotation angularVelocity = Rotation.IDENTITY; + + /** + * Translation + */ + private Vector3D netForce = Vector3D.ZERO; + + /** + * Rotation + */ + private Vector3D netTorque = Vector3D.ZERO; + + private net.minecraft.entity.Entity mcEntity() { + return getProvider().components.get(MCEntityTransform.class).wrapper; + } + + private Entity entity() { + return (Entity) getProvider(); + } + + @Override + public void update(double deltaTime) { + updateTranslation(deltaTime); + updateRotation(deltaTime); + } + + void updateTranslation(double deltaTime) { + //Integrate velocity to displacement + Vector3D displacement = velocity().scalarMultiply(deltaTime); + mcEntity().moveEntity(MoverType.SELF, displacement.getX(), displacement.getY(), displacement.getZ()); + + //Integrate netForce to velocity + setVelocity(velocity().add(netForce.scalarMultiply(1 / mass()).scalarMultiply(deltaTime))); + + //Clear net force + netForce = Vector3D.ZERO; + + //Apply drag + addForce(velocity().negate().scalarMultiply(drag())); + if (!mcEntity().onGround) { + //Apply gravity + addForce(gravity().scalarMultiply(mass())); + } + } + + void updateRotation(double deltaTime) { + + //Integrate angular velocity to angular displacement + Rotation angularVel = angularVelocity(); + Rotation deltaRotation = RotationUtil.slerp(Rotation.IDENTITY, angularVel, deltaTime); + entity().transform().setRotation(entity().rotation().applyTo(deltaRotation)); + + //Integrate torque to angular velocity + Vector3D torque = netTorque.scalarMultiply(deltaTime); + if (!Vector3D.ZERO.equals(torque)) { + setAngularVelocity(angularVelocity().applyTo(new Rotation(Vector3DUtil.FORWARD, torque))); + } + + //Clear net torque + netTorque = Vector3D.ZERO; + + //Apply drag + Vector3D eulerAngularVel = angularVelocity().applyInverseTo(Vector3DUtil.FORWARD); + addTorque(eulerAngularVel.negate().scalarMultiply(angularDrag())); + } + + @Override + public Vector3D getVelocity() { + return new Vector3D(mcEntity().motionX, mcEntity().motionY, mcEntity().motionZ); + } + + @Override + public void setVelocity(Vector3D velocity) { + mcEntity().motionX = velocity.getX(); + mcEntity().motionY = velocity.getY(); + mcEntity().motionZ = velocity.getZ(); + } + + @Override + public void addForce(Vector3D force, Vector3D position) { + //TODO: implement + } + + @Override + public void addTorque(Vector3D torque) { + //TODO: implement + } + + @Override + public void addForce(Vector3D force) { + netForce = netForce.add(force.scalarMultiply(1 / mass())); + } + + /** + * Mass in kilograms. Default is 1 kg. + */ + @Override + public double getMass() { + return mass; + } + + @Override + public void setMass(double mass) { + this.mass = mass; + } + + @Override + public double getDrag() { + return drag; + } + + @Override + public void setDrag(double drag) { + this.drag = drag; + } + + /** + * Gravity is an acceleration. + */ + @Override + public Vector3D getGravity() { + return gravity; + } + + @Override + public void setGravity(Vector3D gravity) { + this.gravity = gravity; + } + + /** + * Rotation Methods + */ + @Override + public double getAngularDrag() { + return angularDrag; + } + + @Override + public void setAngularDrag(double angularDrag) { + this.angularDrag = angularDrag; + } + + @Override + public Rotation getAngularVelocity() { + return angularVelocity; + } + + @Override + public void setAngularVelocity(Rotation angularVelocity) { + this.angularVelocity = angularVelocity; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java new file mode 100644 index 000000000..df22a4fb3 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; + +import io.netty.buffer.ByteBuf; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; +import nova.core.block.Stateful; +import nova.core.component.Updater; +import nova.core.component.misc.Collider; +import nova.core.component.transform.EntityTransform; +import nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.retention.Data; +import nova.core.retention.Storable; +import nova.core.util.shape.Cuboid; +import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; +import nova.internal.core.Game; + +/** + * Entity wrapper + * @author Calclavia + */ +public class FWEntity extends net.minecraft.entity.Entity implements IEntityAdditionalSpawnData { + + protected final EntityTransform transform; + protected Entity wrapped; + boolean firstTick = true; + + public FWEntity(World worldIn) { + super(worldIn); + this.transform = new MCEntityTransform(this); + } + + public FWEntity(World world, EntityFactory factory) { + this(world); + setWrapped(factory.build()); + entityInit(); + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) { + if (wrapped instanceof Storable) { + ((Storable) wrapped).load(Game.natives().toNova(nbt)); + } + if (wrapped == null) { + //This entity was saved to disk. + setWrapped(Game.entities().get(nbt.getString("novaID")).get().build()); + } + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) { + if (wrapped instanceof Storable) { + Data data = new Data(); + ((Storable) wrapped).save(data); + DataWrapper.instance().toNative(nbt, data); + } + nbt.setString("novaID", wrapped.getID().asString()); // TODO? + } + + @Override + public void writeSpawnData(ByteBuf buffer) { + //Write the ID of the entity to client + String id = wrapped.getID().asString(); // TODO? + char[] chars = id.toCharArray(); + buffer.writeInt(chars.length); + + for (char c : chars) + buffer.writeChar(c); + } + + @Override + public void readSpawnData(ByteBuf buffer) { + //Load the client ID + String id = ""; + int length = buffer.readInt(); + for (int i = 0; i < length; i++) + id += buffer.readChar(); + + setWrapped(Game.entities().get(id).get().build()); + } + + public Entity getWrapped() { + return wrapped; + } + + private void setWrapped(Entity wrapped) { + this.wrapped = wrapped; + wrapped.components.add(transform); + } + + public EntityTransform getTransform() { + return transform; + } + + /** + * All methods below here are exactly the same between FWEntity and FWEntityFX. + * ***************************************************************************** + */ + @Override + protected void entityInit() { + //MC calls entityInit() before we finish wrapping, so this variable is required to check if wrapped exists. + if (wrapped != null) { + wrapped.events.publish(new Stateful.LoadEvent()); + updateCollider(); + } + } + + @Override + public void onUpdate() { + if (wrapped != null) { + if (firstTick) { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + setPosition(posX, posY, posZ); + firstTick = false; + } + + //onEntityUpdate(); + + double deltaTime = 0.05; + + if (wrapped instanceof Updater) { + ((Updater) wrapped).update(deltaTime); + } + + updateCollider(); + + /** + * Update all components in the entity. + */ + wrapped.components() + .stream() + .filter(component -> component instanceof Updater) + .forEach(component -> ((Updater) component).update(deltaTime)); + } else { + Game.logger().error("Ticking entity without wrapped entity object."); + } + } + + /** + * Wraps the entity collider values + */ + public void updateCollider() { + //Wrap entity collider + if (wrapped.components.has(Collider.class)) { + Collider collider = wrapped.components.get(Collider.class); + + //Transform cuboid based on entity. + Cuboid size = collider + .boundingBox + .get(); + ///.scalarMultiply(transform.scale()); + + setBounds(size); + } + } + + @Override + protected void setSize(float width, float height) { + if (width != this.width || height != this.height) { + this.width = width; + this.height = height; + setBounds(new Cuboid(-width / 2, -height / 2, -width / 2, width / 2, height / 2, width / 2)); + } + } + + @Override + public void setPosition(double x, double y, double z) { + this.posX = x; + this.posY = y; + this.posZ = z; + //Reset the bounding box + if (getCollisionBoundingBox() != null) { + setBounds(Game.natives().toNova(getCollisionBoundingBox())); + } + } + + /** + * Sets the bounding box of the entity based on NOVA cuboid bounds + * @param bounds NOVA Cuboid bounds + */ + public void setBounds(Cuboid bounds) { + //TODO: Fix moveEntity auto-centering + if (transform != null) { + setEntityBoundingBox(Game.natives().toNative(bounds.add(transform.position()))); + } + } + + @Override + public void setDead() { + wrapped.events.publish(new Stateful.UnloadEvent()); + super.setDead(); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java new file mode 100644 index 000000000..eb02d4f37 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.client.FMLClientHandler; +import nova.core.component.renderer.DynamicRenderer; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWModel; +import org.lwjgl.opengl.GL11; + +import java.util.Optional; + +import static org.lwjgl.opengl.GL11.GL_BLEND; +import static org.lwjgl.opengl.GL11.GL_SMOOTH; +import static org.lwjgl.opengl.GL11.GL_QUADS; +import static org.lwjgl.opengl.GL11.glEnable; +import static org.lwjgl.opengl.GL11.glShadeModel; + +/** + * Renders entities. + * @author Calclavia + */ +public class FWEntityRenderer extends Render { + public static final FWEntityRenderer instance = new FWEntityRenderer(); + + public FWEntityRenderer() { + super(FMLClientHandler.instance().getClient().getRenderManager()); + } + + public static void render(Particle wrapper, nova.core.entity.Entity entity, double x, double y, double z) { + Optional opRenderer = entity.components.getOp(DynamicRenderer.class); + + if (opRenderer.isPresent()) { + BWModel model = new BWModel(); + model.matrix + .translate(x, y, z) + .scale(entity.scale()) + .translate(entity.pivot()) + .rotate(entity.rotation()) + .translate(entity.pivot().negate()); + + opRenderer.get().onRender.accept(model); + + if (model.blendSFactor > 0 && model.blendDFactor > 0) { + glShadeModel(GL_SMOOTH); + glEnable(GL_BLEND); + GL11.glBlendFunc(model.blendSFactor, model.blendDFactor); + } + + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); + model.render(Optional.of(Minecraft.getMinecraft().getRenderManager())); + Tessellator.getInstance().draw(); + + if (model.blendSFactor > 0 && model.blendDFactor > 0) { + RenderUtility.disableBlending(); + } + } + } + + public static void render(Entity wrapper, nova.core.entity.Entity entity, double x, double y, double z) { + Optional opRenderer = entity.components.getOp(DynamicRenderer.class); + + if (opRenderer.isPresent()) { + BWModel model = new BWModel(); + model.matrix + .translate(x, y, z) + .scale(entity.scale()) + .translate(entity.pivot()) + .rotate(entity.rotation()) + .translate(entity.pivot().negate()); + + opRenderer.get().onRender.accept(model); + + if (model.blendSFactor > 0 && model.blendDFactor > 0) { + glShadeModel(GL_SMOOTH); + glEnable(GL_BLEND); + GL11.glBlendFunc(model.blendSFactor, model.blendDFactor); + } + + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); + model.render(Optional.of(Minecraft.getMinecraft().getRenderManager())); + Tessellator.getInstance().draw(); + + if (model.blendSFactor > 0 && model.blendDFactor > 0) { + RenderUtility.disableBlending(); + } + } + } + + @Override + public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { + if (entity instanceof FWEntity) { + render(entity, ((FWEntity) entity).wrapped, x, y, z); + } + } + + @Override + protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + return null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java new file mode 100644 index 000000000..cb0b425df --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraftforge.common.DimensionManager; +import nova.core.component.transform.EntityTransform; +import nova.core.util.math.RotationUtil; +import nova.core.util.math.Vector3DUtil; +import nova.core.world.World; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.Arrays; + +/** + * Wraps Transform3d used in entity + * @author Calclavia + */ +public class MCEntityTransform extends EntityTransform { + public final net.minecraft.entity.Entity wrapper; + + public MCEntityTransform(net.minecraft.entity.Entity wrapper) { + this.wrapper = wrapper; + this.setPivot(Vector3D.ZERO); + this.setScale(Vector3DUtil.ONE); + } + + @Override + public World world() { + return Game.natives().toNova(wrapper.worldObj); + } + + @Override + public void setWorld(World world) { + wrapper.changeDimension(Arrays.stream(DimensionManager.getWorlds()) + .filter(w -> w.getProviderName().equals(world.getID())) + .findAny().get().provider.getDimensionType().getId()); + } + + @Override + public Vector3D position() { + return new Vector3D(wrapper.posX, wrapper.posY, wrapper.posZ); + } + + @Override + public void setPosition(Vector3D position) { + if (wrapper instanceof EntityPlayerMP) { + ((EntityPlayerMP) wrapper).connection.setPlayerLocation(position.getX(), position.getY(), position.getZ(), wrapper.rotationYaw, wrapper.rotationPitch); + } else { + wrapper.setPosition(position.getX(), position.getY(), position.getZ()); + } + } + + @Override + public Rotation rotation() { + return new Rotation(RotationUtil.DEFAULT_ORDER, -Math.toRadians(wrapper.rotationYaw) - Math.PI, -Math.toRadians(wrapper.rotationPitch), 0); + } + + @Override + public void setRotation(Rotation rotation) { + double[] euler = rotation.getAngles(RotationUtil.DEFAULT_ORDER); + wrapper.rotationYaw = (float) Math.toDegrees(euler[0]); + wrapper.rotationPitch = (float) Math.toDegrees(euler[1]); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java new file mode 100644 index 000000000..d2b7303f0 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import nova.core.component.inventory.Inventory; +import nova.core.item.Item; +import nova.internal.core.Game; + +import java.util.Optional; + +public class BWInventory implements Inventory { + public final IInventory wrapped; + + public BWInventory(IInventory mcInventory) { + this.wrapped = mcInventory; + } + + @Override + public Optional get(int i) { + ItemStack stackInSlot = wrapped.getStackInSlot(i); + + if (stackInSlot == null) { + return Optional.empty(); + } + + return Optional.of(Game.natives().toNova(stackInSlot)); + } + + @Override + public boolean set(int i, Item item) { + wrapped.setInventorySlotContents(i, Game.natives().toNative(item)); + return true; + } + + @Override + public Optional remove(int slot) { + Optional item = get(slot); + wrapped.setInventorySlotContents(slot, null); + return item; + } + + @Override + public int size() { + return wrapped.getSizeInventory(); + } + + @Override + public void markChanged() { + wrapped.markDirty(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java new file mode 100644 index 000000000..2a87ed9b0 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import nova.core.component.inventory.Inventory; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; + +public class FWInventory implements IInventory { + + public Inventory wrapped; + + public FWInventory(Inventory inventory) { + this.wrapped = inventory; + } + + @Override + public int getSizeInventory() { + return wrapped.size(); + } + + @Override + public boolean func_191420_l() { + return false; // TODO: What does this do? + } + + @Override + public ItemStack getStackInSlot(int slot) { + return ItemConverter.instance().toNative(wrapped.get(slot).orElse(null)); + } + + @Override + public ItemStack decrStackSize(int slot, int amount) { + ItemStack stack = getStackInSlot(slot); + ItemStack ret = stack.copy(); + ret.func_190920_e(Math.min(ret.func_190916_E(), amount)); + stack.func_190920_e(stack.func_190916_E() - ret.func_190916_E()); + if (stack.func_190916_E() <= 0) { + setInventorySlotContents(slot, null); + return null; + } + markDirty(); + return ret; + } + + public ItemStack getStackInSlotOnClosing(int slot) { + return getStackInSlot(slot); + } + + @Override + public ItemStack removeStackFromSlot(int slot) { + ItemStack stack = getStackInSlot(slot); + decrStackSize(slot, stack.func_190916_E()); + return stack; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + wrapped.set(slot, stack != null ? ItemConverter.instance().getNovaItem(stack) : null); + } + + @Override + public String getName() { + // TODO Shouldn't be empty? + return ""; + } + + @Override + public boolean hasCustomName() { + return false; + } + + @Override + public ITextComponent getDisplayName() { + return null; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public void markDirty() { + wrapped.markChanged(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + // TODO Auto-generated method stub + return true; + } + + @Override + public void openInventory(EntityPlayer playerIn) { + + } + + @Override + public void closeInventory(EntityPlayer playerIn) { + + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) { + // TODO Auto-generated method stub + return true; + } + + @Override + public int getField(int id) { + return 0; + } + + @Override + public void setField(int id, int value) { + + } + + @Override + public int getFieldCount() { + return 0; + } + + @Override + public void clear() { + this.wrapped = null; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java new file mode 100644 index 000000000..b0812ce20 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; + +import net.minecraft.inventory.IInventory; +import nova.core.component.inventory.Inventory; +import nova.core.nativewrapper.NativeConverter; + +/** + * @author Calclavia + */ +public class InventoryConverter implements NativeConverter { + @Override + public Class getNovaSide() { + return Inventory.class; + } + + @Override + public Class getNativeSide() { + return IInventory.class; + } + + @Override + public Inventory toNova(IInventory nativeObj) { + if (nativeObj instanceof FWInventory) { + return ((FWInventory) nativeObj).wrapped; + } + + return new BWInventory(nativeObj); + } + + @Override + public IInventory toNative(Inventory novaObj) { + + if (novaObj instanceof BWInventory) { + return ((BWInventory) novaObj).wrapped; + } + return new FWInventory(novaObj); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java new file mode 100644 index 000000000..16bbb021f --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import nova.core.item.Item; +import nova.core.retention.Storable; + +/** + * @author Stan + * @since 3/02/2015. + */ +public class BWItem extends Item implements Storable { + private final net.minecraft.item.Item item; + private final int meta; + private final NBTTagCompound tag; + + public BWItem(ItemStack itemStack) { + this(itemStack.getItem(), itemStack.getHasSubtypes() ? itemStack.getItemDamage() : 0, itemStack.getTagCompound()); + } + + public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag) { + this.item = item; + this.meta = meta; + this.tag = tag; + } + + public net.minecraft.item.Item getItem() { + return item; + } + + public int getMeta() { + return meta; + } + + public NBTTagCompound getTag() { + return tag; + } + + public ItemStack makeItemStack(int stackSize) { + ItemStack result = new ItemStack(item, stackSize, meta); + if (tag != null) { + result.setTagCompound(tag); + } + return result; + } + + @Override + public String toString() { + return getID().asString(); // TODO? + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java new file mode 100644 index 000000000..b2fa60ed3 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.nbt.NBTTagCompound; +import nova.core.component.misc.FactoryProvider; +import nova.core.item.Item; +import nova.core.item.ItemFactory; +import nova.core.retention.Data; +import nova.internal.core.Game; + +/** + * A Minecraft wrapped item factory. + * @author Stan + * @since 3/02/2015. + */ +public class BWItemFactory extends ItemFactory { + private final net.minecraft.item.Item item; + private final int meta; + + public BWItemFactory(net.minecraft.item.Item item, int meta) { + super(net.minecraft.item.Item.REGISTRY.getNameForObject(item) + (item.getHasSubtypes() ? ":" + meta : ""), () -> new BWItem(item, meta, null)); + + this.item = item; + this.meta = meta; + } + + public net.minecraft.item.Item getItem() { + return item; + } + + public int getMeta() { + return meta; + } + + @Override + public Item build(Data data) { + int meta = (Integer) data.getOrDefault("damage", this.meta); + NBTTagCompound nbtData = Game.natives().toNative(data); + BWItem bwItem = new BWItem(item, meta, nbtData); + bwItem.components.add(new FactoryProvider(this)); + return bwItem; + } + + @Override + public Data save(Item item) { + if (!(item instanceof BWItem)) { + throw new IllegalArgumentException("This factory can only handle MCItems"); + } + + BWItem mcItem = (BWItem) item; + + Data result = mcItem.getTag() != null ? Game.natives().toNova(mcItem.getTag()) : new Data(); + if (result == null) { + result = new Data(); + } + + if (mcItem.getMeta() != meta) { + result.put("damage", mcItem.getMeta()); + } + + return result; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java new file mode 100644 index 000000000..1f7fc126e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import nova.core.item.ItemFactory; + +import java.util.List; + +/** + * @author Calclavia + */ +public class FWItem extends net.minecraft.item.Item implements ItemWrapperMethods { + + public final ItemFactory itemFactory; + + public FWItem(ItemFactory item) { + this.itemFactory = item; + setUnlocalizedName(item.getID().asString()); // TODO? + setMaxStackSize(item.build().getMaxCount()); + } + + @Override + public ItemFactory getItemFactory() { + return itemFactory; + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + return ItemWrapperMethods.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); + } + + @Override + public int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { + return ItemWrapperMethods.super.getColorFromItemStack(itemStack, p_82790_2_); + } + +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java new file mode 100644 index 000000000..3721b3513 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import nova.core.item.ItemFactory; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; + +import java.util.List; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; + +/** + * @author Calclavia + */ +public class FWItemBlock extends net.minecraft.item.ItemBlock implements ItemWrapperMethods { + + public FWItemBlock(net.minecraft.block.Block block) { + super(block); + } + + @Override + public ItemFactory getItemFactory() { + return ((FWBlock) block).dummy.getItemFactory(); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); + } + + @Override + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + return ItemWrapperMethods.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); + } + + @Override + public int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { + return ItemWrapperMethods.super.getColorFromItemStack(itemStack, p_82790_2_); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java new file mode 100644 index 000000000..81d1f25f2 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.nbt.NBTTagCompound; +import nova.core.item.Item; + +/** + * A wrapped NBTTagCompound object that references the item instance + * @author Stan + * @since 3/02/2015. + */ +public class FWNBTTagCompound extends NBTTagCompound { + private final Item item; + + public FWNBTTagCompound(Item item) { + this.item = item; + } + + public Item getItem() { + return item; + } + + @Override + public NBTTagCompound copy() { + FWNBTTagCompound result = new FWNBTTagCompound(item); + getKeySet().forEach(s -> result.setTag((String) s, getTag((String) s).copy())); + return result; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java new file mode 100644 index 000000000..095c8125d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import com.google.common.collect.HashBiMap; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.registry.GameRegistry; +import nova.core.block.BlockFactory; +import nova.core.component.Category; +import nova.core.item.Item; +import nova.core.item.ItemBlock; +import nova.core.item.ItemFactory; +import nova.core.item.ItemManager; +import nova.core.item.event.ItemIDNotFoundEvent; +import nova.core.loader.Loadable; +import nova.core.nativewrapper.NativeConverter; +import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; +import nova.internal.core.Game; +import nova.internal.core.launch.InitializationException; + +import java.util.Arrays; +import java.util.Optional; +import java.util.Set; + +/** + * The main class responsible for wrapping items. + * @author Calclavia, Stan Hebben + */ +public class ItemConverter implements NativeConverter, Loadable { + + /** + * A map of all items registered + */ + private final HashBiMap map = HashBiMap.create(); + + public static ItemConverter instance() { + return (ItemConverter) Game.natives().getNative(Item.class, ItemStack.class); + } + + @Override + public Class getNovaSide() { + return Item.class; + } + + @Override + public Class getNativeSide() { + return ItemStack.class; + } + + @Override + public Item toNova(ItemStack itemStack) { + return getNovaItem(itemStack).setCount(itemStack.func_190916_E()); + } + + //TODO: Why is this method separate? + // Maybe because toNova calls setCount on the result of this method? + public Item getNovaItem(ItemStack itemStack) { + if (itemStack.getItemDamage() == net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE) { + // TODO: Deal withPriority wildcard meta values - important for the ore dictionary + return getNovaItem(new ItemStack(itemStack.getItem(), 1, 0)); + } + + if (itemStack.getTagCompound() != null && itemStack.getTagCompound() instanceof FWNBTTagCompound) { + return ((FWNBTTagCompound) itemStack.getTagCompound()).getItem(); + } else { + ItemFactory itemFactory = registerMinecraftMapping(itemStack.getItem(), itemStack.getItemDamage()); + + Data data = itemStack.getTagCompound() != null ? Game.natives().toNova(itemStack.getTagCompound()) : new Data(); + if (!itemStack.getHasSubtypes() && itemStack.getItemDamage() > 0) { + data.put("damage", itemStack.getItemDamage()); + } + + return itemFactory.build(data); + } + } + + @Override + public ItemStack toNative(Item item) { + if (item == null) { + return null; + } + + //Prevent recusive wrapping + if (item instanceof BWItem) { + return ((BWItem) item).makeItemStack(item.count()); + } else { + ItemFactory itemFactory = Game.items().get(item.getID().asString()).get();// TODO? + FWNBTTagCompound tag = new FWNBTTagCompound(item); + + MinecraftItemMapping mapping = get(itemFactory); + if (mapping == null) { + throw new InitializationException("Missing mapping for " + itemFactory.getID()); + } + + ItemStack result = new ItemStack(mapping.item, item.count(), mapping.meta); + result.setTagCompound(tag); + return result; + } + } + + public ItemStack toNative(ItemFactory itemFactory) { + FWNBTTagCompound tag = new FWNBTTagCompound(itemFactory.build()); + + MinecraftItemMapping mapping = get(itemFactory); + if (mapping == null) { + throw new InitializationException("Missing mapping for " + itemFactory.getID()); + } + + ItemStack result = new ItemStack(mapping.item, 1, mapping.meta); + result.setTagCompound(tag); + return result; + } + + public ItemStack toNative(String id) { + return toNative(Game.items().get(id).get().build().setCount(1)); + } + + public MinecraftItemMapping get(ItemFactory item) { + return map.get(item); + } + + public ItemFactory get(MinecraftItemMapping minecraftItem) { + return map.inverse().get(minecraftItem); + } + + /** + * Saves NOVA item into a Minecraft ItemStack. + */ + public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { + itemStack.func_190920_e(item.count()); + if (itemStack.func_190916_E() <= 0) { + return null; + } + + itemStack.setTagCompound(Game.natives().toNative(item.getFactory().save(item))); + return itemStack; + } + + /** + * Register all Nova blocks + */ + @Override + public void preInit() { + registerNOVAItemsToMinecraft(); + registerMinecraftItemsToNOVA(); + registerSubtypeResolution(); + } + + private void registerNOVAItemsToMinecraft() { + //There should be no items registered during Native Converter preInit() + // item.registry.forEach(this::registerNOVAItem); + Game.events().on(ItemManager.ItemRegistrationEvent.class).bind(this::onItemRegistered); + } + + private void onItemRegistered(ItemManager.ItemRegistrationEvent event) { + registerNOVAItem(event.itemFactory); + } + + private void registerNOVAItem(ItemFactory itemFactory) { + if (map.containsKey(itemFactory)) { + // just a safeguard - don't map stuff twice + return; + } + + net.minecraft.item.Item itemWrapper; + + Item dummy = itemFactory.build(); + if (dummy instanceof ItemBlock) { + BlockFactory blockFactory = ((ItemBlock) dummy).blockFactory; + net.minecraft.block.Block mcBlock = BlockConverter.instance().toNative(blockFactory); + itemWrapper = net.minecraft.item.Item.getItemFromBlock(mcBlock); + if (itemWrapper == null) { + throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); + } + } else { + itemWrapper = new FWItem(itemFactory); + } + + MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); + map.put(itemFactory, minecraftItemMapping); + + // Don't register ItemBlocks twice + if (!(dummy instanceof ItemBlock)) { + NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); + GameRegistry.register(itemWrapper, new ResourceLocation(itemFactory.getID().asString())); + + if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { + //Add into creative tab + Category category = dummy.components.get(Category.class); + Optional first = Arrays.stream(CreativeTabs.CREATIVE_TAB_ARRAY) + .filter(tab -> tab.getTabLabel().equals(category.name)) + .findFirst(); + if (first.isPresent()) { + itemWrapper.setCreativeTab(first.get()); + } else { + Optional item = category.item; + ModCreativeTab tab = new ModCreativeTab(category.name, item.isPresent() ? Game.natives().toNative(item.get()) : itemWrapper); + itemWrapper.setCreativeTab(tab); + } + } + + System.out.println("[NOVA]: Registered '" + itemFactory.getID() + "' item."); + } + } + + private void registerMinecraftItemsToNOVA() { + Set itemIDs = (Set) net.minecraft.item.Item.REGISTRY.getKeys(); + itemIDs.forEach(itemID -> { + net.minecraft.item.Item item = (net.minecraft.item.Item) net.minecraft.item.Item.REGISTRY.getObject(itemID); + registerMinecraftMapping(item, 0); + }); + } + + private void registerSubtypeResolution() { + Game.events().on(ItemIDNotFoundEvent.class).bind(this::onIDNotFound); + } + + private void onIDNotFound(ItemIDNotFoundEvent event) { + // if item minecraft:planks:2 is detected, this code will register minecraft:planks:2 dynamically + // we cannot do this up front since there is **NO** reliable way to get the sub-items of an item + + int lastColon = event.id.lastIndexOf(':'); + if (lastColon < 0) { + return; + } + + try { + int meta = Integer.parseInt(event.id.substring(lastColon + 1)); + String itemID = event.id.substring(0, lastColon); + + net.minecraft.item.Item item = (net.minecraft.item.Item) net.minecraft.item.Item.REGISTRY.getObject(new ResourceLocation(itemID)); + if (item == null || !item.getHasSubtypes()) { + return; + } + + event.setRemappedFactory(registerMinecraftMapping(item, meta)); + } catch (NumberFormatException ex) { + } + } + + private ItemFactory registerMinecraftMapping(net.minecraft.item.Item item, int meta) { + MinecraftItemMapping mapping = new MinecraftItemMapping(item, meta); + if (map.inverse().containsKey(mapping)) { + // don't register twice, return the factory instead + return map.inverse().get(mapping); + } + + BWItemFactory itemFactory = new BWItemFactory(item, meta); + map.put(itemFactory, mapping); + + Game.items().register(itemFactory); + + return itemFactory; + } + + /** + * Used to map MC items and their meta to nova item factories. + */ + public final class MinecraftItemMapping { + public final net.minecraft.item.Item item; + public final int meta; + + public MinecraftItemMapping(net.minecraft.item.Item item, int meta) { + this.item = item; + this.meta = item.getHasSubtypes() ? meta : 0; + } + + public MinecraftItemMapping(ItemStack itemStack) { + this.item = itemStack.getItem(); + this.meta = itemStack.getHasSubtypes() ? itemStack.getItemDamage() : 0; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + MinecraftItemMapping that = (MinecraftItemMapping) o; + + if (meta != that.meta) { + return false; + } + if (!item.equals(that.item)) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = item.hashCode(); + result = 31 * result + meta; + return result; + } + + @Override + public String toString() { + if (item.getHasSubtypes()) { + return net.minecraft.item.Item.REGISTRY.getNameForObject(item) + ":" + meta; + } else { + return net.minecraft.item.Item.REGISTRY.getNameForObject(item).toString(); + } + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java new file mode 100644 index 000000000..e03e0dba8 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.world.World; +import nova.core.item.Item; +import nova.core.item.ItemFactory; +import nova.core.util.Direction; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.List; +import java.util.Optional; + +/** + * An interface implemented by ItemBlockWrapper and ItemWrapper classes to override Minecraft's item events. + * @author Calclavia + */ +public interface ItemWrapperMethods { + + ItemFactory getItemFactory(); + + default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + Item item = Game.natives().toNova(itemStack); + item.setCount(itemStack.func_190916_E()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list)); + getItemFactory().save(item); + } + + default EnumActionResult onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { + Item item = Game.natives().toNova(itemStack); + Item.UseEvent event = new Item.UseEvent(new BWEntity(player), new Vector3D(x, y, z), Direction.fromOrdinal(side), new Vector3D(hitX, hitY, hitZ)); + item.events.publish(event); + ItemConverter.instance().updateMCItemStack(itemStack, item); + return event.action ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + } + + default ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + Item item = Game.natives().toNova(itemStack); + item.events.publish(new Item.RightClickEvent(new BWEntity(player))); + return ItemConverter.instance().updateMCItemStack(itemStack, item); + } + + default int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { + return ((Item) Game.natives().toNova(itemStack)).colorMultiplier().argb(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java new file mode 100644 index 000000000..888beccdc --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.item; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import nova.core.item.Item; +import nova.core.item.ItemDictionary; +import nova.core.util.Dictionary; +import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.internal.core.Game; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Stan on 8/02/2015. + */ +public class OreDictionaryIntegration { + public static final OreDictionaryIntegration instance = new OreDictionaryIntegration(); + private static final List> OREDICT_CONTENTS = ReflectionUtil.getOreIdStacks(); + + private OreDictionaryIntegration() { + } + + public void registerOreDictionary() { + ItemDictionary novaItemDictionary = Game.itemDictionary(); + + for (String oredictEntry : novaItemDictionary.keys()) { + for (Item oreValue : novaItemDictionary.get(oredictEntry)) { + OreDictionary.registerOre(oredictEntry, ItemConverter.instance().toNative(oreValue)); + } + } + + for (String oredictEntry : OreDictionary.getOreNames()) { + for (ItemStack oreValue : OreDictionary.getOres(oredictEntry)) { + Item novaItem = ItemConverter.instance().getNovaItem(oreValue); + if (!novaItemDictionary.get(oredictEntry).contains(novaItem)) { + novaItemDictionary.add(oredictEntry, novaItem); + } + } + } + + novaItemDictionary.whenEntryAdded(this::onEntryAdded); + novaItemDictionary.whenEntryRemoved(this::onEntryRemoved); + } + + private void onEntryAdded(Dictionary.AddEvent event) { + if (!OreDictionary.getOres(event.key).contains(event.value)) { + OreDictionary.registerOre(event.key, ItemConverter.instance().toNative(event.value)); + } + } + + private void onEntryRemoved(Dictionary.RemoveEvent event) { + int id = OreDictionary.getOreID(event.key); + ItemStack itemStack = ItemConverter.instance().toNative(event.value); + ItemStack toRemove = null; + for (ItemStack oreDictItemStack : OreDictionary.getOres(event.key)) { + if (oreDictItemStack.getItem() == itemStack.getItem() && toRemove.getItemDamage() == oreDictItemStack.getItemDamage()) { + toRemove = oreDictItemStack; + } + } + + if (toRemove != null) { + OREDICT_CONTENTS.get(id).remove(toRemove); + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java new file mode 100644 index 000000000..55e651a6c --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward; + +import com.google.common.collect.HashBiMap; +import net.minecraft.client.particle.Barrier; +import net.minecraft.client.particle.IParticleFactory; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleBlockDust; +import net.minecraft.client.particle.ParticleBreaking; +import net.minecraft.client.particle.ParticleBubble; +import net.minecraft.client.particle.ParticleCloud; +import net.minecraft.client.particle.ParticleCrit; +import net.minecraft.client.particle.ParticleDigging; +import net.minecraft.client.particle.ParticleDragonBreath; +import net.minecraft.client.particle.ParticleDrip; +import net.minecraft.client.particle.ParticleEmitter; +import net.minecraft.client.particle.ParticleEnchantmentTable; +import net.minecraft.client.particle.ParticleEndRod; +import net.minecraft.client.particle.ParticleExplosion; +import net.minecraft.client.particle.ParticleExplosionHuge; +import net.minecraft.client.particle.ParticleExplosionLarge; +import net.minecraft.client.particle.ParticleFallingDust; +import net.minecraft.client.particle.ParticleFirework; +import net.minecraft.client.particle.ParticleFlame; +import net.minecraft.client.particle.ParticleFootStep; +import net.minecraft.client.particle.ParticleHeart; +import net.minecraft.client.particle.ParticleItemPickup; +import net.minecraft.client.particle.ParticleLava; +import net.minecraft.client.particle.ParticleMobAppearance; +import net.minecraft.client.particle.ParticleNote; +import net.minecraft.client.particle.ParticlePortal; +import net.minecraft.client.particle.ParticleRain; +import net.minecraft.client.particle.ParticleRedstone; +import net.minecraft.client.particle.ParticleSmokeLarge; +import net.minecraft.client.particle.ParticleSmokeNormal; +import net.minecraft.client.particle.ParticleSnowShovel; +import net.minecraft.client.particle.ParticleSpell; +import net.minecraft.client.particle.ParticleSpit; +import net.minecraft.client.particle.ParticleSplash; +import net.minecraft.client.particle.ParticleSuspend; +import net.minecraft.client.particle.ParticleSuspendedTown; +import net.minecraft.client.particle.ParticleSweepAttack; +import net.minecraft.client.particle.ParticleTotem; +import net.minecraft.client.particle.ParticleWaterWake; +import net.minecraft.util.EnumParticleTypes; +import net.minecraftforge.fml.client.FMLClientHandler; + +import java.util.HashMap; +import java.util.Map; + +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; + +/** + * A backward entity particle that acts as a black box, which wraps a Minecraft particle fxs. + * + * TODO: Minecraft particles are no longer entities. + * + * @author Calclavia + */ +public class BWParticle extends BWEntity { + + public static final HashBiMap> FX_CLASS_MAP = HashBiMap.create(); + public static final Map FX_FACTORY_MAP = new HashMap<>(); + + static { + //TODO: Handle duplicate fxs using a function instead of a map + FX_CLASS_MAP.put(EnumParticleTypes.EXPLOSION_NORMAL.getParticleID(), ParticleExplosion.class); + FX_CLASS_MAP.put(EnumParticleTypes.WATER_BUBBLE.getParticleID(), ParticleBubble.class); + FX_CLASS_MAP.put(EnumParticleTypes.WATER_SPLASH.getParticleID(), ParticleSplash.class); + FX_CLASS_MAP.put(EnumParticleTypes.WATER_WAKE.getParticleID(), ParticleWaterWake.class); + FX_CLASS_MAP.put(EnumParticleTypes.WATER_DROP.getParticleID(), ParticleRain.class); + FX_CLASS_MAP.put(EnumParticleTypes.SUSPENDED.getParticleID(), ParticleSuspend.class); + //FX_CLASS_MAP.put(EnumParticleTypes.SUSPENDED_DEPTH.getParticleID(), ParticleSuspendedTown.class); + FX_CLASS_MAP.put(EnumParticleTypes.CRIT.getParticleID(), ParticleCrit.class); + //FX_CLASS_MAP.put(EnumParticleTypes.CRIT_MAGIC.getParticleID(), ParticleCrit.class); + FX_CLASS_MAP.put(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), ParticleSmokeNormal.class); + FX_CLASS_MAP.put(EnumParticleTypes.SMOKE_LARGE.getParticleID(), ParticleSmokeLarge.class); + FX_CLASS_MAP.put(EnumParticleTypes.SPELL.getParticleID(), ParticleSpell.class); + /*FX_CLASS_MAP.put(EnumParticleTypes.SPELL_INSTANT.getParticleID(), ParticleSpell.class); + FX_CLASS_MAP.put(EnumParticleTypes.SPELL_MOB.getParticleID(), ParticleSpell.class); + FX_CLASS_MAP.put(EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID(), ParticleSpell.class); + FX_CLASS_MAP.put(EnumParticleTypes.SPELL_WITCH.getParticleID(), ParticleSpell.class);*/ + FX_CLASS_MAP.put(EnumParticleTypes.DRIP_WATER.getParticleID(), ParticleDrip.class); + //FX_CLASS_MAP.put(EnumParticleTypes.DRIP_LAVA.getParticleID(), ParticleDrip.class); + //FX_CLASS_MAP.put(EnumParticleTypes.VILLAGER_ANGRY.getParticleID(), ParticleHeart.class); + //FX_CLASS_MAP.put(EnumParticleTypes.VILLAGER_HAPPY.getParticleID(), ParticleSuspendedTown.class); + FX_CLASS_MAP.put(EnumParticleTypes.TOWN_AURA.getParticleID(), ParticleSuspendedTown.class); + FX_CLASS_MAP.put(EnumParticleTypes.NOTE.getParticleID(), ParticleNote.class); + FX_CLASS_MAP.put(EnumParticleTypes.PORTAL.getParticleID(), ParticlePortal.class); + FX_CLASS_MAP.put(EnumParticleTypes.ENCHANTMENT_TABLE.getParticleID(), ParticleEnchantmentTable.class); + FX_CLASS_MAP.put(EnumParticleTypes.FLAME.getParticleID(), ParticleFlame.class); + FX_CLASS_MAP.put(EnumParticleTypes.LAVA.getParticleID(), ParticleLava.class); + FX_CLASS_MAP.put(EnumParticleTypes.FOOTSTEP.getParticleID(), ParticleFootStep.class); + FX_CLASS_MAP.put(EnumParticleTypes.CLOUD.getParticleID(), ParticleCloud.class); + FX_CLASS_MAP.put(EnumParticleTypes.REDSTONE.getParticleID(), ParticleRedstone.class); + FX_CLASS_MAP.put(EnumParticleTypes.SNOWBALL.getParticleID(), ParticleBreaking.class); + FX_CLASS_MAP.put(EnumParticleTypes.SNOW_SHOVEL.getParticleID(), ParticleSnowShovel.class); + //FX_CLASS_MAP.put(EnumParticleTypes.SLIME.getParticleID(), ParticleBreaking.class); + FX_CLASS_MAP.put(EnumParticleTypes.HEART.getParticleID(), ParticleHeart.class); + FX_CLASS_MAP.put(EnumParticleTypes.BARRIER.getParticleID(), Barrier.class); + //FX_CLASS_MAP.put(EnumParticleTypes.ITEM_CRACK.getParticleID(), ParticleBreaking.class); + FX_CLASS_MAP.put(EnumParticleTypes.BLOCK_CRACK.getParticleID(), ParticleDigging.class); + FX_CLASS_MAP.put(EnumParticleTypes.BLOCK_DUST.getParticleID(), ParticleBlockDust.class); + FX_CLASS_MAP.put(EnumParticleTypes.EXPLOSION_HUGE.getParticleID(), ParticleExplosionHuge.class); + FX_CLASS_MAP.put(EnumParticleTypes.EXPLOSION_LARGE.getParticleID(), ParticleExplosionLarge.class); + FX_CLASS_MAP.put(EnumParticleTypes.FIREWORKS_SPARK.getParticleID(), ParticleFirework.Spark.class); + FX_CLASS_MAP.put(EnumParticleTypes.MOB_APPEARANCE.getParticleID(), ParticleMobAppearance.class); + FX_CLASS_MAP.put(EnumParticleTypes.SPIT.getParticleID(), ParticleSpit.class); + FX_CLASS_MAP.put(EnumParticleTypes.FALLING_DUST.getParticleID(), ParticleFallingDust.class); + FX_CLASS_MAP.put(EnumParticleTypes.DRAGON_BREATH.getParticleID(), ParticleDragonBreath.class); + FX_CLASS_MAP.put(EnumParticleTypes.END_ROD.getParticleID(), ParticleEndRod.class); + /*FX_CLASS_MAP.put(EnumParticleTypes.DAMAGE_INDICATOR.getParticleID(), ParticleCrit.class);*/ + FX_CLASS_MAP.put(EnumParticleTypes.SWEEP_ATTACK.getParticleID(), ParticleSweepAttack.class); + FX_CLASS_MAP.put(EnumParticleTypes.TOTEM.getParticleID(), ParticleTotem.class); + + FX_FACTORY_MAP.put(EnumParticleTypes.EXPLOSION_NORMAL.getParticleID(), new ParticleExplosion.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.WATER_BUBBLE.getParticleID(), new ParticleBubble.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.WATER_SPLASH.getParticleID(), new ParticleSplash.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.WATER_WAKE.getParticleID(), new ParticleWaterWake.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.WATER_DROP.getParticleID(), new ParticleRain.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SUSPENDED.getParticleID(), new ParticleSuspend.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SUSPENDED_DEPTH.getParticleID(), new ParticleSuspendedTown.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.CRIT.getParticleID(), new ParticleCrit.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.CRIT_MAGIC.getParticleID(), new ParticleCrit.MagicFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), new ParticleSmokeNormal.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SMOKE_LARGE.getParticleID(), new ParticleSmokeLarge.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPELL.getParticleID(), new ParticleSpell.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPELL_INSTANT.getParticleID(), new ParticleSpell.InstantFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPELL_MOB.getParticleID(), new ParticleSpell.MobFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID(), new ParticleSpell.AmbientMobFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPELL_WITCH.getParticleID(), new ParticleSpell.WitchFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.DRIP_WATER.getParticleID(), new ParticleDrip.WaterFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.DRIP_LAVA.getParticleID(), new ParticleDrip.LavaFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.VILLAGER_ANGRY.getParticleID(), new ParticleHeart.AngryVillagerFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.VILLAGER_HAPPY.getParticleID(), new ParticleSuspendedTown.HappyVillagerFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.TOWN_AURA.getParticleID(), new ParticleSuspendedTown.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.NOTE.getParticleID(), new ParticleNote.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.PORTAL.getParticleID(), new ParticlePortal.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.ENCHANTMENT_TABLE.getParticleID(), new ParticleEnchantmentTable.EnchantmentTable()); + FX_FACTORY_MAP.put(EnumParticleTypes.FLAME.getParticleID(), new ParticleFlame.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.LAVA.getParticleID(), new ParticleLava.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.FOOTSTEP.getParticleID(), new ParticleFootStep.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.CLOUD.getParticleID(), new ParticleCloud.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.REDSTONE.getParticleID(), new ParticleRedstone.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SNOWBALL.getParticleID(), new ParticleBreaking.SnowballFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SNOW_SHOVEL.getParticleID(), new ParticleSnowShovel.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SLIME.getParticleID(), new ParticleBreaking.SlimeFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.HEART.getParticleID(), new ParticleHeart.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.BARRIER.getParticleID(), new Barrier.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.ITEM_CRACK.getParticleID(), new ParticleBreaking.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.BLOCK_CRACK.getParticleID(), new ParticleDigging.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.BLOCK_DUST.getParticleID(), new ParticleBlockDust.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.EXPLOSION_HUGE.getParticleID(), new ParticleExplosionHuge.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.EXPLOSION_LARGE.getParticleID(), new ParticleExplosionLarge.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.FIREWORKS_SPARK.getParticleID(), new ParticleFirework.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.MOB_APPEARANCE.getParticleID(), new ParticleMobAppearance.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SPIT.getParticleID(), new ParticleSpit.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.FALLING_DUST.getParticleID(), new ParticleFallingDust.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.DRAGON_BREATH.getParticleID(), new ParticleDragonBreath.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.END_ROD.getParticleID(), new ParticleEndRod.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.DAMAGE_INDICATOR.getParticleID(), new ParticleCrit.DamageIndicatorFactory()); + FX_FACTORY_MAP.put(EnumParticleTypes.SWEEP_ATTACK.getParticleID(), new ParticleSweepAttack.Factory()); + FX_FACTORY_MAP.put(EnumParticleTypes.TOTEM.getParticleID(), new ParticleTotem.Factory()); + } + + private final int particleID; + + public BWParticle(int particleID) { + //TODO: NPE + super(null); + this.particleID = particleID; + } + + public Particle createParticle(net.minecraft.world.World world) { + //Look up for particle factory and pass it into BWParticle + IParticleFactory particleFactory = (IParticleFactory) FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID); + return particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java new file mode 100644 index 000000000..702f1e77a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward; + +import net.minecraft.client.particle.Particle; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.world.World; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.block.Stateful; +import nova.core.component.Updater; +import nova.core.component.misc.Collider; +import nova.core.component.transform.EntityTransform; +import nova.core.entity.Entity; +import nova.core.entity.EntityFactory; +import nova.core.util.shape.Cuboid; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntityRenderer; + +import static org.lwjgl.opengl.GL11.GL_QUADS; + +/** + * A copy of BWEntity that extends EntityFX + * @author Calclavia + */ +@SideOnly(Side.CLIENT) +public class FWParticle extends Particle { + + public final Entity wrapped; + public final EntityTransform transform; + + boolean firstTick = true; + + public FWParticle(World world, EntityFactory factory) { + super(world, 0, 0, 0); + this.wrapped = factory.build(); + this.transform = new MCParticleTransform(this); + wrapped.components.add(transform); + entityInit(); + } + + public FWParticle(World world, Entity entity) { + super(world, 0, 0, 0); + this.wrapped = entity; + this.transform = new MCParticleTransform(this); + wrapped.components.add(transform); + entityInit(); + } + + @Override + public void renderParticle(VertexBuffer worldRendererIn, net.minecraft.entity.Entity p_180434_2_, float p_70539_2_, float x, float y, float z, float p_70539_6_, float p_70539_7_) { + if (firstTick) { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + setPosition(posX, posY, posZ); + firstTick = false; + } + float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX); + float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY); + float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ); + + Tessellator.getInstance().draw(); + FWEntityRenderer.render(this, wrapped, f11, f12, f13); + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderUtility.particleResource); + } + + /** + * All methods below here are exactly the same between FWEntity and FWParticle. + * ***************************************************************************** + */ + protected void entityInit() { + //MC calls entityInit() before we finish wrapping, so this variable is required to check if wrapped exists. + if (wrapped != null) { + wrapped.events.publish(new Stateful.LoadEvent()); + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + setPosition(posX, posY, posZ); + } + } + + @Override + public void onUpdate() { + //TODO: Minecraft's collision is messed up (gets concurrent problems) + this.canCollide = false; + this.particleAge = 0; + super.onUpdate(); + double deltaTime = 0.05; + + if (wrapped instanceof Updater) { + ((Updater) wrapped).update(deltaTime); + } + + //Wrap entity collider + if (wrapped.components.has(Collider.class)) { + Collider collider = wrapped.components.get(Collider.class); + + //Transform cuboid based on entity. + Cuboid size = collider + .boundingBox + .get(); + // .scalarMultiply(transform.scale()); + + //Sadly Minecraft doesn't support rotated cuboids. And fixed x-z sizes. We take average.. + float width = (float) ((size.max.getX() - size.min.getX()) + (size.max.getZ() - size.min.getZ())) / 2; + float height = (float) (size.max.getY() - size.min.getY()); + setSize(width, height); + } + + /** + * Update all components in the entity. + */ + wrapped.components() + .stream() + .filter(component -> component instanceof Updater) + .forEach(component -> ((Updater) component).update(deltaTime)); + } + + @Override + public void setExpired() { + wrapped.events.publish(new Stateful.UnloadEvent()); + super.setExpired(); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java new file mode 100644 index 000000000..f52e7e32b --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward; + +import net.minecraft.client.particle.Particle; +import nova.core.component.transform.EntityTransform; +import nova.core.util.math.RotationUtil; +import nova.core.util.math.Vector3DUtil; +import nova.core.world.World; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * Wraps Transform3d used in particle + * @author ExE Boss + */ +public class MCParticleTransform extends EntityTransform { + public final net.minecraft.client.particle.Particle wrapper; + + public MCParticleTransform(Particle wrapper) { + this.wrapper = wrapper; + this.setPivot(Vector3D.ZERO); + this.setScale(Vector3DUtil.ONE); + } + + @Override + public World world() { + return Game.natives().toNova(wrapper.worldObj); + } + + @Override + public void setWorld(World world) { + + } + + @Override + public Vector3D position() { + return new Vector3D(wrapper.posX, wrapper.posY, wrapper.posZ); + } + + @Override + public void setPosition(Vector3D position) { + wrapper.setPosition(position.getX(), position.getY(), position.getZ()); + } + + @Override + public Rotation rotation() { + // TODO: Calculate rotation so that it is always facing the camera. + return new Rotation(RotationUtil.DEFAULT_ORDER, 0, 0, 0); + } + + @Override + public void setRotation(Rotation rotation) { + // Particles can’t be rotated. + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java new file mode 100644 index 000000000..ba2409e15 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.render.RenderException; +import nova.core.render.texture.Texture; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; + +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; +import java.util.Iterator; + +/** + * @author Calclavia + */ +public class BWClientRenderManager extends BWRenderManager { + @SideOnly(Side.CLIENT) + @Override + public Vector2D getDimension(Texture texture) { + ResourceLocation loc = toResourceLocation(texture); + + try { + ImageInputStream in = ImageIO.createImageInputStream(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream()); + Iterator readers = ImageIO.getImageReaders(in); + if (readers.hasNext()) { + ImageReader reader = readers.next(); + try { + reader.setInput(in); + return new Vector2D(reader.getWidth(0), reader.getHeight(0)); + } finally { + reader.dispose(); + } + } + } catch (Exception e) { + throw new RenderException("Couldn't load texture " + texture.getPath(), e); + } + return new Vector2D(16, 16); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java new file mode 100644 index 000000000..8d6f4ef92 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import nova.core.render.model.MeshModel; +import nova.core.render.texture.EntityTexture; +import nova.core.render.texture.Texture; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; + +import java.lang.reflect.Constructor; +import java.util.BitSet; +import java.util.Optional; + + +/** + * BWModel for dynamic rendering + * @author Calclavia + */ +public class BWModel extends MeshModel { + + public void render() { + render(Optional.empty()); + } + + public void render(Optional entityRenderManager) { + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer worldRenderer = tessellator.getBuffer(); + worldRenderer.color(1F, 1F, 1F, 1F); + + /** + * Convert textures and UV into Minecraft equivalent. + */ + flatten().forEach( + model -> { + if (model instanceof MeshModel) { + MeshModel meshModel = (MeshModel) model; + meshModel.faces.forEach(face -> + { + // TODO: Figure out if ? + // Brightness is defined as: skyLight << 20 | blockLight << 4 + if (face.getBrightness() >= 0) { + worldRenderer.lightmap((int)(face.getBrightness() * (15 << 20)), (int)(face.getBrightness() * (11 << 4))); + //worldRenderer.setBrightness((int) (face.getBrightness() * (15 << 20 | 11 << 4))); + } else { + // Determine nearest adjacent block. + worldRenderer.lightmap(15 << 20, 11 << 4); + //worldRenderer.setBrightness(15 << 20 | 11 << 4); + } + + worldRenderer.normal((int) face.normal.getX(), (int) face.normal.getY(), (int) face.normal.getZ()); + + if (face.texture.isPresent()) { + if (entityRenderManager.isPresent() && face.texture.get() instanceof EntityTexture) { + //We're not working on an atlas, so just do... this. + Texture t = face.texture.get(); + entityRenderManager.get().renderEngine.bindTexture(new ResourceLocation(t.domain, "textures/entities/" + t.resource + ".png")); + face.vertices.forEach( + v -> { + worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); + worldRenderer.tex(v.uv.getX(), v.uv.getY()); + worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); + } + ); + } else { + Texture texture = face.texture.get(); + TextureAtlasSprite icon = RenderUtility.instance.getTexture(texture); + face.vertices.forEach( + v -> { + worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); + if (icon != null) { + worldRenderer.tex(icon.getInterpolatedU(16 * v.uv.getX()), icon.getInterpolatedV(16 * v.uv.getY())); + worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); + } else { + worldRenderer.tex(v.uv.getX(), v.uv.getY()); + worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); + } + } + ); + } + } else { + face.vertices.forEach( + v -> { + worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); + worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); + } + ); + } + }); + } + //TODO: Handle BW Rendering + } + ); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java new file mode 100644 index 000000000..5196d6a8d --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.util.ResourceLocation; +import nova.core.render.RenderManager; +import nova.core.render.texture.Texture; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; + +public class BWRenderManager extends RenderManager { + + public static ResourceLocation toResourceLocation(Texture texture) { + return new ResourceLocation(texture.domain, texture.getPath()); + } + + @Override + public Vector2D getDimension(Texture texture) { + return new Vector2D(16, 16); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java new file mode 100644 index 000000000..491f70602 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.item.ItemStack; + +import java.util.Collections; +import java.util.List; +import net.minecraft.client.renderer.block.model.ItemOverrideList; + +/** + * Generates a smart model based on a NOVA Model + * @author Calclavia + */ +public class FWEmptyModel extends FWSmartModel implements IBakedModel { + + @Override + public TextureAtlasSprite getParticleTexture() { + return null; + } + + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.NONE; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java new file mode 100644 index 000000000..e535e7eb5 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemTransformVec3f; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.item.ItemStack; +import nova.core.block.Block; +import nova.core.component.renderer.ItemRenderer; +import nova.core.component.renderer.StaticRenderer; +import nova.core.item.ItemBlock; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.internal.core.Game; + +import java.util.List; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import org.lwjgl.util.vector.Vector3f; + +/** + * Generates a smart model based on a NOVA Model + * @author Calclavia + */ +public class FWSmartBlockModel extends FWSmartModel implements IBakedModel { + + private final Block block; + private final boolean isItem; + + public FWSmartBlockModel(Block block, boolean isDummy) { + super(); + this.block = block; + this.isItem = isDummy; + // Change the default transforms to the default full Block transforms + this.itemCameraTransforms = new ItemCameraTransforms( + new ItemTransformVec3f(new Vector3f(10, -45, 170), // Third Person (Left) + new Vector3f(0, 0.09375f, -0.171875f), new Vector3f(0.375f, 0.375f, 0.375f)), + new ItemTransformVec3f(new Vector3f(10, -45, 170), // Third Person (Right) + new Vector3f(0, 0.09375f, -0.171875f), new Vector3f(0.375f, 0.375f, 0.375f)), + ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, // First Person (Left, Right) + ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, // Head, Gui + ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); // Ground, Fixed + } + + //Block rendering + public IBakedModel handleBlockState(IBlockState state) { + FWBlock block = (FWBlock) state.getBlock(); + + Block blockInstance = block.getBlockInstance(block.lastExtendedWorld, Game.natives().toNova(block.lastExtendedStatePos)); + + if (blockInstance.components.has(StaticRenderer.class)) { + return new FWSmartBlockModel(blockInstance, false); + } + + return new FWEmptyModel(); + } + + //Itemblock rendering + public IBakedModel handleItemState(ItemStack stack) { + ItemBlock item = Game.natives().toNova(stack); + ItemRenderer renderer = + item.components.has(ItemRenderer.class) ? item.components.get(ItemRenderer.class) : block.components.has(ItemRenderer.class) ? block.components.get(ItemRenderer.class) : null; + + if (renderer != null) { + return new FWSmartBlockModel(block, true); + } + + return new FWEmptyModel(); + } + +// public List getGeneralQuads() { +// BWModel blockModel = new BWModel(); +// blockModel.matrix.translate(0.5, 0.5, 0.5); +// +// if (isItem) { +// ItemRenderer renderer = block.components.get(ItemRenderer.class); +// renderer.onRender.accept(blockModel); +// } else { +// StaticRenderer renderer = block.components.get(StaticRenderer.class); +// renderer.onRender.accept(blockModel); +// } +// +// return modelToQuads(blockModel); +// } + + @Override + public TextureAtlasSprite getParticleTexture() { + /* + if (block.components.has(StaticRenderer.class)) { + Optional apply = block.components.get(StaticRenderer.class).texture.apply(Direction.UNKNOWN); + if (apply.isPresent()) { + return RenderUtility.instance.getTexture(apply.components.get()); + } + }*/ + + if (block.components.has(ItemRenderer.class)) { + ItemRenderer itemRenderer = block.components.get(ItemRenderer.class); + if (itemRenderer.texture.isPresent()) { + return RenderUtility.instance.getTexture(itemRenderer.texture.get()); + } + } + + return null; + } + + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.NONE; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java new file mode 100644 index 000000000..bc058802a --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemTransformVec3f; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.item.ItemStack; +import nova.core.component.renderer.ItemRenderer; +import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.internal.core.Game; + +import java.util.Collections; +import java.util.List; +import net.minecraft.client.renderer.block.model.*; +import org.lwjgl.util.vector.Vector3f; + +/** + * Generates a smart model based on a NOVA Model + * @author Calclavia + */ +public class FWSmartItemModel extends FWSmartModel implements IBakedModel { + + private final Item item; + + public FWSmartItemModel(Item item) { + super(); + this.item = item; + // Change the default transforms to the default Item transforms + this.itemCameraTransforms = new ItemCameraTransforms( + new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person + new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person + ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, + ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); + } + + public IBakedModel handleItemState(ItemStack stack) { + Item item = Game.natives().toNova(stack); + + if (item.components.has(ItemRenderer.class)) { + return new FWSmartItemModel(item); + } + + return this; + } + +// public List getGeneralQuads() { +// if (item.components.has(ItemRenderer.class)) { +// BWModel model = new BWModel(); +// ItemRenderer renderer = item.components.get(ItemRenderer.class); +// model.matrix.translate(0.5, 0.5, 0.5); +// renderer.onRender.accept(model); +// return modelToQuads(model); +// } +// +// return Collections.emptyList(); +// } + + @Override + public TextureAtlasSprite getParticleTexture() { + if (item.components.has(ItemRenderer.class)) { + ItemRenderer itemRenderer = item.components.get(ItemRenderer.class); + if (itemRenderer.texture.isPresent()) { + return RenderUtility.instance.getTexture(itemRenderer.texture.get()); + } + } + + return null; + } + + @Override + public boolean isGui3d() { + return item.components.has(ItemRenderer.class); + } + + @Override + public ItemOverrideList getOverrides() { + return ItemOverrideList.NONE; + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java new file mode 100644 index 000000000..a730fa566 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.render; + +import com.google.common.primitives.Ints; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.util.EnumFacing; +import nova.core.render.model.MeshModel; +import nova.core.render.model.Model; +import nova.core.render.model.Vertex; +import nova.core.util.Direction; +import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrideList; + +/** + * Generates a smart model based on a NOVA Model + * @author Calclavia + */ +public abstract class FWSmartModel implements IBakedModel { + + protected final VertexFormat format; + // Default item transforms. Can be changed in subclasses. + protected ItemCameraTransforms itemCameraTransforms = ItemCameraTransforms.DEFAULT; + + public FWSmartModel() { + this.format = new VertexFormat(); + } + + public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture) { + return new int[] { + Float.floatToRawIntBits((float) vertex.vec.getX()), + Float.floatToRawIntBits((float) vertex.vec.getY()), + Float.floatToRawIntBits((float) vertex.vec.getZ()), + vertex.color.rgba(), + Float.floatToRawIntBits(texture.getInterpolatedU(16 * vertex.uv.getX())), + Float.floatToRawIntBits(texture.getInterpolatedV(16 * vertex.uv.getY())), + 0 + }; + } + + protected List modelToQuads(Model modelIn) { + return modelIn + .flatten() + .stream() + .flatMap( + model -> { + if (model instanceof MeshModel) { + MeshModel meshModel = (MeshModel) model; + return meshModel.faces + .stream() + .map( + face -> { + List vertexData = face.vertices + .stream() + .map(v -> vertexToInts(v, RenderUtility.instance.getTexture(face.texture.get()))) + .collect(Collectors.toList()); + + int[] data = Ints.concat(vertexData.toArray(new int[][] {})); + //TODO: The facing might be wrong + return new BakedQuad(data, -1, EnumFacing.values()[Direction.fromVector(face.normal).ordinal()], + getParticleTexture(), true, getFormat()); + } + ); + } + //TODO: Handle BW Rendering + return Stream.empty(); + } + ) + .collect(Collectors.toList()); + } + + public VertexFormat getFormat() { + return format; + } + + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + return Collections.emptyList(); + } + + @Override + public boolean isAmbientOcclusion() { + return true; + } + + @Override + public boolean isGui3d() { + return true; + } + + @Override + public boolean isBuiltInRenderer() { + return false; + } + + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return itemCameraTransforms; + } +} diff --git a/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg b/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg index 33402846a..8602ae65f 100644 --- a/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg +++ b/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg @@ -10,3 +10,21 @@ public net.minecraft.client.renderer.block.model.ModelBakery field_177606_o # MO public net.minecraft.client.renderer.block.model.ModelBakery field_177609_j # textureMap public net.minecraft.client.renderer.block.model.ModelBakery field_177599_g # sprites public net.minecraft.client.renderer.block.model.ModelBakery func_177578_a(Lnet/minecraft/client/renderer/block/model/ModelBlock;Lnet/minecraft/client/renderer/block/model/ModelRotation;Z)Lnet/minecraft/client/renderer/block/model/IBakedModel; # models + +# Particles +public net.minecraft.client.particle.Particle field_187122_b # worldObj +public net.minecraft.client.particle.Particle field_187123_c # prevPosX +public net.minecraft.client.particle.Particle field_187124_d # prevPosY +public net.minecraft.client.particle.Particle field_187125_e # prevPosZ +public net.minecraft.client.particle.Particle field_187126_f # posX +public net.minecraft.client.particle.Particle field_187127_g # posY +public net.minecraft.client.particle.Particle field_187128_h # posZ +public net.minecraft.client.particle.Particle field_187129_i # motionX +public net.minecraft.client.particle.Particle field_187130_j # motionY +public net.minecraft.client.particle.Particle field_187131_k # motionZ +public net.minecraft.client.particle.Particle field_187132_l # isCollided +public net.minecraft.client.particle.Particle field_187133_m # isExpired +public net.minecraft.client.particle.Particle field_187134_n # width +public net.minecraft.client.particle.Particle field_187135_o # height +public net.minecraft.client.particle.Particle field_70544_f # particleScale +public net.minecraft.client.particle.Particle field_70545_g # particleGravity diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java new file mode 100644 index 000000000..b73dcc587 --- /dev/null +++ b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.GameInfoModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.KeyModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.LanguageModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.RenderModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.SaveModule; +import nova.core.wrapper.mc.forge.v1_11.depmodules.TickerModule; +import nova.internal.core.Game; +import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; +import nova.wrappertests.depmodules.FakeNetworkModule; +import org.junit.Test; +import se.jbee.inject.bootstrap.Bundle; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author rx14 + */ +public class NovaLauncherTest extends nova.wrappertests.NovaLauncherTest { + + @Override + public List> getModules() { + return Arrays.>asList( + ClientModule.class, + KeyModule.class, + LanguageModule.class, + FakeNetworkModule.class, //NetworkManager calls into FML code in the class instantiation, so we create a fake. + RenderModule.class, + SaveModule.class, + TickerModule.class, + GameInfoModule.class + ); + } + + @Override + @Test + public void testLaunching() { + doLaunchAssert(createLauncher()); + } + + @Override + @Test + public void testResolveGame() { + DependencyInjectionEntryPoint diep = new DependencyInjectionEntryPoint(); + + getModules().forEach(diep::install); + + Game game = diep.init(); + + assertThat(game).isNotNull(); + } +} From f6837a7d7a30afcb636e148a7574852801bd9a76 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 20 Dec 2016 17:52:35 +0100 Subject: [PATCH 07/61] Added mcmod.info + Minecraft 1.11 now launches and is playable (currently no NOVA TileEntities) TODO: Fix TileEntityTransformer. --- .../transformers/TileEntityTransformer.java | 2 +- .../v1_11/asm/transformers/Transformers.java | 2 +- .../v1_11/launcher/ForgeEventHandler.java | 2 +- .../forge/v1_11/launcher/NovaMinecraft.java | 3 +- .../mc/forge/v1_11/render/RenderUtility.java | 2 +- .../resources/assets/nova/textures/NOVA.png | Bin 0 -> 8484 bytes .../resources/assets/nova/textures/NOVA.svg | 53 ++++++++++++++++++ minecraft/1.11/src/main/resources/mcmod.info | 21 +++++++ .../resources/assets/nova/textures/NOVA.png | Bin 0 -> 8484 bytes .../resources/assets/nova/textures/NOVA.svg | 53 ++++++++++++++++++ minecraft/1.7/src/main/resources/mcmod.info | 21 +++++++ .../resources/assets/nova/textures/NOVA.png | Bin 0 -> 8484 bytes .../resources/assets/nova/textures/NOVA.svg | 53 ++++++++++++++++++ minecraft/1.8/src/main/resources/mcmod.info | 21 +++++++ 14 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.png create mode 100644 minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.svg create mode 100644 minecraft/1.11/src/main/resources/mcmod.info create mode 100644 minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png create mode 100644 minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.svg create mode 100644 minecraft/1.7/src/main/resources/mcmod.info create mode 100644 minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png create mode 100644 minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.svg create mode 100644 minecraft/1.8/src/main/resources/mcmod.info diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java index 9fb66f60c..db682a886 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java @@ -52,7 +52,7 @@ public void transform(ClassNode cnode) { System.out.println("[NOVA] Transforming method " + method.name); - ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 33, 36)); + ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 31, 44)); InsnList list = new InsnList(); list.add(new VarInsnNode(ALOAD, 0)); // World diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java index fc8a1cf2f..6876bfc38 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java @@ -36,7 +36,7 @@ public final class Transformers implements IClassTransformer { public Transformers() { registerTransformer(new ChunkTransformer(), "net.minecraft.world.chunk.Chunk"); - registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); + //registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); } public static void registerTransformer(Transformer transformer, String... classes) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java index b84f1707e..54e808c09 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java @@ -77,7 +77,7 @@ public void playerInteractEvent(PlayerInteractEvent event) { ((LeftClickBlock)event).setUseBlock(Event.Result.values()[evt.useBlock.ordinal()]); ((LeftClickBlock)event).setUseItem(Event.Result.values()[evt.useItem.ordinal()]); } - event.setCanceled(evt.isCanceled()); + if (event.isCancelable()) event.setCanceled(evt.isCanceled()); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index eeb986800..fff394693 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -80,7 +80,7 @@ public class NovaMinecraft { public static final String name = "NOVA"; public static final String mcId = "minecraft"; - @SidedProxy(clientSide = "nova.core.wrapper.mc.forge.v18.launcher.ClientProxy", serverSide = "nova.core.wrapper.mc.forge.v18.launcher.CommonProxy") + @SidedProxy(clientSide = "nova.core.wrapper.mc.forge.v1_11.launcher.ClientProxy", serverSide = "nova.core.wrapper.mc.forge.v1_11.launcher.CommonProxy") public static CommonProxy proxy; @Mod.Instance(id) public static NovaMinecraft instance; @@ -162,6 +162,7 @@ public void preInit(FMLPreInitializationEvent evt) { nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet()); nativeConverters.stream().forEachOrdered(Loadable::preInit); + // TODO: Make child mods section display names of loaded NOVA mods. childModMetadata = Collections.emptySet();//.stream().filter(l -> l.getClass().isAnnotationPresent(nova.core.loader.Mod.class)) //.map(l -> ((nova.core.loader.Mod)l.getClass().getDeclaredAnnotation(nova.core.loader.Mod.class))).collect(Collectors.toSet()); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index bb66e4662..b47c6c7ee 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -107,7 +107,7 @@ public class RenderUtility { " \"rotation\": [ 0, -135, 25 ],\n" + " \"translation\": [ 0, 4, 2 ],\n" + " \"scale\": [ 1.7, 1.7, 1.7 ]\n" + - " }\n" + + " },\n" + " \"firstperson_lefthand\": {\n" + " \"rotation\": [ 0, 135, 25 ],\n" + " \"translation\": [ 0, 4, 2 ],\n" + diff --git a/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.png new file mode 100644 index 0000000000000000000000000000000000000000..1f42e113ce5dbaa9b1bc62df36b8d523f52b5ae5 GIT binary patch literal 8484 zcmd6NhdY)3|NnhZW^rsn#zDzGl}&MkGD0Xb9UZdw$T}H0M&3roF^(ch65`k^;~>Z0 zd++UtWPR^G|HSX-x*VMAT(A4(^?W`b>%Jo&>uOw~;iLfo;EI+e!Tc8yWz#kMIs#;H|z^?!*8w~h2wX5bc4*^Rx_Z z+Wg9{?<45%xlzRlX^rITGLb<`;$_x}U*KO_ciMWgV&OT8N%ubR!KRE>jD57xH$q2w zqr~54(Y#VW-Fxs8<{9GmJ7<0SILGBFhj#yv#mS_9L8*#ERkC>Ej+|EY$za_{Mj(*; z-r(WQ|MxF<`W{a*J!T4(T7C{hz)4Wt3OAJEr#63@F5(>^Bt`lOTu${vW6GsT0NMni zsE5$YGsw^DT-v7{9(Vs1%#izDoX&o8xhs97cW}^?4w?zfQUGmazM=OHB+<$MJ;ay2 zQEhm9<&t}n0aEgN_)m5Z6?EuV?hI_v@4$;#dk^zYRH?8e>5hS4`duga@`{QISQ6VM zB$1gvt%vvw$Ro3hv0Kdpo&tUjTSWq#9z`)yE|+)7JG4tmv>nE>A_S8ruseWc)pj0ZBnjOj0)NYu- z-b0#B>{*e~L{-0tsiJQb4nwNg6$U<$E#)VqT9N&Udpzk{Wv-lEQ*)yJv3Ar~>c5#) zKTEyL=wpVd^W1;mGS9E2IlOuqh1lbS=o{^0G#d%V|OOn&aSFS;EyA^xgm zL(my7eC8&XziWR~@7C6q7s4~vb+i2E&z~W#DD@br>y*3GRBsdB}B_$0MfsOno}3v+Aqo=jWGzX&6=uaceylR3-omMUUieZ{>hAR4Sg6G^-adQ~p)`SW|HukO%jS+WDOmEc7$xQ}4= zV+n$fu0G5g*nrgD+OBGOhj9moBf6>bx@m4%$4rnRd?VhM9*b3+g5 z1^a7Vp+vVIkfz)g2|D&?PA*p}i1{>2?sD|^Aop~3^1RVNfJ%DTc^x7Z?~TEHQlMzF z3{&1~VHyBF$=s}!f7So#X;k->D_0&tPIb7DBlB-6OrNp?&(l`?rU4j zvLG4I=H6hTY;pd-Yyg2&OMmJ9?l#zxz6=yQyNWwXKrE%}Rd_IYBRymj;~V=5Rd4vU zjS(71&-9Hdu$?ag!qU%RaL%tHwvukMC zi#HCcl|CwLb8!-oN+qh0?iVG0WJON+j(4{&7;y&YRM5;$A_u~w{)G^_R%&@+c>JS% z$o}!EAtBYW-J3^gnw?b7zVpGgZ_g_{l&Jr*bWBg0(lxN8m{(h?$nH>Hx+9X{>A@qW*X_@VVldLjyR3*PCUP<;)x+zTuD9Xu>@Db4TQIw2agE?KaaI)BU^EMg_)atw(1C8|&+_&zG<9o<^Z0 z#5--Ijb!Ly+0H1o}!cv;vYC}kK;ROY>i=}r$X6BoNy~1XBw^AwA4k*+JgFe<#Nkg zS~fA*7UGB;59;_}Z9rvcXz2I11vkrulOUJ;C-Rr?6*XHgJCFTXin3Qz?5Ux?$19no zr2e{Q;@h**ZVJ~gHbU^366dMv%mi$bowGCU7cndL_2ikat(DbG-aHN=Xb%o36b}|J zt&&lSW-gH8d-;Jh`cWaCt;Nm6OHZ%o7I2Qkm|L#z<9GLy-8xrDdXPVny#d||VEvWn zh=FOETX?WwDb}B?j1yWccfKIH#OZ)W;z)UUInQoHMY8BKcLuoC_6;1w99391tskWR z4X;KFxCTlW#3`g9Ai%Y(_u$qn!P z8FTX2!XfvN3>24;+WpEb2zyu8-50=sxec6@vS7*VT{@gB<2+eO*Ju&@w(|L0Q@9a# z$cyDWz`5w{tSPKM%f|`63uWbGlX{SOdC;(PK&Xer*sxST%yt>@rF^hGTUZqYV@wt^ z8(!VDc^R>D!apIG8+K{uF7Tfm#^q~4K}}g2dbi`Vnw@fuoP=tGaAxjIn+rEP`;C7E zq&9nUgnZVoLevclhXBjhkjmGOVDrTuE8Q=F=~Z5EmKn$NrcG;6RgGUE{}n?Mvl ze6Vw%xHD<5M^Q8QuNiWxf6<}7e@)UXc^bgkc&17k+mcODUyU5JQ~-$zGM43J2Jxg? zeuI^Gw9i6ddS$IizIvO$#dw6sX5^Wc)0I!bHe~dyWWDcBT0S}F27-7qA0eE`q{OES z6<)P*vu5V1SYMPq6+NW3jTM>1xRu)oK?|uuX0OEs(kRk3u7&tz3;mB5A-ze9Nl!WW|+D?*GRzSaJZgX@$>set*1KacMBoA!XJ+}%Lmn=@&Tp{XSm3My2IYy z-eUk}rbn^leoO#Sh!VKCnMw=u-B?GMfnaZgs+Zo@LbRyg-@k5wvr9%51`2IDi{yW- zuRkZ+lfCx$e}s7dC$U!;=lf#(CttD2XKgH_U!Rpe3!J~%76x8!3?v&EOSFTI_tnvtl#O^7JNbw1oX~IX zHE^I02G;uRd%7#*!oq(V`7fyfiv>=x$xj$nDlKgt3=I=IlbLk=a7Tf2?agcwmZ!t^ zYFu>=Y&TUSf|b{%mFS;31m6O83C@gMTpc|*P#-J z6MXyRz8{VwJmqY%KFA;!EfX)S{|T^EzuZ|_-t6dR^0$%Dlcq)@Id0`8Uky#eTTFdw zhmCnfb}T0(^%keBd)B?KUrX)~Xkk1Nmi_f2wpsPu2|NkIA@$Yby7B|Q0uv!U+@t`w z|I%)G2YG0wAhv_p2@1=@y$cKSvGKl%rtjtdt^ojZI6o6%g-DF?;CN=i2{J~G8NGNm zqImoE;H^|Pwm!9&_Zc(;yF@7;v;G<{{JN8Zh1=q;&Sk^lGpucfw)s!&DSKfY927s5 z9jNDqjrzv*`%QgeFRTH;!3l@WonhL!D@GNvZEwa6Ymaa8Yp^Iq=`fqTl3((hZqB** z`U@K0-t@dMkZ0e2wm?LcDgJ;`DmJICTuP{wn3YI`@i%~~zxC{llhP+EfXMC<hOF)aghQNws+}(u>23OQlzn*F&n@76>)KsXo60{i76d3;AV}8{oVJXvZCn$Ehft ze!-U~2C&t z8W%=)7M{)3-elwhC9EK--UwWsa%UXxpbeJPf+#)b=Qv#-SYtQWzzABH9ZKG6r*!PC zpaM`&y3*RnblnCUl5~kg5OV`9%%A#THt1PI&L0q&t5Zau@sH^V8h~|V9iR2X9eDqe z)e072d&Um%X6nw+&G8?|+F#03`xBXnakgj(sypZ)>HFb?&&rD3+G4qbavOaAH790O zcTUdyeOReUq&cXz76|XGF7L+W{K0MFVC`{Y|liFfRex)iRJD3&4>i>eO)i}(u%&yN2$PiIHJac2tj9m2q zI4=oMO8qGG)oxO$SsgZtkdZbPEdkFW%#6UQ7DO)#ps@|E;c9I$3ty0rblwT1UPwmc<>mIv0-X5U@J0-?B(zL>Rmc)(0;4)M3XK zW#S~p2{0#)w%9ZG7X=CZI=;F$;)p1-knS-x6XM@X?9E~M*nD>0zlE3C8ZAK3$T&j;ar;ZSXnV9P=S(m>O#%8ciu#7J^C`ko4J}*jWA zHfZSO8qB9Ow1i{TFGTM%U`DJS=JtzWDyei3dG{+<>7J`|soS=@=m&mzDjIttswbX8 z3ryaSz0RQTkTLbq;e~bklKXv7-(1^Q(DhbmW+&0d{%8e@`?om?Ypb=~8j1OI^d?$a z3Mi`Mw~*kfnc*)BJsjtvcyn+#p&wopq$0}Y-?iFcbMZDJ!XGaOW6gM2m*Rf0j-@mW>8aAfPYtwC)>$cy}M|YFL zB5EWyIhgShR4Zq0e-GA-X0Gv+zlUyB|01%9o0V(-XtXRz``4F>@qg}U?7iX_5&frh zWA_CkStXQu(j{rhZCrN8tL=wGge`(sx-uvyB|Ze*Fwu<>KKWT6BS7vWs@EK|#~N$4J4crVy+OFP1Ik z5-qDXIq#VI$g_gD-MTVTVsDjsH*)!9(?YGH(|B2XbT@9rg6e~%r2EM3?yi`D^>M(t z4-h1pL|N~)tFE2$`!T) z$8bUewWWK!JbrF(Z>Pja9RYT%F-qkii=VZ=*fRlUKcG9VmQTcf&CkzgK_3u83}dAF zGs9bF?o!-$UV@VHuE`b80VzR_?pE9O>FQr8-yJ z7EU^kiuU=9IN+GYXOmtv?H!pq2r7&khhfY&H&nP9rJ61{j<`8aR1wjz?d#X0(=6D5 z#-p<>G1_xPlb!Kmxh*LU=VA!Ur zsiE5Po3`b>Fy`IQE|ppq0F>E(S5hZj4Vi7aLHTX$Iz>%*g^beNjq_&WsgA~&5g-5B zb<>E$-@h~YGB~iH4SeIeIFK_nFUXhDd5I`G6}CNVQR9t=#vf>{q~z&k1*L#Po6xIp z!?rT^vSKs&%zBo6_0`~T*FKKMs4vmogj5+gDda|*_7{$K@7_7-Uoj?ukis0@+6Gjv zi>b1&utbS_d3!rw-c5Dg>;Q4TKks3tgQH_DGy33+GoEF>`Ic6$N~9iJH?2Yb`_bWU zsY(igbOC19OZ@gzaK8Vw_IIEcdZd`$LiAhH?jhBOa;{%{86y{lZGdqp+(Q^;z2(lS z{7(2b_#eoVxOeW2uC!i`PJE1Z&S3uJ%S^753KCUXTADb;?ndPbGzo+v>f;fuwwI;P z1Txn8hvI@wE89#@zPc_4bz$KvmX!+WhIkM-;Uq=?KYToz|7Bf_$=-T(b(NhegqL>A z|0&b0Q;H*xHFH$`Pj=FSHS`2^U?fy1MQ|Z7c z2UhCQp!$mAU4KS&P7YV;gHNf){NOT`;4(Dfs&6oelN{lp_csllDR&b>R|nu&qS00N zg5l|DOECYV1zJvqnEJf9xw*;vtCFZ(7|ht(Mo*v=_Zf~8>EPFQL0=M%=`LC%)Z1&f zgG+*W(%~hbzio<1_>|APFxrv7S{lrU+~O_X6`EB{Q_b2?_Dw`YMCAHU#b|Nu>}!LZH?W(mC(7Qh$P}&eW+agL4EC`F^2p}cmww0V$C@I6O=SY#_B;>y?&0K?j8Kh#09{s=k0qlSZDR}6=i?DbSv#u1$CvYaX9aIrUH<*JQV~)wuK7`xhvbyq*uG^g`p+9YXtzr04 zH=;Z>Ie9vScNlSIA}YH6Z$T2o5 zc4+fge}8;KQ3U&}ur->^%0fIP<^Hxm=>vg4&{Om6{0qTL0*#wvr57e(zTpNavw)|# z7uX<^-WBu?d!dI=t53of*(~3BCl!3Tmv+_-6_kL%kr#uee2a^R=Md25%f5;5WQKCL z5_e{PyzJD7Y+rkmSvQ*TFxNCkxle%=G!E+dPpWCIelOx~?a~Le;i@z$Ip9uJ;rH*| z>L%!~o?c!`4lz~NLPn~jNx4<#+pqKUyk~)Ysm+@pV&@vXx`|dHD6yrWdT?htfCG~K z?-jrlVy=U@1T;|enuw=lf!XiP9#W7RLWSJ*8a((?V?K~=$@~`Ur)6R?LJR#*K`1jb zGaW0p&hJSLJ#uvS%p!=*-Q8{hsY30&21pf=%1+#_AV41+95@~*N`z84QhN%X9u%`T zhJp#Fbt+b3H}GP*QrIApJ*wBo%t7F+cd)nDmB&V5@pAr?^~*mM^}|)?l-p;7#jCx3 zqe0oso7Hm>f-Q>i=MjJA;4?Hb(nA^d<>;Fm7|{Q%zyA9!(XDj&oMO8>?=*?s)SUrX z`|RqoL^{q3gR9G}E_pw6a3~m!{Z8%;+N+tPhASV0xBV*1?1#QKfa-rh@`u_2nn0{l z{W!ZGR(UHXUbjNu_YH0?;5z z^{9nNXvX(~H)cwnh=6yU<|Gb^x7ES0-gWgMRR0Kd;T7Ipmk%~9f$JQxREHT`n~xl;=;qi7Cn?zQMHyb_|8`<(Cg@4rEW2$;Fhu2gc>m?XKaHUOs<;D4nx z$rL|(5+s41ss8of>!X2?OSGRsS&&I4Q)FKC<8%FI?m@L_U4+rh%a63pJeXBgpds3y zM;~m3SY9e+s#zJg9(8s&2@mKN4+||@l2c#JI>6a3pK!h0F|x3jvgPv+%B7q25Alnq zQmIrF!rpW{$rPvaFCKP2Qk0;5ZVSfws$c{~*621z-;cNxe=W~8_4vumkwnGt)m9~r zSD;EFNB_a+AUqAEkZM|=)~QE{jlli%t(Ky7h?wQugTP31d1oqJed2S^d9m}H`gH8>;|*@ z+}Q|ITBvCw{XZKH%c!zKz^2r_)IL65W$BKI!F#iz(*@yJzmBGG+6z=|gB9D`z*I%Q zeRUv+1yn7@H<)Qa5S5F^DyUBuW1lT7Q{EcMPF@tSiBK2orMIaZ`l}FdkP> zP>|7(4VtIBa%Ji=HaK)Cp)gHjV0id0Q{ywx0*B{e9B`rX9qA`0Cu}h*GOZ*3ut z+$%eQbtd8N8Q@`rgY@cyDAN=nbqHsDt7@CxO)mmI^n#M*=+~{HfJRa+6A(brSOUPd z-|&zXzrkMLSKP71ttc`7KG`uXMs=kX5>m||8OG|`4CUh(?J9FnTqZn+ + + + + + + image/svg+xml + + + + + + + NOVA + + + + + + + + diff --git a/minecraft/1.11/src/main/resources/mcmod.info b/minecraft/1.11/src/main/resources/mcmod.info new file mode 100644 index 000000000..069e663b7 --- /dev/null +++ b/minecraft/1.11/src/main/resources/mcmod.info @@ -0,0 +1,21 @@ +{ + "modListVersion": 2, + "modList": [{ + "modid": "nova", + "name": "NOVA", + "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", + "version": "0.0.1", + "mcversion": "1.11", + "url": "http://novaapi.net/", + "updateUrl": "", + "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], + "credits": "Created by the NOVA Team.\nPorted to Minecraft 1.11 by: ExE Boss.", + "logoFile": "/assets/nova/textures/NOVA.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": true + }] +} diff --git a/minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png new file mode 100644 index 0000000000000000000000000000000000000000..1f42e113ce5dbaa9b1bc62df36b8d523f52b5ae5 GIT binary patch literal 8484 zcmd6NhdY)3|NnhZW^rsn#zDzGl}&MkGD0Xb9UZdw$T}H0M&3roF^(ch65`k^;~>Z0 zd++UtWPR^G|HSX-x*VMAT(A4(^?W`b>%Jo&>uOw~;iLfo;EI+e!Tc8yWz#kMIs#;H|z^?!*8w~h2wX5bc4*^Rx_Z z+Wg9{?<45%xlzRlX^rITGLb<`;$_x}U*KO_ciMWgV&OT8N%ubR!KRE>jD57xH$q2w zqr~54(Y#VW-Fxs8<{9GmJ7<0SILGBFhj#yv#mS_9L8*#ERkC>Ej+|EY$za_{Mj(*; z-r(WQ|MxF<`W{a*J!T4(T7C{hz)4Wt3OAJEr#63@F5(>^Bt`lOTu${vW6GsT0NMni zsE5$YGsw^DT-v7{9(Vs1%#izDoX&o8xhs97cW}^?4w?zfQUGmazM=OHB+<$MJ;ay2 zQEhm9<&t}n0aEgN_)m5Z6?EuV?hI_v@4$;#dk^zYRH?8e>5hS4`duga@`{QISQ6VM zB$1gvt%vvw$Ro3hv0Kdpo&tUjTSWq#9z`)yE|+)7JG4tmv>nE>A_S8ruseWc)pj0ZBnjOj0)NYu- z-b0#B>{*e~L{-0tsiJQb4nwNg6$U<$E#)VqT9N&Udpzk{Wv-lEQ*)yJv3Ar~>c5#) zKTEyL=wpVd^W1;mGS9E2IlOuqh1lbS=o{^0G#d%V|OOn&aSFS;EyA^xgm zL(my7eC8&XziWR~@7C6q7s4~vb+i2E&z~W#DD@br>y*3GRBsdB}B_$0MfsOno}3v+Aqo=jWGzX&6=uaceylR3-omMUUieZ{>hAR4Sg6G^-adQ~p)`SW|HukO%jS+WDOmEc7$xQ}4= zV+n$fu0G5g*nrgD+OBGOhj9moBf6>bx@m4%$4rnRd?VhM9*b3+g5 z1^a7Vp+vVIkfz)g2|D&?PA*p}i1{>2?sD|^Aop~3^1RVNfJ%DTc^x7Z?~TEHQlMzF z3{&1~VHyBF$=s}!f7So#X;k->D_0&tPIb7DBlB-6OrNp?&(l`?rU4j zvLG4I=H6hTY;pd-Yyg2&OMmJ9?l#zxz6=yQyNWwXKrE%}Rd_IYBRymj;~V=5Rd4vU zjS(71&-9Hdu$?ag!qU%RaL%tHwvukMC zi#HCcl|CwLb8!-oN+qh0?iVG0WJON+j(4{&7;y&YRM5;$A_u~w{)G^_R%&@+c>JS% z$o}!EAtBYW-J3^gnw?b7zVpGgZ_g_{l&Jr*bWBg0(lxN8m{(h?$nH>Hx+9X{>A@qW*X_@VVldLjyR3*PCUP<;)x+zTuD9Xu>@Db4TQIw2agE?KaaI)BU^EMg_)atw(1C8|&+_&zG<9o<^Z0 z#5--Ijb!Ly+0H1o}!cv;vYC}kK;ROY>i=}r$X6BoNy~1XBw^AwA4k*+JgFe<#Nkg zS~fA*7UGB;59;_}Z9rvcXz2I11vkrulOUJ;C-Rr?6*XHgJCFTXin3Qz?5Ux?$19no zr2e{Q;@h**ZVJ~gHbU^366dMv%mi$bowGCU7cndL_2ikat(DbG-aHN=Xb%o36b}|J zt&&lSW-gH8d-;Jh`cWaCt;Nm6OHZ%o7I2Qkm|L#z<9GLy-8xrDdXPVny#d||VEvWn zh=FOETX?WwDb}B?j1yWccfKIH#OZ)W;z)UUInQoHMY8BKcLuoC_6;1w99391tskWR z4X;KFxCTlW#3`g9Ai%Y(_u$qn!P z8FTX2!XfvN3>24;+WpEb2zyu8-50=sxec6@vS7*VT{@gB<2+eO*Ju&@w(|L0Q@9a# z$cyDWz`5w{tSPKM%f|`63uWbGlX{SOdC;(PK&Xer*sxST%yt>@rF^hGTUZqYV@wt^ z8(!VDc^R>D!apIG8+K{uF7Tfm#^q~4K}}g2dbi`Vnw@fuoP=tGaAxjIn+rEP`;C7E zq&9nUgnZVoLevclhXBjhkjmGOVDrTuE8Q=F=~Z5EmKn$NrcG;6RgGUE{}n?Mvl ze6Vw%xHD<5M^Q8QuNiWxf6<}7e@)UXc^bgkc&17k+mcODUyU5JQ~-$zGM43J2Jxg? zeuI^Gw9i6ddS$IizIvO$#dw6sX5^Wc)0I!bHe~dyWWDcBT0S}F27-7qA0eE`q{OES z6<)P*vu5V1SYMPq6+NW3jTM>1xRu)oK?|uuX0OEs(kRk3u7&tz3;mB5A-ze9Nl!WW|+D?*GRzSaJZgX@$>set*1KacMBoA!XJ+}%Lmn=@&Tp{XSm3My2IYy z-eUk}rbn^leoO#Sh!VKCnMw=u-B?GMfnaZgs+Zo@LbRyg-@k5wvr9%51`2IDi{yW- zuRkZ+lfCx$e}s7dC$U!;=lf#(CttD2XKgH_U!Rpe3!J~%76x8!3?v&EOSFTI_tnvtl#O^7JNbw1oX~IX zHE^I02G;uRd%7#*!oq(V`7fyfiv>=x$xj$nDlKgt3=I=IlbLk=a7Tf2?agcwmZ!t^ zYFu>=Y&TUSf|b{%mFS;31m6O83C@gMTpc|*P#-J z6MXyRz8{VwJmqY%KFA;!EfX)S{|T^EzuZ|_-t6dR^0$%Dlcq)@Id0`8Uky#eTTFdw zhmCnfb}T0(^%keBd)B?KUrX)~Xkk1Nmi_f2wpsPu2|NkIA@$Yby7B|Q0uv!U+@t`w z|I%)G2YG0wAhv_p2@1=@y$cKSvGKl%rtjtdt^ojZI6o6%g-DF?;CN=i2{J~G8NGNm zqImoE;H^|Pwm!9&_Zc(;yF@7;v;G<{{JN8Zh1=q;&Sk^lGpucfw)s!&DSKfY927s5 z9jNDqjrzv*`%QgeFRTH;!3l@WonhL!D@GNvZEwa6Ymaa8Yp^Iq=`fqTl3((hZqB** z`U@K0-t@dMkZ0e2wm?LcDgJ;`DmJICTuP{wn3YI`@i%~~zxC{llhP+EfXMC<hOF)aghQNws+}(u>23OQlzn*F&n@76>)KsXo60{i76d3;AV}8{oVJXvZCn$Ehft ze!-U~2C&t z8W%=)7M{)3-elwhC9EK--UwWsa%UXxpbeJPf+#)b=Qv#-SYtQWzzABH9ZKG6r*!PC zpaM`&y3*RnblnCUl5~kg5OV`9%%A#THt1PI&L0q&t5Zau@sH^V8h~|V9iR2X9eDqe z)e072d&Um%X6nw+&G8?|+F#03`xBXnakgj(sypZ)>HFb?&&rD3+G4qbavOaAH790O zcTUdyeOReUq&cXz76|XGF7L+W{K0MFVC`{Y|liFfRex)iRJD3&4>i>eO)i}(u%&yN2$PiIHJac2tj9m2q zI4=oMO8qGG)oxO$SsgZtkdZbPEdkFW%#6UQ7DO)#ps@|E;c9I$3ty0rblwT1UPwmc<>mIv0-X5U@J0-?B(zL>Rmc)(0;4)M3XK zW#S~p2{0#)w%9ZG7X=CZI=;F$;)p1-knS-x6XM@X?9E~M*nD>0zlE3C8ZAK3$T&j;ar;ZSXnV9P=S(m>O#%8ciu#7J^C`ko4J}*jWA zHfZSO8qB9Ow1i{TFGTM%U`DJS=JtzWDyei3dG{+<>7J`|soS=@=m&mzDjIttswbX8 z3ryaSz0RQTkTLbq;e~bklKXv7-(1^Q(DhbmW+&0d{%8e@`?om?Ypb=~8j1OI^d?$a z3Mi`Mw~*kfnc*)BJsjtvcyn+#p&wopq$0}Y-?iFcbMZDJ!XGaOW6gM2m*Rf0j-@mW>8aAfPYtwC)>$cy}M|YFL zB5EWyIhgShR4Zq0e-GA-X0Gv+zlUyB|01%9o0V(-XtXRz``4F>@qg}U?7iX_5&frh zWA_CkStXQu(j{rhZCrN8tL=wGge`(sx-uvyB|Ze*Fwu<>KKWT6BS7vWs@EK|#~N$4J4crVy+OFP1Ik z5-qDXIq#VI$g_gD-MTVTVsDjsH*)!9(?YGH(|B2XbT@9rg6e~%r2EM3?yi`D^>M(t z4-h1pL|N~)tFE2$`!T) z$8bUewWWK!JbrF(Z>Pja9RYT%F-qkii=VZ=*fRlUKcG9VmQTcf&CkzgK_3u83}dAF zGs9bF?o!-$UV@VHuE`b80VzR_?pE9O>FQr8-yJ z7EU^kiuU=9IN+GYXOmtv?H!pq2r7&khhfY&H&nP9rJ61{j<`8aR1wjz?d#X0(=6D5 z#-p<>G1_xPlb!Kmxh*LU=VA!Ur zsiE5Po3`b>Fy`IQE|ppq0F>E(S5hZj4Vi7aLHTX$Iz>%*g^beNjq_&WsgA~&5g-5B zb<>E$-@h~YGB~iH4SeIeIFK_nFUXhDd5I`G6}CNVQR9t=#vf>{q~z&k1*L#Po6xIp z!?rT^vSKs&%zBo6_0`~T*FKKMs4vmogj5+gDda|*_7{$K@7_7-Uoj?ukis0@+6Gjv zi>b1&utbS_d3!rw-c5Dg>;Q4TKks3tgQH_DGy33+GoEF>`Ic6$N~9iJH?2Yb`_bWU zsY(igbOC19OZ@gzaK8Vw_IIEcdZd`$LiAhH?jhBOa;{%{86y{lZGdqp+(Q^;z2(lS z{7(2b_#eoVxOeW2uC!i`PJE1Z&S3uJ%S^753KCUXTADb;?ndPbGzo+v>f;fuwwI;P z1Txn8hvI@wE89#@zPc_4bz$KvmX!+WhIkM-;Uq=?KYToz|7Bf_$=-T(b(NhegqL>A z|0&b0Q;H*xHFH$`Pj=FSHS`2^U?fy1MQ|Z7c z2UhCQp!$mAU4KS&P7YV;gHNf){NOT`;4(Dfs&6oelN{lp_csllDR&b>R|nu&qS00N zg5l|DOECYV1zJvqnEJf9xw*;vtCFZ(7|ht(Mo*v=_Zf~8>EPFQL0=M%=`LC%)Z1&f zgG+*W(%~hbzio<1_>|APFxrv7S{lrU+~O_X6`EB{Q_b2?_Dw`YMCAHU#b|Nu>}!LZH?W(mC(7Qh$P}&eW+agL4EC`F^2p}cmww0V$C@I6O=SY#_B;>y?&0K?j8Kh#09{s=k0qlSZDR}6=i?DbSv#u1$CvYaX9aIrUH<*JQV~)wuK7`xhvbyq*uG^g`p+9YXtzr04 zH=;Z>Ie9vScNlSIA}YH6Z$T2o5 zc4+fge}8;KQ3U&}ur->^%0fIP<^Hxm=>vg4&{Om6{0qTL0*#wvr57e(zTpNavw)|# z7uX<^-WBu?d!dI=t53of*(~3BCl!3Tmv+_-6_kL%kr#uee2a^R=Md25%f5;5WQKCL z5_e{PyzJD7Y+rkmSvQ*TFxNCkxle%=G!E+dPpWCIelOx~?a~Le;i@z$Ip9uJ;rH*| z>L%!~o?c!`4lz~NLPn~jNx4<#+pqKUyk~)Ysm+@pV&@vXx`|dHD6yrWdT?htfCG~K z?-jrlVy=U@1T;|enuw=lf!XiP9#W7RLWSJ*8a((?V?K~=$@~`Ur)6R?LJR#*K`1jb zGaW0p&hJSLJ#uvS%p!=*-Q8{hsY30&21pf=%1+#_AV41+95@~*N`z84QhN%X9u%`T zhJp#Fbt+b3H}GP*QrIApJ*wBo%t7F+cd)nDmB&V5@pAr?^~*mM^}|)?l-p;7#jCx3 zqe0oso7Hm>f-Q>i=MjJA;4?Hb(nA^d<>;Fm7|{Q%zyA9!(XDj&oMO8>?=*?s)SUrX z`|RqoL^{q3gR9G}E_pw6a3~m!{Z8%;+N+tPhASV0xBV*1?1#QKfa-rh@`u_2nn0{l z{W!ZGR(UHXUbjNu_YH0?;5z z^{9nNXvX(~H)cwnh=6yU<|Gb^x7ES0-gWgMRR0Kd;T7Ipmk%~9f$JQxREHT`n~xl;=;qi7Cn?zQMHyb_|8`<(Cg@4rEW2$;Fhu2gc>m?XKaHUOs<;D4nx z$rL|(5+s41ss8of>!X2?OSGRsS&&I4Q)FKC<8%FI?m@L_U4+rh%a63pJeXBgpds3y zM;~m3SY9e+s#zJg9(8s&2@mKN4+||@l2c#JI>6a3pK!h0F|x3jvgPv+%B7q25Alnq zQmIrF!rpW{$rPvaFCKP2Qk0;5ZVSfws$c{~*621z-;cNxe=W~8_4vumkwnGt)m9~r zSD;EFNB_a+AUqAEkZM|=)~QE{jlli%t(Ky7h?wQugTP31d1oqJed2S^d9m}H`gH8>;|*@ z+}Q|ITBvCw{XZKH%c!zKz^2r_)IL65W$BKI!F#iz(*@yJzmBGG+6z=|gB9D`z*I%Q zeRUv+1yn7@H<)Qa5S5F^DyUBuW1lT7Q{EcMPF@tSiBK2orMIaZ`l}FdkP> zP>|7(4VtIBa%Ji=HaK)Cp)gHjV0id0Q{ywx0*B{e9B`rX9qA`0Cu}h*GOZ*3ut z+$%eQbtd8N8Q@`rgY@cyDAN=nbqHsDt7@CxO)mmI^n#M*=+~{HfJRa+6A(brSOUPd z-|&zXzrkMLSKP71ttc`7KG`uXMs=kX5>m||8OG|`4CUh(?J9FnTqZn+ + + + + + + image/svg+xml + + + + + + + NOVA + + + + + + + + diff --git a/minecraft/1.7/src/main/resources/mcmod.info b/minecraft/1.7/src/main/resources/mcmod.info new file mode 100644 index 000000000..404ea8879 --- /dev/null +++ b/minecraft/1.7/src/main/resources/mcmod.info @@ -0,0 +1,21 @@ +{ + "modListVersion": 2, + "modList": [{ + "modid": "nova", + "name": "NOVA", + "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", + "version": "0.0.1", + "mcversion": "1.7.10", + "url": "http://novaapi.net/", + "updateUrl": "", + "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], + "credits": "Created by the NOVA Team.", + "logoFile": "/assets/nova/textures/NOVA.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": true + }] +} diff --git a/minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png new file mode 100644 index 0000000000000000000000000000000000000000..1f42e113ce5dbaa9b1bc62df36b8d523f52b5ae5 GIT binary patch literal 8484 zcmd6NhdY)3|NnhZW^rsn#zDzGl}&MkGD0Xb9UZdw$T}H0M&3roF^(ch65`k^;~>Z0 zd++UtWPR^G|HSX-x*VMAT(A4(^?W`b>%Jo&>uOw~;iLfo;EI+e!Tc8yWz#kMIs#;H|z^?!*8w~h2wX5bc4*^Rx_Z z+Wg9{?<45%xlzRlX^rITGLb<`;$_x}U*KO_ciMWgV&OT8N%ubR!KRE>jD57xH$q2w zqr~54(Y#VW-Fxs8<{9GmJ7<0SILGBFhj#yv#mS_9L8*#ERkC>Ej+|EY$za_{Mj(*; z-r(WQ|MxF<`W{a*J!T4(T7C{hz)4Wt3OAJEr#63@F5(>^Bt`lOTu${vW6GsT0NMni zsE5$YGsw^DT-v7{9(Vs1%#izDoX&o8xhs97cW}^?4w?zfQUGmazM=OHB+<$MJ;ay2 zQEhm9<&t}n0aEgN_)m5Z6?EuV?hI_v@4$;#dk^zYRH?8e>5hS4`duga@`{QISQ6VM zB$1gvt%vvw$Ro3hv0Kdpo&tUjTSWq#9z`)yE|+)7JG4tmv>nE>A_S8ruseWc)pj0ZBnjOj0)NYu- z-b0#B>{*e~L{-0tsiJQb4nwNg6$U<$E#)VqT9N&Udpzk{Wv-lEQ*)yJv3Ar~>c5#) zKTEyL=wpVd^W1;mGS9E2IlOuqh1lbS=o{^0G#d%V|OOn&aSFS;EyA^xgm zL(my7eC8&XziWR~@7C6q7s4~vb+i2E&z~W#DD@br>y*3GRBsdB}B_$0MfsOno}3v+Aqo=jWGzX&6=uaceylR3-omMUUieZ{>hAR4Sg6G^-adQ~p)`SW|HukO%jS+WDOmEc7$xQ}4= zV+n$fu0G5g*nrgD+OBGOhj9moBf6>bx@m4%$4rnRd?VhM9*b3+g5 z1^a7Vp+vVIkfz)g2|D&?PA*p}i1{>2?sD|^Aop~3^1RVNfJ%DTc^x7Z?~TEHQlMzF z3{&1~VHyBF$=s}!f7So#X;k->D_0&tPIb7DBlB-6OrNp?&(l`?rU4j zvLG4I=H6hTY;pd-Yyg2&OMmJ9?l#zxz6=yQyNWwXKrE%}Rd_IYBRymj;~V=5Rd4vU zjS(71&-9Hdu$?ag!qU%RaL%tHwvukMC zi#HCcl|CwLb8!-oN+qh0?iVG0WJON+j(4{&7;y&YRM5;$A_u~w{)G^_R%&@+c>JS% z$o}!EAtBYW-J3^gnw?b7zVpGgZ_g_{l&Jr*bWBg0(lxN8m{(h?$nH>Hx+9X{>A@qW*X_@VVldLjyR3*PCUP<;)x+zTuD9Xu>@Db4TQIw2agE?KaaI)BU^EMg_)atw(1C8|&+_&zG<9o<^Z0 z#5--Ijb!Ly+0H1o}!cv;vYC}kK;ROY>i=}r$X6BoNy~1XBw^AwA4k*+JgFe<#Nkg zS~fA*7UGB;59;_}Z9rvcXz2I11vkrulOUJ;C-Rr?6*XHgJCFTXin3Qz?5Ux?$19no zr2e{Q;@h**ZVJ~gHbU^366dMv%mi$bowGCU7cndL_2ikat(DbG-aHN=Xb%o36b}|J zt&&lSW-gH8d-;Jh`cWaCt;Nm6OHZ%o7I2Qkm|L#z<9GLy-8xrDdXPVny#d||VEvWn zh=FOETX?WwDb}B?j1yWccfKIH#OZ)W;z)UUInQoHMY8BKcLuoC_6;1w99391tskWR z4X;KFxCTlW#3`g9Ai%Y(_u$qn!P z8FTX2!XfvN3>24;+WpEb2zyu8-50=sxec6@vS7*VT{@gB<2+eO*Ju&@w(|L0Q@9a# z$cyDWz`5w{tSPKM%f|`63uWbGlX{SOdC;(PK&Xer*sxST%yt>@rF^hGTUZqYV@wt^ z8(!VDc^R>D!apIG8+K{uF7Tfm#^q~4K}}g2dbi`Vnw@fuoP=tGaAxjIn+rEP`;C7E zq&9nUgnZVoLevclhXBjhkjmGOVDrTuE8Q=F=~Z5EmKn$NrcG;6RgGUE{}n?Mvl ze6Vw%xHD<5M^Q8QuNiWxf6<}7e@)UXc^bgkc&17k+mcODUyU5JQ~-$zGM43J2Jxg? zeuI^Gw9i6ddS$IizIvO$#dw6sX5^Wc)0I!bHe~dyWWDcBT0S}F27-7qA0eE`q{OES z6<)P*vu5V1SYMPq6+NW3jTM>1xRu)oK?|uuX0OEs(kRk3u7&tz3;mB5A-ze9Nl!WW|+D?*GRzSaJZgX@$>set*1KacMBoA!XJ+}%Lmn=@&Tp{XSm3My2IYy z-eUk}rbn^leoO#Sh!VKCnMw=u-B?GMfnaZgs+Zo@LbRyg-@k5wvr9%51`2IDi{yW- zuRkZ+lfCx$e}s7dC$U!;=lf#(CttD2XKgH_U!Rpe3!J~%76x8!3?v&EOSFTI_tnvtl#O^7JNbw1oX~IX zHE^I02G;uRd%7#*!oq(V`7fyfiv>=x$xj$nDlKgt3=I=IlbLk=a7Tf2?agcwmZ!t^ zYFu>=Y&TUSf|b{%mFS;31m6O83C@gMTpc|*P#-J z6MXyRz8{VwJmqY%KFA;!EfX)S{|T^EzuZ|_-t6dR^0$%Dlcq)@Id0`8Uky#eTTFdw zhmCnfb}T0(^%keBd)B?KUrX)~Xkk1Nmi_f2wpsPu2|NkIA@$Yby7B|Q0uv!U+@t`w z|I%)G2YG0wAhv_p2@1=@y$cKSvGKl%rtjtdt^ojZI6o6%g-DF?;CN=i2{J~G8NGNm zqImoE;H^|Pwm!9&_Zc(;yF@7;v;G<{{JN8Zh1=q;&Sk^lGpucfw)s!&DSKfY927s5 z9jNDqjrzv*`%QgeFRTH;!3l@WonhL!D@GNvZEwa6Ymaa8Yp^Iq=`fqTl3((hZqB** z`U@K0-t@dMkZ0e2wm?LcDgJ;`DmJICTuP{wn3YI`@i%~~zxC{llhP+EfXMC<hOF)aghQNws+}(u>23OQlzn*F&n@76>)KsXo60{i76d3;AV}8{oVJXvZCn$Ehft ze!-U~2C&t z8W%=)7M{)3-elwhC9EK--UwWsa%UXxpbeJPf+#)b=Qv#-SYtQWzzABH9ZKG6r*!PC zpaM`&y3*RnblnCUl5~kg5OV`9%%A#THt1PI&L0q&t5Zau@sH^V8h~|V9iR2X9eDqe z)e072d&Um%X6nw+&G8?|+F#03`xBXnakgj(sypZ)>HFb?&&rD3+G4qbavOaAH790O zcTUdyeOReUq&cXz76|XGF7L+W{K0MFVC`{Y|liFfRex)iRJD3&4>i>eO)i}(u%&yN2$PiIHJac2tj9m2q zI4=oMO8qGG)oxO$SsgZtkdZbPEdkFW%#6UQ7DO)#ps@|E;c9I$3ty0rblwT1UPwmc<>mIv0-X5U@J0-?B(zL>Rmc)(0;4)M3XK zW#S~p2{0#)w%9ZG7X=CZI=;F$;)p1-knS-x6XM@X?9E~M*nD>0zlE3C8ZAK3$T&j;ar;ZSXnV9P=S(m>O#%8ciu#7J^C`ko4J}*jWA zHfZSO8qB9Ow1i{TFGTM%U`DJS=JtzWDyei3dG{+<>7J`|soS=@=m&mzDjIttswbX8 z3ryaSz0RQTkTLbq;e~bklKXv7-(1^Q(DhbmW+&0d{%8e@`?om?Ypb=~8j1OI^d?$a z3Mi`Mw~*kfnc*)BJsjtvcyn+#p&wopq$0}Y-?iFcbMZDJ!XGaOW6gM2m*Rf0j-@mW>8aAfPYtwC)>$cy}M|YFL zB5EWyIhgShR4Zq0e-GA-X0Gv+zlUyB|01%9o0V(-XtXRz``4F>@qg}U?7iX_5&frh zWA_CkStXQu(j{rhZCrN8tL=wGge`(sx-uvyB|Ze*Fwu<>KKWT6BS7vWs@EK|#~N$4J4crVy+OFP1Ik z5-qDXIq#VI$g_gD-MTVTVsDjsH*)!9(?YGH(|B2XbT@9rg6e~%r2EM3?yi`D^>M(t z4-h1pL|N~)tFE2$`!T) z$8bUewWWK!JbrF(Z>Pja9RYT%F-qkii=VZ=*fRlUKcG9VmQTcf&CkzgK_3u83}dAF zGs9bF?o!-$UV@VHuE`b80VzR_?pE9O>FQr8-yJ z7EU^kiuU=9IN+GYXOmtv?H!pq2r7&khhfY&H&nP9rJ61{j<`8aR1wjz?d#X0(=6D5 z#-p<>G1_xPlb!Kmxh*LU=VA!Ur zsiE5Po3`b>Fy`IQE|ppq0F>E(S5hZj4Vi7aLHTX$Iz>%*g^beNjq_&WsgA~&5g-5B zb<>E$-@h~YGB~iH4SeIeIFK_nFUXhDd5I`G6}CNVQR9t=#vf>{q~z&k1*L#Po6xIp z!?rT^vSKs&%zBo6_0`~T*FKKMs4vmogj5+gDda|*_7{$K@7_7-Uoj?ukis0@+6Gjv zi>b1&utbS_d3!rw-c5Dg>;Q4TKks3tgQH_DGy33+GoEF>`Ic6$N~9iJH?2Yb`_bWU zsY(igbOC19OZ@gzaK8Vw_IIEcdZd`$LiAhH?jhBOa;{%{86y{lZGdqp+(Q^;z2(lS z{7(2b_#eoVxOeW2uC!i`PJE1Z&S3uJ%S^753KCUXTADb;?ndPbGzo+v>f;fuwwI;P z1Txn8hvI@wE89#@zPc_4bz$KvmX!+WhIkM-;Uq=?KYToz|7Bf_$=-T(b(NhegqL>A z|0&b0Q;H*xHFH$`Pj=FSHS`2^U?fy1MQ|Z7c z2UhCQp!$mAU4KS&P7YV;gHNf){NOT`;4(Dfs&6oelN{lp_csllDR&b>R|nu&qS00N zg5l|DOECYV1zJvqnEJf9xw*;vtCFZ(7|ht(Mo*v=_Zf~8>EPFQL0=M%=`LC%)Z1&f zgG+*W(%~hbzio<1_>|APFxrv7S{lrU+~O_X6`EB{Q_b2?_Dw`YMCAHU#b|Nu>}!LZH?W(mC(7Qh$P}&eW+agL4EC`F^2p}cmww0V$C@I6O=SY#_B;>y?&0K?j8Kh#09{s=k0qlSZDR}6=i?DbSv#u1$CvYaX9aIrUH<*JQV~)wuK7`xhvbyq*uG^g`p+9YXtzr04 zH=;Z>Ie9vScNlSIA}YH6Z$T2o5 zc4+fge}8;KQ3U&}ur->^%0fIP<^Hxm=>vg4&{Om6{0qTL0*#wvr57e(zTpNavw)|# z7uX<^-WBu?d!dI=t53of*(~3BCl!3Tmv+_-6_kL%kr#uee2a^R=Md25%f5;5WQKCL z5_e{PyzJD7Y+rkmSvQ*TFxNCkxle%=G!E+dPpWCIelOx~?a~Le;i@z$Ip9uJ;rH*| z>L%!~o?c!`4lz~NLPn~jNx4<#+pqKUyk~)Ysm+@pV&@vXx`|dHD6yrWdT?htfCG~K z?-jrlVy=U@1T;|enuw=lf!XiP9#W7RLWSJ*8a((?V?K~=$@~`Ur)6R?LJR#*K`1jb zGaW0p&hJSLJ#uvS%p!=*-Q8{hsY30&21pf=%1+#_AV41+95@~*N`z84QhN%X9u%`T zhJp#Fbt+b3H}GP*QrIApJ*wBo%t7F+cd)nDmB&V5@pAr?^~*mM^}|)?l-p;7#jCx3 zqe0oso7Hm>f-Q>i=MjJA;4?Hb(nA^d<>;Fm7|{Q%zyA9!(XDj&oMO8>?=*?s)SUrX z`|RqoL^{q3gR9G}E_pw6a3~m!{Z8%;+N+tPhASV0xBV*1?1#QKfa-rh@`u_2nn0{l z{W!ZGR(UHXUbjNu_YH0?;5z z^{9nNXvX(~H)cwnh=6yU<|Gb^x7ES0-gWgMRR0Kd;T7Ipmk%~9f$JQxREHT`n~xl;=;qi7Cn?zQMHyb_|8`<(Cg@4rEW2$;Fhu2gc>m?XKaHUOs<;D4nx z$rL|(5+s41ss8of>!X2?OSGRsS&&I4Q)FKC<8%FI?m@L_U4+rh%a63pJeXBgpds3y zM;~m3SY9e+s#zJg9(8s&2@mKN4+||@l2c#JI>6a3pK!h0F|x3jvgPv+%B7q25Alnq zQmIrF!rpW{$rPvaFCKP2Qk0;5ZVSfws$c{~*621z-;cNxe=W~8_4vumkwnGt)m9~r zSD;EFNB_a+AUqAEkZM|=)~QE{jlli%t(Ky7h?wQugTP31d1oqJed2S^d9m}H`gH8>;|*@ z+}Q|ITBvCw{XZKH%c!zKz^2r_)IL65W$BKI!F#iz(*@yJzmBGG+6z=|gB9D`z*I%Q zeRUv+1yn7@H<)Qa5S5F^DyUBuW1lT7Q{EcMPF@tSiBK2orMIaZ`l}FdkP> zP>|7(4VtIBa%Ji=HaK)Cp)gHjV0id0Q{ywx0*B{e9B`rX9qA`0Cu}h*GOZ*3ut z+$%eQbtd8N8Q@`rgY@cyDAN=nbqHsDt7@CxO)mmI^n#M*=+~{HfJRa+6A(brSOUPd z-|&zXzrkMLSKP71ttc`7KG`uXMs=kX5>m||8OG|`4CUh(?J9FnTqZn+ + + + + + + image/svg+xml + + + + + + + NOVA + + + + + + + + diff --git a/minecraft/1.8/src/main/resources/mcmod.info b/minecraft/1.8/src/main/resources/mcmod.info new file mode 100644 index 000000000..21979da16 --- /dev/null +++ b/minecraft/1.8/src/main/resources/mcmod.info @@ -0,0 +1,21 @@ +{ + "modListVersion": 2, + "modList": [{ + "modid": "nova", + "name": "NOVA", + "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", + "version": "0.0.1", + "mcversion": "1.8", + "url": "http://novaapi.net/", + "updateUrl": "", + "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], + "credits": "Created by the NOVA Team.", + "logoFile": "/assets/nova/textures/NOVA.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": true + }] +} From 6aff453b4636263717f3d2f16c438c605b3c8481 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 20 Dec 2016 18:18:43 +0100 Subject: [PATCH 08/61] Rendering fixes --- .../wrapper/particle/backward/BWParticle.java | 2 - .../v1_11/wrapper/render/FWEmptyModel.java | 11 +++- .../wrapper/render/FWSmartBlockModel.java | 56 ++++++------------- .../wrapper/render/FWSmartItemModel.java | 29 +++++----- .../v1_11/wrapper/render/FWSmartModel.java | 5 -- 5 files changed, 40 insertions(+), 63 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java index 55e651a6c..a556f936e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java @@ -32,7 +32,6 @@ import net.minecraft.client.particle.ParticleDigging; import net.minecraft.client.particle.ParticleDragonBreath; import net.minecraft.client.particle.ParticleDrip; -import net.minecraft.client.particle.ParticleEmitter; import net.minecraft.client.particle.ParticleEnchantmentTable; import net.minecraft.client.particle.ParticleEndRod; import net.minecraft.client.particle.ParticleExplosion; @@ -43,7 +42,6 @@ import net.minecraft.client.particle.ParticleFlame; import net.minecraft.client.particle.ParticleFootStep; import net.minecraft.client.particle.ParticleHeart; -import net.minecraft.client.particle.ParticleItemPickup; import net.minecraft.client.particle.ParticleLava; import net.minecraft.client.particle.ParticleMobAppearance; import net.minecraft.client.particle.ParticleNote; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java index 491f70602..f61e7e79d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java @@ -22,13 +22,13 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.item.ItemStack; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.EnumFacing; import java.util.Collections; import java.util.List; -import net.minecraft.client.renderer.block.model.ItemOverrideList; /** * Generates a smart model based on a NOVA Model @@ -36,6 +36,11 @@ */ public class FWEmptyModel extends FWSmartModel implements IBakedModel { + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + return Collections.emptyList(); + } + @Override public TextureAtlasSprite getParticleTexture() { return null; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java index e535e7eb5..04d6c87f6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java @@ -22,11 +22,13 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; -import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import nova.core.block.Block; import nova.core.component.renderer.ItemRenderer; import nova.core.component.renderer.StaticRenderer; @@ -34,10 +36,9 @@ import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; import nova.internal.core.Game; +import org.lwjgl.util.vector.Vector3f; import java.util.List; -import net.minecraft.client.renderer.block.model.ItemOverrideList; -import org.lwjgl.util.vector.Vector3f; /** * Generates a smart model based on a NOVA Model @@ -63,47 +64,22 @@ public FWSmartBlockModel(Block block, boolean isDummy) { ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); // Ground, Fixed } - //Block rendering - public IBakedModel handleBlockState(IBlockState state) { - FWBlock block = (FWBlock) state.getBlock(); - - Block blockInstance = block.getBlockInstance(block.lastExtendedWorld, Game.natives().toNova(block.lastExtendedStatePos)); - - if (blockInstance.components.has(StaticRenderer.class)) { - return new FWSmartBlockModel(blockInstance, false); - } - - return new FWEmptyModel(); - } - - //Itemblock rendering - public IBakedModel handleItemState(ItemStack stack) { - ItemBlock item = Game.natives().toNova(stack); - ItemRenderer renderer = - item.components.has(ItemRenderer.class) ? item.components.get(ItemRenderer.class) : block.components.has(ItemRenderer.class) ? block.components.get(ItemRenderer.class) : null; - - if (renderer != null) { - return new FWSmartBlockModel(block, true); + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + BWModel blockModel = new BWModel(); + blockModel.matrix.translate(0.5, 0.5, 0.5); + + if (isItem) { + ItemRenderer renderer = block.components.get(ItemRenderer.class); + renderer.onRender.accept(blockModel); + } else { + StaticRenderer renderer = block.components.get(StaticRenderer.class); + renderer.onRender.accept(blockModel); } - return new FWEmptyModel(); + return modelToQuads(blockModel); } -// public List getGeneralQuads() { -// BWModel blockModel = new BWModel(); -// blockModel.matrix.translate(0.5, 0.5, 0.5); -// -// if (isItem) { -// ItemRenderer renderer = block.components.get(ItemRenderer.class); -// renderer.onRender.accept(blockModel); -// } else { -// StaticRenderer renderer = block.components.get(StaticRenderer.class); -// renderer.onRender.accept(blockModel); -// } -// -// return modelToQuads(blockModel); -// } - @Override public TextureAtlasSprite getParticleTexture() { /* diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java index bc058802a..ad6410caa 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java @@ -20,21 +20,23 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import nova.core.component.renderer.ItemRenderer; import nova.core.item.Item; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; import nova.internal.core.Game; +import org.lwjgl.util.vector.Vector3f; import java.util.Collections; import java.util.List; -import net.minecraft.client.renderer.block.model.*; -import org.lwjgl.util.vector.Vector3f; /** * Generates a smart model based on a NOVA Model @@ -67,17 +69,18 @@ public IBakedModel handleItemState(ItemStack stack) { return this; } -// public List getGeneralQuads() { -// if (item.components.has(ItemRenderer.class)) { -// BWModel model = new BWModel(); -// ItemRenderer renderer = item.components.get(ItemRenderer.class); -// model.matrix.translate(0.5, 0.5, 0.5); -// renderer.onRender.accept(model); -// return modelToQuads(model); -// } -// -// return Collections.emptyList(); -// } + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + if (item.components.has(ItemRenderer.class)) { + BWModel model = new BWModel(); + ItemRenderer renderer = item.components.get(ItemRenderer.class); + model.matrix.translate(0.5, 0.5, 0.5); + renderer.onRender.accept(model); + return modelToQuads(model); + } + + return Collections.emptyList(); + } @Override public TextureAtlasSprite getParticleTexture() { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java index a730fa566..9df1f71af 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java @@ -101,11 +101,6 @@ public VertexFormat getFormat() { return format; } - @Override - public List getQuads(IBlockState state, EnumFacing side, long rand) { - return Collections.emptyList(); - } - @Override public boolean isAmbientOcclusion() { return true; From 419029fd3ce19cf950acac20f46ca43538c4c3cd Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 20 Dec 2016 18:33:38 +0100 Subject: [PATCH 09/61] Scale particles --- .../particle/forward/MCParticleTransform.java | 12 +++++++++++- .../mc/forge/v1_11/wrapper/render/BWModel.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java index f52e7e32b..86736617c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java @@ -24,7 +24,6 @@ public class MCParticleTransform extends EntityTransform { public MCParticleTransform(Particle wrapper) { this.wrapper = wrapper; this.setPivot(Vector3D.ZERO); - this.setScale(Vector3DUtil.ONE); } @Override @@ -47,6 +46,17 @@ public void setPosition(Vector3D position) { wrapper.setPosition(position.getX(), position.getY(), position.getZ()); } + @Override + public void setScale(Vector3D scale) { + // MC Particles only have one scale. + wrapper.particleScale = (float) ((scale.getX() + scale.getY() + scale.getZ()) / 3); + } + + @Override + public Vector3D scale() { + return new Vector3D(wrapper.particleScale, wrapper.particleScale, wrapper.particleScale); + } + @Override public Rotation rotation() { // TODO: Calculate rotation so that it is always facing the camera. diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java index 8d6f4ef92..0c34ddd8e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java @@ -65,7 +65,7 @@ public void render(Optional entityRenderManager) { MeshModel meshModel = (MeshModel) model; meshModel.faces.forEach(face -> { - // TODO: Figure out if ? + // TODO: See if this works, and possibly fix it // Brightness is defined as: skyLight << 20 | blockLight << 4 if (face.getBrightness() >= 0) { worldRenderer.lightmap((int)(face.getBrightness() * (15 << 20)), (int)(face.getBrightness() * (11 << 4))); From c6c07b1a7188b62ed096a16f972189c91929cb89 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 21 Dec 2016 00:33:35 +0100 Subject: [PATCH 10/61] Use https in mcmod.info --- minecraft/1.11/src/main/resources/mcmod.info | 2 +- minecraft/1.7/src/main/resources/mcmod.info | 2 +- minecraft/1.8/src/main/resources/mcmod.info | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/minecraft/1.11/src/main/resources/mcmod.info b/minecraft/1.11/src/main/resources/mcmod.info index 069e663b7..6b534e351 100644 --- a/minecraft/1.11/src/main/resources/mcmod.info +++ b/minecraft/1.11/src/main/resources/mcmod.info @@ -6,7 +6,7 @@ "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", "version": "0.0.1", "mcversion": "1.11", - "url": "http://novaapi.net/", + "url": "https://novaapi.net/", "updateUrl": "", "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], "credits": "Created by the NOVA Team.\nPorted to Minecraft 1.11 by: ExE Boss.", diff --git a/minecraft/1.7/src/main/resources/mcmod.info b/minecraft/1.7/src/main/resources/mcmod.info index 404ea8879..bf0db8f3a 100644 --- a/minecraft/1.7/src/main/resources/mcmod.info +++ b/minecraft/1.7/src/main/resources/mcmod.info @@ -6,7 +6,7 @@ "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", "version": "0.0.1", "mcversion": "1.7.10", - "url": "http://novaapi.net/", + "url": "https://novaapi.net/", "updateUrl": "", "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], "credits": "Created by the NOVA Team.", diff --git a/minecraft/1.8/src/main/resources/mcmod.info b/minecraft/1.8/src/main/resources/mcmod.info index 21979da16..c54cab9c6 100644 --- a/minecraft/1.8/src/main/resources/mcmod.info +++ b/minecraft/1.8/src/main/resources/mcmod.info @@ -6,7 +6,7 @@ "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", "version": "0.0.1", "mcversion": "1.8", - "url": "http://novaapi.net/", + "url": "https://novaapi.net/", "updateUrl": "", "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], "credits": "Created by the NOVA Team.", From 7e9ab0851274f77a047c00e079bebdf0105e7de6 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 21 Dec 2016 23:19:46 +0100 Subject: [PATCH 11/61] Mods can now be loaded + IDs are now properly namespaced. Other changes: - The instance of ModLoader can now be retrieved by mods to ensure that IDs are properly namespaced. (Forge does this too) - Wrappers were moved to proper packages. - Nova recipe classes are now registered to RecipeSorter, as recommended by Forge. --- .../forge/v1_11/NovaMinecraftPreloader.java | 21 +++- .../forge/v1_11/depmodules/RenderModule.java | 2 +- .../mc/forge/v1_11/launcher/ClientProxy.java | 2 +- .../mc/forge/v1_11/launcher/CommonProxy.java | 9 +- .../forge/v1_11/launcher/NovaMinecraft.java | 24 +---- .../recipes/MinecraftRecipeRegistry.java | 11 +++ .../forge/v1_11/recipes/RecipeConverter.java | 98 ++++++++++--------- .../forge/v1_11/render/NovaResourcePack.java | 4 +- .../mc/forge/v1_11/render/RenderUtility.java | 14 ++- .../v1_11/wrapper/block/BlockConverter.java | 14 ++- .../v1_11/wrapper/block/forward/FWBlock.java | 8 +- .../wrapper/block/forward/FWTileRenderer.java | 2 +- .../entity/forward/FWEntityRenderer.java | 2 +- .../v1_11/wrapper/item/ItemConverter.java | 22 ++++- .../wrapper/item/{ => backward}/BWItem.java | 2 +- .../item/{ => backward}/BWItemFactory.java | 4 +- .../wrapper/item/{ => forward}/FWItem.java | 4 +- .../item/{ => forward}/FWItemBlock.java | 5 +- .../item/{ => forward}/FWNBTTagCompound.java | 2 +- .../{ => backward}/BWClientRenderManager.java | 9 +- .../render/{ => backward}/BWModel.java | 3 +- .../{ => backward}/BWRenderManager.java | 3 +- .../render/{ => forward}/FWEmptyModel.java | 2 +- .../{ => forward}/FWSmartBlockModel.java | 3 +- .../{ => forward}/FWSmartItemModel.java | 3 +- .../render/{ => forward}/FWSmartModel.java | 11 ++- .../java/nova/core/util/registry/Factory.java | 23 ++++- .../nova/internal/core/launch/ModLoader.java | 36 +++++++ 28 files changed, 232 insertions(+), 111 deletions(-) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/{ => backward}/BWItem.java (96%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/{ => backward}/BWItemFactory.java (94%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/{ => forward}/FWItem.java (94%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/{ => forward}/FWItemBlock.java (91%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/{ => forward}/FWNBTTagCompound.java (95%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => backward}/BWClientRenderManager.java (83%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => backward}/BWModel.java (98%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => backward}/BWRenderManager.java (93%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => forward}/FWEmptyModel.java (96%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => forward}/FWSmartBlockModel.java (96%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => forward}/FWSmartItemModel.java (96%) rename minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/{ => forward}/FWSmartModel.java (96%) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java index c0613c5ac..4976f3e9a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java @@ -53,6 +53,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -66,6 +67,7 @@ public class NovaMinecraftPreloader extends DummyModContainer { public static final String version = "0.0.1"; private static final ModMetadata md; public static Set> modClasses; + public static Map, File> modClassToFile; static { md = new ModMetadata(); @@ -209,6 +211,7 @@ public void load(FMLConstructionEvent event) { // Scan mod classes ASMDataTable asmData = event.getASMHarvestedData(); + modClassToFile = new HashMap<>(); modClasses = asmData .getAll(Mod.class.getName()) .stream() @@ -233,7 +236,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta)); + newMods.add(new DummyNovaMod(fakeMeta, mod)); }); //TODO: Use AT ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -273,6 +276,7 @@ public void registerResourcePacks() { } catch (MalformedURLException | URISyntaxException e) { file = new File(fn); //This will probably not work on Windows, but we can at least try } + modClassToFile.put(c, file); if (!addedPacks.contains(fn)) { addedPacks.add(fn); @@ -290,6 +294,7 @@ public void registerResourcePacks() { folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); } + modClassToFile.put(c, folderFile); addedPacks.add(folderLocation); packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); @@ -306,8 +311,20 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class DummyNovaMod extends DummyModContainer { - public DummyNovaMod(ModMetadata meta) { + private final Class mod; + private File source = null; + + public DummyNovaMod(ModMetadata meta, Class mod) { super(meta); + this.mod = mod; + } + + @Override + public File getSource() { + if (this.source == null) { + this.source = NovaMinecraftPreloader.modClassToFile.get(mod); + } + return this.source; } } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java index e450ec8e6..1aec0cd07 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java @@ -21,7 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11.depmodules; import nova.core.render.RenderManager; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWClientRenderManager; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWClientRenderManager; import se.jbee.inject.bind.BinderModule; public class RenderModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java index 040e9ff8f..1bc259112 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java @@ -44,7 +44,7 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.FWParticle; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntityRenderer; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java index c19908bd8..ffd9fe85d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java @@ -30,9 +30,10 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileUpdater; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; import java.util.Set; + import net.minecraft.util.ResourceLocation; /** @@ -41,9 +42,9 @@ public class CommonProxy implements Loadable { @Override public void preInit() { - GameRegistry.registerTileEntity(FWTile.class, "novaTile"); - GameRegistry.registerTileEntity(FWTileUpdater.class, "novaTileUpdater"); - EntityRegistry.registerModEntity(new ResourceLocation("novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true); + GameRegistry.registerTileEntity(FWTile.class, "nova:novaTile"); + GameRegistry.registerTileEntity(FWTileUpdater.class, "nova:novaTileUpdater"); + EntityRegistry.registerModEntity(new ResourceLocation("nova", "novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true); } public void registerResourcePacks(Set> modClasses) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index fff394693..762d33164 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -21,11 +21,9 @@ package nova.core.wrapper.mc.forge.v1_11.launcher; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.DummyModContainer; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.Metadata; -import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -63,9 +61,9 @@ import nova.internal.core.launch.InitializationException; import nova.internal.core.launch.NovaLauncher; -import java.util.ArrayList; -import java.util.Collections; +import java.lang.reflect.Field; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -89,8 +87,6 @@ public class NovaMinecraft { private static ModMetadata modMetadata; private static Set nativeConverters; - private static Set childModMetadata; - private static Set childModContainers; /** * ORDER OF LOADING. @@ -162,10 +158,6 @@ public void preInit(FMLPreInitializationEvent evt) { nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet()); nativeConverters.stream().forEachOrdered(Loadable::preInit); - // TODO: Make child mods section display names of loaded NOVA mods. - childModMetadata = Collections.emptySet();//.stream().filter(l -> l.getClass().isAnnotationPresent(nova.core.loader.Mod.class)) - //.map(l -> ((nova.core.loader.Mod)l.getClass().getDeclaredAnnotation(nova.core.loader.Mod.class))).collect(Collectors.toSet()); - Game.blocks().init(); Game.items().init(); Game.entities().init(); @@ -215,17 +207,6 @@ public void postInit(FMLPostInitializationEvent evt) { proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); launcher.postInit(); - - if (modMetadata.childMods == null) modMetadata.childMods = new ArrayList<>(); - childModMetadata.stream().forEachOrdered((nova.core.loader.Mod m) -> { - ModMetadata forgeMetadata = new ModMetadata(); - forgeMetadata.modId = m.id(); - forgeMetadata.name = m.name(); - forgeMetadata.version = m.version(); - forgeMetadata.description = m.description(); - ModContainer modContainer = new DummyModContainer(forgeMetadata); - modMetadata.childMods.add(modContainer); // So that nova mods are shown alongside Forge mods. - }); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); @@ -242,5 +223,4 @@ public void serverStarting(FMLServerStartingEvent event) { public void serverStopping(FMLServerStoppingEvent event) { Game.events().publish(new ServerEvent.Stop()); } - } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java index d6105160a..2d62ab294 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java @@ -22,6 +22,9 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.oredict.RecipeSorter; +import net.minecraftforge.oredict.RecipeSorter.Category; +import nova.core.item.Item; import nova.core.recipes.RecipeAddedEvent; import nova.core.recipes.RecipeManager; import nova.core.recipes.RecipeRemovedEvent; @@ -72,6 +75,14 @@ public void registerRecipes() { System.out.println("Initialized recipes in " + (System.currentTimeMillis() - startTime) + " ms"); + RecipeSorter.register("nova:shaped", ShapedRecipeBasic.class, Category.SHAPED, "before:forge:shapedore"); + RecipeSorter.register("nova:shaped.oredict", ShapedRecipeOre.class, Category.SHAPED, "after:nova:shaped after:minecraft:shaped before:minecraft:shapeless"); + + RecipeSorter.register("nova:shapeless", ShapelessRecipeBasic.class, Category.SHAPELESS, "after:minecraft:shapeless before:forge:shapelessore"); + RecipeSorter.register("nova:shapeless.oredict", ShapelessRecipeOre.class, Category.SHAPELESS, "after:nova:shapeless after:minecraft:shapeless"); + + RecipeSorter.register("nova:unknown", NovaCraftingRecipe.class, Category.UNKNOWN, ""); + recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java index ed7564aac..2ec0901be 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java @@ -139,20 +139,23 @@ public static IRecipe convert(ShapelessCraftingRecipe recipe) { ItemIngredient[] ingredients = recipe.getIngredients(); int type = getRecipeType(ingredients); - if (type == TYPE_BASIC) { - ItemStack[] items = new ItemStack[ingredients.length]; - for (int i = 0; i < ingredients.length; i++) { - items[i] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + switch (type) { + case TYPE_BASIC: { + ItemStack[] items = new ItemStack[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + } + return new ShapelessRecipeBasic(items, recipe); } - return new ShapelessRecipeBasic(items, recipe); - } else if (type == TYPE_ORE) { - Object[] items = new Object[ingredients.length]; - for (int i = 0; i < ingredients.length; i++) { - items[i] = getInternal(ingredients[i]); + case TYPE_ORE: { + Object[] items = new Object[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = getInternal(ingredients[i]); + } + return new ShapelessRecipeOre(items, recipe); } - return new ShapelessRecipeOre(items, recipe); - } else { - return new NovaCraftingRecipe(recipe); + default: + return new NovaCraftingRecipe(recipe); } } @@ -165,47 +168,50 @@ public static IRecipe convert(ShapedCraftingRecipe recipe) { int type = getRecipeType(ingredients); // construct recipe - if (type == TYPE_BASIC) { - ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()]; - for (int i = 0; i < ingredients.length; i++) { - basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = wrapSpecific((SpecificItemIngredient) ingredients[i]); - } + switch (type) { + case TYPE_BASIC: { + ItemStack[] basicIngredients = new ItemStack[recipe.getHeight() * recipe.getWidth()]; + for (int i = 0; i < ingredients.length; i++) { + basicIngredients[posx[i] + posy[i] * recipe.getWidth()] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + } - return new ShapedRecipeBasic(basicIngredients, recipe); - } else if (type == TYPE_ORE) { - Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()]; - for (int i = 0; i < ingredients.length; i++) { - converted[posx[i] + posy[i] * recipe.getWidth()] = getInternal(ingredients[i]); + return new ShapedRecipeBasic(basicIngredients, recipe); } + case TYPE_ORE: { + Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()]; + for (int i = 0; i < ingredients.length; i++) { + converted[posx[i] + posy[i] * recipe.getWidth()] = getInternal(ingredients[i]); + } - // arguments contents: - // 1) recipe patterns - // 2) characters + ingredients - - int counter = 0; - String[] parts = new String[recipe.getHeight()]; - ArrayList rarguments = new ArrayList(); - for (int i = 0; i < recipe.getHeight(); i++) { - char[] pattern = new char[recipe.getWidth()]; - for (int j = 0; j < recipe.getWidth(); j++) { - int off = i * recipe.getWidth() + j; - if (converted[off] == null) { - pattern[j] = ' '; - } else { - pattern[j] = (char) ('A' + counter); - rarguments.add(pattern[j]); - rarguments.add(converted[off]); - counter++; + // arguments contents: + // 1) recipe patterns + // 2) characters + ingredients + + int counter = 0; + String[] parts = new String[recipe.getHeight()]; + ArrayList rarguments = new ArrayList(); + for (int i = 0; i < recipe.getHeight(); i++) { + char[] pattern = new char[recipe.getWidth()]; + for (int j = 0; j < recipe.getWidth(); j++) { + int off = i * recipe.getWidth() + j; + if (converted[off] == null) { + pattern[j] = ' '; + } else { + pattern[j] = (char) ('A' + counter); + rarguments.add(pattern[j]); + rarguments.add(converted[off]); + counter++; + } } + parts[i] = new String(pattern); } - parts[i] = new String(pattern); - } - rarguments.addAll(0, Arrays.asList(parts)); + rarguments.addAll(0, Arrays.asList(parts)); - return new ShapedRecipeOre(rarguments.toArray(), recipe); - } else { - return new NovaCraftingRecipe(recipe); + return new ShapedRecipeOre(rarguments.toArray(), recipe); + } + default: + return new NovaCraftingRecipe(recipe); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java index 6793348bb..504e4559f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java @@ -37,8 +37,8 @@ public class NovaResourcePack extends FileResourcePack { private final String modid; private final String[] domains; - public NovaResourcePack(File p_i1290_1_, String modid, String[] domains) { - super(p_i1290_1_); + public NovaResourcePack(File file, String modid, String[] domains) { + super(file); this.modid = modid; this.domains = domains; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index b47c6c7ee..a13f726af 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -51,10 +51,10 @@ import nova.core.render.texture.ItemTexture; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItem; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWEmptyModel; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWSmartBlockModel; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.FWSmartItemModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWEmptyModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWSmartBlockModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWSmartItemModel; import nova.internal.core.Game; import org.lwjgl.opengl.GL11; @@ -160,6 +160,12 @@ public static void enableLightmap() { OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } + public TextureAtlasSprite getTexture(Optional texture) { + if (!texture.isPresent()) + return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); + return getTexture(texture.get()); + } + public TextureAtlasSprite getTexture(Texture texture) { if (textureMap.containsKey(texture)) { return textureMap.get(texture); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java index c60d7821a..e3b47d3f6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -25,6 +25,7 @@ import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.Block; import nova.core.block.BlockFactory; @@ -32,13 +33,15 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.FWItemBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItemBlock; import nova.internal.core.Game; +import nova.internal.core.launch.ModLoader; import java.util.Arrays; import java.util.HashMap; @@ -99,6 +102,7 @@ public net.minecraft.block.Block toNative(BlockFactory blockFactory) { /** * Register all Nova blocks */ + @Override public void preInit() { registerMinecraftToNOVA(); registerNOVAToMinecraft(); @@ -138,8 +142,12 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); FWItemBlock itemBlockWrapper = new FWItemBlock(blockWrapper); blockFactoryMap.put(blockFactory, blockWrapper); - GameRegistry.register(blockWrapper, new ResourceLocation(blockFactory.getID().asString())); - GameRegistry.register(itemBlockWrapper, new ResourceLocation(blockFactory.getID().asString())); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String blockId = blockFactory.getID().asString(); + ResourceLocation id = blockId.contains(":") ? new ResourceLocation(blockId) : new ResourceLocation(modId, blockId); + GameRegistry.register(blockWrapper, id); + GameRegistry.register(itemBlockWrapper, id); NovaMinecraft.proxy.postRegisterBlock(blockWrapper); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java index 0821c3bea..eb15f9ebb 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -307,7 +307,13 @@ public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) @Override public boolean isFullCube(IBlockState state) { - return isNormalCube(state); + Optional blockCollider = dummy.components.getOp(Collider.class); + + if (blockCollider.isPresent()) { + return blockCollider.get().isCube.get(); + } else { + return super.isFullCube(state); + } } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java index a7edf4759..e7f7dad88 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java @@ -28,7 +28,7 @@ import nova.core.block.Block; import nova.core.component.renderer.DynamicRenderer; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java index eb02d4f37..0736fb867 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java @@ -30,7 +30,7 @@ import net.minecraftforge.fml.client.FMLClientHandler; import nova.core.component.renderer.DynamicRenderer; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.BWModel; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; import org.lwjgl.opengl.GL11; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index 095c8125d..9913330d4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -20,11 +20,16 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItemFactory; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWNBTTagCompound; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; import com.google.common.collect.HashBiMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.BlockFactory; import nova.core.component.Category; @@ -34,6 +39,7 @@ import nova.core.item.ItemManager; import nova.core.item.event.ItemIDNotFoundEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; @@ -41,8 +47,10 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import nova.internal.core.launch.ModLoader; import java.util.Arrays; +import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -196,17 +204,25 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } + if (!Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)).equals(itemFactory.getID().asString())) { + System.err.println("ItemConverter: " + net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper).toString() + " != " + itemFactory.getID()); + net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString()); + itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; + } } else { itemWrapper = new FWItem(itemFactory); } MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); - map.put(itemFactory, minecraftItemMapping); + map.forcePut(itemFactory, minecraftItemMapping); // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - GameRegistry.register(itemWrapper, new ResourceLocation(itemFactory.getID().asString())); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String itemId = itemFactory.getID().asString(); + GameRegistry.register(itemWrapper, itemId.contains(":") ? new ResourceLocation(itemId) : new ResourceLocation(modId, itemId)); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -327,7 +343,7 @@ public String toString() { if (item.getHasSubtypes()) { return net.minecraft.item.Item.REGISTRY.getNameForObject(item) + ":" + meta; } else { - return net.minecraft.item.Item.REGISTRY.getNameForObject(item).toString(); + return Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(item)); } } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java index 16bbb021f..482bed308 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java index b2fa60ed3..af064ac77 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/BWItemFactory.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java @@ -18,13 +18,15 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; import net.minecraft.nbt.NBTTagCompound; import nova.core.component.misc.FactoryProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; +import nova.core.util.id.Identifier; +import nova.core.util.id.StringIdentifier; import nova.internal.core.Game; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java index 1f7fc126e..05d3474ac 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -31,6 +31,8 @@ import java.util.List; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; + /** * @author Calclavia */ diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java index 3721b3513..a81da8951 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWItemBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -29,8 +29,11 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; import java.util.List; + import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; /** * @author Calclavia diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java index 81d1f25f2..133273097 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/FWNBTTagCompound.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; import net.minecraft.nbt.NBTTagCompound; import nova.core.item.Item; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java similarity index 83% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java index ba2409e15..f59c6bb00 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWClientRenderManager.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java @@ -18,19 +18,22 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import nova.core.render.RenderException; import nova.core.render.texture.Texture; import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; +import org.apache.logging.log4j.Level; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; + import java.util.Iterator; /** @@ -55,7 +58,9 @@ public Vector2D getDimension(Texture texture) { } } } catch (Exception e) { - throw new RenderException("Couldn't load texture " + texture.getPath(), e); + FMLLog.log("NOVA", Level.ERROR, new RenderException("Couldn't load texture " + texture.getPath(), e), + !texture.getResource().toLowerCase().equals(texture.getResource()) ? + "Minecraft doesn’t support textures with uppercase characters" : ""); } return new Vector2D(16, 16); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java index 0c34ddd8e..3a31a6ddf 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.Tessellator; @@ -40,7 +40,6 @@ import java.util.BitSet; import java.util.Optional; - /** * BWModel for dynamic rendering * @author Calclavia diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java index 5196d6a8d..c153ec597 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/BWRenderManager.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java @@ -18,12 +18,11 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; import net.minecraft.util.ResourceLocation; import nova.core.render.RenderManager; import nova.core.render.texture.Texture; -import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; public class BWRenderManager extends RenderManager { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java index f61e7e79d..9c9d47e54 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWEmptyModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java index 04d6c87f6..a146a5475 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartBlockModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java @@ -18,8 +18,9 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java index ad6410caa..5b3393209 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartItemModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java @@ -18,8 +18,9 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java rename to minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java index 9df1f71af..49ecfaa8d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/FWSmartModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java @@ -18,9 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render; +package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; import com.google.common.primitives.Ints; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -36,9 +40,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.client.renderer.block.model.ItemOverrideList; /** * Generates a smart model based on a NOVA Model @@ -80,7 +81,7 @@ protected List modelToQuads(Model modelIn) { face -> { List vertexData = face.vertices .stream() - .map(v -> vertexToInts(v, RenderUtility.instance.getTexture(face.texture.get()))) + .map(v -> vertexToInts(v, RenderUtility.instance.getTexture(face.texture))) .collect(Collectors.toList()); int[] data = Ints.concat(vertexData.toArray(new int[][] {})); diff --git a/src/main/java/nova/core/util/registry/Factory.java b/src/main/java/nova/core/util/registry/Factory.java index 7ce169d1e..c1e019b41 100644 --- a/src/main/java/nova/core/util/registry/Factory.java +++ b/src/main/java/nova/core/util/registry/Factory.java @@ -21,7 +21,11 @@ package nova.core.util.registry; import nova.core.util.Identifiable; +import nova.core.loader.Mod; +import nova.internal.core.Game; +import nova.internal.core.launch.ModLoader; +import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; @@ -51,7 +55,7 @@ public abstract class Factory, T extends Identifiable> i * @param processor The processor function */ public Factory(String id, Supplier constructor, Function processor) { - this.id = id; + this.id = addPrefix(id); this.constructor = constructor; this.processor = processor; } @@ -81,4 +85,21 @@ public T build() { public String getID() { return id; } + + private static String addPrefix(String id) { + int prefixEnd = id.lastIndexOf(':'); + String oldPrefix = prefixEnd < 0 ? "" : id.substring(0, prefixEnd); + String newPrefix = null; + Optional mod = ModLoader.instance().activeMod(); + + if (mod.isPresent()) { + newPrefix = mod.get().id(); + } + + if (newPrefix != null && !oldPrefix.startsWith(newPrefix)) { + id = newPrefix + ':' + id; + } + + return id; + } } diff --git a/src/main/java/nova/internal/core/launch/ModLoader.java b/src/main/java/nova/internal/core/launch/ModLoader.java index c361e86a6..286e3f58e 100755 --- a/src/main/java/nova/internal/core/launch/ModLoader.java +++ b/src/main/java/nova/internal/core/launch/ModLoader.java @@ -44,6 +44,8 @@ */ public class ModLoader implements Loadable { + private static ModLoader instance; + protected final DependencyInjectionEntryPoint diep; /** @@ -66,9 +68,20 @@ public class ModLoader implements Loadable { */ protected Map mods; + /** + * Holds the annotations of mod instances + */ + protected Map modAnnotations; + protected List orderedMods; + /** + * The mod that is currently being pre-initialized, initialized or post-initialized + */ + protected Optional activeMod = Optional.empty(); + public ModLoader(Class annotationType, DependencyInjectionEntryPoint diep, Set> modClasses) { + instance = this; this.diep = diep; this.annotationType = annotationType; @@ -121,6 +134,7 @@ public T makeObjectWithDep(Class classToConstruct) throws InstantiationEx public void load() { mods = new HashMap<>(); + modAnnotations = new HashMap<>(); /** * Instantiate Java mods @@ -179,6 +193,8 @@ public void load() { ) ); + modAnnotations.putAll(mods.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey))); + orderedMods = mods.values() .stream() .filter(mod -> mod.getClass().isAssignableFrom(Loadable.class)) @@ -190,36 +206,46 @@ public void load() { public void preInit() { orderedMods.stream().forEachOrdered(mod -> { try { + activeMod = Optional.of(modAnnotations.get(mod)); mod.preInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during pre initialization phase", t); throw new InitializationException(t); } }); + activeMod = Optional.empty(); } @Override public void init() { orderedMods.stream().forEachOrdered(mod -> { try { + activeMod = Optional.of(modAnnotations.get(mod)); mod.init(); } catch (Throwable t) { Game.logger().error("Critical error caught during initialization phase", t); throw new InitializationException(t); } }); + activeMod = Optional.empty(); } @Override public void postInit() { orderedMods.stream().forEachOrdered(mod -> { try { + activeMod = Optional.of(modAnnotations.get(mod)); mod.postInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during post initialization phase", t); throw new InitializationException(t); } }); + activeMod = Optional.empty(); + } + + public Optional activeMod() { + return activeMod; } public Set getLoadedMods() { @@ -237,4 +263,14 @@ public Map> getModClasses() { public Map> getScalaClassesMap() { return new HashMap<>(scalaClasses); } + + /** + * Returns the mod loader. + * + * @param The mod annotation, should be {@link nova.core.loader.Mod}. + * @return The mod loader (if it exists). + */ + public static ModLoader instance() { + return (ModLoader) instance; + } } From 8db3e956536b7b258a1e0530fb2655b215bc4139 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 22 Dec 2016 00:54:57 +0100 Subject: [PATCH 12/61] Backported fixes to 1.7 and 1.8 1.7 and 1.8 work now --- .../v1_11/wrapper/block/BlockConverter.java | 2 +- .../v1_11/wrapper/item/ItemConverter.java | 6 ++-- .../wrapper/item/forward/FWItemBlock.java | 10 +++--- .../mc/forge/v17/NovaMinecraftPreloader.java | 21 ++++++++++-- .../v17/wrapper/block/BlockConverter.java | 31 ++++++++++++++++- .../forge/v17/wrapper/item/ItemConverter.java | 34 +++++++++++++++++-- .../mc/forge/v18/NovaMinecraftPreloader.java | 21 ++++++++++-- .../v18/wrapper/block/BlockConverter.java | 33 +++++++++++++++++- .../forge/v18/wrapper/item/ItemConverter.java | 34 +++++++++++++++++-- 9 files changed, 172 insertions(+), 20 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java index e3b47d3f6..f987be692 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -144,7 +144,7 @@ private void registerNovaBlock(BlockFactory blockFactory) { blockFactoryMap.put(blockFactory, blockWrapper); Optional activeMod = ModLoader.instance().activeMod(); String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); - String blockId = blockFactory.getID().asString(); + String blockId = blockFactory.getID().asString(); // TODO? ResourceLocation id = blockId.contains(":") ? new ResourceLocation(blockId) : new ResourceLocation(modId, blockId); GameRegistry.register(blockWrapper, id); GameRegistry.register(itemBlockWrapper, id); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index 9913330d4..5742ff29f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -204,8 +204,8 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } - if (!Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)).equals(itemFactory.getID().asString())) { - System.err.println("ItemConverter: " + net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper).toString() + " != " + itemFactory.getID()); + if (!itemFactory.getID().asString().equals(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)))) { + System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString()); itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; } @@ -221,7 +221,7 @@ private void registerNOVAItem(ItemFactory itemFactory) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); Optional activeMod = ModLoader.instance().activeMod(); String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); - String itemId = itemFactory.getID().asString(); + String itemId = itemFactory.getID().asString(); // TODO? GameRegistry.register(itemWrapper, itemId.contains(":") ? new ResourceLocation(itemId) : new ResourceLocation(modId, itemId)); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java index a81da8951..c7eba732e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java @@ -22,25 +22,23 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import nova.core.item.ItemFactory; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; import java.util.List; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; - /** * @author Calclavia */ public class FWItemBlock extends net.minecraft.item.ItemBlock implements ItemWrapperMethods { - public FWItemBlock(net.minecraft.block.Block block) { + public FWItemBlock(FWBlock block) { super(block); } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java index 11e41dcee..27cd702cd 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java @@ -53,6 +53,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -66,6 +67,7 @@ public class NovaMinecraftPreloader extends DummyModContainer { public static final String version = "0.0.1"; private static final ModMetadata md; public static Set> modClasses; + public static Map, File> modClassToFile; static { md = new ModMetadata(); @@ -208,6 +210,7 @@ public void load(FMLConstructionEvent event) { // Scan mod classes ASMDataTable asmData = event.getASMHarvestedData(); + modClassToFile = new HashMap<>(); modClasses = asmData .getAll(Mod.class.getName()) .stream() @@ -232,7 +235,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta)); + newMods.add(new DummyNovaMod(fakeMeta, mod)); }); ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -277,6 +280,7 @@ public void registerResourcePacks() { packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); System.out.println("Registered NOVA jar resource pack: " + fn); } + modClassToFile.put(c, file); } 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(); @@ -288,6 +292,7 @@ public void registerResourcePacks() { folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); } + modClassToFile.put(c, folderFile); addedPacks.add(folderLocation); packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); @@ -304,8 +309,20 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class DummyNovaMod extends DummyModContainer { - public DummyNovaMod(ModMetadata meta) { + private final Class mod; + private File source = null; + + public DummyNovaMod(ModMetadata meta, Class mod) { super(meta); + this.mod = mod; + } + + @Override + public File getSource() { + if (this.source == null) { + this.source = NovaMinecraftPreloader.modClassToFile.get(mod); + } + return this.source; } } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java index 58b2c817a..f5a461622 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java @@ -21,6 +21,8 @@ package nova.core.wrapper.mc.forge.v17.wrapper.block; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; @@ -31,6 +33,7 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v17.util.ModCreativeTab; @@ -38,7 +41,9 @@ import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v17.wrapper.item.FWItemBlock; import nova.internal.core.Game; +import nova.internal.core.launch.ModLoader; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Optional; @@ -136,7 +141,11 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); NovaMinecraft.proxy.registerBlock(blockWrapper); - GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID()); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String blockId = blockFactory.getID(); +// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId); + registerNovaBlock(blockWrapper, blockId.contains(":") ? blockId : modId + ":" + blockId); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -155,4 +164,24 @@ private void registerNovaBlock(BlockFactory blockFactory) { System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); } + + /** + * Prevent forge from prefixing block IDs with "nova:" + */ + private void registerNovaBlock(FWBlock blockWrapper, String blockId) { + try { + Class gameDataClass = GameData.class; + Method getMain = gameDataClass.getDeclaredMethod("getMain"); + Method registerBlock = gameDataClass.getDeclaredMethod("registerBlock", net.minecraft.block.Block.class, String.class, Integer.TYPE); + Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); + getMain.setAccessible(true); + registerBlock.setAccessible(true); + registerItem.setAccessible(true); + GameData gameData = (GameData) getMain.invoke(null); + registerBlock.invoke(gameData, blockWrapper, blockId, -1); + registerItem.invoke(gameData, new FWItemBlock(blockWrapper), blockId, -1); + } catch (ReflectiveOperationException e) { + GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId); + } + } } \ No newline at end of file diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java index 969162193..d8a559cb3 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java @@ -22,6 +22,8 @@ import com.google.common.collect.HashBiMap; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; @@ -33,6 +35,7 @@ import nova.core.item.ItemManager; import nova.core.item.event.ItemIDNotFoundEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft; @@ -40,7 +43,9 @@ import nova.core.wrapper.mc.forge.v17.wrapper.block.BlockConverter; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import nova.internal.core.launch.ModLoader; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -192,17 +197,25 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } + if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) { + System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); + net.minecraft.item.Item newItemWrapper = (net.minecraft.item.Item)net.minecraft.item.Item.itemRegistry.getObject(itemFactory.getID().asString()); + itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; + } } else { itemWrapper = new FWItem(itemFactory); } MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); - map.put(itemFactory, minecraftItemMapping); + map.forcePut(itemFactory, minecraftItemMapping); // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - GameRegistry.registerItem(itemWrapper, itemFactory.getID()); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String itemId = itemFactory.getID(); + GameRegistry.registerItem(itemWrapper, itemId.contains(":") ? itemId : modId + ":" + itemId); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -223,6 +236,23 @@ private void registerNOVAItem(ItemFactory itemFactory) { } } + /** + * Prevent forge from prefixing item IDs with "nova:" + */ + private void registerNovaBlock(FWItem itemWrapper, String blockId) { + try { + Class gameDataClass = GameData.class; + Method getMain = gameDataClass.getDeclaredMethod("getMain"); + Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); + getMain.setAccessible(true); + registerItem.setAccessible(true); + GameData gameData = (GameData) getMain.invoke(null); + registerItem.invoke(gameData, itemWrapper, blockId, -1); + } catch (ReflectiveOperationException e) { + GameRegistry.registerItem(itemWrapper, blockId); + } + } + private void registerMinecraftItemsToNOVA() { Set itemIDs = (Set) net.minecraft.item.Item.itemRegistry.getKeys(); itemIDs.forEach(itemID -> { diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java index 4c1b03064..198f87df7 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java @@ -53,6 +53,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -66,6 +67,7 @@ public class NovaMinecraftPreloader extends DummyModContainer { public static final String version = "0.0.1"; private static final ModMetadata md; public static Set> modClasses; + public static Map, File> modClassToFile; static { md = new ModMetadata(); @@ -209,6 +211,7 @@ public void load(FMLConstructionEvent event) { // Scan mod classes ASMDataTable asmData = event.getASMHarvestedData(); + modClassToFile = new HashMap<>(); modClasses = asmData .getAll(Mod.class.getName()) .stream() @@ -233,7 +236,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta)); + newMods.add(new DummyNovaMod(fakeMeta, mod)); }); //TODO: Use AT ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -279,6 +282,7 @@ public void registerResourcePacks() { packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); System.out.println("Registered NOVA jar resource pack: " + fn); } + modClassToFile.put(c, file); } 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(); @@ -290,6 +294,7 @@ public void registerResourcePacks() { folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); } + modClassToFile.put(c, folderFile); addedPacks.add(folderLocation); packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); @@ -306,8 +311,20 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class DummyNovaMod extends DummyModContainer { - public DummyNovaMod(ModMetadata meta) { + private final Class mod; + private File source = null; + + public DummyNovaMod(ModMetadata meta, Class mod) { super(meta); + this.mod = mod; + } + + @Override + public File getSource() { + if (this.source == null) { + this.source = NovaMinecraftPreloader.modClassToFile.get(mod); + } + return this.source; } } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java index 17514f534..63310d4c3 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java @@ -24,6 +24,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.Block; import nova.core.block.BlockFactory; @@ -31,6 +33,7 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v18.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v18.util.ModCreativeTab; @@ -38,7 +41,9 @@ import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v18.wrapper.item.FWItemBlock; import nova.internal.core.Game; +import nova.internal.core.launch.ModLoader; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Optional; @@ -136,7 +141,11 @@ public boolean canReplace() { private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); - GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID()); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String blockId = blockFactory.getID(); +// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId); + registerNovaBlock(blockWrapper, blockId.contains(":") ? blockId : modId + ":" + blockId); NovaMinecraft.proxy.postRegisterBlock(blockWrapper); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { @@ -156,4 +165,26 @@ private void registerNovaBlock(BlockFactory blockFactory) { System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); } + + /** + * Prevent forge from prefixing block IDs with "nova:" + */ + private void registerNovaBlock(FWBlock blockWrapper, String blockId) { + try { + Class gameDataClass = GameData.class; + Method getMain = gameDataClass.getDeclaredMethod("getMain"); + Method registerBlock = gameDataClass.getDeclaredMethod("registerBlock", net.minecraft.block.Block.class, String.class, Integer.TYPE); + Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); + getMain.setAccessible(true); + registerBlock.setAccessible(true); + registerItem.setAccessible(true); + GameData gameData = (GameData) getMain.invoke(null); + registerBlock.invoke(gameData, blockWrapper, blockId, -1); + FWItemBlock itemWrapper = new FWItemBlock(blockWrapper); + registerItem.invoke(gameData, itemWrapper, blockId, -1); + GameData.getBlockItemMap().put(blockWrapper, itemWrapper); + } catch (ReflectiveOperationException e) { + GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId); + } + } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java index 793bb2fd1..5073cf741 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java @@ -25,6 +25,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.BlockFactory; import nova.core.component.Category; @@ -34,6 +36,7 @@ import nova.core.item.ItemManager; import nova.core.item.event.ItemIDNotFoundEvent; import nova.core.loader.Loadable; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v18.launcher.NovaMinecraft; @@ -41,7 +44,9 @@ import nova.core.wrapper.mc.forge.v18.wrapper.block.BlockConverter; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import nova.internal.core.launch.ModLoader; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -194,17 +199,25 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } + if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) { + System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); + net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString()); + itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; + } } else { itemWrapper = new FWItem(itemFactory); } MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); - map.put(itemFactory, minecraftItemMapping); + map.forcePut(itemFactory, minecraftItemMapping); // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - GameRegistry.registerItem(itemWrapper, itemFactory.getID()); + Optional activeMod = ModLoader.instance().activeMod(); + String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); + String itemId = itemFactory.getID(); + GameRegistry.registerItem(itemWrapper, itemId.contains(":") ? itemId : modId + ":" + itemId); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -225,6 +238,23 @@ private void registerNOVAItem(ItemFactory itemFactory) { } } + /** + * Prevent forge from prefixing item IDs with "nova:" + */ + private void registerNovaBlock(FWItem itemWrapper, String blockId) { + try { + Class gameDataClass = GameData.class; + Method getMain = gameDataClass.getDeclaredMethod("getMain"); + Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); + getMain.setAccessible(true); + registerItem.setAccessible(true); + GameData gameData = (GameData) getMain.invoke(null); + registerItem.invoke(gameData, itemWrapper, blockId, -1); + } catch (ReflectiveOperationException e) { + GameRegistry.registerItem(itemWrapper, blockId); + } + } + private void registerMinecraftItemsToNOVA() { Set itemIDs = (Set) net.minecraft.item.Item.itemRegistry.getKeys(); itemIDs.forEach(itemID -> { From 41b128f2964a8649eec3db7447ad13c409725cc7 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 22 Dec 2016 12:57:56 +0100 Subject: [PATCH 13/61] Rendering fixes + Progress bar TODO: Fix textures on blocks --- .../forge/v1_11/launcher/FMLProgressBar.java | 28 ++++++++ .../forge/v1_11/launcher/NovaMinecraft.java | 20 ++++-- .../mc/forge/v1_11/render/RenderUtility.java | 57 ++++++++-------- .../wrapper/render/backward/BWModel.java | 3 + .../render/forward/FWSmartBlockModel.java | 22 +++++-- .../wrapper/render/forward/FWSmartModel.java | 6 ++ .../nova/internal/core/launch/ModLoader.java | 20 ++++++ .../internal/core/launch/NovaLauncher.java | 10 +-- .../internal/core/launch/ProgressBar.java | 66 +++++++++++++++++++ 9 files changed, 188 insertions(+), 44 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java create mode 100644 src/main/java/nova/internal/core/launch/ProgressBar.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java new file mode 100644 index 000000000..d23e24ace --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraftforge.fml.common.ProgressManager.ProgressBar; + +/** + * Wrapper class for FML progress bar that is shown when Minecraft boots. + * + * @author ExE Boss + */ +public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { + + private final ProgressBar progressBar; + + public FMLProgressBar(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + @Override + public void step(String s) { + if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; + this.progressBar.step(s); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index 762d33164..6abbb964c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -25,6 +25,8 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.Metadata; import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.ProgressManager; +import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; @@ -61,9 +63,7 @@ import nova.internal.core.launch.InitializationException; import nova.internal.core.launch.NovaLauncher; -import java.lang.reflect.Field; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -150,7 +150,9 @@ public void preInit(FMLPreInitializationEvent evt) { e.printStackTrace(); } - launcher.load(); + ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); + launcher.load(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); /** * Instantiate native loaders @@ -164,7 +166,9 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); - launcher.preInit(); + progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); + launcher.preInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -190,9 +194,11 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { + ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(); + launcher.init(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -203,10 +209,12 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { + ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(); + launcher.postInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index a13f726af..1dde208db 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -90,30 +90,32 @@ public class RenderUtility { protected static final FaceBakery FACE_BAKERY = new FaceBakery(); // Ugly D: protected static final ModelBlock MODEL_GENERATED = ModelBlock.deserialize( - "{\"" + - "elements\":[{" + - " \"from\": [0, 0, 0], " + - " \"to\": [16, 16, 16], " + - " \"faces\": {" + - " \"down\": {\"uv\": [0, 0, 16, 16], \"texture\":\"\"}" + - " }}]," + - " \"display\": {\n" + - " \"thirdperson_righthand\": {\n" + - " \"rotation\": [ -90, 0, 0 ],\n" + - " \"translation\": [ 0, 1, -3 ],\n" + - " \"scale\": [ 0.55, 0.55, 0.55 ]\n" + - " },\n" + - " \"firstperson_righthand\": {\n" + - " \"rotation\": [ 0, -135, 25 ],\n" + - " \"translation\": [ 0, 4, 2 ],\n" + - " \"scale\": [ 1.7, 1.7, 1.7 ]\n" + - " },\n" + - " \"firstperson_lefthand\": {\n" + - " \"rotation\": [ 0, 135, 25 ],\n" + - " \"translation\": [ 0, 4, 2 ],\n" + - " \"scale\": [ 1.7, 1.7, 1.7 ]\n" + - " }\n" + - "}}"); + "{" + + " \"elements\":[{\n" + + " \"from\": [0, 0, 0],\n" + + " \"to\": [16, 16, 16],\n" + + " \"faces\": {\n" + + " \"down\": {\"uv\": [0, 0, 16, 16], \"texture\":\"\"}\n" + + " }\n" + + " }],\n" + + " \"display\": {\n" + + " \"thirdperson_righthand\": {\n" + + " \"rotation\": [ -90, 0, 0 ],\n" + + " \"translation\": [ 0, 1, -3 ],\n" + + " \"scale\": [ 0.55, 0.55, 0.55 ]\n" + + " },\n" + + " \"firstperson_righthand\": {\n" + + " \"rotation\": [ 0, -90, 25 ],\n" + + " \"translation\": [ 0, 3.75, 2.3125 ],\n" + + " \"scale\": [ 0.6, 0.6, 0.6 ]\n" + + " },\n" + + " \"firstperson_lefthand\": {\n" + + " \"rotation\": [ 0, 90, -25 ],\n" + + " \"translation\": [ 0, 3.75, 2.3125 ],\n" + + " \"scale\": [ 0.6, 0.6, 0.6 ]\n" + + " }\n" + + " }\n" + + "}"); //NOVA Texture to MC TextureAtlasSprite private final HashMap textureMap = new HashMap<>(); @@ -191,7 +193,10 @@ public void preTextureHook(TextureStitchEvent.Pre event) { public void registerIcon(Texture texture, TextureStitchEvent.Pre event) { String resPath = (texture instanceof BlockTexture ? "blocks" : texture instanceof ItemTexture ? "items" : "entities") + "/" + texture.resource; - textureMap.put(texture, event.getMap().registerSprite(new ResourceLocation(texture.domain, resPath))); + System.out.println(texture + " (" + texture.domain + ':' + resPath + ')'); + TextureAtlasSprite sprite = event.getMap().registerSprite(new ResourceLocation(texture.domain, resPath)); + textureMap.put(texture, sprite); + System.out.println(sprite); } @SubscribeEvent @@ -288,7 +293,7 @@ public TextureAtlasSprite getAtlasSprite(String iconName) { if (item.components.has(ItemRenderer.class)) { ItemRenderer itemRenderer = item.components.get(ItemRenderer.class); if (itemRenderer.texture.isPresent()) { - return RenderUtility.instance.getTexture(itemRenderer.texture.get()); + return RenderUtility.instance.getTexture(itemRenderer.texture); } } return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java index 3a31a6ddf..23341fca9 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java @@ -60,10 +60,12 @@ public void render(Optional entityRenderManager) { */ flatten().forEach( model -> { + System.out.println(model); if (model instanceof MeshModel) { MeshModel meshModel = (MeshModel) model; meshModel.faces.forEach(face -> { + System.out.println(face); // TODO: See if this works, and possibly fix it // Brightness is defined as: skyLight << 20 | blockLight << 4 if (face.getBrightness() >= 0) { @@ -77,6 +79,7 @@ public void render(Optional entityRenderManager) { worldRenderer.normal((int) face.normal.getX(), (int) face.normal.getY(), (int) face.normal.getZ()); + System.out.println(face.texture); if (face.texture.isPresent()) { if (entityRenderManager.isPresent() && face.texture.get() instanceof EntityTexture) { //We're not working on an atlas, so just do... this. diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java index a146a5475..a52a64b1e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java @@ -56,13 +56,21 @@ public FWSmartBlockModel(Block block, boolean isDummy) { this.isItem = isDummy; // Change the default transforms to the default full Block transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(10, -45, 170), // Third Person (Left) - new Vector3f(0, 0.09375f, -0.171875f), new Vector3f(0.375f, 0.375f, 0.375f)), - new ItemTransformVec3f(new Vector3f(10, -45, 170), // Third Person (Right) - new Vector3f(0, 0.09375f, -0.171875f), new Vector3f(0.375f, 0.375f, 0.375f)), - ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, // First Person (Left, Right) - ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, // Head, Gui - ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); // Ground, Fixed + new ItemTransformVec3f(new Vector3f(75, 225, 0), // Third Person (Left) + new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), + new ItemTransformVec3f(new Vector3f(75, 45, 0), // Third Person (Right) + new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), + new ItemTransformVec3f(new Vector3f(0, 225, 0), // First Person (Left) + new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), + new ItemTransformVec3f(new Vector3f(0, 45, 0), // First Person (Right) + new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), + ItemTransformVec3f.DEFAULT, // Head + new ItemTransformVec3f(new Vector3f(30, 225, 0), // Gui + new Vector3f(0, 0, 0), new Vector3f(0.625f, 0.625f, 0.625f)), + new ItemTransformVec3f(new Vector3f(0, 0, 0), // Ground + new Vector3f(0, 0, 0), new Vector3f(0, 0, 0)), + new ItemTransformVec3f(new Vector3f(0, 0, 0), // Fixed + new Vector3f(0, 0, 0), new Vector3f(0, 0, 0))); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java index 49ecfaa8d..1c050f6f0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java @@ -28,6 +28,7 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.EnumFacing; import nova.core.render.model.MeshModel; @@ -53,6 +54,11 @@ public abstract class FWSmartModel implements IBakedModel { public FWSmartModel() { this.format = new VertexFormat(); + + this.format.addElement(DefaultVertexFormats.POSITION_3F); + this.format.addElement(DefaultVertexFormats.COLOR_4UB); + this.format.addElement(DefaultVertexFormats.TEX_2F); + this.format.addElement(DefaultVertexFormats.PADDING_1B); } public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture) { diff --git a/src/main/java/nova/internal/core/launch/ModLoader.java b/src/main/java/nova/internal/core/launch/ModLoader.java index 286e3f58e..45dad9b26 100755 --- a/src/main/java/nova/internal/core/launch/ModLoader.java +++ b/src/main/java/nova/internal/core/launch/ModLoader.java @@ -133,6 +133,10 @@ public T makeObjectWithDep(Class classToConstruct) throws InstantiationEx } public void load() { + this.load(ProgressBar.NULL_PROGRESS_BAR); + } + + public void load(ProgressBar progressBar) { mods = new HashMap<>(); modAnnotations = new HashMap<>(); @@ -144,6 +148,7 @@ public void load() { .collect(Collectors.>, ANNOTATION, Object>toMap(Map.Entry::getKey, entry -> { try { + progressBar.step(entry.getValue()); return makeObjectWithDep(entry.getValue()); } catch (Exception ex) { ex.printStackTrace(); @@ -204,8 +209,13 @@ public void load() { @Override public void preInit() { + this.preInit(ProgressBar.NULL_PROGRESS_BAR); + } + + public void preInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { + progressBar.step(mod.getClass()); activeMod = Optional.of(modAnnotations.get(mod)); mod.preInit(); } catch (Throwable t) { @@ -218,8 +228,13 @@ public void preInit() { @Override public void init() { + this.init(ProgressBar.NULL_PROGRESS_BAR); + } + + public void init(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { + progressBar.step(mod.getClass()); activeMod = Optional.of(modAnnotations.get(mod)); mod.init(); } catch (Throwable t) { @@ -232,8 +247,13 @@ public void init() { @Override public void postInit() { + this.postInit(ProgressBar.NULL_PROGRESS_BAR); + } + + public void postInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { + progressBar.step(mod.getClass()); activeMod = Optional.of(modAnnotations.get(mod)); mod.postInit(); } catch (Throwable t) { diff --git a/src/main/java/nova/internal/core/launch/NovaLauncher.java b/src/main/java/nova/internal/core/launch/NovaLauncher.java index 61b2ef676..e8e1966ac 100644 --- a/src/main/java/nova/internal/core/launch/NovaLauncher.java +++ b/src/main/java/nova/internal/core/launch/NovaLauncher.java @@ -74,6 +74,11 @@ public NovaLauncher(DependencyInjectionEntryPoint diep, Set> modClasses @Override public void load() { super.load(); + } + + @Override + public void load(ProgressBar progressBar) { + super.load(progressBar); TopologicalSort.DirectedGraph modGraph = new TopologicalSort.DirectedGraph<>(); @@ -123,11 +128,6 @@ public Map dependencyToMap(String[] dependencies) { .collect(Collectors.toMap(s -> s[0], s -> s.length > 1 ? s[1] : "")); } - @Override - public void preInit() { - super.preInit(); - } - public Map> getNeededDeps() { if (neededDeps == null) { throw new IllegalStateException("Dependencies have not been generated"); diff --git a/src/main/java/nova/internal/core/launch/ProgressBar.java b/src/main/java/nova/internal/core/launch/ProgressBar.java new file mode 100644 index 000000000..925bf1919 --- /dev/null +++ b/src/main/java/nova/internal/core/launch/ProgressBar.java @@ -0,0 +1,66 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.internal.core.launch; + +import nova.core.loader.Mod; + +/** + * A progress bar used to show mod loading. + * + * The default implementation does nothing. + * It is up to wrappers to implement functionality. + * + * @author ExE Boss + */ +public abstract class ProgressBar { + + /** + * A progress bar implementation that does nothing. + */ + public static final ProgressBar NULL_PROGRESS_BAR = new ProgressBar() { + @Override + public void step(String s) {} + }; + + /** + * Advance one step. + * + * @param message The message to show for the current step. + */ + public abstract void step(String message); + + /** + * Advance one step. + * + * The default implementation is the same as calling: + * {@link #step(java.lang.String) ProgressBar.step(state + ": " + clazz)} + * + * @param state + * @param clazz + */ + public void step(Class clazz) { + step(toStringMod(clazz)); + } + + /** + * Advance one step. + * + * The default implementation is the same as calling: + * {@link #step(java.lang.String) ProgressBar.step(state + ": " + clazz)} + * + * @param state + * @param clazz + */ + public void step(String state, Class clazz) { + step((state == null || state.isEmpty() ? "" : state + ": ") + toStringMod(clazz)); + } + + protected static String toStringMod(Class clazz) { + if (clazz == null) return null; + if (clazz.isAnnotationPresent(Mod.class)) return clazz.getAnnotation(Mod.class).name(); + return clazz.getSimpleName(); + } +} From 390ff355a16dce22aca8fd95237f4207d524bc69 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 22 Dec 2016 13:59:23 +0100 Subject: [PATCH 14/61] Fix Travis build + extra method in ProgressBar --- .../internal/core/launch/ProgressBar.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/nova/internal/core/launch/ProgressBar.java b/src/main/java/nova/internal/core/launch/ProgressBar.java index 925bf1919..1203b48eb 100644 --- a/src/main/java/nova/internal/core/launch/ProgressBar.java +++ b/src/main/java/nova/internal/core/launch/ProgressBar.java @@ -38,8 +38,7 @@ public void step(String s) {} * The default implementation is the same as calling: * {@link #step(java.lang.String) ProgressBar.step(state + ": " + clazz)} * - * @param state - * @param clazz + * @param clazz The mod class */ public void step(Class clazz) { step(toStringMod(clazz)); @@ -49,13 +48,26 @@ public void step(Class clazz) { * Advance one step. * * The default implementation is the same as calling: - * {@link #step(java.lang.String) ProgressBar.step(state + ": " + clazz)} + * {@link #step(java.lang.String) ProgressBar.step(message + ": " + clazz)} + * + * @param message The message to display before {@code clazz} + * @param clazz The mod class + */ + public void step(String message, Class clazz) { + step((message == null || message.isEmpty() ? "" : message + ": ") + toStringMod(clazz)); + } + + /** + * Advance one step. + * + * The default implementation is the same as calling: + * {@link #step(java.lang.String) ProgressBar.step(clazz + ": " + message)} * - * @param state - * @param clazz + * @param message The message to display before {@code clazz} + * @param clazz The mod class */ - public void step(String state, Class clazz) { - step((state == null || state.isEmpty() ? "" : state + ": ") + toStringMod(clazz)); + public void step(Class clazz, String message) { + step(toStringMod(clazz) + (message == null || message.isEmpty() ? "" : ": " + message)); } protected static String toStringMod(Class clazz) { From f14622db995ce9d1981fd9123c5a0ae01d329ed8 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 23 Dec 2016 01:44:32 +0100 Subject: [PATCH 15/61] Moved Factory.addPrefix to Identifiable.addPrefix + Display NOVA version on Main Menu --- .../src/main/resources/fmlbranding.properties | 1 + .../src/main/resources/fmlbranding.properties | 1 + .../src/main/resources/fmlbranding.properties | 1 + .../java/nova/core/util/Identifiable.java | 22 +++++++++++++++++++ .../java/nova/core/util/registry/Factory.java | 19 +--------------- 5 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 minecraft/1.11/src/main/resources/fmlbranding.properties create mode 100644 minecraft/1.7/src/main/resources/fmlbranding.properties create mode 100644 minecraft/1.8/src/main/resources/fmlbranding.properties diff --git a/minecraft/1.11/src/main/resources/fmlbranding.properties b/minecraft/1.11/src/main/resources/fmlbranding.properties new file mode 100644 index 000000000..d0872c237 --- /dev/null +++ b/minecraft/1.11/src/main/resources/fmlbranding.properties @@ -0,0 +1 @@ +fmlbranding=NOVA 0.0.1-SNAPSHOT diff --git a/minecraft/1.7/src/main/resources/fmlbranding.properties b/minecraft/1.7/src/main/resources/fmlbranding.properties new file mode 100644 index 000000000..d0872c237 --- /dev/null +++ b/minecraft/1.7/src/main/resources/fmlbranding.properties @@ -0,0 +1 @@ +fmlbranding=NOVA 0.0.1-SNAPSHOT diff --git a/minecraft/1.8/src/main/resources/fmlbranding.properties b/minecraft/1.8/src/main/resources/fmlbranding.properties new file mode 100644 index 000000000..d0872c237 --- /dev/null +++ b/minecraft/1.8/src/main/resources/fmlbranding.properties @@ -0,0 +1 @@ +fmlbranding=NOVA 0.0.1-SNAPSHOT diff --git a/src/main/java/nova/core/util/Identifiable.java b/src/main/java/nova/core/util/Identifiable.java index e98159e43..e2ffbae9b 100644 --- a/src/main/java/nova/core/util/Identifiable.java +++ b/src/main/java/nova/core/util/Identifiable.java @@ -20,6 +20,11 @@ package nova.core.util; +import nova.core.loader.Mod; +import nova.internal.core.launch.ModLoader; + +import java.util.Optional; + /** * A generic interface signifying that this object is identifiable * by an ID @@ -42,4 +47,21 @@ public interface Identifiable { default boolean sameType(Identifiable other) { return getID().equals(other.getID()); } + + static String addPrefix(String id, boolean force) { + int prefixEnd = id.lastIndexOf(':'); + String oldPrefix = prefixEnd < 0 ? "" : id.substring(0, prefixEnd); + String newPrefix = null; + Optional mod = ModLoader.instance().activeMod(); + + if (mod.isPresent()) { + newPrefix = mod.get().id(); + } + + if (newPrefix != null && (force ? !oldPrefix.startsWith(newPrefix) : oldPrefix.isEmpty())) { + id = newPrefix + ':' + id; + } + + return id; + } } diff --git a/src/main/java/nova/core/util/registry/Factory.java b/src/main/java/nova/core/util/registry/Factory.java index c1e019b41..36e12ebb9 100644 --- a/src/main/java/nova/core/util/registry/Factory.java +++ b/src/main/java/nova/core/util/registry/Factory.java @@ -55,7 +55,7 @@ public abstract class Factory, T extends Identifiable> i * @param processor The processor function */ public Factory(String id, Supplier constructor, Function processor) { - this.id = addPrefix(id); + this.id = Identifiable.addPrefix(id, true); this.constructor = constructor; this.processor = processor; } @@ -85,21 +85,4 @@ public T build() { public String getID() { return id; } - - private static String addPrefix(String id) { - int prefixEnd = id.lastIndexOf(':'); - String oldPrefix = prefixEnd < 0 ? "" : id.substring(0, prefixEnd); - String newPrefix = null; - Optional mod = ModLoader.instance().activeMod(); - - if (mod.isPresent()) { - newPrefix = mod.get().id(); - } - - if (newPrefix != null && !oldPrefix.startsWith(newPrefix)) { - id = newPrefix + ':' + id; - } - - return id; - } } From b70793c78d3d5268a9347b21273510f5649bfcf4 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 25 Dec 2016 01:47:11 +0100 Subject: [PATCH 16/61] Backport ProgressBar functionality to 1.7 and 1.8 --- .../forge/v1_11/launcher/NovaMinecraft.java | 1 + .../mc/forge/v17/launcher/FMLProgressBar.java | 28 +++++++++++++++++++ .../mc/forge/v17/launcher/NovaMinecraft.java | 19 +++++++++---- .../mc/forge/v18/launcher/FMLProgressBar.java | 28 +++++++++++++++++++ .../mc/forge/v18/launcher/NovaMinecraft.java | 20 +++++++++---- 5 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java create mode 100644 minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index 6abbb964c..1aaf06810 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -166,6 +166,7 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); + //Load preInit progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); launcher.preInit(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java new file mode 100644 index 000000000..10de8097b --- /dev/null +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v17.launcher; + +import cpw.mods.fml.common.ProgressManager.ProgressBar; + +/** + * Wrapper class for FML progress bar that is shown when Minecraft boots. + * + * @author ExE Boss + */ +public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { + + private final ProgressBar progressBar; + + public FMLProgressBar(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + @Override + public void step(String s) { + if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; + this.progressBar.step(s); + } +} diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java index 5201d012d..37db3a7ef 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java @@ -22,6 +22,8 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.ProgressManager.ProgressBar; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; @@ -142,7 +144,9 @@ public void preInit(FMLPreInitializationEvent evt) { e.printStackTrace(); } - launcher.load(); + ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size()); + launcher.postInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); /** * Instantiate native loaders @@ -157,7 +161,9 @@ public void preInit(FMLPreInitializationEvent evt) { Game.language().init(); //Load preInit - launcher.preInit(); + progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size()); + launcher.preInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -183,10 +189,11 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { - + ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size()); proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(); + launcher.init(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -197,10 +204,12 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { + ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size()); Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(); + launcher.postInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java new file mode 100644 index 000000000..04e13374c --- /dev/null +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v18.launcher; + +import net.minecraftforge.fml.common.ProgressManager.ProgressBar; + +/** + * Wrapper class for FML progress bar that is shown when Minecraft boots. + * + * @author ExE Boss + */ +public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { + + private final ProgressBar progressBar; + + public FMLProgressBar(ProgressBar progressBar) { + this.progressBar = progressBar; + } + + @Override + public void step(String s) { + if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; + this.progressBar.step(s); + } +} diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java index eb0a0f321..5a8ac7ae1 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java @@ -23,6 +23,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.ProgressManager; +import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; @@ -144,7 +146,9 @@ public void preInit(FMLPreInitializationEvent evt) { e.printStackTrace(); } - launcher.load(); + ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); + launcher.load(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); /** * Instantiate native loaders @@ -158,7 +162,10 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); - launcher.preInit(); + //Load preInit + progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); + launcher.preInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -184,10 +191,11 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { - + ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(); + launcher.init(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -198,10 +206,12 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { + ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(); + launcher.postInit(new FMLProgressBar(progressBar)); + ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); From 655782c130cd1f9c94db2150f7ce08a2d2d15b1c Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 25 Dec 2016 20:38:12 +0100 Subject: [PATCH 17/61] Added ability for wrappers to register their custom FWTileLoaders Reason: NOVA-Energy + Forge Energy compatibilty Also made it so that wrappers are displayed as NOVA-Core-Wrapper-MC{mcversion} in all IDEs. --- .../forge/v1_11/launcher/NovaMinecraft.java | 10 ++++ .../mc/forge/v1_11/render/RenderUtility.java | 3 +- .../block/forward/FWCustomTileLoader.java | 49 +++++++++++++++++ .../wrapper/block/forward/FWTileLoader.java | 53 +++++++++++++++++-- settings.gradle | 4 ++ .../java/nova/core/util/Identifiable.java | 6 +-- .../java/nova/core/util/registry/Factory.java | 2 +- 7 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index 1aaf06810..d121c01ab 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -63,6 +63,7 @@ import nova.internal.core.launch.InitializationException; import nova.internal.core.launch.NovaLauncher; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -87,6 +88,11 @@ public class NovaMinecraft { private static ModMetadata modMetadata; private static Set nativeConverters; + private static Set wrappers = new HashSet<>(); + + public static void registerNovaWrapper(Loadable wrapper) { + wrappers.add(wrapper); + } /** * ORDER OF LOADING. @@ -166,6 +172,8 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); + wrappers.stream().forEachOrdered(Loadable::preInit); + //Load preInit progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); launcher.preInit(new FMLProgressBar(progressBar)); @@ -198,6 +206,7 @@ public void init(FMLInitializationEvent evt) { ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); + wrappers.stream().forEachOrdered(Loadable::init); launcher.init(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); } catch (Exception e) { @@ -214,6 +223,7 @@ public void postInit(FMLPostInitializationEvent evt) { Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); + wrappers.stream().forEachOrdered(Loadable::postInit); launcher.postInit(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); } catch (Exception e) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index 1dde208db..75d33419e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -28,6 +28,7 @@ import net.minecraft.client.renderer.block.model.BlockPartFace; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.ItemModelGenerator; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelRotation; @@ -74,8 +75,6 @@ import static org.lwjgl.opengl.GL11.glEnable; import static org.lwjgl.opengl.GL11.glShadeModel; -import net.minecraft.client.renderer.block.model.ItemOverrideList; - /** * @author Calclavia */ diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java new file mode 100644 index 000000000..47a2dbbdf --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; + +import net.minecraft.nbt.NBTTagCompound; +import nova.core.block.Block; + +/** + * + * @author ExE Boss + */ +public interface FWCustomTileLoader { + + /** + * Load a FWTile. + * + * @param block The Nova Block + * @param data The Minecraft NBTTagCompound + * @return The loaded FWTile or null, if this CustomTileLoader doesn't support this Tile. + */ + FWTile loadTile(Block block, NBTTagCompound data); + + /** + * Load a FWTile. + * + * @param block The Nova Block + * @param blockID The block ID + * @return The loaded FWTile or null, if this CustomTileLoader doesn't support this Tile. + */ + FWTile loadTile(Block block, String blockID); +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index 0d9002636..00b429475 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -27,7 +27,10 @@ import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; import nova.internal.core.Game; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; /** * @author Vic Nightfall @@ -37,14 +40,33 @@ public final class FWTileLoader { private static ComponentInjector injector = new ComponentInjector<>(FWTile.class); private static ComponentInjector updaterInjector = new ComponentInjector<>(FWTileUpdater.class); + private static Set tileLoaders = new HashSet<>(); + private FWTileLoader() { } + /** + * Registers a {@link FWCustomTileLoader custom tile loader}. + * + * Custom tile loaders are evaluated first. + * This class is used as a fallback. + * + * @param predicate The predicate (use {@code block instanceof Annotation}). + * @param customTileLoader The custom tile loader. + */ + public static void registerTileLoader(Predicate predicate, FWCustomTileLoader customTileLoader) { + tileLoaders.add(new TileLoaderEntry(predicate, customTileLoader)); + } + public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); + Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isValid(block)).findFirst(); + FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, data) : null; + if (tile == null) + tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : + injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); return tile; } catch (Exception e) { @@ -55,8 +77,11 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { - String.class }, new Object[] { blockID }); + Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isValid(block)).findFirst(); + FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, blockID) : null; + if (tile == null) + tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : + injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); return tile; } catch (Exception e) { @@ -72,4 +97,26 @@ private static Block createBlock(String blockID) { throw new RuntimeException("Error! Invalid NOVA block ID: " + blockID); } } + + private static final class TileLoaderEntry { + private final Predicate predicate; + private final FWCustomTileLoader customTileLoader; + + public TileLoaderEntry(Predicate predicate, FWCustomTileLoader customTileLoader) { + this.predicate = predicate; + this.customTileLoader = customTileLoader; + } + + public boolean isValid(Block block) { + return predicate.test(block); + } + + public FWTile loadTile(Block block, NBTTagCompound data) { + return customTileLoader.loadTile(block, data); + } + + public FWTile loadTile(Block block, String blockID) { + return customTileLoader.loadTile(block, blockID); + } + } } diff --git a/settings.gradle b/settings.gradle index 27fdae8ff..78aae8fc9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,3 +3,7 @@ rootProject.name = 'NOVA-Core' include "minecraft:1.11" include "minecraft:1.8" include "minecraft:1.7" + +project(":minecraft:1.11").name = "NOVA-Core-Wrapper-MC1.11" +project(":minecraft:1.8").name = "NOVA-Core-Wrapper-MC1.8" +project(":minecraft:1.7").name = "NOVA-Core-Wrapper-MC1.7" diff --git a/src/main/java/nova/core/util/Identifiable.java b/src/main/java/nova/core/util/Identifiable.java index e2ffbae9b..1a1f411b2 100644 --- a/src/main/java/nova/core/util/Identifiable.java +++ b/src/main/java/nova/core/util/Identifiable.java @@ -52,10 +52,10 @@ static String addPrefix(String id, boolean force) { int prefixEnd = id.lastIndexOf(':'); String oldPrefix = prefixEnd < 0 ? "" : id.substring(0, prefixEnd); String newPrefix = null; - Optional mod = ModLoader.instance().activeMod(); + Optional mod = ModLoader.instance().activeMod(); - if (mod.isPresent()) { - newPrefix = mod.get().id(); + if (mod.isPresent() && mod.get() instanceof Mod) { + newPrefix = ((Mod)mod.get()).id(); } if (newPrefix != null && (force ? !oldPrefix.startsWith(newPrefix) : oldPrefix.isEmpty())) { diff --git a/src/main/java/nova/core/util/registry/Factory.java b/src/main/java/nova/core/util/registry/Factory.java index 36e12ebb9..184b43c00 100644 --- a/src/main/java/nova/core/util/registry/Factory.java +++ b/src/main/java/nova/core/util/registry/Factory.java @@ -55,7 +55,7 @@ public abstract class Factory, T extends Identifiable> i * @param processor The processor function */ public Factory(String id, Supplier constructor, Function processor) { - this.id = Identifiable.addPrefix(id, true); + this.id = Identifiable.addPrefix(id, false); this.constructor = constructor; this.processor = processor; } From 447fa5dd2a08136b637a7e5fc3f81e755e3a746e Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 25 Dec 2016 20:47:14 +0100 Subject: [PATCH 18/61] Simplified the way FWCustomTileLoaders are registered. --- .../block/forward/FWCustomTileLoader.java | 6 ++++ .../wrapper/block/forward/FWTileLoader.java | 32 +++---------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java index 47a2dbbdf..d3ca72faf 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java @@ -29,6 +29,12 @@ */ public interface FWCustomTileLoader { + /** + * @param block The Nova Block + * @return true if the block is supported, false if not. + */ + boolean isBlockSupported(Block block); + /** * Load a FWTile. * diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index 00b429475..9f3f9952c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -40,7 +40,7 @@ public final class FWTileLoader { private static ComponentInjector injector = new ComponentInjector<>(FWTile.class); private static ComponentInjector updaterInjector = new ComponentInjector<>(FWTileUpdater.class); - private static Set tileLoaders = new HashSet<>(); + private static Set tileLoaders = new HashSet<>(); private FWTileLoader() { } @@ -54,15 +54,15 @@ private FWTileLoader() { * @param predicate The predicate (use {@code block instanceof Annotation}). * @param customTileLoader The custom tile loader. */ - public static void registerTileLoader(Predicate predicate, FWCustomTileLoader customTileLoader) { - tileLoaders.add(new TileLoaderEntry(predicate, customTileLoader)); + public static void registerTileLoader(FWCustomTileLoader customTileLoader) { + tileLoaders.add(customTileLoader); } public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isValid(block)).findFirst(); + Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isBlockSupported(block)).findFirst(); FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, data) : null; if (tile == null) tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : @@ -77,7 +77,7 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isValid(block)).findFirst(); + Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isBlockSupported(block)).findFirst(); FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, blockID) : null; if (tile == null) tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : @@ -97,26 +97,4 @@ private static Block createBlock(String blockID) { throw new RuntimeException("Error! Invalid NOVA block ID: " + blockID); } } - - private static final class TileLoaderEntry { - private final Predicate predicate; - private final FWCustomTileLoader customTileLoader; - - public TileLoaderEntry(Predicate predicate, FWCustomTileLoader customTileLoader) { - this.predicate = predicate; - this.customTileLoader = customTileLoader; - } - - public boolean isValid(Block block) { - return predicate.test(block); - } - - public FWTile loadTile(Block block, NBTTagCompound data) { - return customTileLoader.loadTile(block, data); - } - - public FWTile loadTile(Block block, String blockID) { - return customTileLoader.loadTile(block, blockID); - } - } } From dbe848679ce7385e08691f4589648d5d3fde3629 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 25 Dec 2016 20:49:11 +0100 Subject: [PATCH 19/61] Fix Travis build --- .../mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java | 1 - 1 file changed, 1 deletion(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index 9f3f9952c..238ce5830 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -51,7 +51,6 @@ private FWTileLoader() { * Custom tile loaders are evaluated first. * This class is used as a fallback. * - * @param predicate The predicate (use {@code block instanceof Annotation}). * @param customTileLoader The custom tile loader. */ public static void registerTileLoader(FWCustomTileLoader customTileLoader) { From c3538c86c23bbade4cd2af83004c6da06e448d0b Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 25 Dec 2016 21:06:35 +0100 Subject: [PATCH 20/61] Made private methods in BWBlock protected. Reason: NOVA-Energy + Forge Energy compatibility --- .../mc/forge/v1_11/wrapper/block/backward/BWBlock.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 25664bb09..94bf4a1c0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -102,15 +102,15 @@ public ItemFactory getItemFactory() { return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(mcBlock))); } - private IBlockAccess getMcBlockAccess() { + protected IBlockAccess getMcBlockAccess() { return ((BWWorld) world()).access; } - private IBlockState blockState() { + protected IBlockState blockState() { return getMcBlockAccess().getBlockState(new BlockPos(x(), y(), z())); } - private TileEntity getTileEntity() { + protected TileEntity getTileEntity() { if (mcTileEntity == null && mcBlock.hasTileEntity(blockState())) { mcTileEntity = getMcBlockAccess().getTileEntity(new BlockPos(x(), y(), z())); } From 701224046f2f6e4706971d548b1a42b4291ebeb2 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 26 Dec 2016 13:01:29 +0100 Subject: [PATCH 21/61] Update to latest MCP mapping + Fix bug in MCCraftingGrid --- minecraft/1.11/build.gradle | 4 +- .../mc/forge/v1_11/launcher/ClientProxy.java | 2 +- .../v1_11/network/netty/MCNetworkManager.java | 2 +- .../forge/v1_11/recipes/MCCraftingGrid.java | 30 +++++++-------- .../v1_11/recipes/NovaCraftingRecipe.java | 2 +- .../v1_11/wrapper/block/world/BWWorld.java | 4 +- .../wrapper/entity/backward/BWEntity.java | 2 +- .../wrapper/entity/forward/BWRigidBody.java | 2 +- .../entity/forward/MCEntityTransform.java | 2 +- .../v1_11/wrapper/inventory/FWInventory.java | 21 ++++++---- .../v1_11/wrapper/item/ItemConverter.java | 8 ++-- .../wrapper/item/ItemWrapperMethods.java | 2 +- .../item/OreDictionaryIntegration.java | 5 ++- .../particle/forward/MCParticleTransform.java | 2 +- .../mc/forge/v17/recipes/MCCraftingGrid.java | 38 +++++++++---------- .../mc/forge/v18/recipes/MCCraftingGrid.java | 28 +++++++------- 16 files changed, 80 insertions(+), 74 deletions(-) diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index 6f83ac975..aade6345d 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -103,11 +103,11 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20161111' + mappings = 'snapshot_20161220' runDir = "run" } -reobf { +reobfJar { // TODO Figure out what this was replaced by in ForgeGrade 2.2 //reobf(fatJar) {spec -> spec.classpath = configurations.compile} } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java index 1bc259112..bd05bf377 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java @@ -146,6 +146,6 @@ public Entity spawnParticle(net.minecraft.world.World world, Entity entity) { @Override public EntityPlayer getClientPlayer() { - return Minecraft.getMinecraft().thePlayer; + return Minecraft.getMinecraft().player; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java index 5c7b508ba..b834f7fe7 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java @@ -90,7 +90,7 @@ public PacketAbstract writePacket(int id, Syncable sender) { @Override public void sendChat(Player player, String message) { if (player instanceof BWEntity.MCPlayer) { - ((BWEntity.MCPlayer) player).entity.addChatMessage(new TextComponentString(message)); + ((BWEntity.MCPlayer) player).entity.sendMessage(new TextComponentString(message)); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java index c81615a0e..0eafaf8b9 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java @@ -183,8 +183,8 @@ public boolean setStack(int x, int y, Optional stack) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (!stack.equals(stacks[ix])) { - if (stack.isPresent()) { + if (stack.isPresent()) { + if (!stack.get().equals(stacks[ix])) { inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); if (stacks[ix] == null) { @@ -192,11 +192,11 @@ public boolean setStack(int x, int y, Optional stack) { } stacks[ix] = stack.get(); - } else { - numberOfStacks--; - inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; } + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; } return true; @@ -206,21 +206,21 @@ public boolean setStack(int x, int y, Optional stack) { public boolean setStack(int i, Optional stack) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack == null) { + if (stack.isPresent()) { if (stacks[i] == null) { - return true; + numberOfStacks++; } - numberOfStacks--; - inventory.setInventorySlotContents(i, null); - stacks[i] = null; + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); } else { if (stacks[i] == null) { - numberOfStacks++; + return true; } - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); + numberOfStacks--; + inventory.setInventorySlotContents(i, null); + stacks[i] = null; } return true; @@ -246,7 +246,7 @@ private boolean changed(int i) { return true; } - if (original[i] != null && stacks[i].count() != original[i].func_190916_E()) { + if (original[i] != null && stacks[i].count() != original[i].getCount()) { return true; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java index 9c33ea307..c04a4c622 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java @@ -69,6 +69,6 @@ public ItemStack getRecipeOutput() { @Override public NonNullList getRemainingItems(InventoryCrafting inv) { - return NonNullList.func_191196_a(); + return NonNullList.create(); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java index c3395e43e..5d5798496 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java @@ -117,7 +117,7 @@ public boolean removeBlock(Vector3D position) { public Entity addEntity(EntityFactory factory) { FWEntity bwEntity = new FWEntity(world(), factory); bwEntity.forceSpawn = true; - world().spawnEntityInWorld(bwEntity); + world().spawnEntity(bwEntity); return bwEntity.getWrapped(); } @@ -150,7 +150,7 @@ public Set getEntities(Cuboid bound) { @Override public Entity addEntity(Vector3D position, Item item) { EntityItem entityItem = new EntityItem(world(), position.getX(), position.getY(), position.getZ(), Game.natives().toNative(item)); - world().spawnEntityInWorld(entityItem); + world().spawnEntity(entityItem); return Game.natives().toNova(entityItem); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java index 7ec3bffb4..c7f6b9247 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java @@ -51,7 +51,7 @@ public BWEntity(net.minecraft.entity.Entity entity) { @Override public void damage(double amount, DamageType type) { if (type == DamageType.generic) { - entity.attackEntityFrom(DamageSource.generic, (float) amount); + entity.attackEntityFrom(DamageSource.GENERIC, (float) amount); } // TODO: Apply other damage source wrappers? } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java index c268f66cf..e5bd7d97d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java @@ -78,7 +78,7 @@ public void update(double deltaTime) { void updateTranslation(double deltaTime) { //Integrate velocity to displacement Vector3D displacement = velocity().scalarMultiply(deltaTime); - mcEntity().moveEntity(MoverType.SELF, displacement.getX(), displacement.getY(), displacement.getZ()); + mcEntity().move(MoverType.SELF, displacement.getX(), displacement.getY(), displacement.getZ()); //Integrate netForce to velocity setVelocity(velocity().add(netForce.scalarMultiply(1 / mass()).scalarMultiply(deltaTime))); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java index cb0b425df..c2a4517b8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java @@ -46,7 +46,7 @@ public MCEntityTransform(net.minecraft.entity.Entity wrapper) { @Override public World world() { - return Game.natives().toNova(wrapper.worldObj); + return Game.natives().toNova(wrapper.world); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java index 2a87ed9b0..c994c5d07 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java @@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; import nova.core.component.inventory.Inventory; +import nova.core.item.Item; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; public class FWInventory implements IInventory { @@ -41,8 +42,12 @@ public int getSizeInventory() { } @Override - public boolean func_191420_l() { - return false; // TODO: What does this do? + public boolean isEmpty() { + int i = 0; + for (Item item : wrapped) { + i++; + } + return i == 0; } @Override @@ -54,11 +59,11 @@ public ItemStack getStackInSlot(int slot) { public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); ItemStack ret = stack.copy(); - ret.func_190920_e(Math.min(ret.func_190916_E(), amount)); - stack.func_190920_e(stack.func_190916_E() - ret.func_190916_E()); - if (stack.func_190916_E() <= 0) { + ret.setCount(Math.min(ret.getCount(), amount)); + stack.setCount(stack.getCount() - ret.getCount()); + if (stack.getCount() <= 0) { setInventorySlotContents(slot, null); - return null; + return ItemStack.EMPTY; } markDirty(); return ret; @@ -71,7 +76,7 @@ public ItemStack getStackInSlotOnClosing(int slot) { @Override public ItemStack removeStackFromSlot(int slot) { ItemStack stack = getStackInSlot(slot); - decrStackSize(slot, stack.func_190916_E()); + decrStackSize(slot, stack.getCount()); return stack; } @@ -107,7 +112,7 @@ public void markDirty() { } @Override - public boolean isUseableByPlayer(EntityPlayer player) { + public boolean isUsableByPlayer(EntityPlayer player) { // TODO Auto-generated method stub return true; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index 5742ff29f..6b837d777 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -81,7 +81,7 @@ public Class getNativeSide() { @Override public Item toNova(ItemStack itemStack) { - return getNovaItem(itemStack).setCount(itemStack.func_190916_E()); + return getNovaItem(itemStack).setCount(itemStack.getCount()); } //TODO: Why is this method separate? @@ -159,9 +159,9 @@ public ItemFactory get(MinecraftItemMapping minecraftItem) { * Saves NOVA item into a Minecraft ItemStack. */ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { - itemStack.func_190920_e(item.count()); - if (itemStack.func_190916_E() <= 0) { - return null; + itemStack.setCount(item.count()); + if (itemStack.getCount() <= 0) { + return ItemStack.EMPTY; } itemStack.setTagCompound(Game.natives().toNative(item.getFactory().save(item))); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java index e03e0dba8..6e532a690 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java @@ -44,7 +44,7 @@ public interface ItemWrapperMethods { default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { Item item = Game.natives().toNova(itemStack); - item.setCount(itemStack.func_190916_E()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list)); + item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list)); getItemFactory().save(item); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java index 888beccdc..245f6f6d1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java @@ -64,8 +64,9 @@ public void registerOreDictionary() { } private void onEntryAdded(Dictionary.AddEvent event) { - if (!OreDictionary.getOres(event.key).contains(event.value)) { - OreDictionary.registerOre(event.key, ItemConverter.instance().toNative(event.value)); + ItemStack nativeValue = ItemConverter.instance().toNative(event.value); + if (!OreDictionary.getOres(event.key).contains(nativeValue)) { + OreDictionary.registerOre(event.key, nativeValue); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java index 86736617c..061a08a24 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java @@ -28,7 +28,7 @@ public MCParticleTransform(Particle wrapper) { @Override public World world() { - return Game.natives().toNova(wrapper.worldObj); + return Game.natives().toNova(wrapper.world); } @Override diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java index 34c893dda..01eb6f266 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java @@ -183,20 +183,20 @@ public boolean setStack(int x, int y, Optional stack) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (!stack.equals(stacks[ix])) { - if (stack.isPresent()) { - inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); + if (stack.isPresent()) { + if (!stack.get().equals(stacks[ix])) { + inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); - if (stacks[ix] == null) { - numberOfStacks++; - } + if (stacks[ix] == null) { + numberOfStacks++; + } - stacks[ix] = stack.get(); - } else { - numberOfStacks--; - inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; + stacks[ix] = stack.get(); } + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; } return true; @@ -206,21 +206,21 @@ public boolean setStack(int x, int y, Optional stack) { public boolean setStack(int i, Optional stack) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack == null) { + if (stack.isPresent()) { if (stacks[i] == null) { - return true; + numberOfStacks++; } - numberOfStacks--; - inventory.setInventorySlotContents(i, null); - stacks[i] = null; + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); } else { if (stacks[i] == null) { - numberOfStacks++; + return true; } - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); + numberOfStacks--; + inventory.setInventorySlotContents(i, null); + stacks[i] = null; } return true; diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java index 64e9a8524..80ae84fce 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java @@ -183,8 +183,8 @@ public boolean setStack(int x, int y, Optional stack) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (!stack.equals(stacks[ix])) { - if (stack.isPresent()) { + if (stack.isPresent()) { + if (!stack.get().equals(stacks[ix])) { inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); if (stacks[ix] == null) { @@ -192,11 +192,11 @@ public boolean setStack(int x, int y, Optional stack) { } stacks[ix] = stack.get(); - } else { - numberOfStacks--; - inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; } + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; } return true; @@ -206,21 +206,21 @@ public boolean setStack(int x, int y, Optional stack) { public boolean setStack(int i, Optional stack) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack == null) { + if (stack.isPresent()) { if (stacks[i] == null) { - return true; + numberOfStacks++; } - numberOfStacks--; - inventory.setInventorySlotContents(i, null); - stacks[i] = null; + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); } else { if (stacks[i] == null) { - numberOfStacks++; + return true; } - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); + numberOfStacks--; + inventory.setInventorySlotContents(i, null); + stacks[i] = null; } return true; From 3579ecd5964b4947bcec559ad8f2244734fc5e35 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 2 Jan 2017 19:07:29 +0100 Subject: [PATCH 22/61] Added ability for custom wrappers to handle component registration on BWBlocks and BWItems. Needed for NOVA Energy + Minecraft Forge Energy compatibility. Additional changes: Revert subprojects display name change. --- .../v1_11/wrapper/block/backward/BWBlock.java | 15 +++++++++++--- .../backward/BWBlockComponentHandler.java | 20 +++++++++++++++++++ .../item/backward/BWItemComponentHandler.java | 20 +++++++++++++++++++ .../wrapper/item/backward/BWItemFactory.java | 12 +++++++++-- settings.gradle | 4 ---- 5 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 94bf4a1c0..7149fe319 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -47,10 +47,14 @@ import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; public class BWBlock extends Block implements Storable { + private static final Set componentHandlers = new HashSet<>(); + public final net.minecraft.block.Block mcBlock; @Store public int metadata; @@ -94,6 +98,7 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }); + componentHandlers.forEach(handler -> handler.addComponents(this, mcBlock)); //TODO: Set selection bounds } @@ -102,15 +107,15 @@ public ItemFactory getItemFactory() { return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(mcBlock))); } - protected IBlockAccess getMcBlockAccess() { + public IBlockAccess getMcBlockAccess() { return ((BWWorld) world()).access; } - protected IBlockState blockState() { + public IBlockState blockState() { return getMcBlockAccess().getBlockState(new BlockPos(x(), y(), z())); } - protected TileEntity getTileEntity() { + public TileEntity getTileEntity() { if (mcTileEntity == null && mcBlock.hasTileEntity(blockState())) { mcTileEntity = getMcBlockAccess().getTileEntity(new BlockPos(x(), y(), z())); } @@ -155,4 +160,8 @@ public void load(Data data) { tileEntity.writeToNBT(Game.natives().toNative(data)); } } + + static void registerComponentHandler(BWBlockComponentHandler handler) { + componentHandlers.add(handler); + } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java new file mode 100644 index 000000000..5cc3eebd6 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward; + +/** + * Adds additional components to the NOVA block. + * + * @author ExE Boss + */ +public interface BWBlockComponentHandler { + + void addComponents(BWBlock novaBlock, net.minecraft.block.Block mcBlock); + + static void register(BWBlockComponentHandler handler) { + BWBlock.registerComponentHandler(handler); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java new file mode 100644 index 000000000..bcf0cf88e --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; + +/** + * Adds additional components to the NOVA item. + * + * @author ExE Boss + */ +public interface BWItemComponentHandler { + + void addComponents(BWItem novaItem, net.minecraft.item.Item mcItem); + + static void register(BWItemComponentHandler handler) { + BWItemFactory.registerComponentHandler(handler); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java index af064ac77..d5ad117a8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java @@ -25,16 +25,19 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; -import nova.core.util.id.Identifier; -import nova.core.util.id.StringIdentifier; import nova.internal.core.Game; +import java.util.HashSet; +import java.util.Set; + /** * A Minecraft wrapped item factory. * @author Stan * @since 3/02/2015. */ public class BWItemFactory extends ItemFactory { + private static final Set componentHandlers = new HashSet<>(); + private final net.minecraft.item.Item item; private final int meta; @@ -59,6 +62,7 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); + componentHandlers.forEach(handler -> handler.addComponents(bwItem, item)); return bwItem; } @@ -81,4 +85,8 @@ public Data save(Item item) { return result; } + + static void registerComponentHandler(BWItemComponentHandler handler) { + componentHandlers.add(handler); + } } diff --git a/settings.gradle b/settings.gradle index 78aae8fc9..27fdae8ff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,3 @@ rootProject.name = 'NOVA-Core' include "minecraft:1.11" include "minecraft:1.8" include "minecraft:1.7" - -project(":minecraft:1.11").name = "NOVA-Core-Wrapper-MC1.11" -project(":minecraft:1.8").name = "NOVA-Core-Wrapper-MC1.8" -project(":minecraft:1.7").name = "NOVA-Core-Wrapper-MC1.7" From 6c1f5de13e88e4865336224784f7acf8020cdec0 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 19:08:26 +0100 Subject: [PATCH 23/61] Changed component handlers and custom tile loaders to events Reason: Consistency with the rest of the NOVA wrappers. --- .../mc/forge/v1_11/util/WrapperEvent.java | 57 +++++++++++++++++++ .../v1_11/wrapper/block/backward/BWBlock.java | 12 +--- .../backward/BWBlockComponentHandler.java | 20 ------- .../block/forward/FWCustomTileLoader.java | 55 ------------------ .../wrapper/block/forward/FWTileLoader.java | 25 +++----- .../item/backward/BWItemComponentHandler.java | 20 ------- .../wrapper/item/backward/BWItemFactory.java | 13 +---- 7 files changed, 70 insertions(+), 132 deletions(-) delete mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java delete mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java delete mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java index c783709f0..e13ab6495 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java @@ -20,9 +20,16 @@ package nova.core.wrapper.mc.forge.v1_11.util; +import net.minecraft.nbt.NBTTagCompound; +import nova.core.block.Block; import nova.core.event.BlockEvent; +import nova.core.event.bus.CancelableEvent; +import nova.core.event.bus.Event; import nova.core.util.Direction; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; /** @@ -60,4 +67,54 @@ public WeakRedstone(World world, Vector3D position, Direction direction) { this.direction = direction; } } + + public static class BWBlockCreate extends BlockEvent { + public final net.minecraft.block.Block mcBlock; + public final BWBlock novaBlock; + + public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.minecraft.block.Block mcBlock) { + super(world, position); + this.novaBlock = novaBlock; + this.mcBlock = mcBlock; + } + } + + public static class BWItemCreate extends CancelableEvent { + public final net.minecraft.item.Item mcItem; + public final BWItem novaItem; + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { + this.novaItem = novaItem; + this.mcItem = mcItem; + } + } + + public static class FWTileLoad extends Event { + public final Block block; + public final NBTTagCompound data; + private FWTile result = null; + + public FWTileLoad(Block block) { + this.block = block; + this.data = null; + } + + public FWTileLoad(Block block, NBTTagCompound data) { + this.block = block; + this.data = data; + } + + public boolean hasResult() { + return result != null; + } + + public FWTile getResult() { + return result; + } + + public void setResult(FWTile result) { + if (this.result == null) + this.result = result; + } + } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 7149fe319..653cf8db6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -42,19 +42,16 @@ import nova.core.sound.Sound; import nova.core.util.shape.Cuboid; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; public class BWBlock extends Block implements Storable { - private static final Set componentHandlers = new HashSet<>(); - public final net.minecraft.block.Block mcBlock; @Store public int metadata; @@ -98,7 +95,8 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }); - componentHandlers.forEach(handler -> handler.addComponents(this, mcBlock)); + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); + Game.events().publish(event); //TODO: Set selection bounds } @@ -160,8 +158,4 @@ public void load(Data data) { tileEntity.writeToNBT(Game.natives().toNative(data)); } } - - static void registerComponentHandler(BWBlockComponentHandler handler) { - componentHandlers.add(handler); - } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java deleted file mode 100644 index 5cc3eebd6..000000000 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlockComponentHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward; - -/** - * Adds additional components to the NOVA block. - * - * @author ExE Boss - */ -public interface BWBlockComponentHandler { - - void addComponents(BWBlock novaBlock, net.minecraft.block.Block mcBlock); - - static void register(BWBlockComponentHandler handler) { - BWBlock.registerComponentHandler(handler); - } -} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java deleted file mode 100644 index d3ca72faf..000000000 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWCustomTileLoader.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; - -import net.minecraft.nbt.NBTTagCompound; -import nova.core.block.Block; - -/** - * - * @author ExE Boss - */ -public interface FWCustomTileLoader { - - /** - * @param block The Nova Block - * @return true if the block is supported, false if not. - */ - boolean isBlockSupported(Block block); - - /** - * Load a FWTile. - * - * @param block The Nova Block - * @param data The Minecraft NBTTagCompound - * @return The loaded FWTile or null, if this CustomTileLoader doesn't support this Tile. - */ - FWTile loadTile(Block block, NBTTagCompound data); - - /** - * Load a FWTile. - * - * @param block The Nova Block - * @param blockID The block ID - * @return The loaded FWTile or null, if this CustomTileLoader doesn't support this Tile. - */ - FWTile loadTile(Block block, String blockID); -} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index 238ce5830..e9db9c35a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -25,6 +25,7 @@ import nova.core.block.BlockFactory; import nova.core.component.Updater; import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.internal.core.Game; import java.util.HashSet; @@ -40,29 +41,16 @@ public final class FWTileLoader { private static ComponentInjector injector = new ComponentInjector<>(FWTile.class); private static ComponentInjector updaterInjector = new ComponentInjector<>(FWTileUpdater.class); - private static Set tileLoaders = new HashSet<>(); - private FWTileLoader() { } - /** - * Registers a {@link FWCustomTileLoader custom tile loader}. - * - * Custom tile loaders are evaluated first. - * This class is used as a fallback. - * - * @param customTileLoader The custom tile loader. - */ - public static void registerTileLoader(FWCustomTileLoader customTileLoader) { - tileLoaders.add(customTileLoader); - } - public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isBlockSupported(block)).findFirst(); - FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, data) : null; + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block, data); + Game.events().publish(event); + FWTile tile = event.getResult(); if (tile == null) tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); @@ -76,8 +64,9 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - Optional customTileLoader = tileLoaders.stream().filter(tileLoader -> tileLoader.isBlockSupported(block)).findFirst(); - FWTile tile = customTileLoader.isPresent() ? customTileLoader.get().loadTile(block, blockID) : null; + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); + Game.events().publish(event); + FWTile tile = event.getResult(); if (tile == null) tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java deleted file mode 100644 index bcf0cf88e..000000000 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemComponentHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; - -/** - * Adds additional components to the NOVA item. - * - * @author ExE Boss - */ -public interface BWItemComponentHandler { - - void addComponents(BWItem novaItem, net.minecraft.item.Item mcItem); - - static void register(BWItemComponentHandler handler) { - BWItemFactory.registerComponentHandler(handler); - } -} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java index d5ad117a8..6a39fd5bb 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java @@ -25,19 +25,15 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.internal.core.Game; -import java.util.HashSet; -import java.util.Set; - /** * A Minecraft wrapped item factory. * @author Stan * @since 3/02/2015. */ public class BWItemFactory extends ItemFactory { - private static final Set componentHandlers = new HashSet<>(); - private final net.minecraft.item.Item item; private final int meta; @@ -62,7 +58,8 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); - componentHandlers.forEach(handler -> handler.addComponents(bwItem, item)); + WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); + Game.events().publish(event); return bwItem; } @@ -85,8 +82,4 @@ public Data save(Item item) { return result; } - - static void registerComponentHandler(BWItemComponentHandler handler) { - componentHandlers.add(handler); - } } From 4c925c3e1a327ccac589479b1c16d3970295b7b1 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 19:18:46 +0100 Subject: [PATCH 24/61] Changed WrapperEvent.FWTileLoad.data to Optional Reason: Consistency --- .../core/wrapper/mc/forge/v1_11/util/WrapperEvent.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java index e13ab6495..0cada8fa1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java @@ -32,6 +32,8 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Optional; + /** * Events for wrappers to hook into * @author Calclavia @@ -91,17 +93,17 @@ public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { public static class FWTileLoad extends Event { public final Block block; - public final NBTTagCompound data; + public final Optional data; private FWTile result = null; public FWTileLoad(Block block) { this.block = block; - this.data = null; + this.data = Optional.empty(); } public FWTileLoad(Block block, NBTTagCompound data) { this.block = block; - this.data = data; + this.data = Optional.of(data); } public boolean hasResult() { From 2befae4e06261d812cdc0128aa7e99e6ab9e6686 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 3 Jan 2017 21:14:41 +0100 Subject: [PATCH 25/61] Backport new Wrapper Events to 1.7 and 1.8 Reason: Consistency --- .../mc/forge/v17/util/WrapperEvent.java | 59 +++++++++++++++++++ .../v17/wrapper/block/backward/BWBlock.java | 3 + .../wrapper/block/forward/FWTileLoader.java | 13 +++- .../forge/v17/wrapper/item/BWItemFactory.java | 3 + .../mc/forge/v18/util/WrapperEvent.java | 59 +++++++++++++++++++ .../v18/wrapper/block/backward/BWBlock.java | 3 + .../wrapper/block/forward/FWTileLoader.java | 15 ++++- .../forge/v18/wrapper/item/BWItemFactory.java | 3 + 8 files changed, 153 insertions(+), 5 deletions(-) diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java index eff9a048c..a5dba397f 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java @@ -20,11 +20,20 @@ package nova.core.wrapper.mc.forge.v17.util; +import net.minecraft.nbt.NBTTagCompound; +import nova.core.block.Block; import nova.core.event.BlockEvent; +import nova.core.event.bus.CancelableEvent; +import nova.core.event.bus.Event; import nova.core.util.Direction; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v17.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v17.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Optional; + /** * @author Calclavia */ @@ -59,4 +68,54 @@ public WeakRedstone(World world, Vector3D position, Direction direction) { this.direction = direction; } } + + public static class BWBlockCreate extends BlockEvent { + public final net.minecraft.block.Block mcBlock; + public final BWBlock novaBlock; + + public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.minecraft.block.Block mcBlock) { + super(world, position); + this.novaBlock = novaBlock; + this.mcBlock = mcBlock; + } + } + + public static class BWItemCreate extends CancelableEvent { + public final net.minecraft.item.Item mcItem; + public final BWItem novaItem; + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { + this.novaItem = novaItem; + this.mcItem = mcItem; + } + } + + public static class FWTileLoad extends Event { + public final Block block; + public final Optional data; + private FWTile result = null; + + public FWTileLoad(Block block) { + this.block = block; + this.data = Optional.empty(); + } + + public FWTileLoad(Block block, NBTTagCompound data) { + this.block = block; + this.data = Optional.of(data); + } + + public boolean hasResult() { + return result != null; + } + + public FWTile getResult() { + return result; + } + + public void setResult(FWTile result) { + if (this.result == null) + this.result = result; + } + } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java index 20d6a7a56..b1870876b 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java @@ -40,6 +40,7 @@ import nova.core.retention.Store; import nova.core.util.shape.Cuboid; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -85,6 +86,8 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { }); components.add(new StaticRenderer()) .onRender(model -> model.addChild(new CustomModel(self -> RenderBlocks.getInstance().renderStandardBlock(mcBlock, x(), y(), z())))); + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); + Game.events().publish(event); //TODO: Set selection bounds } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java index 64c75e154..4592f44ac 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java @@ -24,6 +24,7 @@ import nova.core.block.Block; import nova.core.block.BlockFactory; import nova.core.wrapper.mc.forge.v17.asm.lib.ComponentInjector; +import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.internal.core.Game; import java.util.Optional; @@ -42,7 +43,11 @@ public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - FWTile tile = injector.inject(block, new Class[0], new Object[0]); + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block, data); + Game.events().publish(event); + FWTile tile = event.getResult(); + if (tile == null) + tile = injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); return tile; } catch (Exception e) { @@ -53,7 +58,11 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - FWTile tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); + Game.events().publish(event); + FWTile tile = event.getResult(); + if (tile == null) + tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); return tile; } catch (Exception e) { diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java index fa9f5ae35..0e07b06b6 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java @@ -25,6 +25,7 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.internal.core.Game; /** @@ -57,6 +58,8 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); + WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); + Game.events().publish(event); return bwItem; } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java index e8f9fc32c..5435d1ad6 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java @@ -20,11 +20,20 @@ package nova.core.wrapper.mc.forge.v18.util; +import net.minecraft.nbt.NBTTagCompound; +import nova.core.block.Block; import nova.core.event.BlockEvent; +import nova.core.event.bus.CancelableEvent; +import nova.core.event.bus.Event; import nova.core.util.Direction; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v18.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v18.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Optional; + /** * Events for wrappers to hook into * @author Calclavia @@ -60,4 +69,54 @@ public WeakRedstone(World world, Vector3D position, Direction direction) { this.direction = direction; } } + + public static class BWBlockCreate extends BlockEvent { + public final net.minecraft.block.Block mcBlock; + public final BWBlock novaBlock; + + public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.minecraft.block.Block mcBlock) { + super(world, position); + this.novaBlock = novaBlock; + this.mcBlock = mcBlock; + } + } + + public static class BWItemCreate extends CancelableEvent { + public final net.minecraft.item.Item mcItem; + public final BWItem novaItem; + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { + this.novaItem = novaItem; + this.mcItem = mcItem; + } + } + + public static class FWTileLoad extends Event { + public final Block block; + public final Optional data; + private FWTile result = null; + + public FWTileLoad(Block block) { + this.block = block; + this.data = Optional.empty(); + } + + public FWTileLoad(Block block, NBTTagCompound data) { + this.block = block; + this.data = Optional.of(data); + } + + public boolean hasResult() { + return result != null; + } + + public FWTile getResult() { + return result; + } + + public void setResult(FWTile result) { + if (this.result == null) + this.result = result; + } + } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java index a7d70ff25..88f45c504 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java @@ -42,6 +42,7 @@ import nova.core.sound.Sound; import nova.core.util.shape.Cuboid; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.core.wrapper.mc.forge.v18.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -93,6 +94,8 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }); + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); + Game.events().publish(event); //TODO: Set selection bounds } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java index 907633c88..49538e9a4 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java @@ -25,6 +25,7 @@ import nova.core.block.BlockFactory; import nova.core.component.Updater; import nova.core.wrapper.mc.forge.v18.asm.lib.ComponentInjector; +import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.internal.core.Game; import java.util.Optional; @@ -44,7 +45,11 @@ public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); + Game.events().publish(event); + FWTile tile = event.getResult(); + if (tile == null) + tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); return tile; } catch (Exception e) { @@ -55,8 +60,12 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { - String.class }, new Object[] { blockID }); + WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); + Game.events().publish(event); + FWTile tile = event.getResult(); + if (tile == null) + tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : + injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); return tile; } catch (Exception e) { diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java index e28085d10..1ef0f138f 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java @@ -25,6 +25,7 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.internal.core.Game; /** @@ -57,6 +58,8 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); + WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); + Game.events().publish(event); return bwItem; } From 52da4e6c3c9f0687e0e74f9291c36c72efe8bb9a Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 16:38:25 +0100 Subject: [PATCH 26/61] Begin the switch to Forge Capabilities --- .../mc/forge/v1_11/util/WrapperEvent.java | 62 ++++++++++++------ .../v1_11/wrapper/block/forward/FWTile.java | 46 ++++++++++++- .../wrapper/block/forward/FWTileLoader.java | 31 ++++++--- .../forward/FWCapabilityProvider.java | 64 +++++++++++++++++++ .../wrapper/entity/backward/BWEntity.java | 22 ++++--- .../wrapper/entity/forward/FWEntity.java | 40 ++++++++++++ .../v1_11/wrapper/item/backward/BWItem.java | 2 +- .../v1_11/wrapper/item/forward/FWItem.java | 13 ++++ .../wrapper/particle/backward/BWParticle.java | 9 ++- .../mc/forge/v17/util/WrapperEvent.java | 52 +++++++++------ .../wrapper/block/forward/FWTileLoader.java | 16 ++--- .../mc/forge/v18/util/WrapperEvent.java | 52 +++++++++------ .../wrapper/block/forward/FWTileLoader.java | 16 ++--- 13 files changed, 322 insertions(+), 103 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java index 0cada8fa1..0bfdb80c1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java @@ -20,15 +20,20 @@ package nova.core.wrapper.mc.forge.v1_11.util; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.ItemStack; import nova.core.block.Block; +import nova.core.entity.Entity; import nova.core.event.BlockEvent; import nova.core.event.bus.CancelableEvent; import nova.core.event.bus.Event; +import nova.core.item.Item; import nova.core.util.Direction; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -84,39 +89,58 @@ public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.mine public static class BWItemCreate extends CancelableEvent { public final net.minecraft.item.Item mcItem; public final BWItem novaItem; + public final Optional itemStack; public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { this.novaItem = novaItem; this.mcItem = mcItem; + this.itemStack = Optional.empty(); + } + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem, ItemStack itemStack) { + this.novaItem = novaItem; + this.mcItem = mcItem; + this.itemStack = Optional.of(itemStack); } } - public static class FWTileLoad extends Event { - public final Block block; - public final Optional data; - private FWTile result = null; + public static class BWEntityCreate extends CancelableEvent { + public final net.minecraft.entity.Entity mcEntity; + public final BWEntity novaEntity; - public FWTileLoad(Block block) { - this.block = block; - this.data = Optional.empty(); + public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { + this.mcEntity = mcEntity; + this.novaEntity = novaEntity; } + } - public FWTileLoad(Block block, NBTTagCompound data) { - this.block = block; - this.data = Optional.of(data); - } + public static class FWItemInitCapabilities extends Event { + public final Item novaItem; + public final FWCapabilityProvider capabilityProvider; - public boolean hasResult() { - return result != null; + public FWItemInitCapabilities(Item novaItem, FWCapabilityProvider capabilityProvider) { + this.novaItem = novaItem; + this.capabilityProvider = capabilityProvider; } + } + + public static class FWTileCreate extends Event { + public final Block novaBlock; + public final FWTile tileEntity; - public FWTile getResult() { - return result; + public FWTileCreate(Block novaBlock, FWTile tileEntity) { + this.novaBlock = novaBlock; + this.tileEntity = tileEntity; } + } + + public static class FWEntityCreate extends Event { + public final Entity novaBlock; + public final FWEntity mcEntity; - public void setResult(FWTile result) { - if (this.result == null) - this.result = result; + public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { + this.novaBlock = novaBlock; + this.mcEntity = mcEntity; } } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java index 25f5bb98a..3da300bbd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java @@ -27,17 +27,25 @@ import net.minecraft.network.play.INetHandlerPlayClient; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.capabilities.Capability; import nova.core.block.Block; import nova.core.block.Stateful; import nova.core.network.Syncable; import nova.core.retention.Data; import nova.core.retention.Storable; +import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.io.IOException; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; /** * A Minecraft TileEntity to Nova block wrapper @@ -45,12 +53,16 @@ */ public class FWTile extends TileEntity { + private final Map, Object> capabilities = new HashMap<>(); + private final Map, Object>> sidedCapabilities = new HashMap<>(); + protected String blockID; protected Block block; protected Data cacheData = null; public FWTile() { - + for (EnumFacing facing : EnumFacing.VALUES) + sidedCapabilities.put(facing, new HashMap<>()); } public FWTile(String blockID) { @@ -118,6 +130,38 @@ public void readFromNBT(NBTTagCompound nbt) { cacheData = Game.natives().toNova(nbt.getCompoundTag("nova")); } + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing == null || facing.allowsAll()) { + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + } else { + facing.forEach(enumFacing -> { + Map, Object> capabilities = sidedCapabilities.get(enumFacing); + + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + }); + } + return capabilityInstance; + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)) + || super.hasCapability(capability, facing); + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + if (!hasCapability(capability, facing)) return null; + T capabilityInstance = (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); + return capabilityInstance != null ? capabilityInstance : super.getCapability(capability, facing); + } + private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { private final Packet packet; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index e9db9c35a..b26fc4f45 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -21,13 +21,18 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import nova.core.block.Block; import nova.core.block.BlockFactory; import nova.core.component.Updater; +import nova.core.component.fluid.SidedTankProvider; +import nova.core.util.Direction; import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11.wrapper.fluid.forward.FWFluidTank; import nova.internal.core.Game; +import java.util.Arrays; import java.util.HashSet; import java.util.Optional; import java.util.Set; @@ -44,17 +49,25 @@ public final class FWTileLoader { private FWTileLoader() { } + static { + Game.events().on(WrapperEvent.FWTileCreate.class).bind(evt -> { + if (evt.novaBlock instanceof SidedTankProvider) { + Arrays.stream(Direction.values()).filter(dir -> ((SidedTankProvider) evt.novaBlock).getTank(dir) != null) + .forEach(dir -> evt.tileEntity.addCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, + new FWFluidTank(((SidedTankProvider) evt.novaBlock).getTank(dir)), facing)); + } + }) + } + public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block, data); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); @@ -64,13 +77,11 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java new file mode 100644 index 000000000..bf8195d32 --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java @@ -0,0 +1,64 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward; + +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import nova.core.util.EnumSelector; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author ExE Boss + */ +public class FWCapabilityProvider implements ICapabilityProvider { + + private final Map, Object> capabilities = new HashMap<>(); + private final Map, Object>> sidedCapabilities = new HashMap<>(); + + public FWCapabilityProvider() { + for (EnumFacing facing : EnumFacing.VALUES) + sidedCapabilities.put(facing, new HashMap<>()); + } + + public boolean hasCapabilities() { + return !capabilities.isEmpty() || sidedCapabilities.values().stream().flatMap(map -> map.keySet().stream()).count() > 0; + } + + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing == null || facing.allowsAll()) { + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + } else { + facing.forEach(enumFacing -> { + Map, Object> capabilities = sidedCapabilities.get(enumFacing); + + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + }); + } + return capabilityInstance; + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)); + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + if (!hasCapability(capability, facing)) return null; + return (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java index c7f6b9247..5c2b4046c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java @@ -45,17 +45,19 @@ public class BWEntity extends Entity { public BWEntity(net.minecraft.entity.Entity entity) { this.entity = entity; - components.add(new MCEntityTransform(entity)); - - components.add(new Damageable() { - @Override - public void damage(double amount, DamageType type) { - if (type == DamageType.generic) { - entity.attackEntityFrom(DamageSource.GENERIC, (float) amount); + if (entity != null) { + components.add(new MCEntityTransform(entity)); + + components.add(new Damageable() { + @Override + public void damage(double amount, DamageType type) { + if (type == DamageType.generic) { + entity.attackEntityFrom(DamageSource.GENERIC, (float) amount); + } + // TODO: Apply other damage source wrappers? } - // TODO: Apply other damage source wrappers? - } - }); + }); + } if (entity instanceof EntityLivingBase) { if (entity instanceof EntityPlayer) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java index df22a4fb3..682b1357c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java @@ -22,7 +22,9 @@ import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; import nova.core.block.Stateful; import nova.core.component.Updater; @@ -32,16 +34,23 @@ import nova.core.entity.EntityFactory; import nova.core.retention.Data; import nova.core.retention.Storable; +import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; import nova.internal.core.Game; +import java.util.HashMap; +import java.util.Map; + /** * Entity wrapper * @author Calclavia */ public class FWEntity extends net.minecraft.entity.Entity implements IEntityAdditionalSpawnData { + private final Map, Object> capabilities = new HashMap<>(); + private final Map, Object>> sidedCapabilities = new HashMap<>(); + protected final EntityTransform transform; protected Entity wrapped; boolean firstTick = true; @@ -214,4 +223,35 @@ public void setDead() { super.setDead(); } + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing == null || facing.allowsAll()) { + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + } else { + facing.forEach(enumFacing -> { + Map, Object> capabilities = sidedCapabilities.get(enumFacing); + + if (capabilities.containsKey(capability)) + throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + + capabilities.put(capability, capabilityInstance); + }); + } + return capabilityInstance; + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)) + || super.hasCapability(capability, facing); + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + if (!hasCapability(capability, facing)) return null; + T capabilityInstance = (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); + return capabilityInstance != null ? capabilityInstance : super.getCapability(capability, facing); + } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java index 482bed308..6749b1c09 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java @@ -59,7 +59,7 @@ public NBTTagCompound getTag() { public ItemStack makeItemStack(int stackSize) { ItemStack result = new ItemStack(item, stackSize, meta); if (tag != null) { - result.setTagCompound(tag); + result.deserializeNBT(tag); } return result; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java index 05d3474ac..093537f2b 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java @@ -20,18 +20,24 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; +import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import nova.core.item.Item; import nova.core.item.ItemFactory; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import java.util.List; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; +import nova.internal.core.Game; /** * @author Calclavia @@ -46,6 +52,13 @@ public FWItem(ItemFactory item) { setMaxStackSize(item.build().getMaxCount()); } + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + Item item = Game.natives().toNova(stack); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); + return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; + } + @Override public ItemFactory getItemFactory() { return itemFactory; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java index a556f936e..ccd415fab 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java @@ -66,9 +66,10 @@ import java.util.Map; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.MCParticleTransform; /** - * A backward entity particle that acts as a black box, which wraps a Minecraft particle fxs. + * A backward entity particle that acts as a black box, which wraps a Minecraft particle. * * TODO: Minecraft particles are no longer entities. * @@ -191,6 +192,10 @@ public BWParticle(int particleID) { public Particle createParticle(net.minecraft.world.World world) { //Look up for particle factory and pass it into BWParticle IParticleFactory particleFactory = (IParticleFactory) FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID); - return particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0); + Particle particle = particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0); + if (components.has(MCParticleTransform.class)) + components.remove(MCParticleTransform.class); + components.add(new MCParticleTransform(particle)); + return particle; } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java index a5dba397f..cb3044ce9 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java @@ -20,8 +20,9 @@ package nova.core.wrapper.mc.forge.v17.util; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.ItemStack; import nova.core.block.Block; +import nova.core.entity.Entity; import nova.core.event.BlockEvent; import nova.core.event.bus.CancelableEvent; import nova.core.event.bus.Event; @@ -29,6 +30,8 @@ import nova.core.world.World; import nova.core.wrapper.mc.forge.v17.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v17.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -83,39 +86,48 @@ public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.mine public static class BWItemCreate extends CancelableEvent { public final net.minecraft.item.Item mcItem; public final BWItem novaItem; + public final Optional itemStack; public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { this.novaItem = novaItem; this.mcItem = mcItem; + this.itemStack = Optional.empty(); + } + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem, ItemStack itemStack) { + this.novaItem = novaItem; + this.mcItem = mcItem; + this.itemStack = Optional.of(itemStack); } } - public static class FWTileLoad extends Event { - public final Block block; - public final Optional data; - private FWTile result = null; + public static class BWEntityCreate extends CancelableEvent { + public final net.minecraft.entity.Entity mcEntity; + public final BWEntity novaEntity; - public FWTileLoad(Block block) { - this.block = block; - this.data = Optional.empty(); + public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { + this.mcEntity = mcEntity; + this.novaEntity = novaEntity; } + } - public FWTileLoad(Block block, NBTTagCompound data) { - this.block = block; - this.data = Optional.of(data); - } + public static class FWTileCreate extends Event { + public final Block novaBlock; + public final FWTile tileEntity; - public boolean hasResult() { - return result != null; + public FWTileCreate(Block novaBlock, FWTile tileEntity) { + this.novaBlock = novaBlock; + this.tileEntity = tileEntity; } + } - public FWTile getResult() { - return result; - } + public static class FWEntityCreate extends Event { + public final Entity novaBlock; + public final FWEntity mcEntity; - public void setResult(FWTile result) { - if (this.result == null) - this.result = result; + public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { + this.novaBlock = novaBlock; + this.mcEntity = mcEntity; } } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java index 4592f44ac..8a25e7b0a 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java @@ -43,12 +43,10 @@ public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block, data); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = injector.inject(block, new Class[0], new Object[0]); + FWTile tile = injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); @@ -58,12 +56,10 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); + FWTile tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java index 5435d1ad6..ec47c7f45 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java @@ -20,8 +20,9 @@ package nova.core.wrapper.mc.forge.v18.util; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.item.ItemStack; import nova.core.block.Block; +import nova.core.entity.Entity; import nova.core.event.BlockEvent; import nova.core.event.bus.CancelableEvent; import nova.core.event.bus.Event; @@ -29,6 +30,8 @@ import nova.core.world.World; import nova.core.wrapper.mc.forge.v18.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v18.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v18.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v18.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -84,39 +87,48 @@ public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.mine public static class BWItemCreate extends CancelableEvent { public final net.minecraft.item.Item mcItem; public final BWItem novaItem; + public final Optional itemStack; public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { this.novaItem = novaItem; this.mcItem = mcItem; + this.itemStack = Optional.empty(); + } + + public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem, ItemStack itemStack) { + this.novaItem = novaItem; + this.mcItem = mcItem; + this.itemStack = Optional.of(itemStack); } } - public static class FWTileLoad extends Event { - public final Block block; - public final Optional data; - private FWTile result = null; + public static class BWEntityCreate extends CancelableEvent { + public final net.minecraft.entity.Entity mcEntity; + public final BWEntity novaEntity; - public FWTileLoad(Block block) { - this.block = block; - this.data = Optional.empty(); + public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { + this.mcEntity = mcEntity; + this.novaEntity = novaEntity; } + } - public FWTileLoad(Block block, NBTTagCompound data) { - this.block = block; - this.data = Optional.of(data); - } + public static class FWTileCreate extends Event { + public final Block novaBlock; + public final FWTile tileEntity; - public boolean hasResult() { - return result != null; + public FWTileCreate(Block novaBlock, FWTile tileEntity) { + this.novaBlock = novaBlock; + this.tileEntity = tileEntity; } + } - public FWTile getResult() { - return result; - } + public static class FWEntityCreate extends Event { + public final Entity novaBlock; + public final FWEntity mcEntity; - public void setResult(FWTile result) { - if (this.result == null) - this.result = result; + public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { + this.novaBlock = novaBlock; + this.mcEntity = mcEntity; } } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java index 49538e9a4..3005acf92 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java @@ -45,12 +45,10 @@ public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); @@ -60,13 +58,11 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - WrapperEvent.FWTileLoad event = new WrapperEvent.FWTileLoad(block); - Game.events().publish(event); - FWTile tile = event.getResult(); - if (tile == null) - tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); + WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); + Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); From 7c7229081bbeb5fc0e4c8a6b34c8ff10846728c2 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 16:42:50 +0100 Subject: [PATCH 27/61] =?UTF-8?q?Removed=20a=20WIP=20static=20initializer?= =?UTF-8?q?=20(FWFluidTank=20doesn=E2=80=99t=20exist=20yet)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v1_11/wrapper/block/forward/FWTileLoader.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index b26fc4f45..3c50ae2fd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -49,16 +49,6 @@ public final class FWTileLoader { private FWTileLoader() { } - static { - Game.events().on(WrapperEvent.FWTileCreate.class).bind(evt -> { - if (evt.novaBlock instanceof SidedTankProvider) { - Arrays.stream(Direction.values()).filter(dir -> ((SidedTankProvider) evt.novaBlock).getTank(dir) != null) - .forEach(dir -> evt.tileEntity.addCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, - new FWFluidTank(((SidedTankProvider) evt.novaBlock).getTank(dir)), facing)); - } - }) - } - public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); From 386bdf554d0d5c17460be2c1b5d8b342dab077c9 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 4 Jan 2017 19:33:28 +0100 Subject: [PATCH 28/61] Remove registerNovaWrapper method in NovaMinecraft --- .../mc/forge/v1_11/launcher/NovaMinecraft.java | 11 +---------- .../capability/forward/FWCapabilityProvider.java | 1 - 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index d121c01ab..64329e97f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -48,6 +48,7 @@ import nova.core.wrapper.mc.forge.v1_11.depmodules.SaveModule; import nova.core.wrapper.mc.forge.v1_11.depmodules.TickerModule; import nova.core.wrapper.mc.forge.v1_11.recipes.MinecraftRecipeRegistry; +import nova.core.wrapper.mc.forge.v1_11.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.WorldConverter; @@ -63,7 +64,6 @@ import nova.internal.core.launch.InitializationException; import nova.internal.core.launch.NovaLauncher; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -88,11 +88,6 @@ public class NovaMinecraft { private static ModMetadata modMetadata; private static Set nativeConverters; - private static Set wrappers = new HashSet<>(); - - public static void registerNovaWrapper(Loadable wrapper) { - wrappers.add(wrapper); - } /** * ORDER OF LOADING. @@ -172,8 +167,6 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); - wrappers.stream().forEachOrdered(Loadable::preInit); - //Load preInit progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); launcher.preInit(new FMLProgressBar(progressBar)); @@ -206,7 +199,6 @@ public void init(FMLInitializationEvent evt) { ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - wrappers.stream().forEachOrdered(Loadable::init); launcher.init(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); } catch (Exception e) { @@ -223,7 +215,6 @@ public void postInit(FMLPostInitializationEvent evt) { Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - wrappers.stream().forEachOrdered(Loadable::postInit); launcher.postInit(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); } catch (Exception e) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java index bf8195d32..ff4c731c3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java @@ -10,7 +10,6 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.util.EnumSelector; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; From 2a084646d64439776683d9e5d8a72e0ad1245b7b Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 5 Jan 2017 21:37:34 +0100 Subject: [PATCH 29/61] Clean up rawtypes + Clean up some deprecation + Get rid of Identifiable.addPrefix --- .../forge/v1_11/NovaMinecraftPreloader.java | 14 +++-- .../mc/forge/v1_11/launcher/ClientProxy.java | 21 +------- .../forge/v1_11/launcher/NovaMinecraft.java | 9 ++++ .../v1_11/network/netty/MCNetworkManager.java | 3 +- .../recipes/MinecraftRecipeRegistry.java | 3 +- .../forge/v1_11/recipes/RecipeConverter.java | 4 +- .../mc/forge/v1_11/render/RenderUtility.java | 8 +-- .../mc/forge/v1_11/util/ReflectionUtil.java | 30 ++++------- .../v1_11/wrapper/DirectionConverter.java | 53 +++++++++++++++++++ .../v1_11/wrapper/block/BlockConverter.java | 4 +- .../v1_11/wrapper/block/backward/BWBlock.java | 21 +++++--- .../v1_11/wrapper/block/forward/FWBlock.java | 9 ++++ .../wrapper/block/forward/FWTileRenderer.java | 6 +-- .../entity/forward/FWEntityRenderer.java | 26 +++++---- .../v1_11/wrapper/item/ItemConverter.java | 8 +-- .../wrapper/item/ItemWrapperMethods.java | 2 +- .../v1_11/wrapper/item/forward/FWItem.java | 2 +- .../wrapper/item/forward/FWItemBlock.java | 2 +- .../v17/wrapper/block/BlockConverter.java | 4 +- .../forge/v17/wrapper/item/ItemConverter.java | 7 ++- .../v18/wrapper/block/BlockConverter.java | 5 +- .../forge/v18/wrapper/item/ItemConverter.java | 4 +- .../java/nova/core/util/Identifiable.java | 23 -------- .../java/nova/core/util/registry/Factory.java | 7 +-- .../nova/internal/core/launch/ModLoader.java | 28 ---------- 25 files changed, 143 insertions(+), 160 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java index 4976f3e9a..a3aee5cf0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java @@ -91,7 +91,7 @@ public NovaMinecraftPreloader() { public static String generateSoundJSON(AbstractResourcePack pack) { JsonObject fakeSoundJSON = new JsonObject(); - for (String domain : (Set) pack.getResourceDomains()) { + for (String domain : pack.getResourceDomains()) { if (pack instanceof FileResourcePack) { //For zip resource packs @@ -99,10 +99,10 @@ public static String generateSoundJSON(AbstractResourcePack pack) { ZipFile zipFile = new ZipFile(pack.resourcePackFile); if (zipFile.getEntry("assets/" + domain + "/sounds/") != null) { - Enumeration zipEntries = zipFile.entries(); + Enumeration zipEntries = zipFile.entries(); while (zipEntries.hasMoreElements()) { - String zipPath = ((ZipEntry) zipEntries.nextElement()).getName(); + String zipPath = zipEntries.nextElement().getName(); String prefix = "assets/" + domain + "/sounds/"; if (zipPath.startsWith(prefix) && !zipPath.equals(prefix)) { @@ -116,9 +116,9 @@ public static String generateSoundJSON(AbstractResourcePack pack) { if (entry.isDirectory()) { //Sound Collection - Enumeration zipEntries2 = zipFile.entries(); + Enumeration zipEntries2 = zipFile.entries(); while (zipEntries2.hasMoreElements()) { - String zipPath2 = ((ZipEntry) zipEntries2.nextElement()).getName(); + String zipPath2 = zipEntries2.nextElement().getName(); if (zipPath2.startsWith(prefix + soundName + "/") && !zipFile.getEntry(zipPath2).isDirectory()) { String randomSoundName = zipPath2.replaceFirst(prefix + soundName + "/", ""); @@ -147,9 +147,7 @@ public static String generateSoundJSON(AbstractResourcePack pack) { if (folder.exists()) { File[] listOfFiles = folder.listFiles(); - for (int i = 0; i < listOfFiles.length; i++) { - File listedFile = listOfFiles[i]; - + for (File listedFile : listOfFiles) { JsonObject sound = new JsonObject(); sound.addProperty("category", "ambient"); JsonArray sounds = new JsonArray(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java index bd05bf377..259cfcabd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java @@ -23,12 +23,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; @@ -71,14 +68,7 @@ public void registerItem(FWItem item) { super.registerItem(item); //Hacks to inject custom item definition - ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) { - ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(item); - return new ModelResourceLocation(itemRL, "inventory"); - } - } - ); + ModelLoader.setCustomMeshDefinition(item, stack -> new ModelResourceLocation(Item.REGISTRY.getNameForObject(item), "inventory")); } @Override @@ -88,14 +78,7 @@ public void postRegisterBlock(FWBlock block) { //Hack to inject custom itemblock definition Item itemFromBlock = Item.getItemFromBlock(block); - ModelLoader.setCustomMeshDefinition(itemFromBlock, new ItemMeshDefinition() { - @Override - public ModelResourceLocation getModelLocation(ItemStack stack) { - ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(itemFromBlock); - return new ModelResourceLocation(itemRL, "inventory"); - } - } - ); + ModelLoader.setCustomMeshDefinition(itemFromBlock, stack -> new ModelResourceLocation(Item.REGISTRY.getNameForObject(itemFromBlock), "inventory")); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index 64329e97f..f42a92d02 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -129,6 +129,7 @@ public void preInit(FMLPreInitializationEvent evt) { Game.natives().registerConverter(new CuboidConverter()); Game.natives().registerConverter(new InventoryConverter()); Game.natives().registerConverter(new VectorConverter()); + Game.natives().registerConverter(new DirectionConverter()); /** * Initiate recipe and ore dictionary integration @@ -153,6 +154,8 @@ public void preInit(FMLPreInitializationEvent evt) { ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); launcher.load(new FMLProgressBar(progressBar)); + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step("null"); ProgressManager.pop(progressBar); /** @@ -170,6 +173,8 @@ public void preInit(FMLPreInitializationEvent evt) { //Load preInit progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); launcher.preInit(new FMLProgressBar(progressBar)); + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step("null"); ProgressManager.pop(progressBar); // Initiate config system TODO: Storables @@ -200,6 +205,8 @@ public void init(FMLInitializationEvent evt) { proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); launcher.init(new FMLProgressBar(progressBar)); + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step("null"); ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during init"); @@ -216,6 +223,8 @@ public void postInit(FMLPostInitializationEvent evt) { proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); launcher.postInit(new FMLProgressBar(progressBar)); + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step("null"); ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during postInit"); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java index b834f7fe7..05922cc1e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java @@ -22,6 +22,7 @@ import io.netty.buffer.Unpooled; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.INetHandler; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.text.TextComponentString; @@ -53,7 +54,7 @@ public class MCNetworkManager extends NetworkManager { public final String channel = NovaMinecraft.id; public final EnumMap channelEnumMap = NetworkRegistry.INSTANCE.newChannel(channel, new ChannelHandler(), new MCPacketHandler()); - public Packet toMCPacket(PacketAbstract packet) { + public Packet toMCPacket(PacketAbstract packet) { return channelEnumMap.get(FMLCommonHandler.instance().getEffectiveSide()).generatePacketFrom(packet); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java index 2d62ab294..a90209919 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java @@ -24,7 +24,6 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; -import nova.core.item.Item; import nova.core.recipes.RecipeAddedEvent; import nova.core.recipes.RecipeManager; import nova.core.recipes.RecipeRemovedEvent; @@ -61,7 +60,7 @@ public void registerRecipes() { RecipeManager recipeManager = Game.recipes(); - List recipes = (List) CraftingManager.getInstance().getRecipeList(); + List recipes = CraftingManager.getInstance().getRecipeList(); for (IRecipe recipe : recipes) { CraftingRecipe converted = convert(recipe); if (converted != null) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java index 2ec0901be..c93f6efe6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java @@ -99,7 +99,7 @@ private static ItemIngredient getIngredient(Object ingredient) { } } - private static String findOreDictEntryFor(List ingredient) { + private static String findOreDictEntryFor(List ingredient) { for (String key : net.minecraftforge.oredict.OreDictionary.getOreNames()) { if (net.minecraftforge.oredict.OreDictionary.getOres(key).equals(ingredient)) { return key; @@ -189,7 +189,7 @@ public static IRecipe convert(ShapedCraftingRecipe recipe) { int counter = 0; String[] parts = new String[recipe.getHeight()]; - ArrayList rarguments = new ArrayList(); + ArrayList rarguments = new ArrayList<>(); for (int i = 0; i < recipe.getHeight(); i++) { char[] pattern = new char[recipe.getWidth()]; for (int j = 0; j < recipe.getWidth(); j++) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index 75d33419e..ba2bd62de 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -205,9 +205,9 @@ public void onModelBakeEvent(ModelBakeEvent event) { Object blockObj = Game.natives().toNative(blockFactory.build()); if (blockObj instanceof FWBlock) { FWBlock block = (FWBlock) blockObj; - ResourceLocation blockRL = (ResourceLocation) net.minecraft.block.Block.REGISTRY.getNameForObject(block); + ResourceLocation blockRL = net.minecraft.block.Block.REGISTRY.getNameForObject(block); Item itemFromBlock = Item.getItemFromBlock(block); - ResourceLocation itemRL = (ResourceLocation) Item.REGISTRY.getNameForObject(itemFromBlock); + ResourceLocation itemRL = Item.REGISTRY.getNameForObject(itemFromBlock); ModelResourceLocation blockLocation = new ModelResourceLocation(blockRL, "normal"); ModelResourceLocation itemLocation = new ModelResourceLocation(itemRL, "inventory"); if (block.dummy.components.has(StaticRenderer.class)) { @@ -226,7 +226,7 @@ public void onModelBakeEvent(ModelBakeEvent event) { Item itemObj = ((ItemStack) stackObj).getItem(); if (itemObj instanceof FWItem) { FWItem item = (FWItem) itemObj; - ResourceLocation objRL = (ResourceLocation) Item.REGISTRY.getNameForObject(item); + ResourceLocation objRL = Item.REGISTRY.getNameForObject(item); ModelResourceLocation itemLocation = new ModelResourceLocation(objRL, "inventory"); nova.core.item.Item dummy = item.getItemFactory().build(); @@ -245,7 +245,7 @@ public void onModelBakeEvent(ModelBakeEvent event) { SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(itemModel, ItemOverrideList.NONE).setTexture(getTexture(texture.get())); for (BlockPart blockpart : (Iterable) itemModel.getElements()) { for (EnumFacing enumfacing : (Iterable) blockpart.mapFaces.keySet()) { - BlockPartFace blockpartface = (BlockPartFace) blockpart.mapFaces.get(enumfacing); + BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing); BakedQuad bakedQuad = FACE_BAKERY.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, blockpartface, getTexture(texture.get()), enumfacing, ModelRotation.X0_Y0, blockpart.partRotation, false, blockpart.shade); if (blockpartface.cullFace == null || !TRSRTransformation.isInteger(ModelRotation.X0_Y0.getMatrix())) { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java index 05d787009..b355784d4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java @@ -93,9 +93,7 @@ public class ReflectionUtil { try { seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class); seedEntryConstructor.setAccessible(true); - } catch (NoSuchMethodException ex) { - Logger.getLogger(ReflectionUtil.class.getName()).log(Level.SEVERE, null, ex); - } catch (SecurityException ex) { + } catch (NoSuchMethodException | SecurityException ex) { Logger.getLogger(ReflectionUtil.class.getName()).log(Level.SEVERE, null, ex); } @@ -108,9 +106,7 @@ private ReflectionUtil() { public static BiMap, EntityRegistry.EntityRegistration> getEntityClassRegistrations() { try { return (BiMap, EntityRegistry.EntityRegistration>) ENTITYREGISTRY_CLASSREGISTRATIONS.get(EntityRegistry.instance()); - } catch (IllegalArgumentException ex) { - return null; - } catch (IllegalAccessException ex) { + } catch (IllegalArgumentException | IllegalAccessException ex) { return null; } } @@ -121,18 +117,17 @@ public static List getTagList(NBTTagList list) { } try { return (List) NBTTAGLIST_TAGLIST.get(list); - } catch (IllegalArgumentException ex) { - return null; - } catch (IllegalAccessException ex) { + } catch (IllegalArgumentException | IllegalAccessException ex) { return null; } } - public static List getSeeds() { + public static List getSeeds() { return getPrivateStaticObject(ForgeHooks.class, "seedList"); } /** + * @return {@link Collections#emptyMap()} * @deprecated Removed in Forge 1.9 */ @Deprecated @@ -140,7 +135,7 @@ public static Map getChestLoot() { return Collections.emptyMap();//getPrivateStaticObject(ChestGenHooks.class, "chestInfo"); } - public static Map getTranslations() { + public static Map getTranslations() { return getPrivateObject( getPrivateStaticObject(I18n.class, "localizedName", "field_74839_a"), "languageList", @@ -208,7 +203,7 @@ public static Container getCraftingContainer(InventoryCrafting inventory) { public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) { try { return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot); - } catch (IllegalAccessException ex) { + } catch (IllegalAccessException | NullPointerException ex) { logError("could not get inventory eventhandler"); return null; } @@ -264,11 +259,7 @@ public static T getPrivateStaticObject(Class cls, String... names) { Field field = cls.getDeclaredField(name); field.setAccessible(true); return (T) field.get(null); - } catch (NoSuchFieldException ex) { - - } catch (SecurityException ex) { - - } catch (IllegalAccessException ex) { + } catch (NoSuchFieldException | SecurityException | IllegalAccessException ex) { } } @@ -311,14 +302,13 @@ public static boolean setPrivateObject(Object object, Object value, String... na // ### Private Methods ### // ####################### - private static Field getField(Class cls, String... names) { + private static Field getField(Class cls, String... names) { for (String name : names) { try { Field field = cls.getDeclaredField(name); field.setAccessible(true); return field; - } catch (NoSuchFieldException ex) { - } catch (SecurityException ex) { + } catch (NoSuchFieldException | SecurityException ex) { } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java new file mode 100644 index 000000000..334bdbcdd --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java @@ -0,0 +1,53 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package nova.core.wrapper.mc.forge.v1_11.wrapper; + +import net.minecraft.util.EnumFacing; +import nova.core.nativewrapper.NativeConverter; +import nova.core.util.Direction; + +/** + * + * @author ExE Boss + */ +public class DirectionConverter implements NativeConverter { + + @Override + public Class getNovaSide() { + return Direction.class; + } + + @Override + public Class getNativeSide() { + return EnumFacing.class; + } + + @Override + public Direction toNova(EnumFacing nativeObj) { + switch (nativeObj) { + case DOWN: return Direction.DOWN; + case UP: return Direction.UP; + case NORTH: return Direction.NORTH; + case SOUTH: return Direction.SOUTH; + case WEST: return Direction.WEST; + case EAST: return Direction.EAST; + default: return Direction.UNKNOWN; + } + } + + @Override + public EnumFacing toNative(Direction novaObj) { + switch (novaObj) { + case DOWN: return EnumFacing.DOWN; + case UP: return EnumFacing.UP; + case NORTH: return EnumFacing.NORTH; + case SOUTH: return EnumFacing.SOUTH; + case WEST: return EnumFacing.WEST; + case EAST: return EnumFacing.EAST; + default: return (EnumFacing) null; + } + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java index f987be692..692c70029 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -142,10 +142,8 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); FWItemBlock itemBlockWrapper = new FWItemBlock(blockWrapper); blockFactoryMap.put(blockFactory, blockWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String blockId = blockFactory.getID().asString(); // TODO? - ResourceLocation id = blockId.contains(":") ? new ResourceLocation(blockId) : new ResourceLocation(modId, blockId); + ResourceLocation id = new ResourceLocation(blockId); GameRegistry.register(blockWrapper, id); GameRegistry.register(itemBlockWrapper, id); NovaMinecraft.proxy.postRegisterBlock(blockWrapper); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 653cf8db6..3d72ebaac 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -21,6 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward; import net.minecraft.block.BlockSnow; +import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -71,19 +72,23 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { components.add(new BlockProperty.Opacity().setLightTransmission(!blockState().getMaterial().blocksLight())); BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", mcBlock.getSoundType().getPlaceSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", mcBlock.getSoundType().getBreakSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", mcBlock.getSoundType().getStepSound().getSoundName().getResourcePath())); - - components.add(new LightEmitter()).setEmittedLevel(() -> mcBlock.getLightValue(blockState(), getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); + SoundType soundType; + if (getMcBlockAccess() instanceof net.minecraft.world.World) + soundType = mcBlock.getSoundType(blockState(), (net.minecraft.world.World)getMcBlockAccess(), new BlockPos(x(), y(), z()), null); + else + soundType = mcBlock.getSoundType(); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", soundType.getPlaceSound().getSoundName().getResourcePath())); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", soundType.getBreakSound().getSoundName().getResourcePath())); + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("",soundType.getStepSound().getSoundName().getResourcePath())); + + components.add(new LightEmitter()).setEmittedLevel(() -> blockState().getLightValue(getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); components.add(new Collider(this)) .setBoundingBox(() -> { - AxisAlignedBB aabb = mcBlock.getBoundingBox(blockState(), getMcBlockAccess(), new BlockPos(x(), y(), z())); + AxisAlignedBB aabb = blockState().getBoundingBox(getMcBlockAccess(), new BlockPos(x(), y(), z())); return new Cuboid(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); }).setOcclusionBoxes(entity -> { List aabbs = new ArrayList<>(); - mcBlock.addCollisionBoxToList( - blockState(), + blockState().addCollisionBoxToList( Game.natives().toNative(world()), new BlockPos(x(), y(), z()), Game.natives().toNative(entity.isPresent() ? entity.get().components.get(Collider.class).boundingBox.get() : Cuboid.ONE.add(pos)), diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java index eb15f9ebb..72d44f44d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -23,6 +23,7 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -239,6 +240,7 @@ public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState sta } @Override + @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess access, BlockPos pos) { Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); if (blockInstance.components.has(Collider.class)) { @@ -249,6 +251,7 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess access, Bloc } @Override + @Deprecated public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); @@ -260,6 +263,7 @@ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, Bloc } @Override + @Deprecated public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB boundingBox, List list, Entity entity) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); blockInstance.components.getOp(Collider.class).ifPresent( @@ -279,6 +283,7 @@ public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, } @Override + @Deprecated public boolean isOpaqueCube(IBlockState state) { if (dummy == null) { // Superconstructor fix. -10 style points. @@ -306,6 +311,7 @@ public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) } @Override + @Deprecated public boolean isFullCube(IBlockState state) { Optional blockCollider = dummy.components.getOp(Collider.class); @@ -342,6 +348,7 @@ public boolean canConnectRedstone(IBlockState state, IBlockAccess access, BlockP } @Override + @Deprecated public int getWeakPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); WrapperEvent.WeakRedstone event = new WrapperEvent.WeakRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); @@ -350,6 +357,7 @@ public int getWeakPower(IBlockState state, IBlockAccess access, BlockPos pos, En } @Override + @Deprecated public int getStrongPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); WrapperEvent.StrongRedstone event = new WrapperEvent.StrongRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); @@ -369,6 +377,7 @@ public float getExplosionResistance(World world, BlockPos pos, Entity exploder, } @Override + @Deprecated public float getBlockHardness(IBlockState state, World world, BlockPos pos) { return (float) getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).getHardness() * 2; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java index e7f7dad88..8a3ec4231 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java @@ -37,13 +37,13 @@ /** * @author Calclavia */ -public class FWTileRenderer extends TileEntitySpecialRenderer { +public class FWTileRenderer extends TileEntitySpecialRenderer { public static final FWTileRenderer instance = new FWTileRenderer(); @Override - public void renderTileEntityAt(TileEntity te, double x, double y, double z, float p_180535_8_, int p_180535_9_) { - Block block = ((FWTile) te).getBlock(); + public void renderTileEntityAt(FWTile te, double x, double y, double z, float p_180535_8_, int p_180535_9_) { + Block block = te.getBlock(); Optional opRenderer = block.components.getOp(DynamicRenderer.class); if (opRenderer.isPresent()) { BWModel model = new BWModel(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java index 0736fb867..be3853f79 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java @@ -21,15 +21,15 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.client.registry.IRenderFactory; import nova.core.component.renderer.DynamicRenderer; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.FWParticle; import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; import org.lwjgl.opengl.GL11; @@ -45,14 +45,14 @@ * Renders entities. * @author Calclavia */ -public class FWEntityRenderer extends Render { - public static final FWEntityRenderer instance = new FWEntityRenderer(); +public class FWEntityRenderer extends Render { + public static final IRenderFactory instance = FWEntityRenderer::new; - public FWEntityRenderer() { - super(FMLClientHandler.instance().getClient().getRenderManager()); + public FWEntityRenderer(RenderManager manager) { + super(manager); } - public static void render(Particle wrapper, nova.core.entity.Entity entity, double x, double y, double z) { + public static void render(FWParticle wrapper, nova.core.entity.Entity entity, double x, double y, double z) { Optional opRenderer = entity.components.getOp(DynamicRenderer.class); if (opRenderer.isPresent()) { @@ -82,7 +82,7 @@ public static void render(Particle wrapper, nova.core.entity.Entity entity, doub } } - public static void render(Entity wrapper, nova.core.entity.Entity entity, double x, double y, double z) { + public static void render(FWEntity wrapper, nova.core.entity.Entity entity, double x, double y, double z) { Optional opRenderer = entity.components.getOp(DynamicRenderer.class); if (opRenderer.isPresent()) { @@ -113,14 +113,12 @@ public static void render(Entity wrapper, nova.core.entity.Entity entity, double } @Override - public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { - if (entity instanceof FWEntity) { - render(entity, ((FWEntity) entity).wrapped, x, y, z); - } + public void doRender(FWEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { + render(entity, ((FWEntity) entity).wrapped, x, y, z); } @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { + protected ResourceLocation getEntityTexture(FWEntity entity) { return null; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index 6b837d777..ae28f96cf 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -157,6 +157,10 @@ public ItemFactory get(MinecraftItemMapping minecraftItem) { /** * Saves NOVA item into a Minecraft ItemStack. + * + * @param itemStack Minecraft ItemStack. + * @param item NOVA Item. + * @return The modified ItemStack. */ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { itemStack.setCount(item.count()); @@ -219,10 +223,8 @@ private void registerNOVAItem(ItemFactory itemFactory) { // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String itemId = itemFactory.getID().asString(); // TODO? - GameRegistry.register(itemWrapper, itemId.contains(":") ? new ResourceLocation(itemId) : new ResourceLocation(modId, itemId)); + GameRegistry.register(itemWrapper, new ResourceLocation(itemId)); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java index 6e532a690..5bdd37aff 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java @@ -42,7 +42,7 @@ public interface ItemWrapperMethods { ItemFactory getItemFactory(); - default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { Item item = Game.natives().toNova(itemStack); item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list)); getItemFactory().save(item); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java index 093537f2b..e31c38762 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java @@ -65,7 +65,7 @@ public ItemFactory getItemFactory() { } @Override - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java index c7eba732e..fe69172be 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java @@ -48,7 +48,7 @@ public ItemFactory getItemFactory() { } @Override - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java index f5a461622..37b315547 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java @@ -141,11 +141,9 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); NovaMinecraft.proxy.registerBlock(blockWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String blockId = blockFactory.getID(); // GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId); - registerNovaBlock(blockWrapper, blockId.contains(":") ? blockId : modId + ":" + blockId); + registerNovaBlock(blockWrapper, blockId); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java index d8a559cb3..f0bcc5e5f 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java @@ -212,10 +212,9 @@ private void registerNOVAItem(ItemFactory itemFactory) { // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String itemId = itemFactory.getID(); - GameRegistry.registerItem(itemWrapper, itemId.contains(":") ? itemId : modId + ":" + itemId); + //GameRegistry.registerItem(itemWrapper, itemId); + registerNovaItem((FWItem) itemWrapper, itemId); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -239,7 +238,7 @@ private void registerNOVAItem(ItemFactory itemFactory) { /** * Prevent forge from prefixing item IDs with "nova:" */ - private void registerNovaBlock(FWItem itemWrapper, String blockId) { + private void registerNovaItem(FWItem itemWrapper, String blockId) { try { Class gameDataClass = GameData.class; Method getMain = gameDataClass.getDeclaredMethod("getMain"); diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java index 63310d4c3..133815185 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java @@ -141,11 +141,8 @@ public boolean canReplace() { private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String blockId = blockFactory.getID(); -// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId); - registerNovaBlock(blockWrapper, blockId.contains(":") ? blockId : modId + ":" + blockId); + registerNovaBlock(blockWrapper, blockId); NovaMinecraft.proxy.postRegisterBlock(blockWrapper); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java index 5073cf741..78fd4048b 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java @@ -214,10 +214,8 @@ private void registerNOVAItem(ItemFactory itemFactory) { // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - Optional activeMod = ModLoader.instance().activeMod(); - String modId = activeMod.isPresent() ? activeMod.get().id() : Loader.instance().activeModContainer().getModId(); String itemId = itemFactory.getID(); - GameRegistry.registerItem(itemWrapper, itemId.contains(":") ? itemId : modId + ":" + itemId); + GameRegistry.registerItem(itemWrapper, itemId); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab diff --git a/src/main/java/nova/core/util/Identifiable.java b/src/main/java/nova/core/util/Identifiable.java index 1a1f411b2..3fc6a1d34 100644 --- a/src/main/java/nova/core/util/Identifiable.java +++ b/src/main/java/nova/core/util/Identifiable.java @@ -20,11 +20,6 @@ package nova.core.util; -import nova.core.loader.Mod; -import nova.internal.core.launch.ModLoader; - -import java.util.Optional; - /** * A generic interface signifying that this object is identifiable * by an ID @@ -43,25 +38,7 @@ public interface Identifiable { * @param other Identifiable to compare to * @return If the Identifiables are the same type */ - default boolean sameType(Identifiable other) { return getID().equals(other.getID()); } - - static String addPrefix(String id, boolean force) { - int prefixEnd = id.lastIndexOf(':'); - String oldPrefix = prefixEnd < 0 ? "" : id.substring(0, prefixEnd); - String newPrefix = null; - Optional mod = ModLoader.instance().activeMod(); - - if (mod.isPresent() && mod.get() instanceof Mod) { - newPrefix = ((Mod)mod.get()).id(); - } - - if (newPrefix != null && (force ? !oldPrefix.startsWith(newPrefix) : oldPrefix.isEmpty())) { - id = newPrefix + ':' + id; - } - - return id; - } } diff --git a/src/main/java/nova/core/util/registry/Factory.java b/src/main/java/nova/core/util/registry/Factory.java index 184b43c00..a0f1d659d 100644 --- a/src/main/java/nova/core/util/registry/Factory.java +++ b/src/main/java/nova/core/util/registry/Factory.java @@ -21,11 +21,7 @@ package nova.core.util.registry; import nova.core.util.Identifiable; -import nova.core.loader.Mod; -import nova.internal.core.Game; -import nova.internal.core.launch.ModLoader; -import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; @@ -55,7 +51,7 @@ public abstract class Factory, T extends Identifiable> i * @param processor The processor function */ public Factory(String id, Supplier constructor, Function processor) { - this.id = Identifiable.addPrefix(id, false); + this.id = id; this.constructor = constructor; this.processor = processor; } @@ -82,6 +78,7 @@ public T build() { return processor.apply(constructor.get()); } + @Override public String getID() { return id; } diff --git a/src/main/java/nova/internal/core/launch/ModLoader.java b/src/main/java/nova/internal/core/launch/ModLoader.java index 45dad9b26..e1f61b603 100755 --- a/src/main/java/nova/internal/core/launch/ModLoader.java +++ b/src/main/java/nova/internal/core/launch/ModLoader.java @@ -44,8 +44,6 @@ */ public class ModLoader implements Loadable { - private static ModLoader instance; - protected final DependencyInjectionEntryPoint diep; /** @@ -75,13 +73,7 @@ public class ModLoader implements Loadable { protected List orderedMods; - /** - * The mod that is currently being pre-initialized, initialized or post-initialized - */ - protected Optional activeMod = Optional.empty(); - public ModLoader(Class annotationType, DependencyInjectionEntryPoint diep, Set> modClasses) { - instance = this; this.diep = diep; this.annotationType = annotationType; @@ -216,14 +208,12 @@ public void preInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { progressBar.step(mod.getClass()); - activeMod = Optional.of(modAnnotations.get(mod)); mod.preInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during pre initialization phase", t); throw new InitializationException(t); } }); - activeMod = Optional.empty(); } @Override @@ -235,14 +225,12 @@ public void init(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { progressBar.step(mod.getClass()); - activeMod = Optional.of(modAnnotations.get(mod)); mod.init(); } catch (Throwable t) { Game.logger().error("Critical error caught during initialization phase", t); throw new InitializationException(t); } }); - activeMod = Optional.empty(); } @Override @@ -254,18 +242,12 @@ public void postInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { progressBar.step(mod.getClass()); - activeMod = Optional.of(modAnnotations.get(mod)); mod.postInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during post initialization phase", t); throw new InitializationException(t); } }); - activeMod = Optional.empty(); - } - - public Optional activeMod() { - return activeMod; } public Set getLoadedMods() { @@ -283,14 +265,4 @@ public Map> getModClasses() { public Map> getScalaClassesMap() { return new HashMap<>(scalaClasses); } - - /** - * Returns the mod loader. - * - * @param The mod annotation, should be {@link nova.core.loader.Mod}. - * @return The mod loader (if it exists). - */ - public static ModLoader instance() { - return (ModLoader) instance; - } } From 0949af6489b0ef5b9951e9b23a44f257a453625e Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 5 Jan 2017 22:30:41 +0100 Subject: [PATCH 30/61] Get rid of TileEntity pos hack --- .../v1_11/wrapper/block/forward/FWBlock.java | 17 +---------------- .../v1_11/wrapper/block/forward/FWTile.java | 9 ++++++--- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java index 72d44f44d..418f89eb6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -72,9 +72,6 @@ public class FWBlock extends net.minecraft.block.Block { */ private final BlockFactory factory; private final Class blockClass; - //TODO: Hack. Bad practice. - public IBlockAccess lastExtendedWorld; - public BlockPos lastExtendedStatePos; private Map harvestedBlocks = new HashMap<>(); private static Material getMcMaterial(BlockFactory factory) { @@ -182,19 +179,7 @@ public boolean hasTileEntity(IBlockState state) { @Override public TileEntity createTileEntity(World world, IBlockState state) { - FWTile fwTile = FWTileLoader.loadTile(dummy.getID().asString()); // TODO? - if (lastExtendedStatePos != null) { - fwTile.block.components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ()))); - lastExtendedStatePos = null; - } - return fwTile; - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - lastExtendedWorld = world; - lastExtendedStatePos = pos; - return super.getExtendedState(state, world, pos); + return FWTileLoader.loadTile(dummy.getID().asString()); // TODO? } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java index 3da300bbd..9c45c3f2e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java @@ -37,13 +37,10 @@ import nova.core.retention.Storable; import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.io.IOException; -import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -162,6 +159,12 @@ public T getCapability(Capability capability, EnumFacing facing) { return capabilityInstance != null ? capabilityInstance : super.getCapability(capability, facing); } + @Override + public void setPos(BlockPos pos) { + super.setPos(pos); + this.block.components.getOrAdd(new MCBlockTransform(this.block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); + } + private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { private final Packet packet; From 73503a87382b0a8fc160100ae7c9031e98139511 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sat, 17 Dec 2016 22:52:39 +0100 Subject: [PATCH 31/61] Minecraft 1.11 Wrappers --- minecraft/1.11/build.gradle | 10 +-- .../v1_11/depmodules/GameInfoModule.java | 2 +- .../forge/v1_11/launcher/FMLProgressBar.java | 10 ++- .../forge/v1_11/launcher/NovaMinecraft.java | 6 -- .../recipes/MinecraftItemIngredient.java | 2 +- .../recipes/MinecraftRecipeRegistry.java | 13 ++- .../forge/v1_11/recipes/RecipeConverter.java | 7 +- .../mc/forge/v1_11/render/RenderUtility.java | 61 +------------- .../mc/forge/v1_11/util/WrapUtility.java | 20 ++++- .../mc/forge/v1_11/util/WrapperEvent.java | 10 +-- .../v1_11/wrapper/block/BlockConverter.java | 5 +- .../v1_11/wrapper/block/backward/BWBlock.java | 15 +++- .../v1_11/wrapper/block/forward/FWBlock.java | 8 +- .../wrapper/block/forward/FWBlockSound.java | 6 +- .../v1_11/wrapper/block/forward/FWTile.java | 4 +- .../wrapper/block/forward/FWTileLoader.java | 1 - .../v1_11/wrapper/block/world/BWWorld.java | 8 +- .../wrapper/entity/backward/BWEntity.java | 12 +-- .../wrapper/entity/forward/FWEntity.java | 7 +- .../v1_11/wrapper/item/ItemConverter.java | 22 ++--- .../v1_11/wrapper/item/backward/BWItem.java | 2 +- .../v1_11/wrapper/item/forward/FWItem.java | 2 +- .../wrapper/item/forward/FWItemBlock.java | 13 +++ .../wrapper/render/backward/BWModel.java | 11 +-- .../render/forward/FWSmartBlockModel.java | 45 +++------- .../render/forward/FWSmartItemModel.java | 48 +++-------- .../wrapper/render/forward/FWSmartModel.java | 15 +++- .../resources/assets/nova/textures/NOVA.svg | 53 ------------ .../src/main/resources/fmlbranding.properties | 2 +- minecraft/1.11/src/main/resources/mcmod.info | 38 ++++----- .../mc/forge/v17/NovaMinecraftPreloader.java | 21 +---- .../mc/forge/v17/launcher/FMLProgressBar.java | 28 ------- .../mc/forge/v17/launcher/NovaMinecraft.java | 19 ++--- .../mc/forge/v17/recipes/MCCraftingGrid.java | 38 ++++----- .../mc/forge/v17/util/WrapperEvent.java | 71 ---------------- .../v17/wrapper/block/BlockConverter.java | 29 +------ .../v17/wrapper/block/backward/BWBlock.java | 3 - .../wrapper/block/forward/FWTileLoader.java | 5 -- .../forge/v17/wrapper/item/BWItemFactory.java | 3 - .../forge/v17/wrapper/item/ItemConverter.java | 33 +------- .../resources/assets/nova/textures/NOVA.png | Bin 8484 -> 0 bytes .../resources/assets/nova/textures/NOVA.svg | 53 ------------ .../src/main/resources/fmlbranding.properties | 1 - minecraft/1.7/src/main/resources/mcmod.info | 21 ----- .../mc/forge/v18/NovaMinecraftPreloader.java | 21 +---- .../mc/forge/v18/launcher/FMLProgressBar.java | 28 ------- .../mc/forge/v18/launcher/NovaMinecraft.java | 20 ++--- .../mc/forge/v18/recipes/MCCraftingGrid.java | 28 +++---- .../mc/forge/v18/util/WrapperEvent.java | 71 ---------------- .../v18/wrapper/block/BlockConverter.java | 30 +------ .../v18/wrapper/block/backward/BWBlock.java | 3 - .../wrapper/block/forward/FWTileLoader.java | 9 +- .../forge/v18/wrapper/item/BWItemFactory.java | 3 - .../forge/v18/wrapper/item/ItemConverter.java | 32 +------ .../resources/assets/nova/textures/NOVA.png | Bin 8484 -> 0 bytes .../resources/assets/nova/textures/NOVA.svg | 53 ------------ .../src/main/resources/fmlbranding.properties | 1 - minecraft/1.8/src/main/resources/mcmod.info | 21 ----- .../java/nova/core/util/Identifiable.java | 1 + .../java/nova/core/util/registry/Factory.java | 1 - .../nova/internal/core/launch/ModLoader.java | 28 ------- .../internal/core/launch/NovaLauncher.java | 10 +-- .../internal/core/launch/ProgressBar.java | 78 ------------------ 63 files changed, 233 insertions(+), 988 deletions(-) delete mode 100644 minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.svg delete mode 100644 minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java delete mode 100644 minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png delete mode 100644 minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.svg delete mode 100644 minecraft/1.7/src/main/resources/fmlbranding.properties delete mode 100644 minecraft/1.7/src/main/resources/mcmod.info delete mode 100644 minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java delete mode 100644 minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png delete mode 100644 minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.svg delete mode 100644 minecraft/1.8/src/main/resources/fmlbranding.properties delete mode 100644 minecraft/1.8/src/main/resources/mcmod.info delete mode 100644 src/main/java/nova/internal/core/launch/ProgressBar.java diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11/build.gradle index aade6345d..7b369edcd 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11/build.gradle @@ -107,9 +107,9 @@ minecraft { runDir = "run" } -reobfJar { - // TODO Figure out what this was replaced by in ForgeGrade 2.2 - //reobf(fatJar) {spec -> spec.classpath = configurations.compile} +reobf { + // TODO Figure out how to make this work with maven-publish (creates a new task 'reobfFatJar' that isn't compatible with maven-publish) + fatJar {classpath += configurations.compile} } runClient { @@ -125,11 +125,11 @@ processResources { inputs.property "mcversion", project.minecraft.version from(sourceSets.main.resources.srcDirs) { - include 'mcmod.info' + include 'mcmod.info', 'fmlbranding.properties' expand 'version': project.version, 'mcversion': project.minecraft.version } from(sourceSets.main.resources.srcDirs) { - exclude 'mcmod.info' + exclude 'mcmod.info', 'fmlbranding.properties' } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java index f36dd9b03..b6790d0b1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java @@ -27,7 +27,7 @@ import se.jbee.inject.bind.BinderModule; public class GameInfoModule extends BinderModule { - private static final GameInfo minecraft = new GameInfo("minecraft", "1.7.10"); + private static final GameInfo minecraft = new GameInfo("minecraft", "1.11"); @Override protected void declare() { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java index d23e24ace..3f350a87a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java @@ -12,7 +12,7 @@ * * @author ExE Boss */ -public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { +public class FMLProgressBar extends nova.core.util.AbstractProgressBar { private final ProgressBar progressBar; @@ -21,8 +21,14 @@ public FMLProgressBar(ProgressBar progressBar) { } @Override - public void step(String s) { + public void stepImpl(String s) { if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; this.progressBar.step(s); } + + @Override + protected void finishImpl() { + while (progressBar.getStep() < progressBar.getSteps()) + progressBar.step(""); + } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index f42a92d02..958fc60a7 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -154,8 +154,6 @@ public void preInit(FMLPreInitializationEvent evt) { ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); launcher.load(new FMLProgressBar(progressBar)); - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("null"); ProgressManager.pop(progressBar); /** @@ -205,8 +203,6 @@ public void init(FMLInitializationEvent evt) { proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); launcher.init(new FMLProgressBar(progressBar)); - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("null"); ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during init"); @@ -223,8 +219,6 @@ public void postInit(FMLPostInitializationEvent evt) { proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); launcher.postInit(new FMLProgressBar(progressBar)); - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("null"); ProgressManager.pop(progressBar); } catch (Exception e) { System.out.println("Error during postInit"); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java index a0581f4c2..f430a58f0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java @@ -29,6 +29,6 @@ */ public class MinecraftItemIngredient extends SpecificItemIngredient { public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) { - super(((Item) Game.natives().toNova(itemStack)).getID().asString()); // TODO? + super(((Item) Game.natives().toNova(itemStack)).getID()); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java index a90209919..af3f96b4a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java @@ -24,9 +24,8 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; -import nova.core.recipes.RecipeAddedEvent; +import nova.core.event.RecipeEvent; import nova.core.recipes.RecipeManager; -import nova.core.recipes.RecipeRemovedEvent; import nova.core.recipes.crafting.CraftingRecipe; import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; import nova.internal.core.Game; @@ -94,8 +93,8 @@ private IRecipe convert(CraftingRecipe recipe) { return RecipeConverter.toMinecraft(recipe); } - private void onNOVARecipeAdded(RecipeAddedEvent e) { - CraftingRecipe recipe = e.getRecipe(); + private void onNOVARecipeAdded(RecipeEvent.Add e) { + CraftingRecipe recipe = e.recipe; if (forwardWrappers.containsKey(recipe)) { return; } @@ -108,10 +107,10 @@ private void onNOVARecipeAdded(RecipeAddedEvent e) { CraftingManager.getInstance().getRecipeList().add(minecraftRecipe); } - private void onNOVARecipeRemoved(RecipeRemovedEvent e) { - IRecipe minecraftRecipe = forwardWrappers.get(e.getRecipe()); + private void onNOVARecipeRemoved(RecipeEvent.Remove e) { + IRecipe minecraftRecipe = forwardWrappers.get(e.recipe); - forwardWrappers.remove(e.getRecipe()); + forwardWrappers.remove(e.recipe); backwardWrappers.remove(minecraftRecipe); CraftingManager.getInstance().getRecipeList().remove(minecraftRecipe); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java index c93f6efe6..eb711986f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java @@ -84,11 +84,12 @@ private static ItemIngredient getIngredient(Object ingredient) { if (ingredient == null) { return null; } else if (ingredient instanceof ItemStack) { - return new SpecificItemIngredient(((Item) Game.natives().toNova(ingredient)).getID().asString()); // TODO? + return ((ItemStack) ingredient).isEmpty() ? null : ItemIngredient.forItem(net.minecraft.item.Item.REGISTRY.getNameForObject(((ItemStack) ingredient).getItem()).toString()); } else if (ingredient instanceof String) { - return new OreItemIngredient((String) ingredient); + return ItemIngredient.forDictionary((String) ingredient); } else if (ingredient instanceof List) { - String oreDictEntry = findOreDictEntryFor((List) ingredient); + @SuppressWarnings("unchecked") + String oreDictEntry = findOreDictEntryFor((List) ingredient); if (oreDictEntry == null) { return null; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index ba2bd62de..0c3d52672 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -23,30 +23,22 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockPart; -import net.minecraft.client.renderer.block.model.BlockPartFace; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.ItemModelGenerator; -import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.client.renderer.block.model.ModelRotation; -import net.minecraft.client.renderer.block.model.SimpleBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.IResource; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import nova.core.component.renderer.ItemRenderer; +import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; import nova.core.render.texture.BlockTexture; import nova.core.render.texture.ItemTexture; @@ -231,35 +223,8 @@ public void onModelBakeEvent(ModelBakeEvent event) { nova.core.item.Item dummy = item.getItemFactory().build(); - if (dummy.components.has(ItemRenderer.class)) { - Optional texture = dummy.components.get(ItemRenderer.class).texture; - - if (texture.isPresent()) { - MODEL_GENERATED.textures.put("layer0", texture.get().getResource()); - MODEL_GENERATED.name = itemLocation.toString(); - - // This is the key part, it takes the texture and makes the "3d" one wide voxel model - ModelBlock itemModel = ITEM_MODEL_GENERATOR.makeItemModel(new FakeTextureMap(dummy), MODEL_GENERATED); - - // This was taken from ModelBakery and simplified for the generation of our Items - SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(itemModel, ItemOverrideList.NONE).setTexture(getTexture(texture.get())); - for (BlockPart blockpart : (Iterable) itemModel.getElements()) { - for (EnumFacing enumfacing : (Iterable) blockpart.mapFaces.keySet()) { - BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing); - BakedQuad bakedQuad = FACE_BAKERY.makeBakedQuad(blockpart.positionFrom, blockpart.positionTo, blockpartface, getTexture(texture.get()), enumfacing, ModelRotation.X0_Y0, blockpart.partRotation, false, blockpart.shade); - - if (blockpartface.cullFace == null || !TRSRTransformation.isInteger(ModelRotation.X0_Y0.getMatrix())) { - builder.addGeneralQuad(bakedQuad); - } else { - - builder.addFaceQuad(ModelRotation.X0_Y0.rotate(blockpartface.cullFace), bakedQuad); - } - } - } - event.getModelRegistry().putObject(itemLocation, builder.makeBakedModel()); - } else { - event.getModelRegistry().putObject(itemLocation, new FWSmartItemModel(dummy)); - } + if (dummy.components.has(Renderer.class)) { + event.getModelRegistry().putObject(itemLocation, new FWSmartItemModel(dummy)); } } } @@ -278,24 +243,4 @@ public void preInit() { } }); } - - private class FakeTextureMap extends TextureMap { - private final nova.core.item.Item item; - - public FakeTextureMap(nova.core.item.Item item) { - super(""); - this.item = item; - } - - @Override - public TextureAtlasSprite getAtlasSprite(String iconName) { - if (item.components.has(ItemRenderer.class)) { - ItemRenderer itemRenderer = item.components.get(ItemRenderer.class); - if (itemRenderer.texture.isPresent()) { - return RenderUtility.instance.getTexture(itemRenderer.texture); - } - } - return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); - } - } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java index 5edb8daa0..26b530a73 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java @@ -22,7 +22,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import nova.core.entity.Entity; import nova.core.entity.component.Player; +import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.internal.core.Game; import java.util.Objects; import java.util.Optional; @@ -34,19 +37,28 @@ public class WrapUtility { public static Optional getNovaPlayer(EntityPlayer player) { - // TODO: implement - return Optional.empty(); + return ((Entity)Game.natives().toNova(player)).components.getOp(Player.class); } public static String getItemID(Item item, int meta) { if (item.getHasSubtypes()) { return Item.REGISTRY.getNameForObject(item) + ":" + meta; } else { - return (String) Objects.toString(Item.REGISTRY.getNameForObject(item)); + return Objects.toString(Item.REGISTRY.getNameForObject(item)); } } - public EntityPlayer getMCPlayer(Optional player) { + public static EntityPlayer getMCPlayer(Optional player) { + if (!player.isPresent()) + return null; + + Entity entity = player.get().entity(); + if (entity instanceof BWEntity) { + if (((BWEntity)entity).entity instanceof EntityPlayer) + return (EntityPlayer)((BWEntity)entity).entity; + } + + // TODO return null; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java index 0bfdb80c1..7f2feedac 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java @@ -108,9 +108,9 @@ public static class BWEntityCreate extends CancelableEvent { public final net.minecraft.entity.Entity mcEntity; public final BWEntity novaEntity; - public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { - this.mcEntity = mcEntity; + public BWEntityCreate(BWEntity novaEntity, net.minecraft.entity.Entity mcEntity) { this.novaEntity = novaEntity; + this.mcEntity = mcEntity; } } @@ -135,11 +135,11 @@ public FWTileCreate(Block novaBlock, FWTile tileEntity) { } public static class FWEntityCreate extends Event { - public final Entity novaBlock; + public final Entity novaEntity; public final FWEntity mcEntity; - public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { - this.novaBlock = novaBlock; + public FWEntityCreate(Entity novaEntity, FWEntity mcEntity) { + this.novaEntity = novaEntity; this.mcEntity = mcEntity; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java index 692c70029..7c8442567 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -25,7 +25,6 @@ import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.Block; import nova.core.block.BlockFactory; @@ -33,7 +32,6 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; @@ -41,7 +39,6 @@ import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItemBlock; import nova.internal.core.Game; -import nova.internal.core.launch.ModLoader; import java.util.Arrays; import java.util.HashMap; @@ -142,7 +139,7 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); FWItemBlock itemBlockWrapper = new FWItemBlock(blockWrapper); blockFactoryMap.put(blockFactory, blockWrapper); - String blockId = blockFactory.getID().asString(); // TODO? + String blockId = blockFactory.getID(); // TODO? ResourceLocation id = new ResourceLocation(blockId); GameRegistry.register(blockWrapper, id); GameRegistry.register(itemBlockWrapper, id); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 3d72ebaac..07633a8fa 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -77,9 +77,18 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { soundType = mcBlock.getSoundType(blockState(), (net.minecraft.world.World)getMcBlockAccess(), new BlockPos(x(), y(), z()), null); else soundType = mcBlock.getSoundType(); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", soundType.getPlaceSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", soundType.getBreakSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("",soundType.getStepSound().getSoundName().getResourcePath())); + + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, + new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), + soundType.getPlaceSound().getSoundName().getResourcePath())); + + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, + new Sound(soundType.getBreakSound().getSoundName().getResourceDomain(), + soundType.getBreakSound().getSoundName().getResourcePath())); + + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, + new Sound(soundType.getStepSound().getSoundName().getResourceDomain(), + soundType.getStepSound().getSoundName().getResourcePath())); components.add(new LightEmitter()).setEmittedLevel(() -> blockState().getLightValue(getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); components.add(new Collider(this)) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java index 418f89eb6..99d32ea39 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -99,7 +99,7 @@ public FWBlock(BlockFactory factory) { this.blockSoundType = SoundType.STONE; } this.blockClass = dummy.getClass(); - this.setUnlocalizedName(dummy.getID().asString()); // TODO? + this.setUnlocalizedName(dummy.getID()); // Recalculate super constructor things after loading the block properly this.fullBlock = getDefaultState().isOpaqueCube(); @@ -107,6 +107,10 @@ public FWBlock(BlockFactory factory) { this.translucent = !this.fullBlock; } + public BlockFactory getFactory() { + return this.factory; + } + public Block getBlockInstance(IBlockAccess access, Vector3D position) { /** * If this block has a TileEntity, forward the method into the Stateful @@ -179,7 +183,7 @@ public boolean hasTileEntity(IBlockState state) { @Override public TileEntity createTileEntity(World world, IBlockState state) { - return FWTileLoader.loadTile(dummy.getID().asString()); // TODO? + return FWTileLoader.loadTile(dummy.getID()); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java index 5107fc0ff..aa1981bc0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java @@ -30,7 +30,7 @@ public SoundEvent getBreakSound() { SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("dig." + sound.name)); return event == null ? super.getPlaceSound() : event; } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); return event == null ? super.getPlaceSound() : event; } return super.getBreakSound(); @@ -44,7 +44,7 @@ public SoundEvent getStepSound() { SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("step." + sound.name)); return event == null ? super.getPlaceSound() : event; } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); return event == null ? super.getPlaceSound() : event; } return super.getStepSound(); @@ -58,7 +58,7 @@ public SoundEvent getPlaceSound() { SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.name)); return event == null ? super.getPlaceSound() : event; } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())); // TODO? + SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); return event == null ? super.getPlaceSound() : event; } // By default MC uses the block break sound for block placement diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java index 9c45c3f2e..74afd64b1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java @@ -162,7 +162,9 @@ public T getCapability(Capability capability, EnumFacing facing) { @Override public void setPos(BlockPos pos) { super.setPos(pos); - this.block.components.getOrAdd(new MCBlockTransform(this.block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); + if (this.block.components.has(MCBlockTransform.class)) + this.block.components.remove(MCBlockTransform.class); + this.block.components.add(new MCBlockTransform(this.block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); } private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java index 3c50ae2fd..cf7e53f08 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java @@ -29,7 +29,6 @@ import nova.core.util.Direction; import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.fluid.forward.FWFluidTank; import nova.internal.core.Game; import java.util.Arrays; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java index 5d5798496..36a6055bf 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java @@ -31,8 +31,6 @@ import nova.core.entity.EntityFactory; import nova.core.item.Item; import nova.core.sound.Sound; -import nova.core.util.id.Identifier; -import nova.core.util.id.StringIdentifier; import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; @@ -160,12 +158,12 @@ public Optional getEntity(String uniqueID) { } @Override - public Identifier getID() { - return new StringIdentifier(world().provider.getDimensionType().getName()); + public String getID() { + return world().provider.getDimensionType().getName(); } @Override public void playSoundAtPosition(Vector3D position, Sound sound) { - world().playSound(position.getX(), position.getY(), position.getZ(), SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID().asString())), SoundCategory.BLOCKS, sound.volume, sound.pitch, true); + world().playSound(position.getX(), position.getY(), position.getZ(), SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())), SoundCategory.BLOCKS, sound.volume, sound.pitch, true); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java index 5c2b4046c..97842c06f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java @@ -28,10 +28,10 @@ import nova.core.entity.Entity; import nova.core.entity.component.Living; import nova.core.entity.component.Player; -import nova.core.util.id.Identifier; -import nova.core.util.id.UUIDIdentifier; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; import nova.core.wrapper.mc.forge.v1_11.wrapper.inventory.BWInventory; +import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; /** @@ -47,7 +47,6 @@ public BWEntity(net.minecraft.entity.Entity entity) { this.entity = entity; if (entity != null) { components.add(new MCEntityTransform(entity)); - components.add(new Damageable() { @Override public void damage(double amount, DamageType type) { @@ -68,6 +67,9 @@ public void damage(double amount, DamageType type) { living.faceDisplacement = () -> Vector3D.PLUS_J.scalarMultiply(entity.getEyeHeight()); } } + + WrapperEvent.BWEntityCreate event = new WrapperEvent.BWEntityCreate(this, entity); + Game.events().publish(event); } public static class MCPlayer extends Player { @@ -92,8 +94,8 @@ public String getUsername() { } @Override - public Identifier getID() { - return new UUIDIdentifier(entity.getGameProfile().getId()); + public String getID() { + return entity.getGameProfile().getId().toString(); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java index 682b1357c..b66b3d077 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java @@ -36,6 +36,7 @@ import nova.core.retention.Storable; import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; import nova.internal.core.Game; @@ -84,13 +85,13 @@ protected void writeEntityToNBT(NBTTagCompound nbt) { ((Storable) wrapped).save(data); DataWrapper.instance().toNative(nbt, data); } - nbt.setString("novaID", wrapped.getID().asString()); // TODO? + nbt.setString("novaID", wrapped.getID()); } @Override public void writeSpawnData(ByteBuf buffer) { //Write the ID of the entity to client - String id = wrapped.getID().asString(); // TODO? + String id = wrapped.getID(); char[] chars = id.toCharArray(); buffer.writeInt(chars.length); @@ -132,6 +133,8 @@ protected void entityInit() { if (wrapped != null) { wrapped.events.publish(new Stateful.LoadEvent()); updateCollider(); + WrapperEvent.FWEntityCreate event = new WrapperEvent.FWEntityCreate(wrapped, this); + Game.events().publish(event); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index ae28f96cf..0889f48dc 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -37,7 +37,7 @@ import nova.core.item.ItemBlock; import nova.core.item.ItemFactory; import nova.core.item.ItemManager; -import nova.core.item.event.ItemIDNotFoundEvent; +import nova.core.event.ItemEvent; import nova.core.loader.Loadable; import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; @@ -116,7 +116,7 @@ public ItemStack toNative(Item item) { if (item instanceof BWItem) { return ((BWItem) item).makeItemStack(item.count()); } else { - ItemFactory itemFactory = Game.items().get(item.getID().asString()).get();// TODO? + ItemFactory itemFactory = Game.items().get(item.getID()).get();// TODO? FWNBTTagCompound tag = new FWNBTTagCompound(item); MinecraftItemMapping mapping = get(itemFactory); @@ -185,10 +185,10 @@ public void preInit() { private void registerNOVAItemsToMinecraft() { //There should be no items registered during Native Converter preInit() // item.registry.forEach(this::registerNOVAItem); - Game.events().on(ItemManager.ItemRegistrationEvent.class).bind(this::onItemRegistered); + Game.events().on(ItemEvent.Register.class).bind(this::onItemRegistered); } - private void onItemRegistered(ItemManager.ItemRegistrationEvent event) { + private void onItemRegistered(ItemEvent.Register event) { registerNOVAItem(event.itemFactory); } @@ -208,9 +208,9 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } - if (!itemFactory.getID().asString().equals(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)))) { + if (!itemFactory.getID().equals(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)))) { System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); - net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString()); + net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID()); itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; } } else { @@ -223,7 +223,7 @@ private void registerNOVAItem(ItemFactory itemFactory) { // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - String itemId = itemFactory.getID().asString(); // TODO? + String itemId = itemFactory.getID(); // TODO? GameRegistry.register(itemWrapper, new ResourceLocation(itemId)); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { @@ -246,18 +246,18 @@ private void registerNOVAItem(ItemFactory itemFactory) { } private void registerMinecraftItemsToNOVA() { - Set itemIDs = (Set) net.minecraft.item.Item.REGISTRY.getKeys(); + Set itemIDs = net.minecraft.item.Item.REGISTRY.getKeys(); itemIDs.forEach(itemID -> { - net.minecraft.item.Item item = (net.minecraft.item.Item) net.minecraft.item.Item.REGISTRY.getObject(itemID); + net.minecraft.item.Item item = net.minecraft.item.Item.REGISTRY.getObject(itemID); registerMinecraftMapping(item, 0); }); } private void registerSubtypeResolution() { - Game.events().on(ItemIDNotFoundEvent.class).bind(this::onIDNotFound); + Game.events().on(ItemEvent.IDNotFound.class).bind(this::onIDNotFound); } - private void onIDNotFound(ItemIDNotFoundEvent event) { + private void onIDNotFound(ItemEvent.IDNotFound event) { // if item minecraft:planks:2 is detected, this code will register minecraft:planks:2 dynamically // we cannot do this up front since there is **NO** reliable way to get the sub-items of an item diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java index 6749b1c09..c9b7b9e92 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java @@ -66,6 +66,6 @@ public ItemStack makeItemStack(int stackSize) { @Override public String toString() { - return getID().asString(); // TODO? + return getID(); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java index e31c38762..c0deadc88 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java @@ -48,7 +48,7 @@ public class FWItem extends net.minecraft.item.Item implements ItemWrapperMethod public FWItem(ItemFactory item) { this.itemFactory = item; - setUnlocalizedName(item.getID().asString()); // TODO? + setUnlocalizedName(item.getID()); setMaxStackSize(item.build().getMaxCount()); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java index fe69172be..485de5912 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java @@ -22,14 +22,20 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import nova.core.item.Item; import nova.core.item.ItemFactory; +import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; +import nova.internal.core.Game; import java.util.List; @@ -42,6 +48,13 @@ public FWItemBlock(FWBlock block) { super(block); } + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + Item item = Game.natives().toNova(stack); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); + return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; + } + @Override public ItemFactory getItemFactory() { return ((FWBlock) block).dummy.getItemFactory(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java index 23341fca9..af26d076d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java @@ -20,24 +20,16 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import nova.core.render.model.MeshModel; import nova.core.render.texture.EntityTexture; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import java.lang.reflect.Constructor; -import java.util.BitSet; import java.util.Optional; /** @@ -63,8 +55,7 @@ public void render(Optional entityRenderManager) { System.out.println(model); if (model instanceof MeshModel) { MeshModel meshModel = (MeshModel) model; - meshModel.faces.forEach(face -> - { + meshModel.faces.forEach(face -> { System.out.println(face); // TODO: See if this works, and possibly fix it // Brightness is defined as: skyLight << 20 | blockLight << 4 diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java index a52a64b1e..24c4da890 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java @@ -27,16 +27,10 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import nova.core.block.Block; -import nova.core.component.renderer.ItemRenderer; +import nova.core.component.renderer.DynamicRenderer; import nova.core.component.renderer.StaticRenderer; -import nova.core.item.ItemBlock; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.internal.core.Game; import org.lwjgl.util.vector.Vector3f; import java.util.List; @@ -75,38 +69,23 @@ public FWSmartBlockModel(Block block, boolean isDummy) { @Override public List getQuads(IBlockState state, EnumFacing side, long rand) { - BWModel blockModel = new BWModel(); - blockModel.matrix.translate(0.5, 0.5, 0.5); + BWModel model = new BWModel(); + model.matrix.translate(0.5, 0.5, 0.5); if (isItem) { - ItemRenderer renderer = block.components.get(ItemRenderer.class); - renderer.onRender.accept(blockModel); + if (block.components.has(StaticRenderer.class)) { + StaticRenderer staticRenderer = block.components.get(StaticRenderer.class); + staticRenderer.onRender.accept(model); + } else if (block.components.has(DynamicRenderer.class)) { + DynamicRenderer dynamicRenderer = block.components.get(DynamicRenderer.class); + dynamicRenderer.onRender.accept(model); + } } else { StaticRenderer renderer = block.components.get(StaticRenderer.class); - renderer.onRender.accept(blockModel); - } - - return modelToQuads(blockModel); - } - - @Override - public TextureAtlasSprite getParticleTexture() { - /* - if (block.components.has(StaticRenderer.class)) { - Optional apply = block.components.get(StaticRenderer.class).texture.apply(Direction.UNKNOWN); - if (apply.isPresent()) { - return RenderUtility.instance.getTexture(apply.components.get()); - } - }*/ - - if (block.components.has(ItemRenderer.class)) { - ItemRenderer itemRenderer = block.components.get(ItemRenderer.class); - if (itemRenderer.texture.isPresent()) { - return RenderUtility.instance.getTexture(itemRenderer.texture.get()); - } + renderer.onRender.accept(model); } - return null; + return modelToQuads(model); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java index 5b3393209..c1ced7d18 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java @@ -27,16 +27,13 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; -import nova.core.component.renderer.ItemRenderer; +import nova.core.component.renderer.DynamicRenderer; +import nova.core.component.renderer.Renderer; +import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.internal.core.Game; import org.lwjgl.util.vector.Vector3f; -import java.util.Collections; import java.util.List; /** @@ -60,44 +57,25 @@ public FWSmartItemModel(Item item) { ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); } - public IBakedModel handleItemState(ItemStack stack) { - Item item = Game.natives().toNova(stack); - - if (item.components.has(ItemRenderer.class)) { - return new FWSmartItemModel(item); - } - - return this; - } - @Override public List getQuads(IBlockState state, EnumFacing side, long rand) { - if (item.components.has(ItemRenderer.class)) { - BWModel model = new BWModel(); - ItemRenderer renderer = item.components.get(ItemRenderer.class); - model.matrix.translate(0.5, 0.5, 0.5); - renderer.onRender.accept(model); - return modelToQuads(model); - } - - return Collections.emptyList(); - } + BWModel model = new BWModel(); + model.matrix.translate(0.5, 0.5, 0.5); - @Override - public TextureAtlasSprite getParticleTexture() { - if (item.components.has(ItemRenderer.class)) { - ItemRenderer itemRenderer = item.components.get(ItemRenderer.class); - if (itemRenderer.texture.isPresent()) { - return RenderUtility.instance.getTexture(itemRenderer.texture.get()); - } + if (item.components.has(StaticRenderer.class)) { + StaticRenderer staticRenderer = item.components.get(StaticRenderer.class); + staticRenderer.onRender.accept(model); + } else if (item.components.has(DynamicRenderer.class)) { + DynamicRenderer dynamicRenderer = item.components.get(DynamicRenderer.class); + dynamicRenderer.onRender.accept(model); } - return null; + return modelToQuads(model); } @Override public boolean isGui3d() { - return item.components.has(ItemRenderer.class); + return item.components.has(Renderer.class); } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java index 1c050f6f0..9b3307a81 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java @@ -22,6 +22,7 @@ import com.google.common.primitives.Ints; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureUtil; @@ -31,6 +32,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.EnumFacing; +import nova.core.render.model.CustomModel; import nova.core.render.model.MeshModel; import nova.core.render.model.Model; import nova.core.render.model.Vertex; @@ -54,11 +56,9 @@ public abstract class FWSmartModel implements IBakedModel { public FWSmartModel() { this.format = new VertexFormat(); - this.format.addElement(DefaultVertexFormats.POSITION_3F); this.format.addElement(DefaultVertexFormats.COLOR_4UB); this.format.addElement(DefaultVertexFormats.TEX_2F); - this.format.addElement(DefaultVertexFormats.PADDING_1B); } public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture) { @@ -69,7 +69,6 @@ public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture) { vertex.color.rgba(), Float.floatToRawIntBits(texture.getInterpolatedU(16 * vertex.uv.getX())), Float.floatToRawIntBits(texture.getInterpolatedV(16 * vertex.uv.getY())), - 0 }; } @@ -85,9 +84,11 @@ protected List modelToQuads(Model modelIn) { .stream() .map( face -> { + TextureAtlasSprite texture = face.texture.map(RenderUtility.instance::getTexture) + .orElse(Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()); List vertexData = face.vertices .stream() - .map(v -> vertexToInts(v, RenderUtility.instance.getTexture(face.texture))) + .map(v -> vertexToInts(v, texture)) .collect(Collectors.toList()); int[] data = Ints.concat(vertexData.toArray(new int[][] {})); @@ -124,6 +125,12 @@ public boolean isBuiltInRenderer() { } @Override + public TextureAtlasSprite getParticleTexture() { + return null; + } + + @Override + @Deprecated public ItemCameraTransforms getItemCameraTransforms() { return itemCameraTransforms; } diff --git a/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.svg b/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.svg deleted file mode 100644 index 2ff05fe43..000000000 --- a/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - NOVA - - - - - - - - diff --git a/minecraft/1.11/src/main/resources/fmlbranding.properties b/minecraft/1.11/src/main/resources/fmlbranding.properties index d0872c237..d8ae8b040 100644 --- a/minecraft/1.11/src/main/resources/fmlbranding.properties +++ b/minecraft/1.11/src/main/resources/fmlbranding.properties @@ -1 +1 @@ -fmlbranding=NOVA 0.0.1-SNAPSHOT +fmlbranding=${version} diff --git a/minecraft/1.11/src/main/resources/mcmod.info b/minecraft/1.11/src/main/resources/mcmod.info index 6b534e351..5364e1dc9 100644 --- a/minecraft/1.11/src/main/resources/mcmod.info +++ b/minecraft/1.11/src/main/resources/mcmod.info @@ -1,21 +1,21 @@ { - "modListVersion": 2, - "modList": [{ - "modid": "nova", - "name": "NOVA", - "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", - "version": "0.0.1", - "mcversion": "1.11", - "url": "https://novaapi.net/", - "updateUrl": "", - "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], - "credits": "Created by the NOVA Team.\nPorted to Minecraft 1.11 by: ExE Boss.", - "logoFile": "/assets/nova/textures/NOVA.png", - "screenshots": [], - "parent": "", - "requiredMods": [], - "dependencies": [], - "dependants": [], - "useDependencyInformation": true - }] + "modListVersion": 2, + "modList": [{ + "modid": "nova", + "name": "NOVA", + "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "https://novaapi.net/", + "updateUrl": "", + "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], + "credits": "Created by the NOVA Team.\nPorted to Minecraft 1.11 by: ExE Boss.", + "logoFile": "/assets/nova/textures/NOVA.png", + "screenshots": [], + "parent": "", + "requiredMods": [], + "dependencies": [], + "dependants": [], + "useDependencyInformation": true + }] } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java index 27cd702cd..11e41dcee 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/NovaMinecraftPreloader.java @@ -53,7 +53,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -67,7 +66,6 @@ public class NovaMinecraftPreloader extends DummyModContainer { public static final String version = "0.0.1"; private static final ModMetadata md; public static Set> modClasses; - public static Map, File> modClassToFile; static { md = new ModMetadata(); @@ -210,7 +208,6 @@ public void load(FMLConstructionEvent event) { // Scan mod classes ASMDataTable asmData = event.getASMHarvestedData(); - modClassToFile = new HashMap<>(); modClasses = asmData .getAll(Mod.class.getName()) .stream() @@ -235,7 +232,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta, mod)); + newMods.add(new DummyNovaMod(fakeMeta)); }); ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -280,7 +277,6 @@ public void registerResourcePacks() { packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); System.out.println("Registered NOVA jar resource pack: " + fn); } - modClassToFile.put(c, file); } 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(); @@ -292,7 +288,6 @@ public void registerResourcePacks() { folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); } - modClassToFile.put(c, folderFile); addedPacks.add(folderLocation); packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); @@ -309,20 +304,8 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class DummyNovaMod extends DummyModContainer { - private final Class mod; - private File source = null; - - public DummyNovaMod(ModMetadata meta, Class mod) { + public DummyNovaMod(ModMetadata meta) { super(meta); - this.mod = mod; - } - - @Override - public File getSource() { - if (this.source == null) { - this.source = NovaMinecraftPreloader.modClassToFile.get(mod); - } - return this.source; } } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java deleted file mode 100644 index 10de8097b..000000000 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/FMLProgressBar.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nova.core.wrapper.mc.forge.v17.launcher; - -import cpw.mods.fml.common.ProgressManager.ProgressBar; - -/** - * Wrapper class for FML progress bar that is shown when Minecraft boots. - * - * @author ExE Boss - */ -public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { - - private final ProgressBar progressBar; - - public FMLProgressBar(ProgressBar progressBar) { - this.progressBar = progressBar; - } - - @Override - public void step(String s) { - if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; - this.progressBar.step(s); - } -} diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java index 37db3a7ef..5201d012d 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/launcher/NovaMinecraft.java @@ -22,8 +22,6 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.ProgressManager; -import cpw.mods.fml.common.ProgressManager.ProgressBar; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; @@ -144,9 +142,7 @@ public void preInit(FMLPreInitializationEvent evt) { e.printStackTrace(); } - ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size()); - launcher.postInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.load(); /** * Instantiate native loaders @@ -161,9 +157,7 @@ public void preInit(FMLPreInitializationEvent evt) { Game.language().init(); //Load preInit - progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size()); - launcher.preInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.preInit(); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -189,11 +183,10 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size()); + proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.init(); } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -204,12 +197,10 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size()); Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.postInit(); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java index 01eb6f266..34c893dda 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/recipes/MCCraftingGrid.java @@ -183,20 +183,20 @@ public boolean setStack(int x, int y, Optional stack) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (stack.isPresent()) { - if (!stack.get().equals(stacks[ix])) { - inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); + if (!stack.equals(stacks[ix])) { + if (stack.isPresent()) { + inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); - if (stacks[ix] == null) { - numberOfStacks++; - } + if (stacks[ix] == null) { + numberOfStacks++; + } - stacks[ix] = stack.get(); + stacks[ix] = stack.get(); + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; } - } else { - numberOfStacks--; - inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; } return true; @@ -206,14 +206,7 @@ public boolean setStack(int x, int y, Optional stack) { public boolean setStack(int i, Optional stack) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack.isPresent()) { - if (stacks[i] == null) { - numberOfStacks++; - } - - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); - } else { + if (stack == null) { if (stacks[i] == null) { return true; } @@ -221,6 +214,13 @@ public boolean setStack(int i, Optional stack) { numberOfStacks--; inventory.setInventorySlotContents(i, null); stacks[i] = null; + } else { + if (stacks[i] == null) { + numberOfStacks++; + } + + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); } return true; diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java index cb3044ce9..eff9a048c 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/util/WrapperEvent.java @@ -20,23 +20,11 @@ package nova.core.wrapper.mc.forge.v17.util; -import net.minecraft.item.ItemStack; -import nova.core.block.Block; -import nova.core.entity.Entity; import nova.core.event.BlockEvent; -import nova.core.event.bus.CancelableEvent; -import nova.core.event.bus.Event; import nova.core.util.Direction; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v17.wrapper.block.backward.BWBlock; -import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v17.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v17.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import java.util.Optional; - /** * @author Calclavia */ @@ -71,63 +59,4 @@ public WeakRedstone(World world, Vector3D position, Direction direction) { this.direction = direction; } } - - public static class BWBlockCreate extends BlockEvent { - public final net.minecraft.block.Block mcBlock; - public final BWBlock novaBlock; - - public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.minecraft.block.Block mcBlock) { - super(world, position); - this.novaBlock = novaBlock; - this.mcBlock = mcBlock; - } - } - - public static class BWItemCreate extends CancelableEvent { - public final net.minecraft.item.Item mcItem; - public final BWItem novaItem; - public final Optional itemStack; - - public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { - this.novaItem = novaItem; - this.mcItem = mcItem; - this.itemStack = Optional.empty(); - } - - public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem, ItemStack itemStack) { - this.novaItem = novaItem; - this.mcItem = mcItem; - this.itemStack = Optional.of(itemStack); - } - } - - public static class BWEntityCreate extends CancelableEvent { - public final net.minecraft.entity.Entity mcEntity; - public final BWEntity novaEntity; - - public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { - this.mcEntity = mcEntity; - this.novaEntity = novaEntity; - } - } - - public static class FWTileCreate extends Event { - public final Block novaBlock; - public final FWTile tileEntity; - - public FWTileCreate(Block novaBlock, FWTile tileEntity) { - this.novaBlock = novaBlock; - this.tileEntity = tileEntity; - } - } - - public static class FWEntityCreate extends Event { - public final Entity novaBlock; - public final FWEntity mcEntity; - - public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { - this.novaBlock = novaBlock; - this.mcEntity = mcEntity; - } - } } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java index 37b315547..58b2c817a 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/BlockConverter.java @@ -21,8 +21,6 @@ package nova.core.wrapper.mc.forge.v17.wrapper.block; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; @@ -33,7 +31,6 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v17.util.ModCreativeTab; @@ -41,9 +38,7 @@ import nova.core.wrapper.mc.forge.v17.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v17.wrapper.item.FWItemBlock; import nova.internal.core.Game; -import nova.internal.core.launch.ModLoader; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Optional; @@ -141,9 +136,7 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); NovaMinecraft.proxy.registerBlock(blockWrapper); - String blockId = blockFactory.getID(); -// GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId.contains(":") ? blockId : modId + ":" + blockId); - registerNovaBlock(blockWrapper, blockId); + GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID()); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -162,24 +155,4 @@ private void registerNovaBlock(BlockFactory blockFactory) { System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); } - - /** - * Prevent forge from prefixing block IDs with "nova:" - */ - private void registerNovaBlock(FWBlock blockWrapper, String blockId) { - try { - Class gameDataClass = GameData.class; - Method getMain = gameDataClass.getDeclaredMethod("getMain"); - Method registerBlock = gameDataClass.getDeclaredMethod("registerBlock", net.minecraft.block.Block.class, String.class, Integer.TYPE); - Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); - getMain.setAccessible(true); - registerBlock.setAccessible(true); - registerItem.setAccessible(true); - GameData gameData = (GameData) getMain.invoke(null); - registerBlock.invoke(gameData, blockWrapper, blockId, -1); - registerItem.invoke(gameData, new FWItemBlock(blockWrapper), blockId, -1); - } catch (ReflectiveOperationException e) { - GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId); - } - } } \ No newline at end of file diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java index b1870876b..20d6a7a56 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java @@ -40,7 +40,6 @@ import nova.core.retention.Store; import nova.core.util.shape.Cuboid; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -86,8 +85,6 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { }); components.add(new StaticRenderer()) .onRender(model -> model.addChild(new CustomModel(self -> RenderBlocks.getInstance().renderStandardBlock(mcBlock, x(), y(), z())))); - WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); - Game.events().publish(event); //TODO: Set selection bounds } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java index 8a25e7b0a..64c75e154 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/forward/FWTileLoader.java @@ -24,7 +24,6 @@ import nova.core.block.Block; import nova.core.block.BlockFactory; import nova.core.wrapper.mc.forge.v17.asm.lib.ComponentInjector; -import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.internal.core.Game; import java.util.Optional; @@ -45,8 +44,6 @@ public static FWTile loadTile(NBTTagCompound data) { Block block = createBlock(blockID); FWTile tile = injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); - WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); - Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); @@ -58,8 +55,6 @@ public static FWTile loadTile(String blockID) { Block block = createBlock(blockID); FWTile tile = injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); - WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); - Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java index 0e07b06b6..fa9f5ae35 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItemFactory.java @@ -25,7 +25,6 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; -import nova.core.wrapper.mc.forge.v17.util.WrapperEvent; import nova.internal.core.Game; /** @@ -58,8 +57,6 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); - WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); - Game.events().publish(event); return bwItem; } diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java index f0bcc5e5f..969162193 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/ItemConverter.java @@ -22,8 +22,6 @@ import com.google.common.collect.HashBiMap; import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; @@ -35,7 +33,6 @@ import nova.core.item.ItemManager; import nova.core.item.event.ItemIDNotFoundEvent; import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v17.launcher.NovaMinecraft; @@ -43,9 +40,7 @@ import nova.core.wrapper.mc.forge.v17.wrapper.block.BlockConverter; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; -import nova.internal.core.launch.ModLoader; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -197,24 +192,17 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } - if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) { - System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); - net.minecraft.item.Item newItemWrapper = (net.minecraft.item.Item)net.minecraft.item.Item.itemRegistry.getObject(itemFactory.getID().asString()); - itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; - } } else { itemWrapper = new FWItem(itemFactory); } MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); - map.forcePut(itemFactory, minecraftItemMapping); + map.put(itemFactory, minecraftItemMapping); // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - String itemId = itemFactory.getID(); - //GameRegistry.registerItem(itemWrapper, itemId); - registerNovaItem((FWItem) itemWrapper, itemId); + GameRegistry.registerItem(itemWrapper, itemFactory.getID()); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -235,23 +223,6 @@ private void registerNOVAItem(ItemFactory itemFactory) { } } - /** - * Prevent forge from prefixing item IDs with "nova:" - */ - private void registerNovaItem(FWItem itemWrapper, String blockId) { - try { - Class gameDataClass = GameData.class; - Method getMain = gameDataClass.getDeclaredMethod("getMain"); - Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); - getMain.setAccessible(true); - registerItem.setAccessible(true); - GameData gameData = (GameData) getMain.invoke(null); - registerItem.invoke(gameData, itemWrapper, blockId, -1); - } catch (ReflectiveOperationException e) { - GameRegistry.registerItem(itemWrapper, blockId); - } - } - private void registerMinecraftItemsToNOVA() { Set itemIDs = (Set) net.minecraft.item.Item.itemRegistry.getKeys(); itemIDs.forEach(itemID -> { diff --git a/minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.7/src/main/resources/assets/nova/textures/NOVA.png deleted file mode 100644 index 1f42e113ce5dbaa9b1bc62df36b8d523f52b5ae5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8484 zcmd6NhdY)3|NnhZW^rsn#zDzGl}&MkGD0Xb9UZdw$T}H0M&3roF^(ch65`k^;~>Z0 zd++UtWPR^G|HSX-x*VMAT(A4(^?W`b>%Jo&>uOw~;iLfo;EI+e!Tc8yWz#kMIs#;H|z^?!*8w~h2wX5bc4*^Rx_Z z+Wg9{?<45%xlzRlX^rITGLb<`;$_x}U*KO_ciMWgV&OT8N%ubR!KRE>jD57xH$q2w zqr~54(Y#VW-Fxs8<{9GmJ7<0SILGBFhj#yv#mS_9L8*#ERkC>Ej+|EY$za_{Mj(*; z-r(WQ|MxF<`W{a*J!T4(T7C{hz)4Wt3OAJEr#63@F5(>^Bt`lOTu${vW6GsT0NMni zsE5$YGsw^DT-v7{9(Vs1%#izDoX&o8xhs97cW}^?4w?zfQUGmazM=OHB+<$MJ;ay2 zQEhm9<&t}n0aEgN_)m5Z6?EuV?hI_v@4$;#dk^zYRH?8e>5hS4`duga@`{QISQ6VM zB$1gvt%vvw$Ro3hv0Kdpo&tUjTSWq#9z`)yE|+)7JG4tmv>nE>A_S8ruseWc)pj0ZBnjOj0)NYu- z-b0#B>{*e~L{-0tsiJQb4nwNg6$U<$E#)VqT9N&Udpzk{Wv-lEQ*)yJv3Ar~>c5#) zKTEyL=wpVd^W1;mGS9E2IlOuqh1lbS=o{^0G#d%V|OOn&aSFS;EyA^xgm zL(my7eC8&XziWR~@7C6q7s4~vb+i2E&z~W#DD@br>y*3GRBsdB}B_$0MfsOno}3v+Aqo=jWGzX&6=uaceylR3-omMUUieZ{>hAR4Sg6G^-adQ~p)`SW|HukO%jS+WDOmEc7$xQ}4= zV+n$fu0G5g*nrgD+OBGOhj9moBf6>bx@m4%$4rnRd?VhM9*b3+g5 z1^a7Vp+vVIkfz)g2|D&?PA*p}i1{>2?sD|^Aop~3^1RVNfJ%DTc^x7Z?~TEHQlMzF z3{&1~VHyBF$=s}!f7So#X;k->D_0&tPIb7DBlB-6OrNp?&(l`?rU4j zvLG4I=H6hTY;pd-Yyg2&OMmJ9?l#zxz6=yQyNWwXKrE%}Rd_IYBRymj;~V=5Rd4vU zjS(71&-9Hdu$?ag!qU%RaL%tHwvukMC zi#HCcl|CwLb8!-oN+qh0?iVG0WJON+j(4{&7;y&YRM5;$A_u~w{)G^_R%&@+c>JS% z$o}!EAtBYW-J3^gnw?b7zVpGgZ_g_{l&Jr*bWBg0(lxN8m{(h?$nH>Hx+9X{>A@qW*X_@VVldLjyR3*PCUP<;)x+zTuD9Xu>@Db4TQIw2agE?KaaI)BU^EMg_)atw(1C8|&+_&zG<9o<^Z0 z#5--Ijb!Ly+0H1o}!cv;vYC}kK;ROY>i=}r$X6BoNy~1XBw^AwA4k*+JgFe<#Nkg zS~fA*7UGB;59;_}Z9rvcXz2I11vkrulOUJ;C-Rr?6*XHgJCFTXin3Qz?5Ux?$19no zr2e{Q;@h**ZVJ~gHbU^366dMv%mi$bowGCU7cndL_2ikat(DbG-aHN=Xb%o36b}|J zt&&lSW-gH8d-;Jh`cWaCt;Nm6OHZ%o7I2Qkm|L#z<9GLy-8xrDdXPVny#d||VEvWn zh=FOETX?WwDb}B?j1yWccfKIH#OZ)W;z)UUInQoHMY8BKcLuoC_6;1w99391tskWR z4X;KFxCTlW#3`g9Ai%Y(_u$qn!P z8FTX2!XfvN3>24;+WpEb2zyu8-50=sxec6@vS7*VT{@gB<2+eO*Ju&@w(|L0Q@9a# z$cyDWz`5w{tSPKM%f|`63uWbGlX{SOdC;(PK&Xer*sxST%yt>@rF^hGTUZqYV@wt^ z8(!VDc^R>D!apIG8+K{uF7Tfm#^q~4K}}g2dbi`Vnw@fuoP=tGaAxjIn+rEP`;C7E zq&9nUgnZVoLevclhXBjhkjmGOVDrTuE8Q=F=~Z5EmKn$NrcG;6RgGUE{}n?Mvl ze6Vw%xHD<5M^Q8QuNiWxf6<}7e@)UXc^bgkc&17k+mcODUyU5JQ~-$zGM43J2Jxg? zeuI^Gw9i6ddS$IizIvO$#dw6sX5^Wc)0I!bHe~dyWWDcBT0S}F27-7qA0eE`q{OES z6<)P*vu5V1SYMPq6+NW3jTM>1xRu)oK?|uuX0OEs(kRk3u7&tz3;mB5A-ze9Nl!WW|+D?*GRzSaJZgX@$>set*1KacMBoA!XJ+}%Lmn=@&Tp{XSm3My2IYy z-eUk}rbn^leoO#Sh!VKCnMw=u-B?GMfnaZgs+Zo@LbRyg-@k5wvr9%51`2IDi{yW- zuRkZ+lfCx$e}s7dC$U!;=lf#(CttD2XKgH_U!Rpe3!J~%76x8!3?v&EOSFTI_tnvtl#O^7JNbw1oX~IX zHE^I02G;uRd%7#*!oq(V`7fyfiv>=x$xj$nDlKgt3=I=IlbLk=a7Tf2?agcwmZ!t^ zYFu>=Y&TUSf|b{%mFS;31m6O83C@gMTpc|*P#-J z6MXyRz8{VwJmqY%KFA;!EfX)S{|T^EzuZ|_-t6dR^0$%Dlcq)@Id0`8Uky#eTTFdw zhmCnfb}T0(^%keBd)B?KUrX)~Xkk1Nmi_f2wpsPu2|NkIA@$Yby7B|Q0uv!U+@t`w z|I%)G2YG0wAhv_p2@1=@y$cKSvGKl%rtjtdt^ojZI6o6%g-DF?;CN=i2{J~G8NGNm zqImoE;H^|Pwm!9&_Zc(;yF@7;v;G<{{JN8Zh1=q;&Sk^lGpucfw)s!&DSKfY927s5 z9jNDqjrzv*`%QgeFRTH;!3l@WonhL!D@GNvZEwa6Ymaa8Yp^Iq=`fqTl3((hZqB** z`U@K0-t@dMkZ0e2wm?LcDgJ;`DmJICTuP{wn3YI`@i%~~zxC{llhP+EfXMC<hOF)aghQNws+}(u>23OQlzn*F&n@76>)KsXo60{i76d3;AV}8{oVJXvZCn$Ehft ze!-U~2C&t z8W%=)7M{)3-elwhC9EK--UwWsa%UXxpbeJPf+#)b=Qv#-SYtQWzzABH9ZKG6r*!PC zpaM`&y3*RnblnCUl5~kg5OV`9%%A#THt1PI&L0q&t5Zau@sH^V8h~|V9iR2X9eDqe z)e072d&Um%X6nw+&G8?|+F#03`xBXnakgj(sypZ)>HFb?&&rD3+G4qbavOaAH790O zcTUdyeOReUq&cXz76|XGF7L+W{K0MFVC`{Y|liFfRex)iRJD3&4>i>eO)i}(u%&yN2$PiIHJac2tj9m2q zI4=oMO8qGG)oxO$SsgZtkdZbPEdkFW%#6UQ7DO)#ps@|E;c9I$3ty0rblwT1UPwmc<>mIv0-X5U@J0-?B(zL>Rmc)(0;4)M3XK zW#S~p2{0#)w%9ZG7X=CZI=;F$;)p1-knS-x6XM@X?9E~M*nD>0zlE3C8ZAK3$T&j;ar;ZSXnV9P=S(m>O#%8ciu#7J^C`ko4J}*jWA zHfZSO8qB9Ow1i{TFGTM%U`DJS=JtzWDyei3dG{+<>7J`|soS=@=m&mzDjIttswbX8 z3ryaSz0RQTkTLbq;e~bklKXv7-(1^Q(DhbmW+&0d{%8e@`?om?Ypb=~8j1OI^d?$a z3Mi`Mw~*kfnc*)BJsjtvcyn+#p&wopq$0}Y-?iFcbMZDJ!XGaOW6gM2m*Rf0j-@mW>8aAfPYtwC)>$cy}M|YFL zB5EWyIhgShR4Zq0e-GA-X0Gv+zlUyB|01%9o0V(-XtXRz``4F>@qg}U?7iX_5&frh zWA_CkStXQu(j{rhZCrN8tL=wGge`(sx-uvyB|Ze*Fwu<>KKWT6BS7vWs@EK|#~N$4J4crVy+OFP1Ik z5-qDXIq#VI$g_gD-MTVTVsDjsH*)!9(?YGH(|B2XbT@9rg6e~%r2EM3?yi`D^>M(t z4-h1pL|N~)tFE2$`!T) z$8bUewWWK!JbrF(Z>Pja9RYT%F-qkii=VZ=*fRlUKcG9VmQTcf&CkzgK_3u83}dAF zGs9bF?o!-$UV@VHuE`b80VzR_?pE9O>FQr8-yJ z7EU^kiuU=9IN+GYXOmtv?H!pq2r7&khhfY&H&nP9rJ61{j<`8aR1wjz?d#X0(=6D5 z#-p<>G1_xPlb!Kmxh*LU=VA!Ur zsiE5Po3`b>Fy`IQE|ppq0F>E(S5hZj4Vi7aLHTX$Iz>%*g^beNjq_&WsgA~&5g-5B zb<>E$-@h~YGB~iH4SeIeIFK_nFUXhDd5I`G6}CNVQR9t=#vf>{q~z&k1*L#Po6xIp z!?rT^vSKs&%zBo6_0`~T*FKKMs4vmogj5+gDda|*_7{$K@7_7-Uoj?ukis0@+6Gjv zi>b1&utbS_d3!rw-c5Dg>;Q4TKks3tgQH_DGy33+GoEF>`Ic6$N~9iJH?2Yb`_bWU zsY(igbOC19OZ@gzaK8Vw_IIEcdZd`$LiAhH?jhBOa;{%{86y{lZGdqp+(Q^;z2(lS z{7(2b_#eoVxOeW2uC!i`PJE1Z&S3uJ%S^753KCUXTADb;?ndPbGzo+v>f;fuwwI;P z1Txn8hvI@wE89#@zPc_4bz$KvmX!+WhIkM-;Uq=?KYToz|7Bf_$=-T(b(NhegqL>A z|0&b0Q;H*xHFH$`Pj=FSHS`2^U?fy1MQ|Z7c z2UhCQp!$mAU4KS&P7YV;gHNf){NOT`;4(Dfs&6oelN{lp_csllDR&b>R|nu&qS00N zg5l|DOECYV1zJvqnEJf9xw*;vtCFZ(7|ht(Mo*v=_Zf~8>EPFQL0=M%=`LC%)Z1&f zgG+*W(%~hbzio<1_>|APFxrv7S{lrU+~O_X6`EB{Q_b2?_Dw`YMCAHU#b|Nu>}!LZH?W(mC(7Qh$P}&eW+agL4EC`F^2p}cmww0V$C@I6O=SY#_B;>y?&0K?j8Kh#09{s=k0qlSZDR}6=i?DbSv#u1$CvYaX9aIrUH<*JQV~)wuK7`xhvbyq*uG^g`p+9YXtzr04 zH=;Z>Ie9vScNlSIA}YH6Z$T2o5 zc4+fge}8;KQ3U&}ur->^%0fIP<^Hxm=>vg4&{Om6{0qTL0*#wvr57e(zTpNavw)|# z7uX<^-WBu?d!dI=t53of*(~3BCl!3Tmv+_-6_kL%kr#uee2a^R=Md25%f5;5WQKCL z5_e{PyzJD7Y+rkmSvQ*TFxNCkxle%=G!E+dPpWCIelOx~?a~Le;i@z$Ip9uJ;rH*| z>L%!~o?c!`4lz~NLPn~jNx4<#+pqKUyk~)Ysm+@pV&@vXx`|dHD6yrWdT?htfCG~K z?-jrlVy=U@1T;|enuw=lf!XiP9#W7RLWSJ*8a((?V?K~=$@~`Ur)6R?LJR#*K`1jb zGaW0p&hJSLJ#uvS%p!=*-Q8{hsY30&21pf=%1+#_AV41+95@~*N`z84QhN%X9u%`T zhJp#Fbt+b3H}GP*QrIApJ*wBo%t7F+cd)nDmB&V5@pAr?^~*mM^}|)?l-p;7#jCx3 zqe0oso7Hm>f-Q>i=MjJA;4?Hb(nA^d<>;Fm7|{Q%zyA9!(XDj&oMO8>?=*?s)SUrX z`|RqoL^{q3gR9G}E_pw6a3~m!{Z8%;+N+tPhASV0xBV*1?1#QKfa-rh@`u_2nn0{l z{W!ZGR(UHXUbjNu_YH0?;5z z^{9nNXvX(~H)cwnh=6yU<|Gb^x7ES0-gWgMRR0Kd;T7Ipmk%~9f$JQxREHT`n~xl;=;qi7Cn?zQMHyb_|8`<(Cg@4rEW2$;Fhu2gc>m?XKaHUOs<;D4nx z$rL|(5+s41ss8of>!X2?OSGRsS&&I4Q)FKC<8%FI?m@L_U4+rh%a63pJeXBgpds3y zM;~m3SY9e+s#zJg9(8s&2@mKN4+||@l2c#JI>6a3pK!h0F|x3jvgPv+%B7q25Alnq zQmIrF!rpW{$rPvaFCKP2Qk0;5ZVSfws$c{~*621z-;cNxe=W~8_4vumkwnGt)m9~r zSD;EFNB_a+AUqAEkZM|=)~QE{jlli%t(Ky7h?wQugTP31d1oqJed2S^d9m}H`gH8>;|*@ z+}Q|ITBvCw{XZKH%c!zKz^2r_)IL65W$BKI!F#iz(*@yJzmBGG+6z=|gB9D`z*I%Q zeRUv+1yn7@H<)Qa5S5F^DyUBuW1lT7Q{EcMPF@tSiBK2orMIaZ`l}FdkP> zP>|7(4VtIBa%Ji=HaK)Cp)gHjV0id0Q{ywx0*B{e9B`rX9qA`0Cu}h*GOZ*3ut z+$%eQbtd8N8Q@`rgY@cyDAN=nbqHsDt7@CxO)mmI^n#M*=+~{HfJRa+6A(brSOUPd z-|&zXzrkMLSKP71ttc`7KG`uXMs=kX5>m||8OG|`4CUh(?J9FnTqZn+ - - - - - - image/svg+xml - - - - - - - NOVA - - - - - - - - diff --git a/minecraft/1.7/src/main/resources/fmlbranding.properties b/minecraft/1.7/src/main/resources/fmlbranding.properties deleted file mode 100644 index d0872c237..000000000 --- a/minecraft/1.7/src/main/resources/fmlbranding.properties +++ /dev/null @@ -1 +0,0 @@ -fmlbranding=NOVA 0.0.1-SNAPSHOT diff --git a/minecraft/1.7/src/main/resources/mcmod.info b/minecraft/1.7/src/main/resources/mcmod.info deleted file mode 100644 index bf0db8f3a..000000000 --- a/minecraft/1.7/src/main/resources/mcmod.info +++ /dev/null @@ -1,21 +0,0 @@ -{ - "modListVersion": 2, - "modList": [{ - "modid": "nova", - "name": "NOVA", - "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", - "version": "0.0.1", - "mcversion": "1.7.10", - "url": "https://novaapi.net/", - "updateUrl": "", - "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], - "credits": "Created by the NOVA Team.", - "logoFile": "/assets/nova/textures/NOVA.png", - "screenshots": [], - "parent": "", - "requiredMods": [], - "dependencies": [], - "dependants": [], - "useDependencyInformation": true - }] -} diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java index 198f87df7..4c1b03064 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/NovaMinecraftPreloader.java @@ -53,7 +53,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -67,7 +66,6 @@ public class NovaMinecraftPreloader extends DummyModContainer { public static final String version = "0.0.1"; private static final ModMetadata md; public static Set> modClasses; - public static Map, File> modClassToFile; static { md = new ModMetadata(); @@ -211,7 +209,6 @@ public void load(FMLConstructionEvent event) { // Scan mod classes ASMDataTable asmData = event.getASMHarvestedData(); - modClassToFile = new HashMap<>(); modClasses = asmData .getAll(Mod.class.getName()) .stream() @@ -236,7 +233,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta, mod)); + newMods.add(new DummyNovaMod(fakeMeta)); }); //TODO: Use AT ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -282,7 +279,6 @@ public void registerResourcePacks() { packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); System.out.println("Registered NOVA jar resource pack: " + fn); } - modClassToFile.put(c, file); } 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(); @@ -294,7 +290,6 @@ public void registerResourcePacks() { folderFile = new File(folderLocation.replaceAll("build[\\\\/]classes", "build/resources")); folderFile = new File(folderFile, "assets").isDirectory() ? folderFile : new File(folderLocation); } - modClassToFile.put(c, folderFile); addedPacks.add(folderLocation); packs.add(new NovaFolderResourcePack(folderFile, novaMod.id(), novaMod.domains())); @@ -311,20 +306,8 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class DummyNovaMod extends DummyModContainer { - private final Class mod; - private File source = null; - - public DummyNovaMod(ModMetadata meta, Class mod) { + public DummyNovaMod(ModMetadata meta) { super(meta); - this.mod = mod; - } - - @Override - public File getSource() { - if (this.source == null) { - this.source = NovaMinecraftPreloader.modClassToFile.get(mod); - } - return this.source; } } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java deleted file mode 100644 index 04e13374c..000000000 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/FMLProgressBar.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nova.core.wrapper.mc.forge.v18.launcher; - -import net.minecraftforge.fml.common.ProgressManager.ProgressBar; - -/** - * Wrapper class for FML progress bar that is shown when Minecraft boots. - * - * @author ExE Boss - */ -public class FMLProgressBar extends nova.internal.core.launch.ProgressBar { - - private final ProgressBar progressBar; - - public FMLProgressBar(ProgressBar progressBar) { - this.progressBar = progressBar; - } - - @Override - public void step(String s) { - if (this.progressBar.getStep() >= this.progressBar.getSteps()) return; - this.progressBar.step(s); - } -} diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java index 5a8ac7ae1..eb0a0f321 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/launcher/NovaMinecraft.java @@ -23,8 +23,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.ProgressManager; -import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; @@ -146,9 +144,7 @@ public void preInit(FMLPreInitializationEvent evt) { e.printStackTrace(); } - ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); - launcher.load(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.load(); /** * Instantiate native loaders @@ -162,10 +158,7 @@ public void preInit(FMLPreInitializationEvent evt) { Game.render().init(); Game.language().init(); - //Load preInit - progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); - launcher.preInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.preInit(); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -191,11 +184,10 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); + proxy.init(); nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.init(); } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -206,12 +198,10 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); Game.recipes().init(); proxy.postInit(); nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + launcher.postInit(); } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java index 80ae84fce..64e9a8524 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/recipes/MCCraftingGrid.java @@ -183,8 +183,8 @@ public boolean setStack(int x, int y, Optional stack) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (stack.isPresent()) { - if (!stack.get().equals(stacks[ix])) { + if (!stack.equals(stacks[ix])) { + if (stack.isPresent()) { inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); if (stacks[ix] == null) { @@ -192,11 +192,11 @@ public boolean setStack(int x, int y, Optional stack) { } stacks[ix] = stack.get(); + } else { + numberOfStacks--; + inventory.setInventorySlotContents(ix, null); + stacks[ix] = null; } - } else { - numberOfStacks--; - inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; } return true; @@ -206,14 +206,7 @@ public boolean setStack(int x, int y, Optional stack) { public boolean setStack(int i, Optional stack) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack.isPresent()) { - if (stacks[i] == null) { - numberOfStacks++; - } - - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); - } else { + if (stack == null) { if (stacks[i] == null) { return true; } @@ -221,6 +214,13 @@ public boolean setStack(int i, Optional stack) { numberOfStacks--; inventory.setInventorySlotContents(i, null); stacks[i] = null; + } else { + if (stacks[i] == null) { + numberOfStacks++; + } + + inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); + stacks[i] = stack.get(); } return true; diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java index ec47c7f45..e8f9fc32c 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/util/WrapperEvent.java @@ -20,23 +20,11 @@ package nova.core.wrapper.mc.forge.v18.util; -import net.minecraft.item.ItemStack; -import nova.core.block.Block; -import nova.core.entity.Entity; import nova.core.event.BlockEvent; -import nova.core.event.bus.CancelableEvent; -import nova.core.event.bus.Event; import nova.core.util.Direction; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v18.wrapper.block.backward.BWBlock; -import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v18.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v18.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v18.wrapper.item.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import java.util.Optional; - /** * Events for wrappers to hook into * @author Calclavia @@ -72,63 +60,4 @@ public WeakRedstone(World world, Vector3D position, Direction direction) { this.direction = direction; } } - - public static class BWBlockCreate extends BlockEvent { - public final net.minecraft.block.Block mcBlock; - public final BWBlock novaBlock; - - public BWBlockCreate(World world, Vector3D position, BWBlock novaBlock, net.minecraft.block.Block mcBlock) { - super(world, position); - this.novaBlock = novaBlock; - this.mcBlock = mcBlock; - } - } - - public static class BWItemCreate extends CancelableEvent { - public final net.minecraft.item.Item mcItem; - public final BWItem novaItem; - public final Optional itemStack; - - public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem) { - this.novaItem = novaItem; - this.mcItem = mcItem; - this.itemStack = Optional.empty(); - } - - public BWItemCreate(BWItem novaItem, net.minecraft.item.Item mcItem, ItemStack itemStack) { - this.novaItem = novaItem; - this.mcItem = mcItem; - this.itemStack = Optional.of(itemStack); - } - } - - public static class BWEntityCreate extends CancelableEvent { - public final net.minecraft.entity.Entity mcEntity; - public final BWEntity novaEntity; - - public BWEntityCreate(net.minecraft.entity.Entity mcEntity, BWEntity novaEntity) { - this.mcEntity = mcEntity; - this.novaEntity = novaEntity; - } - } - - public static class FWTileCreate extends Event { - public final Block novaBlock; - public final FWTile tileEntity; - - public FWTileCreate(Block novaBlock, FWTile tileEntity) { - this.novaBlock = novaBlock; - this.tileEntity = tileEntity; - } - } - - public static class FWEntityCreate extends Event { - public final Entity novaBlock; - public final FWEntity mcEntity; - - public FWEntityCreate(Entity novaBlock, FWEntity mcEntity) { - this.novaBlock = novaBlock; - this.mcEntity = mcEntity; - } - } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java index 133815185..17514f534 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/BlockConverter.java @@ -24,8 +24,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.Block; import nova.core.block.BlockFactory; @@ -33,7 +31,6 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v18.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v18.util.ModCreativeTab; @@ -41,9 +38,7 @@ import nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v18.wrapper.item.FWItemBlock; import nova.internal.core.Game; -import nova.internal.core.launch.ModLoader; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; import java.util.Optional; @@ -141,8 +136,7 @@ public boolean canReplace() { private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); blockFactoryMap.put(blockFactory, blockWrapper); - String blockId = blockFactory.getID(); - registerNovaBlock(blockWrapper, blockId); + GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockFactory.getID()); NovaMinecraft.proxy.postRegisterBlock(blockWrapper); if (blockWrapper.dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { @@ -162,26 +156,4 @@ private void registerNovaBlock(BlockFactory blockFactory) { System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); } - - /** - * Prevent forge from prefixing block IDs with "nova:" - */ - private void registerNovaBlock(FWBlock blockWrapper, String blockId) { - try { - Class gameDataClass = GameData.class; - Method getMain = gameDataClass.getDeclaredMethod("getMain"); - Method registerBlock = gameDataClass.getDeclaredMethod("registerBlock", net.minecraft.block.Block.class, String.class, Integer.TYPE); - Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); - getMain.setAccessible(true); - registerBlock.setAccessible(true); - registerItem.setAccessible(true); - GameData gameData = (GameData) getMain.invoke(null); - registerBlock.invoke(gameData, blockWrapper, blockId, -1); - FWItemBlock itemWrapper = new FWItemBlock(blockWrapper); - registerItem.invoke(gameData, itemWrapper, blockId, -1); - GameData.getBlockItemMap().put(blockWrapper, itemWrapper); - } catch (ReflectiveOperationException e) { - GameRegistry.registerBlock(blockWrapper, FWItemBlock.class, blockId); - } - } } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java index 88f45c504..a7d70ff25 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java @@ -42,7 +42,6 @@ import nova.core.sound.Sound; import nova.core.util.shape.Cuboid; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.core.wrapper.mc.forge.v18.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -94,8 +93,6 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }); - WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); - Game.events().publish(event); //TODO: Set selection bounds } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java index 3005acf92..907633c88 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/forward/FWTileLoader.java @@ -25,7 +25,6 @@ import nova.core.block.BlockFactory; import nova.core.component.Updater; import nova.core.wrapper.mc.forge.v18.asm.lib.ComponentInjector; -import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.internal.core.Game; import java.util.Optional; @@ -47,8 +46,6 @@ public static FWTile loadTile(NBTTagCompound data) { Block block = createBlock(blockID); FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : injector.inject(block, new Class[0], new Object[0]); tile.setBlock(block); - WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); - Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); @@ -58,11 +55,9 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : - injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); + FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : injector.inject(block, new Class[] { + String.class }, new Object[] { blockID }); tile.setBlock(block); - WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); - Game.events().publish(event); return tile; } catch (Exception e) { throw new RuntimeException("Fatal error when trying to create a new NOVA tile.", e); diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java index 1ef0f138f..e28085d10 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/BWItemFactory.java @@ -25,7 +25,6 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; -import nova.core.wrapper.mc.forge.v18.util.WrapperEvent; import nova.internal.core.Game; /** @@ -58,8 +57,6 @@ public Item build(Data data) { NBTTagCompound nbtData = Game.natives().toNative(data); BWItem bwItem = new BWItem(item, meta, nbtData); bwItem.components.add(new FactoryProvider(this)); - WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); - Game.events().publish(event); return bwItem; } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java index 78fd4048b..793bb2fd1 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/item/ItemConverter.java @@ -25,8 +25,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.registry.GameData; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.BlockFactory; import nova.core.component.Category; @@ -36,7 +34,6 @@ import nova.core.item.ItemManager; import nova.core.item.event.ItemIDNotFoundEvent; import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v18.launcher.NovaMinecraft; @@ -44,9 +41,7 @@ import nova.core.wrapper.mc.forge.v18.wrapper.block.BlockConverter; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; -import nova.internal.core.launch.ModLoader; -import java.lang.reflect.Method; import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -199,23 +194,17 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } - if (!itemFactory.getID().asString().equals(net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper))) { - System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.itemRegistry.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); - net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID().asString()); - itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; - } } else { itemWrapper = new FWItem(itemFactory); } MinecraftItemMapping minecraftItemMapping = new MinecraftItemMapping(itemWrapper, 0); - map.forcePut(itemFactory, minecraftItemMapping); + map.put(itemFactory, minecraftItemMapping); // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - String itemId = itemFactory.getID(); - GameRegistry.registerItem(itemWrapper, itemId); + GameRegistry.registerItem(itemWrapper, itemFactory.getID()); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab @@ -236,23 +225,6 @@ private void registerNOVAItem(ItemFactory itemFactory) { } } - /** - * Prevent forge from prefixing item IDs with "nova:" - */ - private void registerNovaBlock(FWItem itemWrapper, String blockId) { - try { - Class gameDataClass = GameData.class; - Method getMain = gameDataClass.getDeclaredMethod("getMain"); - Method registerItem = gameDataClass.getDeclaredMethod("registerItem", net.minecraft.item.Item.class, String.class, Integer.TYPE); - getMain.setAccessible(true); - registerItem.setAccessible(true); - GameData gameData = (GameData) getMain.invoke(null); - registerItem.invoke(gameData, itemWrapper, blockId, -1); - } catch (ReflectiveOperationException e) { - GameRegistry.registerItem(itemWrapper, blockId); - } - } - private void registerMinecraftItemsToNOVA() { Set itemIDs = (Set) net.minecraft.item.Item.itemRegistry.getKeys(); itemIDs.forEach(itemID -> { diff --git a/minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.8/src/main/resources/assets/nova/textures/NOVA.png deleted file mode 100644 index 1f42e113ce5dbaa9b1bc62df36b8d523f52b5ae5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8484 zcmd6NhdY)3|NnhZW^rsn#zDzGl}&MkGD0Xb9UZdw$T}H0M&3roF^(ch65`k^;~>Z0 zd++UtWPR^G|HSX-x*VMAT(A4(^?W`b>%Jo&>uOw~;iLfo;EI+e!Tc8yWz#kMIs#;H|z^?!*8w~h2wX5bc4*^Rx_Z z+Wg9{?<45%xlzRlX^rITGLb<`;$_x}U*KO_ciMWgV&OT8N%ubR!KRE>jD57xH$q2w zqr~54(Y#VW-Fxs8<{9GmJ7<0SILGBFhj#yv#mS_9L8*#ERkC>Ej+|EY$za_{Mj(*; z-r(WQ|MxF<`W{a*J!T4(T7C{hz)4Wt3OAJEr#63@F5(>^Bt`lOTu${vW6GsT0NMni zsE5$YGsw^DT-v7{9(Vs1%#izDoX&o8xhs97cW}^?4w?zfQUGmazM=OHB+<$MJ;ay2 zQEhm9<&t}n0aEgN_)m5Z6?EuV?hI_v@4$;#dk^zYRH?8e>5hS4`duga@`{QISQ6VM zB$1gvt%vvw$Ro3hv0Kdpo&tUjTSWq#9z`)yE|+)7JG4tmv>nE>A_S8ruseWc)pj0ZBnjOj0)NYu- z-b0#B>{*e~L{-0tsiJQb4nwNg6$U<$E#)VqT9N&Udpzk{Wv-lEQ*)yJv3Ar~>c5#) zKTEyL=wpVd^W1;mGS9E2IlOuqh1lbS=o{^0G#d%V|OOn&aSFS;EyA^xgm zL(my7eC8&XziWR~@7C6q7s4~vb+i2E&z~W#DD@br>y*3GRBsdB}B_$0MfsOno}3v+Aqo=jWGzX&6=uaceylR3-omMUUieZ{>hAR4Sg6G^-adQ~p)`SW|HukO%jS+WDOmEc7$xQ}4= zV+n$fu0G5g*nrgD+OBGOhj9moBf6>bx@m4%$4rnRd?VhM9*b3+g5 z1^a7Vp+vVIkfz)g2|D&?PA*p}i1{>2?sD|^Aop~3^1RVNfJ%DTc^x7Z?~TEHQlMzF z3{&1~VHyBF$=s}!f7So#X;k->D_0&tPIb7DBlB-6OrNp?&(l`?rU4j zvLG4I=H6hTY;pd-Yyg2&OMmJ9?l#zxz6=yQyNWwXKrE%}Rd_IYBRymj;~V=5Rd4vU zjS(71&-9Hdu$?ag!qU%RaL%tHwvukMC zi#HCcl|CwLb8!-oN+qh0?iVG0WJON+j(4{&7;y&YRM5;$A_u~w{)G^_R%&@+c>JS% z$o}!EAtBYW-J3^gnw?b7zVpGgZ_g_{l&Jr*bWBg0(lxN8m{(h?$nH>Hx+9X{>A@qW*X_@VVldLjyR3*PCUP<;)x+zTuD9Xu>@Db4TQIw2agE?KaaI)BU^EMg_)atw(1C8|&+_&zG<9o<^Z0 z#5--Ijb!Ly+0H1o}!cv;vYC}kK;ROY>i=}r$X6BoNy~1XBw^AwA4k*+JgFe<#Nkg zS~fA*7UGB;59;_}Z9rvcXz2I11vkrulOUJ;C-Rr?6*XHgJCFTXin3Qz?5Ux?$19no zr2e{Q;@h**ZVJ~gHbU^366dMv%mi$bowGCU7cndL_2ikat(DbG-aHN=Xb%o36b}|J zt&&lSW-gH8d-;Jh`cWaCt;Nm6OHZ%o7I2Qkm|L#z<9GLy-8xrDdXPVny#d||VEvWn zh=FOETX?WwDb}B?j1yWccfKIH#OZ)W;z)UUInQoHMY8BKcLuoC_6;1w99391tskWR z4X;KFxCTlW#3`g9Ai%Y(_u$qn!P z8FTX2!XfvN3>24;+WpEb2zyu8-50=sxec6@vS7*VT{@gB<2+eO*Ju&@w(|L0Q@9a# z$cyDWz`5w{tSPKM%f|`63uWbGlX{SOdC;(PK&Xer*sxST%yt>@rF^hGTUZqYV@wt^ z8(!VDc^R>D!apIG8+K{uF7Tfm#^q~4K}}g2dbi`Vnw@fuoP=tGaAxjIn+rEP`;C7E zq&9nUgnZVoLevclhXBjhkjmGOVDrTuE8Q=F=~Z5EmKn$NrcG;6RgGUE{}n?Mvl ze6Vw%xHD<5M^Q8QuNiWxf6<}7e@)UXc^bgkc&17k+mcODUyU5JQ~-$zGM43J2Jxg? zeuI^Gw9i6ddS$IizIvO$#dw6sX5^Wc)0I!bHe~dyWWDcBT0S}F27-7qA0eE`q{OES z6<)P*vu5V1SYMPq6+NW3jTM>1xRu)oK?|uuX0OEs(kRk3u7&tz3;mB5A-ze9Nl!WW|+D?*GRzSaJZgX@$>set*1KacMBoA!XJ+}%Lmn=@&Tp{XSm3My2IYy z-eUk}rbn^leoO#Sh!VKCnMw=u-B?GMfnaZgs+Zo@LbRyg-@k5wvr9%51`2IDi{yW- zuRkZ+lfCx$e}s7dC$U!;=lf#(CttD2XKgH_U!Rpe3!J~%76x8!3?v&EOSFTI_tnvtl#O^7JNbw1oX~IX zHE^I02G;uRd%7#*!oq(V`7fyfiv>=x$xj$nDlKgt3=I=IlbLk=a7Tf2?agcwmZ!t^ zYFu>=Y&TUSf|b{%mFS;31m6O83C@gMTpc|*P#-J z6MXyRz8{VwJmqY%KFA;!EfX)S{|T^EzuZ|_-t6dR^0$%Dlcq)@Id0`8Uky#eTTFdw zhmCnfb}T0(^%keBd)B?KUrX)~Xkk1Nmi_f2wpsPu2|NkIA@$Yby7B|Q0uv!U+@t`w z|I%)G2YG0wAhv_p2@1=@y$cKSvGKl%rtjtdt^ojZI6o6%g-DF?;CN=i2{J~G8NGNm zqImoE;H^|Pwm!9&_Zc(;yF@7;v;G<{{JN8Zh1=q;&Sk^lGpucfw)s!&DSKfY927s5 z9jNDqjrzv*`%QgeFRTH;!3l@WonhL!D@GNvZEwa6Ymaa8Yp^Iq=`fqTl3((hZqB** z`U@K0-t@dMkZ0e2wm?LcDgJ;`DmJICTuP{wn3YI`@i%~~zxC{llhP+EfXMC<hOF)aghQNws+}(u>23OQlzn*F&n@76>)KsXo60{i76d3;AV}8{oVJXvZCn$Ehft ze!-U~2C&t z8W%=)7M{)3-elwhC9EK--UwWsa%UXxpbeJPf+#)b=Qv#-SYtQWzzABH9ZKG6r*!PC zpaM`&y3*RnblnCUl5~kg5OV`9%%A#THt1PI&L0q&t5Zau@sH^V8h~|V9iR2X9eDqe z)e072d&Um%X6nw+&G8?|+F#03`xBXnakgj(sypZ)>HFb?&&rD3+G4qbavOaAH790O zcTUdyeOReUq&cXz76|XGF7L+W{K0MFVC`{Y|liFfRex)iRJD3&4>i>eO)i}(u%&yN2$PiIHJac2tj9m2q zI4=oMO8qGG)oxO$SsgZtkdZbPEdkFW%#6UQ7DO)#ps@|E;c9I$3ty0rblwT1UPwmc<>mIv0-X5U@J0-?B(zL>Rmc)(0;4)M3XK zW#S~p2{0#)w%9ZG7X=CZI=;F$;)p1-knS-x6XM@X?9E~M*nD>0zlE3C8ZAK3$T&j;ar;ZSXnV9P=S(m>O#%8ciu#7J^C`ko4J}*jWA zHfZSO8qB9Ow1i{TFGTM%U`DJS=JtzWDyei3dG{+<>7J`|soS=@=m&mzDjIttswbX8 z3ryaSz0RQTkTLbq;e~bklKXv7-(1^Q(DhbmW+&0d{%8e@`?om?Ypb=~8j1OI^d?$a z3Mi`Mw~*kfnc*)BJsjtvcyn+#p&wopq$0}Y-?iFcbMZDJ!XGaOW6gM2m*Rf0j-@mW>8aAfPYtwC)>$cy}M|YFL zB5EWyIhgShR4Zq0e-GA-X0Gv+zlUyB|01%9o0V(-XtXRz``4F>@qg}U?7iX_5&frh zWA_CkStXQu(j{rhZCrN8tL=wGge`(sx-uvyB|Ze*Fwu<>KKWT6BS7vWs@EK|#~N$4J4crVy+OFP1Ik z5-qDXIq#VI$g_gD-MTVTVsDjsH*)!9(?YGH(|B2XbT@9rg6e~%r2EM3?yi`D^>M(t z4-h1pL|N~)tFE2$`!T) z$8bUewWWK!JbrF(Z>Pja9RYT%F-qkii=VZ=*fRlUKcG9VmQTcf&CkzgK_3u83}dAF zGs9bF?o!-$UV@VHuE`b80VzR_?pE9O>FQr8-yJ z7EU^kiuU=9IN+GYXOmtv?H!pq2r7&khhfY&H&nP9rJ61{j<`8aR1wjz?d#X0(=6D5 z#-p<>G1_xPlb!Kmxh*LU=VA!Ur zsiE5Po3`b>Fy`IQE|ppq0F>E(S5hZj4Vi7aLHTX$Iz>%*g^beNjq_&WsgA~&5g-5B zb<>E$-@h~YGB~iH4SeIeIFK_nFUXhDd5I`G6}CNVQR9t=#vf>{q~z&k1*L#Po6xIp z!?rT^vSKs&%zBo6_0`~T*FKKMs4vmogj5+gDda|*_7{$K@7_7-Uoj?ukis0@+6Gjv zi>b1&utbS_d3!rw-c5Dg>;Q4TKks3tgQH_DGy33+GoEF>`Ic6$N~9iJH?2Yb`_bWU zsY(igbOC19OZ@gzaK8Vw_IIEcdZd`$LiAhH?jhBOa;{%{86y{lZGdqp+(Q^;z2(lS z{7(2b_#eoVxOeW2uC!i`PJE1Z&S3uJ%S^753KCUXTADb;?ndPbGzo+v>f;fuwwI;P z1Txn8hvI@wE89#@zPc_4bz$KvmX!+WhIkM-;Uq=?KYToz|7Bf_$=-T(b(NhegqL>A z|0&b0Q;H*xHFH$`Pj=FSHS`2^U?fy1MQ|Z7c z2UhCQp!$mAU4KS&P7YV;gHNf){NOT`;4(Dfs&6oelN{lp_csllDR&b>R|nu&qS00N zg5l|DOECYV1zJvqnEJf9xw*;vtCFZ(7|ht(Mo*v=_Zf~8>EPFQL0=M%=`LC%)Z1&f zgG+*W(%~hbzio<1_>|APFxrv7S{lrU+~O_X6`EB{Q_b2?_Dw`YMCAHU#b|Nu>}!LZH?W(mC(7Qh$P}&eW+agL4EC`F^2p}cmww0V$C@I6O=SY#_B;>y?&0K?j8Kh#09{s=k0qlSZDR}6=i?DbSv#u1$CvYaX9aIrUH<*JQV~)wuK7`xhvbyq*uG^g`p+9YXtzr04 zH=;Z>Ie9vScNlSIA}YH6Z$T2o5 zc4+fge}8;KQ3U&}ur->^%0fIP<^Hxm=>vg4&{Om6{0qTL0*#wvr57e(zTpNavw)|# z7uX<^-WBu?d!dI=t53of*(~3BCl!3Tmv+_-6_kL%kr#uee2a^R=Md25%f5;5WQKCL z5_e{PyzJD7Y+rkmSvQ*TFxNCkxle%=G!E+dPpWCIelOx~?a~Le;i@z$Ip9uJ;rH*| z>L%!~o?c!`4lz~NLPn~jNx4<#+pqKUyk~)Ysm+@pV&@vXx`|dHD6yrWdT?htfCG~K z?-jrlVy=U@1T;|enuw=lf!XiP9#W7RLWSJ*8a((?V?K~=$@~`Ur)6R?LJR#*K`1jb zGaW0p&hJSLJ#uvS%p!=*-Q8{hsY30&21pf=%1+#_AV41+95@~*N`z84QhN%X9u%`T zhJp#Fbt+b3H}GP*QrIApJ*wBo%t7F+cd)nDmB&V5@pAr?^~*mM^}|)?l-p;7#jCx3 zqe0oso7Hm>f-Q>i=MjJA;4?Hb(nA^d<>;Fm7|{Q%zyA9!(XDj&oMO8>?=*?s)SUrX z`|RqoL^{q3gR9G}E_pw6a3~m!{Z8%;+N+tPhASV0xBV*1?1#QKfa-rh@`u_2nn0{l z{W!ZGR(UHXUbjNu_YH0?;5z z^{9nNXvX(~H)cwnh=6yU<|Gb^x7ES0-gWgMRR0Kd;T7Ipmk%~9f$JQxREHT`n~xl;=;qi7Cn?zQMHyb_|8`<(Cg@4rEW2$;Fhu2gc>m?XKaHUOs<;D4nx z$rL|(5+s41ss8of>!X2?OSGRsS&&I4Q)FKC<8%FI?m@L_U4+rh%a63pJeXBgpds3y zM;~m3SY9e+s#zJg9(8s&2@mKN4+||@l2c#JI>6a3pK!h0F|x3jvgPv+%B7q25Alnq zQmIrF!rpW{$rPvaFCKP2Qk0;5ZVSfws$c{~*621z-;cNxe=W~8_4vumkwnGt)m9~r zSD;EFNB_a+AUqAEkZM|=)~QE{jlli%t(Ky7h?wQugTP31d1oqJed2S^d9m}H`gH8>;|*@ z+}Q|ITBvCw{XZKH%c!zKz^2r_)IL65W$BKI!F#iz(*@yJzmBGG+6z=|gB9D`z*I%Q zeRUv+1yn7@H<)Qa5S5F^DyUBuW1lT7Q{EcMPF@tSiBK2orMIaZ`l}FdkP> zP>|7(4VtIBa%Ji=HaK)Cp)gHjV0id0Q{ywx0*B{e9B`rX9qA`0Cu}h*GOZ*3ut z+$%eQbtd8N8Q@`rgY@cyDAN=nbqHsDt7@CxO)mmI^n#M*=+~{HfJRa+6A(brSOUPd z-|&zXzrkMLSKP71ttc`7KG`uXMs=kX5>m||8OG|`4CUh(?J9FnTqZn+ - - - - - - image/svg+xml - - - - - - - NOVA - - - - - - - - diff --git a/minecraft/1.8/src/main/resources/fmlbranding.properties b/minecraft/1.8/src/main/resources/fmlbranding.properties deleted file mode 100644 index d0872c237..000000000 --- a/minecraft/1.8/src/main/resources/fmlbranding.properties +++ /dev/null @@ -1 +0,0 @@ -fmlbranding=NOVA 0.0.1-SNAPSHOT diff --git a/minecraft/1.8/src/main/resources/mcmod.info b/minecraft/1.8/src/main/resources/mcmod.info deleted file mode 100644 index c54cab9c6..000000000 --- a/minecraft/1.8/src/main/resources/mcmod.info +++ /dev/null @@ -1,21 +0,0 @@ -{ - "modListVersion": 2, - "modList": [{ - "modid": "nova", - "name": "NOVA", - "description": "NOVA (Neatly Organized Voxel API) is a modding framework for voxel games.", - "version": "0.0.1", - "mcversion": "1.8", - "url": "https://novaapi.net/", - "updateUrl": "", - "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], - "credits": "Created by the NOVA Team.", - "logoFile": "/assets/nova/textures/NOVA.png", - "screenshots": [], - "parent": "", - "requiredMods": [], - "dependencies": [], - "dependants": [], - "useDependencyInformation": true - }] -} diff --git a/src/main/java/nova/core/util/Identifiable.java b/src/main/java/nova/core/util/Identifiable.java index 3fc6a1d34..e98159e43 100644 --- a/src/main/java/nova/core/util/Identifiable.java +++ b/src/main/java/nova/core/util/Identifiable.java @@ -38,6 +38,7 @@ public interface Identifiable { * @param other Identifiable to compare to * @return If the Identifiables are the same type */ + default boolean sameType(Identifiable other) { return getID().equals(other.getID()); } diff --git a/src/main/java/nova/core/util/registry/Factory.java b/src/main/java/nova/core/util/registry/Factory.java index a0f1d659d..7ce169d1e 100644 --- a/src/main/java/nova/core/util/registry/Factory.java +++ b/src/main/java/nova/core/util/registry/Factory.java @@ -78,7 +78,6 @@ public T build() { return processor.apply(constructor.get()); } - @Override public String getID() { return id; } diff --git a/src/main/java/nova/internal/core/launch/ModLoader.java b/src/main/java/nova/internal/core/launch/ModLoader.java index e1f61b603..c361e86a6 100755 --- a/src/main/java/nova/internal/core/launch/ModLoader.java +++ b/src/main/java/nova/internal/core/launch/ModLoader.java @@ -66,11 +66,6 @@ public class ModLoader implements Loadable { */ protected Map mods; - /** - * Holds the annotations of mod instances - */ - protected Map modAnnotations; - protected List orderedMods; public ModLoader(Class annotationType, DependencyInjectionEntryPoint diep, Set> modClasses) { @@ -125,12 +120,7 @@ public T makeObjectWithDep(Class classToConstruct) throws InstantiationEx } public void load() { - this.load(ProgressBar.NULL_PROGRESS_BAR); - } - - public void load(ProgressBar progressBar) { mods = new HashMap<>(); - modAnnotations = new HashMap<>(); /** * Instantiate Java mods @@ -140,7 +130,6 @@ public void load(ProgressBar progressBar) { .collect(Collectors.>, ANNOTATION, Object>toMap(Map.Entry::getKey, entry -> { try { - progressBar.step(entry.getValue()); return makeObjectWithDep(entry.getValue()); } catch (Exception ex) { ex.printStackTrace(); @@ -190,8 +179,6 @@ public void load(ProgressBar progressBar) { ) ); - modAnnotations.putAll(mods.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey))); - orderedMods = mods.values() .stream() .filter(mod -> mod.getClass().isAssignableFrom(Loadable.class)) @@ -201,13 +188,8 @@ public void load(ProgressBar progressBar) { @Override public void preInit() { - this.preInit(ProgressBar.NULL_PROGRESS_BAR); - } - - public void preInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { - progressBar.step(mod.getClass()); mod.preInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during pre initialization phase", t); @@ -218,13 +200,8 @@ public void preInit(ProgressBar progressBar) { @Override public void init() { - this.init(ProgressBar.NULL_PROGRESS_BAR); - } - - public void init(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { - progressBar.step(mod.getClass()); mod.init(); } catch (Throwable t) { Game.logger().error("Critical error caught during initialization phase", t); @@ -235,13 +212,8 @@ public void init(ProgressBar progressBar) { @Override public void postInit() { - this.postInit(ProgressBar.NULL_PROGRESS_BAR); - } - - public void postInit(ProgressBar progressBar) { orderedMods.stream().forEachOrdered(mod -> { try { - progressBar.step(mod.getClass()); mod.postInit(); } catch (Throwable t) { Game.logger().error("Critical error caught during post initialization phase", t); diff --git a/src/main/java/nova/internal/core/launch/NovaLauncher.java b/src/main/java/nova/internal/core/launch/NovaLauncher.java index e8e1966ac..61b2ef676 100644 --- a/src/main/java/nova/internal/core/launch/NovaLauncher.java +++ b/src/main/java/nova/internal/core/launch/NovaLauncher.java @@ -74,11 +74,6 @@ public NovaLauncher(DependencyInjectionEntryPoint diep, Set> modClasses @Override public void load() { super.load(); - } - - @Override - public void load(ProgressBar progressBar) { - super.load(progressBar); TopologicalSort.DirectedGraph modGraph = new TopologicalSort.DirectedGraph<>(); @@ -128,6 +123,11 @@ public Map dependencyToMap(String[] dependencies) { .collect(Collectors.toMap(s -> s[0], s -> s.length > 1 ? s[1] : "")); } + @Override + public void preInit() { + super.preInit(); + } + public Map> getNeededDeps() { if (neededDeps == null) { throw new IllegalStateException("Dependencies have not been generated"); diff --git a/src/main/java/nova/internal/core/launch/ProgressBar.java b/src/main/java/nova/internal/core/launch/ProgressBar.java deleted file mode 100644 index 1203b48eb..000000000 --- a/src/main/java/nova/internal/core/launch/ProgressBar.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package nova.internal.core.launch; - -import nova.core.loader.Mod; - -/** - * A progress bar used to show mod loading. - * - * The default implementation does nothing. - * It is up to wrappers to implement functionality. - * - * @author ExE Boss - */ -public abstract class ProgressBar { - - /** - * A progress bar implementation that does nothing. - */ - public static final ProgressBar NULL_PROGRESS_BAR = new ProgressBar() { - @Override - public void step(String s) {} - }; - - /** - * Advance one step. - * - * @param message The message to show for the current step. - */ - public abstract void step(String message); - - /** - * Advance one step. - * - * The default implementation is the same as calling: - * {@link #step(java.lang.String) ProgressBar.step(state + ": " + clazz)} - * - * @param clazz The mod class - */ - public void step(Class clazz) { - step(toStringMod(clazz)); - } - - /** - * Advance one step. - * - * The default implementation is the same as calling: - * {@link #step(java.lang.String) ProgressBar.step(message + ": " + clazz)} - * - * @param message The message to display before {@code clazz} - * @param clazz The mod class - */ - public void step(String message, Class clazz) { - step((message == null || message.isEmpty() ? "" : message + ": ") + toStringMod(clazz)); - } - - /** - * Advance one step. - * - * The default implementation is the same as calling: - * {@link #step(java.lang.String) ProgressBar.step(clazz + ": " + message)} - * - * @param message The message to display before {@code clazz} - * @param clazz The mod class - */ - public void step(Class clazz, String message) { - step(toStringMod(clazz) + (message == null || message.isEmpty() ? "" : ": " + message)); - } - - protected static String toStringMod(Class clazz) { - if (clazz == null) return null; - if (clazz.isAnnotationPresent(Mod.class)) return clazz.getAnnotation(Mod.class).name(); - return clazz.getSimpleName(); - } -} From 052d7dc9ad0c05878683c2781b63e5adb5f2789d Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 27 Feb 2017 15:41:39 +0100 Subject: [PATCH 32/61] Fix compile errors and rebase to master --- .../v1_11/asm/lib/ComponentInjector.java | 4 +- .../v1_11/depmodules/LanguageModule.java | 2 +- .../mc/forge/v1_11/launcher/ClientProxy.java | 12 ++- .../mc/forge/v1_11/launcher/CommonProxy.java | 9 +- .../forge/v1_11/launcher/FMLProgressBar.java | 3 +- .../forge/v1_11/launcher/ForgeLoadable.java | 43 +++++++++ .../forge/v1_11/launcher/NovaMinecraft.java | 96 +++++++++++++------ .../recipes/MinecraftItemIngredient.java | 2 +- .../forge/v1_11/recipes/RecipeConverter.java | 8 +- .../mc/forge/v1_11/render/RenderUtility.java | 8 +- .../forge/v1_11/util/MCLanguageManager.java | 25 +++-- .../mc/forge/v1_11/util/WrapUtility.java | 4 +- .../v1_11/wrapper/DirectionConverter.java | 4 +- .../v1_11/wrapper/block/BlockConverter.java | 7 +- .../v1_11/wrapper/block/backward/BWBlock.java | 4 +- .../v1_11/wrapper/block/forward/FWBlock.java | 12 ++- .../wrapper/block/forward/FWBlockSound.java | 52 ++++------ .../wrapper/block/forward/ProxyMaterial.java | 17 +++- .../v1_11/wrapper/block/world/BWWorld.java | 7 +- .../v1_11/wrapper/entity/EntityConverter.java | 9 +- .../v1_11/wrapper/item/ItemConverter.java | 23 ++--- .../v1_11/wrapper/DirectionConverterTest.java | 66 +++++++++++++ .../v1_11/wrapper/VectorConverterTest.java | 60 ++++++++++++ 23 files changed, 342 insertions(+), 135 deletions(-) create mode 100644 minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java create mode 100644 minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java create mode 100644 minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java index 28b1ea0fa..6aa8bf50c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java @@ -60,7 +60,7 @@ public ComponentInjector(Class baseClazz) { this.baseClazz = baseClazz; } - public synchronized T inject(ComponentProvider provider, Class[] typeArgs, Object[] args) { + public synchronized T inject(ComponentProvider provider, Class[] typeArgs, Object[] args) { try { List components = provider.components().stream() .filter(component -> component.getClass().getAnnotationsByType(Passthrough.class).length > 0) @@ -89,7 +89,7 @@ public synchronized T inject(ComponentProvider provider, Class[] typeArgs, Ob } } - private T inject(T instance, ComponentProvider provider) throws ReflectiveOperationException { + private T inject(T instance, ComponentProvider provider) throws ReflectiveOperationException { Field f = instance.getClass().getDeclaredField("$$_provider"); f.setAccessible(true); f.set(instance, provider); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java index af3f7a24a..753fb92d7 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java @@ -20,7 +20,7 @@ package nova.core.wrapper.mc.forge.v1_11.depmodules; -import nova.core.util.registry.LanguageManager; +import nova.core.language.LanguageManager; import nova.core.wrapper.mc.forge.v1_11.util.MCLanguageManager; import se.jbee.inject.bind.BinderModule; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java index 259cfcabd..93d5061bb 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java @@ -31,6 +31,8 @@ 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.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; @@ -50,16 +52,16 @@ */ public class ClientProxy extends CommonProxy { @Override - public void preInit() { - super.preInit(); + public void preInit(FMLPreInitializationEvent evt) { + super.preInit(evt); MinecraftForge.EVENT_BUS.register(RenderUtility.instance); ClientRegistry.bindTileEntitySpecialRenderer(FWTile.class, FWTileRenderer.instance); - RenderUtility.instance.preInit(); + RenderUtility.instance.preInit(evt); } @Override - public void init() { - super.init(); + public void init(FMLInitializationEvent evt) { + super.init(evt); RenderingRegistry.registerEntityRenderingHandler(FWEntity.class, FWEntityRenderer.instance); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java index ffd9fe85d..b840915a3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java @@ -21,11 +21,12 @@ package nova.core.wrapper.mc.forge.v1_11.launcher; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; -import nova.core.loader.Loadable; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileUpdater; @@ -34,14 +35,12 @@ import java.util.Set; -import net.minecraft.util.ResourceLocation; - /** * @author Calclavia */ -public class CommonProxy implements Loadable { +public class CommonProxy implements ForgeLoadable { @Override - public void preInit() { + public void preInit(FMLPreInitializationEvent evt) { GameRegistry.registerTileEntity(FWTile.class, "nova:novaTile"); GameRegistry.registerTileEntity(FWTileUpdater.class, "nova:novaTileUpdater"); EntityRegistry.registerModEntity(new ResourceLocation("nova", "novaEntity"), FWEntity.class, "novaEntity", 1, NovaMinecraft.instance, 64, 20, true); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java index 3f350a87a..b2c2b13cd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java @@ -6,13 +6,14 @@ package nova.core.wrapper.mc.forge.v1_11.launcher; import net.minecraftforge.fml.common.ProgressManager.ProgressBar; +import nova.core.util.AbstractProgressBar; /** * Wrapper class for FML progress bar that is shown when Minecraft boots. * * @author ExE Boss */ -public class FMLProgressBar extends nova.core.util.AbstractProgressBar { +public class FMLProgressBar extends AbstractProgressBar { private final ProgressBar progressBar; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java new file mode 100644 index 000000000..59de3eecf --- /dev/null +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.launcher; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +/** + * A mod interface implemented to receive FML mod loading event calls. + * + * @author ExE Boss + */ +// TODO Maybe replace with wrapper events. +public interface ForgeLoadable { + + default void preInit(FMLPreInitializationEvent event) { + } + + default void init(FMLInitializationEvent event) { + } + + default void postInit(FMLPostInitializationEvent event) { + } +} diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java index 958fc60a7..6e91e316a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java @@ -36,7 +36,6 @@ import net.minecraftforge.fml.relauncher.FMLInjectionData; import nova.core.deps.MavenDependency; import nova.core.event.ServerEvent; -import nova.core.loader.Loadable; import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule; import nova.core.wrapper.mc.forge.v1_11.depmodules.ComponentModule; @@ -64,6 +63,7 @@ import nova.internal.core.launch.InitializationException; import nova.internal.core.launch.NovaLauncher; +import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -87,7 +87,13 @@ public class NovaMinecraft { @Metadata(id) private static ModMetadata modMetadata; - private static Set nativeConverters; + private static Set nativeConverters; + private static Set novaWrappers = new HashSet<>(); + private static List novaModWrappers; + + public static void registerWrapper(ForgeLoadable wrapper) { + novaWrappers.add(wrapper); + } /** * ORDER OF LOADING. @@ -159,21 +165,8 @@ public void preInit(FMLPreInitializationEvent evt) { /** * Instantiate native loaders */ - nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof Loadable).map(n -> (Loadable) n).collect(Collectors.toSet()); - nativeConverters.stream().forEachOrdered(Loadable::preInit); - - Game.blocks().init(); - Game.items().init(); - Game.entities().init(); - Game.render().init(); - Game.language().init(); - - //Load preInit - progressBar = ProgressManager.push("Pre-initializing NOVA mods", modClasses.size(), true); - launcher.preInit(new FMLProgressBar(progressBar)); - while (progressBar.getStep() < progressBar.getSteps()) - progressBar.step("null"); - ProgressManager.pop(progressBar); + nativeConverters = Game.natives().getNativeConverters().stream().filter(n -> n instanceof ForgeLoadable).map(n -> (ForgeLoadable) n).collect(Collectors.toSet()); + nativeConverters.stream().forEachOrdered(loadable -> loadable.preInit(evt)); // Initiate config system TODO: Storables // launcher.getLoadedModMap().forEach((mod, loader) -> { @@ -181,7 +174,30 @@ public void preInit(FMLPreInitializationEvent evt) { // ConfigManager.instance.sync(config, loader.getClass().getPackage().getName()); // }); - proxy.preInit(); + Game.language().init(); + Game.render().init(); + Game.blocks().init(); + Game.items().init(); + Game.entities().init(); + + //Load preInit + int size = novaModWrappers.size() + novaWrappers.size(); + if (size > 0) { + progressBar = ProgressManager.push("Pre-initializing NOVA wrappers", size); + FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar); + novaModWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.preInit(evt); + }); + novaWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.preInit(evt); + }); + fmlProgressBar.finish(); + ProgressManager.pop(progressBar); + } + + proxy.preInit(evt); /** * Register event handlers @@ -199,11 +215,23 @@ public void preInit(FMLPreInitializationEvent evt) { @Mod.EventHandler public void init(FMLInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); - proxy.init(); - nativeConverters.stream().forEachOrdered(Loadable::init); - launcher.init(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + proxy.init(evt); + nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.init(evt)); + int size = novaModWrappers.size() + novaWrappers.size(); + if (size > 0) { + ProgressManager.ProgressBar progressBar = ProgressManager.push("Initializing NOVA wrappers", size); + FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar); + novaModWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.init(evt); + }); + novaWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.init(evt); + }); + fmlProgressBar.finish(); + ProgressManager.pop(progressBar); + } } catch (Exception e) { System.out.println("Error during init"); e.printStackTrace(); @@ -214,12 +242,24 @@ public void init(FMLInitializationEvent evt) { @Mod.EventHandler public void postInit(FMLPostInitializationEvent evt) { try { - ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA mods", NovaMinecraftPreloader.modClasses.size(), true); + proxy.postInit(evt); + nativeConverters.stream().forEachOrdered(forgeLoadable -> forgeLoadable.postInit(evt)); Game.recipes().init(); - proxy.postInit(); - nativeConverters.stream().forEachOrdered(Loadable::postInit); - launcher.postInit(new FMLProgressBar(progressBar)); - ProgressManager.pop(progressBar); + int size = novaModWrappers.size() + novaWrappers.size(); + if (size > 0) { + ProgressManager.ProgressBar progressBar = ProgressManager.push("Post-initializing NOVA wrappers", size); + FMLProgressBar fmlProgressBar = new FMLProgressBar(progressBar); + novaModWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.postInit(evt); + }); + novaWrappers.stream().forEachOrdered(wrapper -> { + fmlProgressBar.step(wrapper.getClass()); + wrapper.postInit(evt); + }); + fmlProgressBar.finish(); + ProgressManager.pop(progressBar); + } } catch (Exception e) { System.out.println("Error during postInit"); e.printStackTrace(); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java index f430a58f0..a9a67b0be 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java @@ -21,7 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11.recipes; import nova.core.item.Item; -import nova.core.recipes.crafting.SpecificItemIngredient; +import nova.core.recipes.ingredient.SpecificItemIngredient; import nova.internal.core.Game; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java index eb711986f..d7771f31a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java @@ -28,11 +28,11 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; import nova.core.item.Item; import nova.core.recipes.crafting.CraftingRecipe; -import nova.core.recipes.crafting.ItemIngredient; -import nova.core.recipes.crafting.OreItemIngredient; +import nova.core.recipes.ingredient.ItemIngredient; +import nova.core.recipes.ingredient.OreItemIngredient; import nova.core.recipes.crafting.ShapedCraftingRecipe; import nova.core.recipes.crafting.ShapelessCraftingRecipe; -import nova.core.recipes.crafting.SpecificItemIngredient; +import nova.core.recipes.ingredient.SpecificItemIngredient; import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; import nova.internal.core.Game; @@ -111,7 +111,7 @@ private static String findOreDictEntryFor(List ingredient) { } private static ItemStack wrapSpecific(SpecificItemIngredient ingredient) { - for (Item item : ingredient.getExampleItems().get()) { + for (Item item : ingredient.getExampleItems()) { return Game.natives().toNative(item.getFactory().build()); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java index 0c3d52672..1180e95cd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java @@ -28,13 +28,13 @@ import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.IResource; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -43,6 +43,7 @@ import nova.core.render.texture.BlockTexture; import nova.core.render.texture.ItemTexture; import nova.core.render.texture.Texture; +import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWEmptyModel; @@ -71,7 +72,7 @@ * @author Calclavia */ @SideOnly(Side.CLIENT) -public class RenderUtility { +public class RenderUtility implements ForgeLoadable { public static final ResourceLocation particleResource = new ResourceLocation("textures/particle/particles.png"); @@ -231,7 +232,8 @@ public void onModelBakeEvent(ModelBakeEvent event) { }); } - public void preInit() { + @Override + public void preInit(FMLPreInitializationEvent event) { //Load models Game.render().modelProviders.forEach(m -> { ResourceLocation resource = new ResourceLocation(m.domain, "models/" + m.name + "." + m.getType()); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java index 5b7ad087b..49471858a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java @@ -22,34 +22,31 @@ import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.common.FMLCommonHandler; -import nova.core.util.registry.LanguageManager; -import nova.internal.core.Game; +import nova.core.language.LanguageManager; +import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; /** * @deprecated Removed in Forge 1.9 * * @author Calclavia */ -@Deprecated -public class MCLanguageManager extends LanguageManager { +public class MCLanguageManager extends LanguageManager implements ForgeLoadable { - @Override - public void register(String language, String key, String value) { -// LanguageRegistry.instance().addStringLocalization(key, language, value); + public MCLanguageManager() { + NovaMinecraft.registerWrapper(this); } @Override public String getCurrentLanguage() { - return FMLCommonHandler.instance().getCurrentLanguage(); + return FMLCommonHandler.instance().getCurrentLanguage().replace('_', '-'); } @Override public String translate(String key) { - return I18n.translateToLocal(key); - } - - @Override - public void init() { - Game.events().publish(new Init(this)); + String value = super.translate(key); + if (value.equals(key)) + value = I18n.translateToLocal(key); + return value; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java index 26b530a73..1f34147c4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java @@ -36,6 +36,8 @@ */ public class WrapUtility { + private WrapUtility() {} + public static Optional getNovaPlayer(EntityPlayer player) { return ((Entity)Game.natives().toNova(player)).components.getOp(Player.class); } @@ -58,7 +60,7 @@ public static EntityPlayer getMCPlayer(Optional player) { return (EntityPlayer)((BWEntity)entity).entity; } - // TODO + // TODO: Implement FWEntityPlayer return null; } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java index 334bdbcdd..88576e389 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java @@ -27,7 +27,9 @@ public Class getNativeSide() { @Override public Direction toNova(EnumFacing nativeObj) { - switch (nativeObj) { + if (null == nativeObj) + return Direction.UNKNOWN; + else switch (nativeObj) { case DOWN: return Direction.DOWN; case UP: return Direction.UP; case NORTH: return Direction.NORTH; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java index 7c8442567..43759b067 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java @@ -25,14 +25,15 @@ import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.Block; import nova.core.block.BlockFactory; import nova.core.block.BlockManager; import nova.core.component.Category; import nova.core.event.BlockEvent; -import nova.core.loader.Loadable; import nova.core.nativewrapper.NativeConverter; +import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; @@ -48,7 +49,7 @@ * @author Calclavia */ //TODO: Should be -public class BlockConverter implements NativeConverter, Loadable { +public class BlockConverter implements NativeConverter, ForgeLoadable { /** * A map of all blockFactory to MC blocks registered */ @@ -100,7 +101,7 @@ public net.minecraft.block.Block toNative(BlockFactory blockFactory) { * Register all Nova blocks */ @Override - public void preInit() { + public void preInit(FMLPreInitializationEvent evt) { registerMinecraftToNOVA(); registerNOVAToMinecraft(); } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java index 07633a8fa..41732269c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java @@ -69,7 +69,7 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { transform.setWorld(world); transform.setPosition(pos); - components.add(new BlockProperty.Opacity().setLightTransmission(!blockState().getMaterial().blocksLight())); + components.add(new BlockProperty.Opacity().setOpacity(blockState().getMaterial().blocksLight() ? 1 : 0)); BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); SoundType soundType; @@ -77,7 +77,7 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { soundType = mcBlock.getSoundType(blockState(), (net.minecraft.world.World)getMcBlockAccess(), new BlockPos(x(), y(), z()), null); else soundType = mcBlock.getSoundType(); - + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), soundType.getPlaceSound().getSoundName().getResourcePath())); diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java index 99d32ea39..82b32841a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java @@ -48,6 +48,7 @@ import nova.core.retention.Storable; import nova.core.sound.Sound; import nova.core.util.Direction; +import nova.core.util.math.MathUtil; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; import nova.internal.core.Game; @@ -76,9 +77,11 @@ public class FWBlock extends net.minecraft.block.Block { private static Material getMcMaterial(BlockFactory factory) { Block dummy = factory.build(); - if (dummy.components.has(BlockProperty.Opacity.class)) { + if (dummy.components.has(BlockProperty.Opacity.class) || dummy.components.has(BlockProperty.Replaceable.class)) { // TODO allow color selection - return new ProxyMaterial(MapColor.GRAY, dummy.components.get(BlockProperty.Opacity.class)); + return new ProxyMaterial(MapColor.GRAY, + dummy.components.getOp(BlockProperty.Opacity.class), + dummy.components.getOp(BlockProperty.Replaceable.class)); } else { return Material.PISTON; } @@ -221,7 +224,6 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En return evt.result; } - @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); @@ -290,7 +292,7 @@ public boolean isOpaqueCube(IBlockState state) { @Override public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { - Optional blockCollider = dummy.components.getOp(Collider.class); + Optional blockCollider = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).components.getOp(Collider.class); if (blockCollider.isPresent()) { return blockCollider.get().isCube.get(); @@ -317,7 +319,7 @@ public int getLightValue(IBlockState state, IBlockAccess access, BlockPos pos) { Optional opEmitter = blockInstance.components.getOp(LightEmitter.class); if (opEmitter.isPresent()) { - return Math.round(opEmitter.get().emittedLevel.get() * 15.0F); + return (int) MathUtil.clamp(Math.round(opEmitter.get().emittedLevel.getAsDouble() * 15), 0, 15); } else { return 0; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java index aa1981bc0..6f9729e6d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java @@ -4,64 +4,44 @@ import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; -import nova.core.block.component.BlockProperty.BlockSound; -import nova.core.sound.Sound; +import nova.core.block.component.BlockProperty; /** - * @author winsock, soniex2 + * @author winsock, soniex2, ExE Boss */ public class FWBlockSound extends SoundType { - private final BlockSound blockSound; + private final BlockProperty.BlockSound blockSound; /** * Construct a new FWBlockSound * @param blockSound The BlockSound to use. */ - public FWBlockSound(BlockSound blockSound) { + public FWBlockSound(BlockProperty.BlockSound blockSound) { super(1f, 1f, SoundEvents.BLOCK_STONE_BREAK, SoundEvents.BLOCK_STONE_STEP, SoundEvents.BLOCK_STONE_PLACE, SoundEvents.BLOCK_STONE_HIT, SoundEvents.BLOCK_STONE_FALL); this.blockSound = blockSound; } @Override public SoundEvent getBreakSound() { - if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.BREAK)) { - Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.BREAK); - if (sound.domain.isEmpty() && !sound.name.contains(".")) { - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("dig." + sound.name)); - return event == null ? super.getPlaceSound() : event; - } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); - return event == null ? super.getPlaceSound() : event; - } - return super.getBreakSound(); + return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK) + .map(sound -> (sound.domain.isEmpty() && !sound.name.contains(".")) ? "dig." + sound.name : sound.getID()) + .map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID))) + .orElseGet(super::getBreakSound); } @Override public SoundEvent getStepSound() { - if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.WALK)) { - Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.WALK); - if (sound.domain.isEmpty() && !sound.name.contains(".")) { - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation("step." + sound.name)); - return event == null ? super.getPlaceSound() : event; - } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); - return event == null ? super.getPlaceSound() : event; - } - return super.getStepSound(); + return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK) + .map(sound -> (sound.domain.isEmpty() && !sound.name.contains(".")) ? "step." + sound.name : sound.getID()) + .map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID))) + .orElseGet(super::getBreakSound); } @Override public SoundEvent getPlaceSound() { - if (blockSound.blockSoundSoundMap.containsKey(BlockSound.BlockSoundTrigger.WALK)) { - Sound sound = blockSound.blockSoundSoundMap.get(BlockSound.BlockSoundTrigger.WALK); - if (sound.domain.isEmpty()) { - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.name)); - return event == null ? super.getPlaceSound() : event; - } - SoundEvent event = SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())); - return event == null ? super.getPlaceSound() : event; - } - // By default MC uses the block break sound for block placement - return super.getPlaceSound(); + return blockSound.getSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE) + .map(sound -> sound.domain.isEmpty() ? "step." + sound.name : sound.getID()) + .map(soundID -> SoundEvent.REGISTRY.getObject(new ResourceLocation(soundID))) + .orElseGet(super::getPlaceSound); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java index 46b2848ca..2987b8a36 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java @@ -3,32 +3,39 @@ import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import nova.core.block.component.BlockProperty; -import nova.core.block.component.BlockProperty.Opacity; + +import java.util.Optional; /** * @author soniex2 */ public class ProxyMaterial extends Material { - private final Opacity opacity; + private final Optional opacity; + private final Optional replaceable; /** * Construct a new proxy material. * @param color The map color. * @param opacity The Opacity to use. */ - public ProxyMaterial(MapColor color, Opacity opacity) { + public ProxyMaterial(MapColor color, Optional opacity, Optional replaceable) { super(color); this.opacity = opacity; + this.replaceable = replaceable; } @Override public boolean blocksLight() { - return opacity.allowsLightThrough; + return opacity.isPresent() ? opacity.get().opacity == 1 : super.blocksLight(); } @Override public boolean isOpaque() { - return opacity.allowsLightThrough; + return opacity.isPresent() ? opacity.get().opacity == 1 : super.isOpaque(); } + @Override + public boolean isReplaceable() { + return replaceable.isPresent() || super.isReplaceable(); + } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java index 36a6055bf..3f9e158f7 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java @@ -45,9 +45,11 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; + import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; +import nova.core.component.misc.FactoryProvider; /** * The backwards world wrapper. @@ -91,7 +93,10 @@ public Optional getBlock(Vector3D position) { } else if (mcBlock instanceof FWBlock) { return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position)); } else { - return Optional.of(new BWBlock(mcBlock, this, position)); + BWBlock block = new BWBlock(mcBlock, this, position); + Game.blocks().get(net.minecraft.block.Block.REGISTRY.getNameForObject(mcBlock).toString()) + .ifPresent(blockFactory -> block.components.getOrAdd(new FactoryProvider(blockFactory))); + return Optional.of(block); } } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java index da3e8f418..cea64c74e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java @@ -21,21 +21,22 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.entity; import net.minecraft.util.EnumParticleTypes; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; -import nova.core.loader.Loadable; import nova.core.nativewrapper.NativeConverter; +import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; import nova.internal.core.Game; import java.util.Optional; -public class EntityConverter implements NativeConverter, Loadable { +public class EntityConverter implements NativeConverter, ForgeLoadable { @Override public Class getNovaSide() { @@ -79,7 +80,7 @@ public net.minecraft.entity.Entity toNative(Entity novaObj) { @Override @SideOnly(Side.CLIENT) - public void preInit() { + public void preInit(FMLPreInitializationEvent evt) { /** * Backward register all particle effects */ diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java index 0889f48dc..33f6cdf7a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java @@ -20,34 +20,31 @@ package nova.core.wrapper.mc.forge.v1_11.wrapper.item; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItemFactory; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWNBTTagCompound; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; import com.google.common.collect.HashBiMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.block.BlockFactory; import nova.core.component.Category; +import nova.core.event.ItemEvent; import nova.core.item.Item; import nova.core.item.ItemBlock; import nova.core.item.ItemFactory; -import nova.core.item.ItemManager; -import nova.core.event.ItemEvent; -import nova.core.loader.Loadable; -import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItemFactory; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWNBTTagCompound; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; -import nova.internal.core.launch.ModLoader; import java.util.Arrays; import java.util.Objects; @@ -58,7 +55,7 @@ * The main class responsible for wrapping items. * @author Calclavia, Stan Hebben */ -public class ItemConverter implements NativeConverter, Loadable { +public class ItemConverter implements NativeConverter, ForgeLoadable { /** * A map of all items registered @@ -176,7 +173,7 @@ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { * Register all Nova blocks */ @Override - public void preInit() { + public void preInit(FMLPreInitializationEvent evt) { registerNOVAItemsToMinecraft(); registerMinecraftItemsToNOVA(); registerSubtypeResolution(); @@ -270,7 +267,7 @@ private void onIDNotFound(ItemEvent.IDNotFound event) { int meta = Integer.parseInt(event.id.substring(lastColon + 1)); String itemID = event.id.substring(0, lastColon); - net.minecraft.item.Item item = (net.minecraft.item.Item) net.minecraft.item.Item.REGISTRY.getObject(new ResourceLocation(itemID)); + net.minecraft.item.Item item = net.minecraft.item.Item.REGISTRY.getObject(new ResourceLocation(itemID)); if (item == null || !item.getHasSubtypes()) { return; } diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java new file mode 100644 index 000000000..7c377bfcc --- /dev/null +++ b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper; + +import net.minecraft.util.EnumFacing; +import nova.core.util.Direction; +import org.junit.Before; +import org.junit.Test; + +import static nova.testutils.NovaAssertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Used to test {@link DirectionConverter}. + * + * @author ExE Boss + */ +public class DirectionConverterTest { + + DirectionConverter converter; + + @Before + public void setUp() { + converter = new DirectionConverter(); + } + + @Test + public void testToNova() { + assertThat(converter.toNova(EnumFacing.DOWN)).isEqualTo(Direction.DOWN); + assertThat(converter.toNova(EnumFacing.UP)).isEqualTo(Direction.UP); + assertThat(converter.toNova(EnumFacing.NORTH)).isEqualTo(Direction.NORTH); + assertThat(converter.toNova(EnumFacing.SOUTH)).isEqualTo(Direction.SOUTH); + assertThat(converter.toNova(EnumFacing.WEST)).isEqualTo(Direction.WEST); + assertThat(converter.toNova(EnumFacing.EAST)).isEqualTo(Direction.EAST); + assertThat(converter.toNova(null)).isEqualTo(Direction.UNKNOWN); + } + + @Test + public void testToNative() { + assertThat(converter.toNative(Direction.DOWN)).isEqualTo(EnumFacing.DOWN); + assertThat(converter.toNative(Direction.UP)).isEqualTo(EnumFacing.UP); + assertThat(converter.toNative(Direction.NORTH)).isEqualTo(EnumFacing.NORTH); + assertThat(converter.toNative(Direction.SOUTH)).isEqualTo(EnumFacing.SOUTH); + assertThat(converter.toNative(Direction.WEST)).isEqualTo(EnumFacing.WEST); + assertThat(converter.toNative(Direction.EAST)).isEqualTo(EnumFacing.EAST); + assertThat(converter.toNative(Direction.UNKNOWN)).isNull(); + } +} diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java new file mode 100644 index 000000000..98be6e20f --- /dev/null +++ b/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11.wrapper; + +import net.minecraft.util.math.BlockPos; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.junit.Before; +import org.junit.Test; + +import static nova.testutils.NovaAssertions.assertThat; + +/** + * Used to test {@link VectorConverter}. + * + * @author ExE Boss + */ +public class VectorConverterTest { + + VectorConverter converter; + + @Before + public void setUp() { + converter = new VectorConverter(); + } + + @Test + public void testToNova() { + for (int x = -1; x <= 1; x++) + for (int y = -1; y <= 1; y++) + for (int z = -1; z <= 1; z++) + assertThat(converter.toNova(new BlockPos(x, y, z))).isEqualTo(new Vector3D(x, y, z)); + } + + @Test + @SuppressWarnings("unchecked") + public void testToNative() { + for (int x = -1; x <= 1; x++) + for (int y = -1; y <= 1; y++) + for (int z = -1; z <= 1; z++) + assertThat(converter.toNative(new Vector3D(x, y, z))).isEqualTo(new BlockPos(x, y, z)); + } +} From f0be787967b2e776d4dcb5eb52b90a89a4736527 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 27 Feb 2017 17:15:33 +0100 Subject: [PATCH 33/61] Upgrade to 1.11.2 --- minecraft/.gitignore | 2 +- minecraft/{1.11 => 1.11.2}/.gitignore | 0 minecraft/{1.11 => 1.11.2}/build.gradle | 16 +++--- minecraft/{1.11 => 1.11.2}/gradle.properties | 4 +- .../mc/forge/v1_11_2}/NovaMinecraftCore.java | 8 +-- .../v1_11_2}/NovaMinecraftPreloader.java | 14 ++--- .../forge/v1_11_2}/asm/StaticForwarder.java | 6 +-- .../mc/forge/v1_11_2}/asm/lib/ASMHelper.java | 2 +- .../v1_11_2}/asm/lib/CC_ClassWriter.java | 2 +- .../asm/lib/ClassHeirachyManager.java | 2 +- .../v1_11_2}/asm/lib/ComponentInjector.java | 2 +- .../v1_11_2}/asm/lib/InsnListPrinter.java | 2 +- .../asm/lib/InstructionComparator.java | 2 +- .../mc/forge/v1_11_2}/asm/lib/ObfMapping.java | 2 +- .../v1_11_2}/asm/lib/TemplateInjector.java | 2 +- .../forge/v1_11_2}/asm/lib/package-info.java | 2 +- .../asm/transformers/ChunkTransformer.java | 6 +-- .../transformers/TileEntityTransformer.java | 8 +-- .../asm/transformers/Transformer.java | 2 +- .../asm/transformers/Transformers.java | 4 +- .../v1_11_2}/depmodules/ClientModule.java | 4 +- .../v1_11_2}/depmodules/ComponentModule.java | 4 +- .../v1_11_2}/depmodules/GameInfoModule.java | 2 +- .../forge/v1_11_2}/depmodules/KeyModule.java | 4 +- .../v1_11_2}/depmodules/LanguageModule.java | 4 +- .../v1_11_2}/depmodules/NetworkModule.java | 4 +- .../v1_11_2}/depmodules/RenderModule.java | 4 +- .../forge/v1_11_2}/depmodules/SaveModule.java | 4 +- .../v1_11_2}/depmodules/TickerModule.java | 2 +- .../forge/v1_11_2}/launcher/ClientProxy.java | 20 +++---- .../forge/v1_11_2}/launcher/CommonProxy.java | 12 ++--- .../v1_11_2}/launcher/FMLEventHandler.java | 2 +- .../v1_11_2}/launcher/FMLProgressBar.java | 2 +- .../v1_11_2}/launcher/ForgeEventHandler.java | 4 +- .../v1_11_2}/launcher/ForgeLoadable.java | 2 +- .../v1_11_2}/launcher/NovaMinecraft.java | 49 ++++++++++-------- .../v1_11_2}/manager/FWClientManager.java | 6 +-- .../v1_11_2}/manager/MCRetentionManager.java | 2 +- .../manager/config/NovaGuiConfig.java | 2 +- .../manager/config/NovaGuiFactory.java | 2 +- .../mc/forge/v1_11_2}/network/MCPacket.java | 2 +- .../network/discriminator/NovaPacket.java | 6 +-- .../network/discriminator/PacketAbstract.java | 4 +- .../discriminator/PacketPlayerItem.java | 4 +- .../network/netty/ChannelHandler.java | 8 +-- .../network/netty/MCNetworkManager.java | 12 ++--- .../network/netty/MCPacketHandler.java | 8 +-- .../v1_11_2}/recipes/MCCraftingGrid.java | 8 +-- .../v1_11_2}/recipes/MCCraftingRecipe.java | 2 +- .../recipes/MinecraftItemIngredient.java | 2 +- .../recipes/MinecraftRecipeRegistry.java | 4 +- .../v1_11_2}/recipes/NovaCraftingGrid.java | 2 +- .../recipes/NovaCraftingGridContainer.java | 2 +- .../v1_11_2}/recipes/NovaCraftingRecipe.java | 2 +- .../v1_11_2}/recipes/RecipeConverter.java | 4 +- .../v1_11_2}/recipes/ShapedRecipeBasic.java | 2 +- .../v1_11_2}/recipes/ShapedRecipeOre.java | 2 +- .../recipes/ShapelessRecipeBasic.java | 2 +- .../v1_11_2}/recipes/ShapelessRecipeOre.java | 2 +- .../render/NovaFolderResourcePack.java | 4 +- .../v1_11_2}/render/NovaResourcePack.java | 4 +- .../forge/v1_11_2}/render/RenderUtility.java | 14 ++--- .../forge/v1_11_2}/util/MCInputManager.java | 2 +- .../v1_11_2}/util/MCLanguageManager.java | 6 +-- .../forge/v1_11_2}/util/ModCreativeTab.java | 2 +- .../v1_11_2}/util/ObfuscationConstants.java | 2 +- .../forge/v1_11_2}/util/ReflectionUtil.java | 2 +- .../mc/forge/v1_11_2}/util/WrapUtility.java | 4 +- .../mc/forge/v1_11_2}/util/WrapperEvent.java | 14 ++--- .../v1_11_2}/wrapper/DirectionConverter.java | 2 +- .../v1_11_2}/wrapper/VectorConverter.java | 2 +- .../wrapper/block/BlockConverter.java | 14 ++--- .../wrapper/block/backward/BWBlock.java | 21 ++++---- .../wrapper/block/forward/BlockPosition.java | 2 +- .../wrapper/block/forward/FWBlock.java | 8 +-- .../wrapper/block/forward/FWBlockSound.java | 2 +- .../wrapper/block/forward/FWTile.java | 4 +- .../wrapper/block/forward/FWTileLoader.java | 6 +-- .../wrapper/block/forward/FWTileRenderer.java | 6 +-- .../wrapper/block/forward/FWTileUpdater.java | 2 +- .../block/forward/MCBlockTransform.java | 2 +- .../wrapper/block/forward/ProxyMaterial.java | 2 +- .../v1_11_2}/wrapper/block/world/BWWorld.java | 14 ++--- .../wrapper/block/world/WorldConverter.java | 2 +- .../forward/FWCapabilityProvider.java | 2 +- .../wrapper/cuboid/CuboidConverter.java | 2 +- .../v1_11_2}/wrapper/data/DataWrapper.java | 2 +- .../wrapper/entity/EntityConverter.java | 12 ++--- .../wrapper/entity/backward/BWEntity.java | 8 +-- .../wrapper/entity/forward/BWRigidBody.java | 2 +- .../wrapper/entity/forward/FWEntity.java | 6 +-- .../entity/forward/FWEntityRenderer.java | 8 +-- .../entity/forward/MCEntityTransform.java | 2 +- .../wrapper/inventory/BWInventory.java | 2 +- .../wrapper/inventory/FWInventory.java | 4 +- .../wrapper/inventory/InventoryConverter.java | 2 +- .../v1_11_2}/wrapper/item/ItemConverter.java | 18 +++---- .../wrapper/item/ItemWrapperMethods.java | 4 +- .../item/OreDictionaryIntegration.java | 4 +- .../wrapper/item/backward/BWItem.java | 2 +- .../wrapper/item/backward/BWItemFactory.java | 4 +- .../v1_11_2}/wrapper/item/forward/FWItem.java | 8 +-- .../wrapper/item/forward/FWItemBlock.java | 10 ++-- .../item/forward/FWNBTTagCompound.java | 2 +- .../wrapper/particle/backward/BWParticle.java | 6 +-- .../wrapper/particle/forward/FWParticle.java | 6 +-- .../particle/forward/MCParticleTransform.java | 2 +- .../backward/BWClientRenderManager.java | 2 +- .../wrapper/render/backward/BWModel.java | 4 +- .../render/backward/BWRenderManager.java | 2 +- .../wrapper/render/forward/FWEmptyModel.java | 2 +- .../render/forward/FWSmartBlockModel.java | 4 +- .../render/forward/FWSmartItemModel.java | 4 +- .../wrapper/render/forward/FWSmartModel.java | 4 +- .../src/main/resources/META-INF/nova_at.cfg | 0 .../resources/assets/nova/textures/NOVA.png | Bin .../src/main/resources/fmlbranding.properties | 0 .../src/main/resources/mcmod.info | 0 .../v1_11_2}/launcher/NovaLauncherTest.java | 16 +++--- .../wrapper/DirectionConverterTest.java | 3 +- .../v1_11_2}/wrapper/VectorConverterTest.java | 2 +- settings.gradle | 2 +- 122 files changed, 305 insertions(+), 302 deletions(-) rename minecraft/{1.11 => 1.11.2}/.gitignore (100%) rename minecraft/{1.11 => 1.11.2}/build.gradle (82%) rename minecraft/{1.11 => 1.11.2}/gradle.properties (79%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/NovaMinecraftCore.java (86%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/NovaMinecraftPreloader.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/StaticForwarder.java (91%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/ASMHelper.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/CC_ClassWriter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/ClassHeirachyManager.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/ComponentInjector.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/InsnListPrinter.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/InstructionComparator.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/ObfMapping.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/TemplateInjector.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/lib/package-info.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/transformers/ChunkTransformer.java (93%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/transformers/TileEntityTransformer.java (91%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/transformers/Transformer.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/asm/transformers/Transformers.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/ClientModule.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/ComponentModule.java (88%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/GameInfoModule.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/KeyModule.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/LanguageModule.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/NetworkModule.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/RenderModule.java (87%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/SaveModule.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/depmodules/TickerModule.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/ClientProxy.java (86%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/CommonProxy.java (83%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/FMLEventHandler.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/FMLProgressBar.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/ForgeEventHandler.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/ForgeLoadable.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/NovaMinecraft.java (82%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/manager/FWClientManager.java (86%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/manager/MCRetentionManager.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/manager/config/NovaGuiConfig.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/manager/config/NovaGuiFactory.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/MCPacket.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/discriminator/NovaPacket.java (91%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/discriminator/PacketAbstract.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/discriminator/PacketPlayerItem.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/netty/ChannelHandler.java (83%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/netty/MCNetworkManager.java (93%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/network/netty/MCPacketHandler.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/MCCraftingGrid.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/MCCraftingRecipe.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/MinecraftItemIngredient.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/MinecraftRecipeRegistry.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/NovaCraftingGrid.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/NovaCraftingGridContainer.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/NovaCraftingRecipe.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/RecipeConverter.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/ShapedRecipeBasic.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/ShapedRecipeOre.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/ShapelessRecipeBasic.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/recipes/ShapelessRecipeOre.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/render/NovaFolderResourcePack.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/render/NovaResourcePack.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/render/RenderUtility.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/MCInputManager.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/MCLanguageManager.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/ModCreativeTab.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/ObfuscationConstants.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/ReflectionUtil.java (99%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/WrapUtility.java (93%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/util/WrapperEvent.java (89%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/DirectionConverter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/VectorConverter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/BlockConverter.java (91%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/backward/BWBlock.java (90%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/BlockPosition.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWBlock.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWBlockSound.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWTile.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWTileLoader.java (93%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWTileRenderer.java (91%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/FWTileUpdater.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/MCBlockTransform.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/forward/ProxyMaterial.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/world/BWWorld.java (92%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/block/world/WorldConverter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/capability/forward/FWCapabilityProvider.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/cuboid/CuboidConverter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/data/DataWrapper.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/EntityConverter.java (86%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/backward/BWEntity.java (92%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/forward/BWRigidBody.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/forward/FWEntity.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/forward/FWEntityRenderer.java (93%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/entity/forward/MCEntityTransform.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/inventory/BWInventory.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/inventory/FWInventory.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/inventory/InventoryConverter.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/ItemConverter.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/ItemWrapperMethods.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/OreDictionaryIntegration.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/backward/BWItem.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/backward/BWItemFactory.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/forward/FWItem.java (90%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/forward/FWItemBlock.java (88%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/item/forward/FWNBTTagCompound.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/particle/backward/BWParticle.java (98%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/particle/forward/FWParticle.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/particle/forward/MCParticleTransform.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/backward/BWClientRenderManager.java (97%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/backward/BWModel.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/backward/BWRenderManager.java (94%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/forward/FWEmptyModel.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/forward/FWSmartBlockModel.java (96%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/forward/FWSmartItemModel.java (95%) rename minecraft/{1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/render/forward/FWSmartModel.java (97%) rename minecraft/{1.11 => 1.11.2}/src/main/resources/META-INF/nova_at.cfg (100%) rename minecraft/{1.11 => 1.11.2}/src/main/resources/assets/nova/textures/NOVA.png (100%) rename minecraft/{1.11 => 1.11.2}/src/main/resources/fmlbranding.properties (100%) rename minecraft/{1.11 => 1.11.2}/src/main/resources/mcmod.info (100%) rename minecraft/{1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2}/launcher/NovaLauncherTest.java (79%) rename minecraft/{1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/DirectionConverterTest.java (95%) rename minecraft/{1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11 => 1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2}/wrapper/VectorConverterTest.java (97%) diff --git a/minecraft/.gitignore b/minecraft/.gitignore index 896c508ad..dc5338fca 100644 --- a/minecraft/.gitignore +++ b/minecraft/.gitignore @@ -3,6 +3,6 @@ !/build.gradle !/.gitignore -!/1.11 +!/1.11.2 !/1.8 !/1.7 diff --git a/minecraft/1.11/.gitignore b/minecraft/1.11.2/.gitignore similarity index 100% rename from minecraft/1.11/.gitignore rename to minecraft/1.11.2/.gitignore diff --git a/minecraft/1.11/build.gradle b/minecraft/1.11.2/build.gradle similarity index 82% rename from minecraft/1.11/build.gradle rename to minecraft/1.11.2/build.gradle index 7b369edcd..09dc17657 100644 --- a/minecraft/1.11/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -4,8 +4,8 @@ apply plugin: "com.jfrog.artifactory" apply plugin: "com.github.johnrengelman.shadow" apply plugin: "maven-publish" -idea.module.name = "Core-MC-1.11" -archivesBaseName = "NOVA-Core-Wrapper-MC1.11" +idea.module.name = "Core-MC-1.11.2" +archivesBaseName = "NOVA-Core-Wrapper-MC1.11.2" configurations { fatJar @@ -23,7 +23,7 @@ dependencies { jar { manifest { - attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftCore' attributes 'FMLCorePluginContainsFMLMod': 'true' attributes 'FMLAT': 'nova_at.cfg' } @@ -33,7 +33,7 @@ task deobfJar(type: Jar) { from sourceSets.main.output classifier = 'deobf' manifest { - attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftCore' attributes 'FMLCorePluginContainsFMLMod': 'true' attributes 'FMLAT': 'nova_at.cfg' } @@ -51,7 +51,7 @@ task fatJar(type: Jar) { with jar manifest { - attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + attributes 'FMLCorePlugin': 'nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftCore' attributes 'FMLCorePluginContainsFMLMod': 'true' attributes 'FMLAT': 'nova_at.cfg' } @@ -103,7 +103,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20161220' + mappings = 'snapshot_20170227' runDir = "run" } @@ -113,11 +113,11 @@ reobf { } runClient { - jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftCore' } runServer { - jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11.NovaMinecraftCore' + jvmArgs '-Dfml.coreMods.load=nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftCore' } processResources { diff --git a/minecraft/1.11/gradle.properties b/minecraft/1.11.2/gradle.properties similarity index 79% rename from minecraft/1.11/gradle.properties rename to minecraft/1.11.2/gradle.properties index 3d511bebd..dfff6bc70 100644 --- a/minecraft/1.11/gradle.properties +++ b/minecraft/1.11.2/gradle.properties @@ -1,7 +1,7 @@ group = nova.core -minecraft.version = 1.11 -forge.version = 13.19.1.2189 +minecraft.version = 1.11.2 +forge.version = 13.20.0.2228 forgeGradleVersion = 2.2-SNAPSHOT packaging = jar diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftCore.java similarity index 86% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftCore.java index ac9c77799..04f4eeb53 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftCore.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftCore.java @@ -18,15 +18,15 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11; +package nova.core.wrapper.mc.forge.v1_11_2; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion; -import nova.core.wrapper.mc.forge.v1_11.asm.transformers.Transformers; +import nova.core.wrapper.mc.forge.v1_11_2.asm.transformers.Transformers; import java.util.Map; -@MCVersion(value = "1.11") +@MCVersion(value = "1.11.2") public class NovaMinecraftCore implements IFMLLoadingPlugin { @Override public String[] getASMTransformerClass() { @@ -35,7 +35,7 @@ public String[] getASMTransformerClass() { @Override public String getModContainerClass() { - return "nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader"; + return "nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader"; } @Override diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index a3aee5cf0..741234fac 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11; +package nova.core.wrapper.mc.forge.v1_11_2; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; @@ -42,9 +42,9 @@ import net.minecraftforge.fml.relauncher.Side; import nova.core.loader.Mod; import nova.core.util.ClassLoaderUtil; -import nova.core.wrapper.mc.forge.v1_11.render.NovaFolderResourcePack; -import nova.core.wrapper.mc.forge.v1_11.render.NovaResourcePack; -import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.render.NovaFolderResourcePack; +import nova.core.wrapper.mc.forge.v1_11_2.render.NovaResourcePack; +import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import java.io.File; import java.lang.reflect.Field; @@ -234,7 +234,7 @@ public void load(FMLConstructionEvent event) { fakeMeta.name = annotation.name(); fakeMeta.version = annotation.version(); fakeMeta.description = annotation.description(); - newMods.add(new DummyNovaMod(fakeMeta, mod)); + newMods.add(new NovaModContainer(fakeMeta, mod)); }); //TODO: Use AT ReflectionUtil.setPrivateObject(Loader.instance(), newMods, "mods"); @@ -308,11 +308,11 @@ public void registerResourcePacks() { /** * A fake NovaMod to inject into FML. */ - private static class DummyNovaMod extends DummyModContainer { + private static class NovaModContainer extends DummyModContainer { private final Class mod; private File source = null; - public DummyNovaMod(ModMetadata meta, Class mod) { + public NovaModContainer(ModMetadata meta, Class mod) { super(meta); this.mod = mod; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index 43dc0a3e9..bd69056c0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm; +package nova.core.wrapper.mc.forge.v1_11_2.asm; import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; @@ -27,8 +27,8 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import nova.core.event.BlockEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileLoader; +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.FWTileLoader; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java index 956054244..bd72563a0 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ASMHelper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/CC_ClassWriter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/CC_ClassWriter.java index 383fd30a0..ad30b23c6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/CC_ClassWriter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/CC_ClassWriter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import org.objectweb.asm.ClassWriter; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java index 726369343..0d971e5ba 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ClassHeirachyManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.LaunchClassLoader; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java index 6aa8bf50c..5c33ab1b5 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ComponentInjector.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import nova.core.component.Component; import nova.core.component.ComponentProvider; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InsnListPrinter.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InsnListPrinter.java index 4a5cba910..42bb4fc52 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InsnListPrinter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InsnListPrinter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InstructionComparator.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InstructionComparator.java index df12d50f4..bde3b868e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/InstructionComparator.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/InstructionComparator.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.FieldInsnNode; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ObfMapping.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ObfMapping.java index 95776e95d..b49b235f8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/ObfMapping.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ObfMapping.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import com.google.common.base.Objects; import net.minecraft.launchwrapper.LaunchClassLoader; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java index 52f7fff99..d61214e85 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/TemplateInjector.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; import com.google.common.collect.HashBiMap; import org.objectweb.asm.tree.ClassNode; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/package-info.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/package-info.java index 136f2221c..492b88b39 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/lib/package-info.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/package-info.java @@ -24,4 +24,4 @@ * @author Calclavia */ -package nova.core.wrapper.mc.forge.v1_11.asm.lib; \ No newline at end of file +package nova.core.wrapper.mc.forge.v1_11_2.asm.lib; \ No newline at end of file diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java index e7ed4dda9..457e8992e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/ChunkTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.transformers; +package nova.core.wrapper.mc.forge.v1_11_2.asm.transformers; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ObfMapping; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ObfMapping; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java index db682a886..5217f145d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java @@ -18,11 +18,11 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.transformers; +package nova.core.wrapper.mc.forge.v1_11_2.asm.transformers; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.InstructionComparator; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ObfMapping; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.InstructionComparator; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ObfMapping; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodInsnNode; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformer.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformer.java index 33fb0a284..cd3a07f69 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformer.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.transformers; +package nova.core.wrapper.mc.forge.v1_11_2.asm.transformers; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.ClassNode; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java index 6876bfc38..2cb946924 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/asm/transformers/Transformers.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.asm.transformers; +package nova.core.wrapper.mc.forge.v1_11_2.asm.transformers; import net.minecraft.launchwrapper.IClassTransformer; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; import org.objectweb.asm.tree.ClassNode; import java.util.ArrayList; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ClientModule.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ClientModule.java index b87359207..2a152c3f5 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ClientModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ClientModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.game.ClientManager; -import nova.core.wrapper.mc.forge.v1_11.manager.FWClientManager; +import nova.core.wrapper.mc.forge.v1_11_2.manager.FWClientManager; import se.jbee.inject.bind.BinderModule; public class ClientModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ComponentModule.java similarity index 88% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ComponentModule.java index ac50e1676..3cd1623f3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/ComponentModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/ComponentModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.entity.component.RigidBody; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.BWRigidBody; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.BWRigidBody; import se.jbee.inject.bind.BinderModule; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/GameInfoModule.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/GameInfoModule.java index b6790d0b1..96a9bdf73 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/GameInfoModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/GameInfoModule.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.game.GameInfo; import se.jbee.inject.Dependency; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/KeyModule.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/KeyModule.java index 70fab59d6..e808576d2 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/KeyModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/KeyModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.game.InputManager; -import nova.core.wrapper.mc.forge.v1_11.util.MCInputManager; +import nova.core.wrapper.mc.forge.v1_11_2.util.MCInputManager; import se.jbee.inject.bind.BinderModule; public class KeyModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/LanguageModule.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/LanguageModule.java index 753fb92d7..454922996 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/LanguageModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/LanguageModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.language.LanguageManager; -import nova.core.wrapper.mc.forge.v1_11.util.MCLanguageManager; +import nova.core.wrapper.mc.forge.v1_11_2.util.MCLanguageManager; import se.jbee.inject.bind.BinderModule; public class LanguageModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/NetworkModule.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/NetworkModule.java index 1682d0905..114ca1584 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/NetworkModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/NetworkModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.network.NetworkManager; -import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; import se.jbee.inject.bind.BinderModule; public class NetworkModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java similarity index 87% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java index 1aec0cd07..3e15adf8f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/RenderModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.render.RenderManager; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWClientRenderManager; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWClientRenderManager; import se.jbee.inject.bind.BinderModule; public class RenderModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/SaveModule.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/SaveModule.java index 339d28ede..981e7d0f2 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/SaveModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/SaveModule.java @@ -18,10 +18,10 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.core.util.registry.RetentionManager; -import nova.core.wrapper.mc.forge.v1_11.manager.MCRetentionManager; +import nova.core.wrapper.mc.forge.v1_11_2.manager.MCRetentionManager; import se.jbee.inject.bind.BinderModule; public class SaveModule extends BinderModule { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/TickerModule.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/TickerModule.java index 54be1bf1a..fc5c85fef 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/depmodules/TickerModule.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/TickerModule.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.depmodules; +package nova.core.wrapper.mc.forge.v1_11_2.depmodules; import nova.internal.core.tick.UpdateTicker; import se.jbee.inject.Dependency; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java similarity index 86% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java index 93d5061bb..363665787 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ClientProxy.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -35,15 +35,15 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileRenderer; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.FWParticle; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntityRenderer; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; +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.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java similarity index 83% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java index b840915a3..cf312880e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/CommonProxy.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; @@ -27,11 +27,11 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTileUpdater; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; +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; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; import java.util.Set; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java index 1089c4c0e..b53428620 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLEventHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLProgressBar.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLProgressBar.java index b2c2b13cd..01f6a9450 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/FMLProgressBar.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLProgressBar.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.fml.common.ProgressManager.ProgressBar; import nova.core.util.AbstractProgressBar; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java index 54e808c09..f64e066ad 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeEventHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; @@ -29,7 +29,7 @@ import net.minecraftforge.oredict.OreDictionary; import nova.core.item.Item; import nova.core.item.ItemDictionary; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeLoadable.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeLoadable.java index 59de3eecf..f9fb607fa 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/ForgeLoadable.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeLoadable.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java similarity index 82% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 6e91e316a..48674a713 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2015 NOVA, All rights reserved. * This library is free software, licensed under GNU Lesser General Public License version 3 @@ -18,7 +19,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -36,27 +37,27 @@ import net.minecraftforge.fml.relauncher.FMLInjectionData; import nova.core.deps.MavenDependency; import nova.core.event.ServerEvent; -import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; -import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.ComponentModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.GameInfoModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.KeyModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.LanguageModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.NetworkModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.RenderModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.SaveModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.TickerModule; -import nova.core.wrapper.mc.forge.v1_11.recipes.MinecraftRecipeRegistry; -import nova.core.wrapper.mc.forge.v1_11.wrapper.DirectionConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.VectorConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.WorldConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.cuboid.CuboidConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.EntityConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.inventory.InventoryConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.OreDictionaryIntegration; +import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.ClientModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.ComponentModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.GameInfoModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.KeyModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.LanguageModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.NetworkModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.RenderModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.SaveModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; +import nova.core.wrapper.mc.forge.v1_11_2.recipes.MinecraftRecipeRegistry; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +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.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; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.OreDictionaryIntegration; import nova.internal.core.Game; import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; import nova.internal.core.deps.DepDownloader; @@ -79,7 +80,7 @@ public class NovaMinecraft { public static final String name = "NOVA"; public static final String mcId = "minecraft"; - @SidedProxy(clientSide = "nova.core.wrapper.mc.forge.v1_11.launcher.ClientProxy", serverSide = "nova.core.wrapper.mc.forge.v1_11.launcher.CommonProxy") + @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) public static NovaMinecraft instance; @@ -161,6 +162,8 @@ public void preInit(FMLPreInitializationEvent evt) { ProgressBar progressBar = ProgressManager.push("Loading NOVA mods", modClasses.size(), true); launcher.load(new FMLProgressBar(progressBar)); ProgressManager.pop(progressBar); + novaModWrappers = launcher.getOrdererdMods().stream().filter(mod -> mod instanceof ForgeLoadable).map(mod -> (ForgeLoadable) mod).collect(Collectors.toList()); + novaWrappers.removeAll(novaModWrappers); /** * Instantiate native loaders diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/FWClientManager.java similarity index 86% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/FWClientManager.java index f4487085d..b3b665bc3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/FWClientManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/FWClientManager.java @@ -18,13 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.manager; +package nova.core.wrapper.mc.forge.v1_11_2.manager; import net.minecraft.client.Minecraft; import nova.core.entity.Entity; import nova.core.game.ClientManager; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; /** * @author Calclavia diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java index 81d21cc3b..62e93bad6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/MCRetentionManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.manager; +package nova.core.wrapper.mc.forge.v1_11_2.manager; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiConfig.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiConfig.java index c045c7b35..86cdfae5d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiConfig.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiConfig.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.manager.config; +package nova.core.wrapper.mc.forge.v1_11_2.manager.config; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java index 2d7cd5345..a40439757 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/manager/config/NovaGuiFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.manager.config; +package nova.core.wrapper.mc.forge.v1_11_2.manager.config; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/MCPacket.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/MCPacket.java index 2da87aa23..4e75e369b 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/MCPacket.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/MCPacket.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network; +package nova.core.wrapper.mc.forge.v1_11_2.network; import io.netty.buffer.ByteBuf; import net.minecraftforge.fml.common.network.ByteBufUtils; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java index 61b04541d..15e6810e8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/NovaPacket.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.discriminator; +package nova.core.wrapper.mc.forge.v1_11_2.network.discriminator; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; @@ -26,8 +26,8 @@ import nova.core.entity.Entity; import nova.core.entity.component.Player; import nova.core.network.handler.PacketHandler; -import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; -import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.network.MCPacket; +import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; import nova.internal.core.Game; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketAbstract.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketAbstract.java index 3a866fc07..13e4acf21 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketAbstract.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketAbstract.java @@ -18,13 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.discriminator; +package nova.core.wrapper.mc.forge.v1_11_2.network.discriminator; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; -import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; /** * For custom packets extend this Class and register on Mod loading phase diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketPlayerItem.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketPlayerItem.java index 3d4f75858..50c480a9f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/discriminator/PacketPlayerItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/PacketPlayerItem.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.discriminator; +package nova.core.wrapper.mc.forge.v1_11_2.network.discriminator; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import nova.core.network.Syncable; -import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; +import nova.core.wrapper.mc.forge.v1_11_2.network.MCPacket; /** * A packet handler for players who are currently holding their item. diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/ChannelHandler.java similarity index 83% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/ChannelHandler.java index d49859e0a..ec75a1e3c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/ChannelHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/ChannelHandler.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.netty; +package nova.core.wrapper.mc.forge.v1_11_2.network.netty; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.NovaPacket; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketPlayerItem; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.NovaPacket; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.PacketAbstract; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.PacketPlayerItem; /** * Handles the channel and discriminators. diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java index 05922cc1e..f8d8d6a13 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCNetworkManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.netty; +package nova.core.wrapper.mc.forge.v1_11_2.network.netty; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.EntityPlayerMP; @@ -36,11 +36,11 @@ import nova.core.entity.component.Player; import nova.core.network.NetworkManager; import nova.core.network.Syncable; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.network.MCPacket; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.NovaPacket; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.network.MCPacket; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.NovaPacket; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.PacketAbstract; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.EnumMap; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCPacketHandler.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCPacketHandler.java index 994303ffe..1b79afc79 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/network/netty/MCPacketHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCPacketHandler.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.network.netty; +package nova.core.wrapper.mc.forge.v1_11_2.network.netty; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; @@ -28,8 +28,8 @@ import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.network.discriminator.PacketAbstract; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.network.discriminator.PacketAbstract; /** * @author tgame14 @@ -46,7 +46,7 @@ protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) th FMLClientHandler.instance().getClient().addScheduledTask(() -> packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer())); break; case SERVER: - FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> packet.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity)); + FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> packet.handleServerSide(((NetHandlerPlayServer) netHandler).player)); break; default: break; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java index 0eafaf8b9..3d3a70267 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack; import nova.core.entity.component.Player; import nova.core.recipes.crafting.CraftingGrid; -import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; -import nova.core.wrapper.mc.forge.v1_11.util.WrapUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import java.util.List; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java index 8b3a53453..3602be3e5 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MCCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.item.crafting.IRecipe; import nova.core.item.Item; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java index a9a67b0be..24d414695 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftItemIngredient.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import nova.core.item.Item; import nova.core.recipes.ingredient.SpecificItemIngredient; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java index af3f96b4a..d720dd32e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; @@ -27,7 +27,7 @@ import nova.core.event.RecipeEvent; import nova.core.recipes.RecipeManager; import nova.core.recipes.crafting.CraftingRecipe; -import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import nova.internal.core.Game; import java.util.AbstractList; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java index 29d385bee..89cff4d2d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import nova.core.recipes.crafting.CraftingGrid; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java index 2059423a5..2cd66dac7 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingGridContainer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java index c04a4c622..ee0efe290 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/NovaCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java index d7771f31a..9175a75d4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/RecipeConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -33,7 +33,7 @@ import nova.core.recipes.crafting.ShapedCraftingRecipe; import nova.core.recipes.crafting.ShapelessCraftingRecipe; import nova.core.recipes.ingredient.SpecificItemIngredient; -import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import nova.internal.core.Game; import java.util.ArrayList; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java index 8a8f4a40a..7a11e97a9 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java index f7c9b1c77..0a55e71eb 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapedRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java @@ -24,7 +24,7 @@ * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java index 60f24670d..a5714e309 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java @@ -24,7 +24,7 @@ * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java index 25aed3f64..a883827cd 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/recipes/ShapelessRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.recipes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java index 08c06cae6..0c1bf7266 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaFolderResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java @@ -18,12 +18,12 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.render; +package nova.core.wrapper.mc.forge.v1_11_2.render; import com.google.common.base.Charsets; import net.minecraft.client.resources.FolderResourcePack; import net.minecraft.util.ResourceLocation; -import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; +import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java index 504e4559f..5a0b766a2 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/NovaResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java @@ -18,12 +18,12 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.render; +package nova.core.wrapper.mc.forge.v1_11_2.render; import com.google.common.base.Charsets; import net.minecraft.client.resources.FileResourcePack; import net.minecraft.util.ResourceLocation; -import nova.core.wrapper.mc.forge.v1_11.NovaMinecraftPreloader; +import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java index 1180e95cd..a8c9bed05 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/render/RenderUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.render; +package nova.core.wrapper.mc.forge.v1_11_2.render; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; @@ -43,12 +43,12 @@ import nova.core.render.texture.BlockTexture; import nova.core.render.texture.ItemTexture; import nova.core.render.texture.Texture; -import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWEmptyModel; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWSmartBlockModel; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward.FWSmartItemModel; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWEmptyModel; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartBlockModel; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartItemModel; import nova.internal.core.Game; import org.lwjgl.opengl.GL11; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCInputManager.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCInputManager.java index aecf19e06..90f3c8843 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCInputManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCInputManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import nova.core.game.InputManager; import org.lwjgl.input.Keyboard; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java index 49471858a..7a06e4475 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/MCLanguageManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java @@ -18,13 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.common.FMLCommonHandler; import nova.core.language.LanguageManager; -import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; /** * @deprecated Removed in Forge 1.9 diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ModCreativeTab.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ModCreativeTab.java index ce419e932..974bead69 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ModCreativeTab.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ModCreativeTab.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java index fe6303417..d3f3b658f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ObfuscationConstants.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; /** * @author Stan Hebben diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java similarity index 99% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java index b355784d4..a2d5d390a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/ReflectionUtil.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import com.google.common.collect.BiMap; import net.minecraft.entity.Entity; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java index 1f34147c4..577081d72 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java @@ -18,13 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import nova.core.entity.Entity; import nova.core.entity.component.Player; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import nova.internal.core.Game; import java.util.Objects; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java similarity index 89% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java index 7f2feedac..0deef379b 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/util/WrapperEvent.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.util; +package nova.core.wrapper.mc.forge.v1_11_2.util; import net.minecraft.item.ItemStack; import nova.core.block.Block; @@ -29,12 +29,12 @@ import nova.core.item.Item; import nova.core.util.Direction; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWTile; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java index 88576e389..c6bd88bc8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.wrapper; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper; import net.minecraft.util.EnumFacing; import nova.core.nativewrapper.NativeConverter; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java index 8bc1b9487..5d336b43a 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper; import net.minecraft.util.math.BlockPos; import nova.core.nativewrapper.NativeConverter; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index 43759b067..ef0d41001 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; @@ -33,12 +33,12 @@ import nova.core.component.Category; import nova.core.event.BlockEvent; import nova.core.nativewrapper.NativeConverter; -import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItemBlock; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemBlock; import nova.internal.core.Game; import java.util.Arrays; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java similarity index 90% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index 41732269c..9c62b8fd3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward; import net.minecraft.block.BlockSnow; import net.minecraft.block.SoundType; @@ -43,8 +43,8 @@ import nova.core.sound.Sound; import nova.core.util.shape.Cuboid; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.BWWorld; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -79,16 +79,16 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { soundType = mcBlock.getSoundType(); blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, - new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), - soundType.getPlaceSound().getSoundName().getResourcePath())); + new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), + soundType.getPlaceSound().getSoundName().getResourcePath())); blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, - new Sound(soundType.getBreakSound().getSoundName().getResourceDomain(), - soundType.getBreakSound().getSoundName().getResourcePath())); + new Sound(soundType.getBreakSound().getSoundName().getResourceDomain(), + soundType.getBreakSound().getSoundName().getResourcePath())); blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, - new Sound(soundType.getStepSound().getSoundName().getResourceDomain(), - soundType.getStepSound().getSoundName().getResourcePath())); + new Sound(soundType.getStepSound().getSoundName().getResourceDomain(), + soundType.getStepSound().getSoundName().getResourcePath())); components.add(new LightEmitter()).setEmittedLevel(() -> blockState().getLightValue(getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); components.add(new Collider(this)) @@ -102,7 +102,8 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { new BlockPos(x(), y(), z()), Game.natives().toNative(entity.isPresent() ? entity.get().components.get(Collider.class).boundingBox.get() : Cuboid.ONE.add(pos)), aabbs, - entity.isPresent() ? Game.natives().toNative(entity.get()) : null + entity.isPresent() ? Game.natives().toNative(entity.get()) : null, + true ); return aabbs.stream() .map(aabb -> (Cuboid) Game.natives().toNova(aabb)) diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/BlockPosition.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/BlockPosition.java index 57c2117a3..f5b8234a9 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/BlockPosition.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/BlockPosition.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.world.World; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index 82b32841a..538429691 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; @@ -50,7 +50,7 @@ import nova.core.util.Direction; import nova.core.util.math.MathUtil; import nova.core.util.shape.Cuboid; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -255,7 +255,7 @@ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, Bloc @Override @Deprecated - public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB boundingBox, List list, Entity entity) { + public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB boundingBox, List list, Entity entity, boolean b) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); blockInstance.components.getOp(Collider.class).ifPresent( collider -> { @@ -319,7 +319,7 @@ public int getLightValue(IBlockState state, IBlockAccess access, BlockPos pos) { Optional opEmitter = blockInstance.components.getOp(LightEmitter.class); if (opEmitter.isPresent()) { - return (int) MathUtil.clamp(Math.round(opEmitter.get().emittedLevel.getAsDouble() * 15), 0, 15); + return (int) MathUtil.clamp(Math.round(((java.util.function.DoubleSupplier)((Object)opEmitter.get().emittedLevel)).getAsDouble() * 15), 0, 15); } else { return 0; } diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockSound.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockSound.java index 6f9729e6d..9774f6408 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWBlockSound.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockSound.java @@ -1,4 +1,4 @@ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.block.SoundType; import net.minecraft.init.SoundEvents; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index 74afd64b1..0a51e18b4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetHandler; @@ -36,7 +36,7 @@ import nova.core.retention.Data; import nova.core.retention.Storable; import nova.core.util.EnumSelector; -import nova.core.wrapper.mc.forge.v1_11.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java index cf7e53f08..339294a22 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -27,8 +27,8 @@ import nova.core.component.Updater; import nova.core.component.fluid.SidedTankProvider; import nova.core.util.Direction; -import nova.core.wrapper.mc.forge.v1_11.asm.lib.ComponentInjector; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ComponentInjector; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.internal.core.Game; import java.util.Arrays; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java similarity index 91% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java index 8a3ec4231..9a6331749 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; @@ -27,8 +27,8 @@ import net.minecraft.tileentity.TileEntity; import nova.core.block.Block; import nova.core.component.renderer.DynamicRenderer; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; +import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java index 75b6bcdf7..43d189e12 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/FWTileUpdater.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.util.ITickable; import nova.core.component.Updater; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java index 3d4fca20e..3c4c61f2c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/MCBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import nova.core.block.Block; import nova.core.component.transform.BlockTransform; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java index 2987b8a36..d1e506593 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/forward/ProxyMaterial.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java @@ -1,4 +1,4 @@ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java similarity index 92% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java index 3f9e158f7..f37023989 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.world; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; @@ -33,12 +33,12 @@ import nova.core.sound.Sound; import nova.core.util.shape.Cuboid; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.MCBlockTransform; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; +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.MCBlockTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.MCEntityTransform; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java index aeee56881..a4e70edb5 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/block/world/WorldConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.block.world; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world; import net.minecraft.world.IBlockAccess; import nova.core.nativewrapper.NativeConverter; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java index ff4c731c3..56ac46133 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java index 127e6ffd7..888fb1100 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/cuboid/CuboidConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.cuboid; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.cuboid; import net.minecraft.util.math.AxisAlignedBB; import nova.core.nativewrapper.NativeConverter; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java index b452e2747..d5cfc932c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/data/DataWrapper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.data; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.data; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagByte; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java similarity index 86% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java index cea64c74e..5eb83db59 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/EntityConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -27,11 +27,11 @@ import nova.core.entity.Entity; import nova.core.entity.EntityFactory; import nova.core.nativewrapper.NativeConverter; -import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward.BWParticle; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.backward.BWParticle; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java similarity index 92% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java index 97842c06f..9cd31e4fb 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -28,9 +28,9 @@ import nova.core.entity.Entity; import nova.core.entity.component.Living; import nova.core.entity.component.Player; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.MCEntityTransform; -import nova.core.wrapper.mc.forge.v1_11.wrapper.inventory.BWInventory; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory.BWInventory; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/BWRigidBody.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/BWRigidBody.java index e5bd7d97d..9a74e0df4 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/BWRigidBody.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/BWRigidBody.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward; import net.minecraft.entity.MoverType; import nova.core.entity.Entity; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index b66b3d077..c4bf2890c 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; @@ -36,8 +36,8 @@ import nova.core.retention.Storable; import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.data.DataWrapper; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataWrapper; import nova.internal.core.Game; import java.util.HashMap; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java similarity index 93% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java index be3853f79..b761c5695 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/FWEntityRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -28,9 +28,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; import nova.core.component.renderer.DynamicRenderer; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.FWParticle; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; +import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward.FWParticle; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.opengl.GL11; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java index c2a4517b8..92001cce8 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/entity/forward/MCEntityTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.DimensionManager; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java index d2b7303f0..4ba4e84e3 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/BWInventory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/FWInventory.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/FWInventory.java index c994c5d07..5dc81b61d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/FWInventory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/FWInventory.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -26,7 +26,7 @@ import net.minecraft.util.text.ITextComponent; import nova.core.component.inventory.Inventory; import nova.core.item.Item; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; public class FWInventory implements IInventory { diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java index b0812ce20..08d82c8e5 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/inventory/InventoryConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.inventory; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory; import net.minecraft.inventory.IInventory; import nova.core.component.inventory.Inventory; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 33f6cdf7a..76a5e828e 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import com.google.common.collect.HashBiMap; import net.minecraft.creativetab.CreativeTabs; @@ -35,14 +35,14 @@ import nova.core.item.ItemFactory; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; -import nova.core.wrapper.mc.forge.v1_11.launcher.ForgeLoadable; -import nova.core.wrapper.mc.forge.v1_11.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11.util.ModCreativeTab; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.BlockConverter; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItem; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward.BWItemFactory; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWItem; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward.FWNBTTagCompound; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWNBTTagCompound; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java index 5bdd37aff..d39ace421 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/ItemWrapperMethods.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -27,7 +27,7 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.util.Direction; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java index 245f6f6d1..a2a288c92 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/OreDictionaryIntegration.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import nova.core.item.Item; import nova.core.item.ItemDictionary; import nova.core.util.Dictionary; -import nova.core.wrapper.mc.forge.v1_11.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import nova.internal.core.Game; import java.util.ArrayList; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java index c9b7b9e92..b0d0eca3f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java index 6a39fd5bb..74535afa6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/backward/BWItemFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java @@ -18,14 +18,14 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward; import net.minecraft.nbt.NBTTagCompound; import nova.core.component.misc.FactoryProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.retention.Data; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.internal.core.Game; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java similarity index 90% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index c0deadc88..1a83dc4a6 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -18,9 +18,9 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; -import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -32,11 +32,11 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import java.util.List; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemWrapperMethods; import nova.internal.core.Game; /** diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java similarity index 88% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index 485de5912..a03a9eb95 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -31,10 +31,10 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; -import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11.wrapper.capability.forward.FWCapabilityProvider; -import nova.core.wrapper.mc.forge.v1_11.wrapper.item.ItemWrapperMethods; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemWrapperMethods; import nova.internal.core.Game; import java.util.List; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java index 133273097..1a33ca364 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/item/forward/FWNBTTagCompound.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.item.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; import net.minecraft.nbt.NBTTagCompound; import nova.core.item.Item; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java similarity index 98% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java index ccd415fab..4c2a2998d 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/backward/BWParticle.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.backward; import com.google.common.collect.HashBiMap; import net.minecraft.client.particle.Barrier; @@ -65,8 +65,8 @@ import java.util.HashMap; import java.util.Map; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward.MCParticleTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward.MCParticleTransform; /** * A backward entity particle that acts as a black box, which wraps a Minecraft particle. diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/FWParticle.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/FWParticle.java index 702f1e77a..18e9b1307 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/FWParticle.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/FWParticle.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.Tessellator; @@ -35,8 +35,8 @@ import nova.core.entity.Entity; import nova.core.entity.EntityFactory; import nova.core.util.shape.Cuboid; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; -import nova.core.wrapper.mc.forge.v1_11.wrapper.entity.forward.FWEntityRenderer; +import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntityRenderer; import static org.lwjgl.opengl.GL11.GL_QUADS; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java index 061a08a24..39c2bf61f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/particle/forward/MCParticleTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.particle.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward; import net.minecraft.client.particle.Particle; import nova.core.component.transform.EntityTransform; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java index f59c6bb00..43fce8657 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWClientRenderManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java index af26d076d..d74edd5b1 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; @@ -28,7 +28,7 @@ import nova.core.render.model.MeshModel; import nova.core.render.texture.EntityTexture; import nova.core.render.texture.Texture; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; import java.util.Optional; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java similarity index 94% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java index c153ec597..59e15e897 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/backward/BWRenderManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; import net.minecraft.util.ResourceLocation; import nova.core.render.RenderManager; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java index 9c9d47e54..7410a8832 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWEmptyModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java similarity index 96% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 24c4da890..623ee533b 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -18,9 +18,9 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java similarity index 95% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index c1ced7d18..75330776f 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -18,9 +18,9 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; -import nova.core.wrapper.mc.forge.v1_11.wrapper.render.backward.BWModel; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; diff --git a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java similarity index 97% rename from minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java index 9b3307a81..a6b115a04 100644 --- a/minecraft/1.11/src/main/java/nova/core/wrapper/mc/forge/v1_11/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper.render.forward; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; import com.google.common.primitives.Ints; import net.minecraft.block.state.IBlockState; @@ -37,7 +37,7 @@ import nova.core.render.model.Model; import nova.core.render.model.Vertex; import nova.core.util.Direction; -import nova.core.wrapper.mc.forge.v1_11.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; import java.util.Collections; import java.util.List; diff --git a/minecraft/1.11/src/main/resources/META-INF/nova_at.cfg b/minecraft/1.11.2/src/main/resources/META-INF/nova_at.cfg similarity index 100% rename from minecraft/1.11/src/main/resources/META-INF/nova_at.cfg rename to minecraft/1.11.2/src/main/resources/META-INF/nova_at.cfg diff --git a/minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.png b/minecraft/1.11.2/src/main/resources/assets/nova/textures/NOVA.png similarity index 100% rename from minecraft/1.11/src/main/resources/assets/nova/textures/NOVA.png rename to minecraft/1.11.2/src/main/resources/assets/nova/textures/NOVA.png diff --git a/minecraft/1.11/src/main/resources/fmlbranding.properties b/minecraft/1.11.2/src/main/resources/fmlbranding.properties similarity index 100% rename from minecraft/1.11/src/main/resources/fmlbranding.properties rename to minecraft/1.11.2/src/main/resources/fmlbranding.properties diff --git a/minecraft/1.11/src/main/resources/mcmod.info b/minecraft/1.11.2/src/main/resources/mcmod.info similarity index 100% rename from minecraft/1.11/src/main/resources/mcmod.info rename to minecraft/1.11.2/src/main/resources/mcmod.info diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java similarity index 79% rename from minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java rename to minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java index b73dcc587..6b6cfbd34 100644 --- a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/launcher/NovaLauncherTest.java +++ b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java @@ -18,15 +18,15 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.launcher; +package nova.core.wrapper.mc.forge.v1_11_2.launcher; -import nova.core.wrapper.mc.forge.v1_11.depmodules.ClientModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.GameInfoModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.KeyModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.LanguageModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.RenderModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.SaveModule; -import nova.core.wrapper.mc.forge.v1_11.depmodules.TickerModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.ClientModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.GameInfoModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.KeyModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.LanguageModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.RenderModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.SaveModule; +import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; import nova.internal.core.Game; import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; import nova.wrappertests.depmodules.FakeNetworkModule; diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverterTest.java similarity index 95% rename from minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java rename to minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverterTest.java index 7c377bfcc..54c536223 100644 --- a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/DirectionConverterTest.java +++ b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverterTest.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper; import net.minecraft.util.EnumFacing; import nova.core.util.Direction; @@ -26,7 +26,6 @@ import org.junit.Test; import static nova.testutils.NovaAssertions.assertThat; -import static org.assertj.core.api.Assertions.assertThat; /** * Used to test {@link DirectionConverter}. diff --git a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverterTest.java similarity index 97% rename from minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java rename to minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverterTest.java index 98be6e20f..39c4bfb0d 100644 --- a/minecraft/1.11/src/test/java/nova/core/wrapper/mc/forge/v1_11/wrapper/VectorConverterTest.java +++ b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverterTest.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11.wrapper; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper; import net.minecraft.util.math.BlockPos; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; diff --git a/settings.gradle b/settings.gradle index 27fdae8ff..fdfa91bf1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ rootProject.name = 'NOVA-Core' -include "minecraft:1.11" +include "minecraft:1.11.2" include "minecraft:1.8" include "minecraft:1.7" From 20771f060b59cd418c3538d4c5b840f86a030abc Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 1 Mar 2017 23:52:37 +0100 Subject: [PATCH 34/61] Rebase to master + Get rendering to a usable state Current state of rendering: https://cdn.discordapp.com/attachments/266966095624142848/286631420246491136/2017-03-01_23.49.30.png --- .../forge/v1_11_2/NovaMinecraftPreloader.java | 196 ++++++++++-------- .../mc/forge/v1_11_2/asm/StaticForwarder.java | 9 +- .../mc/forge/v1_11_2/asm/lib/ASMHelper.java | 4 +- .../v1_11_2/asm/lib/ClassHeirachyManager.java | 2 +- .../v1_11_2/asm/lib/ComponentInjector.java | 2 +- .../v1_11_2/asm/lib/TemplateInjector.java | 6 +- .../asm/transformers/ChunkTransformer.java | 2 +- .../transformers/TileEntityTransformer.java | 3 +- .../v1_11_2/depmodules/RenderModule.java | 34 --- .../forge/v1_11_2/launcher/NovaMinecraft.java | 11 +- .../forge/v1_11_2/recipes/MCCraftingGrid.java | 7 +- .../forge/v1_11_2/render/RenderUtility.java | 32 ++- .../forge/v1_11_2/util/MCLanguageManager.java | 7 +- .../v1_11_2/util/ObfuscationConstants.java | 2 +- .../mc/forge/v1_11_2/util/WrapUtility.java | 2 + .../v1_11_2/wrapper/CategoryConverter.java | 127 ++++++++++++ .../wrapper/assets/AssetConverter.java | 71 +++++++ .../assets/NovaFileResourcePack.java} | 74 +++++-- .../assets}/NovaFolderResourcePack.java | 66 +++++- .../wrapper/assets/NovaResourcePack.java | 80 +++++++ .../v1_11_2/wrapper/block/BlockConverter.java | 6 +- .../v1_11_2/wrapper/block/forward/FWTile.java | 2 +- .../wrapper/block/forward/FWTileLoader.java | 8 +- .../wrapper/block/forward/ProxyMaterial.java | 1 + .../v1_11_2/wrapper/block/world/BWWorld.java | 4 +- .../forward/FWCapabilityProvider.java | 1 + .../entity/forward/FWEntityRenderer.java | 2 +- .../v1_11_2/wrapper/item/ItemConverter.java | 18 +- .../wrapper/item/ItemWrapperMethods.java | 11 +- .../v1_11_2/wrapper/item/forward/FWItem.java | 12 +- .../wrapper/item/forward/FWItemBlock.java | 7 +- .../item/forward/FWNBTTagCompound.java | 2 +- .../wrapper/particle/backward/BWParticle.java | 2 +- .../backward/BWClientRenderManager.java | 67 ------ .../wrapper/render/backward/BWModel.java | 13 +- .../render/backward/BWRenderManager.java | 38 ---- .../render/forward/FWSmartBlockModel.java | 31 ++- .../render/forward/FWSmartItemModel.java | 15 +- .../wrapper/render/forward/FWSmartModel.java | 39 ++-- .../src/main/resources/fmlbranding.properties | 2 +- .../1.11.2/src/main/resources/mcmod.info | 2 +- .../v1_11_2/launcher/NovaLauncherTest.java | 4 +- 42 files changed, 662 insertions(+), 362 deletions(-) delete mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{render/NovaResourcePack.java => wrapper/assets/NovaFileResourcePack.java} (53%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{render => wrapper/assets}/NovaFolderResourcePack.java (59%) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java delete mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java delete mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index 741234fac..cc675dcfb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -22,11 +22,9 @@ import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; import net.minecraft.client.resources.AbstractResourcePack; import net.minecraft.client.resources.FileResourcePack; +import net.minecraft.client.resources.FolderResourcePack; import net.minecraft.client.resources.IResourcePack; import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraftforge.fml.client.FMLClientHandler; @@ -42,26 +40,30 @@ import net.minecraftforge.fml.relauncher.Side; import nova.core.loader.Mod; import nova.core.util.ClassLoaderUtil; -import nova.core.wrapper.mc.forge.v1_11_2.render.NovaFolderResourcePack; -import nova.core.wrapper.mc.forge.v1_11_2.render.NovaResourcePack; +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 java.io.File; +import java.io.IOException; +import java.io.StringWriter; import java.lang.reflect.Field; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Function; 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"; @@ -87,96 +89,126 @@ public NovaMinecraftPreloader() { * A sound collection falls under the same resource name. When called to play, it will pick a random sound from the collection to play it. * * If it's just a sound file, then load the sound file + * + * @param pack The resource pack to generate the sound JSON for. + * @return The generated sound JSON. */ public static String generateSoundJSON(AbstractResourcePack pack) { - JsonObject fakeSoundJSON = new JsonObject(); - - for (String domain : pack.getResourceDomains()) { - + StringWriter sw = new StringWriter(); + try (JsonGenerator json = Json.createGenerator(sw);) { + json.writeStartObject(); if (pack instanceof FileResourcePack) { //For zip resource packs try { - ZipFile zipFile = new ZipFile(pack.resourcePackFile); - - if (zipFile.getEntry("assets/" + domain + "/sounds/") != null) { - Enumeration zipEntries = zipFile.entries(); - - while (zipEntries.hasMoreElements()) { - String zipPath = zipEntries.nextElement().getName(); - - String prefix = "assets/" + domain + "/sounds/"; - if (zipPath.startsWith(prefix) && !zipPath.equals(prefix)) { - String soundName = zipPath.replaceFirst(prefix, "").replaceFirst("[.][^.]+$", ""); - ZipEntry entry = zipFile.getEntry(zipPath); - - if (!soundName.contains("/")) { - JsonObject sound = new JsonObject(); - sound.addProperty("category", "ambient"); - JsonArray sounds = new JsonArray(); - - if (entry.isDirectory()) { - //Sound Collection - Enumeration zipEntries2 = zipFile.entries(); - while (zipEntries2.hasMoreElements()) { - String zipPath2 = zipEntries2.nextElement().getName(); - - if (zipPath2.startsWith(prefix + soundName + "/") && !zipFile.getEntry(zipPath2).isDirectory()) { - String randomSoundName = zipPath2.replaceFirst(prefix + soundName + "/", ""); - sounds.add(new JsonPrimitive(soundName + "/" + randomSoundName.replaceFirst("[.][^.]+$", ""))); - } - } - } else { - sounds.add(new JsonPrimitive(soundName)); - } - sound.add("sounds", sounds); - fakeSoundJSON.add(soundName, sound); - } - } - } - } - + generateSoundJSON((FileResourcePack) pack, json); } catch (Exception e) { - e.printStackTrace(); - throw new ExceptionInInitializerError("Error generating fake sound JSON file."); + Error error = new ExceptionInInitializerError("Error generating fake sound JSON file."); + error.addSuppressed(e); + throw error; } - } else { + } else if (pack instanceof FolderResourcePack) { //For folder resource packs + generateSoundJSON((FolderResourcePack) pack, json); + } + json.writeEnd().flush(); + return sw.toString(); + } + } + + private static JsonGenerator generateSoundJSON(FileResourcePack pack, JsonGenerator json) throws IOException { + try (ZipFile zipFile = new ZipFile(pack.resourcePackFile)) { + for (String domain : pack.getResourceDomains()) { //Load all sounds in the assets/domain/sounds/* - File folder = new File(pack.resourcePackFile, "assets/" + domain + "/sounds/"); - - if (folder.exists()) { - File[] listOfFiles = folder.listFiles(); - - for (File listedFile : listOfFiles) { - JsonObject sound = new JsonObject(); - sound.addProperty("category", "ambient"); - JsonArray sounds = new JsonArray(); - - String listedName = listedFile.getName().replaceFirst("[.][^.]+$", ""); - if (listedFile.isFile()) { - sounds.add(new JsonPrimitive(listedName)); - } else if (listedFile.isDirectory()) { - for (File soundItemFile : listedFile.listFiles()) - sounds.add(new JsonPrimitive(listedName + "/" + soundItemFile.getName().replaceFirst("[.][^.]+$", ""))); - } - - sound.add("sounds", sounds); - fakeSoundJSON.add(listedName, sound); + if (getZipEntryForResourcePack(pack, "assets/" + domain + "/sounds/") != null) { + String prefix = "assets/" + domain + "/sounds/"; + zipFile.stream() + .filter(e -> e.getName().toLowerCase().startsWith(prefix.toLowerCase()) && !e.getName().equalsIgnoreCase(prefix)) + .forEach(e -> { + String soundName = e.getName().replaceFirst(prefix, "").replaceFirst("\\.[^\\.]+$", ""); + if (soundName.contains("/")) + return; + + json.writeStartObject(soundName); + json.write("category", "ambient"); + json.writeStartArray("sounds"); + + if (e.isDirectory()) { + zipFile.stream() + .filter(e2 -> e2.getName().startsWith(prefix + soundName + "/") && !e2.isDirectory()) + .map(ZipEntry::getName) + .map(s -> s.replaceFirst(prefix + soundName + "/", "").replaceFirst("\\.[^\\.]+$", "")) + .forEach(s -> json.write(soundName + "/" + s)); + } else { + json.write(soundName); + } + json.writeEnd().writeEnd(); + }); + } + } + } + + return json; + } + + private static JsonGenerator generateSoundJSON(FolderResourcePack pack, JsonGenerator json) { + for (String domain : pack.getResourceDomains()) { + //Load all sounds in the assets/domain/sounds/* + File folder = getFileForResourcePack(pack, "assets/" + domain + "/sounds/"); + if (folder.exists()) { + for (File listedFile : folder.listFiles()) { + String soundName = listedFile.getName().replaceFirst("\\.[^\\.]+$", ""); + json.writeStartObject(soundName); + json.write("category", "ambient"); + json.writeStartArray("sounds"); + if (listedFile.isFile()) { + json.write(soundName); + } else if (listedFile.isDirectory()) { + for (File soundItemFile : listedFile.listFiles()) + json.write(soundName + "/" + soundItemFile.getName().replaceFirst("\\.[^\\.]+$", "")); } + json.writeEnd().writeEnd(); } } } - return fakeSoundJSON.toString(); + return json; } public static String generatePackMcmeta() { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("description", "NOVA mod resource pack"); - jsonObject.addProperty("pack_format", "1"); - JsonObject outerObj = new JsonObject(); - outerObj.add("pack", jsonObject); - return outerObj.toString(); + StringWriter sw = new StringWriter(); + try (JsonGenerator json = Json.createGenerator(sw);) { + json.writeStartObject() // { + .writeStartObject("pack") // "pack": { + .write("description", "NOVA mod resource pack") // "description": "NOVA mod resource pack", + .write("pack_format", 1) // "pack_format": 1 + .writeEnd() // } + .writeEnd() // } + .flush(); + + return sw.toString(); + } + } + + public static ZipEntry getZipEntryForResourcePack(FileResourcePack pack, String path) throws IOException { + if (pack instanceof NovaFileResourcePack) { + Optional entry = ((NovaFileResourcePack) pack).findFileCaseInsensitive(path); + if (entry.isPresent()) + return entry.get(); + } + + try (ZipFile zf = new ZipFile(pack.resourcePackFile)) { + return zf.getEntry(path); + } + } + + public static File getFileForResourcePack(FolderResourcePack pack, String path) { + if (pack instanceof NovaFolderResourcePack) { + Optional file = ((NovaFolderResourcePack) pack).findFileCaseInsensitive(path); + if (file.isPresent()) + return file.get(); + } + + return new File(pack.resourcePackFile, path); } @Override @@ -199,7 +231,8 @@ public void load(FMLConstructionEvent event) { //Obfuscation? Field setField = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions"); setField.setAccessible(true); - Set classLoaderExceptions = (Set) setField.get(classLoader); + @SuppressWarnings("unchecked") + Set classLoaderExceptions = (Set) setField.get(classLoader); classLoaderExceptions.remove("org.apache."); System.out.println("Successfully hacked 'org.apache' out of launcher exclusion"); } catch (Exception e) { @@ -256,6 +289,7 @@ public void registerResourcePacks() { // Reflecting FML is just less work for us. (Minecraft.field_110449_ao) Field resourcePackField = FMLClientHandler.class.getDeclaredField("resourcePackList"); resourcePackField.setAccessible(true); + @SuppressWarnings("unchecked") List packs = (List) resourcePackField.get(FMLClientHandler.instance()); Set addedPacks = new HashSet<>(); @@ -278,7 +312,7 @@ public void registerResourcePacks() { if (!addedPacks.contains(fn)) { addedPacks.add(fn); - packs.add(new NovaResourcePack(file, novaMod.id(), novaMod.domains())); + packs.add(new NovaFileResourcePack(file, novaMod.id(), novaMod.domains())); System.out.println("Registered NOVA jar resource pack: " + fn); } } else { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index bd69056c0..069431735 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -51,10 +51,11 @@ public static void chunkSetBlockEvent(Chunk chunk, BlockPos pos, IBlockState old /** * Used to inject forwarded TileEntites - * @param data - * @param clazz - * @return - * @throws Exception + * @param world The world to create the TileEntity in. + * @param data The TileEntity NBT tag compound + * @param clazz The TileEntity class + * @return The new TileEntity instance + * @throws Exception when an exception occurs */ public static TileEntity loadTileEntityHook(World world, NBTTagCompound data, Class clazz) throws Exception { if (FWTile.class.isAssignableFrom(clazz)) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java index bd72563a0..8ec3d69ab 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java @@ -63,8 +63,8 @@ public class ASMHelper { static { try { - defineClass1 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class }); - defineClass2 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class, ProtectionDomain.class }); + defineClass1 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class }); + defineClass2 = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] { String.class, byte[].class, int.class, int.class, ProtectionDomain.class }); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java index 0d971e5ba..07980422b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ClassHeirachyManager.java @@ -62,7 +62,7 @@ public static String unKey(String name) { * Returns true if clazz extends, either directly or indirectly, superclass. * @param name The class in question * @param superclass The class being extended - * @return + * @return If the class extends the superclass */ public static boolean classExtends(String name, String superclass) { name = toKey(name); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java index 5c33ab1b5..0e330dd11 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ComponentInjector.java @@ -44,7 +44,7 @@ * The ComponentInjector is capable of creating dynamic classes that implement a * specified super class and implement the interfaces specified by * {@link Component} and {@link Passthrough}. - * @param + * @param The constructed type * @author Vic Nightfall */ public class ComponentInjector implements Opcodes { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java index d61214e85..d2910a48c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/TemplateInjector.java @@ -44,7 +44,7 @@ public class TemplateInjector { * @param className - Class that will be injected * @param template - Default interface used as a template to inject in the templateName */ - public void registerTemplate(String className, Class template) { + public void registerTemplate(String className, Class template) { templates.put(className, new InjectionTemplate(template.getName())); } @@ -83,8 +83,8 @@ public InjectionTemplate(String templateName) { /** * Patches the cnode withPriority the methods from this template. - * @param cnode - * @return + * @param cnode The class node to inject into + * @return If the injection changed anything */ public boolean inject(ClassNode cnode) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java index 457e8992e..8a34a0d4b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java @@ -47,7 +47,7 @@ public void transform(ClassNode cnode) { list.add(new VarInsnNode(ALOAD, 1)); //BlockPos list.add(new VarInsnNode(ALOAD, 8)); //oldBlock IBlockState list.add(new VarInsnNode(ALOAD, 2)); //newBlock IBlockState - list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder", "chunkSetBlockEvent", "(Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/block/state/IBlockState;)V", false)); + list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder", "chunkSetBlockEvent", "(Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/block/state/IBlockState;)V", false)); AbstractInsnNode lastInsn = method.instructions.getLast(); while (lastInsn instanceof LabelNode || lastInsn instanceof LineNumberNode) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java index 5217f145d..43a715c62 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java @@ -47,6 +47,7 @@ public void transform(ClassNode cnode) { if (method == null) { System.out.println("[NOVA] Lookup " + deobfMap + " failed!"); + return; } } @@ -58,7 +59,7 @@ public void transform(ClassNode cnode) { list.add(new VarInsnNode(ALOAD, 0)); // World list.add(new VarInsnNode(ALOAD, 1)); // NBTTagCompound list.add(new VarInsnNode(ALOAD, 4)); // Class - list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11/asm/StaticForwarder", "loadTileEntityHook", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;Ljava/lang/Class;)Lnet/minecraft/tileentity/TileEntity;", false)); + list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder", "loadTileEntityHook", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;Ljava/lang/Class;)Lnet/minecraft/tileentity/TileEntity;", false)); list.add(new VarInsnNode(ASTORE, 2)); // TileEntity method.instructions.insert(method.instructions.get(31), list); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java deleted file mode 100644 index 3e15adf8f..000000000 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/depmodules/RenderModule.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11_2.depmodules; - -import nova.core.render.RenderManager; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWClientRenderManager; -import se.jbee.inject.bind.BinderModule; - -public class RenderModule extends BinderModule { - - @Override - protected void declare() { - bind(RenderManager.class).to(BWClientRenderManager.class); - } - -} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 48674a713..233a0abad 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -24,7 +24,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.Metadata; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.ProgressManager; import net.minecraftforge.fml.common.ProgressManager.ProgressBar; @@ -44,12 +43,13 @@ import nova.core.wrapper.mc.forge.v1_11_2.depmodules.KeyModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.LanguageModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.NetworkModule; -import nova.core.wrapper.mc.forge.v1_11_2.depmodules.RenderModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.SaveModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; import nova.core.wrapper.mc.forge.v1_11_2.recipes.MinecraftRecipeRegistry; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; 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; @@ -85,7 +85,7 @@ public class NovaMinecraft { @Mod.Instance(id) public static NovaMinecraft instance; private static NovaLauncher launcher; - @Metadata(id) + @Mod.Metadata(id) private static ModMetadata modMetadata; private static Set nativeConverters; @@ -100,6 +100,8 @@ public static void registerWrapper(ForgeLoadable wrapper) { * ORDER OF LOADING. * * 1. Native Loaders 2. Native Converters 3. Mods + * + * @param evt The Minecraft Forge Pre-Initialization event */ @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { @@ -115,7 +117,6 @@ public void preInit(FMLPreInitializationEvent evt) { diep.install(KeyModule.class); diep.install(ClientModule.class); diep.install(GameInfoModule.class); - diep.install(RenderModule.class); diep.install(ComponentModule.class); Set> modClasses = NovaMinecraftPreloader.modClasses; @@ -137,6 +138,8 @@ public void preInit(FMLPreInitializationEvent evt) { Game.natives().registerConverter(new InventoryConverter()); Game.natives().registerConverter(new VectorConverter()); Game.natives().registerConverter(new DirectionConverter()); + Game.natives().registerConverter(new CategoryConverter()); + Game.natives().registerConverter(new AssetConverter()); /** * Initiate recipe and ore dictionary integration diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java index 3d3a70267..f5407beff 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2015 NOVA, All rights reserved. * This library is free software, licensed under GNU Lesser General Public License version 3 @@ -69,15 +70,15 @@ private MCCraftingGrid(InventoryCrafting inventory) { player = WrapUtility.getNovaPlayer(playerOrig); } else { playerOrig = null; - player = null; + player = Optional.empty(); } } else { playerOrig = null; - player = null; + player = Optional.empty(); } } - public MCCraftingGrid(IInventory inventory, EntityPlayer player) { + private MCCraftingGrid(IInventory inventory, EntityPlayer player) { this.inventory = inventory; width = height = (int) Math.sqrt(inventory.getSizeInventory()); stacks = new nova.core.item.Item[width * height]; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java index a8c9bed05..ec2de699c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java @@ -40,19 +40,20 @@ import net.minecraftforge.fml.relauncher.SideOnly; import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; -import nova.core.render.texture.BlockTexture; -import nova.core.render.texture.ItemTexture; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWEmptyModel; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartBlockModel; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartItemModel; import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; import org.lwjgl.opengl.GL11; import java.io.IOException; +import java.lang.reflect.Field; import java.util.HashMap; import java.util.Optional; @@ -166,7 +167,7 @@ public TextureAtlasSprite getTexture(Texture texture) { } //Fallback to MC texture - return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.domain + ":" + texture.getPath().replaceFirst("textures/", "").replace(".png", "")); + return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(AssetConverter.instance().toNativeTexture(texture).toString()); } /** @@ -184,11 +185,26 @@ public void preTextureHook(TextureStitchEvent.Pre event) { } public void registerIcon(Texture texture, TextureStitchEvent.Pre event) { - String resPath = (texture instanceof BlockTexture ? "blocks" : texture instanceof ItemTexture ? "items" : "entities") + "/" + texture.resource; - System.out.println(texture + " (" + texture.domain + ':' + resPath + ')'); - TextureAtlasSprite sprite = event.getMap().registerSprite(new ResourceLocation(texture.domain, resPath)); - textureMap.put(texture, sprite); - System.out.println(sprite); + textureMap.put(texture, event.getMap().registerSprite(AssetConverter.instance().toNativeTexture(texture))); + } + + @SubscribeEvent + public void textureHook(TextureStitchEvent.Post event) { + Game.render().blockTextures.forEach(this::updateTexureDimensions); + Game.render().itemTextures.forEach(this::updateTexureDimensions); + Game.render().entityTextures.forEach(this::updateTexureDimensions); + } + + private void updateTexureDimensions(Texture texture) { + try { + Field dimension = Texture.class.getDeclaredField("dimension"); + dimension.setAccessible(true); + TextureAtlasSprite icon = getTexture(texture); + dimension.set(texture, new Vector2D(icon.getIconWidth(), icon.getIconHeight())); + dimension.setAccessible(false); + } catch (Exception ex) { + throw new RuntimeException("Cannot set dimension of texture " + texture, ex); + } } @SubscribeEvent diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java index 7a06e4475..527d58f62 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java @@ -27,8 +27,6 @@ import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; /** - * @deprecated Removed in Forge 1.9 - * * @author Calclavia */ public class MCLanguageManager extends LanguageManager implements ForgeLoadable { @@ -42,7 +40,12 @@ public String getCurrentLanguage() { return FMLCommonHandler.instance().getCurrentLanguage().replace('_', '-'); } + /** + * {@inheritDoc} + * @deprecated Removed in Forge 1.9 + */ @Override + @Deprecated public String translate(String key) { String value = super.translate(key); if (value.equals(key)) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java index d3f3b658f..baaa5f8c6 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ObfuscationConstants.java @@ -29,7 +29,7 @@ public class ObfuscationConstants { public static final String[] OREDICTIONARY_IDTOSTACKUN = { "idToStackUn" }; public static final String[] MINECRAFTSERVER_ANVILFILE = { "anvilFile", "field_71308_o" }; public static final String[] INVENTORYCRAFTING_EVENTHANDLER = { "eventHandler", "field_70465_c" }; - public static final String[] SLOTCRAFTING_PLAYER = { "thePlayer", "field_75238_b" }; + public static final String[] SLOTCRAFTING_PLAYER = { "player", "field_75238_b" }; public static final String[] STRINGTRANSLATE_INSTANCE = { "instance", "field_74817_a" }; public static final String[] CRAFTINGMANAGER_RECIPES = { "recipes", "field_77597_b" }; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java index 577081d72..3b19c3ef9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java @@ -39,6 +39,8 @@ public class WrapUtility { private WrapUtility() {} public static Optional getNovaPlayer(EntityPlayer player) { + if (player == null) + return Optional.empty(); return ((Entity)Game.natives().toNova(player)).components.getOp(Player.class); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java new file mode 100644 index 000000000..ae0b20b91 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import nova.core.component.Category; +import nova.core.nativewrapper.NativeConverter; +import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; +import nova.internal.core.Game; + +import java.util.Arrays; + +/** + * Converts NOVA {@link Category Categories} to Minecraft {@link CreativeTabs} and back. + * + * @author ExE Boss + */ +public class CategoryConverter implements NativeConverter{ + + public static CategoryConverter instance() { + return (CategoryConverter) Game.natives().getNative(Category.class, CreativeTabs.class); + } + + @Override + public Class getNovaSide() { + return Category.class; + } + + @Override + public Class getNativeSide() { + return CreativeTabs.class; + } + + @Override + public Category toNova(CreativeTabs creativeTab) { + switch (creativeTab.getTabLabel()) { + case "buildingBlocks": + return Category.BUILDING_BLOCKS; + case "decorations": + return Category.DECORATIONS; + case "redstone": + return Category.TECHNOLOGY; + case "transportation": + return Category.TRANSPORTATION; + case "food": + return Category.FOOD; + case "tools": + return Category.TOOLS; + case "combat": + return Category.COMBAT; + case "brewing": + return Category.ALCHEMY; + case "materials": + return Category.MATERIALS; + case "misc": + return Category.MISCELLANEOUS; + default: + return new Category(creativeTab.getTabLabel(), ItemConverter.instance().toNova(creativeTab.getIconItemStack())); + } + } + + @Override + public CreativeTabs toNative(Category category) { + return toNative(category, ItemStack.EMPTY); + } + + public CreativeTabs toNative(Category category, Block block) { + return toNative(category, new ItemStack(block)); + } + + public CreativeTabs toNative(Category category, Item item) { + return toNative(category, new ItemStack(item)); + } + + public CreativeTabs toNative(Category category, ItemStack item) { + if (category.name.startsWith("nova:")) { + switch (category.name) { + case Category.BUILDING_BLOCKS_NAME: + return CreativeTabs.BUILDING_BLOCKS; + case Category.DECORATIONS_NAME: + return CreativeTabs.DECORATIONS; + case Category.TECHNOLOGY_NAME: + return CreativeTabs.REDSTONE; + case Category.TRANSPORTATION_NAME: + return CreativeTabs.TRANSPORTATION; + case Category.FOOD_NAME: + return CreativeTabs.FOOD; + case Category.TOOLS_NAME: + return CreativeTabs.TOOLS; + case Category.COMBAT_NAME: + return CreativeTabs.COMBAT; + case Category.ALCHEMY_NAME: + return CreativeTabs.BREWING; + case Category.MATERIALS_NAME: + return CreativeTabs.MATERIALS; + case Category.MISCELLANEOUS_NAME: + return CreativeTabs.MISC; + } + } + return Arrays.stream(CreativeTabs.CREATIVE_TAB_ARRAY) + .filter(tab -> tab.getTabLabel().equals(category.name)) + .findFirst() + .orElseGet(() -> new ModCreativeTab(category.name, category.item.map(ItemConverter.instance()::toNative).orElse(item))); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java new file mode 100644 index 000000000..ccd2260c9 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets; + +import net.minecraft.util.ResourceLocation; +import nova.core.nativewrapper.NativeConverter; +import nova.core.render.texture.Texture; +import nova.core.util.Asset; +import nova.internal.core.Game; + +/** + * @author ExE Boss + */ +public final class AssetConverter implements NativeConverter { + + public static AssetConverter instance() { + return (AssetConverter) Game.natives().getNative(Asset.class, ResourceLocation.class); + } + + @Override + public Class getNovaSide() { + return Asset.class; + } + + @Override + public Class getNativeSide() { + return ResourceLocation.class; + } + + @Override + public Asset toNova(ResourceLocation resource) { + return new Asset(resource.getResourceDomain(), resource.getResourcePath()) {}; + } + + public Texture toNovaTexture(ResourceLocation resource) { + return new Texture(resource.getResourceDomain(), resource.getResourcePath()); + } + + @Override + public ResourceLocation toNative(Asset asset) { + return new ResourceLocation(asset.domain.toLowerCase(), asset.name.toLowerCase());//path()); + } + + public ResourceLocation toNativeTexture(Asset asset) { + return toNativeTexture(asset, false); + } + + public ResourceLocation toNativeTexture(Asset asset, boolean preserveExtension) { + if (asset instanceof Texture) + return new ResourceLocation(asset.domain.toLowerCase(), asset.path().replaceFirst("^textures/", "").replaceFirst("\\.(\\w+)$", preserveExtension ? ".$1" : "")); + return new ResourceLocation(asset.domain.toLowerCase(), asset.path()); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java similarity index 53% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java index 5a0b766a2..3b3df1f35 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.render; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets; import com.google.common.base.Charsets; import net.minecraft.client.resources.FileResourcePack; @@ -31,38 +31,47 @@ import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; +import java.util.Optional; import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; -public class NovaResourcePack extends FileResourcePack { +public class NovaFileResourcePack extends FileResourcePack implements NovaResourcePack { private final String modid; private final String[] domains; + private ZipFile resourcePackZipFile; - public NovaResourcePack(File file, String modid, String[] domains) { + public NovaFileResourcePack(File file, String modid, String[] domains) { super(file); this.modid = modid; this.domains = domains; } + private ZipFile getResourcePackZipFile() throws IOException { + if (this.resourcePackZipFile == null) { + this.resourcePackZipFile = new ZipFile(this.resourcePackFile); + } + + return this.resourcePackZipFile; + } + @Override - public Set getResourceDomains() { + public Set getResourceDomains() { HashSet domains = new HashSet<>(); domains.add(modid); domains.addAll(Arrays.asList(this.domains)); return domains; } - private String transform(String path) { - return path.replaceFirst("assets[/\\\\]minecraft", modid); - } - @Override protected InputStream getInputStreamByName(String path) throws IOException { + path = transform(path); try { - return super.getInputStreamByName(transform(path)); + return getInputStreamCaseInsensitive(path); } catch (IOException e) { if (path.endsWith("sounds.json")) { return new ByteArrayInputStream(NovaMinecraftPreloader.generateSoundJSON(this).getBytes(Charsets.UTF_8)); - } else if (path.equals("pack.mcmeta")) { + } else if ("pack.mcmeta".equalsIgnoreCase(path)) { return new ByteArrayInputStream(NovaMinecraftPreloader.generatePackMcmeta().getBytes(Charsets.UTF_8)); } else { if (path.endsWith(".mcmeta")) { @@ -73,9 +82,20 @@ protected InputStream getInputStreamByName(String path) throws IOException { } } + @Override + public InputStream getInputStream(ResourceLocation rl) throws IOException { + return getInputStreamByName(transform(rl)); + } + @Override public boolean hasResourceName(String path) { - return super.hasResourceName(transform(path)); + path = transform(path); + //Hack Sounds and McMeta + if (path.endsWith("sounds.json") || path.endsWith("pack.mcmeta")) { + return true; + } + + return findFileCaseInsensitive(path).isPresent(); } @Override @@ -85,6 +105,36 @@ public boolean resourceExists(ResourceLocation rl) { return true; } - return super.resourceExists(rl); + return findFileCaseInsensitive(transform(rl)).isPresent(); + } + + @Override + public String getPackName() { + return NovaResourcePack.super.getPackName(); + } + + @Override + public String getID() { + return modid; + } + + @Override + public InputStream getInputStreamCaseInsensitive(String path) throws IOException { + System.out.println("Opening InputStream '" + path + '\''); + Optional ze = findFileCaseInsensitive(transform(path)); + if (ze.isPresent()) + return getResourcePackZipFile().getInputStream(ze.get()); + return super.getInputStreamByName(path); + } + + @Override + public Optional findFileCaseInsensitive(String path) { + System.out.println("Getting ZipEntry '" + path + '\''); + String p = transform(path); + try { + return getResourcePackZipFile().stream().filter(e -> e.getName().equalsIgnoreCase(p)).findFirst().map(e -> (ZipEntry) e); + } catch (IOException ex) { + return Optional.empty(); + } } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java similarity index 59% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java index 0c1bf7266..b6c9d6786 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/NovaFolderResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.render; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets; import com.google.common.base.Charsets; import net.minecraft.client.resources.FolderResourcePack; @@ -33,9 +33,10 @@ import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; +import java.util.Optional; import java.util.Set; -public class NovaFolderResourcePack extends FolderResourcePack { +public class NovaFolderResourcePack extends FolderResourcePack implements NovaResourcePack { private final String modid; private final String[] domains; @@ -53,18 +54,15 @@ public Set getResourceDomains() { return domains; } - private String transform(String path) { - return path; - } - @Override protected InputStream getInputStreamByName(String path) throws IOException { + path = transform(path); try { - return new BufferedInputStream(new FileInputStream(new File(this.resourcePackFile, transform(path)))); + return getInputStreamCaseInsensitive(path); } catch (IOException e) { if (path.endsWith("sounds.json")) { return new ByteArrayInputStream(NovaMinecraftPreloader.generateSoundJSON(this).getBytes(Charsets.UTF_8)); - } else if (path.equals("pack.mcmeta")) { + } else if ("pack.mcmeta".equalsIgnoreCase(path)) { return new ByteArrayInputStream(NovaMinecraftPreloader.generatePackMcmeta().getBytes(Charsets.UTF_8)); } else { if (path.endsWith(".mcmeta")) { @@ -75,18 +73,64 @@ protected InputStream getInputStreamByName(String path) throws IOException { } } + @Override + public InputStream getInputStream(ResourceLocation rl) throws IOException { + return getInputStreamByName(transform(rl)); + } + @Override public boolean hasResourceName(String path) { - return super.hasResourceName(transform(path)); + path = transform(path); + //Hack Sounds and McMeta + if (path.endsWith("sounds.json") || path.endsWith("pack.mcmeta")) { + return true; + } + + return findFileCaseInsensitive(path).isPresent(); } @Override public boolean resourceExists(ResourceLocation rl) { - //Hack Sounds + //Hack Sounds and McMeta if (rl.getResourcePath().endsWith("sounds.json") || rl.getResourcePath().endsWith("pack.mcmeta")) { return true; } - return new File(resourcePackFile, "assets/" + rl.getResourceDomain() + "/" + rl.getResourcePath()).isFile() || new File(resourcePackFile, rl.getResourceDomain() + "/" + rl.getResourcePath().replace(".mcmeta", "")).isFile(); + return findFileCaseInsensitive(transform(rl)).isPresent(); + } + + @Override + public String getPackName() { + return NovaResourcePack.super.getPackName(); + } + + @Override + public String getID() { + return modid; + } + + @Override + public InputStream getInputStreamCaseInsensitive(String path) throws IOException { + Optional file = findFileCaseInsensitive(transform(path)); + if (file.isPresent()) + return new FileInputStream(file.get()); + return super.getInputStreamByName(path); + } + + @Override + public Optional findFileCaseInsensitive(String path) { + final String transformedPath = transform(path); + + File[] files = resourcePackFile.listFiles((dir, name) -> transform(name).equalsIgnoreCase(transformedPath)); + + switch (files.length) { + case 0: + return Optional.empty(); + case 1: + return Optional.of(files[0]); + default: + // We are on a case sensitive file system + return Optional.of(new File(resourcePackFile, path)).filter(File::exists); + } } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java new file mode 100644 index 000000000..e91b9721e --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets; + +import net.minecraft.util.ResourceLocation; +import nova.core.util.Identifiable; + +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedList; +import java.util.Optional; + +/** + * @author ExE Boss + */ +public interface NovaResourcePack extends Identifiable { + + default String transform(ResourceLocation rl) { + return transform(String.format("assets/%s/%s", rl.getResourceDomain(), toAbsolutePath(rl.getResourcePath()))); + } + + default String transform(String path) { + return toAbsolutePath(path.toLowerCase().replace('\\', '/').replaceFirst("^assets/minecraft", "assets/" + getID())); + } + + default String getPackName() { + return getClass().getSimpleName() + ':' + getID(); + } + + InputStream getInputStreamCaseInsensitive(String path) throws IOException; + + Optional findFileCaseInsensitive(String path); + + static String toAbsolutePath(String path) { + LinkedList stack = new LinkedList<>(); + int skipCount = 0; + String[] split = path.split("[/\\\\]"); + + for (int i = split.length - 1; i >= 0; i--) { + String p = split[i]; + if (".".equals(p)) + continue; + else if ("..".equals(p)) { + skipCount++; + continue; + } + + if (skipCount > 0) { + skipCount--; + continue; + } + + stack.addFirst(p); + } + + if (skipCount > 0) + throw new IllegalArgumentException('\'' + path + "' leads outside root"); + + System.out.println(path + " -> " + String.join("/", stack)); + return String.join("/", stack); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index ef0d41001..049bed661 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -109,10 +109,10 @@ public void preInit(FMLPreInitializationEvent evt) { private void registerMinecraftToNOVA() { //TODO: Will this register ALL Forge mod blocks as well? BlockManager blockManager = Game.blocks(); - net.minecraft.block.Block.REGISTRY.forEach(obj -> + net.minecraft.block.Block.REGISTRY.forEach(block -> blockManager.register( - new BlockFactory(net.minecraft.block.Block.REGISTRY.getNameForObject(obj).toString(), - () -> new BWBlock((net.minecraft.block.Block) obj), evt -> { + new BlockFactory(net.minecraft.block.Block.REGISTRY.getNameForObject(block).toString(), + () -> new BWBlock(block), evt -> { }) ) ); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index 0a51e18b4..d2bb46e56 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -77,7 +77,7 @@ public void setBlock(Block block) { @Override public SPacketUpdateTileEntity getUpdatePacket() { if (block instanceof Syncable) { - return new FWPacketUpdateTileEntity(((MCNetworkManager) Game.network()).toMCPacket(((MCNetworkManager) Game.network()).writePacket(0, (Syncable) block)), + return new FWPacketUpdateTileEntity<>(((MCNetworkManager) Game.network()).toMCPacket(((MCNetworkManager) Game.network()).writePacket(0, (Syncable) block)), this.getPos(), this.getBlockMetadata(), this.getTileData()); } return null; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java index 339294a22..0c1a0211c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java @@ -52,8 +52,8 @@ public static FWTile loadTile(NBTTagCompound data) { try { String blockID = data.getString("novaID"); Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[0], new Object[0]) : - injector.inject(block, new Class[0], new Object[0]); + ComponentInjector inject = (block instanceof Updater) ? updaterInjector : injector; + FWTile tile = inject.inject(block, new Class[0], new Object[0]); tile.setBlock(block); WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); Game.events().publish(event); @@ -66,8 +66,8 @@ public static FWTile loadTile(NBTTagCompound data) { public static FWTile loadTile(String blockID) { try { Block block = createBlock(blockID); - FWTile tile = (block instanceof Updater) ? updaterInjector.inject(block, new Class[] { String.class }, new Object[] { blockID }) : - injector.inject(block, new Class[] { String.class }, new Object[] { blockID }); + ComponentInjector inject = (block instanceof Updater) ? updaterInjector : injector; + FWTile tile = inject.inject(block, new Class[] { String.class }, new Object[] { blockID }); tile.setBlock(block); WrapperEvent.FWTileCreate event = new WrapperEvent.FWTileCreate(block, tile); Game.events().publish(event); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java index d1e506593..f65de03c8 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java @@ -17,6 +17,7 @@ public class ProxyMaterial extends Material { * Construct a new proxy material. * @param color The map color. * @param opacity The Opacity to use. + * @param replaceable The Replaceable to use. */ public ProxyMaterial(MapColor color, Optional opacity, Optional replaceable) { super(color); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java index f37023989..ebfa0364e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java @@ -143,10 +143,10 @@ public void removeEntity(Entity entity) { @Override public Set getEntities(Cuboid bound) { - return (Set) world() + return world() .getEntitiesWithinAABB(net.minecraft.entity.Entity.class, new AxisAlignedBB(bound.min.getX(), bound.min.getY(), bound.min.getZ(), bound.max.getX(), bound.max.getY(), bound.max.getZ())) .stream() - .map(mcEnt -> Game.natives().getNative(Entity.class, net.minecraft.entity.Entity.class).toNova((net.minecraft.entity.Entity) mcEnt)) + .map(mcEnt -> Game.natives().getNative(Entity.class, net.minecraft.entity.Entity.class).toNova(mcEnt)) .collect(Collectors.toSet()); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java index 56ac46133..4b3420423 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java @@ -56,6 +56,7 @@ public boolean hasCapability(Capability capability, EnumFacing facing) { } @Override + @SuppressWarnings("unchecked") public T getCapability(Capability capability, EnumFacing facing) { if (!hasCapability(capability, facing)) return null; return (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java index b761c5695..6e567e421 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java @@ -114,7 +114,7 @@ public static void render(FWEntity wrapper, nova.core.entity.Entity entity, doub @Override public void doRender(FWEntity entity, double x, double y, double z, float p_76986_8_, float p_76986_9_) { - render(entity, ((FWEntity) entity).wrapped, x, y, z); + render(entity, entity.wrapped, x, y, z); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 76a5e828e..f07912db7 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -21,7 +21,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import com.google.common.collect.HashBiMap; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -37,7 +36,7 @@ import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; @@ -46,9 +45,7 @@ import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; -import java.util.Arrays; import java.util.Objects; -import java.util.Optional; import java.util.Set; /** @@ -106,7 +103,7 @@ public Item getNovaItem(ItemStack itemStack) { @Override public ItemStack toNative(Item item) { if (item == null) { - return null; + return ItemStack.EMPTY; } //Prevent recusive wrapping @@ -226,16 +223,7 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { //Add into creative tab Category category = dummy.components.get(Category.class); - Optional first = Arrays.stream(CreativeTabs.CREATIVE_TAB_ARRAY) - .filter(tab -> tab.getTabLabel().equals(category.name)) - .findFirst(); - if (first.isPresent()) { - itemWrapper.setCreativeTab(first.get()); - } else { - Optional item = category.item; - ModCreativeTab tab = new ModCreativeTab(category.name, item.isPresent() ? Game.natives().toNative(item.get()) : itemWrapper); - itemWrapper.setCreativeTab(tab); - } + itemWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, itemWrapper)); } System.out.println("[NOVA]: Registered '" + itemFactory.getID() + "' item."); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java index d39ace421..d2753bb14 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java @@ -22,6 +22,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.world.World; import nova.core.item.Item; @@ -42,9 +43,9 @@ public interface ItemWrapperMethods { ItemFactory getItemFactory(); - default void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { + default void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { Item item = Game.natives().toNova(itemStack); - item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), list)); + item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), tooltip)); getItemFactory().save(item); } @@ -53,13 +54,13 @@ default EnumActionResult onItemUse(ItemStack itemStack, EntityPlayer player, Wor Item.UseEvent event = new Item.UseEvent(new BWEntity(player), new Vector3D(x, y, z), Direction.fromOrdinal(side), new Vector3D(hitX, hitY, hitZ)); item.events.publish(event); ItemConverter.instance().updateMCItemStack(itemStack, item); - return event.action ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + return event.action ? EnumActionResult.SUCCESS : EnumActionResult.PASS; } - default ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + default ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { Item item = Game.natives().toNova(itemStack); item.events.publish(new Item.RightClickEvent(new BWEntity(player))); - return ItemConverter.instance().updateMCItemStack(itemStack, item); + return new ActionResult<>(EnumActionResult.PASS, ItemConverter.instance().updateMCItemStack(itemStack, item)); } default int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index 1a83dc4a6..486f275a0 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -39,6 +40,8 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemWrapperMethods; import nova.internal.core.Game; +import javax.annotation.Nullable; + /** * @author Calclavia */ @@ -53,7 +56,8 @@ public FWItem(ItemFactory item) { } @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + @Nullable + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { Item item = Game.natives().toNova(stack); WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; @@ -65,8 +69,8 @@ public ItemFactory getItemFactory() { } @Override - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { - ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); + public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { + ItemWrapperMethods.super.addInformation(itemStack, player, tooltip, advanced); } @Override @@ -75,7 +79,7 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos } @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index a03a9eb95..685af5f22 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -23,6 +23,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -61,8 +62,8 @@ public ItemFactory getItemFactory() { } @Override - public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean p_77624_4_) { - ItemWrapperMethods.super.addInformation(itemStack, player, list, p_77624_4_); + public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { + ItemWrapperMethods.super.addInformation(itemStack, player, tooltip, advanced); } @Override @@ -71,7 +72,7 @@ public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos } @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java index 1a33ca364..1d89671b6 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java @@ -42,7 +42,7 @@ public Item getItem() { @Override public NBTTagCompound copy() { FWNBTTagCompound result = new FWNBTTagCompound(item); - getKeySet().forEach(s -> result.setTag((String) s, getTag((String) s).copy())); + getKeySet().forEach(key -> result.setTag(key, getTag(key).copy())); return result; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java index 4c2a2998d..59673bbe1 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java @@ -191,7 +191,7 @@ public BWParticle(int particleID) { public Particle createParticle(net.minecraft.world.World world) { //Look up for particle factory and pass it into BWParticle - IParticleFactory particleFactory = (IParticleFactory) FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID); + IParticleFactory particleFactory = FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID); Particle particle = particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0); if (components.has(MCParticleTransform.class)) components.remove(MCParticleTransform.class); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java deleted file mode 100644 index 43fce8657..000000000 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWClientRenderManager.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; - -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import nova.core.render.RenderException; -import nova.core.render.texture.Texture; -import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; -import org.apache.logging.log4j.Level; - -import javax.imageio.ImageIO; -import javax.imageio.ImageReader; -import javax.imageio.stream.ImageInputStream; - -import java.util.Iterator; - -/** - * @author Calclavia - */ -public class BWClientRenderManager extends BWRenderManager { - @SideOnly(Side.CLIENT) - @Override - public Vector2D getDimension(Texture texture) { - ResourceLocation loc = toResourceLocation(texture); - - try { - ImageInputStream in = ImageIO.createImageInputStream(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream()); - Iterator readers = ImageIO.getImageReaders(in); - if (readers.hasNext()) { - ImageReader reader = readers.next(); - try { - reader.setInput(in); - return new Vector2D(reader.getWidth(0), reader.getHeight(0)); - } finally { - reader.dispose(); - } - } - } catch (Exception e) { - FMLLog.log("NOVA", Level.ERROR, new RenderException("Couldn't load texture " + texture.getPath(), e), - !texture.getResource().toLowerCase().equals(texture.getResource()) ? - "Minecraft doesn’t support textures with uppercase characters" : ""); - } - return new Vector2D(16, 16); - } -} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java index d74edd5b1..a55769f9c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java @@ -24,11 +24,12 @@ import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.ResourceLocation; +import nova.core.render.model.CustomModel; import nova.core.render.model.MeshModel; import nova.core.render.texture.EntityTexture; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; import java.util.Optional; @@ -52,11 +53,9 @@ public void render(Optional entityRenderManager) { */ flatten().forEach( model -> { - System.out.println(model); if (model instanceof MeshModel) { MeshModel meshModel = (MeshModel) model; meshModel.faces.forEach(face -> { - System.out.println(face); // TODO: See if this works, and possibly fix it // Brightness is defined as: skyLight << 20 | blockLight << 4 if (face.getBrightness() >= 0) { @@ -68,14 +67,14 @@ public void render(Optional entityRenderManager) { //worldRenderer.setBrightness(15 << 20 | 11 << 4); } - worldRenderer.normal((int) face.normal.getX(), (int) face.normal.getY(), (int) face.normal.getZ()); + worldRenderer.normal((float) face.normal.getX(), (float) face.normal.getY(), (float) face.normal.getZ()); System.out.println(face.texture); if (face.texture.isPresent()) { if (entityRenderManager.isPresent() && face.texture.get() instanceof EntityTexture) { //We're not working on an atlas, so just do... this. Texture t = face.texture.get(); - entityRenderManager.get().renderEngine.bindTexture(new ResourceLocation(t.domain, "textures/entities/" + t.resource + ".png")); + entityRenderManager.get().renderEngine.bindTexture(AssetConverter.instance().toNative(t)); face.vertices.forEach( v -> { worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); @@ -108,8 +107,10 @@ public void render(Optional entityRenderManager) { ); } }); + } else if (model instanceof CustomModel) { + CustomModel customModel = (CustomModel) model; + customModel.render.accept(customModel); } - //TODO: Handle BW Rendering } ); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java deleted file mode 100644 index 59e15e897..000000000 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWRenderManager.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; - -import net.minecraft.util.ResourceLocation; -import nova.core.render.RenderManager; -import nova.core.render.texture.Texture; -import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; - -public class BWRenderManager extends RenderManager { - - public static ResourceLocation toResourceLocation(Texture texture) { - return new ResourceLocation(texture.domain, texture.getPath()); - } - - @Override - public Vector2D getDimension(Texture texture) { - return new Vector2D(16, 16); - } -} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 623ee533b..4a9215c2b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -20,7 +20,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -31,6 +30,7 @@ import nova.core.block.Block; import nova.core.component.renderer.DynamicRenderer; import nova.core.component.renderer.StaticRenderer; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.util.vector.Vector3f; import java.util.List; @@ -39,32 +39,27 @@ * Generates a smart model based on a NOVA Model * @author Calclavia */ +@SuppressWarnings("deprecation") public class FWSmartBlockModel extends FWSmartModel implements IBakedModel { private final Block block; private final boolean isItem; - public FWSmartBlockModel(Block block, boolean isDummy) { + @SuppressWarnings("deprecation") + public FWSmartBlockModel(Block block, boolean isItem) { super(); this.block = block; - this.isItem = isDummy; + this.isItem = isItem; // Change the default transforms to the default full Block transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(75, 225, 0), // Third Person (Left) - new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), - new ItemTransformVec3f(new Vector3f(75, 45, 0), // Third Person (Right) - new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), - new ItemTransformVec3f(new Vector3f(0, 225, 0), // First Person (Left) - new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), - new ItemTransformVec3f(new Vector3f(0, 45, 0), // First Person (Right) - new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), - ItemTransformVec3f.DEFAULT, // Head - new ItemTransformVec3f(new Vector3f(30, 225, 0), // Gui - new Vector3f(0, 0, 0), new Vector3f(0.625f, 0.625f, 0.625f)), - new ItemTransformVec3f(new Vector3f(0, 0, 0), // Ground - new Vector3f(0, 0, 0), new Vector3f(0, 0, 0)), - new ItemTransformVec3f(new Vector3f(0, 0, 0), // Fixed - new Vector3f(0, 0, 0), new Vector3f(0, 0, 0))); + new ItemTransformVec3f(new Vector3f(75, 225, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Left) + new ItemTransformVec3f(new Vector3f(75, 45, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Right) + new ItemTransformVec3f(new Vector3f(0, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Left) + new ItemTransformVec3f(new Vector3f(0, 45, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Right) + ItemTransformVec3f.DEFAULT, // Head + new ItemTransformVec3f(new Vector3f(30, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.625f, 0.625f, 0.625f)), // GUI + ItemTransformVec3f.DEFAULT, // Ground + ItemTransformVec3f.DEFAULT);// Fixed } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index 75330776f..d66e90789 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -40,6 +40,7 @@ * Generates a smart model based on a NOVA Model * @author Calclavia */ +@SuppressWarnings("deprecation") public class FWSmartItemModel extends FWSmartModel implements IBakedModel { private final Item item; @@ -49,12 +50,14 @@ public FWSmartItemModel(Item item) { this.item = item; // Change the default transforms to the default Item transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person - new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person - ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT, - ItemTransformVec3f.DEFAULT, ItemTransformVec3f.DEFAULT); + new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person (Left) + new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person (Right) + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Left) + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Rigth) + ItemTransformVec3f.DEFAULT, // Head + new ItemTransformVec3f(new Vector3f(-30, 135, 0), new Vector3f(), new Vector3f(1.6F, 1.6F, 1.6F)), // GUI + ItemTransformVec3f.DEFAULT, // Ground + ItemTransformVec3f.DEFAULT);// Fixed } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java index a6b115a04..62abf219c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java @@ -21,11 +21,8 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; import com.google.common.primitives.Ints; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.client.renderer.block.model.ItemOverrideList; -import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -37,9 +34,11 @@ import nova.core.render.model.Model; import nova.core.render.model.Vertex; import nova.core.util.Direction; +import nova.core.util.math.MathUtil; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import java.util.Collections; +import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -48,27 +47,42 @@ * Generates a smart model based on a NOVA Model * @author Calclavia */ +@SuppressWarnings("deprecation") public abstract class FWSmartModel implements IBakedModel { + protected static final VertexFormat NOVA_VERTEX_FORMAT; + protected final VertexFormat format; // Default item transforms. Can be changed in subclasses. protected ItemCameraTransforms itemCameraTransforms = ItemCameraTransforms.DEFAULT; + static { + NOVA_VERTEX_FORMAT = DefaultVertexFormats.ITEM; +// NOVA_VERTEX_FORMAT = new VertexFormat(); +// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.POSITION_3F); +// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.COLOR_4UB); +// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.TEX_2F); +// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.NORMAL_3B); +// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.PADDING_1B); + } + + protected FWSmartModel(VertexFormat format) { + this.format = format; + } + public FWSmartModel() { - this.format = new VertexFormat(); - this.format.addElement(DefaultVertexFormats.POSITION_3F); - this.format.addElement(DefaultVertexFormats.COLOR_4UB); - this.format.addElement(DefaultVertexFormats.TEX_2F); + this.format = DefaultVertexFormats.ITEM; } - public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture) { + public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture, Vector3D normal) { return new int[] { Float.floatToRawIntBits((float) vertex.vec.getX()), Float.floatToRawIntBits((float) vertex.vec.getY()), Float.floatToRawIntBits((float) vertex.vec.getZ()), - vertex.color.rgba(), + vertex.color.argb(), Float.floatToRawIntBits(texture.getInterpolatedU(16 * vertex.uv.getX())), Float.floatToRawIntBits(texture.getInterpolatedV(16 * vertex.uv.getY())), + 0 // TODO: Normal }; } @@ -88,12 +102,12 @@ protected List modelToQuads(Model modelIn) { .orElse(Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()); List vertexData = face.vertices .stream() - .map(v -> vertexToInts(v, texture)) + .map(v -> vertexToInts(v, texture, face.normal)) .collect(Collectors.toList()); int[] data = Ints.concat(vertexData.toArray(new int[][] {})); //TODO: The facing might be wrong - return new BakedQuad(data, -1, EnumFacing.values()[Direction.fromVector(face.normal).ordinal()], + return new BakedQuad(Arrays.copyOf(data, MathUtil.max(data.length, 0)), -1, EnumFacing.values()[Direction.fromVector(face.normal).ordinal()], getParticleTexture(), true, getFormat()); } ); @@ -130,7 +144,6 @@ public TextureAtlasSprite getParticleTexture() { } @Override - @Deprecated public ItemCameraTransforms getItemCameraTransforms() { return itemCameraTransforms; } diff --git a/minecraft/1.11.2/src/main/resources/fmlbranding.properties b/minecraft/1.11.2/src/main/resources/fmlbranding.properties index d8ae8b040..bc328e1a2 100644 --- a/minecraft/1.11.2/src/main/resources/fmlbranding.properties +++ b/minecraft/1.11.2/src/main/resources/fmlbranding.properties @@ -1 +1 @@ -fmlbranding=${version} +fmlbranding=NOVA ${version} diff --git a/minecraft/1.11.2/src/main/resources/mcmod.info b/minecraft/1.11.2/src/main/resources/mcmod.info index 5364e1dc9..6bb0881bf 100644 --- a/minecraft/1.11.2/src/main/resources/mcmod.info +++ b/minecraft/1.11.2/src/main/resources/mcmod.info @@ -8,7 +8,7 @@ "mcversion": "${mcversion}", "url": "https://novaapi.net/", "updateUrl": "", - "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts" ], + "authorList": [ "calclavia", "RX14", "AEnterprise", "magik6k", "Shadowfacts", "ExE Boss" ], "credits": "Created by the NOVA Team.\nPorted to Minecraft 1.11 by: ExE Boss.", "logoFile": "/assets/nova/textures/NOVA.png", "screenshots": [], diff --git a/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java index 6b6cfbd34..796fd98b2 100644 --- a/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java +++ b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java @@ -24,7 +24,6 @@ import nova.core.wrapper.mc.forge.v1_11_2.depmodules.GameInfoModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.KeyModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.LanguageModule; -import nova.core.wrapper.mc.forge.v1_11_2.depmodules.RenderModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.SaveModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; import nova.internal.core.Game; @@ -49,8 +48,7 @@ public List> getModules() { ClientModule.class, KeyModule.class, LanguageModule.class, - FakeNetworkModule.class, //NetworkManager calls into FML code in the class instantiation, so we create a fake. - RenderModule.class, + FakeNetworkModule.class, //NetworkManager calls into FML code in the class instantiation, so we use a fake. SaveModule.class, TickerModule.class, GameInfoModule.class From 8649c7167f08ef8fbb663b783515724e12e43f40 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 2 Mar 2017 00:20:17 +0100 Subject: [PATCH 35/61] Fix normal conversion --- .../wrapper/assets/NovaFileResourcePack.java | 2 -- .../v1_11_2/wrapper/assets/NovaResourcePack.java | 1 - .../wrapper/render/forward/FWSmartItemModel.java | 13 +++++++------ .../wrapper/render/forward/FWSmartModel.java | 10 ++++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java index 3b3df1f35..c5fd41dd8 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java @@ -120,7 +120,6 @@ public String getID() { @Override public InputStream getInputStreamCaseInsensitive(String path) throws IOException { - System.out.println("Opening InputStream '" + path + '\''); Optional ze = findFileCaseInsensitive(transform(path)); if (ze.isPresent()) return getResourcePackZipFile().getInputStream(ze.get()); @@ -129,7 +128,6 @@ public InputStream getInputStreamCaseInsensitive(String path) throws IOException @Override public Optional findFileCaseInsensitive(String path) { - System.out.println("Getting ZipEntry '" + path + '\''); String p = transform(path); try { return getResourcePackZipFile().stream().filter(e -> e.getName().equalsIgnoreCase(p)).findFirst().map(e -> (ZipEntry) e); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java index e91b9721e..bd0e6fcdb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java @@ -74,7 +74,6 @@ else if ("..".equals(p)) { if (skipCount > 0) throw new IllegalArgumentException('\'' + path + "' leads outside root"); - System.out.println(path + " -> " + String.join("/", stack)); return String.join("/", stack); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index d66e90789..1f3671e68 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -20,7 +20,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; @@ -32,6 +31,7 @@ import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.util.vector.Vector3f; import java.util.List; @@ -45,17 +45,18 @@ public class FWSmartItemModel extends FWSmartModel implements IBakedModel { private final Item item; + @SuppressWarnings("deprecation") public FWSmartItemModel(Item item) { super(); this.item = item; // Change the default transforms to the default Item transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person (Left) - new ItemTransformVec3f(new Vector3f(-90, 0, 0), new Vector3f(0, 1, -3), new Vector3f(0.55f, 0.55f, 0.55f)), // Third Person (Right) - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Left) - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 4, 2), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Rigth) + new ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Left) + new ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Right) + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Left) + new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Rigth) ItemTransformVec3f.DEFAULT, // Head - new ItemTransformVec3f(new Vector3f(-30, 135, 0), new Vector3f(), new Vector3f(1.6F, 1.6F, 1.6F)), // GUI + ItemTransformVec3f.DEFAULT, // new ItemTransformVec3f(new Vector3f(-30, 135, 0), new Vector3f(), new Vector3f(1.6F, 1.6F, 1.6F)), // GUI ItemTransformVec3f.DEFAULT, // Ground ItemTransformVec3f.DEFAULT);// Fixed } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java index 62abf219c..4fddcc6fd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java @@ -22,8 +22,8 @@ import com.google.common.primitives.Ints; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -71,7 +71,7 @@ protected FWSmartModel(VertexFormat format) { } public FWSmartModel() { - this.format = DefaultVertexFormats.ITEM; + this.format = NOVA_VERTEX_FORMAT; } public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture, Vector3D normal) { @@ -82,7 +82,9 @@ public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture, Vect vertex.color.argb(), Float.floatToRawIntBits(texture.getInterpolatedU(16 * vertex.uv.getX())), Float.floatToRawIntBits(texture.getInterpolatedV(16 * vertex.uv.getY())), - 0 // TODO: Normal + ((((byte)(normal.getX() * 127)) & 0xFF) | + ((((byte)(normal.getY() * 127)) & 0xFF) << 8) | + ((((byte)(normal.getZ() * 127)) & 0xFF) << 16)) // TODO: Normal }; } @@ -108,7 +110,7 @@ protected List modelToQuads(Model modelIn) { int[] data = Ints.concat(vertexData.toArray(new int[][] {})); //TODO: The facing might be wrong return new BakedQuad(Arrays.copyOf(data, MathUtil.max(data.length, 0)), -1, EnumFacing.values()[Direction.fromVector(face.normal).ordinal()], - getParticleTexture(), true, getFormat()); + texture, true, getFormat()); } ); } From 90c6d26c0f241536cb3d1a68ba453294abf0549c Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 13 Mar 2017 13:23:52 +0100 Subject: [PATCH 36/61] Fix TileEntityTransformer --- .../mc/forge/v1_11_2/asm/StaticForwarder.java | 2 + .../transformers/TileEntityTransformer.java | 48 ++++++++++++++++++- .../asm/transformers/Transformers.java | 2 +- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index 069431735..e83ef43cc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -38,6 +38,8 @@ */ public class StaticForwarder { + private StaticForwarder() {} + public static void chunkSetBlockEvent(Chunk chunk, BlockPos pos, IBlockState oldBlockState, IBlockState newBlockState) { // Publish the event Game.events().publish( diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java index 43a715c62..929d8db42 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java @@ -28,9 +28,20 @@ import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.VarInsnNode; +import org.objectweb.asm.util.TraceClassVisitor; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; public class TileEntityTransformer implements Transformer { + /** + * If the TileEntity byte code should be written to a debug file. (One for the unmodified version, and one for the modified version) + */ + public static boolean writeDebug = false; + @Override public void transform(ClassNode cnode) { @@ -41,9 +52,12 @@ public void transform(ClassNode cnode) { MethodNode method = ASMHelper.findMethod(obfMap, cnode); + boolean deobf = false; + if (method == null) { System.out.println("[NOVA] Lookup " + obfMap + " failed. You are probably in a deobf environment."); method = ASMHelper.findMethod(deobfMap, cnode); + deobf = true; if (method == null) { System.out.println("[NOVA] Lookup " + deobfMap + " failed!"); @@ -53,7 +67,24 @@ public void transform(ClassNode cnode) { System.out.println("[NOVA] Transforming method " + method.name); - ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 31, 44)); + if (writeDebug) { + try { + File root = new File("NOVA-Debug"); + if (!root.exists()) + root.mkdir(); + + File file = new File(root, "TileEntityOriginal.java"); + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); + TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); + cnode.accept(traceClassVisitor); + } catch (IOException ex) {} + } + + ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 30, 33)); InsnList list = new InsnList(); list.add(new VarInsnNode(ALOAD, 0)); // World @@ -62,7 +93,20 @@ public void transform(ClassNode cnode) { list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder", "loadTileEntityHook", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;Ljava/lang/Class;)Lnet/minecraft/tileentity/TileEntity;", false)); list.add(new VarInsnNode(ASTORE, 2)); // TileEntity - method.instructions.insert(method.instructions.get(31), list); + method.instructions.insert(method.instructions.get(29), list); + + if (writeDebug) { + try { + File file = new File("NOVA-Debug/TileEntityModified.java"); + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); + TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); + cnode.accept(traceClassVisitor); + } catch (IOException ex) {} + } System.out.println("[NOVA] Injected instruction to method: " + method.name); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java index 2cb946924..daa158fdd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java @@ -36,7 +36,7 @@ public final class Transformers implements IClassTransformer { public Transformers() { registerTransformer(new ChunkTransformer(), "net.minecraft.world.chunk.Chunk"); - //registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); + registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); } public static void registerTransformer(Transformer transformer, String... classes) { From cc2085e749fa76ade0019758ecbcacdada3ed4a3 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 13 Mar 2017 14:06:27 +0100 Subject: [PATCH 37/61] Rebase to Master and update --- minecraft/1.11.2/gradle.properties | 2 +- .../forge/v1_11_2/NovaMinecraftPreloader.java | 27 ++- .../forge/v1_11_2/launcher/ClientProxy.java | 62 ++++- .../forge/v1_11_2/launcher/CommonProxy.java | 3 + .../forge/v1_11_2/launcher/NovaMinecraft.java | 27 +-- .../network/netty/MCNetworkManager.java | 4 +- .../v1_11_2/recipes/RecipeConverter.java | 5 +- .../forge/v1_11_2/render/RenderUtility.java | 58 ++--- .../forge/v1_11_2/util/MCLanguageManager.java | 9 +- .../v1_11_2/wrapper/CategoryConverter.java | 2 +- .../v1_11_2/wrapper/DirectionConverter.java | 13 +- .../v1_11_2/wrapper/VectorConverter.java | 6 + .../wrapper/assets/AssetConverter.java | 2 +- .../wrapper/assets/NovaFileResourcePack.java | 25 +- .../assets/NovaFolderResourcePack.java | 20 +- .../wrapper/assets/NovaResourcePack.java | 7 +- .../v1_11_2/wrapper/block/BlockConverter.java | 4 +- .../wrapper/block/backward/BWBlock.java | 153 ++++++++---- .../wrapper/block/forward/FWBlock.java | 49 +++- .../v1_11_2/wrapper/block/forward/FWTile.java | 12 +- .../wrapper/block/forward/FWTileRenderer.java | 4 +- .../wrapper/block/forward/FWTileUpdater.java | 1 - .../wrapper/block/world/WorldConverter.java | 10 +- .../wrapper/cuboid/CuboidConverter.java | 6 + .../{DataWrapper.java => DataConverter.java} | 6 +- .../wrapper/entity/EntityConverter.java | 4 + .../wrapper/entity/backward/BWEntity.java | 21 +- .../wrapper/entity/forward/FWEntity.java | 4 +- .../wrapper/inventory/InventoryConverter.java | 6 + .../v1_11_2/wrapper/item/ItemConverter.java | 6 +- .../item/OreDictionaryIntegration.java | 65 +++--- .../v1_11_2/wrapper/item/backward/BWItem.java | 19 ++ .../wrapper/item/backward/BWItemFactory.java | 5 + .../v1_11_2/wrapper/item/forward/FWItem.java | 37 +-- .../wrapper/item/forward/FWItemBlock.java | 31 ++- .../IFWItem.java} | 19 +- .../wrapper/particle/backward/BWParticle.java | 11 +- .../wrapper/render/backward/BWBakedModel.java | 218 ++++++++++++++++++ .../wrapper/render/backward/BWModel.java | 121 ++++++---- .../wrapper/render/forward/FWEmptyModel.java | 17 +- .../render/forward/FWSmartBlockModel.java | 57 +++-- .../render/forward/FWSmartItemModel.java | 35 ++- .../wrapper/render/forward/FWSmartModel.java | 62 +++-- .../v1_11_2/launcher/NovaLauncherTest.java | 3 +- 44 files changed, 905 insertions(+), 353 deletions(-) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/{DataWrapper.java => DataConverter.java} (96%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/{ItemWrapperMethods.java => forward/IFWItem.java} (79%) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java diff --git a/minecraft/1.11.2/gradle.properties b/minecraft/1.11.2/gradle.properties index dfff6bc70..4d6000c88 100644 --- a/minecraft/1.11.2/gradle.properties +++ b/minecraft/1.11.2/gradle.properties @@ -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 diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index cc675dcfb..6f5a04399 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -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 @@ -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; @@ -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; @@ -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> modClasses; public static Map, File> modClassToFile; + public static List> novaResourcePacks = Collections.emptyList(); static { md = new ModMetadata(); md.modId = "novapreloader"; md.name = "NOVA Preloader"; - md.version = version; + md.version = VERSION; } public NovaMinecraftPreloader() { @@ -293,6 +298,7 @@ public void registerResourcePacks() { List packs = (List) resourcePackField.get(FMLClientHandler.instance()); Set addedPacks = new HashSet<>(); + List> novaPacks = new LinkedList<>(); classesMap.keySet().forEach(novaMod -> { Class c = classesMap.get(novaMod); @@ -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()) { @@ -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); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java index 363665787..29402dc19 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java @@ -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 @@ -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 */ @@ -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); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java index cf312880e..d019ba281 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/CommonProxy.java @@ -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; @@ -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> modClasses) { } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 233a0abad..26ac85b80 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -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 @@ -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; @@ -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 nativeConverters; @@ -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()); @@ -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(); @@ -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"); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java index f8d8d6a13..14da12f25 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/netty/MCNetworkManager.java @@ -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 channelEnumMap = NetworkRegistry.INSTANCE.newChannel(channel, new ChannelHandler(), new MCPacketHandler()); public Packet toMCPacket(PacketAbstract packet) { @@ -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); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java index 9175a75d4..fd0cd08e2 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java @@ -39,6 +39,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Optional; /** @@ -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) { @@ -237,6 +238,7 @@ public static CraftingRecipe toNova(IRecipe recipe) { } else if (recipe instanceof ShapedRecipes) { ShapedRecipes shaped = (ShapedRecipes) recipe; + @SuppressWarnings({"unchecked", "rawtypes"}) Optional[][] ingredients = new Optional[shaped.recipeHeight][shaped.recipeWidth]; for (int i = 0; i < shaped.recipeHeight; i++) { for (int j = 0; j < shaped.recipeWidth; j++) { @@ -251,6 +253,7 @@ public static CraftingRecipe toNova(IRecipe recipe) { int width = ReflectionUtil.getShapedOreRecipeWidth(shaped); int height = recipe.getRecipeSize() / width; + @SuppressWarnings({"unchecked", "rawtypes"}) Optional[][] recipeIngredients = new Optional[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java index ec2de699c..0a086975e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java @@ -23,9 +23,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.block.model.FaceBakery; -import net.minecraft.client.renderer.block.model.ItemModelGenerator; -import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.IResource; @@ -40,11 +37,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; +import nova.core.item.ItemFactory; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.IFWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWEmptyModel; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartBlockModel; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWSmartItemModel; @@ -55,7 +54,6 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.HashMap; -import java.util.Optional; import static org.lwjgl.opengl.GL11.GL_BLEND; import static org.lwjgl.opengl.GL11.GL_FLAT; @@ -78,37 +76,6 @@ public class RenderUtility implements ForgeLoadable { public static final ResourceLocation particleResource = new ResourceLocation("textures/particle/particles.png"); public static final RenderUtility instance = new RenderUtility(); - // Cruft needed to generate default item models - protected static final ItemModelGenerator ITEM_MODEL_GENERATOR = new ItemModelGenerator(); - protected static final FaceBakery FACE_BAKERY = new FaceBakery(); - // Ugly D: - protected static final ModelBlock MODEL_GENERATED = ModelBlock.deserialize( - "{" + - " \"elements\":[{\n" + - " \"from\": [0, 0, 0],\n" + - " \"to\": [16, 16, 16],\n" + - " \"faces\": {\n" + - " \"down\": {\"uv\": [0, 0, 16, 16], \"texture\":\"\"}\n" + - " }\n" + - " }],\n" + - " \"display\": {\n" + - " \"thirdperson_righthand\": {\n" + - " \"rotation\": [ -90, 0, 0 ],\n" + - " \"translation\": [ 0, 1, -3 ],\n" + - " \"scale\": [ 0.55, 0.55, 0.55 ]\n" + - " },\n" + - " \"firstperson_righthand\": {\n" + - " \"rotation\": [ 0, -90, 25 ],\n" + - " \"translation\": [ 0, 3.75, 2.3125 ],\n" + - " \"scale\": [ 0.6, 0.6, 0.6 ]\n" + - " },\n" + - " \"firstperson_lefthand\": {\n" + - " \"rotation\": [ 0, 90, -25 ],\n" + - " \"translation\": [ 0, 3.75, 2.3125 ],\n" + - " \"scale\": [ 0.6, 0.6, 0.6 ]\n" + - " }\n" + - " }\n" + - "}"); //NOVA Texture to MC TextureAtlasSprite private final HashMap textureMap = new HashMap<>(); @@ -155,12 +122,6 @@ public static void enableLightmap() { OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } - public TextureAtlasSprite getTexture(Optional texture) { - if (!texture.isPresent()) - return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); - return getTexture(texture.get()); - } - public TextureAtlasSprite getTexture(Texture texture) { if (textureMap.containsKey(texture)) { return textureMap.get(texture); @@ -179,7 +140,6 @@ public void preTextureHook(TextureStitchEvent.Pre event) { if (event.getMap() == Minecraft.getMinecraft().getTextureMapBlocks()) { Game.render().blockTextures.forEach(t -> registerIcon(t, event)); Game.render().itemTextures.forEach(t -> registerIcon(t, event)); - //TODO: This is HACKS. We should create custom sprite sheets for entities. Game.render().entityTextures.forEach(t -> registerIcon(t, event)); } } @@ -195,7 +155,15 @@ public void textureHook(TextureStitchEvent.Post event) { Game.render().entityTextures.forEach(this::updateTexureDimensions); } + /** + * Update the texture dimensions for the given texture. + * @param texture The texture to update. + * @throws RuntimeException If the texture update fails. + * @see PR review + */ private void updateTexureDimensions(Texture texture) { + // NOTE: This is the only way to update the `dimension` field without breaking anything. + // https://github.com/NOVA-Team/NOVA-Core/pull/265#discussion_r103739268 try { Field dimension = Texture.class.getDeclaredField("dimension"); dimension.setAccessible(true); @@ -219,12 +187,14 @@ public void onModelBakeEvent(ModelBakeEvent event) { ResourceLocation itemRL = Item.REGISTRY.getNameForObject(itemFromBlock); ModelResourceLocation blockLocation = new ModelResourceLocation(blockRL, "normal"); ModelResourceLocation itemLocation = new ModelResourceLocation(itemRL, "inventory"); + ItemFactory itemFactory = ((IFWItem)itemFromBlock).getItemFactory(); + nova.core.item.Item dummy = itemFactory.build(); if (block.dummy.components.has(StaticRenderer.class)) { - event.getModelRegistry().putObject(blockLocation, new FWSmartBlockModel(block.dummy, true)); + event.getModelRegistry().putObject(blockLocation, new FWSmartBlockModel(block.dummy)); } else { event.getModelRegistry().putObject(blockLocation, new FWEmptyModel()); } - event.getModelRegistry().putObject(itemLocation, new FWSmartBlockModel(block.dummy, true)); + event.getModelRegistry().putObject(itemLocation, new FWSmartBlockModel(block.dummy, dummy)); } }); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java index 527d58f62..12e36ea68 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/MCLanguageManager.java @@ -20,7 +20,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.util; -import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.common.FMLCommonHandler; import nova.core.language.LanguageManager; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; @@ -40,16 +39,12 @@ public String getCurrentLanguage() { return FMLCommonHandler.instance().getCurrentLanguage().replace('_', '-'); } - /** - * {@inheritDoc} - * @deprecated Removed in Forge 1.9 - */ @Override - @Deprecated + @SuppressWarnings("deprecation") public String translate(String key) { String value = super.translate(key); if (value.equals(key)) - value = I18n.translateToLocal(key); + value = net.minecraft.util.text.translation.I18n.translateToLocal(key); return value; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java index ae0b20b91..bb01a118e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/CategoryConverter.java @@ -40,7 +40,7 @@ public class CategoryConverter implements NativeConverter{ public static CategoryConverter instance() { - return (CategoryConverter) Game.natives().getNative(Category.class, CreativeTabs.class); + return Game.natives().getNative(Category.class, CreativeTabs.class); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java index c6bd88bc8..fb6d208bd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java @@ -8,6 +8,10 @@ import net.minecraft.util.EnumFacing; import nova.core.nativewrapper.NativeConverter; import nova.core.util.Direction; +import nova.internal.core.Game; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * @@ -15,6 +19,10 @@ */ public class DirectionConverter implements NativeConverter { + public static DirectionConverter instance() { + return Game.natives().getNative(Direction.class, EnumFacing.class); + } + @Override public Class getNovaSide() { return Direction.class; @@ -26,7 +34,7 @@ public Class getNativeSide() { } @Override - public Direction toNova(EnumFacing nativeObj) { + public Direction toNova(@Nullable EnumFacing nativeObj) { if (null == nativeObj) return Direction.UNKNOWN; else switch (nativeObj) { @@ -41,6 +49,7 @@ else switch (nativeObj) { } @Override + @Nullable public EnumFacing toNative(Direction novaObj) { switch (novaObj) { case DOWN: return EnumFacing.DOWN; @@ -49,7 +58,7 @@ public EnumFacing toNative(Direction novaObj) { case SOUTH: return EnumFacing.SOUTH; case WEST: return EnumFacing.WEST; case EAST: return EnumFacing.EAST; - default: return (EnumFacing) null; + default: return null; } } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java index 5d336b43a..44880c8dc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java @@ -22,9 +22,15 @@ import net.minecraft.util.math.BlockPos; import nova.core.nativewrapper.NativeConverter; +import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; public class VectorConverter implements NativeConverter { + + public static VectorConverter instance() { + return Game.natives().getNative(Vector3D.class, BlockPos.class); + } + @Override public Class getNovaSide() { return Vector3D.class; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java index ccd2260c9..6c6b3f057 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/AssetConverter.java @@ -32,7 +32,7 @@ public final class AssetConverter implements NativeConverter { public static AssetConverter instance() { - return (AssetConverter) Game.natives().getNative(Asset.class, ResourceLocation.class); + return Game.natives().getNative(Asset.class, ResourceLocation.class); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java index c5fd41dd8..67e6ed296 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFileResourcePack.java @@ -23,16 +23,23 @@ import com.google.common.base.Charsets; import net.minecraft.client.resources.FileResourcePack; import net.minecraft.util.ResourceLocation; +import nova.core.language.LanguageManager; import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader; +import nova.internal.core.Game; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Optional; +import java.util.Properties; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -109,8 +116,22 @@ public boolean resourceExists(ResourceLocation rl) { } @Override - public String getPackName() { - return NovaResourcePack.super.getPackName(); + public Set getLanguageFiles() { + Pattern langPattern = Pattern.compile("^assets/([^/]+)/(lang/[a-zA-Z0-9-]+\\.lang)$", Pattern.CASE_INSENSITIVE); + + try { + return getResourcePackZipFile().stream() + .map(e -> { + Matcher m = langPattern.matcher(e.getName()); + if (!m.matches()) + return null; + return new ResourceLocation(m.group(1), m.group(2)); + }) + .filter(e -> e != null) + .collect(Collectors.toSet()); + } catch (IOException ex) { + return Collections.emptySet(); + } } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java index b6c9d6786..641575e65 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaFolderResourcePack.java @@ -23,6 +23,7 @@ import com.google.common.base.Charsets; import net.minecraft.client.resources.FolderResourcePack; import net.minecraft.util.ResourceLocation; +import nova.core.language.LanguageManager; import nova.core.wrapper.mc.forge.v1_11_2.NovaMinecraftPreloader; import java.io.BufferedInputStream; @@ -34,7 +35,10 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Optional; +import java.util.Properties; import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; public class NovaFolderResourcePack extends FolderResourcePack implements NovaResourcePack { private final String modid; @@ -100,8 +104,20 @@ public boolean resourceExists(ResourceLocation rl) { } @Override - public String getPackName() { - return NovaResourcePack.super.getPackName(); + public Set getLanguageFiles() { + Pattern langPattern = Pattern.compile("^[a-zA-Z0-9-]+\\.lang$", Pattern.CASE_INSENSITIVE); + + Set langFiles = new HashSet<>(); + + for (String domain : getResourceDomains()) { + findFileCaseInsensitive("assets/" + domain + "/lang/").filter(File::isDirectory).ifPresent(file -> { + Arrays.stream(file.listFiles((dir, name) -> langPattern.asPredicate().test(name))) + .map(File::getName) + .forEach(name -> langFiles.add(new ResourceLocation(domain, name))); + }); + } + + return langFiles; } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java index bd0e6fcdb..c655fe851 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/assets/NovaResourcePack.java @@ -20,6 +20,7 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets; +import net.minecraft.client.resources.IResourcePack; import net.minecraft.util.ResourceLocation; import nova.core.util.Identifiable; @@ -27,11 +28,12 @@ import java.io.InputStream; import java.util.LinkedList; import java.util.Optional; +import java.util.Set; /** * @author ExE Boss */ -public interface NovaResourcePack extends Identifiable { +public interface NovaResourcePack extends Identifiable, IResourcePack { default String transform(ResourceLocation rl) { return transform(String.format("assets/%s/%s", rl.getResourceDomain(), toAbsolutePath(rl.getResourcePath()))); @@ -41,10 +43,13 @@ default String transform(String path) { return toAbsolutePath(path.toLowerCase().replace('\\', '/').replaceFirst("^assets/minecraft", "assets/" + getID())); } + @Override default String getPackName() { return getClass().getSimpleName() + ':' + getID(); } + Set getLanguageFiles(); + InputStream getInputStreamCaseInsensitive(String path) throws IOException; Optional findFileCaseInsensitive(String path); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index 049bed661..919e5428a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -56,7 +56,7 @@ public class BlockConverter implements NativeConverter blockFactoryMap = new HashMap<>(); public static BlockConverter instance() { - return (BlockConverter) Game.natives().getNative(Block.class, net.minecraft.block.Block.class); + return Game.natives().getNative(Block.class, net.minecraft.block.Block.class); } @Override @@ -87,7 +87,7 @@ public Block toNova(net.minecraft.block.Block nativeBlock) { public net.minecraft.block.Block toNative(Block novaBlock) { //Prevent recursive wrapping if (novaBlock instanceof BWBlock) { - return ((BWBlock) novaBlock).mcBlock; + return ((BWBlock) novaBlock).block(); } return toNative(novaBlock.getFactory()); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index 9c62b8fd3..89e558790 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -23,6 +23,8 @@ import net.minecraft.block.BlockSnow; import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -30,11 +32,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import nova.core.block.Block; import nova.core.block.component.BlockProperty; import nova.core.block.component.LightEmitter; import nova.core.component.misc.Collider; +import nova.core.component.renderer.StaticRenderer; import nova.core.component.transform.BlockTransform; import nova.core.item.ItemFactory; import nova.core.retention.Data; @@ -44,26 +48,28 @@ import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.BWWorld; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWBakedModel; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; public class BWBlock extends Block implements Storable { - public final net.minecraft.block.Block mcBlock; + private final net.minecraft.block.Block block; @Store - public int metadata; private TileEntity mcTileEntity; public BWBlock(net.minecraft.block.Block block) { - this.mcBlock = block; + this.block = block; } + @SuppressWarnings("deprecation") public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { - this.mcBlock = block; + this.block = block; BlockTransform transform = components.add(new BlockTransform()); transform.setWorld(world); @@ -73,33 +79,36 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); SoundType soundType; - if (getMcBlockAccess() instanceof net.minecraft.world.World) - soundType = mcBlock.getSoundType(blockState(), (net.minecraft.world.World)getMcBlockAccess(), new BlockPos(x(), y(), z()), null); + if (blockAccess() instanceof net.minecraft.world.World) + soundType = block.getSoundType(blockState(), (net.minecraft.world.World)blockAccess(), blockPos(), null); else - soundType = mcBlock.getSoundType(); + soundType = block.getSoundType(); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, - new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), - soundType.getPlaceSound().getSoundName().getResourcePath())); + if (soundType.getPlaceSound() != null) + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, + new Sound(soundType.getPlaceSound().getSoundName().getResourceDomain(), + soundType.getPlaceSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, - new Sound(soundType.getBreakSound().getSoundName().getResourceDomain(), - soundType.getBreakSound().getSoundName().getResourcePath())); + if (soundType.getBreakSound() != null) + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, + new Sound(soundType.getBreakSound().getSoundName().getResourceDomain(), + soundType.getBreakSound().getSoundName().getResourcePath())); - blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, - new Sound(soundType.getStepSound().getSoundName().getResourceDomain(), - soundType.getStepSound().getSoundName().getResourcePath())); + if (soundType.getStepSound() != null) + blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, + new Sound(soundType.getStepSound().getSoundName().getResourceDomain(), + soundType.getStepSound().getSoundName().getResourcePath())); - components.add(new LightEmitter()).setEmittedLevel(() -> blockState().getLightValue(getMcBlockAccess(), new BlockPos(x(), y(), z())) / 15.0F); + components.add(new LightEmitter()).setEmittedLevel(() -> blockState().getLightValue(blockAccess(), blockPos()) / 15d); components.add(new Collider(this)) .setBoundingBox(() -> { - AxisAlignedBB aabb = blockState().getBoundingBox(getMcBlockAccess(), new BlockPos(x(), y(), z())); + AxisAlignedBB aabb = blockState().getBoundingBox(blockAccess(), blockPos()); return new Cuboid(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); }).setOcclusionBoxes(entity -> { List aabbs = new ArrayList<>(); blockState().addCollisionBoxToList( Game.natives().toNative(world()), - new BlockPos(x(), y(), z()), + blockPos(), Game.natives().toNative(entity.isPresent() ? entity.get().components.get(Collider.class).boundingBox.get() : Cuboid.ONE.add(pos)), aabbs, entity.isPresent() ? Game.natives().toNative(entity.get()) : null, @@ -109,44 +118,93 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { .map(aabb -> (Cuboid) Game.natives().toNova(aabb)) .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); + }).setSelectionBoxes(entity -> { + AxisAlignedBB bb; + if (blockAccess() instanceof net.minecraft.world.World) { + @SuppressWarnings("deprecation") + AxisAlignedBB bb1 = block.getSelectedBoundingBox(blockState(), ((net.minecraft.world.World) blockAccess()), blockPos()); + bb = bb1; + } else { + bb = blockState().getBoundingBox(blockAccess(), blockPos()).offset(blockPos()); + } + Cuboid cuboid = Game.natives().toNova(bb); + return Collections.singleton(cuboid.subtract(position())); }); - WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); - Game.events().publish(event); //TODO: Set selection bounds + components.add(new StaticRenderer()) + .onRender(model -> { + switch (blockState().getRenderType()) { + case INVISIBLE: + // rendering of invisible type + break; + case LIQUID: + // fluid rendering + // TODO + break; + case ENTITYBLOCK_ANIMATED: + // dynamic block rendering + // Handled by DynamicRenderer + break; + case MODEL: + // model rendering + model.addChild(new BWBakedModel(Minecraft.getMinecraft().getBlockRendererDispatcher() + .getModelForState(blockState()), DefaultVertexFormats.BLOCK, + Optional.of(blockState()), MathHelper.getPositionRandom(blockPos()))); + break; + default: + break; + } + }); + // TODO: TileEntity rendering using DynamicRenderer + + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, block); + Game.events().publish(event); } @Override public ItemFactory getItemFactory() { - return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(mcBlock))); + return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(block))); + } + + public net.minecraft.block.Block block() { + return block; } - public IBlockAccess getMcBlockAccess() { - return ((BWWorld) world()).access; + public int meta() { + return block.getMetaFromState(blockState()); + } + + public BlockPos blockPos() { + return new BlockPos(x(), y(), z()); + } + + public IBlockAccess blockAccess() { + return Game.natives().toNative(world()); } public IBlockState blockState() { - return getMcBlockAccess().getBlockState(new BlockPos(x(), y(), z())); + return blockAccess().getBlockState(blockPos()); } - public TileEntity getTileEntity() { - if (mcTileEntity == null && mcBlock.hasTileEntity(blockState())) { - mcTileEntity = getMcBlockAccess().getTileEntity(new BlockPos(x(), y(), z())); + public Optional tile() { + if (mcTileEntity == null && block.hasTileEntity(blockState())) { + mcTileEntity = blockAccess().getTileEntity(blockPos()); } - return mcTileEntity; + return Optional.ofNullable(mcTileEntity); } @Override public boolean canReplace() { - return mcBlock.canPlaceBlockAt((net.minecraft.world.World) getMcBlockAccess(), new BlockPos(x(), y(), z())); + return block.canPlaceBlockAt((net.minecraft.world.World) blockAccess(), blockPos()); } @Override public boolean shouldDisplacePlacement() { - if (mcBlock == Blocks.SNOW_LAYER && ((int) blockState().getValue(BlockSnow.LAYERS) < 1)) { + if (block == Blocks.SNOW_LAYER && (blockState().getValue(BlockSnow.LAYERS) < 1)) { return false; } - if (mcBlock == Blocks.VINE || mcBlock == Blocks.TALLGRASS || mcBlock == Blocks.DEADBUSH || mcBlock.isReplaceable(Game.natives().toNative(world()), new BlockPos(x(), y(), z()))) { + if (block == Blocks.VINE || block == Blocks.TALLGRASS || block == Blocks.DEADBUSH || block.isReplaceable(blockAccess(), blockPos())) { return false; } return super.shouldDisplacePlacement(); @@ -156,21 +214,34 @@ public boolean shouldDisplacePlacement() { public void save(Data data) { Storable.super.save(data); - TileEntity tileEntity = getTileEntity(); - if (tileEntity != null) { + tile().ifPresent(tile -> { NBTTagCompound nbt = new NBTTagCompound(); - tileEntity.writeToNBT(nbt); + tile.writeToNBT(nbt); data.putAll(Game.natives().toNova(nbt)); - } + }); } @Override public void load(Data data) { Storable.super.load(data); - TileEntity tileEntity = getTileEntity(); - if (tileEntity != null) { - tileEntity.writeToNBT(Game.natives().toNative(data)); - } + tile().ifPresent(tile -> { + tile.readFromNBT(Game.natives().toNative(data)); + }); + } + + @Override + public String getLocalizedName() { + return block.getLocalizedName(); + } + + @Override + public String getUnlocalizedName() { + return block.getUnlocalizedName(); + } + + @Override + public String toString() { + return getID() + '(' + world() + '@' + x() + ',' + y() + ',' + z() + ')'; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index 538429691..c1e8c8faf 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -49,8 +49,10 @@ import nova.core.sound.Sound; import nova.core.util.Direction; import nova.core.util.math.MathUtil; +import nova.core.util.math.Vector3DUtil; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -73,6 +75,9 @@ public class FWBlock extends net.minecraft.block.Block { */ private final BlockFactory factory; private final Class blockClass; + //TODO: Hack. Bad practice. + public IBlockAccess lastExtendedWorld; + public BlockPos lastExtendedStatePos; private Map harvestedBlocks = new HashMap<>(); private static Material getMcMaterial(BlockFactory factory) { @@ -96,9 +101,9 @@ public FWBlock(BlockFactory factory) { this.blockSoundType = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class)); } else { BlockProperty.BlockSound properties = dummy.components.add(new BlockProperty.BlockSound()); - properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); - properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", SoundType.STONE.getPlaceSound().getSoundName().getResourcePath())); - properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", SoundType.STONE.getStepSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound(SoundType.STONE.getBreakSound().getSoundName().getResourceDomain(), SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound(SoundType.STONE.getPlaceSound().getSoundName().getResourceDomain(), SoundType.STONE.getPlaceSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound(SoundType.STONE.getStepSound().getSoundName().getResourceDomain(), SoundType.STONE.getStepSound().getSoundName().getResourcePath())); this.blockSoundType = SoundType.STONE; } this.blockClass = dummy.getClass(); @@ -186,14 +191,32 @@ public boolean hasTileEntity(IBlockState state) { @Override public TileEntity createTileEntity(World world, IBlockState state) { - return FWTileLoader.loadTile(dummy.getID()); + FWTile fwTile = FWTileLoader.loadTile(dummy.getID()); + if (lastExtendedStatePos != null) { + fwTile.getBlock().components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ()))); + lastExtendedStatePos = null; + } + if (!fwTile.getBlock().components.has(BlockProperty.BlockSound.class)) { + BlockProperty.BlockSound properties = fwTile.getBlock().components.add(new BlockProperty.BlockSound()); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound(SoundType.STONE.getBreakSound().getSoundName().getResourceDomain(), SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound(SoundType.STONE.getPlaceSound().getSoundName().getResourceDomain(), SoundType.STONE.getPlaceSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound(SoundType.STONE.getStepSound().getSoundName().getResourceDomain(), SoundType.STONE.getStepSound().getSoundName().getResourcePath())); + } + return fwTile; + } + + @Override + public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { + lastExtendedWorld = world; + lastExtendedStatePos = pos; + return super.getExtendedState(state, world, pos); } @Override - public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighborBlock) { + public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - // Minecraft does not provide the neighbor :( - Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.empty()); + Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent( + Optional.of(VectorConverter.instance().toNova(neighbor))); blockInstance.events.publish(evt); } @@ -247,7 +270,10 @@ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, Bloc Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); if (blockInstance.components.has(Collider.class)) { - Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get(); + Collider collider = blockInstance.components.get(Collider.class); + Set cuboids = collider.selectionBoxes.apply(Optional.empty()); + Cuboid cuboid = cuboids.stream().reduce(collider.boundingBox.get(), + (c1, c2) -> new Cuboid(Vector3DUtil.min(c1.min, c2.min), Vector3DUtil.max(c1.max, c2.max))); return Game.natives().toNative(cuboid.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); } return super.getSelectedBoundingBox(state, world, pos); @@ -358,7 +384,12 @@ public int getStrongPower(IBlockState state, IBlockAccess access, BlockPos pos, @Override public String getUnlocalizedName() { - return super.getUnlocalizedName().replaceFirst("tile", "block"); + return factory.getUnlocalizedName(); + } + + @Override + public String getLocalizedName() { + return factory.getLocalizedName(); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index d2bb46e56..3ac182b4b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -110,9 +110,9 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { if (block != null) { if (block instanceof Storable) { - Data data = new Data(); - ((Storable) block).save(data); - nbt.setTag("nova", Game.natives().toNative(data)); + Data data = new Data(); + ((Storable) block).save(data); + nbt.setTag("nova", Game.natives().toNative(data)); } } @@ -162,9 +162,9 @@ public T getCapability(Capability capability, EnumFacing facing) { @Override public void setPos(BlockPos pos) { super.setPos(pos); - if (this.block.components.has(MCBlockTransform.class)) - this.block.components.remove(MCBlockTransform.class); - this.block.components.add(new MCBlockTransform(this.block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); + if (block.components.has(MCBlockTransform.class)) + block.components.remove(MCBlockTransform.class); + block.components.add(new MCBlockTransform(block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); } private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java index 9a6331749..0d141fb28 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java @@ -42,7 +42,7 @@ public class FWTileRenderer extends TileEntitySpecialRenderer { public static final FWTileRenderer instance = new FWTileRenderer(); @Override - public void renderTileEntityAt(FWTile te, double x, double y, double z, float p_180535_8_, int p_180535_9_) { + public void renderTileEntityAt(FWTile te, double x, double y, double z, float partialTicks, int destroyStage) { Block block = te.getBlock(); Optional opRenderer = block.components.getOp(DynamicRenderer.class); if (opRenderer.isPresent()) { @@ -52,7 +52,7 @@ public void renderTileEntityAt(FWTile te, double x, double y, double z, float p_ bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); RenderUtility.enableBlending(); Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); - model.render(); + model.render(te.getWorld()); Tessellator.getInstance().draw(); RenderUtility.disableBlending(); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java index 43d189e12..112d778cd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileUpdater.java @@ -28,7 +28,6 @@ */ public class FWTileUpdater extends FWTile implements ITickable { public FWTileUpdater() { - } public FWTileUpdater(String blockID) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java index a4e70edb5..39c846414 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/WorldConverter.java @@ -31,6 +31,11 @@ * @author Calclavia */ public class WorldConverter implements NativeConverter { + + public static WorldConverter instance() { + return Game.natives().getNative(World.class, IBlockAccess.class); + } + @Override public Class getNovaSide() { return World.class; @@ -56,10 +61,9 @@ public World toNova(IBlockAccess nativeObj) { @Override public IBlockAccess toNative(World novaObj) { if (novaObj instanceof BWWorld) { - return ((BWWorld) novaObj).world(); + return ((BWWorld) novaObj).access; } - //TODO: Right exception? - throw new RuntimeException("Attempt to convert a world that is not a BWWorld!"); + throw new UnsupportedOperationException("Attempt to convert a world that is not a BWWorld!"); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java index 888fb1100..864a99fc7 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/cuboid/CuboidConverter.java @@ -23,12 +23,18 @@ import net.minecraft.util.math.AxisAlignedBB; import nova.core.nativewrapper.NativeConverter; import nova.core.util.shape.Cuboid; +import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; /** * @author Calclavia */ public class CuboidConverter implements NativeConverter { + + public static CuboidConverter instance() { + return Game.natives().getNative(Cuboid.class, AxisAlignedBB.class); + } + @Override public Class getNovaSide() { return Cuboid.class; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java similarity index 96% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java index d5cfc932c..8e4a55ace 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataWrapper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java @@ -41,10 +41,10 @@ * Utility that manages common NBT queueSave and load methods * @author Calclavia */ -public class DataWrapper implements NativeConverter { +public class DataConverter implements NativeConverter { - public static DataWrapper instance() { - return (DataWrapper) Game.natives().getNative(Data.class, NBTTagCompound.class); + public static DataConverter instance() { + return Game.natives().getNative(Data.class, NBTTagCompound.class); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java index 5eb83db59..a08eac203 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/EntityConverter.java @@ -38,6 +38,10 @@ public class EntityConverter implements NativeConverter, ForgeLoadable { + public static EntityConverter instance() { + return Game.natives().getNative(Entity.class, net.minecraft.entity.Entity.class); + } + @Override public Class getNovaSide() { return Entity.class; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java index 9cd31e4fb..756b6feb5 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java @@ -45,18 +45,17 @@ public class BWEntity extends Entity { public BWEntity(net.minecraft.entity.Entity entity) { this.entity = entity; - if (entity != null) { - components.add(new MCEntityTransform(entity)); - components.add(new Damageable() { - @Override - public void damage(double amount, DamageType type) { - if (type == DamageType.generic) { - entity.attackEntityFrom(DamageSource.GENERIC, (float) amount); - } - // TODO: Apply other damage source wrappers? + + components.add(new MCEntityTransform(entity)); + components.add(new Damageable() { + @Override + public void damage(double amount, DamageType type) { + if (type == DamageType.generic) { + entity.attackEntityFrom(DamageSource.GENERIC, (float) amount); } - }); - } + // TODO: Apply other damage source wrappers? + } + }); if (entity instanceof EntityLivingBase) { if (entity instanceof EntityPlayer) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index c4bf2890c..971e65d27 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -37,7 +37,7 @@ import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; -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.internal.core.Game; import java.util.HashMap; @@ -83,7 +83,7 @@ protected void writeEntityToNBT(NBTTagCompound nbt) { if (wrapped instanceof Storable) { Data data = new Data(); ((Storable) wrapped).save(data); - DataWrapper.instance().toNative(nbt, data); + DataConverter.instance().toNative(nbt, data); } nbt.setString("novaID", wrapped.getID()); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java index 08d82c8e5..f53814f64 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/InventoryConverter.java @@ -23,11 +23,17 @@ import net.minecraft.inventory.IInventory; import nova.core.component.inventory.Inventory; import nova.core.nativewrapper.NativeConverter; +import nova.internal.core.Game; /** * @author Calclavia */ public class InventoryConverter implements NativeConverter { + + public static InventoryConverter instance() { + return Game.natives().getNative(Inventory.class, IInventory.class); + } + @Override public Class getNovaSide() { return Inventory.class; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index f07912db7..6dca71931 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -60,7 +60,7 @@ public class ItemConverter implements NativeConverter, ForgeLoa private final HashBiMap map = HashBiMap.create(); public static ItemConverter instance() { - return (ItemConverter) Game.natives().getNative(Item.class, ItemStack.class); + return Game.natives().getNative(Item.class, ItemStack.class); } @Override @@ -78,8 +78,6 @@ public Item toNova(ItemStack itemStack) { return getNovaItem(itemStack).setCount(itemStack.getCount()); } - //TODO: Why is this method separate? - // Maybe because toNova calls setCount on the result of this method? public Item getNovaItem(ItemStack itemStack) { if (itemStack.getItemDamage() == net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE) { // TODO: Deal withPriority wildcard meta values - important for the ore dictionary @@ -87,7 +85,7 @@ public Item getNovaItem(ItemStack itemStack) { } if (itemStack.getTagCompound() != null && itemStack.getTagCompound() instanceof FWNBTTagCompound) { - return ((FWNBTTagCompound) itemStack.getTagCompound()).getItem(); + return Objects.requireNonNull((FWNBTTagCompound) itemStack.getTagCompound()).getItem(); } else { ItemFactory itemFactory = registerMinecraftMapping(itemStack.getItem(), itemStack.getItemDamage()); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java index a2a288c92..8a2c823cf 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java @@ -21,7 +21,10 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.oredict.OreDictionary; +import nova.core.event.DictionaryEvent; import nova.core.item.Item; import nova.core.item.ItemDictionary; import nova.core.util.Dictionary; @@ -29,7 +32,9 @@ import nova.internal.core.Game; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Optional; /** * Created by Stan on 8/02/2015. @@ -44,44 +49,48 @@ private OreDictionaryIntegration() { public void registerOreDictionary() { ItemDictionary novaItemDictionary = Game.itemDictionary(); - for (String oredictEntry : novaItemDictionary.keys()) { - for (Item oreValue : novaItemDictionary.get(oredictEntry)) { - OreDictionary.registerOre(oredictEntry, ItemConverter.instance().toNative(oreValue)); - } - } + novaItemDictionary.stream().forEach(entry -> { + entry.getValue().stream() + .map(ItemConverter.instance()::toNative) + .filter(item -> !OreDictionary.getOres(entry.getKey()).contains(item)) + .forEach(item -> OreDictionary.registerOre(entry.getKey(), item)); + }); - for (String oredictEntry : OreDictionary.getOreNames()) { - for (ItemStack oreValue : OreDictionary.getOres(oredictEntry)) { - Item novaItem = ItemConverter.instance().getNovaItem(oreValue); - if (!novaItemDictionary.get(oredictEntry).contains(novaItem)) { - novaItemDictionary.add(oredictEntry, novaItem); - } - } - } + Arrays.stream(OreDictionary.getOreNames()).forEach(key -> { + OreDictionary.getOres(key).stream() + .map(ItemConverter.instance()::getNovaItem) + .filter(item -> !novaItemDictionary.get(key).contains(item)) + .forEach(item -> novaItemDictionary.add(key, item)); + }); - novaItemDictionary.whenEntryAdded(this::onEntryAdded); - novaItemDictionary.whenEntryRemoved(this::onEntryRemoved); + novaItemDictionary.whenEntryAdded(this::onNovaAdded); + novaItemDictionary.whenEntryRemoved(this::onNovaRemoved); + MinecraftForge.EVENT_BUS.register(this); } - private void onEntryAdded(Dictionary.AddEvent event) { - ItemStack nativeValue = ItemConverter.instance().toNative(event.value); - if (!OreDictionary.getOres(event.key).contains(nativeValue)) { - OreDictionary.registerOre(event.key, nativeValue); + private void onNovaAdded(DictionaryEvent.Add event) { + ItemStack nativeStack = ItemConverter.instance().toNative(event.value); + if (!OreDictionary.getOres(event.key).stream().anyMatch(stack -> stack.isItemEqual(nativeStack))) { + OreDictionary.registerOre(event.key, nativeStack); } } - private void onEntryRemoved(Dictionary.RemoveEvent event) { + private void onNovaRemoved(DictionaryEvent.Remove event) { int id = OreDictionary.getOreID(event.key); - ItemStack itemStack = ItemConverter.instance().toNative(event.value); - ItemStack toRemove = null; - for (ItemStack oreDictItemStack : OreDictionary.getOres(event.key)) { - if (oreDictItemStack.getItem() == itemStack.getItem() && toRemove.getItemDamage() == oreDictItemStack.getItemDamage()) { - toRemove = oreDictItemStack; - } + ItemStack nativeStack = ItemConverter.instance().toNative(event.value); + Optional toRemove = OreDictionary.getOres(event.key).stream().filter(stack -> stack.isItemEqual(nativeStack)).findFirst(); + + if (toRemove.isPresent()) { + OREDICT_CONTENTS.get(id).remove(toRemove.get()); } + } - if (toRemove != null) { - OREDICT_CONTENTS.get(id).remove(toRemove); + @SubscribeEvent + public void onForgeAdded(OreDictionary.OreRegisterEvent event) { + Item novaItem = ItemConverter.instance().getNovaItem(event.getOre()); + ItemDictionary novaItemDictionary = Game.itemDictionary(); + if (!novaItemDictionary.get(event.getName()).contains(novaItem)) { + novaItemDictionary.add(event.getName(), novaItem); } } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java index b0d0eca3f..f1403e7e7 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java @@ -20,10 +20,13 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward; +import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; import nova.core.retention.Storable; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWBakedModel; /** * @author Stan @@ -42,6 +45,12 @@ public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag) { this.item = item; this.meta = meta; this.tag = tag; + + components.add(new StaticRenderer()) + .onRender(model -> { + model.addChild(new BWBakedModel(Minecraft.getMinecraft().getRenderItem() + .getItemModelMesher().getItemModel(makeItemStack(count())))); + }); } public net.minecraft.item.Item getItem() { @@ -64,6 +73,16 @@ public ItemStack makeItemStack(int stackSize) { return result; } + @Override + public String getLocalizedName() { + return this.item.getItemStackDisplayName(makeItemStack(count())); + } + + @Override + public String getUnlocalizedName() { + return this.item.getUnlocalizedName(makeItemStack(count())); + } + @Override public String toString() { return getID(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java index 74535afa6..935587385 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java @@ -52,6 +52,11 @@ public int getMeta() { return meta; } + @Override + public String getUnlocalizedName() { + return this.item.getUnlocalizedName(); + } + @Override public Item build(Data data) { int meta = (Integer) data.getOrDefault("damage", this.meta); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index 486f275a0..540e75daf 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -20,7 +20,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -34,18 +33,16 @@ import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import java.util.List; - -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemWrapperMethods; -import nova.internal.core.Game; - import javax.annotation.Nullable; /** * @author Calclavia */ -public class FWItem extends net.minecraft.item.Item implements ItemWrapperMethods { +public class FWItem extends net.minecraft.item.Item implements IFWItem { public final ItemFactory itemFactory; @@ -58,7 +55,7 @@ public FWItem(ItemFactory item) { @Override @Nullable public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { - Item item = Game.natives().toNova(stack); + Item item = ItemConverter.instance().toNova(stack); WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; } @@ -70,22 +67,36 @@ public ItemFactory getItemFactory() { @Override public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { - ItemWrapperMethods.super.addInformation(itemStack, player, tooltip, advanced); + IFWItem.super.addInformation(itemStack, player, tooltip, advanced); } @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - return ItemWrapperMethods.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); + return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); + } + + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); + } + + @Override + public int getColorFromItemStack(ItemStack itemStack, int renderPass) { + return IFWItem.super.getColorFromItemStack(itemStack, renderPass); } @Override - public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { - return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); + public String getUnlocalizedName() { + return getItemFactory().getUnlocalizedName(); } @Override - public int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { - return ItemWrapperMethods.super.getColorFromItemStack(itemStack, p_82790_2_); + public String getUnlocalizedName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getUnlocalizedName(); } + @Override + public String getItemStackDisplayName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getLocalizedName(); + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index 685af5f22..b6f67c454 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -35,7 +35,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemWrapperMethods; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import java.util.List; @@ -43,7 +43,7 @@ /** * @author Calclavia */ -public class FWItemBlock extends net.minecraft.item.ItemBlock implements ItemWrapperMethods { +public class FWItemBlock extends net.minecraft.item.ItemBlock implements IFWItem { public FWItemBlock(FWBlock block) { super(block); @@ -63,21 +63,36 @@ public ItemFactory getItemFactory() { @Override public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { - ItemWrapperMethods.super.addInformation(itemStack, player, tooltip, advanced); + IFWItem.super.addInformation(itemStack, player, tooltip, advanced); } @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - return ItemWrapperMethods.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); + return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ); } @Override - public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { - return ItemWrapperMethods.super.onItemRightClick(itemStack, world, player); + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); } @Override - public int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { - return ItemWrapperMethods.super.getColorFromItemStack(itemStack, p_82790_2_); + public int getColorFromItemStack(ItemStack itemStack, int renderPass) { + return IFWItem.super.getColorFromItemStack(itemStack, renderPass); + } + + @Override + public String getUnlocalizedName() { + return getItemFactory().getUnlocalizedName(); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getUnlocalizedName(); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getLocalizedName(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java similarity index 79% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java index d2753bb14..8ab3a50d5 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemWrapperMethods.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -29,28 +29,28 @@ import nova.core.item.ItemFactory; import nova.core.util.Direction; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; -import nova.internal.core.Game; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.List; import java.util.Optional; /** - * An interface implemented by ItemBlockWrapper and ItemWrapper classes to override Minecraft's item events. + * An interface implemented by {@link FWItem} and {@link FWItemBlock} classes to override Minecraft's item events. * @author Calclavia */ -public interface ItemWrapperMethods { +public interface IFWItem { ItemFactory getItemFactory(); default void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { - Item item = Game.natives().toNova(itemStack); + Item item = ItemConverter.instance().toNova(itemStack); item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), tooltip)); getItemFactory().save(item); } default EnumActionResult onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - Item item = Game.natives().toNova(itemStack); + Item item = ItemConverter.instance().toNova(itemStack); Item.UseEvent event = new Item.UseEvent(new BWEntity(player), new Vector3D(x, y, z), Direction.fromOrdinal(side), new Vector3D(hitX, hitY, hitZ)); item.events.publish(event); ItemConverter.instance().updateMCItemStack(itemStack, item); @@ -58,12 +58,13 @@ default EnumActionResult onItemUse(ItemStack itemStack, EntityPlayer player, Wor } default ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { - Item item = Game.natives().toNova(itemStack); + Item item = ItemConverter.instance().toNova(itemStack); item.events.publish(new Item.RightClickEvent(new BWEntity(player))); return new ActionResult<>(EnumActionResult.PASS, ItemConverter.instance().updateMCItemStack(itemStack, item)); } - default int getColorFromItemStack(ItemStack itemStack, int p_82790_2_) { - return ((Item) Game.natives().toNova(itemStack)).colorMultiplier().argb(); + @SuppressWarnings("deprecation") + default int getColorFromItemStack(ItemStack itemStack, int renderPass) { + return ItemConverter.instance().toNova(itemStack).colorMultiplier().argb(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java index 59673bbe1..d3aac2bcc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/backward/BWParticle.java @@ -61,13 +61,11 @@ import net.minecraft.client.particle.ParticleWaterWake; import net.minecraft.util.EnumParticleTypes; import net.minecraftforge.fml.client.FMLClientHandler; +import nova.core.entity.Entity; import java.util.HashMap; import java.util.Map; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.particle.forward.MCParticleTransform; - /** * A backward entity particle that acts as a black box, which wraps a Minecraft particle. * @@ -75,7 +73,7 @@ * * @author Calclavia */ -public class BWParticle extends BWEntity { +public class BWParticle extends Entity { public static final HashBiMap> FX_CLASS_MAP = HashBiMap.create(); public static final Map FX_FACTORY_MAP = new HashMap<>(); @@ -184,8 +182,6 @@ public class BWParticle extends BWEntity { private final int particleID; public BWParticle(int particleID) { - //TODO: NPE - super(null); this.particleID = particleID; } @@ -193,9 +189,6 @@ public Particle createParticle(net.minecraft.world.World world) { //Look up for particle factory and pass it into BWParticle IParticleFactory particleFactory = FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID); Particle particle = particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0); - if (components.has(MCParticleTransform.class)) - components.remove(MCParticleTransform.class); - components.add(new MCParticleTransform(particle)); return particle; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java new file mode 100644 index 000000000..53bc4c632 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import nova.core.render.Color; +import nova.core.render.model.Face; +import nova.core.render.model.MeshModel; +import nova.core.render.model.Model; +import nova.core.render.model.Vertex; +import nova.core.util.Direction; +import nova.core.util.math.MatrixStack; +import nova.core.util.math.TransformUtil; +import nova.core.util.math.Vector3DUtil; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math3.linear.LUDecomposition; +import org.apache.commons.math3.linear.MatrixUtils; +import org.apache.commons.math3.linear.RealMatrix; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.Nullable; + +/** + * @author ExE Boss + */ +public class BWBakedModel extends MeshModel { + + @SuppressWarnings("deprecation") + public final IBakedModel wrapped; + + public final VertexFormat format; + + public final Optional blockState; + + public final long rand; + + public BWBakedModel(IBakedModel wrapped) { + this(wrapped, DefaultVertexFormats.ITEM); + } + + public BWBakedModel(IBakedModel wrapped, VertexFormat format) { + this(wrapped, format, Optional.empty(), 0); + } + + public BWBakedModel(IBakedModel wrapped, VertexFormat format, Optional state, long rand) { + this.wrapped = wrapped; + this.format = format; + this.matrix.translate(-0.5, -0.5, -0.5); + this.blockState = state; + this.rand = rand; + + if (!format.getElements().stream().anyMatch(VertexFormatElement::isPositionElement)) + return; // VertexFormat doesn't have a position + + Arrays.stream(Direction.values()) + .map(this::getQuads) + .flatMap(Collection::stream) + .map(this::quadToFace) + .forEachOrdered(faces::add); + } + + @Override + public Set flatten(MatrixStack matrixStack) { + Set models = new HashSet<>(); + + matrixStack.pushMatrix(); + matrixStack.transform(matrix.getMatrix()); + //Create a new model with transformation applied. + MeshModel transformedModel = clone(); + // correct formula for Normal Matrix is transpose(inverse(mat3(model_mat)) + // we have to augemnt that to 4x4 + RealMatrix normalMatrix3x3 = new LUDecomposition(matrixStack.getMatrix().getSubMatrix(0, 2, 0, 2), 1e-5).getSolver().getInverse().transpose(); + RealMatrix normalMatrix = MatrixUtils.createRealMatrix(4, 4); + normalMatrix.setSubMatrix(normalMatrix3x3.getData(), 0, 0); + normalMatrix.setEntry(3, 3, 1); + + transformedModel.faces.stream().forEach(f -> { + f.normal = TransformUtil.transform(f.normal, normalMatrix); + f.vertices.forEach(v -> v.vec = matrixStack.apply(v.vec)); + } + ); + + models.add(transformedModel); + //Flatten child models + matrixStack.pushMatrix(); + matrixStack.translate(0.5, 0.5, 0.5); + models.addAll(children.stream().flatMap(m -> m.flatten(matrixStack).stream()).collect(Collectors.toSet())); + matrixStack.popMatrix().popMatrix(); + return models; + } + + public List getQuads(Direction side) { + return getQuads(DirectionConverter.instance().toNative(side)); + } + + public List getQuads(@Nullable EnumFacing side) { + return wrapped.getQuads(blockState.orElse(null), side, rand); + } + + public Face quadToFace(BakedQuad quad) { + Face face = new Face(); + final VertexFormat format = quad.getFormat(); + + int[] data = quad.getVertexData(); + Optional texture = Optional.ofNullable(quad.getSprite() == null ? wrapped.getParticleTexture() : quad.getSprite()); + + final Optional posElement = ((Collection)format.getElements()).stream() + .filter(VertexFormatElement::isPositionElement) + .findFirst(); + + final Optional uvElement = ((Collection)format.getElements()).stream() + .filter(vfe -> vfe.getUsage() == VertexFormatElement.EnumUsage.UV) + .findFirst(); + + face.texture = texture + .filter(t -> uvElement.isPresent()) + .map(TextureAtlasSprite::getIconName) + .map(ResourceLocation::new) + .map(AssetConverter.instance()::toNovaTexture); + + // `VertexFormat` offsets are for a `ByteBuffer` + // `data` is an int array, so we convert it + + // TODO: support offsets which are not divisible by four + final int posOffset = posElement.map(VertexFormatElement::getIndex).map(i -> i / 4).orElse(-1); + final int uvOffset = uvElement.map(VertexFormatElement::getIndex).map(i -> i / 4).orElse(-1); + final int colorOffset = format.hasColor() ? (format.getColorOffset() / 4) : -1; + final int normalOffset = format.hasNormal() ? (format.getNormalOffset() / 4) : -1; + + for (int i = 0; i < data.length; i += 7) { + Vector3D pos = posElement.isPresent() ? new Vector3D( + Float.intBitsToFloat(data[i + posOffset]), + Float.intBitsToFloat(data[i + posOffset + 1]), + Float.intBitsToFloat(data[i + posOffset + 2])) : Vector3D.ZERO; + + Vector2D uv = uvElement.isPresent() ? new Vector2D( + deinterpolateU(Float.intBitsToFloat(data[i + uvOffset]), texture), + deinterpolateV(Float.intBitsToFloat(data[i + uvOffset + 1]), texture)) : Vector2D.ZERO; + + Vertex vertex = new Vertex(pos, uv); + if (format.hasColor()) { + vertex.color = Color.argb(data[i + colorOffset]); + } + + Optional normal = Optional.empty(); + if (format.hasNormal()) { + int mergedNormal = data[i + normalOffset]; + if (mergedNormal != 0) + normal = Optional.of(new Vector3D(((byte)(mergedNormal & 0xFF)) / 127D, + ((byte)((mergedNormal >> 8) & 0xFF)) / 127D, + ((byte)((mergedNormal >> 16) & 0xFF)) / 127D)); + } + +// if (format.hasNormal()) +// vertex.normal = normal; + face.drawVertex(vertex); + } + java.util.function.BinaryOperator cartesianProduct = Vector3DUtil::cartesianProduct; +// face.normal = Vector3DUtil.calculateNormal(face); + face.normal = calculateNormal(face); + return face; + } + + private double deinterpolateU(double u, Optional texture) { + return u; + } + + private double deinterpolateV(double v, Optional texture) { + return 1 - v; // Why do you change the format with every version, Mojang? + } + + private static Vector3D calculateNormal(Face face) { + // TODO: Possibly calculate from vertex normals + Vertex firstEntry = face.vertices.get(0); + Vertex secondEntry = face.vertices.get(1); + Vertex thirdEntry = face.vertices.get(2); + Vector3D v1 = secondEntry.vec.subtract(firstEntry.vec); + Vector3D v2 = thirdEntry.vec.subtract(firstEntry.vec); + + return v1.crossProduct(v2).normalize(); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java index a55769f9c..b85657b67 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java @@ -20,19 +20,31 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; import nova.core.render.model.CustomModel; import nova.core.render.model.MeshModel; import nova.core.render.texture.EntityTexture; import nova.core.render.texture.Texture; +import nova.core.util.math.Vector3DUtil; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; import java.util.Optional; +import javax.annotation.Nonnull; + /** * BWModel for dynamic rendering * @author Calclavia @@ -43,7 +55,15 @@ public void render() { render(Optional.empty()); } + public void render(@Nonnull IBlockAccess access) { + render(Optional.of(access), Optional.empty()); + } + public void render(Optional entityRenderManager) { + render(Optional.empty(), entityRenderManager); + } + + public void render(Optional access, Optional entityRenderManager) { Tessellator tessellator = Tessellator.getInstance(); VertexBuffer worldRenderer = tessellator.getBuffer(); worldRenderer.color(1F, 1F, 1F, 1F); @@ -56,56 +76,71 @@ public void render(Optional entityRenderManager) { if (model instanceof MeshModel) { MeshModel meshModel = (MeshModel) model; meshModel.faces.forEach(face -> { - // TODO: See if this works, and possibly fix it - // Brightness is defined as: skyLight << 20 | blockLight << 4 - if (face.getBrightness() >= 0) { - worldRenderer.lightmap((int)(face.getBrightness() * (15 << 20)), (int)(face.getBrightness() * (11 << 4))); - //worldRenderer.setBrightness((int) (face.getBrightness() * (15 << 20 | 11 << 4))); - } else { - // Determine nearest adjacent block. - worldRenderer.lightmap(15 << 20, 11 << 4); - //worldRenderer.setBrightness(15 << 20 | 11 << 4); + boolean isEntityTexture = face.texture.map(t -> t instanceof EntityTexture).orElse(false); + if (entityRenderManager.isPresent() && isEntityTexture) { + entityRenderManager.get().renderEngine.bindTexture(AssetConverter.instance().toNative(face.texture.get())); } - worldRenderer.normal((float) face.normal.getX(), (float) face.normal.getY(), (float) face.normal.getZ()); - - System.out.println(face.texture); - if (face.texture.isPresent()) { - if (entityRenderManager.isPresent() && face.texture.get() instanceof EntityTexture) { - //We're not working on an atlas, so just do... this. - Texture t = face.texture.get(); - entityRenderManager.get().renderEngine.bindTexture(AssetConverter.instance().toNative(t)); - face.vertices.forEach( - v -> { - worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); - worldRenderer.tex(v.uv.getX(), v.uv.getY()); + face.vertices.forEach(v -> { + worldRenderer.getVertexFormat().getElements().forEach(vfe -> { + switch (vfe.getUsage()) { + case POSITION: { worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); - } - ); - } else { - Texture texture = face.texture.get(); - TextureAtlasSprite icon = RenderUtility.instance.getTexture(texture); - face.vertices.forEach( - v -> { + break; + } case NORMAL: { + Vector3D normal = face.normal;//v.normal.orElse(face.normal); + worldRenderer.normal((float)normal.getX(), (float)normal.getY(), (float)normal.getZ()); + break; + } case COLOR: { worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); - if (icon != null) { - worldRenderer.tex(icon.getInterpolatedU(16 * v.uv.getX()), icon.getInterpolatedV(16 * v.uv.getY())); - worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); - } else { - worldRenderer.tex(v.uv.getX(), v.uv.getY()); - worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); + break; + } case UV: { + if (vfe.getIndex() == 0) { + if (entityRenderManager.isPresent() && isEntityTexture) { + //We're not working on an atlas, so just do... this. + worldRenderer.tex(v.uv.getX(), v.uv.getY()); + } else { + TextureAtlasSprite tex = face.texture.map(RenderUtility.instance::getTexture) + .orElseGet(Minecraft.getMinecraft().getTextureMapBlocks()::getMissingSprite); + worldRenderer.tex(tex.getInterpolatedU(16 * v.uv.getX()), tex.getInterpolatedV(16 * v.uv.getY())); + } + } else if (vfe.getIndex() == 1) { + // TODO: Lightmap + if (face.getBrightness() >= 0) { + worldRenderer.lightmap((int)(face.getBrightness() * 15), (int)(face.getBrightness() * 11)); + } else if(access.isPresent()) { + // Determine nearest adjacent block. + Vector3D nearestPos = Vector3DUtil.floor(face.getCenter().add(face.normal.scalarMultiply(0.05))); + BlockPos blockPos = Game.natives().toNative(nearestPos); + IBlockState state = access.get().getBlockState(blockPos); + Block block = state.getBlock(); + @SuppressWarnings("deprecation") + int brightness = block.getPackedLightmapCoords(state, access.get(), blockPos); + + // TODO: Add Ambient Occlusion + /* + int aoBrightnessXYNN = block.getPackedLightmapCoords(state, access.get(), blockPos.east()); + int aoBrightnessYZNN = block.getPackedLightmapCoords(state, access.get(), blockPos.north()); + int aoBrightnessYZNP = block.getPackedLightmapCoords(state, access.get(), blockPos.south()); + int aoBrightnessXYPN = block.getPackedLightmapCoords(state, access.get(), blockPos.west()); + + int brightnessTopLeft = getAoBrightness(aoBrightnessXYZNNP, aoBrightnessXYNN, aoBrightnessYZNP, i1); + int brightnessTopRight = getAoBrightness(aoBrightnessYZNP, aoBrightnessXYZPNP, aoBrightnessXYPN, i1); + int brightnessBottomRight = getAoBrightness(aoBrightnessYZNN, aoBrightnessXYPN, aoBrightnessXYZPNN, i1); + int brightnessBottomLeft = getAoBrightness(aoBrightnessXYNN, aoBrightnessXYZNNN, aoBrightnessYZNN, i1); + */ + + worldRenderer.lightmap((brightness >>> 20) & 0xFFFF, (brightness >>> 4) & 0xFFFF); + } else { + worldRenderer.lightmap(15, 11); + } } + break; } - ); - } - } else { - face.vertices.forEach( - v -> { - worldRenderer.color(v.color.red(), v.color.green(), v.color.blue(), v.color.alpha()); - worldRenderer.pos(v.vec.getX(), v.vec.getY(), v.vec.getZ()); } - ); - } + }); + worldRenderer.endVertex(); + }); }); } else if (model instanceof CustomModel) { CustomModel customModel = (CustomModel) model; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java index 7410a8832..6bc753c3b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java @@ -25,7 +25,10 @@ import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; import java.util.Collections; import java.util.List; @@ -36,18 +39,14 @@ */ public class FWEmptyModel extends FWSmartModel implements IBakedModel { + //Item rendering @Override - public List getQuads(IBlockState state, EnumFacing side, long rand) { - return Collections.emptyList(); + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { + return this; } @Override - public TextureAtlasSprite getParticleTexture() { - return null; - } - - @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.NONE; + public List getQuads(IBlockState state, EnumFacing side, long rand) { + return Collections.emptyList(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 4a9215c2b..793cc48d5 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -24,32 +24,43 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; import nova.core.block.Block; -import nova.core.component.renderer.DynamicRenderer; +import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; +import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.util.vector.Vector3f; import java.util.List; +import java.util.Optional; /** * Generates a smart model based on a NOVA Model * @author Calclavia */ -@SuppressWarnings("deprecation") public class FWSmartBlockModel extends FWSmartModel implements IBakedModel { private final Block block; - private final boolean isItem; + private final Optional item; + + public FWSmartBlockModel(Block block) { + this(block, Optional.empty()); + } + + public FWSmartBlockModel(Block block, Item item) { + this(block, Optional.of(item)); + } @SuppressWarnings("deprecation") - public FWSmartBlockModel(Block block, boolean isItem) { - super(); + public FWSmartBlockModel(Block block, Optional item) { this.block = block; - this.isItem = isItem; + this.item = item; // Change the default transforms to the default full Block transforms this.itemCameraTransforms = new ItemCameraTransforms( new ItemTransformVec3f(new Vector3f(75, 225, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Left) @@ -62,29 +73,33 @@ public FWSmartBlockModel(Block block, boolean isItem) { ItemTransformVec3f.DEFAULT);// Fixed } + //Item rendering + @Override + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { + Item item = ItemConverter.instance().toNova(stack); + + if (item.components.has(Renderer.class) || block.components.has(Renderer.class)) { + return new FWSmartBlockModel(block, item); + } + + return new FWEmptyModel(); + } + @Override public List getQuads(IBlockState state, EnumFacing side, long rand) { BWModel model = new BWModel(); model.matrix.translate(0.5, 0.5, 0.5); - if (isItem) { - if (block.components.has(StaticRenderer.class)) { - StaticRenderer staticRenderer = block.components.get(StaticRenderer.class); - staticRenderer.onRender.accept(model); - } else if (block.components.has(DynamicRenderer.class)) { - DynamicRenderer dynamicRenderer = block.components.get(DynamicRenderer.class); - dynamicRenderer.onRender.accept(model); + if (item.isPresent()) { + if (item.get().components.has(Renderer.class)) { + item.get().components.getSet(Renderer.class).forEach(r -> r.onRender.accept(model)); + } else { + block.components.getSet(Renderer.class).forEach(r -> r.onRender.accept(model)); } } else { - StaticRenderer renderer = block.components.get(StaticRenderer.class); - renderer.onRender.accept(model); + block.components.getOp(StaticRenderer.class).ifPresent(r -> r.onRender.accept(model)); } return modelToQuads(model); } - - @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.NONE; - } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index 1f3671e68..bf774cf51 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -24,13 +24,14 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ItemTransformVec3f; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; -import nova.core.component.renderer.DynamicRenderer; +import net.minecraft.world.World; import nova.core.component.renderer.Renderer; -import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.util.vector.Vector3f; @@ -47,7 +48,6 @@ public class FWSmartItemModel extends FWSmartModel implements IBakedModel { @SuppressWarnings("deprecation") public FWSmartItemModel(Item item) { - super(); this.item = item; // Change the default transforms to the default Item transforms this.itemCameraTransforms = new ItemCameraTransforms( @@ -61,29 +61,28 @@ public FWSmartItemModel(Item item) { ItemTransformVec3f.DEFAULT);// Fixed } + //Item rendering @Override - public List getQuads(IBlockState state, EnumFacing side, long rand) { - BWModel model = new BWModel(); - model.matrix.translate(0.5, 0.5, 0.5); + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { + Item item = ItemConverter.instance().toNova(stack); - if (item.components.has(StaticRenderer.class)) { - StaticRenderer staticRenderer = item.components.get(StaticRenderer.class); - staticRenderer.onRender.accept(model); - } else if (item.components.has(DynamicRenderer.class)) { - DynamicRenderer dynamicRenderer = item.components.get(DynamicRenderer.class); - dynamicRenderer.onRender.accept(model); + if (item.components.has(Renderer.class)) { + return new FWSmartItemModel(item); } - return modelToQuads(model); + return new FWEmptyModel(); } @Override - public boolean isGui3d() { - return item.components.has(Renderer.class); + public List getQuads(IBlockState state, EnumFacing side, long rand) { + BWModel model = new BWModel(); + model.matrix.translate(0.5, 0.5, 0.5); + item.components.getSet(Renderer.class).forEach(r -> r.onRender.accept(model)); + return modelToQuads(model); } @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.NONE; + public boolean isGui3d() { + return item.components.has(Renderer.class); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java index 4fddcc6fd..5cd27c9cc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java @@ -25,20 +25,24 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.util.EnumFacing; -import nova.core.render.model.CustomModel; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import nova.core.render.model.MeshModel; import nova.core.render.model.Model; import nova.core.render.model.Vertex; import nova.core.util.Direction; import nova.core.util.math.MathUtil; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -50,44 +54,41 @@ @SuppressWarnings("deprecation") public abstract class FWSmartModel implements IBakedModel { - protected static final VertexFormat NOVA_VERTEX_FORMAT; + protected static final VertexFormat NOVA_VERTEX_FORMAT = DefaultVertexFormats.ITEM; protected final VertexFormat format; // Default item transforms. Can be changed in subclasses. protected ItemCameraTransforms itemCameraTransforms = ItemCameraTransforms.DEFAULT; - - static { - NOVA_VERTEX_FORMAT = DefaultVertexFormats.ITEM; -// NOVA_VERTEX_FORMAT = new VertexFormat(); -// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.POSITION_3F); -// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.COLOR_4UB); -// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.TEX_2F); -// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.NORMAL_3B); -// NOVA_VERTEX_FORMAT.addElement(DefaultVertexFormats.PADDING_1B); - } + private final FWOverrideList overrides; protected FWSmartModel(VertexFormat format) { this.format = format; + this.overrides = new FWOverrideList(); } public FWSmartModel() { - this.format = NOVA_VERTEX_FORMAT; + this(NOVA_VERTEX_FORMAT); } public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture, Vector3D normal) { + // TODO: Possibly support arbitrary `VertexFormat` +// if (vertex.normal.isPresent()) +// normal = vertex.normal.get(); return new int[] { Float.floatToRawIntBits((float) vertex.vec.getX()), Float.floatToRawIntBits((float) vertex.vec.getY()), Float.floatToRawIntBits((float) vertex.vec.getZ()), - vertex.color.argb(), + vertex.color.rgba(), Float.floatToRawIntBits(texture.getInterpolatedU(16 * vertex.uv.getX())), Float.floatToRawIntBits(texture.getInterpolatedV(16 * vertex.uv.getY())), ((((byte)(normal.getX() * 127)) & 0xFF) | ((((byte)(normal.getY() * 127)) & 0xFF) << 8) | - ((((byte)(normal.getZ() * 127)) & 0xFF) << 16)) // TODO: Normal + ((((byte)(normal.getZ() * 127)) & 0xFF) << 16)) }; } + public abstract IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity); + protected List modelToQuads(Model modelIn) { return modelIn .flatten() @@ -98,19 +99,23 @@ protected List modelToQuads(Model modelIn) { MeshModel meshModel = (MeshModel) model; return meshModel.faces .stream() + .filter(f -> f.vertices.size() > 2) .map( face -> { TextureAtlasSprite texture = face.texture.map(RenderUtility.instance::getTexture) - .orElse(Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite()); + .orElseGet(Minecraft.getMinecraft().getTextureMapBlocks()::getMissingSprite); List vertexData = face.vertices .stream() .map(v -> vertexToInts(v, texture, face.normal)) .collect(Collectors.toList()); + if (vertexData.size() < 4) + vertexData.add(vertexData.get(vertexData.size() - 1)); + int[] data = Ints.concat(vertexData.toArray(new int[][] {})); //TODO: The facing might be wrong - return new BakedQuad(Arrays.copyOf(data, MathUtil.max(data.length, 0)), -1, EnumFacing.values()[Direction.fromVector(face.normal).ordinal()], - texture, true, getFormat()); + return new BakedQuad(Arrays.copyOf(data, MathUtil.min(data.length, format.getNextOffset())), -1, + DirectionConverter.instance().toNative(Direction.fromVector(face.normal)), texture, true, getFormat()); } ); } @@ -142,11 +147,28 @@ public boolean isBuiltInRenderer() { @Override public TextureAtlasSprite getParticleTexture() { - return null; + return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite(); } @Override + @Deprecated public ItemCameraTransforms getItemCameraTransforms() { return itemCameraTransforms; } + + @Override + public final ItemOverrideList getOverrides() { + return overrides; + } + + private final class FWOverrideList extends ItemOverrideList { + private FWOverrideList() { + super(Collections.emptyList()); + } + + @Override + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { + return FWSmartModel.this.handleItemState(originalModel, stack, world, entity); + } + } } diff --git a/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java index 796fd98b2..61175144f 100644 --- a/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java +++ b/minecraft/1.11.2/src/test/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaLauncherTest.java @@ -28,6 +28,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; import nova.internal.core.Game; import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; +import nova.wrappertests.AbstractNovaLauncherTest; import nova.wrappertests.depmodules.FakeNetworkModule; import org.junit.Test; import se.jbee.inject.bootstrap.Bundle; @@ -40,7 +41,7 @@ /** * @author rx14 */ -public class NovaLauncherTest extends nova.wrappertests.NovaLauncherTest { +public class NovaLauncherTest extends AbstractNovaLauncherTest { @Override public List> getModules() { From 20e57cb7882d3843c4ad4f6e9357b0719f56671f Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 13 Mar 2017 14:49:13 +0100 Subject: [PATCH 38/61] Fix build script fat jar reobfuscation --- minecraft/1.11.2/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index 09dc17657..c695ed4f6 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -56,6 +56,10 @@ task fatJar(type: Jar) { attributes 'FMLAT': 'nova_at.cfg' } classifier = 'fat' + + doLast { + reobfFatJar.execute() + } } artifacts { From 1d2c782ef107712977abc48fa159fe9e6328d087 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Mon, 13 Mar 2017 20:02:58 +0100 Subject: [PATCH 39/61] Improve Forge capability support --- minecraft/1.11.2/build.gradle | 4 +- .../mc/forge/v1_11_2/util/WrapperEvent.java | 6 +- .../v1_11_2/wrapper/block/forward/FWTile.java | 58 ++++++++++------ .../forward/FWCapabilityProvider.java | 51 ++++++++------ .../forward/NovaCapabilityProvider.java | 68 +++++++++++++++++++ .../wrapper/entity/forward/FWEntity.java | 54 ++++++++++----- .../entity/forward/FWEntityRenderer.java | 8 +-- .../v1_11_2/wrapper/item/ItemConverter.java | 54 ++++++++++++--- .../v1_11_2/wrapper/item/forward/FWItem.java | 8 +-- .../wrapper/item/forward/FWItemBlock.java | 11 +-- .../forward/FWItemCapabilityProvider.java | 35 ++++++++++ .../wrapper/render/backward/BWModel.java | 55 ++++++++++----- 12 files changed, 305 insertions(+), 107 deletions(-) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index c695ed4f6..d7fe1a678 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -56,7 +56,7 @@ task fatJar(type: Jar) { attributes 'FMLAT': 'nova_at.cfg' } classifier = 'fat' - + doLast { reobfFatJar.execute() } @@ -107,7 +107,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20170227' + mappings = 'snapshot_20170313' runDir = "run" } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java index 0deef379b..27400a5f9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java @@ -29,12 +29,12 @@ import nova.core.item.Item; import nova.core.util.Direction; import nova.core.world.World; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTile; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemCapabilityProvider; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Optional; @@ -116,9 +116,9 @@ public BWEntityCreate(BWEntity novaEntity, net.minecraft.entity.Entity mcEntity) public static class FWItemInitCapabilities extends Event { public final Item novaItem; - public final FWCapabilityProvider capabilityProvider; + public final FWItemCapabilityProvider capabilityProvider; - public FWItemInitCapabilities(Item novaItem, FWCapabilityProvider capabilityProvider) { + public FWItemInitCapabilities(Item novaItem, FWItemCapabilityProvider capabilityProvider) { this.novaItem = novaItem; this.capabilityProvider = capabilityProvider; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index 3ac182b4b..ce50bc993 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -35,32 +35,36 @@ import nova.core.network.Syncable; import nova.core.retention.Data; import nova.core.retention.Storable; +import nova.core.util.Direction; import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.io.IOException; +import java.util.EnumMap; import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; /** * A Minecraft TileEntity to Nova block wrapper * @author Calclavia */ -public class FWTile extends TileEntity { +public class FWTile extends TileEntity implements NovaCapabilityProvider { - private final Map, Object> capabilities = new HashMap<>(); - private final Map, Object>> sidedCapabilities = new HashMap<>(); + private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { + for (Direction facing : Direction.values()) + capabilities.put(facing, new ConcurrentHashMap<>()); + } protected String blockID; protected Block block; protected Data cacheData = null; - public FWTile() { - for (EnumFacing facing : EnumFacing.VALUES) - sidedCapabilities.put(facing, new HashMap<>()); - } + public FWTile() {} public FWTile(String blockID) { this.blockID = blockID; @@ -127,36 +131,48 @@ public void readFromNBT(NBTTagCompound nbt) { cacheData = Game.natives().toNova(nbt.getCompoundTag("nova")); } - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing == null || facing.allowsAll()) { - if (capabilities.containsKey(capability)) + @Override + public boolean hasCapabilities() { + return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; + } + + @Override + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing.allowsAll()) { + if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); } else { facing.forEach(enumFacing -> { - Map, Object> capabilities = sidedCapabilities.get(enumFacing); + Map, Object> caps = capabilities.get(enumFacing); - if (capabilities.containsKey(capability)) + if (caps.containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + caps.put(capability, capabilityInstance); }); } return capabilityInstance; } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { - return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)) - || super.hasCapability(capability, facing); + public boolean hasCapability(Capability capability, Direction direction) { + return Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.containsValue(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); } @Override - public T getCapability(Capability capability, EnumFacing facing) { - if (!hasCapability(capability, facing)) return null; - T capabilityInstance = (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); - return capabilityInstance != null ? capabilityInstance : super.getCapability(capability, facing); + @SuppressWarnings("unchecked") + public T getCapability(Capability capability, Direction direction) { + return (T) Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.get(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java index 4b3420423..a34f9a664 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java @@ -5,60 +5,69 @@ */ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward; -import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import nova.core.util.Direction; import nova.core.util.EnumSelector; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; /** * * @author ExE Boss */ -public class FWCapabilityProvider implements ICapabilityProvider { +public class FWCapabilityProvider implements NovaCapabilityProvider { - private final Map, Object> capabilities = new HashMap<>(); - private final Map, Object>> sidedCapabilities = new HashMap<>(); + private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); public FWCapabilityProvider() { - for (EnumFacing facing : EnumFacing.VALUES) - sidedCapabilities.put(facing, new HashMap<>()); + for (Direction facing : Direction.values()) + capabilities.put(facing, new ConcurrentHashMap<>()); } + @Override public boolean hasCapabilities() { - return !capabilities.isEmpty() || sidedCapabilities.values().stream().flatMap(map -> map.keySet().stream()).count() > 0; + return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; } - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing == null || facing.allowsAll()) { - if (capabilities.containsKey(capability)) + @Override + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing.allowsAll()) { + if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); } else { facing.forEach(enumFacing -> { - Map, Object> capabilities = sidedCapabilities.get(enumFacing); + Map, Object> caps = capabilities.get(enumFacing); - if (capabilities.containsKey(capability)) + if (caps.containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + caps.put(capability, capabilityInstance); }); } return capabilityInstance; } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { - return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)); + public boolean hasCapability(Capability capability, Direction direction) { + return Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.containsValue(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); } @Override @SuppressWarnings("unchecked") - public T getCapability(Capability capability, EnumFacing facing) { - if (!hasCapability(capability, facing)) return null; - return (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); + public T getCapability(Capability capability, Direction direction) { + return (T) Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.get(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java new file mode 100644 index 000000000..c97b3000a --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward; + +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import nova.core.util.Direction; +import nova.core.util.EnumSelector; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; + +import javax.annotation.Nullable; + +/** + * @author ExE Boss + */ +public interface NovaCapabilityProvider extends ICapabilityProvider { + + boolean hasCapabilities(); + + default T addCapability(Capability capability, T instance, Direction... directions) { + return addCapability(capability, instance, EnumSelector.of(Direction.class).blockAll().apart(directions).lock()); + } + + + default T addCapability(Capability capability, T instance, Direction direction) { + return addCapability(capability, instance, direction == Direction.UNKNOWN ? + EnumSelector.of(Direction.class).allowAll().lock() : + EnumSelector.of(Direction.class).blockAll().apart(direction).lock()); + } + + + T addCapability(Capability capability, T instance, EnumSelector directions); + + boolean hasCapability(Capability capability, Direction direction); + + @Override + default boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + return hasCapability(capability, DirectionConverter.instance().toNova(facing)); + } + + @Nullable + T getCapability(Capability capability, Direction direction); + + @Override + @Nullable + default T getCapability(Capability capability, @Nullable EnumFacing facing) { + return getCapability(capability, DirectionConverter.instance().toNova(facing)); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index 971e65d27..985334f68 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -34,23 +34,29 @@ import nova.core.entity.EntityFactory; import nova.core.retention.Data; import nova.core.retention.Storable; +import nova.core.util.Direction; import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; /** * Entity wrapper * @author Calclavia */ -public class FWEntity extends net.minecraft.entity.Entity implements IEntityAdditionalSpawnData { +public class FWEntity extends net.minecraft.entity.Entity implements IEntityAdditionalSpawnData, NovaCapabilityProvider { - private final Map, Object> capabilities = new HashMap<>(); - private final Map, Object>> sidedCapabilities = new HashMap<>(); + private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { + for (Direction facing : Direction.values()) + capabilities.put(facing, new ConcurrentHashMap<>()); + } protected final EntityTransform transform; protected Entity wrapped; @@ -226,35 +232,47 @@ public void setDead() { super.setDead(); } - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing == null || facing.allowsAll()) { - if (capabilities.containsKey(capability)) + @Override + public boolean hasCapabilities() { + return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; + } + + @Override + public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { + if (facing.allowsAll()) { + if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); } else { facing.forEach(enumFacing -> { - Map, Object> capabilities = sidedCapabilities.get(enumFacing); + Map, Object> caps = capabilities.get(enumFacing); - if (capabilities.containsKey(capability)) + if (caps.containsKey(capability)) throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - capabilities.put(capability, capabilityInstance); + caps.put(capability, capabilityInstance); }); } return capabilityInstance; } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { - return (facing != null ? sidedCapabilities.get(facing).containsValue(capability) : capabilities.containsValue(capability)) - || super.hasCapability(capability, facing); + public boolean hasCapability(Capability capability, Direction direction) { + return Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.containsValue(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); } @Override - public T getCapability(Capability capability, EnumFacing facing) { - if (!hasCapability(capability, facing)) return null; - T capabilityInstance = (T) (facing != null ? sidedCapabilities.get(facing).get(capability) : capabilities.get(capability)); - return capabilityInstance != null ? capabilityInstance : super.getCapability(capability, facing); + @SuppressWarnings("unchecked") + public T getCapability(Capability capability, Direction direction) { + return (T) Optional.of(direction) + .filter(d -> d != Direction.UNKNOWN) + .map(capabilities::get) + .map(caps -> caps.get(capability)) + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java index 6e567e421..111fced59 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntityRenderer.java @@ -72,8 +72,8 @@ public static void render(FWParticle wrapper, nova.core.entity.Entity entity, do GL11.glBlendFunc(model.blendSFactor, model.blendDFactor); } - Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); - model.render(Optional.of(Minecraft.getMinecraft().getRenderManager())); + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.ITEM); + model.render(Minecraft.getMinecraft().getRenderManager()); Tessellator.getInstance().draw(); if (model.blendSFactor > 0 && model.blendDFactor > 0) { @@ -102,8 +102,8 @@ public static void render(FWEntity wrapper, nova.core.entity.Entity entity, doub GL11.glBlendFunc(model.blendSFactor, model.blendDFactor); } - Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.BLOCK); - model.render(Optional.of(Minecraft.getMinecraft().getRenderManager())); + Tessellator.getInstance().getBuffer().begin(GL_QUADS, DefaultVertexFormats.ITEM); + model.render(Minecraft.getMinecraft().getRenderManager()); Tessellator.getInstance().draw(); if (model.blendSFactor > 0 && model.blendDFactor > 0) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 6dca71931..58af26934 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -23,6 +23,8 @@ import com.google.common.collect.HashBiMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.capabilities.CapabilityDispatcher; +import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -41,10 +43,12 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWNBTTagCompound; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import java.lang.reflect.Field; import java.util.Objects; import java.util.Set; @@ -74,24 +78,27 @@ public Class getNativeSide() { } @Override - public Item toNova(ItemStack itemStack) { - return getNovaItem(itemStack).setCount(itemStack.getCount()); + public Item toNova(ItemStack stack) { + return getNovaItem(stack).setCount(stack.getCount()); } - public Item getNovaItem(ItemStack itemStack) { - if (itemStack.getItemDamage() == net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE) { + public Item getNovaItem(ItemStack stack) { + if (stack.getItemDamage() == net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE) { // TODO: Deal withPriority wildcard meta values - important for the ore dictionary - return getNovaItem(new ItemStack(itemStack.getItem(), 1, 0)); + return getNovaItem(new ItemStack(stack.getItem(), 1, 0)); } - if (itemStack.getTagCompound() != null && itemStack.getTagCompound() instanceof FWNBTTagCompound) { - return Objects.requireNonNull((FWNBTTagCompound) itemStack.getTagCompound()).getItem(); + ICapabilityProvider stackCapabilities = getStackCapabilities(stack); + if (stack.getTagCompound() instanceof FWNBTTagCompound) { + return ((FWNBTTagCompound) stack.getTagCompound()).getItem(); + } else if (stackCapabilities instanceof FWItemCapabilityProvider) { + return ((FWItemCapabilityProvider) stackCapabilities).item; } else { - ItemFactory itemFactory = registerMinecraftMapping(itemStack.getItem(), itemStack.getItemDamage()); + ItemFactory itemFactory = registerMinecraftMapping(stack.getItem(), stack.getItemDamage()); - Data data = itemStack.getTagCompound() != null ? Game.natives().toNova(itemStack.getTagCompound()) : new Data(); - if (!itemStack.getHasSubtypes() && itemStack.getItemDamage() > 0) { - data.put("damage", itemStack.getItemDamage()); + Data data = stack.getTagCompound() != null ? Game.natives().toNova(stack.getTagCompound()) : new Data(); + if (!stack.getHasSubtypes() && stack.getItemDamage() > 0) { + data.put("damage", stack.getItemDamage()); } return itemFactory.build(data); @@ -332,4 +339,29 @@ public String toString() { } } } + + private ICapabilityProvider getStackCapabilities(ItemStack stack) { + try { + Field capabilities = ItemStack.class.getDeclaredField("capabilities"); + capabilities.setAccessible(true); + @SuppressWarnings("unchecked") + CapabilityDispatcher dispatcher = (CapabilityDispatcher) capabilities.get(stack); + capabilities.setAccessible(false); + if (dispatcher == null) + return null; + + Field caps = CapabilityDispatcher.class.getDeclaredField("caps"); + caps.setAccessible(true); + @SuppressWarnings("unchecked") + ICapabilityProvider[] providers = (ICapabilityProvider[]) caps.get(dispatcher); + caps.setAccessible(false); + + ICapabilityProvider provider = null; + if (providers.length > 0) + provider = providers[0]; + return provider; + } catch (ReflectiveOperationException | ClassCastException ex) { + return null; + } + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index 540e75daf..357c0445a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -29,12 +29,11 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; +import nova.internal.core.Game; import java.util.List; import javax.annotation.Nullable; @@ -54,9 +53,10 @@ public FWItem(ItemFactory item) { @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + public FWItemCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { Item item = ItemConverter.instance().toNova(stack); - WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWItemCapabilityProvider(item)); + Game.events().publish(event); return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index b6f67c454..bfd26d288 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -29,16 +29,15 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import java.util.List; +import javax.annotation.Nullable; /** * @author Calclavia @@ -50,9 +49,11 @@ public FWItemBlock(FWBlock block) { } @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - Item item = Game.natives().toNova(stack); - WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); + @Nullable + public FWItemCapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + Item item = ItemConverter.instance().toNova(stack); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWItemCapabilityProvider(item)); + Game.events().publish(event); return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java new file mode 100644 index 000000000..936ee63ae --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; + +import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; + +/** + * @author ExE Boss + */ +public class FWItemCapabilityProvider extends FWCapabilityProvider { + + public final Item item; + + public FWItemCapabilityProvider(Item item) { + this.item = item; + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java index b85657b67..c5a46cf6c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWModel.java @@ -20,27 +20,27 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import nova.core.render.model.CustomModel; import nova.core.render.model.MeshModel; +import nova.core.render.model.Vertex; import nova.core.render.texture.EntityTexture; -import nova.core.render.texture.Texture; import nova.core.util.math.Vector3DUtil; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; -import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; +import org.lwjgl.opengl.GL11; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; import javax.annotation.Nonnull; @@ -52,15 +52,15 @@ public class BWModel extends MeshModel { public void render() { - render(Optional.empty()); + render(Optional.empty(), Optional.empty()); } public void render(@Nonnull IBlockAccess access) { render(Optional.of(access), Optional.empty()); } - public void render(Optional entityRenderManager) { - render(Optional.empty(), entityRenderManager); + public void render(@Nonnull RenderManager entityRenderManager) { + render(Optional.ofNullable(entityRenderManager.world), Optional.of(entityRenderManager)); } public void render(Optional access, Optional entityRenderManager) { @@ -81,7 +81,29 @@ public void render(Optional access, Optional entity entityRenderManager.get().renderEngine.bindTexture(AssetConverter.instance().toNative(face.texture.get())); } - face.vertices.forEach(v -> { + final List vertices; + switch (worldRenderer.getDrawMode()) { + case GL11.GL_TRIANGLES: + vertices = new ArrayList<>(3); + vertices.add(face.vertices.get(0)); + vertices.add(face.vertices.get(1)); + vertices.add(face.vertices.get(2)); + break; + case GL11.GL_QUADS: + vertices = new ArrayList<>(4); + vertices.add(face.vertices.get(0)); + vertices.add(face.vertices.get(1)); + vertices.add(face.vertices.get(2)); + if (face.vertices.size() >= 4) + vertices.add(face.vertices.get(3)); + else + vertices.add(face.vertices.get(2)); + break; + default: + vertices = new ArrayList<>(face.vertices); + break; + } + vertices.forEach(v -> { worldRenderer.getVertexFormat().getElements().forEach(vfe -> { switch (vfe.getUsage()) { case POSITION: { @@ -105,24 +127,21 @@ public void render(Optional access, Optional entity worldRenderer.tex(tex.getInterpolatedU(16 * v.uv.getX()), tex.getInterpolatedV(16 * v.uv.getY())); } } else if (vfe.getIndex() == 1) { - // TODO: Lightmap if (face.getBrightness() >= 0) { worldRenderer.lightmap((int)(face.getBrightness() * 15), (int)(face.getBrightness() * 11)); } else if(access.isPresent()) { // Determine nearest adjacent block. Vector3D nearestPos = Vector3DUtil.floor(face.getCenter().add(face.normal.scalarMultiply(0.05))); - BlockPos blockPos = Game.natives().toNative(nearestPos); + BlockPos blockPos = VectorConverter.instance().toNative(nearestPos); IBlockState state = access.get().getBlockState(blockPos); - Block block = state.getBlock(); - @SuppressWarnings("deprecation") - int brightness = block.getPackedLightmapCoords(state, access.get(), blockPos); + int brightness = state.getPackedLightmapCoords(access.get(), blockPos); // TODO: Add Ambient Occlusion /* - int aoBrightnessXYNN = block.getPackedLightmapCoords(state, access.get(), blockPos.east()); - int aoBrightnessYZNN = block.getPackedLightmapCoords(state, access.get(), blockPos.north()); - int aoBrightnessYZNP = block.getPackedLightmapCoords(state, access.get(), blockPos.south()); - int aoBrightnessXYPN = block.getPackedLightmapCoords(state, access.get(), blockPos.west()); + int aoBrightnessXYNN = state.getPackedLightmapCoords(access.get(), blockPos.east()); + int aoBrightnessYZNN = state.getPackedLightmapCoords(access.get(), blockPos.north()); + int aoBrightnessYZNP = state.getPackedLightmapCoords(access.get(), blockPos.south()); + int aoBrightnessXYPN = state.getPackedLightmapCoords(access.get(), blockPos.west()); int brightnessTopLeft = getAoBrightness(aoBrightnessXYZNNP, aoBrightnessXYNN, aoBrightnessYZNP, i1); int brightnessTopRight = getAoBrightness(aoBrightnessYZNP, aoBrightnessXYZPNP, aoBrightnessXYPN, i1); From d12889f197592b1d7720c5cc85bcd45121d9d7c7 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 14 Mar 2017 20:21:35 +0100 Subject: [PATCH 40/61] Implement LexManos's solution to making items persistent --- .../mc/forge/v1_11_2/util/WrapperEvent.java | 6 +- .../forward/NovaCapabilityProvider.java | 4 + .../v1_11_2/wrapper/item/ItemConverter.java | 95 ++++++++----------- .../v1_11_2/wrapper/item/forward/FWItem.java | 22 ++--- .../wrapper/item/forward/FWItemBlock.java | 22 ++--- .../item/forward/FWNBTTagCompound.java | 4 +- .../v1_11_2/wrapper/item/forward/IFWItem.java | 15 ++- ...mCapabilityProvider.java => NovaItem.java} | 11 ++- .../render/forward/FWSmartBlockModel.java | 13 ++- .../render/forward/FWSmartItemModel.java | 4 +- .../wrapper/render/forward/FWSmartModel.java | 14 +++ 11 files changed, 112 insertions(+), 98 deletions(-) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/{FWItemCapabilityProvider.java => NovaItem.java} (73%) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java index 27400a5f9..a7bf3fc63 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java @@ -31,10 +31,10 @@ import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWTile; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemCapabilityProvider; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Optional; @@ -116,9 +116,9 @@ public BWEntityCreate(BWEntity novaEntity, net.minecraft.entity.Entity mcEntity) public static class FWItemInitCapabilities extends Event { public final Item novaItem; - public final FWItemCapabilityProvider capabilityProvider; + public final FWCapabilityProvider capabilityProvider; - public FWItemInitCapabilities(Item novaItem, FWItemCapabilityProvider capabilityProvider) { + public FWItemInitCapabilities(Item novaItem, FWCapabilityProvider capabilityProvider) { this.novaItem = novaItem; this.capabilityProvider = capabilityProvider; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java index c97b3000a..d17c1f35c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java @@ -36,6 +36,10 @@ public interface NovaCapabilityProvider extends ICapabilityProvider { boolean hasCapabilities(); + default T addCapability(Capability capability, T instance) { + return addCapability(capability, instance, Direction.UNKNOWN); + } + default T addCapability(Capability capability, T instance, Direction... directions) { return addCapability(capability, instance, EnumSelector.of(Direction.class).blockAll().apart(directions).lock()); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 58af26934..52337b886 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -22,9 +22,12 @@ import com.google.common.collect.HashBiMap; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.capabilities.CapabilityDispatcher; -import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.Capability.IStorage; +import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -40,16 +43,17 @@ import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWNBTTagCompound; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.NovaItem; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; -import java.lang.reflect.Field; import java.util.Objects; +import java.util.Optional; import java.util.Set; /** @@ -88,21 +92,17 @@ public Item getNovaItem(ItemStack stack) { return getNovaItem(new ItemStack(stack.getItem(), 1, 0)); } - ICapabilityProvider stackCapabilities = getStackCapabilities(stack); - if (stack.getTagCompound() instanceof FWNBTTagCompound) { - return ((FWNBTTagCompound) stack.getTagCompound()).getItem(); - } else if (stackCapabilities instanceof FWItemCapabilityProvider) { - return ((FWItemCapabilityProvider) stackCapabilities).item; - } else { - ItemFactory itemFactory = registerMinecraftMapping(stack.getItem(), stack.getItemDamage()); - - Data data = stack.getTagCompound() != null ? Game.natives().toNova(stack.getTagCompound()) : new Data(); - if (!stack.getHasSubtypes() && stack.getItemDamage() > 0) { - data.put("damage", stack.getItemDamage()); - } - - return itemFactory.build(data); - } + // Nova FWCapabilityProvider stores capabilities in a HashMap, so we need this to be as fast as possible. + return Optional.ofNullable(stack.getCapability(NovaItem.CAPABILITY, null)) + .map(wrapped -> wrapped.item) + .orElseGet(() -> { + ItemFactory itemFactory = registerMinecraftMapping(stack.getItem(), stack.getItemDamage()); + Data data = stack.getTagCompound() != null ? Game.natives().toNova(stack.getTagCompound()) : new Data(); + if (!stack.getHasSubtypes() && stack.getItemDamage() > 0) { + data.put("damage", stack.getItemDamage()); + } + return itemFactory.build(data); + }); } @Override @@ -116,30 +116,21 @@ public ItemStack toNative(Item item) { return ((BWItem) item).makeItemStack(item.count()); } else { ItemFactory itemFactory = Game.items().get(item.getID()).get();// TODO? - FWNBTTagCompound tag = new FWNBTTagCompound(item); - MinecraftItemMapping mapping = get(itemFactory); if (mapping == null) { throw new InitializationException("Missing mapping for " + itemFactory.getID()); } - - ItemStack result = new ItemStack(mapping.item, item.count(), mapping.meta); - result.setTagCompound(tag); - return result; + return new ItemStack(mapping.item, item.count(), mapping.meta, new FWNBTTagCompound(item)); } } public ItemStack toNative(ItemFactory itemFactory) { - FWNBTTagCompound tag = new FWNBTTagCompound(itemFactory.build()); - MinecraftItemMapping mapping = get(itemFactory); if (mapping == null) { throw new InitializationException("Missing mapping for " + itemFactory.getID()); } - ItemStack result = new ItemStack(mapping.item, 1, mapping.meta); - result.setTagCompound(tag); - return result; + return new ItemStack(mapping.item, 1, mapping.meta); } public ItemStack toNative(String id) { @@ -167,7 +158,7 @@ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { return ItemStack.EMPTY; } - itemStack.setTagCompound(Game.natives().toNative(item.getFactory().save(item))); + itemStack.setTagCompound(DataConverter.instance().toNative(item.getFactory().save(item))); return itemStack; } @@ -176,11 +167,28 @@ public ItemStack updateMCItemStack(ItemStack itemStack, Item item) { */ @Override public void preInit(FMLPreInitializationEvent evt) { + registerCapabilities(); registerNOVAItemsToMinecraft(); registerMinecraftItemsToNOVA(); registerSubtypeResolution(); } + private void registerCapabilities() { + CapabilityManager.INSTANCE.register(NovaItem.class, new IStorage() { + @Override + public NBTBase writeNBT(Capability capability, NovaItem instance, EnumFacing side) { + throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); + } + + @Override + public void readNBT(Capability capability, NovaItem instance, EnumFacing side, NBTBase nbt) { + throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); + } + }, () -> { + throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); + }); + } + private void registerNOVAItemsToMinecraft() { //There should be no items registered during Native Converter preInit() // item.registry.forEach(this::registerNOVAItem); @@ -339,29 +347,4 @@ public String toString() { } } } - - private ICapabilityProvider getStackCapabilities(ItemStack stack) { - try { - Field capabilities = ItemStack.class.getDeclaredField("capabilities"); - capabilities.setAccessible(true); - @SuppressWarnings("unchecked") - CapabilityDispatcher dispatcher = (CapabilityDispatcher) capabilities.get(stack); - capabilities.setAccessible(false); - if (dispatcher == null) - return null; - - Field caps = CapabilityDispatcher.class.getDeclaredField("caps"); - caps.setAccessible(true); - @SuppressWarnings("unchecked") - ICapabilityProvider[] providers = (ICapabilityProvider[]) caps.get(dispatcher); - caps.setAccessible(false); - - ICapabilityProvider provider = null; - if (providers.length > 0) - provider = providers[0]; - return provider; - } catch (ReflectiveOperationException | ClassCastException ex) { - return null; - } - } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index 357c0445a..91931de64 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -29,11 +29,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import nova.core.item.Item; import nova.core.item.ItemFactory; -import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; -import nova.internal.core.Game; import java.util.List; import javax.annotation.Nullable; @@ -52,17 +50,14 @@ public FWItem(ItemFactory item) { } @Override - @Nullable - public FWItemCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { - Item item = ItemConverter.instance().toNova(stack); - WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWItemCapabilityProvider(item)); - Game.events().publish(event); - return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; + public ItemFactory getItemFactory() { + return itemFactory; } @Override - public ItemFactory getItemFactory() { - return itemFactory; + @Nullable + public FWCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + return IFWItem.super.initCapabilities(stack, nbt); } @Override @@ -80,11 +75,6 @@ public ActionResult onItemRightClick(World world, EntityPlayer player return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); } - @Override - public int getColorFromItemStack(ItemStack itemStack, int renderPass) { - return IFWItem.super.getColorFromItemStack(itemStack, renderPass); - } - @Override public String getUnlocalizedName() { return getItemFactory().getUnlocalizedName(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index bfd26d288..3483096fc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -29,12 +29,10 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import nova.core.item.Item; import nova.core.item.ItemFactory; -import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; -import nova.internal.core.Game; import java.util.List; import javax.annotation.Nullable; @@ -49,17 +47,14 @@ public FWItemBlock(FWBlock block) { } @Override - @Nullable - public FWItemCapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - Item item = ItemConverter.instance().toNova(stack); - WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWItemCapabilityProvider(item)); - Game.events().publish(event); - return event.capabilityProvider.hasCapabilities() ? event.capabilityProvider : null; + public ItemFactory getItemFactory() { + return ((FWBlock) block).dummy.getItemFactory(); } @Override - public ItemFactory getItemFactory() { - return ((FWBlock) block).dummy.getItemFactory(); + @Nullable + public FWCapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { + return IFWItem.super.initCapabilities(stack, nbt); } @Override @@ -77,11 +72,6 @@ public ActionResult onItemRightClick(World world, EntityPlayer player return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); } - @Override - public int getColorFromItemStack(ItemStack itemStack, int renderPass) { - return IFWItem.super.getColorFromItemStack(itemStack, renderPass); - } - @Override public String getUnlocalizedName() { return getItemFactory().getUnlocalizedName(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java index 1d89671b6..26b6d4927 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java @@ -40,8 +40,8 @@ public Item getItem() { } @Override - public NBTTagCompound copy() { - FWNBTTagCompound result = new FWNBTTagCompound(item); + public FWNBTTagCompound copy() { + FWNBTTagCompound result = new FWNBTTagCompound(item.clone()); getKeySet().forEach(key -> result.setTag(key, getTag(key).copy())); return result; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java index 8ab3a50d5..0326c9ca8 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java @@ -22,18 +22,23 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.world.World; import nova.core.item.Item; import nova.core.item.ItemFactory; import nova.core.util.Direction; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; +import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.List; import java.util.Optional; +import javax.annotation.Nullable; /** * An interface implemented by {@link FWItem} and {@link FWItemBlock} classes to override Minecraft's item events. @@ -43,6 +48,15 @@ public interface IFWItem { ItemFactory getItemFactory(); + @Nullable + default FWCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + Item item = (nbt instanceof FWNBTTagCompound ? ((FWNBTTagCompound)nbt).getItem() : ItemConverter.instance().toNova(stack)); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); + event.capabilityProvider.addCapability(NovaItem.CAPABILITY, new NovaItem(item)); + Game.events().publish(event); + return event.capabilityProvider; + } + default void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) { Item item = ItemConverter.instance().toNova(itemStack); item.setCount(itemStack.getCount()).events.publish(new Item.TooltipEvent(Optional.of(new BWEntity(player)), tooltip)); @@ -63,7 +77,6 @@ default ActionResult onItemRightClick(ItemStack itemStack, World worl return new ActionResult<>(EnumActionResult.PASS, ItemConverter.instance().updateMCItemStack(itemStack, item)); } - @SuppressWarnings("deprecation") default int getColorFromItemStack(ItemStack itemStack, int renderPass) { return ItemConverter.instance().toNova(itemStack).colorMultiplier().argb(); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java similarity index 73% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java index 936ee63ae..0f128c29b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java @@ -19,17 +19,24 @@ */ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.energy.IEnergyStorage; import nova.core.item.Item; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; /** + * Internal NOVA capability used to make NOVA items persistent. + * * @author ExE Boss */ -public class FWItemCapabilityProvider extends FWCapabilityProvider { +public class NovaItem { + @CapabilityInject(NovaItem.class) + public static Capability CAPABILITY = null; public final Item item; - public FWItemCapabilityProvider(Item item) { + public NovaItem(Item item) { this.item = item; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 793cc48d5..70243542d 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -33,6 +33,8 @@ import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWModel; import org.lwjgl.util.vector.Vector3f; @@ -86,7 +88,16 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W } @Override + @SuppressWarnings("deprecation") public List getQuads(IBlockState state, EnumFacing side, long rand) { + final Block block; + if (state != null) { + FWBlock fwBlock = (FWBlock) state.getBlock(); + block = fwBlock.getBlockInstance(fwBlock.lastExtendedWorld, VectorConverter.instance().toNova(fwBlock.lastExtendedStatePos)); + } else { + block = this.block; + } + BWModel model = new BWModel(); model.matrix.translate(0.5, 0.5, 0.5); @@ -100,6 +111,6 @@ public List getQuads(IBlockState state, EnumFacing side, long rand) { block.components.getOp(StaticRenderer.class).ifPresent(r -> r.onRender.accept(model)); } - return modelToQuads(model); + return modelToQuads(model, item.map(Item::colorMultiplier)); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index bf774cf51..78059aee7 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2015 NOVA, All rights reserved. * This library is free software, licensed under GNU Lesser General Public License version 3 @@ -74,11 +75,12 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W } @Override + @SuppressWarnings("deprecation") public List getQuads(IBlockState state, EnumFacing side, long rand) { BWModel model = new BWModel(); model.matrix.translate(0.5, 0.5, 0.5); item.components.getSet(Renderer.class).forEach(r -> r.onRender.accept(model)); - return modelToQuads(model); + return modelToQuads(model, item.colorMultiplier()); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java index 5cd27c9cc..c3f242795 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartModel.java @@ -32,6 +32,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import nova.core.render.Color; import nova.core.render.model.MeshModel; import nova.core.render.model.Model; import nova.core.render.model.Vertex; @@ -44,6 +45,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -90,6 +92,14 @@ public static int[] vertexToInts(Vertex vertex, TextureAtlasSprite texture, Vect public abstract IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity); protected List modelToQuads(Model modelIn) { + return modelToQuads(modelIn, Optional.empty()); + } + + protected List modelToQuads(Model modelIn, Color colorMultiplier) { + return modelToQuads(modelIn, Optional.of(colorMultiplier)); + } + + protected List modelToQuads(Model modelIn, Optional colorMultiplier) { return modelIn .flatten() .stream() @@ -106,6 +116,10 @@ protected List modelToQuads(Model modelIn) { .orElseGet(Minecraft.getMinecraft().getTextureMapBlocks()::getMissingSprite); List vertexData = face.vertices .stream() + .map(v -> { + colorMultiplier.ifPresent(c -> v.color = v.color.multiply(c)); + return v; + }) .map(v -> vertexToInts(v, texture, face.normal)) .collect(Collectors.toList()); From 547d3781082b18179d6ae67b66da13152b84605b Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 14 Mar 2017 22:10:17 +0100 Subject: [PATCH 41/61] Remove FWNBTTagCompound --- .../v1_11_2/wrapper/DirectionConverter.java | 10 ++-- .../v1_11_2/wrapper/VectorConverter.java | 5 ++ .../wrapper/block/forward/FWBlock.java | 30 ++++++++---- .../v1_11_2/wrapper/item/ItemConverter.java | 16 +++++-- .../item/forward/FWNBTTagCompound.java | 48 ------------------- .../v1_11_2/wrapper/item/forward/IFWItem.java | 2 +- .../wrapper/item/forward/NovaItem.java | 2 - 7 files changed, 46 insertions(+), 67 deletions(-) delete mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java index fb6d208bd..38555635c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/DirectionConverter.java @@ -34,10 +34,10 @@ public Class getNativeSide() { } @Override - public Direction toNova(@Nullable EnumFacing nativeObj) { - if (null == nativeObj) + public Direction toNova(@Nullable EnumFacing facing) { + if (null == facing) return Direction.UNKNOWN; - else switch (nativeObj) { + else switch (facing) { case DOWN: return Direction.DOWN; case UP: return Direction.UP; case NORTH: return Direction.NORTH; @@ -50,8 +50,8 @@ else switch (nativeObj) { @Override @Nullable - public EnumFacing toNative(Direction novaObj) { - switch (novaObj) { + public EnumFacing toNative(Direction direction) { + switch (direction) { case DOWN: return EnumFacing.DOWN; case UP: return EnumFacing.UP; case NORTH: return EnumFacing.NORTH; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java index 44880c8dc..b778f1cde 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java @@ -21,6 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import nova.core.nativewrapper.NativeConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -41,6 +42,10 @@ public Class getNativeSide() { return BlockPos.class; } + public Vector3D toNova(Vec3d pos) { + return new Vector3D(pos.xCoord, pos.yCoord, pos.zCoord); + } + @Override public Vector3D toNova(BlockPos pos) { return new Vector3D(pos.getX(), pos.getY(), pos.getZ()); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index c1e8c8faf..da8cc06ed 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -52,7 +52,9 @@ import nova.core.util.math.Vector3DUtil; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -137,14 +139,19 @@ public Block getBlockInstance(IBlockAccess access, Vector3D position) { e.printStackTrace(); } } - return getBlockInstance((nova.core.world.World) Game.natives().toNova(access), position); - + return getBlockInstance(WorldConverter.instance().toNova(access), position); } private Block getBlockInstance(nova.core.world.World world, Vector3D position) { // TODO: Implement obj args Block block = factory.build(); block.components.add(new MCBlockTransform(block, world, position)); + if (!block.components.has(BlockProperty.BlockSound.class)) { + BlockProperty.BlockSound properties = block.components.add(new BlockProperty.BlockSound()); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound(SoundType.STONE.getBreakSound().getSoundName().getResourceDomain(), SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound(SoundType.STONE.getPlaceSound().getSoundName().getResourceDomain(), SoundType.STONE.getPlaceSound().getSoundName().getResourcePath())); + properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound(SoundType.STONE.getStepSound().getSoundName().getResourceDomain(), SoundType.STONE.getStepSound().getSoundName().getResourcePath())); + } return block; } @@ -212,11 +219,16 @@ public IBlockState getExtendedState(IBlockState state, IBlockAccess world, Block return super.getExtendedState(state, world, pos); } + @Override + @Deprecated + public void neighborChanged(IBlockState state, World world, BlockPos pos, net.minecraft.block.Block other, BlockPos neighbor) { + onNeighborChange(world, pos, neighbor); + } + @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent( - Optional.of(VectorConverter.instance().toNova(neighbor))); + Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.of(VectorConverter.instance().toNova(neighbor))); blockInstance.events.publish(evt); } @@ -234,15 +246,17 @@ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, Ent @Override public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - RayTraceResult mop = player.rayTrace(10, 1); - Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player), Direction.fromOrdinal(mop.sideHit.ordinal()), new Vector3D(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord)); + Optional mop = Optional.ofNullable(player.rayTrace(10, 1)); + Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player), + DirectionConverter.instance().toNova(mop.map(m -> m.sideHit).orElse(null)), + mop.map(m -> m.hitVec).map(VectorConverter.instance()::toNova).orElseGet(() -> VectorConverter.instance().toNova(pos))); blockInstance.events.publish(evt); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player), Direction.fromOrdinal(side.ordinal()), new Vector3D(hitX, hitY, hitZ)); + Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player), DirectionConverter.instance().toNova(side), new Vector3D(hitX, hitY, hitZ)); blockInstance.events.publish(evt); return evt.result; } @@ -345,7 +359,7 @@ public int getLightValue(IBlockState state, IBlockAccess access, BlockPos pos) { Optional opEmitter = blockInstance.components.getOp(LightEmitter.class); if (opEmitter.isPresent()) { - return (int) MathUtil.clamp(Math.round(((java.util.function.DoubleSupplier)((Object)opEmitter.get().emittedLevel)).getAsDouble() * 15), 0, 15); + return (int) MathUtil.clamp(Math.round(opEmitter.get().emittedLevel.getAsDouble() * 15), 0, 15); } else { return 0; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 52337b886..0fc239084 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -47,11 +47,11 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWNBTTagCompound; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.NovaItem; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import java.util.LinkedList; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -66,6 +66,7 @@ public class ItemConverter implements NativeConverter, ForgeLoa * A map of all items registered */ private final HashBiMap map = HashBiMap.create(); + private final LinkedList nativeConversion = new LinkedList<>(); public static ItemConverter instance() { return Game.natives().getNative(Item.class, ItemStack.class); @@ -120,7 +121,8 @@ public ItemStack toNative(Item item) { if (mapping == null) { throw new InitializationException("Missing mapping for " + itemFactory.getID()); } - return new ItemStack(mapping.item, item.count(), mapping.meta, new FWNBTTagCompound(item)); + nativeConversion.push(item); + return new ItemStack(mapping.item, item.count(), mapping.meta); } } @@ -134,7 +136,15 @@ public ItemStack toNative(ItemFactory itemFactory) { } public ItemStack toNative(String id) { - return toNative(Game.items().get(id).get().build().setCount(1)); + return toNative(Game.items().get(id).get()); + } + + public Optional popNativeConversion() { + if (nativeConversion.isEmpty()) { + return Optional.empty(); + } else { + return Optional.of(nativeConversion.pop()); + } } public MinecraftItemMapping get(ItemFactory item) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java deleted file mode 100644 index 26b6d4927..000000000 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWNBTTagCompound.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; - -import net.minecraft.nbt.NBTTagCompound; -import nova.core.item.Item; - -/** - * A wrapped NBTTagCompound object that references the item instance - * @author Stan - * @since 3/02/2015. - */ -public class FWNBTTagCompound extends NBTTagCompound { - private final Item item; - - public FWNBTTagCompound(Item item) { - this.item = item; - } - - public Item getItem() { - return item; - } - - @Override - public FWNBTTagCompound copy() { - FWNBTTagCompound result = new FWNBTTagCompound(item.clone()); - getKeySet().forEach(key -> result.setTag(key, getTag(key).copy())); - return result; - } -} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java index 0326c9ca8..f827e869c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java @@ -50,7 +50,7 @@ public interface IFWItem { @Nullable default FWCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { - Item item = (nbt instanceof FWNBTTagCompound ? ((FWNBTTagCompound)nbt).getItem() : ItemConverter.instance().toNova(stack)); + Item item = ItemConverter.instance().popNativeConversion().orElseGet(() -> ItemConverter.instance().toNova(stack)); WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); event.capabilityProvider.addCapability(NovaItem.CAPABILITY, new NovaItem(item)); Game.events().publish(event); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java index 0f128c29b..40b9b1937 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java @@ -21,9 +21,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; -import net.minecraftforge.energy.IEnergyStorage; import nova.core.item.Item; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; /** * Internal NOVA capability used to make NOVA items persistent. From 9c0458785229c35128160ac22904258422be6a70 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 15 Mar 2017 17:33:43 +0100 Subject: [PATCH 42/61] Implement correct NOVA ID namespacing --- .../mc/forge/v1_11_2/wrapper/block/BlockConverter.java | 6 +++++- .../mc/forge/v1_11_2/wrapper/item/ItemConverter.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index 919e5428a..500aba7af 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -32,6 +32,7 @@ import nova.core.block.BlockManager; import nova.core.component.Category; import nova.core.event.BlockEvent; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; @@ -40,6 +41,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemBlock; import nova.internal.core.Game; +import nova.internal.core.launch.NovaLauncher; import java.util.Arrays; import java.util.HashMap; @@ -140,7 +142,9 @@ private void registerNovaBlock(BlockFactory blockFactory) { FWBlock blockWrapper = new FWBlock(blockFactory); FWItemBlock itemBlockWrapper = new FWItemBlock(blockWrapper); blockFactoryMap.put(blockFactory, blockWrapper); - String blockId = blockFactory.getID(); // TODO? + String blockId = blockFactory.getID(); + if (!blockId.contains(":")) + blockId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + blockId; ResourceLocation id = new ResourceLocation(blockId); GameRegistry.register(blockWrapper, id); GameRegistry.register(itemBlockWrapper, id); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 0fc239084..15c516d11 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -37,6 +37,7 @@ import nova.core.item.Item; import nova.core.item.ItemBlock; import nova.core.item.ItemFactory; +import nova.core.loader.Mod; import nova.core.nativewrapper.NativeConverter; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; @@ -50,6 +51,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.NovaItem; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; +import nova.internal.core.launch.NovaLauncher; import java.util.LinkedList; import java.util.Objects; @@ -240,7 +242,9 @@ private void registerNOVAItem(ItemFactory itemFactory) { // Don't register ItemBlocks twice if (!(dummy instanceof ItemBlock)) { NovaMinecraft.proxy.registerItem((FWItem) itemWrapper); - String itemId = itemFactory.getID(); // TODO? + String itemId = itemFactory.getID(); + if (!itemId.contains(":")) + itemId = NovaLauncher.instance().flatMap(NovaLauncher::getCurrentMod).map(Mod::id).orElse("nova") + ':' + itemId; GameRegistry.register(itemWrapper, new ResourceLocation(itemId)); if (dummy.components.has(Category.class) && FMLCommonHandler.instance().getSide().isClient()) { From 0ba5b032e40cb9d6e0132066dcf3e7f368128e2c Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 15 Mar 2017 17:52:28 +0100 Subject: [PATCH 43/61] Recipe fixes and utility --- .../forge/v1_11_2/recipes/MinecraftRecipeRegistry.java | 10 +++++----- .../mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java index d720dd32e..a6a855335 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java @@ -73,13 +73,13 @@ public void registerRecipes() { System.out.println("Initialized recipes in " + (System.currentTimeMillis() - startTime) + " ms"); - RecipeSorter.register("nova:shaped", ShapedRecipeBasic.class, Category.SHAPED, "before:forge:shapedore"); - RecipeSorter.register("nova:shaped.oredict", ShapedRecipeOre.class, Category.SHAPED, "after:nova:shaped after:minecraft:shaped before:minecraft:shapeless"); + RecipeSorter.register("nova:shaped", ShapedRecipeBasic.class, Category.SHAPED, "before:forge:shapedore"); + RecipeSorter.register("nova:shaped.oredict", ShapedRecipeOre.class, Category.SHAPED, "after:nova:shaped after:minecraft:shaped before:minecraft:shapeless"); - RecipeSorter.register("nova:shapeless", ShapelessRecipeBasic.class, Category.SHAPELESS, "after:minecraft:shapeless before:forge:shapelessore"); - RecipeSorter.register("nova:shapeless.oredict", ShapelessRecipeOre.class, Category.SHAPELESS, "after:nova:shapeless after:minecraft:shapeless"); + RecipeSorter.register("nova:shapeless", ShapelessRecipeBasic.class, Category.SHAPELESS, "after:minecraft:shapeless before:forge:shapelessore"); + RecipeSorter.register("nova:shapeless.oredict", ShapelessRecipeOre.class, Category.SHAPELESS, "after:nova:shapeless after:minecraft:shapeless"); - RecipeSorter.register("nova:unknown", NovaCraftingRecipe.class, Category.UNKNOWN, ""); + RecipeSorter.register("nova:unknown", NovaCraftingRecipe.class, Category.UNKNOWN, ""); recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java index ee0efe290..692903585 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java @@ -71,4 +71,8 @@ public ItemStack getRecipeOutput() { public NonNullList getRemainingItems(InventoryCrafting inv) { return NonNullList.create(); } + + public CraftingRecipe getRecipe() { + return recipe; + } } From ac264d53d4ab2a77a7dc97bb5224eadac468ea04 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 15 Mar 2017 17:52:49 +0100 Subject: [PATCH 44/61] Item render fixes --- .../forge/v1_11_2/render/RenderUtility.java | 24 +++++++------------ .../wrapper/render/forward/FWEmptyModel.java | 5 ++++ .../render/forward/FWSmartBlockModel.java | 2 +- .../render/forward/FWSmartItemModel.java | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java index 0a086975e..433a82863 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java @@ -42,6 +42,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.IFWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.forward.FWEmptyModel; @@ -192,7 +193,7 @@ public void onModelBakeEvent(ModelBakeEvent event) { if (block.dummy.components.has(StaticRenderer.class)) { event.getModelRegistry().putObject(blockLocation, new FWSmartBlockModel(block.dummy)); } else { - event.getModelRegistry().putObject(blockLocation, new FWEmptyModel()); + event.getModelRegistry().putObject(blockLocation, FWEmptyModel.INSTANCE); } event.getModelRegistry().putObject(itemLocation, new FWSmartBlockModel(block.dummy, dummy)); } @@ -200,20 +201,13 @@ public void onModelBakeEvent(ModelBakeEvent event) { //Register all items Game.items().registry.forEach(itemFactory -> { - Object stackObj = Game.natives().toNative(itemFactory.build()); - if (stackObj instanceof ItemStack) { - Item itemObj = ((ItemStack) stackObj).getItem(); - if (itemObj instanceof FWItem) { - FWItem item = (FWItem) itemObj; - ResourceLocation objRL = Item.REGISTRY.getNameForObject(item); - ModelResourceLocation itemLocation = new ModelResourceLocation(objRL, "inventory"); - - nova.core.item.Item dummy = item.getItemFactory().build(); - - if (dummy.components.has(Renderer.class)) { - event.getModelRegistry().putObject(itemLocation, new FWSmartItemModel(dummy)); - } - } + ItemStack stack = ItemConverter.instance().toNative(itemFactory); + Item itemObj = stack.getItem(); + if (itemObj instanceof FWItem) { + FWItem item = (FWItem) itemObj; + ResourceLocation objRL = Item.REGISTRY.getNameForObject(item); + ModelResourceLocation itemLocation = new ModelResourceLocation(objRL, "inventory"); + event.getModelRegistry().putObject(itemLocation, new FWSmartItemModel(item.getItemFactory().build())); } }); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java index 6bc753c3b..5acdc0d79 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWEmptyModel.java @@ -39,6 +39,11 @@ */ public class FWEmptyModel extends FWSmartModel implements IBakedModel { + /** The singleton instance of an empty model. */ + public static final FWEmptyModel INSTANCE = new FWEmptyModel(); + + private FWEmptyModel() {} + //Item rendering @Override public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 70243542d..226460eee 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -84,7 +84,7 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W return new FWSmartBlockModel(block, item); } - return new FWEmptyModel(); + return FWEmptyModel.INSTANCE; } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index 78059aee7..eba2fcbdb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -71,7 +71,7 @@ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, W return new FWSmartItemModel(item); } - return new FWEmptyModel(); + return FWEmptyModel.INSTANCE; } @Override From bf3c518c6b5b08618db47958ab140416841e143a Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Wed, 15 Mar 2017 17:54:29 +0100 Subject: [PATCH 45/61] Add SLF4J to Log4j bridge to fatJar dependencies --- minecraft/1.11.2/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index d7fe1a678..f60cd19eb 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -16,6 +16,7 @@ dependencies { fatJar project(":") testCompile project(path: ':', configuration: 'wrapperTests') + fatJar 'org.slf4j:slf4j-log4j12:1.7.10' testCompile "junit:junit:4.12" testCompile 'org.assertj:assertj-core:3.0.0' testRuntime 'org.slf4j:slf4j-simple:1.7.10' From cf28661e2f2ceec2c2bc42e9d065c98a21b7f292 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 16 Mar 2017 23:22:35 +0100 Subject: [PATCH 46/61] Improvements to capabilities and world handling --- .../wrapper/block/backward/BWBlock.java | 84 ++++++++-------- .../v1_11_2/wrapper/block/forward/FWTile.java | 28 ++++-- .../block/forward/MCBlockTransform.java | 23 +++++ .../v1_11_2/wrapper/block/world/BWWorld.java | 59 +++++++----- .../wrapper/capability/CapabilityUtil.java | 84 ++++++++++++++++ .../forward/FWCapabilityProvider.java | 24 ++--- .../forward/NovaCapabilityProvider.java | 94 +++++++++++++++--- .../v1_11_2/wrapper/data/DataConverter.java | 23 +++-- .../v1_11_2/wrapper/data/NBTStorable.java | 44 +++++++++ .../wrapper/entity/forward/FWEntity.java | 28 ++++-- .../v1_11_2/wrapper/item/ItemConverter.java | 95 ++++++++----------- .../v1_11_2/wrapper/item/backward/BWItem.java | 29 ++++-- .../wrapper/item/backward/BWItemFactory.java | 23 +++-- .../v1_11_2/wrapper/item/forward/FWItem.java | 16 +++- .../wrapper/item/forward/FWItemBlock.java | 16 +++- .../forward/FWItemCapabilityProvider.java | 65 +++++++++++++ .../v1_11_2/wrapper/item/forward/IFWItem.java | 32 +++++-- .../wrapper/item/forward/NovaItem.java | 14 ++- 18 files changed, 588 insertions(+), 193 deletions(-) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/CapabilityUtil.java create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/NBTStorable.java create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index 89e558790..a81e5c1bd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -27,8 +27,6 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -48,6 +46,11 @@ import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +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.DataConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWBakedModel; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -59,30 +62,30 @@ import java.util.stream.Collectors; public class BWBlock extends Block implements Storable { - private final net.minecraft.block.Block block; + private final IBlockState blockState; @Store private TileEntity mcTileEntity; public BWBlock(net.minecraft.block.Block block) { - this.block = block; + this.blockState = block.getDefaultState(); } @SuppressWarnings("deprecation") - public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { - this.block = block; - + public BWBlock(IBlockState incompleteBlockState, World world, Vector3D pos) { BlockTransform transform = components.add(new BlockTransform()); transform.setWorld(world); transform.setPosition(pos); + incompleteBlockState = incompleteBlockState.getActualState(blockAccess(), blockPos()); + this.blockState = incompleteBlockState.getBlock().getExtendedState(incompleteBlockState, blockAccess(), blockPos()); components.add(new BlockProperty.Opacity().setOpacity(blockState().getMaterial().blocksLight() ? 1 : 0)); BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); SoundType soundType; if (blockAccess() instanceof net.minecraft.world.World) - soundType = block.getSoundType(blockState(), (net.minecraft.world.World)blockAccess(), blockPos(), null); + soundType = block().getSoundType(blockState(), (net.minecraft.world.World) blockAccess(), blockPos(), null); else - soundType = block.getSoundType(); + soundType = block().getSoundType(); if (soundType.getPlaceSound() != null) blockSound.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, @@ -106,31 +109,32 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { return new Cuboid(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); }).setOcclusionBoxes(entity -> { List aabbs = new ArrayList<>(); - blockState().addCollisionBoxToList( - Game.natives().toNative(world()), - blockPos(), - Game.natives().toNative(entity.isPresent() ? entity.get().components.get(Collider.class).boundingBox.get() : Cuboid.ONE.add(pos)), - aabbs, - entity.isPresent() ? Game.natives().toNative(entity.get()) : null, - true - ); + if (blockAccess() instanceof net.minecraft.world.World) + blockState().addCollisionBoxToList( + (net.minecraft.world.World) blockAccess(), + blockPos(), + CuboidConverter.instance().toNative(entity + .flatMap(e -> e.components.getOp(Collider.class)) + .map(c -> c.boundingBox.get()) + .orElseGet(() -> Cuboid.ONE.add(pos))), + aabbs, + entity.map(EntityConverter.instance()::toNative).orElse(null), + true + ); return aabbs.stream() .map(aabb -> (Cuboid) Game.natives().toNova(aabb)) .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }).setSelectionBoxes(entity -> { - AxisAlignedBB bb; + final AxisAlignedBB bb; if (blockAccess() instanceof net.minecraft.world.World) { - @SuppressWarnings("deprecation") - AxisAlignedBB bb1 = block.getSelectedBoundingBox(blockState(), ((net.minecraft.world.World) blockAccess()), blockPos()); - bb = bb1; + bb = block().getSelectedBoundingBox(blockState(), ((net.minecraft.world.World) blockAccess()), blockPos()); } else { bb = blockState().getBoundingBox(blockAccess(), blockPos()).offset(blockPos()); } Cuboid cuboid = Game.natives().toNova(bb); return Collections.singleton(cuboid.subtract(position())); }); - //TODO: Set selection bounds components.add(new StaticRenderer()) .onRender(model -> { switch (blockState().getRenderType()) { @@ -157,21 +161,21 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { }); // TODO: TileEntity rendering using DynamicRenderer - WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, block); + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, block()); Game.events().publish(event); } @Override public ItemFactory getItemFactory() { - return Game.natives().toNova(new ItemStack(Item.getItemFromBlock(block))); + return ItemConverter.instance().toNova(Item.getItemFromBlock(block())); } public net.minecraft.block.Block block() { - return block; + return blockState.getBlock(); } public int meta() { - return block.getMetaFromState(blockState()); + return block().getMetaFromState(blockState()); } public BlockPos blockPos() { @@ -179,15 +183,15 @@ public BlockPos blockPos() { } public IBlockAccess blockAccess() { - return Game.natives().toNative(world()); + return WorldConverter.instance().toNative(world()); } public IBlockState blockState() { - return blockAccess().getBlockState(blockPos()); + return blockState; } public Optional tile() { - if (mcTileEntity == null && block.hasTileEntity(blockState())) { + if (mcTileEntity == null && block().hasTileEntity(blockState())) { mcTileEntity = blockAccess().getTileEntity(blockPos()); } return Optional.ofNullable(mcTileEntity); @@ -195,16 +199,16 @@ public Optional tile() { @Override public boolean canReplace() { - return block.canPlaceBlockAt((net.minecraft.world.World) blockAccess(), blockPos()); + return block().canPlaceBlockAt((net.minecraft.world.World) blockAccess(), blockPos()); } @Override public boolean shouldDisplacePlacement() { - if (block == Blocks.SNOW_LAYER && (blockState().getValue(BlockSnow.LAYERS) < 1)) { + if (block() == Blocks.SNOW_LAYER && (blockState().getValue(BlockSnow.LAYERS) < 1)) { return false; } - if (block == Blocks.VINE || block == Blocks.TALLGRASS || block == Blocks.DEADBUSH || block.isReplaceable(blockAccess(), blockPos())) { + if (block() == Blocks.VINE || block() == Blocks.TALLGRASS || block() == Blocks.DEADBUSH || block().isReplaceable(blockAccess(), blockPos())) { return false; } return super.shouldDisplacePlacement(); @@ -213,31 +217,23 @@ public boolean shouldDisplacePlacement() { @Override public void save(Data data) { Storable.super.save(data); - - tile().ifPresent(tile -> { - NBTTagCompound nbt = new NBTTagCompound(); - tile.writeToNBT(nbt); - data.putAll(Game.natives().toNova(nbt)); - }); + tile().ifPresent(tile -> data.putAll(DataConverter.instance().toNova(tile.serializeNBT()))); } @Override public void load(Data data) { Storable.super.load(data); - - tile().ifPresent(tile -> { - tile.readFromNBT(Game.natives().toNative(data)); - }); + tile().ifPresent(tile -> tile.deserializeNBT(Game.natives().toNative(data))); } @Override public String getLocalizedName() { - return block.getLocalizedName(); + return block().getLocalizedName(); } @Override public String getUnlocalizedName() { - return block.getUnlocalizedName(); + return block().getUnlocalizedName(); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index ce50bc993..1cbece155 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -38,6 +38,7 @@ import nova.core.util.Direction; import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -47,7 +48,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * A Minecraft TileEntity to Nova block wrapper @@ -57,7 +61,7 @@ public class FWTile extends TileEntity implements NovaCapabilityProvider { private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { for (Direction facing : Direction.values()) - capabilities.put(facing, new ConcurrentHashMap<>()); + capabilities.put(facing, new HashMap<>()); } protected String blockID; @@ -133,7 +137,7 @@ public void readFromNBT(NBTTagCompound nbt) { @Override public boolean hasCapabilities() { - return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; + return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).findAny().isPresent(); } @Override @@ -165,14 +169,26 @@ public boolean hasCapability(Capability capability, Direction direction) { .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); } + @Override + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return hasCapability(capability, DirectionConverter.instance().toNova(facing)) || super.hasCapability(capability, facing); + } + @Override @SuppressWarnings("unchecked") - public T getCapability(Capability capability, Direction direction) { - return (T) Optional.of(direction) + public Optional getCapability(Capability capability, Direction direction) { + return Optional.ofNullable((T) Optional.of(direction) .filter(d -> d != Direction.UNKNOWN) .map(capabilities::get) .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); + } + + @Override + @Nullable + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return getCapability(capability, DirectionConverter.instance().toNova(facing)) + .orElseGet(() -> super.getCapability(capability, facing)); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java index 3c4c61f2c..d5b2e6469 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java @@ -20,11 +20,18 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import nova.core.block.Block; import nova.core.component.transform.BlockTransform; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Optional; + /** * @author Calclavia */ @@ -50,15 +57,31 @@ public World world() { return world; } + public IBlockAccess blockAccess() { + return WorldConverter.instance().toNative(world); + } + @Override public void setWorld(World world) { + Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(VectorConverter.instance().toNative(position))); this.world.removeBlock(position); world.setBlock(position, block.getFactory()); + tileEntity.ifPresent(te -> { + te.validate(); // Prevent the removal of the tile entity + net.minecraft.world.World newWorld = Game.natives().toNative(world); + newWorld.setTileEntity(VectorConverter.instance().toNative(position), te); + }); } @Override public void setPosition(Vector3D position) { + Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(VectorConverter.instance().toNative(position))); world.removeBlock(position); world.setBlock(position, block.getFactory()); + tileEntity.ifPresent(te -> { + te.validate(); // Prevent the removal of the tile entity + net.minecraft.world.World world = Game.natives().toNative(this.world); + world.setTileEntity(VectorConverter.instance().toNative(position), te); + }); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java index ebfa0364e..148c7fcfc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java @@ -23,10 +23,14 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import nova.core.block.Block; import nova.core.block.BlockFactory; +import nova.core.component.misc.FactoryProvider; import nova.core.entity.Entity; import nova.core.entity.EntityFactory; import nova.core.item.Item; @@ -34,23 +38,24 @@ import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; 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.MCBlockTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.cuboid.CuboidConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.MCEntityTransform; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Collections; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvent; -import nova.core.component.misc.FactoryProvider; - /** * The backwards world wrapper. * @author Calclavia @@ -64,6 +69,7 @@ public BWWorld(net.minecraft.world.IBlockAccess blockAccess) { public net.minecraft.world.World world() { // Trying to access world from a IBlockAccess object! + // TODO: Return an optional assert access instanceof World; return (net.minecraft.world.World) access; } @@ -85,26 +91,27 @@ public void markChange(Vector3D position) { @Override public Optional getBlock(Vector3D position) { - net.minecraft.block.Block mcBlock = access.getBlockState(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())).getBlock(); - if (mcBlock == null || mcBlock == Blocks.AIR) { + IBlockState blockState = access.getBlockState(new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ())); + net.minecraft.block.Block block = blockState == null ? null : blockState.getBlock(); + if (blockState == null || block == null || block == Blocks.AIR) { Block airBlock = Game.blocks().getAirBlock().build(); airBlock.components.add(new MCBlockTransform(airBlock, this, position)); return Optional.of(airBlock); - } else if (mcBlock instanceof FWBlock) { - return Optional.of(((FWBlock) mcBlock).getBlockInstance(access, position)); + } + if (block instanceof FWBlock) { + return Optional.of(((FWBlock) block).getBlockInstance(access, position)); } else { - BWBlock block = new BWBlock(mcBlock, this, position); - Game.blocks().get(net.minecraft.block.Block.REGISTRY.getNameForObject(mcBlock).toString()) - .ifPresent(blockFactory -> block.components.getOrAdd(new FactoryProvider(blockFactory))); - return Optional.of(block); + BWBlock wrappedBlock = new BWBlock(blockState, this, position); + Game.blocks().get(Objects.toString(net.minecraft.block.Block.REGISTRY.getNameForObject(block))) + .ifPresent(blockFactory -> wrappedBlock.components.getOrAdd(new FactoryProvider(blockFactory))); + return Optional.of(wrappedBlock); } } @Override public boolean setBlock(Vector3D position, BlockFactory blockFactory) { - //TODO: Do not call blockFactory.build() - net.minecraft.block.Block mcBlock = Game.natives().toNative(blockFactory.build()); - BlockPos pos = new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()); + net.minecraft.block.Block mcBlock = BlockConverter.instance().toNative(blockFactory); + BlockPos pos = VectorConverter.instance().toNative(position); net.minecraft.block.Block actualBlock = mcBlock != null ? mcBlock : Blocks.AIR; IBlockState defaultState = actualBlock.getDefaultState(); IBlockState extendedState = actualBlock.getExtendedState(defaultState, world(), pos); @@ -136,17 +143,21 @@ public Entity addClientEntity(Entity entity) { @Override public void removeEntity(Entity entity) { - net.minecraft.entity.Entity wrapper = entity.components.get(MCEntityTransform.class).wrapper; - wrapper.setDead(); - world().removeEntity(wrapper); + if (access instanceof net.minecraft.world.World) { + net.minecraft.entity.Entity wrapper = entity.components.get(MCEntityTransform.class).wrapper; + wrapper.setDead(); + world().removeEntity(wrapper); + } } @Override public Set getEntities(Cuboid bound) { - return world() - .getEntitiesWithinAABB(net.minecraft.entity.Entity.class, new AxisAlignedBB(bound.min.getX(), bound.min.getY(), bound.min.getZ(), bound.max.getX(), bound.max.getY(), bound.max.getZ())) + return Optional.of(access) + .filter(access -> access instanceof net.minecraft.world.World) + .map(access -> world().getEntitiesWithinAABB(net.minecraft.entity.Entity.class, CuboidConverter.instance().toNative(bound))) + .orElseGet(Collections::emptyList) .stream() - .map(mcEnt -> Game.natives().getNative(Entity.class, net.minecraft.entity.Entity.class).toNova(mcEnt)) + .map(EntityConverter.instance()::toNova) .collect(Collectors.toSet()); } @@ -169,6 +180,8 @@ public String getID() { @Override public void playSoundAtPosition(Vector3D position, Sound sound) { - world().playSound(position.getX(), position.getY(), position.getZ(), SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.getID())), SoundCategory.BLOCKS, sound.volume, sound.pitch, true); + world().playSound(position.getX(), position.getY(), position.getZ(), + SoundEvent.REGISTRY.getObject(new ResourceLocation(sound.domain.isEmpty() ? sound.name : sound.getID())), + SoundCategory.BLOCKS, sound.volume, sound.pitch, true); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/CapabilityUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/CapabilityUtil.java new file mode 100644 index 000000000..3b5c5f7cc --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/CapabilityUtil.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.Capability.IStorage; +import nova.core.util.Direction; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; + +import java.util.function.Supplier; + +/** + * @author ExE Boss + */ +public class CapabilityUtil { + + private CapabilityUtil() {} + + /** + * Helper method to easily generate an {@link IStorage} using lambda expressions. + * + * @param The Capability type + * @param The NBT Tag Compound type + * @param writer The Writer + * @param reader The Reader + * @return A new {@link IStorage} instance + */ + public static IStorage createStorage(StorageWriter writer, StorageReader reader) { + return new Capability.IStorage() { + @Override + public NBT writeNBT(Capability capability, T instance, EnumFacing side) { + return writer.writeNBT(capability, instance, DirectionConverter.instance().toNova(side)); + } + + @Override + @SuppressWarnings("unchecked") + public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { + reader.readNBT(capability, instance, DirectionConverter.instance().toNova(side), (NBT) nbt); + } + }; + } + + public static IStorage unsupportedStorage() { + return unsupportedStorage((String) null); + } + + public static IStorage unsupportedStorage(String reason) { + return unsupportedStorage(() -> reason); + } + + public static IStorage unsupportedStorage(Supplier reason) { + return createStorage((capability, instance, side) -> {throw new UnsupportedOperationException(reason.get());}, + (capability, instance, side, nbt) -> {throw new UnsupportedOperationException(reason.get());}); + } + + @FunctionalInterface + public static interface StorageWriter { + NBT writeNBT(Capability capability, T instance, Direction side); + } + + @FunctionalInterface + public static interface StorageReader { + void readNBT(Capability capability, T instance, Direction side, NBT nbt); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java index a34f9a664..7b9accf98 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java @@ -10,9 +10,9 @@ import nova.core.util.EnumSelector; import java.util.EnumMap; +import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; /** * @@ -23,8 +23,8 @@ public class FWCapabilityProvider implements NovaCapabilityProvider { private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); public FWCapabilityProvider() { - for (Direction facing : Direction.values()) - capabilities.put(facing, new ConcurrentHashMap<>()); + for (Direction direction : Direction.values()) + capabilities.put(direction, new HashMap<>()); } @Override @@ -33,18 +33,18 @@ public boolean hasCapabilities() { } @Override - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing.allowsAll()) { + public T addCapability(Capability capability, T capabilityInstance, EnumSelector directions) { + if (directions.allowsAll()) { if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + throw new IllegalArgumentException("Already has capability '" + capabilityInstance.getClass().getSimpleName() + '\''); capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); } else { - facing.forEach(enumFacing -> { - Map, Object> caps = capabilities.get(enumFacing); + directions.forEach(direction -> { + Map, Object> caps = capabilities.get(direction); if (caps.containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); + throw new IllegalArgumentException("Already has capability '" + capabilityInstance.getClass().getSimpleName() + '\''); caps.put(capability, capabilityInstance); }); @@ -63,11 +63,11 @@ public boolean hasCapability(Capability capability, Direction direction) { @Override @SuppressWarnings("unchecked") - public T getCapability(Capability capability, Direction direction) { - return (T) Optional.of(direction) + public Optional getCapability(Capability capability, Direction direction) { + return Optional.ofNullable((T) Optional.of(direction) .filter(d -> d != Direction.UNKNOWN) .map(capabilities::get) .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java index d17c1f35c..49a33c6ec 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java @@ -27,6 +27,8 @@ import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; +import java.util.Optional; +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -36,37 +38,105 @@ public interface NovaCapabilityProvider extends ICapabilityProvider { boolean hasCapabilities(); - default T addCapability(Capability capability, T instance) { + /** + * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. + * + * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. + * + * @param capability The capability to add. + * @param capabilityInstance The capability instance to add. + * @throws IllegalArgumentException if the capability is already present for the direction. + * @returns instance + */ + @Nonnull + default T addCapability(@Nonnull Capability capability, @Nonnull T instance) { return addCapability(capability, instance, Direction.UNKNOWN); } - default T addCapability(Capability capability, T instance, Direction... directions) { + /** + * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. + * + * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. + * + * @param capability The capability to add. + * @param capabilityInstance The capability instance to add. + * @param directions The directions to add the capability to. + * @throws IllegalArgumentException if the capability is already present for the direction. + * @returns instance + */ + @Nonnull + default T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull Direction... directions) { return addCapability(capability, instance, EnumSelector.of(Direction.class).blockAll().apart(directions).lock()); } - - default T addCapability(Capability capability, T instance, Direction direction) { + /** + * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. + * + * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. + * + * @param capability The capability to add. + * @param capabilityInstance The capability instance to add. + * @param direction The direction to add the capability to. + * @throws IllegalArgumentException if the capability is already present for the direction. + * @returns instance + */ + @Nonnull + default T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull Direction direction) { return addCapability(capability, instance, direction == Direction.UNKNOWN ? EnumSelector.of(Direction.class).allowAll().lock() : EnumSelector.of(Direction.class).blockAll().apart(direction).lock()); } + /** + * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. + * + * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. + * + * @param capability The capability to add. + * @param instance The capability instance to add. + * @param directions The directions to add the capability to. + * @throws IllegalArgumentException if the capability is already present for the direction. + * @returns instance + */ + @Nonnull + T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull EnumSelector directions); - T addCapability(Capability capability, T instance, EnumSelector directions); - - boolean hasCapability(Capability capability, Direction direction); + /** + * Determines if this object has support for the capability in question on the specific side. + * The return value of this might change during runtime if this object gains or looses support + * for a capability. + *

+ * Example: + * A Pipe getting a cover placed on one side causing it loose the {@link nova.core.component.inventory.Inventory} attachment function for that side. + * + * @param capability The capability to check + * @param direction The Side to check from: @link nova.core.util.Direction.UNKNOWN UNKNOWN} + * is defined to represent 'internal' or 'self' or used for cases where side doesn't matter. + * @return True if this object supports the capability for this side. + */ + boolean hasCapability(@Nonnull Capability capability, @Nonnull Direction direction); @Override - default boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + default boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { return hasCapability(capability, DirectionConverter.instance().toNova(facing)); } - @Nullable - T getCapability(Capability capability, Direction direction); + /** + * Retrieves the handler for the capability requested on the specific side. + * The return value is {@link Optional#empty()} when the object does not support the capability for the direction. + * The return value can be the same for multiple faces. + *

+ * @param capability The capability to check + * @param direction The Side to check from: @link nova.core.util.Direction.UNKNOWN UNKNOWN} + * is defined to represent 'internal' or 'self' or used for cases where side doesn't matter. + * @return The requested capability. Returns an empty optional when {@link #hasCapability(Capability, EnumFacing)} would return false. + */ + @Nonnull + Optional getCapability(@Nonnull Capability capability, @Nonnull Direction direction); @Override @Nullable - default T getCapability(Capability capability, @Nullable EnumFacing facing) { - return getCapability(capability, DirectionConverter.instance().toNova(facing)); + default T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return getCapability(capability, DirectionConverter.instance().toNova(facing)).orElse(null); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java index 8e4a55ace..6a66fc7f2 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/DataConverter.java @@ -35,7 +35,10 @@ import nova.core.retention.Data; import nova.internal.core.Game; +import java.util.Optional; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Utility that manages common NBT queueSave and load methods @@ -58,18 +61,23 @@ public Class getNativeSide() { } @Override - public Data toNova(NBTTagCompound nbt) { + @Nonnull + public Data toNova(@Nullable NBTTagCompound nbt) { Data data = new Data(); if (nbt != null) { data.className = nbt.getString("class"); Set keys = nbt.getKeySet(); - keys.forEach(k -> data.put(k, load(nbt, k))); + keys.stream() + .filter(k -> k != null && !"class".equals(k)) + .filter(Data.ILLEGAL_SUFFIX.asPredicate().negate()) + .forEach(k -> Optional.ofNullable(load(nbt, k)).ifPresent(v -> data.put(k, v))); } return data; } @Override - public NBTTagCompound toNative(Data data) { + @Nullable + public NBTTagCompound toNative(@Nullable Data data) { if (data == null) { return null; } @@ -77,7 +85,8 @@ public NBTTagCompound toNative(Data data) { return toNative(new NBTTagCompound(), data); } - public NBTTagCompound toNative(NBTTagCompound nbt, Data data) { + @Nonnull + public NBTTagCompound toNative(@Nonnull NBTTagCompound nbt, @Nonnull Data data) { if (data.className != null) { nbt.setString("class", data.className); } @@ -92,7 +101,8 @@ public NBTTagCompound toNative(NBTTagCompound nbt, Data data) { * @param value - the actual object * @return the tag when done saving too i */ - public NBTTagCompound save(NBTTagCompound tag, String key, Object value) { + @Nonnull + public NBTTagCompound save(@Nonnull NBTTagCompound tag, @Nonnull String key, @Nullable Object value) { if (value instanceof Boolean) { tag.setBoolean("isBoolean", true); tag.setBoolean(key, (boolean) value); @@ -127,7 +137,8 @@ public NBTTagCompound save(NBTTagCompound tag, String key, Object value) { * @param key - name of the value * @return object or suggestionValue if nothing is found */ - public Object load(NBTTagCompound tag, String key) { + @Nullable + public Object load(@Nullable NBTTagCompound tag, @Nullable String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/NBTStorable.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/NBTStorable.java new file mode 100644 index 000000000..5df63de31 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/data/NBTStorable.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.data; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.INBTSerializable; +import nova.core.retention.Data; +import nova.core.retention.Storable; + +/** + * @author ExE Boss + */ +public interface NBTStorable extends Storable, INBTSerializable { + + @Override + default NBTTagCompound serializeNBT() { + Data data = new Data(); + save(data); + return DataConverter.instance().toNative(data); + } + + @Override + default void deserializeNBT(NBTTagCompound nbt) { + load(DataConverter.instance().toNova(nbt)); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index 985334f68..ac9f0a0a1 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -38,6 +38,7 @@ import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; @@ -45,7 +46,10 @@ import java.util.EnumMap; import java.util.Map; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Entity wrapper @@ -55,7 +59,7 @@ public class FWEntity extends net.minecraft.entity.Entity implements IEntityAddi private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { for (Direction facing : Direction.values()) - capabilities.put(facing, new ConcurrentHashMap<>()); + capabilities.put(facing, new HashMap<>()); } protected final EntityTransform transform; @@ -234,7 +238,7 @@ public void setDead() { @Override public boolean hasCapabilities() { - return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; + return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).findAny().isPresent(); } @Override @@ -266,13 +270,25 @@ public boolean hasCapability(Capability capability, Direction direction) { .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); } + @Override + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return hasCapability(capability, DirectionConverter.instance().toNova(facing)) || super.hasCapability(capability, facing); + } + @Override @SuppressWarnings("unchecked") - public T getCapability(Capability capability, Direction direction) { - return (T) Optional.of(direction) + public Optional getCapability(Capability capability, Direction direction) { + return Optional.ofNullable((T) Optional.of(direction) .filter(d -> d != Direction.UNKNOWN) .map(capabilities::get) .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability)); + .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); + } + + @Override + @Nullable + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return getCapability(capability, DirectionConverter.instance().toNova(facing)) + .orElseGet(() -> super.getCapability(capability, facing)); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 15c516d11..73aea7d5a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -22,11 +22,7 @@ import com.google.common.collect.HashBiMap; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -44,10 +40,12 @@ import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.CapabilityUtil; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItemFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.IFWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.NovaItem; import nova.internal.core.Game; import nova.internal.core.launch.InitializationException; @@ -57,6 +55,8 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * The main class responsible for wrapping items. @@ -84,23 +84,34 @@ public Class getNativeSide() { return ItemStack.class; } + public ItemFactory toNova(net.minecraft.item.Item item) { + if (item instanceof IFWItem) { + return ((IFWItem) item).getItemFactory(); + } else { + return registerMinecraftMapping(item, 0); + } + } + @Override - public Item toNova(ItemStack stack) { + public Item toNova(@Nonnull ItemStack stack) { return getNovaItem(stack).setCount(stack.getCount()); } - public Item getNovaItem(ItemStack stack) { + public Item getNovaItem(@Nonnull ItemStack stack) { if (stack.getItemDamage() == net.minecraftforge.oredict.OreDictionary.WILDCARD_VALUE) { // TODO: Deal withPriority wildcard meta values - important for the ore dictionary - return getNovaItem(new ItemStack(stack.getItem(), 1, 0)); + ItemStack copy = stack.copy(); + copy.setItemDamage(0); + return getNovaItem(copy); // Preserve capabilities } // Nova FWCapabilityProvider stores capabilities in a HashMap, so we need this to be as fast as possible. + // So I implemented FWItemCapabilityProvider which has a single NovaItem capability field for near-instanteneous access. return Optional.ofNullable(stack.getCapability(NovaItem.CAPABILITY, null)) .map(wrapped -> wrapped.item) .orElseGet(() -> { ItemFactory itemFactory = registerMinecraftMapping(stack.getItem(), stack.getItemDamage()); - Data data = stack.getTagCompound() != null ? Game.natives().toNova(stack.getTagCompound()) : new Data(); + Data data = stack.getTagCompound() != null ? DataConverter.instance().toNova(stack.getTagCompound()) : new Data(); if (!stack.getHasSubtypes() && stack.getItemDamage() > 0) { data.put("damage", stack.getItemDamage()); } @@ -109,7 +120,7 @@ public Item getNovaItem(ItemStack stack) { } @Override - public ItemStack toNative(Item item) { + public ItemStack toNative(@Nullable Item item) { if (item == null) { return ItemStack.EMPTY; } @@ -118,35 +129,32 @@ public ItemStack toNative(Item item) { if (item instanceof BWItem) { return ((BWItem) item).makeItemStack(item.count()); } else { - ItemFactory itemFactory = Game.items().get(item.getID()).get();// TODO? - MinecraftItemMapping mapping = get(itemFactory); + MinecraftItemMapping mapping = get(item.getFactory()); if (mapping == null) { - throw new InitializationException("Missing mapping for " + itemFactory.getID()); + throw new InitializationException("Missing mapping for " + item.getID()); } nativeConversion.push(item); return new ItemStack(mapping.item, item.count(), mapping.meta); } } - public ItemStack toNative(ItemFactory itemFactory) { + public ItemStack toNative(@Nonnull ItemFactory itemFactory) { + Objects.requireNonNull(itemFactory); MinecraftItemMapping mapping = get(itemFactory); if (mapping == null) { throw new InitializationException("Missing mapping for " + itemFactory.getID()); } - + if (!(itemFactory instanceof BWItemFactory)) + nativeConversion.push(itemFactory.build()); return new ItemStack(mapping.item, 1, mapping.meta); } public ItemStack toNative(String id) { - return toNative(Game.items().get(id).get()); + return Game.items().get(id).map(this::toNative).get(); } public Optional popNativeConversion() { - if (nativeConversion.isEmpty()) { - return Optional.empty(); - } else { - return Optional.of(nativeConversion.pop()); - } + return Optional.ofNullable(nativeConversion.poll()); } public MinecraftItemMapping get(ItemFactory item) { @@ -186,19 +194,9 @@ public void preInit(FMLPreInitializationEvent evt) { } private void registerCapabilities() { - CapabilityManager.INSTANCE.register(NovaItem.class, new IStorage() { - @Override - public NBTBase writeNBT(Capability capability, NovaItem instance, EnumFacing side) { - throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); - } - - @Override - public void readNBT(Capability capability, NovaItem instance, EnumFacing side, NBTBase nbt) { - throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); - } - }, () -> { - throw new UnsupportedOperationException("The `NovaItem` Capability is an internal NOVA API"); - }); + CapabilityManager.INSTANCE.register(NovaItem.class, CapabilityUtil.createStorage( + (capability, instance, side) -> instance.serializeNBT(), + (capability, instance, side, nbt) -> instance.deserializeNBT(nbt)), () -> null); } private void registerNOVAItemsToMinecraft() { @@ -311,38 +309,25 @@ private ItemFactory registerMinecraftMapping(net.minecraft.item.Item item, int m * Used to map MC items and their meta to nova item factories. */ public final class MinecraftItemMapping { - public final net.minecraft.item.Item item; - public final int meta; + @Nonnull public final net.minecraft.item.Item item; + @Nonnull public final int meta; - public MinecraftItemMapping(net.minecraft.item.Item item, int meta) { + public MinecraftItemMapping(@Nonnull net.minecraft.item.Item item, int meta) { this.item = item; this.meta = item.getHasSubtypes() ? meta : 0; } - public MinecraftItemMapping(ItemStack itemStack) { + public MinecraftItemMapping(@Nonnull ItemStack itemStack) { this.item = itemStack.getItem(); this.meta = itemStack.getHasSubtypes() ? itemStack.getItemDamage() : 0; } @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - MinecraftItemMapping that = (MinecraftItemMapping) o; - - if (meta != that.meta) { - return false; - } - if (!item.equals(that.item)) { - return false; - } - - return true; + public boolean equals(Object other) { + if (this == other) return true; + if (other == null || getClass() != other.getClass()) return false; + return (meta == ((MinecraftItemMapping) other).meta + && item.equals(((MinecraftItemMapping) other).item)); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java index f1403e7e7..fffdf5d64 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItem.java @@ -26,25 +26,31 @@ import nova.core.component.renderer.StaticRenderer; import nova.core.item.Item; import nova.core.retention.Storable; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.IFWItem; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.render.backward.BWBakedModel; +import java.util.Optional; + /** * @author Stan * @since 3/02/2015. */ +// TODO: Make this class into a wrapper around an ItemStack instance. public class BWItem extends Item implements Storable { private final net.minecraft.item.Item item; private final int meta; private final NBTTagCompound tag; + private final NBTTagCompound caps; public BWItem(ItemStack itemStack) { - this(itemStack.getItem(), itemStack.getHasSubtypes() ? itemStack.getItemDamage() : 0, itemStack.getTagCompound()); + this(itemStack.getItem(), itemStack.getHasSubtypes() ? itemStack.getItemDamage() : 0, itemStack.getTagCompound(), itemStack.serializeNBT().getCompoundTag("ForgeCaps")); } - public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag) { + public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag, NBTTagCompound caps) { this.item = item; this.meta = meta; - this.tag = tag; + this.tag = tag; + this.caps = caps; components.add(new StaticRenderer()) .onRender(model -> { @@ -61,14 +67,18 @@ public int getMeta() { return meta; } - public NBTTagCompound getTag() { - return tag; + public Optional getTag() { + return Optional.ofNullable(tag); + } + + public Optional getCaps() { + return Optional.ofNullable(caps); } public ItemStack makeItemStack(int stackSize) { - ItemStack result = new ItemStack(item, stackSize, meta); + ItemStack result = new ItemStack(item, stackSize, meta, caps); if (tag != null) { - result.deserializeNBT(tag); + result.setTagCompound(tag); } return result; } @@ -83,6 +93,11 @@ public String getUnlocalizedName() { return this.item.getUnlocalizedName(makeItemStack(count())); } + @Override + public int getMaxCount() { + return this.item.getItemStackLimit(makeItemStack(count())); + } + @Override public String toString() { return getID(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java index 935587385..3996caa6a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/backward/BWItemFactory.java @@ -26,6 +26,7 @@ import nova.core.item.ItemFactory; import nova.core.retention.Data; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; /** @@ -38,7 +39,7 @@ public class BWItemFactory extends ItemFactory { private final int meta; public BWItemFactory(net.minecraft.item.Item item, int meta) { - super(net.minecraft.item.Item.REGISTRY.getNameForObject(item) + (item.getHasSubtypes() ? ":" + meta : ""), () -> new BWItem(item, meta, null)); + super(net.minecraft.item.Item.REGISTRY.getNameForObject(item) + (item.getHasSubtypes() ? ":" + meta : ""), () -> new BWItem(item, meta, null, null)); this.item = item; this.meta = meta; @@ -59,9 +60,15 @@ public String getUnlocalizedName() { @Override public Item build(Data data) { - int meta = (Integer) data.getOrDefault("damage", this.meta); - NBTTagCompound nbtData = Game.natives().toNative(data); - BWItem bwItem = new BWItem(item, meta, nbtData); + final int meta = (Integer) data.getOrDefault("damage", this.meta); + final NBTTagCompound capsData = DataConverter.instance().toNative(data.get("forgeCaps")); + final NBTTagCompound nbtData; + if (data.containsKey("tag")) + nbtData = DataConverter.instance().toNative(data.get("tag")); + else + nbtData = DataConverter.instance().toNative(data); + + BWItem bwItem = new BWItem(item, meta, nbtData, capsData); bwItem.components.add(new FactoryProvider(this)); WrapperEvent.BWItemCreate event = new WrapperEvent.BWItemCreate(bwItem, item); Game.events().publish(event); @@ -76,11 +83,9 @@ public Data save(Item item) { BWItem mcItem = (BWItem) item; - Data result = mcItem.getTag() != null ? Game.natives().toNova(mcItem.getTag()) : new Data(); - if (result == null) { - result = new Data(); - } - + Data result = new Data(); + mcItem.getTag().map(DataConverter.instance()::toNova).ifPresent(caps -> result.put("tag", caps)); + mcItem.getCaps().map(DataConverter.instance()::toNova).ifPresent(caps -> result.put("forgeCaps", caps)); if (mcItem.getMeta() != meta) { result.put("damage", mcItem.getMeta()); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java index 91931de64..647062133 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItem.java @@ -75,18 +75,28 @@ public ActionResult onItemRightClick(World world, EntityPlayer player return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); } + @Override + public int getItemStackLimit(ItemStack stack) { + return IFWItem.super.getItemStackLimit(stack); + } + @Override public String getUnlocalizedName() { - return getItemFactory().getUnlocalizedName(); + return IFWItem.super.getUnlocalizedName(); + } + + @Override + public String getLocalizedName() { + return IFWItem.super.getLocalizedName(); } @Override public String getUnlocalizedName(ItemStack stack) { - return ItemConverter.instance().toNova(stack).getUnlocalizedName(); + return IFWItem.super.getUnlocalizedName(stack); } @Override public String getItemStackDisplayName(ItemStack stack) { - return ItemConverter.instance().toNova(stack).getLocalizedName(); + return IFWItem.super.getItemStackDisplayName(stack); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java index 3483096fc..d3b5ce067 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemBlock.java @@ -72,18 +72,28 @@ public ActionResult onItemRightClick(World world, EntityPlayer player return IFWItem.super.onItemRightClick(player.getHeldItem(hand), world, player); } + @Override + public int getItemStackLimit(ItemStack stack) { + return IFWItem.super.getItemStackLimit(stack); + } + @Override public String getUnlocalizedName() { - return getItemFactory().getUnlocalizedName(); + return IFWItem.super.getUnlocalizedName(); + } + + @Override + public String getLocalizedName() { + return IFWItem.super.getLocalizedName(); } @Override public String getUnlocalizedName(ItemStack stack) { - return ItemConverter.instance().toNova(stack).getUnlocalizedName(); + return IFWItem.super.getUnlocalizedName(stack); } @Override public String getItemStackDisplayName(ItemStack stack) { - return ItemConverter.instance().toNova(stack).getLocalizedName(); + return IFWItem.super.getItemStackDisplayName(stack); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java new file mode 100644 index 000000000..9c472b11d --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward; + +import net.minecraftforge.common.capabilities.Capability; +import nova.core.item.Item; +import nova.core.util.Direction; +import nova.core.util.EnumSelector; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; + +import java.util.Optional; + +/** + * @author ExE Boss + */ +public class FWItemCapabilityProvider extends FWCapabilityProvider { + + private final NovaItem item; + + public FWItemCapabilityProvider(Item item) { + this.item = new NovaItem(item); + } + + @Override + public boolean hasCapabilities() { + return true; + } + + @Override + public T addCapability(Capability capability, T capabilityInstance, EnumSelector directions) { + if (capability == NovaItem.CAPABILITY) + throw new IllegalArgumentException("Already has capability 'NovaItem'"); + return super.addCapability(capability, capabilityInstance, directions); + } + + @Override + public boolean hasCapability(Capability capability, Direction direction) { + return capability == NovaItem.CAPABILITY || super.hasCapability(capability, direction); + } + + @Override + @SuppressWarnings("unchecked") + public Optional getCapability(Capability capability, Direction direction) { + if (capability == NovaItem.CAPABILITY) + return Optional.of((T) item); + return super.getCapability(capability, direction); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java index f827e869c..b43d997df 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java @@ -28,7 +28,9 @@ import net.minecraft.world.World; import nova.core.item.Item; import nova.core.item.ItemFactory; +import nova.core.language.Translateable; import nova.core.util.Direction; +import nova.core.util.math.MathUtil; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; @@ -38,21 +40,21 @@ import java.util.List; import java.util.Optional; + import javax.annotation.Nullable; /** * An interface implemented by {@link FWItem} and {@link FWItemBlock} classes to override Minecraft's item events. * @author Calclavia */ -public interface IFWItem { +public interface IFWItem extends Translateable { ItemFactory getItemFactory(); @Nullable default FWCapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { - Item item = ItemConverter.instance().popNativeConversion().orElseGet(() -> ItemConverter.instance().toNova(stack)); - WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWCapabilityProvider()); - event.capabilityProvider.addCapability(NovaItem.CAPABILITY, new NovaItem(item)); + Item item = ItemConverter.instance().popNativeConversion().orElseGet(() -> ItemConverter.instance().getNovaItem(stack)); + WrapperEvent.FWItemInitCapabilities event = new WrapperEvent.FWItemInitCapabilities(item, new FWItemCapabilityProvider(item)); Game.events().publish(event); return event.capabilityProvider; } @@ -77,7 +79,25 @@ default ActionResult onItemRightClick(ItemStack itemStack, World worl return new ActionResult<>(EnumActionResult.PASS, ItemConverter.instance().updateMCItemStack(itemStack, item)); } - default int getColorFromItemStack(ItemStack itemStack, int renderPass) { - return ItemConverter.instance().toNova(itemStack).colorMultiplier().argb(); + default int getItemStackLimit(ItemStack stack) { + return MathUtil.max(ItemConverter.instance().toNova(stack).getMaxCount(), 64); + } + + @Override + default String getUnlocalizedName() { + return getItemFactory().getUnlocalizedName(); + } + + @Override + default String getLocalizedName() { + return getItemFactory().getLocalizedName(); + } + + default String getUnlocalizedName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getUnlocalizedName(); + } + + default String getItemStackDisplayName(ItemStack stack) { + return ItemConverter.instance().toNova(stack).getLocalizedName(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java index 40b9b1937..8f7d5516a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/NovaItem.java @@ -22,13 +22,15 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import nova.core.item.Item; +import nova.core.retention.Data; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.NBTStorable; /** * Internal NOVA capability used to make NOVA items persistent. * * @author ExE Boss */ -public class NovaItem { +public class NovaItem implements NBTStorable { @CapabilityInject(NovaItem.class) public static Capability CAPABILITY = null; @@ -37,4 +39,14 @@ public class NovaItem { public NovaItem(Item item) { this.item = item; } + + @Override + public void save(Data data) { + item.save(data); + } + + @Override + public void load(Data data) { + item.load(data); + } } From a22add763e8a271bbad23b7bb0ad9ddabf581ca9 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 17 Mar 2017 23:59:04 +0100 Subject: [PATCH 47/61] Move the block's associated TileEntity on block move --- .../wrapper/block/backward/BWBlock.java | 16 +-- .../block/backward/BWBlockTransform.java | 98 +++++++++++++++++++ .../wrapper/block/forward/FWBlock.java | 29 +++--- ...ckTransform.java => FWBlockTransform.java} | 28 ++++-- .../v1_11_2/wrapper/block/forward/FWTile.java | 12 +-- .../block/forward/TEBlockTransform.java | 75 ++++++++++++++ .../v1_11_2/wrapper/block/world/BWWorld.java | 4 +- 7 files changed, 217 insertions(+), 45 deletions(-) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/{MCBlockTransform.java => FWBlockTransform.java} (79%) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index a81e5c1bd..cc32d40c9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -71,13 +71,9 @@ public BWBlock(net.minecraft.block.Block block) { } @SuppressWarnings("deprecation") - public BWBlock(IBlockState incompleteBlockState, World world, Vector3D pos) { - BlockTransform transform = components.add(new BlockTransform()); - transform.setWorld(world); - transform.setPosition(pos); - incompleteBlockState = incompleteBlockState.getActualState(blockAccess(), blockPos()); - this.blockState = incompleteBlockState.getBlock().getExtendedState(incompleteBlockState, blockAccess(), blockPos()); - + public BWBlock(IBlockState blockState, World world, Vector3D pos) { + this.blockState = blockState; + components.add(new BWBlockTransform(this, world, pos)); components.add(new BlockProperty.Opacity().setOpacity(blockState().getMaterial().blocksLight() ? 1 : 0)); BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); @@ -187,7 +183,11 @@ public IBlockAccess blockAccess() { } public IBlockState blockState() { - return blockState; + if (!components.has(BlockTransform.class)) + return blockState; + + IBlockState actualState = blockState.getActualState(blockAccess(), blockPos()); + return actualState.getBlock().getExtendedState(actualState, blockAccess(), blockPos()); } public Optional tile() { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java new file mode 100644 index 000000000..5432d03b6 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import nova.core.component.transform.BlockTransform; +import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +import java.util.Optional; + +/** + * @author ExE Boss + */ +public class BWBlockTransform extends BlockTransform { + + private final BWBlock block; + private World world; + private Vector3D position; + + public BWBlockTransform(BWBlock block, World world, Vector3D position) { + this.block = block; + this.world = world; + this.position = position; + } + + @Override + public Vector3D position() { + return position; + } + + @Override + public World world() { + return world; + } + + public BlockPos blockPos() { + return VectorConverter.instance().toNative(position); + } + + public IBlockAccess blockAccess() { + return WorldConverter.instance().toNative(world); + } + + @Override + public void setWorld(World world) { + BlockPos pos = blockPos(); + net.minecraft.world.World oldWorld = Game.natives().toNative(this.world); + net.minecraft.world.World newWorld = Game.natives().toNative(world); + Optional tileEntity = Optional.ofNullable(oldWorld.getTileEntity(pos)); + newWorld.setBlockState(pos, block.blockState()); + if (tileEntity.isPresent()) { + newWorld.setTileEntity(pos, tileEntity.get()); + tileEntity.get().setWorld(newWorld); + } else { + newWorld.setTileEntity(pos, null); + } + oldWorld.setBlockToAir(pos); + } + + @Override + public void setPosition(Vector3D position) { + BlockPos oldPos = blockPos(); + BlockPos newPos = VectorConverter.instance().toNative(position); + net.minecraft.world.World world = Game.natives().toNative(this.world); + Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(oldPos)); + world.setBlockState(newPos, block.blockState()); + if (tileEntity.isPresent()) { + world.setTileEntity(newPos, tileEntity.get()); + tileEntity.get().setPos(newPos); + } else { + world.setTileEntity(newPos, null); + } + world.setBlockToAir(oldPos); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index da8cc06ed..4a2829da5 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -23,7 +23,6 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -55,10 +54,10 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -113,7 +112,10 @@ public FWBlock(BlockFactory factory) { // Recalculate super constructor things after loading the block properly this.fullBlock = getDefaultState().isOpaqueCube(); - this.lightOpacity = this.fullBlock ? 255 : 0; + this.lightOpacity = dummy.components + .getOp(BlockProperty.Opacity.class) + .map(o -> MathUtil.clamp((int) Math.round(o.opacity * 255), 0, 255)) + .orElse(this.fullBlock ? 255 : 0); this.translucent = !this.fullBlock; } @@ -145,7 +147,7 @@ public Block getBlockInstance(IBlockAccess access, Vector3D position) { private Block getBlockInstance(nova.core.world.World world, Vector3D position) { // TODO: Implement obj args Block block = factory.build(); - block.components.add(new MCBlockTransform(block, world, position)); + block.components.add(new FWBlockTransform(block, world, position)); if (!block.components.has(BlockProperty.BlockSound.class)) { BlockProperty.BlockSound properties = block.components.add(new BlockProperty.BlockSound()); properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound(SoundType.STONE.getBreakSound().getSoundName().getResourceDomain(), SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); @@ -182,27 +184,24 @@ public List getDrops(IBlockAccess world, BlockPos pos, IBlockState st Block.DropEvent event = new Block.DropEvent(blockInstance); blockInstance.events.publish(event); - return new ArrayList<>( - event.drops - .stream() - .map(item -> (ItemStack) Game.natives().toNative(item)) - .collect(Collectors.toCollection(ArrayList::new)) - ); + return event.drops + .stream() + .map(ItemConverter.instance()::toNative) + .collect(Collectors.toList()); } @Override public boolean hasTileEntity(IBlockState state) { // A block requires a TileEntity if it stores data or if it ticks. - return Storable.class.isAssignableFrom(blockClass) || Stateful.class.isAssignableFrom(blockClass) || Updater.class.isAssignableFrom(blockClass); + return Storable.class.isAssignableFrom(blockClass) || + Stateful.class.isAssignableFrom(blockClass) || + Updater.class.isAssignableFrom(blockClass); } @Override public TileEntity createTileEntity(World world, IBlockState state) { FWTile fwTile = FWTileLoader.loadTile(dummy.getID()); - if (lastExtendedStatePos != null) { - fwTile.getBlock().components.getOrAdd(new MCBlockTransform(dummy, Game.natives().toNova(world), new Vector3D(lastExtendedStatePos.getX(), lastExtendedStatePos.getY(), lastExtendedStatePos.getZ()))); - lastExtendedStatePos = null; - } + fwTile.getBlock().components.getOrAdd(new TEBlockTransform(fwTile)); if (!fwTile.getBlock().components.has(BlockProperty.BlockSound.class)) { BlockProperty.BlockSound properties = fwTile.getBlock().components.add(new BlockProperty.BlockSound()); properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound(SoundType.STONE.getBreakSound().getSoundName().getResourceDomain(), SoundType.STONE.getBreakSound().getSoundName().getResourcePath())); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java similarity index 79% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java index d5b2e6469..5393dd85c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/MCBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java @@ -21,6 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import nova.core.block.Block; import nova.core.component.transform.BlockTransform; @@ -35,13 +36,13 @@ /** * @author Calclavia */ -public class MCBlockTransform extends BlockTransform { +public class FWBlockTransform extends BlockTransform { public final Block block; public final World world; public final Vector3D position; - public MCBlockTransform(Block block, World world, Vector3D position) { + public FWBlockTransform(Block block, World world, Vector3D position) { this.block = block; this.world = world; this.position = position; @@ -57,31 +58,38 @@ public World world() { return world; } + public BlockPos blockPos() { + return VectorConverter.instance().toNative(position); + } + public IBlockAccess blockAccess() { return WorldConverter.instance().toNative(world); } @Override public void setWorld(World world) { - Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(VectorConverter.instance().toNative(position))); - this.world.removeBlock(position); + BlockPos pos = blockPos(); + Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(pos)); world.setBlock(position, block.getFactory()); tileEntity.ifPresent(te -> { - te.validate(); // Prevent the removal of the tile entity net.minecraft.world.World newWorld = Game.natives().toNative(world); - newWorld.setTileEntity(VectorConverter.instance().toNative(position), te); + newWorld.setTileEntity(pos, te); + te.setWorld(newWorld); }); + this.world.removeBlock(position); } @Override public void setPosition(Vector3D position) { - Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(VectorConverter.instance().toNative(position))); - world.removeBlock(position); + BlockPos oldPos = blockPos(); + BlockPos newPos = VectorConverter.instance().toNative(position); + Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(oldPos)); world.setBlock(position, block.getFactory()); tileEntity.ifPresent(te -> { - te.validate(); // Prevent the removal of the tile entity net.minecraft.world.World world = Game.natives().toNative(this.world); - world.setTileEntity(VectorConverter.instance().toNative(position), te); + world.setTileEntity(newPos, te); + te.setPos(newPos); }); + world.removeBlock(this.position); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index 1cbece155..fdbe8b5b0 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -94,7 +94,7 @@ public SPacketUpdateTileEntity getUpdatePacket() { @Override public void validate() { super.validate(); - block.components.getOrAdd(new MCBlockTransform(block, Game.natives().toNova(getWorld()), new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + block.components.getOrAdd(new TEBlockTransform(this)); if (cacheData != null && block instanceof Storable) { ((Storable) block).load(cacheData); @@ -191,18 +191,10 @@ public T getCapability(@Nonnull Capability capability, @Nullable EnumFaci .orElseGet(() -> super.getCapability(capability, facing)); } - @Override - public void setPos(BlockPos pos) { - super.setPos(pos); - if (block.components.has(MCBlockTransform.class)) - block.components.remove(MCBlockTransform.class); - block.components.add(new MCBlockTransform(block, Game.natives().toNova(this.getWorld()), Game.natives().toNova(this.getPos()))); - } - private static class FWPacketUpdateTileEntity extends SPacketUpdateTileEntity { private final Packet packet; - public FWPacketUpdateTileEntity(Packet packet, BlockPos blockPosIn, int metadataIn, NBTTagCompound compoundIn) { + private FWPacketUpdateTileEntity(Packet packet, BlockPos blockPosIn, int metadataIn, NBTTagCompound compoundIn) { super(blockPosIn, metadataIn, compoundIn); this.packet = packet; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java new file mode 100644 index 000000000..923bd53aa --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; + +import net.minecraft.util.math.BlockPos; +import nova.core.component.transform.BlockTransform; +import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.internal.core.Game; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; + +/** + * @author ExE Boss + */ +public class TEBlockTransform extends BlockTransform { + + private final FWTile tileEntity; + + public TEBlockTransform(FWTile tileEntity) { + this.tileEntity = tileEntity; + } + + @Override + public Vector3D position() { + return VectorConverter.instance().toNova(tileEntity.getPos()); + } + + @Override + public World world() { + return WorldConverter.instance().toNova(tileEntity.getWorld()); + } + + public net.minecraft.world.World mcWorld() { + return tileEntity.getWorld(); + } + + @Override + public void setWorld(nova.core.world.World world) { + nova.core.world.World originalWorld = world(); + Vector3D originalPosition = position(); + world.setBlock(position(), tileEntity.block.getFactory()); + net.minecraft.world.World mcWorld = Game.natives().toNative(world); + mcWorld.setTileEntity(tileEntity.getPos(), tileEntity); + tileEntity.setWorld(mcWorld); + originalWorld.removeBlock(originalPosition); + } + + @Override + public void setPosition(Vector3D position) { + Vector3D originalPosition = position(); + world().setBlock(position, tileEntity.block.getFactory()); + BlockPos newPos = VectorConverter.instance().toNative(position); + mcWorld().setTileEntity(newPos, tileEntity); + tileEntity.setPos(newPos); + world().removeBlock(originalPosition); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java index 148c7fcfc..87fcf906f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java @@ -42,7 +42,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; 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.MCBlockTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlockTransform; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.cuboid.CuboidConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; @@ -95,7 +95,7 @@ public Optional getBlock(Vector3D position) { net.minecraft.block.Block block = blockState == null ? null : blockState.getBlock(); if (blockState == null || block == null || block == Blocks.AIR) { Block airBlock = Game.blocks().getAirBlock().build(); - airBlock.components.add(new MCBlockTransform(airBlock, this, position)); + airBlock.components.add(new FWBlockTransform(airBlock, this, position)); return Optional.of(airBlock); } if (block instanceof FWBlock) { From 353ed4a825adc84c937300d01d080a136a78cc96 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 7 Apr 2017 21:27:48 +0200 Subject: [PATCH 48/61] Implement BWBlockFactory --- .../mc/forge/v1_11_2/asm/StaticForwarder.java | 36 +++++++++++++++---- .../forge/v1_11_2/render/RenderUtility.java | 4 +-- .../v1_11_2/wrapper/block/BlockConverter.java | 34 +++++++++--------- .../block/backward/BWBlockFactory.java | 32 +++++++++++++++++ 4 files changed, 79 insertions(+), 27 deletions(-) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index e83ef43cc..cc5f751db 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -26,12 +26,19 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; +import nova.core.block.Block; +import nova.core.component.misc.FactoryProvider; import nova.core.event.BlockEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; +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.FWTileLoader; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Objects; + /** * Static forwarder forwards injected methods. * @author Calclavia @@ -41,14 +48,29 @@ public class StaticForwarder { private StaticForwarder() {} public static void chunkSetBlockEvent(Chunk chunk, BlockPos pos, IBlockState oldBlockState, IBlockState newBlockState) { + nova.core.world.World world = WorldConverter.instance().toNova(chunk.getWorld()); + Vector3D position = new Vector3D((chunk.xPosition << 4) + pos.getX(), pos.getY(), (chunk.zPosition << 4) + pos.getZ()); + Block oldBlockInstance; + Block newBlockInstance; + + if (oldBlockState.getBlock() instanceof FWBlock) { + oldBlockInstance = ((FWBlock) oldBlockState.getBlock()).getFactory().build(); + } else { + oldBlockInstance = new BWBlock(oldBlockState, world, position); + Game.blocks().get(Objects.toString(net.minecraft.block.Block.REGISTRY.getNameForObject(oldBlockState.getBlock()))) + .ifPresent(blockFactory -> oldBlockInstance.components.getOrAdd(new FactoryProvider(blockFactory))); + } + + if (newBlockState.getBlock() instanceof FWBlock) { + newBlockInstance = ((FWBlock) newBlockState.getBlock()).getFactory().build(); + } else { + newBlockInstance = new BWBlock(newBlockState, world, position); + Game.blocks().get(Objects.toString(net.minecraft.block.Block.REGISTRY.getNameForObject(newBlockState.getBlock()))) + .ifPresent(blockFactory -> newBlockInstance.components.getOrAdd(new FactoryProvider(blockFactory))); + } + // Publish the event - Game.events().publish( - new BlockEvent.Change( - Game.natives().toNova(chunk.getWorld()), - new Vector3D((chunk.xPosition << 4) + pos.getX(), pos.getY(), (chunk.zPosition << 4) + pos.getZ()), - Game.natives().toNova(oldBlockState.getBlock()), Game.natives().toNova(newBlockState.getBlock()) - ) - ); + Game.events().publish(new BlockEvent.Change(world, position, oldBlockInstance, newBlockInstance)); } /** diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java index 433a82863..2892d995c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/render/RenderUtility.java @@ -35,12 +35,12 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import nova.core.component.renderer.Renderer; import nova.core.component.renderer.StaticRenderer; import nova.core.item.ItemFactory; import nova.core.render.texture.Texture; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.assets.AssetConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.BlockConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItem; @@ -180,7 +180,7 @@ private void updateTexureDimensions(Texture texture) { public void onModelBakeEvent(ModelBakeEvent event) { //Register all blocks Game.blocks().registry.forEach(blockFactory -> { - Object blockObj = Game.natives().toNative(blockFactory.build()); + Object blockObj = BlockConverter.instance().toNative(blockFactory); if (blockObj instanceof FWBlock) { FWBlock block = (FWBlock) blockObj; ResourceLocation blockRL = net.minecraft.block.Block.REGISTRY.getNameForObject(block); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index 500aba7af..d8981fa89 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -20,6 +20,8 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -38,32 +40,32 @@ import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlockFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.forward.FWItemBlock; import nova.internal.core.Game; import nova.internal.core.launch.NovaLauncher; import java.util.Arrays; -import java.util.HashMap; import java.util.Optional; /** * @author Calclavia */ //TODO: Should be -public class BlockConverter implements NativeConverter, ForgeLoadable { +public class BlockConverter implements NativeConverter, ForgeLoadable { /** * A map of all blockFactory to MC blocks registered */ - public final HashMap blockFactoryMap = new HashMap<>(); + public final BiMap blockFactoryMap = HashBiMap.create(); public static BlockConverter instance() { - return Game.natives().getNative(Block.class, net.minecraft.block.Block.class); + return Game.natives().getNative(BlockFactory.class, net.minecraft.block.Block.class); } @Override - public Class getNovaSide() { - return Block.class; + public Class getNovaSide() { + return BlockFactory.class; } @Override @@ -72,20 +74,19 @@ public Class getNativeSide() { } @Override - public Block toNova(net.minecraft.block.Block nativeBlock) { + public BlockFactory toNova(net.minecraft.block.Block nativeBlock) { //Prevent recursive wrapping if (nativeBlock instanceof FWBlock) { - return ((FWBlock) nativeBlock).dummy; + return ((FWBlock) nativeBlock).getFactory(); } if (nativeBlock == Blocks.AIR) { - return Game.blocks().getAirBlock().build(); + return Game.blocks().getAirBlock(); } - return new BWBlock(nativeBlock); + return blockFactoryMap.inverse().get(nativeBlock); } - @Override public net.minecraft.block.Block toNative(Block novaBlock) { //Prevent recursive wrapping if (novaBlock instanceof BWBlock) { @@ -95,12 +96,15 @@ public net.minecraft.block.Block toNative(Block novaBlock) { return toNative(novaBlock.getFactory()); } + @Override public net.minecraft.block.Block toNative(BlockFactory blockFactory) { return blockFactoryMap.get(blockFactory); } /** * Register all Nova blocks + * + * @param evt The Minecraft Forge pre-initialization event */ @Override public void preInit(FMLPreInitializationEvent evt) { @@ -111,13 +115,7 @@ public void preInit(FMLPreInitializationEvent evt) { private void registerMinecraftToNOVA() { //TODO: Will this register ALL Forge mod blocks as well? BlockManager blockManager = Game.blocks(); - net.minecraft.block.Block.REGISTRY.forEach(block -> - blockManager.register( - new BlockFactory(net.minecraft.block.Block.REGISTRY.getNameForObject(block).toString(), - () -> new BWBlock(block), evt -> { - }) - ) - ); + net.minecraft.block.Block.REGISTRY.forEach(block -> blockManager.register(new BWBlockFactory(block))); } private void registerNOVAToMinecraft() { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java new file mode 100644 index 000000000..fa1497f7c --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . + */ +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward; + +import nova.core.block.BlockFactory; + +/** + * @author ExE Boss + */ +public class BWBlockFactory extends BlockFactory { + + public BWBlockFactory(net.minecraft.block.Block block) { + super(net.minecraft.block.Block.REGISTRY.getNameForObject(block).toString(), () -> new BWBlock(block), factory -> {}); + } +} From 8684f32118fbe17b1ed2813d3e26a11f876f8bc1 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 7 Apr 2017 21:27:48 +0200 Subject: [PATCH 49/61] Capability Wrapper Rework --- .../mc/forge/v1_11_2/util/WrapperEvent.java | 21 ++++ .../wrapper/block/backward/BWBlock.java | 30 ++++++ .../v1_11_2/wrapper/block/forward/FWTile.java | 71 +++++------- .../forward/FWCapabilityProvider.java | 101 ++++++++++-------- .../forward/NovaCapabilityProvider.java | 65 ----------- .../wrapper/entity/forward/FWEntity.java | 69 +++++------- .../forward/FWItemCapabilityProvider.java | 14 +-- 7 files changed, 159 insertions(+), 212 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java index a7bf3fc63..7af5fd6a0 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapperEvent.java @@ -21,7 +21,9 @@ package nova.core.wrapper.mc.forge.v1_11_2.util; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.capabilities.ICapabilityProvider; import nova.core.block.Block; +import nova.core.component.Component; import nova.core.entity.Entity; import nova.core.event.BlockEvent; import nova.core.event.bus.CancelableEvent; @@ -37,7 +39,10 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.backward.BWItem; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Collections; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; /** * Events for wrappers to hook into @@ -143,4 +148,20 @@ public FWEntityCreate(Entity novaEntity, FWEntity mcEntity) { this.mcEntity = mcEntity; } } + + public static class CapabilityToComponent extends Event { + public final ICapabilityProvider capabilities; + public final Class component; + public final Set defaultInstances; + public final Set instances; + public final Direction direction; + + public CapabilityToComponent(ICapabilityProvider capabilities, Class component, Set defaultInstances, Direction direction) { + this.capabilities = capabilities; + this.component = component; + this.defaultInstances = Collections.unmodifiableSet(defaultInstances); + this.instances = new HashSet<>(); + this.direction = direction; + } + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index cc32d40c9..8e6d0d0fb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -35,6 +35,10 @@ import nova.core.block.Block; import nova.core.block.component.BlockProperty; import nova.core.block.component.LightEmitter; +import nova.core.component.Component; +import nova.core.component.fluid.FluidConsumer; +import nova.core.component.fluid.FluidHandler; +import nova.core.component.fluid.FluidProvider; import nova.core.component.misc.Collider; import nova.core.component.renderer.StaticRenderer; import nova.core.component.transform.BlockTransform; @@ -43,6 +47,7 @@ import nova.core.retention.Storable; import nova.core.retention.Store; import nova.core.sound.Sound; +import nova.core.util.Direction; import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; @@ -59,6 +64,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; public class BWBlock extends Block implements Storable { @@ -161,6 +167,30 @@ public BWBlock(IBlockState blockState, World world, Vector3D pos) { Game.events().publish(event); } + @SuppressWarnings("unchecked") + private Set getSidedComponent(Class component, Set instances, Direction direction) { + if (!tile().isPresent()) { + return Collections.emptySet(); + } + + if (FluidProvider.class.isAssignableFrom(component) || + FluidConsumer.class.isAssignableFrom(component) || + FluidHandler.class.isAssignableFrom(component)) { +// return (Set) tile() +// .map(t -> t.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, DirectionConverter.instance().toNative(direction))) +// .map(BWFluidHandler::new) +// .map(Collections::singleton) +// .orElse(Collections.emptySet()); + } else { // TODO: Add Support for inventories + WrapperEvent.CapabilityToComponent event = new WrapperEvent.CapabilityToComponent<>(tile().get(), component, instances, direction); + Game.events().publish(event); + if (!event.instances.isEmpty()) + return event.instances; + } + + return Collections.emptySet(); + } + @Override public ItemFactory getItemFactory() { return ItemConverter.instance().toNova(Item.getItemFromBlock(block())); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index fdbe8b5b0..a24cd3e43 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -30,26 +30,21 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.items.CapabilityItemHandler; import nova.core.block.Block; import nova.core.block.Stateful; import nova.core.network.Syncable; import nova.core.retention.Data; import nova.core.retention.Storable; import nova.core.util.Direction; -import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; import nova.internal.core.Game; -import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.io.IOException; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; -import java.util.HashMap; - import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -59,11 +54,6 @@ */ public class FWTile extends TileEntity implements NovaCapabilityProvider { - private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { - for (Direction facing : Direction.values()) - capabilities.put(facing, new HashMap<>()); - } - protected String blockID; protected Block block; protected Data cacheData = null; @@ -136,37 +126,18 @@ public void readFromNBT(NBTTagCompound nbt) { } @Override - public boolean hasCapabilities() { - return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).findAny().isPresent(); - } - - @Override - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing.allowsAll()) { - if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - - capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); - } else { - facing.forEach(enumFacing -> { - Map, Object> caps = capabilities.get(enumFacing); - - if (caps.containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - - caps.put(capability, capabilityInstance); - }); + public boolean hasCapability(Capability capability, Direction direction) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return +// block.components.has(FluidProvider.class, direction) || +// block.components.has(FluidConsumer.class, direction) || +// block.components.has(FluidHandler.class, direction) || +// block instanceof SidedTankProvider; + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return false; // TODO: implement } - return capabilityInstance; - } - @Override - public boolean hasCapability(Capability capability, Direction direction) { - return Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.containsValue(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); + return false; } @Override @@ -177,11 +148,19 @@ public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFa @Override @SuppressWarnings("unchecked") public Optional getCapability(Capability capability, Direction direction) { - return Optional.ofNullable((T) Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return (Optional) Optional.of(new FWFluidHandler( +// block.components.getOp(FluidProvider.class, direction), +// block.components.getOp(FluidConsumer.class, direction), +// block.components.getOp(FluidHandler.class, direction), +// Optional.of(block) +// .filter(b -> b instanceof SidedTankProvider) +// .map(b -> (SidedTankProvider) b), direction)).filter(FWFluidHandler::isPresent); + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return Optional.empty(); // TODO: implement + } + + return Optional.empty(); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java index 7b9accf98..0758a19f3 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/FWCapabilityProvider.java @@ -1,17 +1,32 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright (c) 2015 NOVA, All rights reserved. + * 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. + * + * NOVA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NOVA. If not, see . */ + package nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.items.CapabilityItemHandler; +import nova.core.component.ComponentProvider; +import nova.core.component.SidedComponentMap; import nova.core.util.Direction; -import nova.core.util.EnumSelector; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; import java.util.Optional; /** @@ -20,54 +35,50 @@ */ public class FWCapabilityProvider implements NovaCapabilityProvider { - private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); + private final ComponentProvider componentProvider; - public FWCapabilityProvider() { - for (Direction direction : Direction.values()) - capabilities.put(direction, new HashMap<>()); + public FWCapabilityProvider(ComponentProvider componentProvider) { + this.componentProvider = componentProvider; } @Override - public boolean hasCapabilities() { - return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).count() > 0; - } - - @Override - public T addCapability(Capability capability, T capabilityInstance, EnumSelector directions) { - if (directions.allowsAll()) { - if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) - throw new IllegalArgumentException("Already has capability '" + capabilityInstance.getClass().getSimpleName() + '\''); - - capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); - } else { - directions.forEach(direction -> { - Map, Object> caps = capabilities.get(direction); - - if (caps.containsKey(capability)) - throw new IllegalArgumentException("Already has capability '" + capabilityInstance.getClass().getSimpleName() + '\''); - - caps.put(capability, capabilityInstance); - }); + public boolean hasCapability(Capability capability, Direction direction) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return +// getComponent(FluidProvider.class, direction).isPresent() || +// getComponent(FluidConsumer.class, direction).isPresent() || +// getComponent(FluidHandler.class, direction).isPresent() || +// componentProvider instanceof SidedTankProvider; + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return false; // TODO: implement } - return capabilityInstance; - } - @Override - public boolean hasCapability(Capability capability, Direction direction) { - return Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.containsValue(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); + return false; } @Override @SuppressWarnings("unchecked") public Optional getCapability(Capability capability, Direction direction) { - return Optional.ofNullable((T) Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return (Optional) Optional.of(new FWFluidHandler( +// getComponent(FluidProvider.class, direction), +// getComponent(FluidConsumer.class, direction), +// getComponent(FluidHandler.class, direction), +// Optional.of(componentProvider) +// .filter(p -> p instanceof SidedTankProvider) +// .map(p -> (SidedTankProvider) p), direction)).filter(FWFluidHandler::isPresent); + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return Optional.empty(); // TODO: implement + } + + return Optional.empty(); + } + + private Optional getComponent(Class component, Direction direction) { + if (componentProvider.components instanceof SidedComponentMap) { + return ((SidedComponentMap) componentProvider.components).getOp(component, direction); + } else { + return componentProvider.components.getOp(component); + } } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java index 49a33c6ec..3ee9c6371 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java @@ -36,71 +36,6 @@ */ public interface NovaCapabilityProvider extends ICapabilityProvider { - boolean hasCapabilities(); - - /** - * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. - * - * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. - * - * @param capability The capability to add. - * @param capabilityInstance The capability instance to add. - * @throws IllegalArgumentException if the capability is already present for the direction. - * @returns instance - */ - @Nonnull - default T addCapability(@Nonnull Capability capability, @Nonnull T instance) { - return addCapability(capability, instance, Direction.UNKNOWN); - } - - /** - * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. - * - * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. - * - * @param capability The capability to add. - * @param capabilityInstance The capability instance to add. - * @param directions The directions to add the capability to. - * @throws IllegalArgumentException if the capability is already present for the direction. - * @returns instance - */ - @Nonnull - default T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull Direction... directions) { - return addCapability(capability, instance, EnumSelector.of(Direction.class).blockAll().apart(directions).lock()); - } - - /** - * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. - * - * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. - * - * @param capability The capability to add. - * @param capabilityInstance The capability instance to add. - * @param direction The direction to add the capability to. - * @throws IllegalArgumentException if the capability is already present for the direction. - * @returns instance - */ - @Nonnull - default T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull Direction direction) { - return addCapability(capability, instance, direction == Direction.UNKNOWN ? - EnumSelector.of(Direction.class).allowAll().lock() : - EnumSelector.of(Direction.class).blockAll().apart(direction).lock()); - } - - /** - * Internal NOVA method. Used by wrappers to add wrapper specific capabilities. - * - * Ex. NOVA-Energy adds wrappers for EnergyStorage component -> IEnergyStorage capability. - * - * @param capability The capability to add. - * @param instance The capability instance to add. - * @param directions The directions to add the capability to. - * @throws IllegalArgumentException if the capability is already present for the direction. - * @returns instance - */ - @Nonnull - T addCapability(@Nonnull Capability capability, @Nonnull T instance, @Nonnull EnumSelector directions); - /** * Determines if this object has support for the capability in question on the specific side. * The return value of this might change during runtime if this object gains or looses support diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index ac9f0a0a1..1f6da4560 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -25,7 +25,9 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; +import net.minecraftforge.items.CapabilityItemHandler; import nova.core.block.Stateful; import nova.core.component.Updater; import nova.core.component.misc.Collider; @@ -35,7 +37,6 @@ import nova.core.retention.Data; import nova.core.retention.Storable; import nova.core.util.Direction; -import nova.core.util.EnumSelector; import nova.core.util.shape.Cuboid; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; @@ -43,25 +44,18 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; -import java.util.EnumMap; -import java.util.Map; import java.util.Optional; -import java.util.HashMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; + /** * Entity wrapper * @author Calclavia */ public class FWEntity extends net.minecraft.entity.Entity implements IEntityAdditionalSpawnData, NovaCapabilityProvider { - private final EnumMap, Object>> capabilities = new EnumMap<>(Direction.class); { - for (Direction facing : Direction.values()) - capabilities.put(facing, new HashMap<>()); - } - protected final EntityTransform transform; protected Entity wrapped; boolean firstTick = true; @@ -237,37 +231,18 @@ public void setDead() { } @Override - public boolean hasCapabilities() { - return capabilities.values().parallelStream().map(map -> map.keySet().parallelStream()).findAny().isPresent(); - } - - @Override - public T addCapability(Capability capability, T capabilityInstance, EnumSelector facing) { - if (facing.allowsAll()) { - if (capabilities.get(Direction.UNKNOWN).containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - - capabilities.get(Direction.UNKNOWN).put(capability, capabilityInstance); - } else { - facing.forEach(enumFacing -> { - Map, Object> caps = capabilities.get(enumFacing); - - if (caps.containsKey(capability)) - throw new IllegalArgumentException("Already has capability " + capabilityInstance.getClass()); - - caps.put(capability, capabilityInstance); - }); + public boolean hasCapability(Capability capability, Direction direction) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return +// wrapped.components.has(FluidProvider.class) || +// wrapped.components.has(FluidConsumer.class) || +// wrapped.components.has(FluidHandler.class) || +// wrapped instanceof SidedTankProvider; + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return false; // TODO: implement } - return capabilityInstance; - } - @Override - public boolean hasCapability(Capability capability, Direction direction) { - return Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.containsValue(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).containsValue(capability)); + return false; } @Override @@ -278,11 +253,19 @@ public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFa @Override @SuppressWarnings("unchecked") public Optional getCapability(Capability capability, Direction direction) { - return Optional.ofNullable((T) Optional.of(direction) - .filter(d -> d != Direction.UNKNOWN) - .map(capabilities::get) - .map(caps -> caps.get(capability)) - .orElseGet(() -> capabilities.get(Direction.UNKNOWN).get(capability))); + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { +// return (Optional) Optional.of(new FWFluidHandler( +// wrapped.components.getOp(FluidProvider.class), +// wrapped.components.getOp(FluidConsumer.class), +// wrapped.components.getOp(FluidHandler.class), +// Optional.of(wrapped) +// .filter(e -> e instanceof SidedTankProvider) +// .map(e -> (SidedTankProvider) e), direction)).filter(FWFluidHandler::isPresent); + } else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return Optional.empty(); // TODO: implement + } + + return Optional.empty(); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java index 9c472b11d..129640ca1 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/FWItemCapabilityProvider.java @@ -22,7 +22,6 @@ import net.minecraftforge.common.capabilities.Capability; import nova.core.item.Item; import nova.core.util.Direction; -import nova.core.util.EnumSelector; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.FWCapabilityProvider; import java.util.Optional; @@ -35,21 +34,10 @@ public class FWItemCapabilityProvider extends FWCapabilityProvider { private final NovaItem item; public FWItemCapabilityProvider(Item item) { + super(item); this.item = new NovaItem(item); } - @Override - public boolean hasCapabilities() { - return true; - } - - @Override - public T addCapability(Capability capability, T capabilityInstance, EnumSelector directions) { - if (capability == NovaItem.CAPABILITY) - throw new IllegalArgumentException("Already has capability 'NovaItem'"); - return super.addCapability(capability, capabilityInstance, directions); - } - @Override public boolean hasCapability(Capability capability, Direction direction) { return capability == NovaItem.CAPABILITY || super.hasCapability(capability, direction); From 39905d6f40d430f7a037130bdc865b7b0fe57ddf Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 20 Apr 2017 23:41:20 +0200 Subject: [PATCH 50/61] Refactor `recipes` package --- minecraft/1.11.2/build.gradle | 2 +- .../forge/v1_11_2/launcher/NovaMinecraft.java | 2 +- .../recipes/MinecraftItemIngredient.java | 34 ------------------- .../v1_11_2/wrapper/item/forward/IFWItem.java | 5 ++- .../recipes/MinecraftRecipeRegistry.java | 7 +++- .../recipes/RecipeConverter.java | 8 ++++- .../recipes/backward}/MCCraftingGrid.java | 2 +- .../recipes/backward}/MCCraftingRecipe.java | 3 +- .../recipes/forward}/NovaCraftingGrid.java | 2 +- .../forward}/NovaCraftingGridContainer.java | 2 +- .../recipes/forward}/NovaCraftingRecipe.java | 3 +- .../recipes/forward}/ShapedRecipeBasic.java | 3 +- .../recipes/forward}/ShapedRecipeOre.java | 3 +- .../forward}/ShapelessRecipeBasic.java | 3 +- .../recipes/forward}/ShapelessRecipeOre.java | 3 +- .../wrapper/render/backward/BWBakedModel.java | 20 ++--------- 16 files changed, 35 insertions(+), 67 deletions(-) delete mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{ => wrapper}/recipes/MinecraftRecipeRegistry.java (94%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{ => wrapper}/recipes/RecipeConverter.java (94%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/backward}/MCCraftingGrid.java (99%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/backward}/MCCraftingRecipe.java (92%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/NovaCraftingGrid.java (94%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/NovaCraftingGridContainer.java (95%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/NovaCraftingRecipe.java (93%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/ShapedRecipeBasic.java (92%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/ShapedRecipeOre.java (93%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/ShapelessRecipeBasic.java (93%) rename minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/{recipes => wrapper/recipes/forward}/ShapelessRecipeOre.java (92%) diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index f60cd19eb..fe98abd66 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -108,7 +108,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20170313' + mappings = 'snapshot_20170407' runDir = "run" } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 26ac85b80..664568c96 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -45,7 +45,6 @@ import nova.core.wrapper.mc.forge.v1_11_2.depmodules.NetworkModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.SaveModule; import nova.core.wrapper.mc.forge.v1_11_2.depmodules.TickerModule; -import nova.core.wrapper.mc.forge.v1_11_2.recipes.MinecraftRecipeRegistry; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; @@ -58,6 +57,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.inventory.InventoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.OreDictionaryIntegration; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.MinecraftRecipeRegistry; import nova.internal.core.Game; import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; import nova.internal.core.deps.DepDownloader; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java deleted file mode 100644 index 24d414695..000000000 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftItemIngredient.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015 NOVA, All rights reserved. - * 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. - * - * NOVA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with NOVA. If not, see . - */ - -package nova.core.wrapper.mc.forge.v1_11_2.recipes; - -import nova.core.item.Item; -import nova.core.recipes.ingredient.SpecificItemIngredient; -import nova.internal.core.Game; - -/** - * @author Stan Hebben - */ -public class MinecraftItemIngredient extends SpecificItemIngredient { - public MinecraftItemIngredient(net.minecraft.item.ItemStack itemStack) { - super(((Item) Game.natives().toNova(itemStack)).getID()); - } -} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java index b43d997df..af5dad82c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/forward/IFWItem.java @@ -28,7 +28,7 @@ import net.minecraft.world.World; import nova.core.item.Item; import nova.core.item.ItemFactory; -import nova.core.language.Translateable; +import nova.core.language.Translatable; import nova.core.util.Direction; import nova.core.util.math.MathUtil; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; @@ -40,14 +40,13 @@ import java.util.List; import java.util.Optional; - import javax.annotation.Nullable; /** * An interface implemented by {@link FWItem} and {@link FWItemBlock} classes to override Minecraft's item events. * @author Calclavia */ -public interface IFWItem extends Translateable { +public interface IFWItem extends Translatable { ItemFactory getItemFactory(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java similarity index 94% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java index a6a855335..a19095c67 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; @@ -28,6 +28,11 @@ import nova.core.recipes.RecipeManager; import nova.core.recipes.crafting.CraftingRecipe; import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeBasic; import nova.internal.core.Game; import java.util.AbstractList; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java similarity index 94% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java index fd0cd08e2..b63fb6e42 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/RecipeConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -34,6 +34,12 @@ import nova.core.recipes.crafting.ShapelessCraftingRecipe; import nova.core.recipes.ingredient.SpecificItemIngredient; import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingRecipe; import nova.internal.core.Game; import java.util.ArrayList; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java similarity index 99% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java index f5407beff..cc797a309 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java @@ -19,7 +19,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java similarity index 92% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java index 3602be3e5..9a6c11d53 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/MCCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java @@ -18,12 +18,13 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward; import net.minecraft.item.crafting.IRecipe; import nova.core.item.Item; import nova.core.recipes.crafting.CraftingGrid; import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingGrid; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java similarity index 94% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java index 89cff4d2d..81debde99 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import nova.core.recipes.crafting.CraftingGrid; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGridContainer.java similarity index 95% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGridContainer.java index 2cd66dac7..97580928d 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingGridContainer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGridContainer.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java similarity index 93% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java index 692903585..d83870e26 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/NovaCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -27,6 +27,7 @@ import net.minecraft.world.World; import nova.core.item.Item; import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java similarity index 92% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java index 7a11e97a9..dad784e58 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java @@ -18,13 +18,14 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.world.World; import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java similarity index 93% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java index 0a55e71eb..a1ec778af 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapedRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java @@ -24,7 +24,7 @@ * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -32,6 +32,7 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import nova.core.item.Item; import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java similarity index 93% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java index a5714e309..9589fbef2 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java @@ -24,7 +24,7 @@ * and open the template in the editor. */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -32,6 +32,7 @@ import net.minecraft.world.World; import nova.core.item.Item; import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; import nova.internal.core.Game; import java.util.Arrays; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java similarity index 92% rename from minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java rename to minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java index a883827cd..537fb2e77 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/recipes/ShapelessRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java @@ -18,7 +18,7 @@ * along with NOVA. If not, see . */ -package nova.core.wrapper.mc.forge.v1_11_2.recipes; +package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -26,6 +26,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; import nova.core.item.Item; import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; import nova.internal.core.Game; import java.util.Optional; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java index 53bc4c632..ae212ac73 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/backward/BWBakedModel.java @@ -53,7 +53,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; - import javax.annotation.Nullable; /** @@ -187,13 +186,11 @@ public Face quadToFace(BakedQuad quad) { ((byte)((mergedNormal >> 16) & 0xFF)) / 127D)); } -// if (format.hasNormal()) -// vertex.normal = normal; + if (format.hasNormal()) + vertex.normal = normal; face.drawVertex(vertex); } - java.util.function.BinaryOperator cartesianProduct = Vector3DUtil::cartesianProduct; -// face.normal = Vector3DUtil.calculateNormal(face); - face.normal = calculateNormal(face); + face.normal = Vector3DUtil.calculateNormal(face); return face; } @@ -204,15 +201,4 @@ private double deinterpolateU(double u, Optional texture) { private double deinterpolateV(double v, Optional texture) { return 1 - v; // Why do you change the format with every version, Mojang? } - - private static Vector3D calculateNormal(Face face) { - // TODO: Possibly calculate from vertex normals - Vertex firstEntry = face.vertices.get(0); - Vertex secondEntry = face.vertices.get(1); - Vertex thirdEntry = face.vertices.get(2); - Vector3D v1 = secondEntry.vec.subtract(firstEntry.vec); - Vector3D v2 = thirdEntry.vec.subtract(firstEntry.vec); - - return v1.crossProduct(v2).normalize(); - } } From 4a5ae77bc909bda463eff0d42f6bc8bb21105352 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 20 Apr 2017 23:46:10 +0200 Subject: [PATCH 51/61] Port recipe changes from `recipes/finish-crafting-implementation` --- .../forge/v1_11_2/launcher/NovaMinecraft.java | 3 +- .../recipes/MinecraftRecipeRegistry.java | 63 +++++--- .../wrapper/recipes/RecipeConverter.java | 138 ++++++++++-------- .../recipes/backward/MCCraftingGrid.java | 120 ++++++++------- .../recipes/backward/MCCraftingRecipe.java | 28 +++- .../recipes/forward/NovaCraftingGrid.java | 63 ++++++++ .../recipes/forward/NovaCraftingRecipe.java | 32 +--- .../recipes/forward/ShapedRecipeBasic.java | 13 +- .../recipes/forward/ShapedRecipeOre.java | 14 +- .../recipes/forward/ShapelessRecipeBasic.java | 19 +-- .../recipes/forward/ShapelessRecipeOre.java | 14 +- 11 files changed, 288 insertions(+), 219 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 664568c96..23cb2279f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -22,7 +22,6 @@ package nova.core.wrapper.mc.forge.v1_11_2.launcher; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.ModMetadata; import net.minecraftforge.fml.common.ProgressManager; @@ -58,6 +57,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.OreDictionaryIntegration; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.MinecraftRecipeRegistry; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.RecipeConverter; import nova.internal.core.Game; import nova.internal.core.bootstrap.DependencyInjectionEntryPoint; import nova.internal.core.deps.DepDownloader; @@ -140,6 +140,7 @@ public void preInit(FMLPreInitializationEvent evt) { Game.natives().registerConverter(new DirectionConverter()); Game.natives().registerConverter(new CategoryConverter()); Game.natives().registerConverter(new AssetConverter()); + Game.natives().registerConverter(new RecipeConverter()); /** * Initiate recipe and ore dictionary integration diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java index a19095c67..374c51332 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java @@ -20,29 +20,30 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes; +import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.oredict.RecipeSorter; -import net.minecraftforge.oredict.RecipeSorter.Category; import nova.core.event.RecipeEvent; +import nova.core.item.Item; import nova.core.recipes.RecipeManager; import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.recipes.ingredient.ItemIngredient; +import nova.core.recipes.smelting.SmeltingRecipe; import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingRecipe; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeBasic; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import java.util.AbstractList; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Optional; import java.util.Spliterator; import java.util.function.Consumer; import java.util.stream.Stream; @@ -64,6 +65,7 @@ public void registerRecipes() { RecipeManager recipeManager = Game.recipes(); + @SuppressWarnings("unchecked") List recipes = CraftingManager.getInstance().getRecipeList(); for (IRecipe recipe : recipes) { CraftingRecipe converted = convert(recipe); @@ -78,28 +80,24 @@ public void registerRecipes() { System.out.println("Initialized recipes in " + (System.currentTimeMillis() - startTime) + " ms"); - RecipeSorter.register("nova:shaped", ShapedRecipeBasic.class, Category.SHAPED, "before:forge:shapedore"); - RecipeSorter.register("nova:shaped.oredict", ShapedRecipeOre.class, Category.SHAPED, "after:nova:shaped after:minecraft:shaped before:minecraft:shapeless"); - - RecipeSorter.register("nova:shapeless", ShapelessRecipeBasic.class, Category.SHAPELESS, "after:minecraft:shapeless before:forge:shapelessore"); - RecipeSorter.register("nova:shapeless.oredict", ShapelessRecipeOre.class, Category.SHAPELESS, "after:nova:shapeless after:minecraft:shapeless"); - - RecipeSorter.register("nova:unknown", NovaCraftingRecipe.class, Category.UNKNOWN, ""); - recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); + + recipeManager.whenRecipeAdded(SmeltingRecipe.class, this::onNOVASmeltingAdded); + recipeManager.whenRecipeRemoved(SmeltingRecipe.class, this::onNOVASmeltingRemoved); } private CraftingRecipe convert(IRecipe recipe) { - return RecipeConverter.toNova(recipe); + return RecipeConverter.instance().toNova(recipe); } private IRecipe convert(CraftingRecipe recipe) { - return RecipeConverter.toMinecraft(recipe); + return RecipeConverter.instance().toNative(recipe); } - private void onNOVARecipeAdded(RecipeEvent.Add e) { - CraftingRecipe recipe = e.recipe; + @SuppressWarnings("unchecked") + private void onNOVARecipeAdded(RecipeEvent.Add evt) { + CraftingRecipe recipe = evt.recipe; if (forwardWrappers.containsKey(recipe)) { return; } @@ -112,10 +110,10 @@ private void onNOVARecipeAdded(RecipeEvent.Add e) { CraftingManager.getInstance().getRecipeList().add(minecraftRecipe); } - private void onNOVARecipeRemoved(RecipeEvent.Remove e) { - IRecipe minecraftRecipe = forwardWrappers.get(e.recipe); + private void onNOVARecipeRemoved(RecipeEvent.Remove evt) { + IRecipe minecraftRecipe = forwardWrappers.get(evt.recipe); - forwardWrappers.remove(e.recipe); + forwardWrappers.remove(evt.recipe); backwardWrappers.remove(minecraftRecipe); CraftingManager.getInstance().getRecipeList().remove(minecraftRecipe); @@ -143,6 +141,27 @@ private void onMinecraftRecipeRemoved(IRecipe recipe) { Game.recipes().removeRecipe(novaRecipe); } + private void onNOVASmeltingAdded(RecipeEvent.Add evt) { + SmeltingRecipe recipe = evt.recipe; + + Collection inputs = recipe.getInput().map(ItemIngredient::getExampleItems).orElse(Collections.emptyList()); + + final Optional output = recipe.getExampleOutput().map(ItemConverter.instance()::toNative); + if (!output.isPresent()) + return; + + inputs.stream().map(ItemConverter.instance()::toNative).forEach(input -> FurnaceRecipes.instance().addSmeltingRecipe(input, output.get(), 0)); + } + + private void onNOVASmeltingRemoved(RecipeEvent.Remove evt) { + SmeltingRecipe recipe = evt.recipe; + + Collection inputs = recipe.getInput().map(ItemIngredient::getExampleItems).orElse(Collections.emptyList()); + @SuppressWarnings("unchecked") + Map smeltingList = FurnaceRecipes.instance().getSmeltingList(); + inputs.stream().map(ItemConverter.instance()::toNative).forEach(input -> smeltingList.remove(input)); + } + private class RecipeListWrapper extends AbstractList { private final List original; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java index b63fb6e42..1b555e354 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/RecipeConverter.java @@ -20,6 +20,8 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingGrid; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; @@ -27,25 +29,26 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import nova.core.item.Item; +import nova.core.item.ItemFactory; +import nova.core.nativewrapper.NativeConverter; import nova.core.recipes.crafting.CraftingRecipe; -import nova.core.recipes.ingredient.ItemIngredient; -import nova.core.recipes.ingredient.OreItemIngredient; import nova.core.recipes.crafting.ShapedCraftingRecipe; import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.recipes.ingredient.ItemIngredient; +import nova.core.recipes.ingredient.OreItemIngredient; import nova.core.recipes.ingredient.SpecificItemIngredient; import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingRecipe; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeBasic; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; import nova.internal.core.Game; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.Optional; /** @@ -59,15 +62,26 @@ * given the proper information and be informed of their registration, if desired. * @author Stan Hebben */ -public class RecipeConverter { +public class RecipeConverter implements NativeConverter { public static final int TYPE_ADVANCED = 0; public static final int TYPE_ORE = 1; public static final int TYPE_BASIC = 2; - private RecipeConverter() { + public static RecipeConverter instance() { + return Game.natives().getNative(CraftingRecipe.class, IRecipe.class); + } + + @Override + public Class getNovaSide() { + return CraftingRecipe.class; } - private static int getIngredientType(ItemIngredient ingredient) { + @Override + public Class getNativeSide() { + return IRecipe.class; + } + + private int getIngredientType(ItemIngredient ingredient) { if (ingredient instanceof SpecificItemIngredient) { return TYPE_BASIC; } else if (ingredient instanceof OreItemIngredient) { @@ -77,7 +91,7 @@ private static int getIngredientType(ItemIngredient ingredient) { } } - private static Object getInternal(ItemIngredient ingredient) { + private Object getInternal(ItemIngredient ingredient) { if (ingredient instanceof SpecificItemIngredient) { return wrapSpecific((SpecificItemIngredient) ingredient); } else if (ingredient instanceof OreItemIngredient) { @@ -87,16 +101,15 @@ private static Object getInternal(ItemIngredient ingredient) { return null; } - private static ItemIngredient getIngredient(Object ingredient) { + private ItemIngredient getIngredient(Object ingredient) { if (ingredient == null) { return null; } else if (ingredient instanceof ItemStack) { - return ((ItemStack) ingredient).isEmpty() ? null : ItemIngredient.forItem(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(((ItemStack) ingredient).getItem()))); + return new SpecificItemIngredient(ItemConverter.instance().toNova((ItemStack) ingredient).getID()); } else if (ingredient instanceof String) { - return ItemIngredient.forDictionary((String) ingredient); + return new OreItemIngredient((String) ingredient); } else if (ingredient instanceof List) { - @SuppressWarnings("unchecked") - String oreDictEntry = findOreDictEntryFor((List) ingredient); + String oreDictEntry = findOreDictEntryFor((List) ingredient); if (oreDictEntry == null) { return null; } @@ -107,7 +120,7 @@ private static ItemIngredient getIngredient(Object ingredient) { } } - private static String findOreDictEntryFor(List ingredient) { + private String findOreDictEntryFor(List ingredient) { for (String key : net.minecraftforge.oredict.OreDictionary.getOreNames()) { if (net.minecraftforge.oredict.OreDictionary.getOres(key).equals(ingredient)) { return key; @@ -117,15 +130,15 @@ private static String findOreDictEntryFor(List ingredient) { return null; } - private static ItemStack wrapSpecific(SpecificItemIngredient ingredient) { + private ItemStack wrapSpecific(SpecificItemIngredient ingredient) { for (Item item : ingredient.getExampleItems()) { - return Game.natives().toNative(item.getFactory().build()); + return ItemConverter.instance().toNative(item.getFactory()); } throw new AssertionError("this can't be!"); } - private static int getRecipeType(ItemIngredient[] ingredients) { + private int getRecipeType(ItemIngredient[] ingredients) { int type = TYPE_BASIC; for (ItemIngredient ingredient : ingredients) { type = Math.min(type, getIngredientType(ingredient)); @@ -133,41 +146,18 @@ private static int getRecipeType(ItemIngredient[] ingredients) { return type; } - public static IRecipe toMinecraft(CraftingRecipe recipe) { + @Override + public IRecipe toNative(CraftingRecipe recipe) { if (recipe instanceof ShapedCraftingRecipe) { - return convert((ShapedCraftingRecipe) recipe); + return toNative((ShapedCraftingRecipe) recipe); } else if (recipe instanceof ShapelessCraftingRecipe) { - return convert((ShapelessCraftingRecipe) recipe); + return toNative((ShapelessCraftingRecipe) recipe); } else { return new NovaCraftingRecipe(recipe); } } - public static IRecipe convert(ShapelessCraftingRecipe recipe) { - ItemIngredient[] ingredients = recipe.getIngredients(); - int type = getRecipeType(ingredients); - - switch (type) { - case TYPE_BASIC: { - ItemStack[] items = new ItemStack[ingredients.length]; - for (int i = 0; i < ingredients.length; i++) { - items[i] = wrapSpecific((SpecificItemIngredient) ingredients[i]); - } - return new ShapelessRecipeBasic(items, recipe); - } - case TYPE_ORE: { - Object[] items = new Object[ingredients.length]; - for (int i = 0; i < ingredients.length; i++) { - items[i] = getInternal(ingredients[i]); - } - return new ShapelessRecipeOre(items, recipe); - } - default: - return new NovaCraftingRecipe(recipe); - } - } - - public static IRecipe convert(ShapedCraftingRecipe recipe) { + public IRecipe toNative(ShapedCraftingRecipe recipe) { ItemIngredient[] ingredients = recipe.getIngredients(); int[] posx = recipe.getIngredientsX(); int[] posy = recipe.getIngredientsY(); @@ -184,8 +174,7 @@ public static IRecipe convert(ShapedCraftingRecipe recipe) { } return new ShapedRecipeBasic(basicIngredients, recipe); - } - case TYPE_ORE: { + } case TYPE_ORE: { Object[] converted = new Object[recipe.getHeight() * recipe.getWidth()]; for (int i = 0; i < ingredients.length; i++) { converted[posx[i] + posy[i] * recipe.getWidth()] = getInternal(ingredients[i]); @@ -197,7 +186,7 @@ public static IRecipe convert(ShapedCraftingRecipe recipe) { int counter = 0; String[] parts = new String[recipe.getHeight()]; - ArrayList rarguments = new ArrayList<>(); + List rarguments = new ArrayList<>(); for (int i = 0; i < recipe.getHeight(); i++) { char[] pattern = new char[recipe.getWidth()]; for (int j = 0; j < recipe.getWidth(); j++) { @@ -217,20 +206,43 @@ public static IRecipe convert(ShapedCraftingRecipe recipe) { rarguments.addAll(0, Arrays.asList(parts)); return new ShapedRecipeOre(rarguments.toArray(), recipe); + } default: { + return new NovaCraftingRecipe(recipe); } - default: + } + } + + public IRecipe toNative(ShapelessCraftingRecipe recipe) { + ItemIngredient[] ingredients = recipe.getIngredients(); + int type = getRecipeType(ingredients); + + switch (type) { + case TYPE_BASIC: { + ItemStack[] items = new ItemStack[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = wrapSpecific((SpecificItemIngredient) ingredients[i]); + } + return new ShapelessRecipeBasic(items, recipe); + } case TYPE_ORE: { + Object[] items = new Object[ingredients.length]; + for (int i = 0; i < ingredients.length; i++) { + items[i] = getInternal(ingredients[i]); + } + return new ShapelessRecipeOre(items, recipe); + } default: { return new NovaCraftingRecipe(recipe); + } } } - public static CraftingRecipe toNova(IRecipe recipe) { + @Override + public CraftingRecipe toNova(IRecipe recipe) { ItemStack recipeOutput = recipe.getRecipeOutput(); - Item output; if (recipeOutput == null) { - output = null; - } else { - output = Game.natives().toNova(recipeOutput); + return new MCCraftingRecipe(recipe); } + Item output = ItemConverter.instance().toNova(recipeOutput); + ItemFactory outputFactory = output.getFactory(); if (recipe instanceof ShapelessRecipes) { ShapelessRecipes shapeless = (ShapelessRecipes) recipe; @@ -240,7 +252,8 @@ public static CraftingRecipe toNova(IRecipe recipe) { ingredients[i] = getIngredient(shapeless.recipeItems.get(i)); } - return new ShapelessCraftingRecipe(output, ingredients); + return new ShapelessCraftingRecipe(outputFactory, (craftingGrid, taggedIngredients, o) -> + Optional.ofNullable(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))).map(ItemConverter.instance()::toNova), ingredients); } else if (recipe instanceof ShapedRecipes) { ShapedRecipes shaped = (ShapedRecipes) recipe; @@ -252,12 +265,13 @@ public static CraftingRecipe toNova(IRecipe recipe) { } } - return new ShapedCraftingRecipe(output, ingredients, false); + return new ShapedCraftingRecipe(outputFactory, (craftingGrid, taggedIngredients, o) -> + Optional.ofNullable(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))).map(ItemConverter.instance()::toNova), ingredients, false); } else if (recipe instanceof ShapedOreRecipe) { ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; int width = ReflectionUtil.getShapedOreRecipeWidth(shaped); - int height = recipe.getRecipeSize() / width; + int height = shaped.getRecipeSize() / width; @SuppressWarnings({"unchecked", "rawtypes"}) Optional[][] recipeIngredients = new Optional[height][width]; @@ -267,7 +281,8 @@ public static CraftingRecipe toNova(IRecipe recipe) { } } - return new ShapedCraftingRecipe(output, recipeIngredients, false); + return new ShapedCraftingRecipe(outputFactory, (craftingGrid, taggedIngredients, o) -> + Optional.ofNullable(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))).map(ItemConverter.instance()::toNova), recipeIngredients, false); } else if (recipe instanceof ShapelessOreRecipe) { ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; @@ -276,7 +291,8 @@ public static CraftingRecipe toNova(IRecipe recipe) { ingredients[i] = getIngredient(shapeless.getInput().get(i)); } - return new ShapelessCraftingRecipe(output, ingredients); + return new ShapelessCraftingRecipe(outputFactory, (craftingGrid, taggedIngredients, o) -> + Optional.ofNullable(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))).map(ItemConverter.instance()::toNova), ingredients); } else { return new MCCraftingRecipe(recipe); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java index cc797a309..ce4db8fb5 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2015 NOVA, All rights reserved. * This library is free software, licensed under GNU Lesser General Public License version 3 @@ -33,7 +32,6 @@ import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapUtility; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; -import nova.internal.core.Game; import java.util.List; import java.util.Optional; @@ -49,29 +47,39 @@ public class MCCraftingGrid implements CraftingGrid { private final EntityPlayer playerOrig; private int width; private int height; - private nova.core.item.Item[] stacks; + private nova.core.item.Item[] items; private ItemStack[] original; - private int numberOfStacks; + private int itemCount; private MCCraftingGrid(InventoryCrafting inventory) { this.inventory = inventory; width = height = (int) Math.sqrt(inventory.getSizeInventory()); - stacks = new nova.core.item.Item[width * height]; - original = new ItemStack[stacks.length]; - numberOfStacks = 0; + items = new nova.core.item.Item[width * height]; + original = new ItemStack[items.length]; + itemCount = 0; update(); Container container = ReflectionUtil.getCraftingContainer(inventory); if (container != null) { + @SuppressWarnings("unchecked") List slots = container.inventorySlots; - if (!slots.isEmpty() && slots.get(0) instanceof SlotCrafting) { - SlotCrafting slotCrafting = (SlotCrafting) slots.get(0); - playerOrig = ReflectionUtil.getCraftingSlotPlayer(slotCrafting); - player = WrapUtility.getNovaPlayer(playerOrig); - } else { - playerOrig = null; - player = Optional.empty(); + + EntityPlayer playerOrig = null; + Optional player = Optional.empty(); + + for (Slot slot : slots) { + if (slot instanceof SlotCrafting) { + playerOrig = ReflectionUtil.getCraftingSlotPlayer((SlotCrafting) slot); + player = WrapUtility.getNovaPlayer(playerOrig); + + if (player.isPresent()) { + break; + } + } } + + this.playerOrig = playerOrig; + this.player = player; } else { playerOrig = null; player = Optional.empty(); @@ -81,9 +89,9 @@ private MCCraftingGrid(InventoryCrafting inventory) { private MCCraftingGrid(IInventory inventory, EntityPlayer player) { this.inventory = inventory; width = height = (int) Math.sqrt(inventory.getSizeInventory()); - stacks = new nova.core.item.Item[width * height]; - original = new ItemStack[stacks.length]; - numberOfStacks = 0; + items = new nova.core.item.Item[width * height]; + original = new ItemStack[items.length]; + itemCount = 0; update(); playerOrig = player; @@ -117,9 +125,9 @@ public static MCCraftingGrid get(IInventory inventory, EntityPlayer player) { private void update() { if (inventory.getSizeInventory() != original.length) { width = height = (int) Math.sqrt(inventory.getSizeInventory()); - stacks = new nova.core.item.Item[inventory.getSizeInventory()]; - original = new ItemStack[stacks.length]; - numberOfStacks = 0; + items = new nova.core.item.Item[inventory.getSizeInventory()]; + original = new ItemStack[items.length]; + itemCount = 0; } for (int i = 0; i < inventory.getSizeInventory(); i++) { @@ -127,21 +135,21 @@ private void update() { //System.out.println("Slot " + i + " changed"); original[i] = inventory.getStackInSlot(i); if (inventory.getStackInSlot(i) != null) { - if (stacks[i] == null) { - numberOfStacks++; + if (items[i] == null) { + itemCount++; } - stacks[i] = Game.natives().toNova(original[i]); + items[i] = ItemConverter.instance().toNova(original[i]); } else { - if (stacks[i] != null) { - numberOfStacks--; + if (items[i] != null) { + itemCount--; } - stacks[i] = null; + items[i] = null; } } } - //System.out.println("Num stack count: " + numberOfStacks); + //System.out.println("Num stack count: " + itemCount); } @Override @@ -166,80 +174,82 @@ public int getHeight() { @Override public int countFilledStacks() { - return numberOfStacks; + return itemCount; } @Override - public Optional getStack(int i) { - return Optional.ofNullable(stacks[i]); + public Optional getCrafting(int i) { + return Optional.ofNullable(items[i]); } @Override - public Optional getStack(int x, int y) { - return Optional.ofNullable(stacks[y * width + x]); + public Optional getCrafting(int x, int y) { + return Optional.ofNullable(items[y * width + x]); } @Override - public boolean setStack(int x, int y, Optional stack) { + public boolean setCrafting(int x, int y, Optional item) { //System.out.println("SetStack(" + x + ", " + y + ") " + stack); int ix = y * width + x; - if (stack.isPresent()) { - if (!stack.get().equals(stacks[ix])) { - inventory.setInventorySlotContents(ix, Game.natives().toNative(stack.get())); + if (item.isPresent()) { + if (!item.get().equals(items[ix])) { + inventory.setInventorySlotContents(ix, ItemConverter.instance().toNative(item.get())); - if (stacks[ix] == null) { - numberOfStacks++; + if (items[ix] == null) { + itemCount++; } - stacks[ix] = stack.get(); + items[ix] = item.get(); } } else { - numberOfStacks--; + itemCount--; inventory.setInventorySlotContents(ix, null); - stacks[ix] = null; + items[ix] = null; } return true; } @Override - public boolean setStack(int i, Optional stack) { + public boolean setCrafting(int i, Optional item) { //System.out.println("SetStack(" + i + ") " + stack); - if (stack.isPresent()) { - if (stacks[i] == null) { - numberOfStacks++; + if (item.isPresent()) { + if (items[i] == null) { + itemCount++; } - inventory.setInventorySlotContents(i, Game.natives().toNative(stack.get())); - stacks[i] = stack.get(); + inventory.setInventorySlotContents(i, ItemConverter.instance().toNative(item.get())); + items[i] = item.get(); } else { - if (stacks[i] == null) { + if (items[i] == null) { return true; } - numberOfStacks--; + itemCount--; inventory.setInventorySlotContents(i, null); - stacks[i] = null; + items[i] = null; } return true; } @Override - public void giveBack(nova.core.item.Item itemStack) { - playerOrig.inventory.addItemStackToInventory(ItemConverter.instance().toNative(itemStack)); + public void giveBack(nova.core.item.Item item) { + if (playerOrig != null) { + playerOrig.inventory.addItemStackToInventory(ItemConverter.instance().toNative(item)); + } } @Override public String getTopology() { - return CraftingGrid.topologySquare; + return CraftingGrid.TOPOLOGY_SQUARE; } @Override public String getType() { - return CraftingGrid.typeCrafting; + return CraftingGrid.TYPE_CRAFTING; } private boolean changed(int i) { @@ -247,7 +257,7 @@ private boolean changed(int i) { return true; } - if (original[i] != null && stacks[i].count() != original[i].getCount()) { + if (original[i] != null && items[i].count() != original[i].getCount()) { return true; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java index 9a6c11d53..dfa7b437e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingRecipe.java @@ -20,12 +20,17 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingGrid; +import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.NonNullList; +import nova.core.entity.Entity; +import nova.core.entity.component.Player; import nova.core.item.Item; import nova.core.recipes.crafting.CraftingGrid; import nova.core.recipes.crafting.CraftingRecipe; -import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingGrid; -import nova.internal.core.Game; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import java.util.Optional; @@ -41,22 +46,29 @@ public MCCraftingRecipe(IRecipe recipe) { @Override public boolean matches(CraftingGrid craftingGrid) { - // TODO: supply world somehow? - return recipe.matches(new NovaCraftingGrid(craftingGrid), null); + return recipe.matches(new NovaCraftingGrid(craftingGrid), (net.minecraft.world.World) craftingGrid.getPlayer().map(Player::entity) + .map(Entity::world).map(WorldConverter.instance()::toNative).filter(w -> w instanceof net.minecraft.world.World).orElse(null)); } @Override public Optional getCraftingResult(CraftingGrid craftingGrid) { - return Game.natives().toNova(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))); + return Optional.of(recipe.getCraftingResult(new NovaCraftingGrid(craftingGrid))).filter(item -> !item.isEmpty()).map(ItemConverter.instance()::toNova); } @Override public void consumeItems(CraftingGrid craftingGrid) { - // not supported + NonNullList remainder = recipe.getRemainingItems(new NovaCraftingGrid(craftingGrid)); + for (int i = 0; i < remainder.size(); i++) { + Optional result = Optional.of(remainder.get(i)).filter(item -> !item.isEmpty()).map(ItemConverter.instance()::toNova); + if (!result.isPresent()) { + result = craftingGrid.getCrafting(i).filter(item -> item.count() > 1).map(item -> item.withAmount(item.count() - 1)); + } + craftingGrid.setCrafting(i, result); + } } @Override - public Optional getNominalOutput() { - return Game.natives().toNova(recipe.getRecipeOutput()); + public Optional getExampleOutput() { + return Optional.of(recipe.getRecipeOutput()).filter(item -> !item.isEmpty()).map(ItemConverter.instance()::toNova); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java index 81debde99..801a5850c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingGrid.java @@ -21,7 +21,12 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import nova.core.item.Item; import nova.core.recipes.crafting.CraftingGrid; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; + +import java.util.Optional; public class NovaCraftingGrid extends InventoryCrafting { private final CraftingGrid craftingGrid; @@ -30,4 +35,62 @@ public NovaCraftingGrid(CraftingGrid craftingGrid) { super(new NovaCraftingGridContainer(craftingGrid), craftingGrid.getWidth(), craftingGrid.getHeight()); this.craftingGrid = craftingGrid; } + + @Override + public int getSizeInventory() { + return craftingGrid.size(); + } + + @Override + public ItemStack getStackInSlot(int slot) { + return craftingGrid.getCrafting(slot).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); + } + + @Override + public ItemStack getStackInRowAndColumn(int x, int y) { + return craftingGrid.getCrafting(x, y).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); + } + + @Override + public void setInventorySlotContents(int slot, ItemStack item) { + craftingGrid.setCrafting(slot, Optional.of(item).filter(i -> !i.isEmpty()).map(ItemConverter.instance()::toNova)); + } + + @Override + public ItemStack decrStackSize(int slot, int count) { + Optional optionalItem = craftingGrid.getCrafting(slot); + if (!optionalItem.isPresent() || count == 0) { + return null; + } + + Item item = optionalItem.get(); + int added = -item.addCount(-count); + if (item.count() == 0) { + craftingGrid.setCrafting(slot, Optional.empty()); + } + return ItemConverter.instance().toNative(item.withAmount(added)); + } + + @Override + public ItemStack removeStackFromSlot(int slot) { + return craftingGrid.removeCrafting(slot).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); + } + + @Override + public int getWidth() { + return craftingGrid.getWidth(); + } + + @Override + public int getHeight() { + return craftingGrid.getHeight(); + } + + @Override + public void clear() { + super.clear(); + for (int i = 0; i < craftingGrid.size(); i++) { + craftingGrid.setCrafting(i, Optional.empty()); + } + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java index d83870e26..b647d2751 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/NovaCraftingRecipe.java @@ -25,12 +25,9 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.NonNullList; import net.minecraft.world.World; -import nova.core.item.Item; import nova.core.recipes.crafting.CraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; -import nova.internal.core.Game; - -import java.util.Optional; public class NovaCraftingRecipe implements IRecipe { private final CraftingRecipe recipe; @@ -40,18 +37,13 @@ public NovaCraftingRecipe(CraftingRecipe recipe) { } @Override - public boolean matches(InventoryCrafting inventoryCrafting, World world) { - return recipe.matches(MCCraftingGrid.get(inventoryCrafting)); + public boolean matches(InventoryCrafting inventory, World world) { + return recipe.matches(MCCraftingGrid.get(inventory)); } @Override - public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { - Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventoryCrafting)); - if (craftingResult.isPresent()) { - return Game.natives().toNative(craftingResult.get()); - } else { - return null; - } + public ItemStack getCraftingResult(InventoryCrafting inventory) { + return recipe.getCraftingResult(MCCraftingGrid.get(inventory)).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } @Override @@ -61,19 +53,11 @@ public int getRecipeSize() { @Override public ItemStack getRecipeOutput() { - Optional nominalOutput = recipe.getNominalOutput(); - if (nominalOutput.isPresent()) { - return Game.natives().toNative(nominalOutput.get()); - } - return null; + return recipe.getExampleOutput().map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } @Override - public NonNullList getRemainingItems(InventoryCrafting inv) { - return NonNullList.create(); - } - - public CraftingRecipe getRecipe() { - return recipe; + public NonNullList getRemainingItems(InventoryCrafting inventory) { + return NonNullList.withSize(0, ItemStack.EMPTY); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java index dad784e58..5c9e63f9f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeBasic.java @@ -25,10 +25,8 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.world.World; import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; -import nova.internal.core.Game; - -import java.util.Optional; /** * @author Stan Hebben @@ -37,8 +35,7 @@ public class ShapedRecipeBasic extends ShapedRecipes { private final ShapedCraftingRecipe recipe; public ShapedRecipeBasic(ItemStack[] basicInputs, ShapedCraftingRecipe recipe) { - super(recipe.getWidth(), recipe.getHeight(), basicInputs, recipe.getNominalOutput().isPresent() ? Game.natives().toNative(recipe.getNominalOutput().get()) : null); - + super(recipe.getWidth(), recipe.getHeight(), basicInputs, recipe.getExampleOutput().map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY)); this.recipe = recipe; } @@ -49,10 +46,6 @@ public boolean matches(InventoryCrafting inventory, World world) { @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { - Optional result = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); - if (result.isPresent()) { - return Game.natives().toNative(result.get()); - } - return null; + return recipe.getCraftingResult(MCCraftingGrid.get(inventory)).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java index a1ec778af..db28f85ee 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapedRecipeOre.java @@ -30,12 +30,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; -import nova.core.item.Item; import nova.core.recipes.crafting.ShapedCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; -import nova.internal.core.Game; - -import java.util.Optional; /** * @author Stan @@ -44,8 +41,7 @@ public class ShapedRecipeOre extends ShapedOreRecipe { private final ShapedCraftingRecipe recipe; public ShapedRecipeOre(Object[] contents, ShapedCraftingRecipe recipe) { - super((ItemStack) Game.natives().toNative(recipe.getNominalOutput().get()), contents); - + super(recipe.getExampleOutput().map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY), contents); this.recipe = recipe; } @@ -56,10 +52,6 @@ public boolean matches(InventoryCrafting inventory, World world) { @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { - Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); - if (craftingResult.isPresent()) { - return ((ItemStack) Game.natives().toNative(craftingResult.get())).copy(); - } - return null; + return recipe.getCraftingResult(MCCraftingGrid.get(inventory)).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java index 9589fbef2..19068211e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeBasic.java @@ -18,25 +18,17 @@ * along with NOVA. If not, see . */ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - package nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.world.World; -import nova.core.item.Item; import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; -import nova.internal.core.Game; import java.util.Arrays; -import java.util.Optional; /** * @author Stan @@ -45,8 +37,7 @@ public class ShapelessRecipeBasic extends ShapelessRecipes { private final ShapelessCraftingRecipe recipe; public ShapelessRecipeBasic(ItemStack[] ingredients, ShapelessCraftingRecipe recipe) { - super(recipe.getNominalOutput().isPresent() ? Game.natives().toNative(recipe.getNominalOutput().get()) : null, Arrays.asList(ingredients)); - + super(recipe.getExampleOutput().map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY), Arrays.asList(ingredients)); this.recipe = recipe; } @@ -57,10 +48,6 @@ public boolean matches(InventoryCrafting inventory, World world) { @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { - Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); - if (craftingResult.isPresent()) { - return Game.natives().toNative(craftingResult.get()); - } - return null; + return recipe.getCraftingResult(MCCraftingGrid.get(inventory)).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java index 537fb2e77..2b56bfd4b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/forward/ShapelessRecipeOre.java @@ -24,12 +24,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapelessOreRecipe; -import nova.core.item.Item; import nova.core.recipes.crafting.ShapelessCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.backward.MCCraftingGrid; -import nova.internal.core.Game; - -import java.util.Optional; /** * @author Stan Hebben @@ -38,8 +35,7 @@ public class ShapelessRecipeOre extends ShapelessOreRecipe { private final ShapelessCraftingRecipe recipe; public ShapelessRecipeOre(Object[] ingredients, ShapelessCraftingRecipe recipe) { - super((ItemStack) Game.natives().toNative(recipe.getNominalOutput().get()), ingredients); - + super(recipe.getExampleOutput().map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY), ingredients); this.recipe = recipe; } @@ -50,10 +46,6 @@ public boolean matches(InventoryCrafting inventory, World world) { @Override public ItemStack getCraftingResult(InventoryCrafting inventory) { - Optional craftingResult = recipe.getCraftingResult(MCCraftingGrid.get(inventory)); - if (craftingResult.isPresent()) { - return ((ItemStack) Game.natives().toNative(craftingResult.get())).copy(); - } - return null; + return recipe.getCraftingResult(MCCraftingGrid.get(inventory)).map(ItemConverter.instance()::toNative).orElse(ItemStack.EMPTY); } } From 037ccaf130c61adbc34f8bc5d798ad830ac1b163 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 20 Apr 2017 23:48:17 +0200 Subject: [PATCH 52/61] Fixes and improvements --- minecraft/1.11.2/build.gradle | 5 ++++- .../forge/v1_11_2/wrapper/block/BlockConverter.java | 6 ++---- .../wrapper/block/backward/BWBlockFactory.java | 12 ++++++++++-- .../forge/v1_11_2/wrapper/block/forward/FWBlock.java | 12 +++++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index fe98abd66..86a50ea88 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -10,13 +10,16 @@ archivesBaseName = "NOVA-Core-Wrapper-MC1.11.2" configurations { fatJar compile.extendsFrom fatJar + // Exclude slf4j-log4j from tests (we use slf4j-simple) + testRuntime.exclude module: 'slf4j-log4j12' + testRuntime.exclude module: 'log4j-slf4j-impl' } dependencies { fatJar project(":") + fatJar 'org.apache.logging.log4j:log4j-slf4j-impl:2.0-beta9' testCompile project(path: ':', configuration: 'wrapperTests') - fatJar 'org.slf4j:slf4j-log4j12:1.7.10' testCompile "junit:junit:4.12" testCompile 'org.assertj:assertj-core:3.0.0' testRuntime 'org.slf4j:slf4j-simple:1.7.10' diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index d8981fa89..b18066a34 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -24,7 +24,6 @@ import com.google.common.collect.HashBiMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -38,7 +37,7 @@ import nova.core.nativewrapper.NativeConverter; import nova.core.wrapper.mc.forge.v1_11_2.launcher.ForgeLoadable; import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; -import nova.core.wrapper.mc.forge.v1_11_2.util.ModCreativeTab; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.CategoryConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlockFactory; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward.FWBlock; @@ -158,8 +157,7 @@ private void registerNovaBlock(BlockFactory blockFactory) { blockWrapper.setCreativeTab(first.get()); } else { Optional item = category.item; - ModCreativeTab tab = new ModCreativeTab(category.name, item.isPresent() ? Game.natives().toNative(item.get()) : Item.getItemFromBlock(blockWrapper)); - blockWrapper.setCreativeTab(tab); + blockWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, blockWrapper)); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java index fa1497f7c..e247d5c1c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java @@ -19,6 +19,7 @@ */ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward; +import net.minecraft.block.Block; import nova.core.block.BlockFactory; /** @@ -26,7 +27,14 @@ */ public class BWBlockFactory extends BlockFactory { - public BWBlockFactory(net.minecraft.block.Block block) { - super(net.minecraft.block.Block.REGISTRY.getNameForObject(block).toString(), () -> new BWBlock(block), factory -> {}); + private final Block block; + + public BWBlockFactory(Block block) { + super(Block.REGISTRY.getNameForObject(block).toString(), () -> new BWBlock(block), factory -> {}); + this.block = block; + } + + public Block getBlock() { + return block; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index 4a2829da5..07525855c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -81,8 +81,7 @@ public class FWBlock extends net.minecraft.block.Block { public BlockPos lastExtendedStatePos; private Map harvestedBlocks = new HashMap<>(); - private static Material getMcMaterial(BlockFactory factory) { - Block dummy = factory.build(); + private static Material getMcMaterial(Block dummy) { if (dummy.components.has(BlockProperty.Opacity.class) || dummy.components.has(BlockProperty.Replaceable.class)) { // TODO allow color selection return new ProxyMaterial(MapColor.GRAY, @@ -94,10 +93,13 @@ private static Material getMcMaterial(BlockFactory factory) { } public FWBlock(BlockFactory factory) { - //TODO: Hack build() method - super(getMcMaterial(factory)); + this(factory, factory.build()); + } + + private FWBlock(BlockFactory factory, Block dummy) { + super(getMcMaterial(dummy)); this.factory = factory; - this.dummy = factory.build(); + this.dummy = dummy; if (dummy.components.has(BlockProperty.BlockSound.class)) { this.blockSoundType = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class)); } else { From a7ad1188c73a1723e10cc855afc0192c01598d40 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Fri, 21 Apr 2017 21:39:35 +0200 Subject: [PATCH 53/61] Move the block's associated TileEntity on block move properly --- .../wrapper/block/backward/BWBlock.java | 5 +- .../block/backward/BWBlockFactory.java | 10 ++++ .../block/backward/BWBlockTransform.java | 36 +++++++++---- .../block/forward/FWBlockTransform.java | 51 +++++++++++-------- .../v1_11_2/wrapper/block/forward/FWTile.java | 6 +++ .../wrapper/block/forward/FWTileLoader.java | 7 --- .../wrapper/block/forward/FWTileRenderer.java | 1 - .../block/forward/TEBlockTransform.java | 34 +++++++------ 8 files changed, 95 insertions(+), 55 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index 8e6d0d0fb..f0aa340b0 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -51,6 +51,7 @@ import nova.core.util.shape.Cuboid; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; 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.DataConverter; @@ -124,7 +125,7 @@ public BWBlock(IBlockState blockState, World world, Vector3D pos) { true ); return aabbs.stream() - .map(aabb -> (Cuboid) Game.natives().toNova(aabb)) + .map(CuboidConverter.instance()::toNova) .map(cuboid -> cuboid.subtract(pos)) .collect(Collectors.toSet()); }).setSelectionBoxes(entity -> { @@ -205,7 +206,7 @@ public int meta() { } public BlockPos blockPos() { - return new BlockPos(x(), y(), z()); + return VectorConverter.instance().toNative(position()); } public IBlockAccess blockAccess() { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java index e247d5c1c..8e298b2e6 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockFactory.java @@ -37,4 +37,14 @@ public BWBlockFactory(Block block) { public Block getBlock() { return block; } + + @Override + public String getLocalizedName() { + return getBlock().getLocalizedName(); + } + + @Override + public String getUnlocalizedName() { + return getBlock().getUnlocalizedName(); + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java index 5432d03b6..e988b474a 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java @@ -19,6 +19,7 @@ */ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -70,14 +71,20 @@ public void setWorld(World world) { net.minecraft.world.World oldWorld = Game.natives().toNative(this.world); net.minecraft.world.World newWorld = Game.natives().toNative(world); Optional tileEntity = Optional.ofNullable(oldWorld.getTileEntity(pos)); - newWorld.setBlockState(pos, block.blockState()); + Optional nbt = Optional.empty(); if (tileEntity.isPresent()) { - newWorld.setTileEntity(pos, tileEntity.get()); - tileEntity.get().setWorld(newWorld); - } else { - newWorld.setTileEntity(pos, null); + NBTTagCompound compound = new NBTTagCompound(); + tileEntity.get().writeToNBT(compound); + nbt = Optional.of(compound); } + newWorld.setBlockState(pos, block.blockState()); + oldWorld.removeTileEntity(pos); oldWorld.setBlockToAir(pos); + Optional newTileEntity = Optional.ofNullable(newWorld.getTileEntity(pos)); + if (newTileEntity.isPresent() && nbt.isPresent()) { + newTileEntity.get().readFromNBT(nbt.get()); + } + this.world = world; } @Override @@ -86,13 +93,22 @@ public void setPosition(Vector3D position) { BlockPos newPos = VectorConverter.instance().toNative(position); net.minecraft.world.World world = Game.natives().toNative(this.world); Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(oldPos)); - world.setBlockState(newPos, block.blockState()); + Optional nbt = Optional.empty(); if (tileEntity.isPresent()) { - world.setTileEntity(newPos, tileEntity.get()); - tileEntity.get().setPos(newPos); - } else { - world.setTileEntity(newPos, null); + NBTTagCompound compound = new NBTTagCompound(); + tileEntity.get().writeToNBT(compound); + compound.setInteger("x", newPos.getX()); + compound.setInteger("y", newPos.getY()); + compound.setInteger("z", newPos.getZ()); + nbt = Optional.of(compound); } + world.setBlockState(newPos, block.blockState()); + world.removeTileEntity(oldPos); world.setBlockToAir(oldPos); + Optional newTileEntity = Optional.ofNullable(blockAccess().getTileEntity(newPos)); + if (newTileEntity.isPresent() && nbt.isPresent()) { + newTileEntity.get().readFromNBT(nbt.get()); + } + this.position = position; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java index 5393dd85c..d8fdf3eb1 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlockTransform.java @@ -20,15 +20,15 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import nova.core.block.Block; import nova.core.component.transform.BlockTransform; +import nova.core.retention.Data; +import nova.core.retention.Storable; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; -import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Optional; @@ -38,9 +38,9 @@ */ public class FWBlockTransform extends BlockTransform { - public final Block block; - public final World world; - public final Vector3D position; + private Block block; + private World world; + private Vector3D position; public FWBlockTransform(Block block, World world, Vector3D position) { this.block = block; @@ -68,28 +68,39 @@ public IBlockAccess blockAccess() { @Override public void setWorld(World world) { - BlockPos pos = blockPos(); - Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(pos)); world.setBlock(position, block.getFactory()); - tileEntity.ifPresent(te -> { - net.minecraft.world.World newWorld = Game.natives().toNative(world); - newWorld.setTileEntity(pos, te); - te.setWorld(newWorld); - }); + Optional data = Optional.empty(); + if (block instanceof Storable) { + data = Optional.of(new Data()); + ((Storable) block).save(data.get()); + } this.world.removeBlock(position); + Optional newBlock = world.getBlock(position); + if (newBlock.isPresent()) { + block = newBlock.get(); + if (newBlock.get() instanceof Storable && data.isPresent()) { + ((Storable) newBlock.get()).load(data.get()); + } + } + this.world = world; } @Override public void setPosition(Vector3D position) { - BlockPos oldPos = blockPos(); - BlockPos newPos = VectorConverter.instance().toNative(position); - Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(oldPos)); world.setBlock(position, block.getFactory()); - tileEntity.ifPresent(te -> { - net.minecraft.world.World world = Game.natives().toNative(this.world); - world.setTileEntity(newPos, te); - te.setPos(newPos); - }); + Optional data = Optional.empty(); + if (block instanceof Storable) { + data = Optional.of(new Data()); + ((Storable) block).save(data.get()); + } world.removeBlock(this.position); + Optional newBlock = world.getBlock(position); + if (newBlock.isPresent()) { + block = newBlock.get(); + if (newBlock.get() instanceof Storable && data.isPresent()) { + ((Storable) newBlock.get()).load(data.get()); + } + } + this.position = position; } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index a24cd3e43..1d06976ec 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -69,6 +69,9 @@ public Block getBlock() { } public void setBlock(Block block) { + if (block.components.has(TEBlockTransform.class)) + block.components.remove(TEBlockTransform.class); + block.components.getOrAdd(new TEBlockTransform(this)); this.block = block; } @@ -84,6 +87,8 @@ public SPacketUpdateTileEntity getUpdatePacket() { @Override public void validate() { super.validate(); + if (block.components.has(TEBlockTransform.class)) + block.components.remove(TEBlockTransform.class); block.components.getOrAdd(new TEBlockTransform(this)); if (cacheData != null && block instanceof Storable) { @@ -179,6 +184,7 @@ private FWPacketUpdateTileEntity(Packet packet, BlockPos blockPosIn, int meta } @Override + @SuppressWarnings("unchecked") public void processPacket(INetHandlerPlayClient handler) { super.processPacket(handler); try { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java index 0c1a0211c..f9470e90f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileLoader.java @@ -21,21 +21,14 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import nova.core.block.Block; import nova.core.block.BlockFactory; import nova.core.component.Updater; -import nova.core.component.fluid.SidedTankProvider; -import nova.core.util.Direction; import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ComponentInjector; import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.internal.core.Game; -import java.util.Arrays; -import java.util.HashSet; import java.util.Optional; -import java.util.Set; -import java.util.function.Predicate; /** * @author Vic Nightfall diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java index 0d141fb28..3bf3b151f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTileRenderer.java @@ -24,7 +24,6 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.tileentity.TileEntity; import nova.core.block.Block; import nova.core.component.renderer.DynamicRenderer; import nova.core.wrapper.mc.forge.v1_11_2.render.RenderUtility; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java index 923bd53aa..1c8852c1e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/TEBlockTransform.java @@ -20,13 +20,16 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.forward; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import nova.core.block.Block; import nova.core.component.transform.BlockTransform; import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; -import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import java.util.Objects; + /** * @author ExE Boss */ @@ -38,6 +41,10 @@ public TEBlockTransform(FWTile tileEntity) { this.tileEntity = tileEntity; } + public Block block() { + return tileEntity.block; + } + @Override public Vector3D position() { return VectorConverter.instance().toNova(tileEntity.getPos()); @@ -48,28 +55,25 @@ public World world() { return WorldConverter.instance().toNova(tileEntity.getWorld()); } - public net.minecraft.world.World mcWorld() { + public BlockPos blockPos() { + return tileEntity.getPos(); + } + + public IBlockAccess blockAccess() { return tileEntity.getWorld(); } @Override - public void setWorld(nova.core.world.World world) { - nova.core.world.World originalWorld = world(); - Vector3D originalPosition = position(); - world.setBlock(position(), tileEntity.block.getFactory()); - net.minecraft.world.World mcWorld = Game.natives().toNative(world); - mcWorld.setTileEntity(tileEntity.getPos(), tileEntity); - tileEntity.setWorld(mcWorld); - originalWorld.removeBlock(originalPosition); + public void setWorld(World world) { + world().setBlock(position(), tileEntity.block.getFactory()); + world().removeBlock(position()); + Objects.requireNonNull((FWTile) WorldConverter.instance().toNative(world).getTileEntity(blockPos())).setBlock(tileEntity.block); } @Override public void setPosition(Vector3D position) { - Vector3D originalPosition = position(); world().setBlock(position, tileEntity.block.getFactory()); - BlockPos newPos = VectorConverter.instance().toNative(position); - mcWorld().setTileEntity(newPos, tileEntity); - tileEntity.setPos(newPos); - world().removeBlock(originalPosition); + world().removeBlock(position()); + Objects.requireNonNull((FWTile) blockAccess().getTileEntity(VectorConverter.instance().toNative(position))).setBlock(tileEntity.block); } } From a26d66b2b1570faa072fea92e2f92846c828c3e2 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 28 May 2017 18:36:37 +0200 Subject: [PATCH 54/61] Update to master --- .../forge/v1_11_2/NovaMinecraftPreloader.java | 7 ++-- .../mc/forge/v1_11_2/asm/lib/ASMHelper.java | 9 +++-- .../v1_11_2/asm/lib/ComponentInjector.java | 3 +- .../asm/transformers/ChunkTransformer.java | 7 ++-- .../transformers/TileEntityTransformer.java | 12 +++--- .../forge/v1_11_2/launcher/NovaMinecraft.java | 6 +-- .../v1_11_2/manager/MCRetentionManager.java | 10 ++--- .../mc/forge/v1_11_2/util/ReflectionUtil.java | 40 +++++++++---------- .../v1_11_2/wrapper/block/BlockConverter.java | 2 +- .../wrapper/entity/backward/BWEntity.java | 12 +++--- .../v1_11_2/wrapper/item/ItemConverter.java | 9 +---- .../item/OreDictionaryIntegration.java | 3 +- .../recipes/MinecraftRecipeRegistry.java | 4 +- .../recipes/backward/MCCraftingGrid.java | 8 ++-- 14 files changed, 64 insertions(+), 68 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index 6f5a04399..2084f2fb6 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -44,6 +44,7 @@ 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 nova.internal.core.Game; import java.io.File; import java.io.IOException; @@ -239,7 +240,7 @@ public void load(FMLConstructionEvent event) { @SuppressWarnings("unchecked") Set classLoaderExceptions = (Set) setField.get(classLoader); classLoaderExceptions.remove("org.apache."); - System.out.println("Successfully hacked 'org.apache' out of launcher exclusion"); + Game.logger().info("Successfully hacked 'org.apache' out of launcher exclusion"); } catch (Exception e) { throw new ClassLoaderUtil.ClassLoaderException(e); } @@ -321,7 +322,7 @@ public void registerResourcePacks() { NovaFileResourcePack pack = new NovaFileResourcePack(file, novaMod.id(), novaMod.domains()); packs.add(pack); novaPacks.add(pack); - System.out.println("Registered NOVA jar resource pack: " + fn); + Game.logger().info("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. @@ -340,7 +341,7 @@ public void registerResourcePacks() { 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()); + Game.logger().info("Registered NOVA folder resource pack: {}", folderFile.getAbsolutePath()); } }); resourcePackField.set(FMLClientHandler.instance(), packs); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java index 8ec3d69ab..f6f2fd138 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java @@ -23,6 +23,7 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import net.minecraft.launchwrapper.LaunchClassLoader; +import nova.internal.core.Game; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Label; @@ -134,7 +135,7 @@ public static byte[] injectMethods(String name, byte[] bytes, Multimap callNodes; if (injector.before) { @@ -143,16 +144,16 @@ public static byte[] injectMethods(String name, byte[] bytes, Multimap provider, Class[] typeArgs, if (components.size() > 0) { List> componentClazzes = components.stream().map(c -> c.getClass()).collect(Collectors.toList()); - System.out.println(Side.get() + " " + componentClazzes); + Game.logger().info("{} {}", Side.get(), componentClazzes); if (cache.containsKey(componentClazzes)) // Cached class { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java index 8a34a0d4b..39ecbdd4b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java @@ -22,6 +22,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ObfMapping; +import nova.internal.core.Game; import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; @@ -35,12 +36,12 @@ public class ChunkTransformer implements Transformer { @Override public void transform(ClassNode cnode) { - System.out.println("[NOVA] Transforming Chunk class for chunkModified event."); + Game.logger().info("Transforming Chunk class for chunkModified event."); //obf name: func_177436_a MethodNode method = ASMHelper.findMethod(new ObfMapping("net/minecraft/world/chunk/Chunk", "setBlockState", "(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/block/state/IBlockState;"), cnode); - System.out.println("[NOVA] Found method " + method.name); + Game.logger().info("Found method {}", method.name); InsnList list = new InsnList(); list.add(new VarInsnNode(ALOAD, 0)); //this @@ -60,6 +61,6 @@ public void transform(ClassNode cnode) { method.instructions.insert(list); } - System.out.println("[NOVA] Injected instruction to method: " + method.name); + Game.logger().info("Injected instruction to method: {}", method.name); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java index 929d8db42..db64cf554 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java @@ -23,6 +23,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.InstructionComparator; import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ObfMapping; +import nova.internal.core.Game; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.InsnList; import org.objectweb.asm.tree.MethodInsnNode; @@ -45,7 +46,7 @@ public class TileEntityTransformer implements Transformer { @Override public void transform(ClassNode cnode) { - System.out.println("[NOVA] Transforming TileEntity class for dynamic instance injection."); + Game.logger().info("Transforming TileEntity class for dynamic instance injection."); ObfMapping obfMap = new ObfMapping("aqk", "a", "(Laid;Ldr;)Laqk;"); ObfMapping deobfMap = new ObfMapping("net/minecraft/tileentity/TileEntity", "create", "(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/tileentity/TileEntity;"); @@ -55,17 +56,16 @@ public void transform(ClassNode cnode) { boolean deobf = false; if (method == null) { - System.out.println("[NOVA] Lookup " + obfMap + " failed. You are probably in a deobf environment."); + Game.logger().warn("Lookup {} failed. You are probably in a deobf environment.", obfMap); method = ASMHelper.findMethod(deobfMap, cnode); deobf = true; if (method == null) { - System.out.println("[NOVA] Lookup " + deobfMap + " failed!"); - return; + throw new IllegalStateException("[NOVA] Lookup " + deobfMap + " failed!"); } } - System.out.println("[NOVA] Transforming method " + method.name); + Game.logger().info("Transforming method {}", method.name); if (writeDebug) { try { @@ -108,6 +108,6 @@ public void transform(ClassNode cnode) { } catch (IOException ex) {} } - System.out.println("[NOVA] Injected instruction to method: " + method.name); + Game.logger().info("Injected instruction to method: {}", method.name); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java index 23cb2279f..106b4cdcb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/NovaMinecraft.java @@ -214,7 +214,7 @@ public void preInit(FMLPreInitializationEvent evt) { MinecraftForge.EVENT_BUS.register(new FMLEventHandler()); MinecraftForge.EVENT_BUS.register(Game.retention()); } catch (Exception e) { - System.out.println("Error during preInit"); + Game.logger().error("Error during preInit"); e.printStackTrace(); throw new InitializationException(e); } @@ -241,7 +241,7 @@ public void init(FMLInitializationEvent evt) { ProgressManager.pop(progressBar); } } catch (Exception e) { - System.out.println("Error during init"); + Game.logger().error("Error during init"); e.printStackTrace(); throw new InitializationException(e); } @@ -269,7 +269,7 @@ public void postInit(FMLPostInitializationEvent evt) { ProgressManager.pop(progressBar); } } catch (Exception e) { - System.out.println("Error during postInit"); + Game.logger().error("Error during postInit"); e.printStackTrace(); throw new InitializationException(e); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java index 62e93bad6..c952ec1e0 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java @@ -46,7 +46,7 @@ public class MCRetentionManager extends RetentionManager { /** * Last time that the queueSave manager tried to queueSave a file */ - private long lastSaveMills = 0; + private long lastSaveTime = 0; /** * Save all storable queued @@ -88,7 +88,7 @@ public boolean saveFile(File file, NBTTagCompound data) { tempFile.renameTo(file); return true; } catch (Exception e) { - System.out.println("Failed to queueSave " + file.getName() + ".dat!"); + Game.logger().error("Failed to queueSave {}!", file.getName()); e.printStackTrace(); return false; } @@ -110,7 +110,7 @@ public NBTTagCompound loadFile(File file) { return new NBTTagCompound(); } } catch (Exception e) { - System.out.println("Failed to load " + file.getName() + ".dat!"); + Game.logger().error("Failed to load {}!", file.getName()); e.printStackTrace(); return null; } @@ -157,8 +157,8 @@ public File getBaseDirectory() { @SubscribeEvent public void worldSave(WorldEvent evt) { //Current time milli-seconds is used to prevent the files from saving 20 times when the world loads - if (System.currentTimeMillis() - lastSaveMills > 2000) { - lastSaveMills = System.currentTimeMillis(); + if (System.nanoTime() - lastSaveTime > 2_000_000_000) { + lastSaveTime = System.nanoTime(); saveAll(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java index a2d5d390a..9657e96d6 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java @@ -32,6 +32,7 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagList; import net.minecraft.server.MinecraftServer; +import net.minecraft.util.NonNullList; import net.minecraft.util.WeightedRandom; import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.LanguageMap; @@ -39,6 +40,7 @@ import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; +import nova.internal.core.Game; import java.io.File; import java.lang.reflect.Constructor; @@ -142,20 +144,20 @@ public static Map getTranslations() { "field_74816_c"); } - public static List> getOreIdStacks() { + public static List> getOreIdStacks() { try { - return (List>) OREDICTIONARY_IDTOSTACK.get(null); + return (List>) OREDICTIONARY_IDTOSTACK.get(null); } catch (IllegalAccessException ex) { - logError("ERROR - could not load ore dictionary stacks!"); + Game.logger().error("ERROR - could not load ore dictionary stacks!"); return null; } } - public static List> getOreIdStacksUn() { + public static List> getOreIdStacksUn() { try { - return (List>) OREDICTIONARY_IDTOSTACKUN.get(null); + return (List>) OREDICTIONARY_IDTOSTACKUN.get(null); } catch (IllegalAccessException ex) { - logError("ERROR - could not load ore dictionary stacks!"); + Game.logger().error("ERROR - could not load ore dictionary stacks!"); return null; } } @@ -164,7 +166,7 @@ public static File getAnvilFile(MinecraftServer server) { try { return (File) MINECRAFTSERVER_ANVILFILE.get(server); } catch (IllegalAccessException ex) { - logError("could not load anvil file!"); + Game.logger().error("could not load anvil file!"); return null; } } @@ -186,7 +188,7 @@ public static int getShapedOreRecipeWidth(ShapedOreRecipe recipe) { try { return SHAPEDORERECIPE_WIDTH.getInt(recipe); } catch (IllegalAccessException ex) { - logError("could not load shaped ore recipe width!"); + Game.logger().error("could not load shaped ore recipe width!"); return 3; } } @@ -195,7 +197,7 @@ public static Container getCraftingContainer(InventoryCrafting inventory) { try { return (Container) INVENTORYCRAFTING_EVENTHANDLER.get(inventory); } catch (IllegalAccessException ex) { - logError("could not get inventory eventhandler"); + Game.logger().error("could not get inventory eventhandler"); return null; } } @@ -204,7 +206,7 @@ public static EntityPlayer getCraftingSlotPlayer(SlotCrafting slot) { try { return (EntityPlayer) SLOTCRAFTING_PLAYER.get(slot); } catch (IllegalAccessException | NullPointerException ex) { - logError("could not get inventory eventhandler"); + Game.logger().error("could not get inventory eventhandler"); return null; } } @@ -214,7 +216,7 @@ public static LanguageMap getStringTranslateInstance() { Field field = getField(LanguageMap.class, ObfuscationConstants.STRINGTRANSLATE_INSTANCE); return (LanguageMap) field.get(null); } catch (IllegalAccessException ex) { - logError("could not get string translator"); + Game.logger().error("could not get string translator"); return null; } } @@ -223,7 +225,7 @@ public static ItemStack getSeedEntrySeed(Object entry) { try { return (ItemStack) SEEDENTRY_SEED.get(entry); } catch (IllegalAccessException ex) { - logError("could not get SeedEntry seed"); + Game.logger().error("could not get SeedEntry seed"); return null; } } @@ -233,7 +235,7 @@ public static void setCraftingRecipeList(List craftingRecipeList) { CraftingManager.getInstance(), craftingRecipeList, ObfuscationConstants.CRAFTINGMANAGER_RECIPES)) { - logError("could not set crafting recipe list"); + Game.logger().error("could not set crafting recipe list"); } } @@ -241,13 +243,13 @@ public static void setCraftingRecipeList(List craftingRecipeList) { try { return SEEDENTRY_CONSTRUCTOR.newInstance(MineTweakerMC.getItemStack(stack.getStack()), (int) stack.getChance()); } catch (InstantiationException ex) { - logError("could not construct SeedEntry"); + Game.logger().error("could not construct SeedEntry"); } catch (IllegalAccessException ex) { - logError("could not construct SeedEntry"); + Game.logger().error("could not construct SeedEntry"); } catch (IllegalArgumentException ex) { - logError("could not construct SeedEntry"); + Game.logger().error("could not construct SeedEntry"); } catch (InvocationTargetException ex) { - logError("could not construct SeedEntry"); + Game.logger().error("could not construct SeedEntry"); } return null; @@ -314,8 +316,4 @@ private static Field getField(Class cls, String... names) { return null; } - - private static void logError(String message) { - System.out.println("ERROR: " + message); - } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java index b18066a34..c8f9df8ff 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/BlockConverter.java @@ -161,6 +161,6 @@ private void registerNovaBlock(BlockFactory blockFactory) { } } - System.out.println("[NOVA]: Registered '" + blockFactory.getID() + "' block."); + Game.logger().info("Registered block: {}", blockFactory.getID()); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java index 756b6feb5..230601d04 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/backward/BWEntity.java @@ -88,12 +88,7 @@ public Entity entity() { } @Override - public String getUsername() { - return entity.getGameProfile().getName(); - } - - @Override - public String getID() { + public String getUniqueID() { return entity.getGameProfile().getId().toString(); } @@ -102,6 +97,11 @@ public InventoryPlayer getInventory() { return inventory; } + @Override + public String getUsername() { + return entity.getGameProfile().getName(); + } + @Override public String getDisplayName() { return entity.getDisplayName().getUnformattedText(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java index 73aea7d5a..232a16948 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/ItemConverter.java @@ -105,8 +105,6 @@ public Item getNovaItem(@Nonnull ItemStack stack) { return getNovaItem(copy); // Preserve capabilities } - // Nova FWCapabilityProvider stores capabilities in a HashMap, so we need this to be as fast as possible. - // So I implemented FWItemCapabilityProvider which has a single NovaItem capability field for near-instanteneous access. return Optional.ofNullable(stack.getCapability(NovaItem.CAPABILITY, null)) .map(wrapped -> wrapped.item) .orElseGet(() -> { @@ -225,11 +223,6 @@ private void registerNOVAItem(ItemFactory itemFactory) { if (itemWrapper == null) { throw new InitializationException("ItemConverter: Missing block: " + itemFactory.getID()); } - if (!itemFactory.getID().equals(Objects.toString(net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper)))) { - System.err.println("[NOVA]: ItemConverter: " + net.minecraft.item.Item.REGISTRY.getNameForObject(itemWrapper) + " != " + itemFactory.getID()); - net.minecraft.item.Item newItemWrapper = net.minecraft.item.Item.getByNameOrId(itemFactory.getID()); - itemWrapper = newItemWrapper != null ? newItemWrapper : itemWrapper; - } } else { itemWrapper = new FWItem(itemFactory); } @@ -251,7 +244,7 @@ private void registerNOVAItem(ItemFactory itemFactory) { itemWrapper.setCreativeTab(CategoryConverter.instance().toNative(category, itemWrapper)); } - System.out.println("[NOVA]: Registered '" + itemFactory.getID() + "' item."); + Game.logger().info("Registered item: {}", itemFactory.getID()); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java index 8a2c823cf..e29511923 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/item/OreDictionaryIntegration.java @@ -21,6 +21,7 @@ package nova.core.wrapper.mc.forge.v1_11_2.wrapper.item; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.oredict.OreDictionary; @@ -41,7 +42,7 @@ */ public class OreDictionaryIntegration { public static final OreDictionaryIntegration instance = new OreDictionaryIntegration(); - private static final List> OREDICT_CONTENTS = ReflectionUtil.getOreIdStacks(); + private static final List> OREDICT_CONTENTS = ReflectionUtil.getOreIdStacks(); private OreDictionaryIntegration() { } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java index 374c51332..d7cd43a8f 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java @@ -61,7 +61,7 @@ private MinecraftRecipeRegistry() { } public void registerRecipes() { - long startTime = System.currentTimeMillis(); + long startTime = System.nanoTime(); RecipeManager recipeManager = Game.recipes(); @@ -78,7 +78,7 @@ public void registerRecipes() { ReflectionUtil.setCraftingRecipeList(new RecipeListWrapper(recipes)); - System.out.println("Initialized recipes in " + (System.currentTimeMillis() - startTime) + " ms"); + Game.logger().info("Initialized recipes in {} ms", (System.nanoTime() - startTime) / 1_000_000); recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java index ce4db8fb5..dd95327a3 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/backward/MCCraftingGrid.java @@ -132,7 +132,7 @@ private void update() { for (int i = 0; i < inventory.getSizeInventory(); i++) { if (changed(i)) { - //System.out.println("Slot " + i + " changed"); + //Game.logger().info("Slot {} changed", i); original[i] = inventory.getStackInSlot(i); if (inventory.getStackInSlot(i) != null) { if (items[i] == null) { @@ -149,7 +149,7 @@ private void update() { } } } - //System.out.println("Num stack count: " + itemCount); + //Game.logger().info("Num stack count: {}", itemCount); } @Override @@ -189,7 +189,7 @@ public Optional getCrafting(int x, int y) { @Override public boolean setCrafting(int x, int y, Optional item) { - //System.out.println("SetStack(" + x + ", " + y + ") " + stack); + //Game.logger().info("setCrafting({}, {}) {}", x, y, item); int ix = y * width + x; if (item.isPresent()) { @@ -213,7 +213,7 @@ public boolean setCrafting(int x, int y, Optional item) { @Override public boolean setCrafting(int i, Optional item) { - //System.out.println("SetStack(" + i + ") " + stack); + //Game.logger().info("setCrafting({}) {}", i, item); if (item.isPresent()) { if (items[i] == null) { From aadf0576942f3509dd02325e2a7c63ea80429943 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 28 May 2017 19:47:36 +0200 Subject: [PATCH 55/61] Silence FML logs when registering blocks and items with a NOVA mod prefix --- .../mc/forge/v1_11_2/asm/StaticForwarder.java | 11 +++ .../mc/forge/v1_11_2/asm/lib/ASMHelper.java | 8 +- .../IForgeRegistryEntryTransformer.java | 93 +++++++++++++++++++ .../asm/transformers/Transformers.java | 1 + .../mc/forge/v1_11_2/util/ReflectionUtil.java | 13 +-- 5 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index cc5f751db..996db72bd 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -29,6 +29,7 @@ import nova.core.block.Block; import nova.core.component.misc.FactoryProvider; import nova.core.event.BlockEvent; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.backward.BWBlock; 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; @@ -88,4 +89,14 @@ public static TileEntity loadTileEntityHook(World world, NBTTagCompound data, Cl return clazz.newInstance(); } } + + /** + * Checks if the prefix is equal to the NOVA mod ID ("nova"). + * + * @param prefix The prefix to check + * @return If the prefix is equal to the NOVA mod ID ("nova"). + */ + public static boolean isNovaPrefix(String prefix) { + return NovaMinecraft.MOD_ID.equals(prefix); + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java index f6f2fd138..d3903bf51 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/lib/ASMHelper.java @@ -177,7 +177,7 @@ public static String printInsn(AbstractInsnNode insn) { } public static Map cloneLabels(InsnList insns) { - HashMap labelMap = new HashMap(); + HashMap labelMap = new HashMap<>(); for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext()) { if (insn.getType() == 8) { labelMap.put((LabelNode) insn, new LabelNode()); @@ -200,7 +200,7 @@ public static InsnList cloneInsnList(Map labelMap, InsnLis } public static List cloneTryCatchBlocks(Map labelMap, List tcblocks) { - ArrayList clone = new ArrayList(); + ArrayList clone = new ArrayList<>(tcblocks.size()); for (TryCatchBlockNode node : tcblocks) { clone.add(new TryCatchBlockNode(labelMap.get(node.start), labelMap.get(node.end), labelMap.get(node.handler), node.type)); } @@ -209,7 +209,7 @@ public static List cloneTryCatchBlocks(Map cloneLocals(Map labelMap, List locals) { - ArrayList clone = new ArrayList(); + ArrayList clone = new ArrayList<>(locals.size()); for (LocalVariableNode node : locals) { clone.add(new LocalVariableNode(node.name, node.desc, node.signature, labelMap.get(node.start), labelMap.get(node.end), node.index)); } @@ -314,6 +314,7 @@ public static Class defineClass(ClassNode cn, int flags) { try { byte[] bytes = createBytes(cn, flags); defineClass1.setAccessible(true); + @SuppressWarnings("unchecked") Class clazz = (Class) defineClass1.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length); defineClass1.setAccessible(false); return clazz; @@ -329,6 +330,7 @@ public static Class defineClass(ClassNode cn, int flags, ProtectionDomain try { byte[] bytes = createBytes(cn, flags); defineClass2.setAccessible(true); + @SuppressWarnings("unchecked") Class clazz = (Class) defineClass2.invoke(Thread.currentThread().getContextClassLoader(), cn.name.replaceAll("/", "."), bytes, 0, bytes.length, domain); defineClass2.setAccessible(false); return clazz; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java new file mode 100644 index 000000000..755ef66c4 --- /dev/null +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 NOVA, All rights reserved. + * 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 Lesser General Public License + * as published by 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NOVA. If not, see . + */ + +package nova.core.wrapper.mc.forge.v1_11_2.asm.transformers; + +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ASMHelper; +import nova.core.wrapper.mc.forge.v1_11_2.asm.lib.ObfMapping; +import nova.internal.core.Game; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.VarInsnNode; +import org.objectweb.asm.util.TraceClassVisitor; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * @author ExE Boss + */ +public class IForgeRegistryEntryTransformer implements Transformer { + + @Override + public void transform(ClassNode cnode) { + Game.logger().info("Transforming IForgeRegistryEntry class for correct NOVA mod id mapping."); + + ObfMapping mapping = new ObfMapping("net/minecraftforge/fml/common/registry/IForgeRegistryEntry$Impl", "setRegistryName", "(Ljava/lang/String;)Lnet/minecraftforge/fml/common/registry/IForgeRegistryEntry;"); + MethodNode method = ASMHelper.findMethod(mapping, cnode); + + if (method == null) { + throw new IllegalStateException("[NOVA] Lookup " + mapping + " failed!"); + } + + Game.logger().info("Transforming method {}", method.name); + + try { + File root = new File("NOVA-Debug"); + if (!root.exists()) + root.mkdir(); + + File file = new File(root, "IForgeRegistryEntryOriginal.java"); + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); + TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); + cnode.accept(traceClassVisitor); + } catch (IOException ex) {} + + InsnList list = new InsnList(); + list.add(new VarInsnNode(ALOAD, 5)); + list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder", "isNovaPrefix", "(Ljava/lang/String;)Z", false)); + list.add(new JumpInsnNode(IFNE, (LabelNode) method.instructions.get(120))); + + method.instructions.insert(method.instructions.get(101), list); + + try { + File file = new File("NOVA-Debug/IForgeRegistryEntryModified.java"); + if (file.exists()) { + file.delete(); + } + file.createNewFile(); + PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); + TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); + cnode.accept(traceClassVisitor); + } catch (IOException ex) {} + + Game.logger().info("Injected instruction to method: {}", method.name); + } +} diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java index daa158fdd..d750043a9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/Transformers.java @@ -37,6 +37,7 @@ public final class Transformers implements IClassTransformer { public Transformers() { registerTransformer(new ChunkTransformer(), "net.minecraft.world.chunk.Chunk"); registerTransformer(new TileEntityTransformer(), "net.minecraft.tileentity.TileEntity"); + registerTransformer(new IForgeRegistryEntryTransformer(), "net.minecraftforge.fml.common.registry.IForgeRegistryEntry$Impl"); } public static void registerTransformer(Transformer transformer, String... classes) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java index 9657e96d6..1034581a8 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java @@ -45,12 +45,10 @@ import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; +import java.util.Objects; /** * Common class for all runtime hacks (stuff requiring reflection). It is not @@ -58,6 +56,7 @@ * adjustment - as such, those have been collected here. * @author Stan Hebben */ +@SuppressWarnings("unchecked") public class ReflectionUtil { private static final Field NBTTAGLIST_TAGLIST; private static final Field OREDICTIONARY_IDTOSTACK; @@ -86,6 +85,7 @@ public class ReflectionUtil { try { forgeSeedEntry = (Class) Class.forName("net.minecraftforge.common.ForgeHooks$SeedEntry"); } catch (ClassNotFoundException ex) { + Game.logger().error("ReflectionUtil can't find SeedEntry", ex); } SEEDENTRY_SEED = getField(forgeSeedEntry, "seed"); @@ -93,10 +93,10 @@ public class ReflectionUtil { Constructor seedEntryConstructor = null; try { - seedEntryConstructor = forgeSeedEntry.getConstructor(ItemStack.class, int.class); + seedEntryConstructor = Objects.requireNonNull(forgeSeedEntry, "SeedEntry class is null").getConstructor(ItemStack.class, int.class); seedEntryConstructor.setAccessible(true); - } catch (NoSuchMethodException | SecurityException ex) { - Logger.getLogger(ReflectionUtil.class.getName()).log(Level.SEVERE, null, ex); + } catch (NoSuchMethodException | SecurityException | NullPointerException ex) { + Game.logger().error("ReflectionUtil can't find SeedEntry constructor", ex); } SEEDENTRY_CONSTRUCTOR = seedEntryConstructor; @@ -137,6 +137,7 @@ public static Map getChestLoot() { return Collections.emptyMap();//getPrivateStaticObject(ChestGenHooks.class, "chestInfo"); } + @SuppressWarnings("deprecation") public static Map getTranslations() { return getPrivateObject( getPrivateStaticObject(I18n.class, "localizedName", "field_74839_a"), From 232f29fe5058997c42103efa4b0fa727ee70a738 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 28 May 2017 19:56:22 +0200 Subject: [PATCH 56/61] Re-add accidentally deleted lines from `MinecraftRecipeRegistry` --- .../wrapper/recipes/MinecraftRecipeRegistry.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java index d7cd43a8f..33b9afebc 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/recipes/MinecraftRecipeRegistry.java @@ -24,6 +24,8 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.IRecipe; +import net.minecraftforge.oredict.RecipeSorter; +import net.minecraftforge.oredict.RecipeSorter.Category; import nova.core.event.RecipeEvent; import nova.core.item.Item; import nova.core.recipes.RecipeManager; @@ -32,6 +34,11 @@ import nova.core.recipes.smelting.SmeltingRecipe; import nova.core.wrapper.mc.forge.v1_11_2.util.ReflectionUtil; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.NovaCraftingRecipe; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapedRecipeOre; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeBasic; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.recipes.forward.ShapelessRecipeOre; import nova.internal.core.Game; import java.util.AbstractList; @@ -80,6 +87,14 @@ public void registerRecipes() { Game.logger().info("Initialized recipes in {} ms", (System.nanoTime() - startTime) / 1_000_000); + RecipeSorter.register("nova:shaped", ShapedRecipeBasic.class, Category.SHAPED, "before:forge:shapedore"); + RecipeSorter.register("nova:shaped.oredict", ShapedRecipeOre.class, Category.SHAPED, "after:nova:shaped after:minecraft:shaped before:minecraft:shapeless"); + + RecipeSorter.register("nova:shapeless", ShapelessRecipeBasic.class, Category.SHAPELESS, "after:minecraft:shapeless before:forge:shapelessore"); + RecipeSorter.register("nova:shapeless.oredict", ShapelessRecipeOre.class, Category.SHAPELESS, "after:nova:shapeless after:minecraft:shapeless"); + + RecipeSorter.register("nova:unknown", NovaCraftingRecipe.class, Category.UNKNOWN, ""); + recipeManager.whenRecipeAdded(CraftingRecipe.class, this::onNOVARecipeAdded); recipeManager.whenRecipeRemoved(CraftingRecipe.class, this::onNOVARecipeRemoved); From b13972ec89bd88e7507ad1827dbbf16d4d1bb77d Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 28 May 2017 19:56:36 +0200 Subject: [PATCH 57/61] Hide NOVA Preloader from the mod list --- .../wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java | 6 ++++++ .../core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index 2084f2fb6..c06d2c335 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -40,6 +40,7 @@ import net.minecraftforge.fml.relauncher.Side; import nova.core.loader.Mod; import nova.core.util.ClassLoaderUtil; +import nova.core.wrapper.mc.forge.v1_11_2.launcher.NovaMinecraft; 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; @@ -63,6 +64,8 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; +import java.util.logging.Level; +import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -266,6 +269,7 @@ public void load(FMLConstructionEvent event) { List fmlMods = ReflectionUtil.getPrivateObject(Loader.instance(), "mods"); List newMods = new ArrayList<>(); newMods.addAll(fmlMods); + newMods.stream().filter(mc -> NovaMinecraft.MOD_ID.equals(mc.getModId())).findFirst().ifPresent(nova -> md.parentMod = nova); modClasses.forEach(mod -> { ModMetadata fakeMeta = new ModMetadata(); Mod annotation = mod.getAnnotation(Mod.class); @@ -355,11 +359,13 @@ public void registerResourcePacks() { * A fake NovaMod to inject into FML. */ private static class NovaModContainer extends DummyModContainer { + private final ModMetadata meta; private final Class mod; private File source = null; public NovaModContainer(ModMetadata meta, Class mod) { super(meta); + this.meta = meta; this.mod = mod; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java index 1034581a8..b4e84937c 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java @@ -226,7 +226,7 @@ public static ItemStack getSeedEntrySeed(Object entry) { try { return (ItemStack) SEEDENTRY_SEED.get(entry); } catch (IllegalAccessException ex) { - Game.logger().error("could not get SeedEntry seed"); + Game.logger().error("could not get SeedEntry seed", ex); return null; } } From dca3c10ca5d00355a4756a04bd686651843073cd Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 28 May 2017 20:17:43 +0200 Subject: [PATCH 58/61] Add obfuscated code support to ChunkTransformer --- .../asm/transformers/ChunkTransformer.java | 14 +++++- .../IForgeRegistryEntryTransformer.java | 26 ----------- .../transformers/TileEntityTransformer.java | 44 ------------------- 3 files changed, 13 insertions(+), 71 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java index 39ecbdd4b..b431daa8d 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/ChunkTransformer.java @@ -39,7 +39,19 @@ public void transform(ClassNode cnode) { Game.logger().info("Transforming Chunk class for chunkModified event."); //obf name: func_177436_a - MethodNode method = ASMHelper.findMethod(new ObfMapping("net/minecraft/world/chunk/Chunk", "setBlockState", "(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/block/state/IBlockState;"), cnode); + ObfMapping obfMap = new ObfMapping("auo", "a", "(Lco;Latl;)Latl;"); + ObfMapping deobfMap = new ObfMapping("net/minecraft/world/chunk/Chunk", "setBlockState", "(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/state/IBlockState;)Lnet/minecraft/block/state/IBlockState;"); + + MethodNode method = ASMHelper.findMethod(obfMap, cnode); + + if (method == null) { + Game.logger().warn("Lookup {} failed. You are probably in a deobf environment.", obfMap); + method = ASMHelper.findMethod(deobfMap, cnode); + + if (method == null) { + throw new IllegalStateException("[NOVA] Lookup " + deobfMap + " failed!"); + } + } Game.logger().info("Found method {}", method.name); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java index 755ef66c4..1f7883453 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/IForgeRegistryEntryTransformer.java @@ -55,21 +55,6 @@ public void transform(ClassNode cnode) { Game.logger().info("Transforming method {}", method.name); - try { - File root = new File("NOVA-Debug"); - if (!root.exists()) - root.mkdir(); - - File file = new File(root, "IForgeRegistryEntryOriginal.java"); - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); - TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); - cnode.accept(traceClassVisitor); - } catch (IOException ex) {} - InsnList list = new InsnList(); list.add(new VarInsnNode(ALOAD, 5)); list.add(new MethodInsnNode(INVOKESTATIC, "nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder", "isNovaPrefix", "(Ljava/lang/String;)Z", false)); @@ -77,17 +62,6 @@ public void transform(ClassNode cnode) { method.instructions.insert(method.instructions.get(101), list); - try { - File file = new File("NOVA-Debug/IForgeRegistryEntryModified.java"); - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); - TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); - cnode.accept(traceClassVisitor); - } catch (IOException ex) {} - Game.logger().info("Injected instruction to method: {}", method.name); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java index db64cf554..91e826d8d 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/transformers/TileEntityTransformer.java @@ -29,20 +29,9 @@ import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.VarInsnNode; -import org.objectweb.asm.util.TraceClassVisitor; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintWriter; public class TileEntityTransformer implements Transformer { - /** - * If the TileEntity byte code should be written to a debug file. (One for the unmodified version, and one for the modified version) - */ - public static boolean writeDebug = false; - @Override public void transform(ClassNode cnode) { @@ -53,12 +42,9 @@ public void transform(ClassNode cnode) { MethodNode method = ASMHelper.findMethod(obfMap, cnode); - boolean deobf = false; - if (method == null) { Game.logger().warn("Lookup {} failed. You are probably in a deobf environment.", obfMap); method = ASMHelper.findMethod(deobfMap, cnode); - deobf = true; if (method == null) { throw new IllegalStateException("[NOVA] Lookup " + deobfMap + " failed!"); @@ -67,23 +53,6 @@ public void transform(ClassNode cnode) { Game.logger().info("Transforming method {}", method.name); - if (writeDebug) { - try { - File root = new File("NOVA-Debug"); - if (!root.exists()) - root.mkdir(); - - File file = new File(root, "TileEntityOriginal.java"); - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); - TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); - cnode.accept(traceClassVisitor); - } catch (IOException ex) {} - } - ASMHelper.removeBlock(method.instructions, new InstructionComparator.InsnListSection(method.instructions, 30, 33)); InsnList list = new InsnList(); @@ -95,19 +64,6 @@ public void transform(ClassNode cnode) { method.instructions.insert(method.instructions.get(29), list); - if (writeDebug) { - try { - File file = new File("NOVA-Debug/TileEntityModified.java"); - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - PrintWriter printWriter = new PrintWriter(new FileOutputStream(file)); - TraceClassVisitor traceClassVisitor = new TraceClassVisitor(printWriter); - cnode.accept(traceClassVisitor); - } catch (IOException ex) {} - } - Game.logger().info("Injected instruction to method: {}", method.name); } } From 413f3640f340ba8ba2db792be1785656497e10ee Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Thu, 19 Oct 2017 23:43:06 +0200 Subject: [PATCH 59/61] Update Minecraft Forge to 1.11.2-13.20.1.2386 --- minecraft/1.11.2/build.gradle | 2 +- minecraft/1.11.2/gradle.properties | 2 +- .../mc/forge/v1_11_2/NovaMinecraftPreloader.java | 6 +++--- .../wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java | 2 +- .../forge/v1_11_2/manager/config/NovaGuiFactory.java | 10 ++++++++++ .../mc/forge/v1_11_2/wrapper/VectorConverter.java | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/minecraft/1.11.2/build.gradle b/minecraft/1.11.2/build.gradle index 86a50ea88..e21d5efcb 100644 --- a/minecraft/1.11.2/build.gradle +++ b/minecraft/1.11.2/build.gradle @@ -111,7 +111,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' minecraft { version = property("minecraft.version") + "-" + property("forge.version") - mappings = 'snapshot_20170407' + mappings = 'snapshot_20170612' runDir = "run" } diff --git a/minecraft/1.11.2/gradle.properties b/minecraft/1.11.2/gradle.properties index 4d6000c88..6c3c1709c 100644 --- a/minecraft/1.11.2/gradle.properties +++ b/minecraft/1.11.2/gradle.properties @@ -1,7 +1,7 @@ group = nova.core minecraft.version = 1.11.2 -forge.version = 13.20.0.2228 +forge.version = 13.20.1.2386 forgeGradleVersion = 2.2-SNAPSHOT packaging = jar diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java index c06d2c335..c89b891d8 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/NovaMinecraftPreloader.java @@ -186,12 +186,12 @@ private static JsonGenerator generateSoundJSON(FolderResourcePack pack, JsonGene public static String generatePackMcmeta() { StringWriter sw = new StringWriter(); try (JsonGenerator json = Json.createGenerator(sw);) { - json.writeStartObject() // { + json.writeStartObject() // { .writeStartObject("pack") // "pack": { .write("description", "NOVA mod resource pack") // "description": "NOVA mod resource pack", - .write("pack_format", 1) // "pack_format": 1 + .write("pack_format", 3) // "pack_format": 3 // Required by 1.11+ .writeEnd() // } - .writeEnd() // } + .writeEnd() // } .flush(); return sw.toString(); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java index 996db72bd..544b27f37 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/asm/StaticForwarder.java @@ -50,7 +50,7 @@ private StaticForwarder() {} public static void chunkSetBlockEvent(Chunk chunk, BlockPos pos, IBlockState oldBlockState, IBlockState newBlockState) { nova.core.world.World world = WorldConverter.instance().toNova(chunk.getWorld()); - Vector3D position = new Vector3D((chunk.xPosition << 4) + pos.getX(), pos.getY(), (chunk.zPosition << 4) + pos.getZ()); + Vector3D position = new Vector3D((chunk.x << 4) + pos.getX(), pos.getY(), (chunk.z << 4) + pos.getZ()); Block oldBlockInstance; Block newBlockInstance; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java index a40439757..e9d82af54 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java @@ -35,6 +35,16 @@ public void initialize(Minecraft minecraftInstance) { } + @Override + public boolean hasConfigGui() { + return false; + } + + @Override + public GuiScreen createConfigGui(GuiScreen parentScreen) { + return null; + } + @Override public Class mainConfigGuiClass() { return NovaGuiConfig.class; diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java index b778f1cde..9dfc195d7 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/VectorConverter.java @@ -43,7 +43,7 @@ public Class getNativeSide() { } public Vector3D toNova(Vec3d pos) { - return new Vector3D(pos.xCoord, pos.yCoord, pos.zCoord); + return new Vector3D(pos.x, pos.y, pos.z); } @Override From c7d2a41eb40435f13debecff6ca799d5445aff62 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 24 Oct 2017 11:11:11 +0200 Subject: [PATCH 60/61] Update to master --- .../v1_11_2/launcher/FMLEventHandler.java | 5 +- .../v1_11_2/launcher/ForgeEventHandler.java | 16 ++-- .../v1_11_2/manager/MCRetentionManager.java | 14 +-- .../manager/config/NovaGuiFactory.java | 2 + .../network/discriminator/NovaPacket.java | 5 +- .../mc/forge/v1_11_2/util/ReflectionUtil.java | 3 +- .../mc/forge/v1_11_2/util/WrapUtility.java | 7 +- .../wrapper/block/backward/BWBlock.java | 15 ++- .../block/backward/BWBlockTransform.java | 7 +- .../wrapper/block/forward/FWBlock.java | 91 +++++++++++++------ .../v1_11_2/wrapper/block/forward/FWTile.java | 5 +- .../wrapper/block/forward/ProxyMaterial.java | 8 +- .../v1_11_2/wrapper/block/world/BWWorld.java | 13 +-- .../forward/NovaCapabilityProvider.java | 11 ++- .../wrapper/entity/forward/FWEntity.java | 19 ++-- .../entity/forward/MCEntityTransform.java | 11 ++- .../wrapper/inventory/BWInventory.java | 15 +-- .../particle/forward/MCParticleTransform.java | 3 +- .../render/forward/FWSmartBlockModel.java | 17 ++-- .../render/forward/FWSmartItemModel.java | 17 ++-- 20 files changed, 165 insertions(+), 119 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java index b53428620..c1c38b432 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/FMLEventHandler.java @@ -23,6 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import nova.core.event.PlayerEvent; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.internal.core.Game; /** @@ -32,12 +33,12 @@ public class FMLEventHandler { @SubscribeEvent public void playerJoin(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent evt) { - Game.events().publish(new PlayerEvent.Join(Game.natives().toNova(evt.player))); + Game.events().publish(new PlayerEvent.Join(EntityConverter.instance().toNova(evt.player))); } @SubscribeEvent public void playerLeave(net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent evt) { - Game.events().publish(new PlayerEvent.Leave(Game.natives().toNova(evt.player))); + Game.events().publish(new PlayerEvent.Leave(EntityConverter.instance().toNova(evt.player))); } @SubscribeEvent diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java index f64e066ad..b2b758d03 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ForgeEventHandler.java @@ -29,9 +29,11 @@ import net.minecraftforge.oredict.OreDictionary; import nova.core.item.Item; import nova.core.item.ItemDictionary; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; -import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; /** * @author Stan, Calclavia @@ -40,12 +42,12 @@ public class ForgeEventHandler { @SubscribeEvent public void worldUnload(WorldEvent.Load evt) { - Game.events().publish(new nova.core.event.WorldEvent.Load(Game.natives().toNova(evt.getWorld()))); + Game.events().publish(new nova.core.event.WorldEvent.Load(WorldConverter.instance().toNova(evt.getWorld()))); } @SubscribeEvent public void worldLoad(WorldEvent.Unload evt) { - Game.events().publish(new nova.core.event.WorldEvent.Unload(Game.natives().toNova(evt.getWorld()))); + Game.events().publish(new nova.core.event.WorldEvent.Unload(WorldConverter.instance().toNova(evt.getWorld()))); } @SubscribeEvent @@ -60,11 +62,11 @@ public void onOreRegister(OreDictionary.OreRegisterEvent event) { @SubscribeEvent public void playerInteractEvent(PlayerInteractEvent event) { - if (event.getWorld() != null && event.getPos() != null) { + if (event.getWorld() != null) { nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact( - Game.natives().toNova(event.getWorld()), - new Vector3D(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ()), - Game.natives().toNova(event.getEntityPlayer()), + WorldConverter.instance().toNova(event.getWorld()), + VectorConverter.instance().toNova(event.getPos()), + EntityConverter.instance().toNova(event.getEntityPlayer()), nova.core.event.PlayerEvent.Interact.Action.values()[toNovaInteractOrdinal(event)] ); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java index c952ec1e0..a3cdd0573 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/MCRetentionManager.java @@ -22,20 +22,20 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.server.FMLServerHandler; import nova.core.retention.Data; import nova.core.retention.Storable; import nova.core.util.registry.RetentionManager; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import net.minecraftforge.fml.server.FMLServerHandler; /** * A manager that handles external file saving. @@ -60,13 +60,13 @@ public void saveAll() { public void save(String filename, Storable storable) { Data saveMap = new Data(); storable.save(saveMap); - saveFile(filename, Game.natives().toNative(saveMap)); + saveFile(filename, DataConverter.instance().toNative(saveMap)); } @Override public void load(String filename, Storable storable) { NBTTagCompound nbt = loadFile(filename); - storable.load(Game.natives().toNova(nbt)); + storable.load(DataConverter.instance().toNova(nbt)); } /** @@ -77,7 +77,7 @@ public void load(String filename, Storable storable) { */ public boolean saveFile(File file, NBTTagCompound data) { try { - File tempFile = new File(file.getParent(), file.getName() + "_tmp.dat"); + File tempFile = new File(file.getParent(), file.getName().replaceFirst("\\.nbt$", ".tmp.nbt")); CompressedStreamTools.writeCompressed(data, new FileOutputStream(tempFile)); @@ -95,7 +95,7 @@ public boolean saveFile(File file, NBTTagCompound data) { } public boolean saveFile(File saveDirectory, String filename, NBTTagCompound data) { - return saveFile(new File(saveDirectory, filename + ".dat"), data); + return saveFile(new File(saveDirectory, filename + ".nbt"), data); } public boolean saveFile(String filename, NBTTagCompound data) { @@ -123,7 +123,7 @@ public NBTTagCompound loadFile(File file) { * @return The NBT data */ public NBTTagCompound loadFile(File saveDirectory, String filename) { - return loadFile(new File(saveDirectory, filename + ".dat")); + return loadFile(new File(saveDirectory, filename + ".nbt")); } public NBTTagCompound loadFile(String filename) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java index e9d82af54..84cb09be4 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/manager/config/NovaGuiFactory.java @@ -46,6 +46,7 @@ public GuiScreen createConfigGui(GuiScreen parentScreen) { } @Override + @Deprecated public Class mainConfigGuiClass() { return NovaGuiConfig.class; } @@ -56,6 +57,7 @@ public Set runtimeGuiCategories() { } @Override + @Deprecated public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java index 15e6810e8..2a88a9fbb 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/network/discriminator/NovaPacket.java @@ -23,11 +23,10 @@ import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; import net.minecraft.entity.player.EntityPlayer; -import nova.core.entity.Entity; -import nova.core.entity.component.Player; import nova.core.network.handler.PacketHandler; import nova.core.wrapper.mc.forge.v1_11_2.network.MCPacket; import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; +import nova.core.wrapper.mc.forge.v1_11_2.util.WrapUtility; import nova.internal.core.Game; /** @@ -65,7 +64,7 @@ public void handle(EntityPlayer player) { MCNetworkManager network = (MCNetworkManager) Game.network(); PacketHandler packetHandler = network.getPacketType(data.readInt()); int subId = data.readInt(); - MCPacket packet = new MCPacket(data.slice(), ((Entity) Game.natives().toNova(player)).components.get(Player.class)); + MCPacket packet = new MCPacket(data.slice(), WrapUtility.getNovaPlayer(player).get()); //Set the ID of the packet packet.setID(subId); packetHandler.read(packet); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java index b4e84937c..64eebe236 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/ReflectionUtil.java @@ -34,7 +34,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.NonNullList; import net.minecraft.util.WeightedRandom; -import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.LanguageMap; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fml.common.registry.EntityRegistry; @@ -140,7 +139,7 @@ public static Map getChestLoot() { @SuppressWarnings("deprecation") public static Map getTranslations() { return getPrivateObject( - getPrivateStaticObject(I18n.class, "localizedName", "field_74839_a"), + getPrivateStaticObject(net.minecraft.util.text.translation.I18n.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c"); } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java index 3b19c3ef9..b9b7b7c7e 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/util/WrapUtility.java @@ -24,11 +24,12 @@ import net.minecraft.item.Item; import nova.core.entity.Entity; import nova.core.entity.component.Player; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.backward.BWEntity; -import nova.internal.core.Game; import java.util.Objects; import java.util.Optional; +import javax.annotation.Nullable; /** * Wrap utility methods. @@ -38,10 +39,10 @@ public class WrapUtility { private WrapUtility() {} - public static Optional getNovaPlayer(EntityPlayer player) { + public static Optional getNovaPlayer(@Nullable EntityPlayer player) { if (player == null) return Optional.empty(); - return ((Entity)Game.natives().toNova(player)).components.getOp(Player.class); + return EntityConverter.instance().toNova(player).components.getOp(Player.class); } public static String getItemID(Item item, int meta) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java index f0aa340b0..359665469 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlock.java @@ -81,7 +81,11 @@ public BWBlock(net.minecraft.block.Block block) { public BWBlock(IBlockState blockState, World world, Vector3D pos) { this.blockState = blockState; components.add(new BWBlockTransform(this, world, pos)); - components.add(new BlockProperty.Opacity().setOpacity(blockState().getMaterial().blocksLight() ? 1 : 0)); + components.add(new BlockProperty.Opacity()).setOpacity(() -> blockState().getMaterial().isOpaque() ? 1 : 0); + BlockProperty.Replaceable replaceable = components.add(new BlockProperty.Replaceable()); + if (block() != Blocks.AIR) { + replaceable.setReplaceable(() -> block().canPlaceBlockAt((net.minecraft.world.World) blockAccess(), blockPos())); + } BlockProperty.BlockSound blockSound = components.add(new BlockProperty.BlockSound()); SoundType soundType; @@ -135,7 +139,7 @@ public BWBlock(IBlockState blockState, World world, Vector3D pos) { } else { bb = blockState().getBoundingBox(blockAccess(), blockPos()).offset(blockPos()); } - Cuboid cuboid = Game.natives().toNova(bb); + Cuboid cuboid = CuboidConverter.instance().toNova(bb); return Collections.singleton(cuboid.subtract(position())); }); components.add(new StaticRenderer()) @@ -228,11 +232,6 @@ public Optional tile() { return Optional.ofNullable(mcTileEntity); } - @Override - public boolean canReplace() { - return block().canPlaceBlockAt((net.minecraft.world.World) blockAccess(), blockPos()); - } - @Override public boolean shouldDisplacePlacement() { if (block() == Blocks.SNOW_LAYER && (blockState().getValue(BlockSnow.LAYERS) < 1)) { @@ -254,7 +253,7 @@ public void save(Data data) { @Override public void load(Data data) { Storable.super.load(data); - tile().ifPresent(tile -> tile.deserializeNBT(Game.natives().toNative(data))); + tile().ifPresent(tile -> tile.deserializeNBT(DataConverter.instance().toNative(data))); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java index e988b474a..d04e7404b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/backward/BWBlockTransform.java @@ -27,7 +27,6 @@ import nova.core.world.World; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; -import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; import java.util.Optional; @@ -68,8 +67,8 @@ public IBlockAccess blockAccess() { @Override public void setWorld(World world) { BlockPos pos = blockPos(); - net.minecraft.world.World oldWorld = Game.natives().toNative(this.world); - net.minecraft.world.World newWorld = Game.natives().toNative(world); + net.minecraft.world.World oldWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world); + net.minecraft.world.World newWorld = (net.minecraft.world.World) WorldConverter.instance().toNative(world); Optional tileEntity = Optional.ofNullable(oldWorld.getTileEntity(pos)); Optional nbt = Optional.empty(); if (tileEntity.isPresent()) { @@ -91,7 +90,7 @@ public void setWorld(World world) { public void setPosition(Vector3D position) { BlockPos oldPos = blockPos(); BlockPos newPos = VectorConverter.instance().toNative(position); - net.minecraft.world.World world = Game.natives().toNative(this.world); + net.minecraft.world.World world = (net.minecraft.world.World) WorldConverter.instance().toNative(this.world); Optional tileEntity = Optional.ofNullable(blockAccess().getTileEntity(oldPos)); Optional nbt = Optional.empty(); if (tileEntity.isPresent()) { diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java index 07525855c..ed65dbf93 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWBlock.java @@ -54,6 +54,8 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.VectorConverter; 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.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -116,7 +118,7 @@ private FWBlock(BlockFactory factory, Block dummy) { this.fullBlock = getDefaultState().isOpaqueCube(); this.lightOpacity = dummy.components .getOp(BlockProperty.Opacity.class) - .map(o -> MathUtil.clamp((int) Math.round(o.opacity * 255), 0, 255)) + .map(o -> MathUtil.clamp((int) Math.round(o.getOpacity() * 255), 0, 255)) .orElse(this.fullBlock ? 255 : 0); this.translucent = !this.fullBlock; } @@ -125,6 +127,10 @@ public BlockFactory getFactory() { return this.factory; } + public Block getBlockInstance(IBlockAccess access, BlockPos position) { + return getBlockInstance(access, VectorConverter.instance().toNova(position)); + } + public Block getBlockInstance(IBlockAccess access, Vector3D position) { /** * If this block has a TileEntity, forward the method into the Stateful @@ -166,7 +172,7 @@ public void onBlockHarvested(World world, BlockPos pos, IBlockState state, Entit // hack is needed because the player sets the block to air *before* // getting the drops. woo good logic from mojang. if (!player.capabilities.isCreativeMode) { - harvestedBlocks.put(new BlockPosition(world, pos.getX(), pos.getY(), pos.getZ()), getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + harvestedBlocks.put(new BlockPosition(world, pos.getX(), pos.getY(), pos.getZ()), getBlockInstance(world, pos)); } } @@ -180,7 +186,7 @@ public List getDrops(IBlockAccess world, BlockPos pos, IBlockState st if (harvestedBlocks.containsKey(position)) { blockInstance = harvestedBlocks.remove(position); } else { - blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + blockInstance = getBlockInstance(world, pos); } Block.DropEvent event = new Block.DropEvent(blockInstance); @@ -228,15 +234,15 @@ public void neighborChanged(IBlockState state, World world, BlockPos pos, net.mi @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(world, pos); Block.NeighborChangeEvent evt = new Block.NeighborChangeEvent(Optional.of(VectorConverter.instance().toNova(neighbor))); blockInstance.events.publish(evt); } @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(Game.natives().toNova(player))); + Block blockInstance = getBlockInstance(world, pos); + Block.RemoveEvent evt = new Block.RemoveEvent(Optional.of(EntityConverter.instance().toNova(player))); blockInstance.events.publish(evt); if (evt.result) { return super.removedByPlayer(state, world, pos, player, willHarvest); @@ -246,9 +252,9 @@ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, Ent @Override public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(world, pos); Optional mop = Optional.ofNullable(player.rayTrace(10, 1)); - Block.LeftClickEvent evt = new Block.LeftClickEvent(Game.natives().toNova(player), + Block.LeftClickEvent evt = new Block.LeftClickEvent(EntityConverter.instance().toNova(player), DirectionConverter.instance().toNova(mop.map(m -> m.sideHit).orElse(null)), mop.map(m -> m.hitVec).map(VectorConverter.instance()::toNova).orElseGet(() -> VectorConverter.instance().toNova(pos))); blockInstance.events.publish(evt); @@ -256,22 +262,22 @@ public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - Block.RightClickEvent evt = new Block.RightClickEvent(Game.natives().toNova(player), DirectionConverter.instance().toNova(side), new Vector3D(hitX, hitY, hitZ)); + Block blockInstance = getBlockInstance(world, pos); + Block.RightClickEvent evt = new Block.RightClickEvent(EntityConverter.instance().toNova(player), DirectionConverter.instance().toNova(side), new Vector3D(hitX, hitY, hitZ)); blockInstance.events.publish(evt); return evt.result; } @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); - blockInstance.components.getOp(Collider.class).ifPresent(collider -> blockInstance.events.publish(new Collider.CollideEvent(Game.natives().toNova(entity)))); + Block blockInstance = getBlockInstance(world, pos); + blockInstance.components.getOp(Collider.class).ifPresent(collider -> blockInstance.events.publish(new Collider.CollideEvent(EntityConverter.instance().toNova(entity)))); } @Override @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess access, BlockPos pos) { - Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(access, pos); if (blockInstance.components.has(Collider.class)) { Cuboid cuboid = blockInstance.components.get(Collider.class).boundingBox.get(); return new AxisAlignedBB(cuboid.min.getX(), cuboid.min.getY(), cuboid.min.getZ(), cuboid.max.getX(), cuboid.max.getY(), cuboid.max.getZ()); @@ -282,14 +288,14 @@ public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess access, Bloc @Override @Deprecated public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(world, pos); if (blockInstance.components.has(Collider.class)) { Collider collider = blockInstance.components.get(Collider.class); Set cuboids = collider.selectionBoxes.apply(Optional.empty()); Cuboid cuboid = cuboids.stream().reduce(collider.boundingBox.get(), (c1, c2) -> new Cuboid(Vector3DUtil.min(c1.min, c2.min), Vector3DUtil.max(c1.max, c2.max))); - return Game.natives().toNative(cuboid.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ()))); + return CuboidConverter.instance().toNative(cuboid.add(VectorConverter.instance().toNova(pos))); } return super.getSelectedBoundingBox(state, world, pos); } @@ -297,17 +303,17 @@ public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, Bloc @Override @Deprecated public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB boundingBox, List list, Entity entity, boolean b) { - Block blockInstance = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(world, pos); blockInstance.components.getOp(Collider.class).ifPresent( collider -> { - Set boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? Game.natives().toNova(entity) : null)); + Set boxes = collider.occlusionBoxes.apply(Optional.ofNullable(entity != null ? EntityConverter.instance().toNova(entity) : null)); list.addAll( boxes .stream() - .map(c -> c.add(new Vector3D(pos.getX(), pos.getY(), pos.getZ()))) - .filter(c -> c.intersects((Cuboid) Game.natives().toNova(boundingBox))) - .map(cuboid -> (AxisAlignedBB) Game.natives().toNative(cuboid)) + .map(c -> c.add(VectorConverter.instance().toNova(pos))) + .filter(c -> c.intersects(CuboidConverter.instance().toNova(boundingBox))) + .map(CuboidConverter.instance()::toNative) .collect(Collectors.toList()) ); } @@ -333,7 +339,7 @@ public boolean isOpaqueCube(IBlockState state) { @Override public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) { - Optional blockCollider = getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).components.getOp(Collider.class); + Optional blockCollider = getBlockInstance(world, pos).components.getOp(Collider.class); if (blockCollider.isPresent()) { return blockCollider.get().isCube.get(); @@ -356,7 +362,7 @@ public boolean isFullCube(IBlockState state) { @Override public int getLightValue(IBlockState state, IBlockAccess access, BlockPos pos) { - Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(access, pos); Optional opEmitter = blockInstance.components.getOp(LightEmitter.class); if (opEmitter.isPresent()) { @@ -373,7 +379,7 @@ public BlockRenderLayer getBlockLayer() { @Override public boolean canConnectRedstone(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { - Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(access, pos); WrapperEvent.RedstoneConnect event = new WrapperEvent.RedstoneConnect(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); Game.events().publish(event); return event.canConnect; @@ -382,7 +388,7 @@ public boolean canConnectRedstone(IBlockState state, IBlockAccess access, BlockP @Override @Deprecated public int getWeakPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { - Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(access, pos); WrapperEvent.WeakRedstone event = new WrapperEvent.WeakRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); Game.events().publish(event); return event.power; @@ -391,7 +397,7 @@ public int getWeakPower(IBlockState state, IBlockAccess access, BlockPos pos, En @Override @Deprecated public int getStrongPower(IBlockState state, IBlockAccess access, BlockPos pos, EnumFacing side) { - Block blockInstance = getBlockInstance(access, new Vector3D(pos.getX(), pos.getY(), pos.getZ())); + Block blockInstance = getBlockInstance(access, pos); WrapperEvent.StrongRedstone event = new WrapperEvent.StrongRedstone(blockInstance.world(), blockInstance.position(), Direction.fromOrdinal(side.ordinal())); Game.events().publish(event); return event.power; @@ -410,12 +416,43 @@ public String getLocalizedName() { @Override public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { // TODO: Maybe do something withPriority these parameters. - return (float) getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).getResistance() * 30; + + // This number was calculated from the blast resistance of Stone, + // which requires exactly one cubic meter of TNT to get blown up. + // + // 1. During construction, the setResistance method is called + // on minecraft:stone with a value of 10. + // + // 2. The setResistance method multiplies that by 3 and assigns + // the result to the blockResistance instance variable. + // + // 3. Finally, the getExplosionResistance method divides the + // blockResistance instance variable by 5 and returns the result. + // + // From this we see that minecraft:stone’s final blast resistance is 6. + + return (float) getBlockInstance(world, pos).getResistance() * 6; } @Override @Deprecated public float getBlockHardness(IBlockState state, World world, BlockPos pos) { - return (float) getBlockInstance(world, new Vector3D(pos.getX(), pos.getY(), pos.getZ())).getHardness() * 2; + return (float) getBlockInstance(world, pos).getHardness() * 2; + } + + @Override + public int getLightOpacity(IBlockState state, IBlockAccess world, BlockPos pos) { + return getBlockInstance(world, pos) + .components.getOp(BlockProperty.Opacity.class) + .map(o -> MathUtil.clamp((int) Math.round(o.getOpacity() * 255), 0, 255)) + .orElse(this.fullBlock ? 255 : 0); + } + + @Override + public boolean isReplaceable(IBlockAccess world, BlockPos pos) { + return getBlockInstance(world, pos) + .components.getOp(BlockProperty.Replaceable.class) + .filter(BlockProperty.Replaceable::isReplaceable) + .isPresent(); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java index 1d06976ec..0a18833ac 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/FWTile.java @@ -41,6 +41,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.network.netty.MCNetworkManager; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; import java.io.IOException; @@ -115,7 +116,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) { if (block instanceof Storable) { Data data = new Data(); ((Storable) block).save(data); - nbt.setTag("nova", Game.natives().toNative(data)); + nbt.setTag("nova", DataConverter.instance().toNative(data)); } } @@ -127,7 +128,7 @@ public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); blockID = nbt.getString("novaID"); - cacheData = Game.natives().toNova(nbt.getCompoundTag("nova")); + cacheData = DataConverter.instance().toNova(nbt.getCompoundTag("nova")); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java index f65de03c8..db920ac5b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/forward/ProxyMaterial.java @@ -17,7 +17,7 @@ public class ProxyMaterial extends Material { * Construct a new proxy material. * @param color The map color. * @param opacity The Opacity to use. - * @param replaceable The Replaceable to use. + * @param replaceable If this block is replaceable. */ public ProxyMaterial(MapColor color, Optional opacity, Optional replaceable) { super(color); @@ -27,16 +27,16 @@ public ProxyMaterial(MapColor color, Optional opacity, Op @Override public boolean blocksLight() { - return opacity.isPresent() ? opacity.get().opacity == 1 : super.blocksLight(); + return opacity.map(BlockProperty.Opacity::isOpaque).orElseGet(super::blocksLight); } @Override public boolean isOpaque() { - return opacity.isPresent() ? opacity.get().opacity == 1 : super.isOpaque(); + return opacity.map(BlockProperty.Opacity::isOpaque).orElseGet(super::isOpaque); } @Override public boolean isReplaceable() { - return replaceable.isPresent() || super.isReplaceable(); + return replaceable.map(BlockProperty.Replaceable::isReplaceable).orElseGet(super::isReplaceable); } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java index 87fcf906f..88ba22ae9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/block/world/BWWorld.java @@ -26,7 +26,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import nova.core.block.Block; import nova.core.block.BlockFactory; @@ -47,6 +46,7 @@ import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.EntityConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.FWEntity; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.entity.forward.MCEntityTransform; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -137,8 +137,9 @@ public Entity addClientEntity(EntityFactory factory) { } @Override - public Entity addClientEntity(Entity entity) { - return NovaMinecraft.proxy.spawnParticle(world(), entity); + @SuppressWarnings("unchecked") + public T addClientEntity(T entity) { + return (T) NovaMinecraft.proxy.spawnParticle(world(), entity); } @Override @@ -163,14 +164,14 @@ public Set getEntities(Cuboid bound) { @Override public Entity addEntity(Vector3D position, Item item) { - EntityItem entityItem = new EntityItem(world(), position.getX(), position.getY(), position.getZ(), Game.natives().toNative(item)); + EntityItem entityItem = new EntityItem(world(), position.getX(), position.getY(), position.getZ(), ItemConverter.instance().toNative(item)); world().spawnEntity(entityItem); - return Game.natives().toNova(entityItem); + return EntityConverter.instance().toNova(entityItem); } @Override public Optional getEntity(String uniqueID) { - return Optional.ofNullable(Game.natives().toNova(world().getEntityByID(Integer.parseInt(uniqueID)))); + return Optional.ofNullable(EntityConverter.instance().toNova(world().getEntityByID(Integer.parseInt(uniqueID)))); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java index 3ee9c6371..01b42ecec 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/capability/forward/NovaCapabilityProvider.java @@ -42,9 +42,10 @@ public interface NovaCapabilityProvider extends ICapabilityProvider { * for a capability. *

* Example: - * A Pipe getting a cover placed on one side causing it loose the {@link nova.core.component.inventory.Inventory} attachment function for that side. + * A Pipe getting a cover placed on one side causing it lose the + * {@link nova.core.component.inventory.Inventory} attachment function for that side. * - * @param capability The capability to check + * @param capability The capability to check. * @param direction The Side to check from: @link nova.core.util.Direction.UNKNOWN UNKNOWN} * is defined to represent 'internal' or 'self' or used for cases where side doesn't matter. * @return True if this object supports the capability for this side. @@ -61,10 +62,12 @@ default boolean hasCapability(@Nonnull Capability capability, @Nullable EnumF * The return value is {@link Optional#empty()} when the object does not support the capability for the direction. * The return value can be the same for multiple faces. *

- * @param capability The capability to check + * @param capability The capability to check. * @param direction The Side to check from: @link nova.core.util.Direction.UNKNOWN UNKNOWN} * is defined to represent 'internal' or 'self' or used for cases where side doesn't matter. - * @return The requested capability. Returns an empty optional when {@link #hasCapability(Capability, EnumFacing)} would return false. + * @param The capability type to check. + * @return The requested capability. Returns an empty optional when + * {@link #hasCapability(Capability, EnumFacing)} would return false. */ @Nonnull Optional getCapability(@Nonnull Capability capability, @Nonnull Direction direction); diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java index 1f6da4560..fd8cebded 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/FWEntity.java @@ -41,15 +41,14 @@ import nova.core.wrapper.mc.forge.v1_11_2.util.WrapperEvent; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.DirectionConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.capability.forward.NovaCapabilityProvider; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.cuboid.CuboidConverter; import nova.core.wrapper.mc.forge.v1_11_2.wrapper.data.DataConverter; import nova.internal.core.Game; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - /** * Entity wrapper * @author Calclavia @@ -74,7 +73,7 @@ public FWEntity(World world, EntityFactory factory) { @Override protected void readEntityFromNBT(NBTTagCompound nbt) { if (wrapped instanceof Storable) { - ((Storable) wrapped).load(Game.natives().toNova(nbt)); + ((Storable) wrapped).load(DataConverter.instance().toNova(nbt)); } if (wrapped == null) { //This entity was saved to disk. @@ -208,9 +207,9 @@ public void setPosition(double x, double y, double z) { this.posY = y; this.posZ = z; //Reset the bounding box - if (getCollisionBoundingBox() != null) { - setBounds(Game.natives().toNova(getCollisionBoundingBox())); - } + Optional.ofNullable(getCollisionBoundingBox()) + .map(CuboidConverter.instance()::toNova) + .ifPresent(this::setBounds); } /** @@ -219,9 +218,11 @@ public void setPosition(double x, double y, double z) { */ public void setBounds(Cuboid bounds) { //TODO: Fix moveEntity auto-centering - if (transform != null) { - setEntityBoundingBox(Game.natives().toNative(bounds.add(transform.position()))); - } + Optional.ofNullable(transform) + .map(EntityTransform::position) + .map(bounds::add) + .map(CuboidConverter.instance()::toNative) + .ifPresent(this::setEntityBoundingBox); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java index 92001cce8..23814613b 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/entity/forward/MCEntityTransform.java @@ -22,9 +22,11 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.DimensionManager; import nova.core.component.transform.EntityTransform; +import nova.core.util.UniqueIdentifiable; import nova.core.util.math.RotationUtil; import nova.core.util.math.Vector3DUtil; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -35,7 +37,7 @@ * Wraps Transform3d used in entity * @author Calclavia */ -public class MCEntityTransform extends EntityTransform { +public class MCEntityTransform extends EntityTransform implements UniqueIdentifiable { public final net.minecraft.entity.Entity wrapper; public MCEntityTransform(net.minecraft.entity.Entity wrapper) { @@ -46,7 +48,7 @@ public MCEntityTransform(net.minecraft.entity.Entity wrapper) { @Override public World world() { - return Game.natives().toNova(wrapper.world); + return WorldConverter.instance().toNova(wrapper.world); } @Override @@ -81,4 +83,9 @@ public void setRotation(Rotation rotation) { wrapper.rotationYaw = (float) Math.toDegrees(euler[0]); wrapper.rotationPitch = (float) Math.toDegrees(euler[1]); } + + @Override + public String getUniqueID() { + return wrapper.getUniqueID().toString(); + } } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java index 4ba4e84e3..ee9e28e69 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/inventory/BWInventory.java @@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack; import nova.core.component.inventory.Inventory; import nova.core.item.Item; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.item.ItemConverter; import nova.internal.core.Game; import java.util.Optional; @@ -36,19 +37,13 @@ public BWInventory(IInventory mcInventory) { } @Override - public Optional get(int i) { - ItemStack stackInSlot = wrapped.getStackInSlot(i); - - if (stackInSlot == null) { - return Optional.empty(); - } - - return Optional.of(Game.natives().toNova(stackInSlot)); + public Optional get(int slot) { + return Optional.ofNullable(wrapped.getStackInSlot(slot)).map(ItemConverter.instance()::toNova); } @Override - public boolean set(int i, Item item) { - wrapped.setInventorySlotContents(i, Game.natives().toNative(item)); + public boolean set(int slot, Item item) { + wrapped.setInventorySlotContents(slot, ItemConverter.instance().toNative(item)); return true; } diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java index 39c2bf61f..088b2bec2 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/particle/forward/MCParticleTransform.java @@ -10,6 +10,7 @@ import nova.core.util.math.RotationUtil; import nova.core.util.math.Vector3DUtil; import nova.core.world.World; +import nova.core.wrapper.mc.forge.v1_11_2.wrapper.block.world.WorldConverter; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Rotation; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; @@ -28,7 +29,7 @@ public MCParticleTransform(Particle wrapper) { @Override public World world() { - return Game.natives().toNova(wrapper.world); + return WorldConverter.instance().toNova(wrapper.world); } @Override diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java index 226460eee..8281360a9 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartBlockModel.java @@ -24,7 +24,6 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemTransformVec3f; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -65,14 +64,14 @@ public FWSmartBlockModel(Block block, Optional item) { this.item = item; // Change the default transforms to the default full Block transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(75, 225, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Left) - new ItemTransformVec3f(new Vector3f(75, 45, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Right) - new ItemTransformVec3f(new Vector3f(0, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Left) - new ItemTransformVec3f(new Vector3f(0, 45, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Right) - ItemTransformVec3f.DEFAULT, // Head - new ItemTransformVec3f(new Vector3f(30, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.625f, 0.625f, 0.625f)), // GUI - ItemTransformVec3f.DEFAULT, // Ground - ItemTransformVec3f.DEFAULT);// Fixed + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(75, 225, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Left) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(75, 45, 0), new Vector3f(0, 0.1875f, 0.03125f), new Vector3f(0.375f, 0.375f, 0.375f)), // Third Person (Right) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Left) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, 45, 0), new Vector3f(0, 0, 0), new Vector3f(0.4f, 0.4f, 0.4f)), // First Person (Right) + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT, // Head + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(30, 225, 0), new Vector3f(0, 0, 0), new Vector3f(0.625f, 0.625f, 0.625f)), // GUI + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT, // Ground + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT);// Fixed } //Item rendering diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java index eba2fcbdb..c40463c17 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/wrapper/render/forward/FWSmartItemModel.java @@ -25,7 +25,6 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemTransformVec3f; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -52,14 +51,14 @@ public FWSmartItemModel(Item item) { this.item = item; // Change the default transforms to the default Item transforms this.itemCameraTransforms = new ItemCameraTransforms( - new ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Left) - new ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Right) - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Left) - new ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Rigth) - ItemTransformVec3f.DEFAULT, // Head - ItemTransformVec3f.DEFAULT, // new ItemTransformVec3f(new Vector3f(-30, 135, 0), new Vector3f(), new Vector3f(1.6F, 1.6F, 1.6F)), // GUI - ItemTransformVec3f.DEFAULT, // Ground - ItemTransformVec3f.DEFAULT);// Fixed + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Left) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, -90, -130), new Vector3f(0, 1f / 24f, -2.75f / 16f), new Vector3f(0.9f, 0.9f, 0.9f)), // Third Person (Right) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Left) + new net.minecraft.client.renderer.block.model.ItemTransformVec3f(new Vector3f(0, -135, 25), new Vector3f(0, 0.25f, 0.125f), new Vector3f(1.7f, 1.7f, 1.7f)), // First Person (Rigth) + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT, // Head + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT, // new ItemTransformVec3f(new Vector3f(-30, 135, 0), new Vector3f(), new Vector3f(1.6F, 1.6F, 1.6F)), // GUI + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT, // Ground + net.minecraft.client.renderer.block.model.ItemTransformVec3f.DEFAULT);// Fixed } //Item rendering From 02120c2aaf5b4405a376daf1e242ba15d05fca1e Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Tue, 24 Oct 2017 16:10:45 +0200 Subject: [PATCH 61/61] Fix NPE in ClientProxy --- .../core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java index 29402dc19..d1f21d0e2 100644 --- a/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java +++ b/minecraft/1.11.2/src/main/java/nova/core/wrapper/mc/forge/v1_11_2/launcher/ClientProxy.java @@ -24,7 +24,6 @@ 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; @@ -54,6 +53,7 @@ import java.io.IOException; import java.io.InputStream; +import java.util.Optional; import java.util.Properties; /** @@ -137,7 +137,8 @@ public void postRegisterBlock(FWBlock block) { @Override public boolean isPaused() { - if (FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) { + if (FMLClientHandler.instance().getClient().isSingleplayer() && + Optional.ofNullable(FMLClientHandler.instance().getClient().getIntegratedServer()).map(is -> !is.getPublic()).orElse(true)) { GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; if (screen != null) { if (screen.doesGuiPauseGame()) {