mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Make reflection Java 12+ compatible, mark mods as children of the main mod (#26)
* Update buildscript and dependencies * Update NEI api * Make reflection Java 12+ compatible, mark mods as children of the main mod
This commit is contained in:
1 parent
c70a3448e5
commit
f2f1dd1195
7 files changed
+106
-85
No files matched your search
@@ -51,7 +51,7 @@ import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
name = "Binnie Core",
|
||||
version = BinnieCore.VERSION,
|
||||
useMetadata = true,
|
||||
dependencies = "after:Forestry@[4.2,)")
|
||||
dependencies = "after:Forestry@[4.2,),required-after:gtnhlib@[0.0.10,)")
|
||||
public class BinnieCore extends AbstractMod {
|
||||
@Mod.Instance("BinnieCore")
|
||||
public static BinnieCore instance;
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
public void loadUsageRecipes(FluidStack ingredient) {}
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(GuiRecipe guiRecipe, List<String> currenttip, int recipe) {
|
||||
public List<String> handleTooltip(GuiRecipe<?> guiRecipe, List<String> currenttip, int recipe) {
|
||||
super.handleTooltip(guiRecipe, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
if (GuiContainerManager.shouldShowTooltip(guiRecipe)) {
|
||||
@@ -98,7 +98,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
public List<String> provideTooltip(
|
||||
GuiRecipe guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe, Point relMouse) {
|
||||
GuiRecipe<?> guiRecipe, List<String> currenttip, CachedBaseRecipe crecipe, Point relMouse) {
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
for (PositionedFluidTank tank : crecipe.getFluidTanks()) {
|
||||
if (tank.position.contains(relMouse)) {
|
||||
@@ -111,7 +111,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(
|
||||
GuiRecipe guiRecipe, ItemStack itemStack, List<String> currenttip, int recipe) {
|
||||
GuiRecipe<?> guiRecipe, ItemStack itemStack, List<String> currenttip, int recipe) {
|
||||
super.handleItemTooltip(guiRecipe, itemStack, currenttip, recipe);
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
Point mouse = GuiDraw.getMousePosition();
|
||||
@@ -125,7 +125,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
public List<String> provideItemTooltip(
|
||||
GuiRecipe guiRecipe,
|
||||
GuiRecipe<?> guiRecipe,
|
||||
ItemStack itemStack,
|
||||
List<String> currenttip,
|
||||
CachedBaseRecipe crecipe,
|
||||
@@ -151,7 +151,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
|
||||
public boolean keyTyped(GuiRecipe<?> gui, char keyChar, int keyCode, int recipe) {
|
||||
if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) {
|
||||
if (this.transferFluidTank(gui, recipe, false)) {
|
||||
return true;
|
||||
@@ -165,7 +165,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
|
||||
public boolean mouseClicked(GuiRecipe<?> gui, int button, int recipe) {
|
||||
if (button == 0) {
|
||||
if (this.transferFluidTank(gui, recipe, false)) {
|
||||
return true;
|
||||
@@ -178,7 +178,7 @@ public abstract class RecipeHandlerBase extends TemplateRecipeHandler {
|
||||
return super.mouseClicked(gui, button, recipe);
|
||||
}
|
||||
|
||||
protected boolean transferFluidTank(GuiRecipe guiRecipe, int recipe, boolean usage) {
|
||||
protected boolean transferFluidTank(GuiRecipe<?> guiRecipe, int recipe, boolean usage) {
|
||||
CachedBaseRecipe crecipe = (CachedBaseRecipe) this.arecipes.get(recipe);
|
||||
|
||||
if (crecipe.getFluidTanks() != null) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package binnie.extratrees;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import forestry.api.arboriculture.EnumWoodType;
|
||||
import forestry.arboriculture.tiles.TileWood;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -14,9 +14,21 @@ import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class FakeWorld extends World {
|
||||
private static Unsafe unsafe;
|
||||
|
||||
static {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
unsafe = (Unsafe) theUnsafe.get(null);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static FakeWorld instance = SilentObjectCreator.create(FakeWorld.class);
|
||||
|
||||
protected Block block;
|
||||
@@ -106,22 +118,10 @@ public class FakeWorld extends World {
|
||||
* Creating objects without calling constructors.
|
||||
*/
|
||||
public static <T> T create(Class<T> clazz) {
|
||||
return create(clazz, Object.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating objects without calling constructors.
|
||||
*/
|
||||
public static <T> T create(Class<T> clazz, Class<? super T> parent) {
|
||||
try {
|
||||
ReflectionFactory rf = ReflectionFactory.getReflectionFactory();
|
||||
Constructor objDef = parent.getDeclaredConstructor();
|
||||
Constructor intConstr = rf.newConstructorForSerialization(clazz, objDef);
|
||||
return clazz.cast(intConstr.newInstance());
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Cannot create object", e);
|
||||
return clazz.cast(unsafe.allocateInstance(clazz));
|
||||
} catch (InstantiationException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.FruitPod;
|
||||
import binnie.extratrees.config.ConfigurationMain;
|
||||
import binnie.extratrees.item.Food;
|
||||
import com.gtnewhorizon.gtnhlib.reflect.Fields;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
@@ -18,7 +19,6 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.arboriculture.FruitProviderNone;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleTreeSpecies;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -254,12 +254,9 @@ public enum ExtraTreeFruitGene implements IAlleleFruit, IFruitProvider {
|
||||
try {
|
||||
IAlleleFruit lemon = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele("forestry.fruitLemon");
|
||||
FruitProviderNone prov = (FruitProviderNone) lemon.getProvider();
|
||||
Field f = FruitProviderNone.class.getDeclaredField("family");
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
f.setAccessible(true);
|
||||
modifiersField.setAccessible(true);
|
||||
modifiersField.setInt(f, f.getModifiers() & 0xFFFFFFEF);
|
||||
f.set(prov, familyCitrus);
|
||||
Fields.ofClass(FruitProviderNone.class)
|
||||
.getField(Fields.LookupType.DECLARED, "family", IFruitFamily.class)
|
||||
.setValue(prov, familyCitrus);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user