diff --git a/.gitignore b/.gitignore
index b5b2dcb..d6b3e9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@
/MinecraftForge-License.txt
/1.7.10 AdvancedVanilla2.iws
# Created by .ignore support plugin (hsz.mobi)
+/run
diff --git a/build.gradle b/build.gradle
index 52cceda..a9940be 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,14 +11,14 @@ buildscript {
}
}
dependencies {
- classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
+ classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'idea'
-version="3.0.0"
+version="3.1.0preAlpha"
group= "de.canitzp.advancedvanilla"
archivesBaseName = "AdvancedVanilla"
@@ -26,9 +26,9 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
- version = "1.9-12.16.0.1767-1.9"
+ version = "1.9.4-12.17.0.1954"
runDir = "run"
- mappings = "snapshot_20160318"
+ mappings = "snapshot_20160604"
makeObfSourceJar = false
useDepAts = true
replaceIn "AdvancedVanilla.java"
@@ -37,8 +37,7 @@ minecraft {
dependencies {}
-processResources
-{
+processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f75413e..1541315 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip
diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java
deleted file mode 100644
index eb2e05a..0000000
--- a/src/main/java/cofh/api/CoFHAPIProps.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package cofh.api;
-
-public class CoFHAPIProps {
-
- private CoFHAPIProps() {
-
- }
-
- public static final String VERSION = "1.8.9R1.2.0B1";
-
-}
diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java
deleted file mode 100644
index dd7dd3e..0000000
--- a/src/main/java/cofh/api/energy/EnergyStorage.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.nbt.NBTTagCompound;
-
-/**
- * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
- *
- * @author King Lemming
- *
- */
-public class EnergyStorage implements IEnergyStorage {
-
- protected int energy;
- protected int capacity;
- protected int maxReceive;
- protected int maxExtract;
-
- public EnergyStorage(int capacity) {
-
- this(capacity, capacity, capacity);
- }
-
- public EnergyStorage(int capacity, int maxTransfer) {
-
- this(capacity, maxTransfer, maxTransfer);
- }
-
- public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
-
- this.capacity = capacity;
- this.maxReceive = maxReceive;
- this.maxExtract = maxExtract;
- }
-
- public EnergyStorage readFromNBT(NBTTagCompound nbt) {
-
- this.energy = nbt.getInteger("Energy");
-
- if (energy > capacity) {
- energy = capacity;
- }
- return this;
- }
-
- public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
-
- if (energy < 0) {
- energy = 0;
- }
- nbt.setInteger("Energy", energy);
- return nbt;
- }
-
- public EnergyStorage setCapacity(int capacity) {
-
- this.capacity = capacity;
-
- if (energy > capacity) {
- energy = capacity;
- }
- return this;
- }
-
- public EnergyStorage setMaxTransfer(int maxTransfer) {
-
- setMaxReceive(maxTransfer);
- setMaxExtract(maxTransfer);
- return this;
- }
-
- public EnergyStorage setMaxReceive(int maxReceive) {
-
- this.maxReceive = maxReceive;
- return this;
- }
-
- public EnergyStorage setMaxExtract(int maxExtract) {
-
- this.maxExtract = maxExtract;
- return this;
- }
-
- public int getMaxReceive() {
-
- return maxReceive;
- }
-
- public int getMaxExtract() {
-
- return maxExtract;
- }
-
- /**
- * This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
- * are guaranteed to have it.
- *
- * @param energy
- */
- public void setEnergyStored(int energy) {
-
- this.energy = energy;
-
- if (this.energy > capacity) {
- this.energy = capacity;
- } else if (this.energy < 0) {
- this.energy = 0;
- }
- }
-
- /**
- * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
- * externally, as not all IEnergyHandlers are guaranteed to have it.
- *
- * @param energy
- */
- public void modifyEnergyStored(int energy) {
-
- this.energy += energy;
-
- if (this.energy > capacity) {
- this.energy = capacity;
- } else if (this.energy < 0) {
- this.energy = 0;
- }
- }
-
- /* IEnergyStorage */
- @Override
- public int receiveEnergy(int maxReceive, boolean simulate) {
-
- int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
-
- if (!simulate) {
- energy += energyReceived;
- }
- return energyReceived;
- }
-
- @Override
- public int extractEnergy(int maxExtract, boolean simulate) {
-
- int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
-
- if (!simulate) {
- energy -= energyExtracted;
- }
- return energyExtracted;
- }
-
- @Override
- public int getEnergyStored() {
-
- return energy;
- }
-
- @Override
- public int getMaxEnergyStored() {
-
- return capacity;
- }
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java
deleted file mode 100644
index 29ef0a1..0000000
--- a/src/main/java/cofh/api/energy/IEnergyConnection.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.util.EnumFacing;
-
-
-/**
- * Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
- * accept it; otherwise just use IEnergyHandler.
- *
- * Note that {@link IEnergyHandler} is an extension of this.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyConnection {
-
- /**
- * Returns TRUE if the TileEntity can connect on a given side.
- */
- boolean canConnectEnergy(EnumFacing from);
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java
deleted file mode 100644
index 3ef7257..0000000
--- a/src/main/java/cofh/api/energy/IEnergyContainerItem.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.item.ItemStack;
-
-/**
- * Implement this interface on Item classes that support external manipulation of their internal energy storages.
- *
- * A reference implementation is provided {@link ItemEnergyContainer}.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyContainerItem {
-
- /**
- * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
- *
- * @param container
- * ItemStack to be charged.
- * @param maxReceive
- * Maximum amount of energy to be sent into the item.
- * @param simulate
- * If TRUE, the charge will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) received by the item.
- */
- int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
-
- /**
- * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
- * discharged.
- *
- * @param container
- * ItemStack to be discharged.
- * @param maxExtract
- * Maximum amount of energy to be extracted from the item.
- * @param simulate
- * If TRUE, the discharge will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) extracted from the item.
- */
- int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
-
- /**
- * Get the amount of energy currently stored in the container item.
- */
- int getEnergyStored(ItemStack container);
-
- /**
- * Get the max amount of energy that can be stored in the container item.
- */
- int getMaxEnergyStored(ItemStack container);
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java
deleted file mode 100644
index 16b236e..0000000
--- a/src/main/java/cofh/api/energy/IEnergyHandler.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.util.EnumFacing;
-
-/**
- * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
- *
- * A reference implementation is provided {@link TileEnergyHandler}.
- *
- * Note that {@link IEnergyReceiver} and {@link IEnergyProvider} are extensions of this.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyHandler extends IEnergyConnection {
-
- /**
- * Returns the amount of energy currently stored.
- */
- int getEnergyStored(EnumFacing from);
-
- /**
- * Returns the maximum amount of energy that can be stored.
- */
- int getMaxEnergyStored(EnumFacing from);
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyProvider.java b/src/main/java/cofh/api/energy/IEnergyProvider.java
deleted file mode 100644
index ef0e09d..0000000
--- a/src/main/java/cofh/api/energy/IEnergyProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.util.EnumFacing;
-
-
-/**
- * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
- *
- * A reference implementation is provided {@link TileEnergyHandler}.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyProvider extends IEnergyHandler {
-
- /**
- * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
- *
- * @param from
- * Orientation the energy is extracted from.
- * @param maxExtract
- * Maximum amount of energy to extract.
- * @param simulate
- * If TRUE, the extraction will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) extracted.
- */
- int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyReceiver.java b/src/main/java/cofh/api/energy/IEnergyReceiver.java
deleted file mode 100644
index 989e9ba..0000000
--- a/src/main/java/cofh/api/energy/IEnergyReceiver.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.util.EnumFacing;
-
-
-/**
- * Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
- *
- * A reference implementation is provided {@link TileEnergyHandler}.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyReceiver extends IEnergyHandler {
-
- /**
- * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver.
- *
- * @param from
- * Orientation the energy is received from.
- * @param maxReceive
- * Maximum amount of energy to receive.
- * @param simulate
- * If TRUE, the charge will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) received.
- */
- int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate);
-
-}
diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java
deleted file mode 100644
index 414b265..0000000
--- a/src/main/java/cofh/api/energy/IEnergyStorage.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cofh.api.energy;
-
-/**
- * An energy storage is the unit of interaction with Energy inventories.
- * This is not to be implemented on TileEntities. This is for internal use only.
- *
- * A reference implementation can be found at {@link EnergyStorage}.
- *
- * @author King Lemming
- *
- */
-public interface IEnergyStorage {
-
- /**
- * Adds energy to the storage. Returns quantity of energy that was accepted.
- *
- * @param maxReceive
- * Maximum amount of energy to be inserted.
- * @param simulate
- * If TRUE, the insertion will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
- */
- int receiveEnergy(int maxReceive, boolean simulate);
-
- /**
- * Removes energy from the storage. Returns quantity of energy that was removed.
- *
- * @param maxExtract
- * Maximum amount of energy to be extracted.
- * @param simulate
- * If TRUE, the extraction will only be simulated.
- * @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
- */
- int extractEnergy(int maxExtract, boolean simulate);
-
- /**
- * Returns the amount of energy currently stored.
- */
- int getEnergyStored();
-
- /**
- * Returns the maximum amount of energy that can be stored.
- */
- int getMaxEnergyStored();
-
-}
diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java
deleted file mode 100644
index 0fb36da..0000000
--- a/src/main/java/cofh/api/energy/ItemEnergyContainer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-
-/**
- * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
- *
- * @author King Lemming
- *
- */
-public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
-
- protected int capacity;
- protected int maxReceive;
- protected int maxExtract;
-
- public ItemEnergyContainer() {
-
- }
-
- public ItemEnergyContainer(int capacity) {
-
- this(capacity, capacity, capacity);
- }
-
- public ItemEnergyContainer(int capacity, int maxTransfer) {
-
- this(capacity, maxTransfer, maxTransfer);
- }
-
- public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
-
- this.capacity = capacity;
- this.maxReceive = maxReceive;
- this.maxExtract = maxExtract;
- }
-
- public ItemEnergyContainer setCapacity(int capacity) {
-
- this.capacity = capacity;
- return this;
- }
-
- public ItemEnergyContainer setMaxTransfer(int maxTransfer) {
-
- setMaxReceive(maxTransfer);
- setMaxExtract(maxTransfer);
- return this;
- }
-
- public ItemEnergyContainer setMaxReceive(int maxReceive) {
-
- this.maxReceive = maxReceive;
- return this;
- }
-
- public ItemEnergyContainer setMaxExtract(int maxExtract) {
-
- this.maxExtract = maxExtract;
- return this;
- }
-
- /* IEnergyContainerItem */
- @Override
- public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
-
- if (!container.hasTagCompound()) {
- container.setTagCompound(new NBTTagCompound());
- }
- int energy = container.getTagCompound().getInteger("Energy");
- int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
-
- if (!simulate) {
- energy += energyReceived;
- container.getTagCompound().setInteger("Energy", energy);
- }
- return energyReceived;
- }
-
- @Override
- public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
-
- if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
- return 0;
- }
- int energy = container.getTagCompound().getInteger("Energy");
- int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
-
- if (!simulate) {
- energy -= energyExtracted;
- container.getTagCompound().setInteger("Energy", energy);
- }
- return energyExtracted;
- }
-
- @Override
- public int getEnergyStored(ItemStack container) {
-
- if (container.getTagCompound() == null || !container.getTagCompound().hasKey("Energy")) {
- return 0;
- }
- return container.getTagCompound().getInteger("Energy");
- }
-
- @Override
- public int getMaxEnergyStored(ItemStack container) {
-
- return capacity;
- }
-
-}
diff --git a/src/main/java/cofh/api/energy/TileEnergyHandler.java b/src/main/java/cofh/api/energy/TileEnergyHandler.java
deleted file mode 100644
index 3ba60a6..0000000
--- a/src/main/java/cofh/api/energy/TileEnergyHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package cofh.api.energy;
-
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.EnumFacing;
-
-/**
- * Reference implementation of {@link IEnergyReceiver} and {@link IEnergyProvider}. Use/extend this or implement your own.
- *
- * This class is really meant to summarize how each interface is properly used.
- *
- * @author King Lemming
- *
- */
-public class TileEnergyHandler extends TileEntity implements IEnergyReceiver, IEnergyProvider {
-
- protected EnergyStorage storage = new EnergyStorage(32000);
-
- @Override
- public void readFromNBT(NBTTagCompound nbt) {
-
- super.readFromNBT(nbt);
- storage.readFromNBT(nbt);
- }
-
- @Override
- public void writeToNBT(NBTTagCompound nbt) {
-
- super.writeToNBT(nbt);
- storage.writeToNBT(nbt);
- }
-
- /* IEnergyConnection */
- @Override
- public boolean canConnectEnergy(EnumFacing from) {
-
- return true;
- }
-
- /* IEnergyReceiver */
- @Override
- public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) {
-
- return storage.receiveEnergy(maxReceive, simulate);
- }
-
- /* IEnergyProvider */
- @Override
- public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) {
-
- return storage.extractEnergy(maxExtract, simulate);
- }
-
- /* IEnergyHandler */
- @Override
- public int getEnergyStored(EnumFacing from) {
-
- return storage.getEnergyStored();
- }
-
- @Override
- public int getMaxEnergyStored(EnumFacing from) {
-
- return storage.getMaxEnergyStored();
- }
-
-}
diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/main/java/cofh/api/energy/package-info.java
deleted file mode 100644
index da85667..0000000
--- a/src/main/java/cofh/api/energy/package-info.java
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub
- * http://www.teamcofh.com
- */
-@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
-package cofh.api.energy;
-
-import net.minecraftforge.fml.common.API;
-import cofh.api.CoFHAPIProps;
-
diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java
deleted file mode 100644
index e2847da..0000000
--- a/src/main/java/cofh/api/package-info.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * (C) 2014-2016 Team CoFH / CoFH / Cult of the Full Hub
- * http://www.teamcofh.com
- */
-@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
-package cofh.api;
-
-import net.minecraftforge.fml.common.API;
-
diff --git a/src/main/java/de/canitzp/advancedvanilla/AdvancedVanilla.java b/src/main/java/de/canitzp/advancedvanilla/AdvancedVanilla.java
index 403fcb6..a4f06d2 100644
--- a/src/main/java/de/canitzp/advancedvanilla/AdvancedVanilla.java
+++ b/src/main/java/de/canitzp/advancedvanilla/AdvancedVanilla.java
@@ -2,8 +2,11 @@
import de.canitzp.advancedvanilla.integration.CheckLoadedMods;
+import de.canitzp.advancedvanilla.proxy.CommonProxy;
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
import de.canitzp.advancedvanilla.util.AVLogger;
import net.minecraftforge.fml.common.Mod;
+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;
@@ -13,25 +16,36 @@ public class AdvancedVanilla {
public static final String MODID = "advancedvanilla";
public static final String VERSION = "@VERSION@";
- public static final String NAME = "AdvacnedVanilla";
+ public static final String NAME = "AdvancedVanilla";
+
+ @Mod.Instance
+ public static AdvancedVanilla instance;
+
+ @SidedProxy(clientSide = "de.canitzp.advancedvanilla.proxy.ClientProxy", serverSide = "de.canitzp.advancedvanilla.proxy.CommonProxy")
+ public static CommonProxy proxy;
+
+ public static boolean finishedStart = false;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event){
AVLogger.info("Start PreInitialization");
- CheckLoadedMods.preInitializeMods();
+ proxy.preInit();
+ CheckLoadedMods.preInitializeMods(event);
}
@Mod.EventHandler
public void init(FMLInitializationEvent event){
AVLogger.info("Start Initialization");
- CheckLoadedMods.initializeMods();
+ CheckLoadedMods.initializeMods(event);
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event){
AVLogger.info("Start PostInitialization");
- CheckLoadedMods.postInitializeMods();
+ CheckLoadedMods.postInitializeMods(event);
+ RecipeHandler.postInit();
AVLogger.info("Loading complete!");
+ finishedStart = true;
}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/api/AdvancedVanillaApi.java b/src/main/java/de/canitzp/advancedvanilla/api/AdvancedVanillaApi.java
new file mode 100644
index 0000000..d6983ee
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/api/AdvancedVanillaApi.java
@@ -0,0 +1,54 @@
+package de.canitzp.advancedvanilla.api;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.EnumHelper;
+import net.minecraftforge.fml.common.FMLLog;
+import net.minecraftforge.fml.common.Loader;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author canitzp
+ */
+public class AdvancedVanillaApi{
+
+ public static List blockListener = new ArrayList<>();
+
+ public static void addBlockListener(IBlockListener listener){
+ if(!blockListener.contains(listener)){
+ blockListener.add(listener);
+ } else {
+ FMLLog.getLogger().info("[AdvancedVanillaApi]: Error while trying to register a IRecipeHandler! The Block is already defined! " + listener);
+ }
+ }
+
+ public static void addBlockListener(Block block, IRecipeHandler handler){
+ addBlockListener(new IBlockListener(){
+ @Override
+ public IRecipeHandler getHandlerFromBlock(World world, BlockPos pos, EntityPlayer player){
+ return block.equals(world.getBlockState(pos).getBlock()) ? handler : null;
+ }
+ });
+ }
+
+ public static SaveFiles addSaveFile(String name){
+ return EnumHelper.addEnum(SaveFiles.class, name.toUpperCase(), new Class[]{String.class}, name);
+ }
+
+ public enum SaveFiles{
+ SHAPED_ORE("forge_shapedOre.recipes"),
+ SHAPELESS_ORE("forge_shapelessOre.recipes");
+
+ public File saveFile;
+ SaveFiles(String file){
+ this.saveFile = new File(Loader.instance().getConfigDir().getAbsolutePath() + File.separator + "advancedvanilla" + File.separator + "recipes" + File.separator + file);
+ }
+ }
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/api/IBlockListener.java b/src/main/java/de/canitzp/advancedvanilla/api/IBlockListener.java
new file mode 100644
index 0000000..316f031
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/api/IBlockListener.java
@@ -0,0 +1,14 @@
+package de.canitzp.advancedvanilla.api;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+
+/**
+ * @author canitzp
+ */
+public interface IBlockListener{
+
+ IRecipeHandler getHandlerFromBlock(World world, BlockPos pos, EntityPlayer player);
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/api/IRecipeHandler.java b/src/main/java/de/canitzp/advancedvanilla/api/IRecipeHandler.java
new file mode 100644
index 0000000..ae77cb1
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/api/IRecipeHandler.java
@@ -0,0 +1,60 @@
+package de.canitzp.advancedvanilla.api;
+
+import de.canitzp.advancedvanilla.proxy.PacketRecipeChanger;
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.List;
+
+/**
+ * @author canitzp
+ */
+public interface IRecipeHandler{
+
+ AdvancedVanillaApi.SaveFiles getSaveFile();
+
+ default void initContainer(Container container, EntityPlayer player){}
+
+ default List getSlots(IInventory inventory, Container container, EntityPlayer player){return null;}
+
+ default void onSaveRecipe(IInventory inventory, Container container, EntityPlayer player){}
+
+ default void onDeleteRecipe(IInventory inventory, Container container, EntityPlayer player){}
+
+ default void onReloadRecipes(IInventory inventory, Container container, EntityPlayer player){}
+
+ default void handlePacket(IInventory inventory, Container container, EntityPlayer player, PacketRecipeChanger.Type type){}
+
+ void resetRecipes();
+
+ default List> saveToFile(){return null;}
+
+ default void readFromFile(String identifier, String recipeLine){}
+
+ @SideOnly(Side.CLIENT)
+ default void drawGuiContainerBackgroundLayer(GuiContainer gui, EntityPlayer player, float partialTicks, int mouseX, int mouseY){}
+
+ @SideOnly(Side.CLIENT)
+ default void mouseClick(GuiContainer gui, EntityPlayer player, int mouseX, int mouseY, int mouseButton){}
+
+ @SideOnly(Side.CLIENT)
+ ResourceLocation getResourceLocation(GuiContainer gui, EntityPlayer player);
+
+ @SideOnly(Side.CLIENT)
+ int getGuiXSize(GuiContainer gui, EntityPlayer player);
+
+ @SideOnly(Side.CLIENT)
+ int getGuiYSize(GuiContainer gui, EntityPlayer player);
+
+ @SideOnly(Side.CLIENT)
+ default void initGui(GuiContainer gui, EntityPlayer player, List buttons){}
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/CheckLoadedMods.java b/src/main/java/de/canitzp/advancedvanilla/integration/CheckLoadedMods.java
index 74cdb0b..9d1f94f 100644
--- a/src/main/java/de/canitzp/advancedvanilla/integration/CheckLoadedMods.java
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/CheckLoadedMods.java
@@ -1,19 +1,51 @@
package de.canitzp.advancedvanilla.integration;
+import de.canitzp.advancedvanilla.integration.mods.ActuallyAdditions;
+import de.canitzp.advancedvanilla.integration.mods.VanillaNetherMetals;
import de.canitzp.advancedvanilla.integration.mods.Vanilla;
-import de.canitzp.advancedvanilla.util.AVConfig;
import de.canitzp.advancedvanilla.util.AVLogger;
import net.minecraftforge.fml.common.Loader;
+import net.minecraftforge.fml.common.ModContainer;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
-import java.util.ArrayList;
+import java.util.*;
public class CheckLoadedMods {
- public static ArrayList modList = new ArrayList();
- public static boolean ActuallyAdditions, AE2, Buildcraft, EnderIO, ExtraUtilities, Forestry, IC2, Mekanism, MFR, TE, OpenBlocks, RFTools, BigReactors;
+ public static List modList = new ArrayList<>();
+ public static Map modsToIntegrate = new HashMap<>();
+ public static Map modsToLoad = new HashMap<>();
- public static void preInitializeMods(){
- if(Loader.isModLoaded("ActuallyAdditions")) ActuallyAdditions = true;
+ public static void createModList(){
+ modsToLoad.put("actuallyadditions", new ActuallyAdditions());
+ modsToLoad.put("vanillanethermetals", new VanillaNetherMetals());
+
+
+ modsToIntegrate.put(null, new Vanilla());
+ for(Map.Entry entry : modsToLoad.entrySet()){
+ if(Loader.isModLoaded(entry.getKey())){
+ modsToIntegrate.put(getModContainer(entry.getKey()), entry.getValue());
+ }
+ }
+ }
+
+ private static ModContainer getModContainer(String modid){
+ for(ModContainer modContainer : Loader.instance().getActiveModList()){
+ if(modContainer.getModId().equals(modid)){
+ return modContainer;
+ }
+ }
+ return null;
+ }
+
+ public static void preInitializeMods(FMLPreInitializationEvent event){
+ createModList();
+ for(IMod mod : modsToIntegrate.values()){
+ mod.preInit(event);
+ }
+ /*
if(Loader.isModLoaded("appliedenergistics2")) AE2 = true;
if(Loader.isModLoaded("BuildCraft|Core")) Buildcraft = true;
if(Loader.isModLoaded("EnderIO")) EnderIO = true;
@@ -26,15 +58,22 @@ public static void preInitializeMods(){
if(Loader.isModLoaded("OpenBlocks")) OpenBlocks = true;
if(Loader.isModLoaded("rftools")) RFTools = true;
if(Loader.isModLoaded("BigReactors")) BigReactors = true;
+ */
}
- public static void initializeMods(){
- configChanger();
+ public static void initializeMods(FMLInitializationEvent event){
+ for(IMod mod : modsToIntegrate.values()){
+ mod.init(event);
+ }
}
- public static void postInitializeMods(){
- Vanilla.postInit();
- if(ActuallyAdditions) de.canitzp.advancedvanilla.integration.mods.ActuallyAdditions.postInit();
+ public static void postInitializeMods(FMLPostInitializationEvent event){
+ for(Map.Entry entry : modsToIntegrate.entrySet()){
+ entry.getValue().postInit(event);
+ modList.add(entry.getValue().getModName() != null ? entry.getValue().getModName() : entry.getKey() != null ? entry.getKey().getModId() : "");
+ }
+
+ /*
if(AE2) de.canitzp.advancedvanilla.integration.mods.AE2.postInit();
if(Buildcraft) de.canitzp.advancedvanilla.integration.mods.Buildcraft.postInit();
if(EnderIO) de.canitzp.advancedvanilla.integration.mods.EnderIO.postInit();
@@ -47,12 +86,8 @@ public static void postInitializeMods(){
if(OpenBlocks) de.canitzp.advancedvanilla.integration.mods.OpenBlocks.postInit();
if(RFTools) de.canitzp.advancedvanilla.integration.mods.RFTools.postInit();
if(BigReactors) de.canitzp.advancedvanilla.integration.mods.BigReactors.postInit();
- AVLogger.info("Mod Integration:" + modList);
- }
-
- private static void configChanger(){
- if(ActuallyAdditions) de.canitzp.advancedvanilla.integration.mods.ActuallyAdditions.configChanger();
- AVLogger.info("AdvancedVanilla changed " + AVConfig.changes + " Configuration Entries.");
+ */
+ AVLogger.info("Loaded mod integrations: " + modList);
}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/IMod.java b/src/main/java/de/canitzp/advancedvanilla/integration/IMod.java
index dc53932..1e5fe3b 100644
--- a/src/main/java/de/canitzp/advancedvanilla/integration/IMod.java
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/IMod.java
@@ -1,16 +1,21 @@
package de.canitzp.advancedvanilla.integration;
+import net.minecraftforge.fml.common.ModContainer;
+import net.minecraftforge.fml.common.event.FMLInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
+import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
+
/**
* @author canitzp
*/
public interface IMod {
- static void preInit(){}
+ default String getModName(){return null;}
- static void init(){}
+ default void preInit(FMLPreInitializationEvent event){}
- static void configChanger(){}
+ default void init(FMLInitializationEvent event){}
- static void postInit(){}
+ default void postInit(FMLPostInitializationEvent event){}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/mods/ActuallyAdditions.java b/src/main/java/de/canitzp/advancedvanilla/integration/mods/ActuallyAdditions.java
index 6d491d8..256a76e 100644
--- a/src/main/java/de/canitzp/advancedvanilla/integration/mods/ActuallyAdditions.java
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/mods/ActuallyAdditions.java
@@ -2,6 +2,7 @@
import de.canitzp.advancedvanilla.integration.CheckLoadedMods;
import de.canitzp.advancedvanilla.integration.IMod;
+import de.canitzp.advancedvanilla.util.AVItem;
import de.canitzp.advancedvanilla.util.AVOreDictionary;
import de.canitzp.advancedvanilla.util.AVRecipe;
import net.minecraft.block.Block;
@@ -9,19 +10,14 @@
import net.minecraft.item.ItemStack;
@SuppressWarnings("unchecked")
-public class ActuallyAdditions implements IMod{ //Version: ActuallyAdditions-1.7.10-r16
+public class ActuallyAdditions implements IMod{ //Version: ActuallyAdditions-1.9-r30
- public static void preInit() {}
-
- public static void init(){}
-
- public static void configChanger() {
- //AVConfig.configChanger("ActuallyAdditions.cfg", "B:\"Black Quartz\"=true", "B:\"Black Quartz\"=false");
- //AVConfig.configChanger("ActuallyAdditions.cfg", "B:\"Black Lotus Gen\"=true", "B:\"Black Lotus Gen\"=false");
+ @Override
+ public String getModName(){
+ return "ActuallyAdditions";
}
- public static void postInit(){
- CheckLoadedMods.modList.add("ActuallyAdditions");
+ public void postInit(){
//MachineBlock:
AVOreDictionary.AVODItem("blockMachineBlockWood", "ActuallyAdditions:blockMisc", 4);
AVOreDictionary.AVODItem("blockMachineBlockStone", "ActuallyAdditions:blockMisc", 5);
@@ -34,10 +30,10 @@ public static void postInit(){
AVOreDictionary.AVODItem("coilBasic", "ActuallyAdditions:itemMisc", 7);
AVOreDictionary.AVODItem("coilAdvanced", "ActuallyAdditions:itemMisc", 8);
//Crafting Recipes:
- AVRecipe.AVODShapedBlock("ActuallyAdditions:blockCompost", 0, new Object[]{"A A", "A A", "ABA", 'A', "plankWood", 'B', new ItemStack(Block.getBlockFromName("ActuallyAdditions:blockMisc"), 4)}, new Object[]{"A A", "A A", "ABA", 'A', "plankWood", 'B', "blockWoodMachineBlock"});
- //AVRecipe.AVODShapedBlock("ActuallyAdditions:blockCanolaPress", 0, "ABA", "ACA", "ADA", 'A', "cobblestone", 'B', "blockHopper", 'C', (new ItemStack(AVItem.getItemFromName("ActuallyAdditions:itemMisc"), 1, 13)), 'D', "coilAdvanced");
- //AVRecipe.AVODShapedBlock("ActuallyAdditions:blockFermentingBarrel", 0, "ABA", "ACA", "ADA", 'A', "logWood", 'B', "blockHopper", 'C', (new ItemStack(AVItem.getItemFromName("ActuallyAdditions:itemMisc"), 1, 13)), 'D', "blockWoodMachineBlock");
- //AVRecipe.AVODShapedBlock("ActuallyAdditions:blockInputter", 0, "AAA", "BCB", "AAA", 'A', "plankWood", 'B', "blockWoodMachineBlock", 'C', "blockHopper");
+ AVRecipe.AVODShapedBlock("ActuallyAdditions:blockCompost", new Object[]{"A A", "A A", "ABA", 'A', "plankWood", 'B', new ItemStack(Block.getBlockFromName("ActuallyAdditions:blockMisc"), 1, 4)}, new Object[]{"A A", "A A", "ABA", 'A', "plankWood", 'B', "blockMachineBlockWood"});
+ AVRecipe.AVODShapedBlock("ActuallyAdditions:blockCanolaPress", new Object[]{}, new Object[]{ "ABA", "ACA", "ADA", 'A', "cobblestone", 'B', "blockHopper", 'C', (new ItemStack(AVItem.getItemFromName("ActuallyAdditions:itemMisc"), 1, 13)), 'D', "coilAdvanced"});
+ AVRecipe.AVODShapedBlock("ActuallyAdditions:blockFermentingBarrel", new Object[]{}, new Object[]{ "ABA", "ACA", "ADA", 'A', "logWood", 'B', "blockHopper", 'C', (new ItemStack(AVItem.getItemFromName("ActuallyAdditions:itemMisc"), 1, 13)), 'D', "blockWoodMachineBlock"});
+ AVRecipe.AVODShapedBlock("ActuallyAdditions:blockInputter", new Object[]{ "AAA", "BCB", "AAA", 'A', "plankWood", 'B', "blockWoodMachineBlock", 'C', "blockHopper"});
//Battery:
AVOreDictionary.AVODItem("itemBattery", "ActuallyAdditions:itemBattery");
AVOreDictionary.AVODItem("itemBatteryTier2", "ActuallyAdditions:itemBatteryDouble");
@@ -76,7 +72,6 @@ public static void postInit(){
AVOreDictionary.AVODItem("foodBreadRice", "ActuallyAdditions:itemFood", 17);
AVOreDictionary.AVODItem("foodDoughnut", "ActuallyAdditions:itemFood", 18);
AVOreDictionary.AVODItem("foodToastChocolate", "ActuallyAdditions:itemFood", 19);
-
}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/mods/MineFactroyReloaded.java b/src/main/java/de/canitzp/advancedvanilla/integration/mods/MineFactroyReloaded.java
index 3fdd391..85807f6 100644
--- a/src/main/java/de/canitzp/advancedvanilla/integration/mods/MineFactroyReloaded.java
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/mods/MineFactroyReloaded.java
@@ -22,7 +22,7 @@ public static void postInit(){
AVOreDictionary.WildcardBlock("logWood", "MineFactoryReloaded:rubberwood.log");
AVOreDictionary.WildcardBlock("treeLeaves", "MineFactoryReloaded:rubberwood.leaves");
//Crafting Recipes:
- AVRecipe.AVODShapedBlock("MineFactoryReloaded:road", 4, new Object[]{"A A", " B ", "A A", 'A', (new ItemStack(Block.getBlockFromName("MineFactoryReloaded:road"), 1, 0)), 'B', "poweredLamp"}, new Object[]{"A A", " B ", "A A", 'A', (new ItemStack(Block.getBlockFromName("MineFactoryReloaded:road"), 1, 0)), 'B', "poweredLamp"});
+ AVRecipe.AVODShapedBlock("MineFactoryReloaded:road", new Object[]{"A A", " B ", "A A", 'A', (new ItemStack(Block.getBlockFromName("MineFactoryReloaded:road"), 1, 0)), 'B', "poweredLamp"}, new Object[]{"A A", " B ", "A A", 'A', (new ItemStack(Block.getBlockFromName("MineFactoryReloaded:road"), 1, 0)), 'B', "poweredLamp"});
}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/mods/Vanilla.java b/src/main/java/de/canitzp/advancedvanilla/integration/mods/Vanilla.java
index 7649b03..948b517 100644
--- a/src/main/java/de/canitzp/advancedvanilla/integration/mods/Vanilla.java
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/mods/Vanilla.java
@@ -1,62 +1,67 @@
package de.canitzp.advancedvanilla.integration.mods;
import de.canitzp.advancedvanilla.integration.CheckLoadedMods;
+import de.canitzp.advancedvanilla.integration.IMod;
import de.canitzp.advancedvanilla.util.AVOreDictionary;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@SuppressWarnings("unchecked")
-public class Vanilla { //Version: Minecraft 1.7.10
+public class Vanilla implements IMod{ //Version: Minecraft 1.7.10
- public static void postInit(){
- CheckLoadedMods.modList.add("Vanilla");
- AVOreDictionary.AVODBlock("blockChiseledQuartz", Blocks.quartz_block, 1);
- AVOreDictionary.AVODBlock("blockPillarQuartz", Blocks.quartz_block, 2);
- AVOreDictionary.AVODBlock("blockBricks", Blocks.brick_block);
- AVOreDictionary.AVODItem("bucketLava", Items.lava_bucket);
- AVOreDictionary.AVODItem("bucketWater", Items.water_bucket);
- AVOreDictionary.AVODItem("bucket", Items.bucket);
- AVOreDictionary.AVODBlock("poweredLamp", Blocks.redstone_lamp);
- AVOreDictionary.AVODBlock("blockSponge", Blocks.sponge);
- AVOreDictionary.AVODBlock("blockGrass", Blocks.grass);
- AVOreDictionary.AVODBlock("blockFence", Blocks.oak_fence);
- AVOreDictionary.AVODBlock("blockFence", Blocks.birch_fence);
- AVOreDictionary.AVODBlock("blockFence", Blocks.spruce_fence);
- AVOreDictionary.AVODBlock("blockFence", Blocks.jungle_fence);
- AVOreDictionary.AVODBlock("blockFence", Blocks.acacia_fence);
- AVOreDictionary.AVODBlock("blockFence", Blocks.dark_oak_fence);
- AVOreDictionary.AVODItem("itemBook", Items.book);
- AVOreDictionary.WildcardItem("itemBook", Items.enchanted_book);
- AVOreDictionary.WildcardBlock("carpet", Blocks.carpet);
+ @Override
+ public String getModName(){
+ return "Vanilla";
+ }
+
+ public void postInit(){
+ AVOreDictionary.AVODBlock("blockChiseledQuartz", Blocks.QUARTZ_BLOCK, 1);
+ AVOreDictionary.AVODBlock("blockPillarQuartz", Blocks.QUARTZ_BLOCK, 2);
+ AVOreDictionary.AVODBlock("blockBricks", Blocks.BRICK_BLOCK);
+ AVOreDictionary.AVODItem("bucketLava", Items.LAVA_BUCKET);
+ AVOreDictionary.AVODItem("bucketWater", Items.WATER_BUCKET);
+ AVOreDictionary.AVODItem("bucket", Items.BUCKET);
+ AVOreDictionary.AVODBlock("poweredLamp", Blocks.REDSTONE_LAMP);
+ AVOreDictionary.AVODBlock("blockSponge", Blocks.SPONGE);
+ AVOreDictionary.AVODBlock("blockGrass", Blocks.GRASS);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.OAK_FENCE);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.BIRCH_FENCE);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.SPRUCE_FENCE);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.JUNGLE_FENCE);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.ACACIA_FENCE);
+ AVOreDictionary.AVODBlock("blockFence", Blocks.DARK_OAK_FENCE);
+ AVOreDictionary.AVODItem("itemBook", Items.BOOK);
+ AVOreDictionary.WildcardItem("itemBook", Items.ENCHANTED_BOOK);
+ AVOreDictionary.WildcardBlock("carpet", Blocks.CARPET);
//Food:
- AVOreDictionary.AVODItem("foodApple", Items.apple);
- AVOreDictionary.AVODItem("foodMushroomStew", Items.mushroom_stew);
- AVOreDictionary.AVODItem("foodBread", Items.bread);
- AVOreDictionary.AVODItem("foodPorkchopRaw", Items.porkchop);
- AVOreDictionary.AVODItem("foodPorkchopCocked", Items.cooked_porkchop);
- AVOreDictionary.AVODItem("foodAppleGold", Items.golden_apple);
- AVOreDictionary.AVODItem("foodAppleEnchanted", Items.golden_apple, 1);
- AVOreDictionary.AVODItem("foodFishRaw", Items.fish);
- AVOreDictionary.AVODItem("foodSalomonRaw", Items.fish, 1);
- AVOreDictionary.AVODItem("foodClownfish", Items.fish, 2);
- AVOreDictionary.AVODItem("foodPufferfish", Items.fish, 3);
- AVOreDictionary.AVODItem("foodFishCocked", Items.cooked_fish);
- AVOreDictionary.AVODItem("foodSalomonCocked", Items.cooked_fish, 1);
- AVOreDictionary.AVODItem("foodCake", Items.cake);
- AVOreDictionary.AVODItem("foodCookie", Items.cookie);
- AVOreDictionary.AVODItem("foodMelon", Items.melon);
- AVOreDictionary.AVODItem("foodBeefRaw", Items.beef);
- AVOreDictionary.AVODItem("foodBeefCocked", Items.cooked_beef);
- AVOreDictionary.AVODItem("foodChickenRaw", Items.chicken);
- AVOreDictionary.AVODItem("foodChickenCocked", Items.cooked_chicken);
- AVOreDictionary.AVODItem("foodRottenFlesh", Items.rotten_flesh);
- AVOreDictionary.AVODItem("foodSpiderEye", Items.spider_eye);
- AVOreDictionary.AVODItem("foodCarrot", Items.carrot);
- AVOreDictionary.AVODItem("foodPotato", Items.potato);
- AVOreDictionary.AVODItem("foodPotatoCocked", Items.baked_potato);
- AVOreDictionary.AVODItem("foodPotatoPoisoned", Items.poisonous_potato);
- AVOreDictionary.AVODItem("foodCarrotGolden", Items.golden_carrot);
- AVOreDictionary.AVODItem("foodPiePumpkin", Items.pumpkin_pie);
+ AVOreDictionary.AVODItem("foodApple", Items.APPLE);
+ AVOreDictionary.AVODItem("foodMushroomStew", Items.MUSHROOM_STEW);
+ AVOreDictionary.AVODItem("foodBread", Items.BREAD);
+ AVOreDictionary.AVODItem("foodPorkchopRaw", Items.PORKCHOP);
+ AVOreDictionary.AVODItem("foodPorkchopCocked", Items.COOKED_PORKCHOP);
+ AVOreDictionary.AVODItem("foodAppleGold", Items.GOLDEN_APPLE);
+ AVOreDictionary.AVODItem("foodAppleEnchanted", Items.GOLDEN_APPLE, 1);
+ AVOreDictionary.AVODItem("foodFishRaw", Items.FISH);
+ AVOreDictionary.AVODItem("foodSalomonRaw", Items.FISH, 1);
+ AVOreDictionary.AVODItem("foodClownfish", Items.FISH, 2);
+ AVOreDictionary.AVODItem("foodPufferfish", Items.FISH, 3);
+ AVOreDictionary.AVODItem("foodFishCocked", Items.COOKED_FISH);
+ AVOreDictionary.AVODItem("foodSalomonCocked", Items.COOKED_FISH, 1);
+ AVOreDictionary.AVODItem("foodCake", Items.CAKE);
+ AVOreDictionary.AVODItem("foodCookie", Items.COOKIE);
+ AVOreDictionary.AVODItem("foodMelon", Items.MELON);
+ AVOreDictionary.AVODItem("foodBeefRaw", Items.BEEF);
+ AVOreDictionary.AVODItem("foodBeefCocked", Items.COOKED_BEEF);
+ AVOreDictionary.AVODItem("foodChickenRaw", Items.CHICKEN);
+ AVOreDictionary.AVODItem("foodChickenCocked", Items.COOKED_CHICKEN);
+ AVOreDictionary.AVODItem("foodRottenFlesh", Items.ROTTEN_FLESH);
+ AVOreDictionary.AVODItem("foodSpiderEye", Items.SPIDER_EYE);
+ AVOreDictionary.AVODItem("foodCarrot", Items.CARROT);
+ AVOreDictionary.AVODItem("foodPotato", Items.POTATO);
+ AVOreDictionary.AVODItem("foodPotatoCocked", Items.BAKED_POTATO);
+ AVOreDictionary.AVODItem("foodPotatoPoisoned", Items.POISONOUS_POTATO);
+ AVOreDictionary.AVODItem("foodCarrotGolden", Items.GOLDEN_CARROT);
+ AVOreDictionary.AVODItem("foodPiePumpkin", Items.PUMPKIN_PIE);
}
}
diff --git a/src/main/java/de/canitzp/advancedvanilla/integration/mods/VanillaNetherMetals.java b/src/main/java/de/canitzp/advancedvanilla/integration/mods/VanillaNetherMetals.java
new file mode 100644
index 0000000..b91543e
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/integration/mods/VanillaNetherMetals.java
@@ -0,0 +1,20 @@
+package de.canitzp.advancedvanilla.integration.mods;
+
+import de.canitzp.advancedvanilla.integration.IMod;
+import de.canitzp.advancedvanilla.util.AVOreDictionary;
+
+/**
+ * @author canitzp
+ */
+public class VanillaNetherMetals implements IMod{ //Version: 1.0
+
+ public void postInit(){
+ AVOreDictionary.AVODBlock("oreNetherIron", "vanillanethermetals:nether_iron_ore");
+ AVOreDictionary.AVODBlock("oreNetherGold", "vanillanethermetals:nether_gold_ore");
+ AVOreDictionary.AVODBlock("oreNetherLapis", "vanillanethermetals:nether_lapis_ore");
+ AVOreDictionary.AVODBlock("oreNetherDiamond", "vanillanethermetals:nether_diamond_ore");
+ AVOreDictionary.AVODBlock("oreNetherRedstone", "vanillanethermetals:nether_redstone_ore");
+ AVOreDictionary.AVODBlock("oreNetherCoal", "vanillanethermetals:nether_coal_ore");
+ }
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/ClientProxy.java b/src/main/java/de/canitzp/advancedvanilla/proxy/ClientProxy.java
new file mode 100644
index 0000000..c77643a
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/ClientProxy.java
@@ -0,0 +1,63 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.api.AdvancedVanillaApi;
+import de.canitzp.advancedvanilla.api.IBlockListener;
+import de.canitzp.advancedvanilla.api.IRecipeHandler;
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.util.math.RayTraceResult;
+import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.client.registry.ClientRegistry;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.InputEvent;
+import org.lwjgl.input.Keyboard;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author canitzp
+ */
+public class ClientProxy extends CommonProxy{
+
+ private Map keys = new HashMap<>();
+ public static final int KEY_OPENRECIPECHANGER = 0;
+
+ @Override
+ public void preInit(){
+ keys.put(KEY_OPENRECIPECHANGER, new KeyBinding("To open the Recipe changer", Keyboard.KEY_R, "av.key.recipechanger"));
+
+ for(KeyBinding key : keys.values()){
+ ClientRegistry.registerKeyBinding(key);
+ }
+
+ MinecraftForge.EVENT_BUS.register(this);
+ super.preInit();
+ }
+
+ @SubscribeEvent
+ public void keyEvent(InputEvent.KeyInputEvent event){
+ for(Map.Entry entry : keys.entrySet()){
+ switch(entry.getKey()){
+ case KEY_OPENRECIPECHANGER:{
+ if(entry.getValue().isPressed()){
+ Minecraft mc = Minecraft.getMinecraft();
+ if(mc.objectMouseOver.typeOfHit.equals(RayTraceResult.Type.BLOCK)){
+ for(IBlockListener listener : AdvancedVanillaApi.blockListener){
+ IRecipeHandler handler = listener.getHandlerFromBlock(mc.theWorld, mc.objectMouseOver.getBlockPos(), mc.thePlayer);
+ if(handler != null){
+ wrapper.sendToServer(new PacketOpenGui(GuiHandler.RECIPE_CHANGER, mc.thePlayer, mc.objectMouseOver.getBlockPos()));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/CommonProxy.java b/src/main/java/de/canitzp/advancedvanilla/proxy/CommonProxy.java
new file mode 100644
index 0000000..d16a80f
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/CommonProxy.java
@@ -0,0 +1,24 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.AdvancedVanilla;
+import net.minecraftforge.fml.common.network.NetworkRegistry;
+import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
+import net.minecraftforge.fml.relauncher.Side;
+
+/**
+ * @author canitzp
+ */
+public class CommonProxy{
+
+ public SimpleNetworkWrapper wrapper;
+
+ public void preInit(){
+ wrapper = new SimpleNetworkWrapper(AdvancedVanilla.MODID);
+ wrapper.registerMessage(PacketOpenGui.Handler.class, PacketOpenGui.class, 0, Side.SERVER);
+ wrapper.registerMessage(PacketRecipeChanger.Handler.class, PacketRecipeChanger.class, 1, Side.SERVER);
+ wrapper.registerMessage(PacketRecipeChangerFeedback.Handler.class, PacketRecipeChangerFeedback.class, 2, Side.CLIENT);
+
+ NetworkRegistry.INSTANCE.registerGuiHandler(AdvancedVanilla.instance, new GuiHandler());
+ }
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/GuiHandler.java b/src/main/java/de/canitzp/advancedvanilla/proxy/GuiHandler.java
new file mode 100644
index 0000000..fba72ed
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/GuiHandler.java
@@ -0,0 +1,54 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.api.AdvancedVanillaApi;
+import de.canitzp.advancedvanilla.api.IBlockListener;
+import de.canitzp.advancedvanilla.api.IRecipeHandler;
+import de.canitzp.advancedvanilla.recipechanger.FileLoader;
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+import net.minecraftforge.fml.common.network.IGuiHandler;
+
+import java.util.Map;
+
+/**
+ * @author canitzp
+ */
+public class GuiHandler implements IGuiHandler{
+
+ public static final int RECIPE_CHANGER = 0;
+
+ @Override
+ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){
+ switch(ID){
+ case RECIPE_CHANGER:{
+ IRecipeHandler handler = getIRecipeHandlerFromBlock(world, player, x, y, z);
+ return new RecipeHandler(handler, player);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){
+ switch(ID){
+ case RECIPE_CHANGER:{
+ IRecipeHandler handler = getIRecipeHandlerFromBlock(world, player, x, y, z);
+ return new RecipeHandler.RecipeHandlerGui(new RecipeHandler(handler, player), handler, player);
+ }
+ }
+ return null;
+ }
+
+ private IRecipeHandler getIRecipeHandlerFromBlock(World world, EntityPlayer player, int x, int y, int z){
+ for(IBlockListener listener : AdvancedVanillaApi.blockListener){
+ IRecipeHandler handler = listener.getHandlerFromBlock(world, new BlockPos(x, y, z), player);
+ if(handler != null){
+ return handler;
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/PacketOpenGui.java b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketOpenGui.java
new file mode 100644
index 0000000..17c87b5
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketOpenGui.java
@@ -0,0 +1,62 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.AdvancedVanilla;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.network.PacketBuffer;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
+import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
+
+/**
+ * @author canitzp
+ */
+public class PacketOpenGui implements IMessage{
+
+ private int guiID, worldID, playerID;
+ private BlockPos pos;
+
+ public PacketOpenGui(){}
+
+ public PacketOpenGui(int guiID, EntityPlayer player, BlockPos pos){
+ this.guiID = guiID;
+ this.playerID = player.getEntityId();
+ this.pos = pos;
+ this.worldID = player.worldObj.provider.getDimension();
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf){
+ PacketBuffer buffer = new PacketBuffer(buf);
+ this.guiID = buffer.readInt();
+ this.worldID = buffer.readInt();
+ this.playerID = buffer.readInt();
+ this.pos = buffer.readBlockPos();
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf){
+ PacketBuffer buffer = new PacketBuffer(buf);
+ buffer.writeInt(this.guiID);
+ buffer.writeInt(this.worldID);
+ buffer.writeInt(this.playerID);
+ buffer.writeBlockPos(this.pos);
+ }
+
+ public static class Handler implements IMessageHandler{
+ @Override
+ public IMessage onMessage(PacketOpenGui message, MessageContext ctx){
+ World world = DimensionManager.getWorld(message.worldID);
+ if(world != null){
+ EntityPlayer player = (EntityPlayer) world.getEntityByID(message.playerID);
+ if(player != null){
+ player.openGui(AdvancedVanilla.instance, message.guiID, world, message.pos.getX(), message.pos.getY(), message.pos.getZ());
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChanger.java b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChanger.java
new file mode 100644
index 0000000..7de1e52
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChanger.java
@@ -0,0 +1,66 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
+import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
+
+/**
+ * @author canitzp
+ */
+public class PacketRecipeChanger implements IMessage{
+
+ private int playerID, worldID;
+ private Type type;
+
+ public PacketRecipeChanger(){}
+
+ public PacketRecipeChanger(EntityPlayer player, Type type){
+ this.playerID = player.getEntityId();
+ this.type = type;
+ this.worldID = player.worldObj.provider.getDimension();
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf){
+ this.worldID = buf.readInt();
+ this.playerID = buf.readInt();
+ this.type = Type.values()[buf.readInt()];
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf){
+ buf.writeInt(this.worldID);
+ buf.writeInt(this.playerID);
+ buf.writeInt(this.type.ordinal());
+ }
+
+ public static class Handler implements IMessageHandler{
+ @Override
+ public IMessage onMessage(PacketRecipeChanger message, MessageContext ctx){
+ World world = DimensionManager.getWorld(message.worldID);
+ if(world != null){
+ EntityPlayer player = (EntityPlayer) world.getEntityByID(message.playerID);
+ if(player != null){
+ Container container = player.openContainer;
+ if(container instanceof RecipeHandler){
+ ((RecipeHandler) container).handlePacket(message.type);
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ public enum Type{
+ SAVE,
+ DELETE,
+ RELOAD,
+ CUSTOM
+ }
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChangerFeedback.java b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChangerFeedback.java
new file mode 100644
index 0000000..f98f961
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/proxy/PacketRecipeChangerFeedback.java
@@ -0,0 +1,56 @@
+package de.canitzp.advancedvanilla.proxy;
+
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.world.World;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.fml.common.network.ByteBufUtils;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
+import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
+import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
+
+/**
+ * @author canitzp
+ */
+public class PacketRecipeChangerFeedback implements IMessage{
+
+ private int playerID, worldID;
+ private String message;
+
+ public PacketRecipeChangerFeedback(){}
+
+ public PacketRecipeChangerFeedback(String message, EntityPlayer player){
+ this.message = message;
+ this.playerID = player.getEntityId();
+ this.worldID = player.worldObj.provider.getDimension();
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf){
+ this.worldID = buf.readInt();
+ this.playerID = buf.readInt();
+ this.message = ByteBufUtils.readUTF8String(buf);
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf){
+ buf.writeInt(this.worldID);
+ buf.writeInt(this.playerID);
+ ByteBufUtils.writeUTF8String(buf, this.message);
+ }
+
+ public static class Handler implements IMessageHandler{
+ @Override
+ public IMessage onMessage(PacketRecipeChangerFeedback message, MessageContext ctx){
+ GuiScreen gui = Minecraft.getMinecraft().currentScreen;
+ if(gui instanceof RecipeHandler.RecipeHandlerGui){
+ ((RecipeHandler.RecipeHandlerGui) gui).changeStatus(message.message);
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/recipechanger/FileLoader.java b/src/main/java/de/canitzp/advancedvanilla/recipechanger/FileLoader.java
new file mode 100644
index 0000000..4888ea1
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/recipechanger/FileLoader.java
@@ -0,0 +1,59 @@
+package de.canitzp.advancedvanilla.recipechanger;
+
+import de.canitzp.advancedvanilla.api.IRecipeHandler;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author canitzp
+ */
+public class FileLoader{
+
+ public static void read(IRecipeHandler handler){
+ if(handler.getSaveFile().saveFile.exists()){
+ try{
+ handler.resetRecipes();
+ List lines = FileUtils.readLines(handler.getSaveFile().saveFile);
+ for(int i = 0; i < lines.size(); i++){
+ if(lines.get(i).contains("#") && !lines.get(i + 1).contains("#")){
+ handler.readFromFile(lines.get(i).replace("#", ""), lines.get(i + 1));
+ }
+ }
+ } catch(IOException e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void save(IRecipeHandler handler){
+ File saveFile = handler.getSaveFile().saveFile;
+ try{
+ if(!saveFile.exists()){
+ saveFile.getParentFile().mkdirs();
+ saveFile.createNewFile();
+ } else {
+ saveFile.delete();
+ saveFile.getParentFile().mkdirs();
+ saveFile.createNewFile();
+ }
+
+ List> entries = handler.saveToFile();
+ if(entries != null && entries.size() > 0){
+ StringBuilder builder = new StringBuilder();
+ for(Map.Entry entry : entries){
+ builder.append("#" + entry.getKey()).append("\r\n").append(entry.getValue()).append("\r\n");
+ }
+ FileUtils.writeStringToFile(saveFile, builder.toString());
+ }
+
+ } catch(IOException e){
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/src/main/java/de/canitzp/advancedvanilla/recipechanger/RecipeHandler.java b/src/main/java/de/canitzp/advancedvanilla/recipechanger/RecipeHandler.java
new file mode 100644
index 0000000..978c193
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/recipechanger/RecipeHandler.java
@@ -0,0 +1,217 @@
+package de.canitzp.advancedvanilla.recipechanger;
+
+import de.canitzp.advancedvanilla.AdvancedVanilla;
+import de.canitzp.advancedvanilla.api.AdvancedVanillaApi;
+import de.canitzp.advancedvanilla.api.IRecipeHandler;
+import de.canitzp.advancedvanilla.proxy.PacketRecipeChanger;
+import de.canitzp.advancedvanilla.proxy.PacketRecipeChangerFeedback;
+import de.canitzp.advancedvanilla.util.AVItem;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.InventoryBasic;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraftforge.fml.common.registry.ForgeRegistries;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.oredict.OreDictionary;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author canitzp
+ */
+public class RecipeHandler extends Container{
+
+ public static String STATUS_OK = TextFormatting.DARK_GRAY + "OK";
+ public static String STATUS_ERROR = TextFormatting.RED + "Error";
+ public static String STATUS_SUCCESS = TextFormatting.GREEN + "Success";
+
+ private EntityPlayer player;
+ private IRecipeHandler handler;
+ private IInventory iInventory = new InventoryBasic("RecipeChangerInventory", false, 20);
+ public static void postInit(){
+ AdvancedVanillaApi.addBlockListener(Blocks.CRAFTING_TABLE, new ShapedOreRecipeHandler());
+ }
+ public RecipeHandler(IRecipeHandler handler, EntityPlayer player){
+ this.player = player;
+ this.handler = handler;
+ handler.resetRecipes();
+ FileLoader.read(handler);
+ handler.initContainer(this, player);
+ for(Slot slot : handler.getSlots(this.iInventory, this, this.player)){
+ this.addSlotToContainer(slot);
+ }
+ }
+ @Override
+ public boolean canInteractWith(EntityPlayer playerIn){
+ return playerIn.isCreative();
+ }
+ public void handlePacket(PacketRecipeChanger.Type type){
+ switch(type){
+ case SAVE:{
+ this.handler.onSaveRecipe(this.iInventory, this, this.player);
+ FileLoader.save(this.handler);
+ return;
+ }
+ case DELETE:{
+ this.handler.onDeleteRecipe(this.iInventory, this, this.player);
+ FileLoader.save(this.handler);
+ return;
+ }
+ case RELOAD:{
+ this.handler.onReloadRecipes(this.iInventory, this, this.player);
+ return;
+ }
+ }
+ this.handler.handlePacket(this.iInventory, this, this.player, type);
+ }
+
+ public static String getStringFromStack(Object stack, boolean oreDict){
+ if(stack != null){
+ if(stack instanceof ItemStack){
+ int[] oreDictIDs = OreDictionary.getOreIDs((ItemStack) stack);
+ if(oreDictIDs.length > 0 && oreDict){
+ return "[" + OreDictionary.getOreName(oreDictIDs[0]) + ",1]";
+ } else {
+ return "[" + ForgeRegistries.ITEMS.getKey(((ItemStack) stack).getItem()) + "," + ((ItemStack) stack).stackSize + "," + ((ItemStack) stack).getMetadata() + "]";
+ }
+ } else if(stack instanceof String){
+ return "[" + stack + "]";
+ }
+ }
+ return "[null]";
+ }
+
+ public static Object getStackFromString(String string){
+ string = string.replace("[", "").replace("]", "");
+ String[] parts = string.split(",");
+ if(parts.length == 3){
+ Item item = AVItem.getItemFromName(parts[0]);
+ int amount = Integer.parseInt(parts[1]);
+ int meta = Integer.parseInt(parts[2]);
+ return item != null ? new ItemStack(item, amount, meta) : null;
+ } else if(parts.length == 2 || (parts.length == 1 && !parts[0].equals("null"))){
+ return parts[0];
+ }
+ return null;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static void setFeedbackMessage(EntityPlayer player, String message){
+ if(player instanceof EntityPlayerMP){
+ AdvancedVanilla.proxy.wrapper.sendTo(new PacketRecipeChangerFeedback(message, player), (EntityPlayerMP) player);
+ }
+ }
+
+ public static ItemStack getStackFromObject(Object o){
+ return o == null ? null : o instanceof ItemStack ? (ItemStack) o : OreDictionary.getOres((String) o).size() > 0 ? OreDictionary.getOres((String) o).get(0) : null;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static class RecipeHandlerGui extends GuiContainer{
+ private EntityPlayer player;
+ private IRecipeHandler handler;
+ private ResourceLocation guiLocation;
+ private List buttons = new ArrayList<>();
+ private TabButton feedbackTab;
+ public RecipeHandlerGui(Container container, IRecipeHandler handler, EntityPlayer player){
+ super(container);
+ this.player = player;
+ this.handler = handler;
+ this.guiLocation = handler.getResourceLocation(this, player);
+ this.xSize = handler.getGuiXSize(this, player);
+ this.ySize = handler.getGuiYSize(this, player);
+ buttons.add(new TabButton("Save", -60, -2){
+ @Override
+ public void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton){
+ AdvancedVanilla.proxy.wrapper.sendToServer(new PacketRecipeChanger(player, PacketRecipeChanger.Type.SAVE));
+ }
+ });
+ buttons.add(new TabButton("Delete", -60, -18){
+ @Override
+ public void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton){
+ AdvancedVanilla.proxy.wrapper.sendToServer(new PacketRecipeChanger(player, PacketRecipeChanger.Type.DELETE));
+ }
+ });
+ buttons.add(new TabButton("Reload", -60, -34){
+ @Override
+ public void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton){
+ AdvancedVanilla.proxy.wrapper.sendToServer(new PacketRecipeChanger(player, PacketRecipeChanger.Type.RELOAD));
+ }
+ });
+ buttons.add(this.feedbackTab = new TabButton(STATUS_OK, -60, -50){
+ @Override
+ public void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton){
+ feedbackTab.setText(STATUS_OK);
+ }
+ });
+ handler.initGui(this, player, this.buttons);
+ }
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY){
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ for(TabButton button : this.buttons){
+ button.draw(this.mc, this.guiLeft, this.guiTop);
+ }
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.getTextureManager().bindTexture(this.guiLocation);
+ this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
+ handler.drawGuiContainerBackgroundLayer(this, this.player, partialTicks, mouseX, mouseY);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException{
+ for(TabButton button : this.buttons){
+ if(button.mouseClick(this.guiLeft, this.guiTop, mouseX, mouseY)){
+ button.onMouseClick(this.guiLeft, this.guiTop, mouseX, mouseY, mouseButton);
+ }
+ }
+ handler.mouseClick(this, this.player, mouseX, mouseY, mouseButton);
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+
+ public void changeStatus(String message){
+ this.feedbackTab.setText(message);
+ }
+
+ public static abstract class TabButton extends Gui{
+ private ResourceLocation tabLocation = new ResourceLocation(AdvancedVanilla.MODID, "textures/gui/tabs.png");
+ private int x, y;
+ private String buttonText;
+ public TabButton(String buttonText, int x, int y){
+ this.buttonText = buttonText;
+ this.x = x;
+ this.y = y;
+ }
+ public void draw(Minecraft minecraft, int guiLeft, int guiTop){
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ minecraft.getTextureManager().bindTexture(this.tabLocation);
+ this.drawTexturedModalRect(guiLeft + this.x, guiTop - this.y, 0, 0, -this.x+3, 15);
+ minecraft.fontRendererObj.drawString(this.buttonText, guiLeft + this.x + 4, guiTop - this.y - (minecraft.fontRendererObj.FONT_HEIGHT / 2) + 8, 0x0);
+ }
+ public boolean mouseClick(int guiLeft, int guiTop, int mouseX, int mouseY){
+ return guiLeft + this.x <= mouseX && guiLeft + this.x + (-this.x + 3) >= mouseX && guiTop - this.y <= mouseY && guiTop - this.y + 15 >= mouseY;
+ }
+ public abstract void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton);
+ public void setText(String text){
+ this.buttonText = text;
+ }
+ public String getText(){
+ return buttonText;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/canitzp/advancedvanilla/recipechanger/ShapedOreRecipeHandler.java b/src/main/java/de/canitzp/advancedvanilla/recipechanger/ShapedOreRecipeHandler.java
new file mode 100644
index 0000000..307540a
--- /dev/null
+++ b/src/main/java/de/canitzp/advancedvanilla/recipechanger/ShapedOreRecipeHandler.java
@@ -0,0 +1,333 @@
+package de.canitzp.advancedvanilla.recipechanger;
+
+import de.canitzp.advancedvanilla.AdvancedVanilla;
+import de.canitzp.advancedvanilla.api.AdvancedVanillaApi;
+import de.canitzp.advancedvanilla.api.IRecipeHandler;
+import de.canitzp.advancedvanilla.proxy.PacketRecipeChanger;
+import de.canitzp.advancedvanilla.util.AVRecipe;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraftforge.common.network.ForgeNetworkHandler;
+import net.minecraftforge.fml.common.FMLCommonHandler;
+import net.minecraftforge.fml.common.event.FMLLoadEvent;
+import net.minecraftforge.fml.common.registry.GameRegistry;
+import net.minecraftforge.fml.relauncher.Side;
+import net.minecraftforge.fml.relauncher.SideOnly;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+import net.minecraftforge.oredict.ShapelessOreRecipe;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author canitzp
+ */
+public class ShapedOreRecipeHandler implements IRecipeHandler{
+
+ private static List shapedRecipe = new ArrayList<>();
+ private static List shapelessRecipe = new ArrayList<>();
+
+ private static final String SHAPED = TextFormatting.RED + "Shaped";
+ private static final String SHAPELESS = TextFormatting.BLUE + "Shapeless";
+ private boolean isShaped = true;
+
+ private List getRecipeList(){
+ return isShaped ? shapedRecipe : shapelessRecipe;
+ }
+
+ @Override
+ public AdvancedVanillaApi.SaveFiles getSaveFile(){
+ return isShaped ? AdvancedVanillaApi.SaveFiles.SHAPED_ORE : AdvancedVanillaApi.SaveFiles.SHAPELESS_ORE;
+ }
+
+ @Override
+ public List getSlots(IInventory inventory, Container container, EntityPlayer player){
+ this.isShaped = true;
+ List slots = new ArrayList<>();
+ slots.add(new Slot(inventory, 9, 124, 35));
+ for(int i = 0; i < 3; ++i){
+ for(int j = 0; j < 3; ++j){
+ slots.add(new Slot(inventory, j + i * 3, 30 + j * 18, 17 + i * 18));
+ }
+ }
+ for(int k = 0; k < 3; ++k){
+ for(int i1 = 0; i1 < 9; ++i1){
+ slots.add(new Slot(player.inventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
+ }
+ }
+ for(int l = 0; l < 9; ++l){
+ slots.add(new Slot(player.inventory, l, 8 + l * 18, 142));
+ }
+ return slots;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public ResourceLocation getResourceLocation(GuiContainer gui, EntityPlayer player){
+ return new ResourceLocation("textures/gui/container/crafting_table.png");
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void initGui(GuiContainer gui, EntityPlayer player, List buttons){
+ buttons.add(new RecipeHandler.RecipeHandlerGui.TabButton(SHAPED, -60, -66){
+ @Override
+ public void onMouseClick(int guiLeft, int guiTop, int mouseX, int mouseY, int mouseButton){
+ AdvancedVanilla.proxy.wrapper.sendToServer(new PacketRecipeChanger(player, PacketRecipeChanger.Type.CUSTOM));
+ if(this.getText().equals(SHAPED)){
+ this.setText(SHAPELESS);
+ } else {
+ this.setText(SHAPED);
+ }
+ }
+ });
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public int getGuiXSize(GuiContainer gui, EntityPlayer player){
+ return 176;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public int getGuiYSize(GuiContainer gui, EntityPlayer player){
+ return 166;
+ }
+
+ @Override
+ public void onSaveRecipe(IInventory inventory, Container container, EntityPlayer player){
+ if(!addRecipe(new RecipeManager(inventory.getStackInSlot(9) != null ? inventory.getStackInSlot(9).copy() : null, inventory))){
+ RecipeHandler.setFeedbackMessage(player, RecipeHandler.STATUS_ERROR);
+ } else {
+ RecipeHandler.setFeedbackMessage(player, RecipeHandler.STATUS_SUCCESS);
+ }
+ }
+
+ @Override
+ public void onDeleteRecipe(IInventory inventory, Container container, EntityPlayer player){
+ if(!removeRecipe(new RecipeManager(inventory.getStackInSlot(9) != null ? inventory.getStackInSlot(9).copy() : null, inventory))){
+ RecipeHandler.setFeedbackMessage(player, RecipeHandler.STATUS_ERROR);
+ } else {
+ RecipeHandler.setFeedbackMessage(player, RecipeHandler.STATUS_SUCCESS);
+ }
+ }
+
+ @Override
+ public void handlePacket(IInventory inventory, Container container, EntityPlayer player, PacketRecipeChanger.Type type){
+ if(type.equals(PacketRecipeChanger.Type.CUSTOM)){
+ this.isShaped = !this.isShaped;
+ FileLoader.read(this);
+ }
+ }
+
+ @Override
+ public void resetRecipes(){
+ getRecipeList().clear();
+ }
+
+ @Override
+ public List> saveToFile(){
+ List> rec = new ArrayList<>();
+ for(RecipeManager recipe : getRecipeList()){
+ String id = RecipeHandler.getStringFromStack(recipe.output.copy(), false);
+ String values = "";
+ for(Object stack : recipe.input.clone()){
+ values += RecipeHandler.getStringFromStack(stack, false); //TODO option to enable oreDict for specific stack
+ }
+ rec.add(Pair.of(id, values));
+ }
+ return rec;
+ }
+
+ @Override
+ public void readFromFile(String identifier, String recipeLine){
+ Object output = RecipeHandler.getStackFromString(identifier);
+ Object[] input = new Object[recipeLine.split("]").length];
+ String[] split = recipeLine.split("]");
+ for(int i = 0; i < split.length; i++){
+ input[i] = RecipeHandler.getStackFromString(split[i]);
+ }
+ if(output != null && output instanceof ItemStack){
+ addRecipe(new RecipeManager(input.clone(), ((ItemStack) output).copy()));
+ }
+ }
+
+ public boolean addRecipe(RecipeManager recipe){
+ if(recipe.output == null || recipe.isInputEmpty()){
+ return false;
+ }
+ for(RecipeManager handler : getRecipeList()){
+ if(handler.equals(recipe)){
+ return false;
+ }
+ }
+ getRecipeList().add(recipe);
+ if(isShaped){
+ addShapedRecipe(recipe.output.copy(), recipe.input.clone());
+ } else {
+ addShapelessRecipe(recipe.output.copy(), recipe.input.clone());
+ }
+
+
+ return true;
+ }
+
+ public boolean removeRecipe(RecipeManager recipe){
+ for(int i = 0; i < getRecipeList().size(); i++){
+ if(getRecipeList().get(i).equals(recipe)){
+ getRecipeList().remove(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void addShapedRecipe(ItemStack output, Object... input){
+ List objects = new ArrayList<>();
+ String firstLine = "", secondLine = "", thirdLine = "";
+
+ if(input[0] != null){
+ firstLine += "A";
+ objects.add('A');
+ objects.add(input[0]);
+ } else {
+ firstLine += " ";
+ }
+ if(input[1] != null){
+ firstLine += "B";
+ objects.add('B');
+ objects.add(input[1]);
+ } else {
+ firstLine += " ";
+ }
+ if(input[2] != null){
+ firstLine += "C";
+ objects.add('C');
+ objects.add(input[2]);
+ } else {
+ firstLine += " ";
+ }
+
+ if(input[3] != null){
+ secondLine += "D";
+ objects.add('D');
+ objects.add(input[3]);
+ } else {
+ secondLine += " ";
+ }
+ if(input[4] != null){
+ secondLine += "E";
+ objects.add('E');
+ objects.add(input[4]);
+ } else {
+ secondLine += " ";
+ }
+ if(input[5] != null){
+ secondLine += "F";
+ objects.add('F');
+ objects.add(input[5]);
+ } else {
+ secondLine += " ";
+ }
+
+ if(input[6] != null){
+ thirdLine += "G";
+ objects.add('G');
+ objects.add(input[6]);
+ } else {
+ thirdLine += " ";
+ }
+ if(input[7] != null){
+ thirdLine += "H";
+ objects.add('H');
+ objects.add(input[7]);
+ } else {
+ thirdLine += " ";
+ }
+ if(input[8] != null){
+ thirdLine += "I";
+ objects.add('I');
+ objects.add(input[8]);
+ } else {
+ thirdLine += " ";
+ }
+
+ List objList = new ArrayList<>();
+ objList.add(firstLine);
+ objList.add(secondLine);
+ objList.add(thirdLine);
+ objList.addAll(objects);
+
+ GameRegistry.addRecipe(new ShapedOreRecipe(output, objList.toArray()));
+ }
+
+ public static void addShapelessRecipe(ItemStack output, Object... input){
+ List newInput = new ArrayList<>();
+ for(Object o : input){
+ if(o != null){
+ if(o instanceof ItemStack || o instanceof String){
+ newInput.add(o);
+ }
+ }
+ }
+ GameRegistry.addRecipe(new ShapelessOreRecipe(output, newInput.toArray()));
+ }
+
+ private static class RecipeManager{
+ private Object[] input;
+ private ItemStack output;
+
+ private RecipeManager(ItemStack result, IInventory input){
+ this.input = new ItemStack[9];
+ for(int i = 0; i < 9; i++){
+ this.input[i] = input.getStackInSlot(i);
+ }
+ this.output = result;
+ }
+
+ private RecipeManager(Object[] input, ItemStack output){
+ this.input = input.clone();
+ this.output = output.copy();
+ }
+
+ @Override
+ public boolean equals(Object obj){
+ if(obj != null && obj instanceof RecipeManager){
+ RecipeManager recipeHandler = (RecipeManager) obj;
+ if(ItemStack.areItemStacksEqual(this.output, recipeHandler.output)){
+ for(int i = 0; i < this.input.length; i++){
+ if(!ItemStack.areItemStacksEqual(RecipeHandler.getStackFromObject(input[i]), RecipeHandler.getStackFromObject(recipeHandler.input[i]))){
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isInputEmpty(){
+ for(Object stack : this.input){
+ if(stack != null){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String toString(){
+ return "Output:[" + this.output.toString() + "] Input:" + Arrays.toString(this.input);
+ }
+ }
+}
+
diff --git a/src/main/java/de/canitzp/advancedvanilla/util/AVItem.java b/src/main/java/de/canitzp/advancedvanilla/util/AVItem.java
index 3da1979..07bae8b 100644
--- a/src/main/java/de/canitzp/advancedvanilla/util/AVItem.java
+++ b/src/main/java/de/canitzp/advancedvanilla/util/AVItem.java
@@ -7,12 +7,12 @@
public class AVItem{
public static Item getItemFromName(String name) {
ResourceLocation loc = new ResourceLocation(name);
- if (Item.itemRegistry.containsKey(loc)) {
- return (Item)Item.itemRegistry.getObject(loc);
+ if (Item.REGISTRY.containsKey(loc)) {
+ return (Item)Item.REGISTRY.getObject(loc);
}
else {
try {
- return (Item)Item.itemRegistry.getObjectById(Integer.parseInt(name));
+ return (Item)Item.REGISTRY.getObjectById(Integer.parseInt(name));
}
catch (NumberFormatException numberformatexception) {
return null;
diff --git a/src/main/java/de/canitzp/advancedvanilla/util/AVRecipe.java b/src/main/java/de/canitzp/advancedvanilla/util/AVRecipe.java
index 113c0cd..957005b 100644
--- a/src/main/java/de/canitzp/advancedvanilla/util/AVRecipe.java
+++ b/src/main/java/de/canitzp/advancedvanilla/util/AVRecipe.java
@@ -1,7 +1,10 @@
package de.canitzp.advancedvanilla.util;
+import de.canitzp.advancedvanilla.recipechanger.RecipeHandler;
import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
@@ -19,25 +22,45 @@
public class AVRecipe {
+ private static boolean isItemBlockEqual(ItemBlock input1, ItemBlock input2){
+ return input1.getRegistryName().equals(input2.getRegistryName());
+ }
+ private static boolean isRecipeInputEqual(Object[] recipe1, Object[] recipe2){
+ for (int i = 0; i < recipe1.length; i++) {
+ Object obj = recipe1[i];
+ if (!(obj == recipe2[i]) && (obj instanceof ItemStack && !(((ItemStack) obj).isItemEqual((ItemStack) recipe2[i])))){
+ return false;
+ }
+ }
+ return true;
+ }
+
//Vanilla:
- public static void AVODShapedBlock(String block, int meta, Object[] paramsOld, Object[] paramsNew){
+ public static void AVODShapedBlock(String block, int amount, int meta, Object[] paramsOld, Object[] paramsNew){
if(paramsOld != null){
+ List recipeList = CraftingManager.getInstance().getRecipeList();
List toRemove = new ArrayList<>(), toAdd = new ArrayList<>();
- for (Object rec : CraftingManager.getInstance().getRecipeList()){
+ for (IRecipe rec : recipeList){
if(rec instanceof ShapedOreRecipe){
- if(((ShapedOreRecipe) rec).getRecipeOutput().getItem() == Item.getItemFromBlock(Block.getBlockFromName(block))){
- if(Arrays.equals(((ShapedOreRecipe) rec).getInput(), paramsOld)){
- toRemove.add((IRecipe) rec);
- toAdd.add(new ShapedOreRecipe(Block.getBlockFromName(block), paramsNew));
+ if(rec.getRecipeOutput().getItem() instanceof ItemBlock){
+ if(isItemBlockEqual((ItemBlock) rec.getRecipeOutput().getItem(), (ItemBlock) Item.getItemFromBlock(Block.getBlockFromName(block)))){
+ if(isRecipeInputEqual(((ShapedOreRecipe) rec).getInput(), new ShapedOreRecipe((Block) null, paramsOld).getInput())){
+ toRemove.add(rec);
+ break;
+ }
}
}
}
}
CraftingManager.getInstance().getRecipeList().removeAll(toRemove);
- CraftingManager.getInstance().getRecipeList().addAll(toAdd);
- return;
}
- GameRegistry.addRecipe(new ShapedOreRecipe(Block.getBlockFromName(block), paramsNew));
+ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Block.getBlockFromName(block), amount, meta), paramsNew));
+ }
+ public static void AVODShapedBlock(String block, Object[] paramsOld, Object[] paramsNew){
+ AVODShapedBlock(block, 1, 0, paramsOld, paramsNew);
+ }
+ public static void AVODShapedBlock(String block, Object[] params){
+ AVODShapedBlock(block, null, params);
}
public static void AVODShapedItem(String item, int meta, Object... params){
diff --git a/src/main/resources/assets/advancedvanilla/textures/gui/tabs.png b/src/main/resources/assets/advancedvanilla/textures/gui/tabs.png
new file mode 100644
index 0000000..15d6873
Binary files /dev/null and b/src/main/resources/assets/advancedvanilla/textures/gui/tabs.png differ