mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
Remove nonfunctional code IMCHandler
Forge currently doesn't allow runtime recipe addition/deletion, disabled those IMC messages
This commit is contained in:
1 parent
fd5df3107d
commit
5e45e160b9
2 files changed
+43
-118
No files matched your search
@@ -21,105 +21,55 @@ public class IMCHandler
|
||||
{
|
||||
if(msg.isNBTMessage())
|
||||
{
|
||||
try {
|
||||
boolean found = false;
|
||||
boolean delete = false;
|
||||
|
||||
String message = msg.key;
|
||||
|
||||
if(message.equals("ShapedMekanismRecipe"))
|
||||
{
|
||||
// ShapedMekanismRecipe recipe = ShapedMekanismRecipe.create(msg.getNBTValue());
|
||||
//
|
||||
// if(recipe != null)
|
||||
// {
|
||||
// GameRegistry.addRecipe(recipe);
|
||||
// Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added a shaped recipe to the recipe list.");
|
||||
// }
|
||||
// else {
|
||||
// Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add an invalid shaped recipe.");
|
||||
// }
|
||||
boolean found = false;
|
||||
boolean delete = false;
|
||||
|
||||
found = true;
|
||||
}
|
||||
else if(message.equals("ShapelessMekanismRecipe"))
|
||||
{
|
||||
// ShapelessMekanismRecipe recipe = ShapelessMekanismRecipe.create(msg.getNBTValue());
|
||||
//
|
||||
// if(recipe != null)
|
||||
// {
|
||||
// GameRegistry.addRecipe(recipe);
|
||||
// Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added a shapeless recipe to the recipe list.");
|
||||
// }
|
||||
// else {
|
||||
// Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add an invalid shapeless recipe.");
|
||||
// }
|
||||
String message = msg.key;
|
||||
|
||||
found = true;
|
||||
}
|
||||
else if(message.equals("DeleteMekanismRecipes") || message.equals("RemoveMekanismRecipes"))
|
||||
if(message.startsWith("Delete") || message.startsWith("Remove"))
|
||||
{
|
||||
message = message.replace("Delete", "").replace("Remove", "");
|
||||
delete = true;
|
||||
}
|
||||
|
||||
for(Recipe type : Recipe.values())
|
||||
{
|
||||
if(message.equalsIgnoreCase(type.getRecipeName() + "Recipe"))
|
||||
{
|
||||
ItemStack stack = RecipeUtils.loadRecipeItemStack(msg.getNBTValue());
|
||||
|
||||
if(!stack.isEmpty())
|
||||
MachineInput input = type.createInput(msg.getNBTValue());
|
||||
|
||||
if(input != null && input.isValid())
|
||||
{
|
||||
RecipeUtils.removeRecipes(stack);
|
||||
Mekanism.logger.info("[Mekanism] " + msg.getSender() + " removed a Mekanism recipe from the recipe list.");
|
||||
}
|
||||
else {
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to remove a Mekanism recipe with an invalid output.");
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
MachineRecipe recipe = type.createRecipe(input, msg.getNBTValue());
|
||||
|
||||
if(message.startsWith("Delete") || message.startsWith("Remove"))
|
||||
{
|
||||
message = message.replace("Delete", "").replace("Remove", "");
|
||||
delete = true;
|
||||
}
|
||||
|
||||
for(Recipe type : Recipe.values())
|
||||
{
|
||||
if(message.equalsIgnoreCase(type.getRecipeName() + "Recipe"))
|
||||
{
|
||||
MachineInput input = type.createInput(msg.getNBTValue());
|
||||
|
||||
if(input != null && input.isValid())
|
||||
if(recipe != null && recipe.recipeOutput != null)
|
||||
{
|
||||
MachineRecipe recipe = type.createRecipe(input, msg.getNBTValue());
|
||||
|
||||
if(recipe != null && recipe.recipeOutput != null)
|
||||
if(delete)
|
||||
{
|
||||
if(delete)
|
||||
{
|
||||
RecipeHandler.removeRecipe(type, recipe);
|
||||
Mekanism.logger.info("[Mekanism] " + msg.getSender() + " removed recipe of type " + type.getRecipeName() + " from the recipe list.");
|
||||
}
|
||||
else {
|
||||
RecipeHandler.addRecipe(type, recipe);
|
||||
Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added recipe of type " + type.getRecipeName() + " to the recipe list.");
|
||||
}
|
||||
RecipeHandler.removeRecipe(type, recipe);
|
||||
Mekanism.logger.info("[Mekanism] " + msg.getSender() + " removed recipe of type " + type.getRecipeName() + " from the recipe list.");
|
||||
}
|
||||
else {
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid output.");
|
||||
RecipeHandler.addRecipe(type, recipe);
|
||||
Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added recipe of type " + type.getRecipeName() + " to the recipe list.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid input.");
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid output.");
|
||||
}
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid input.");
|
||||
}
|
||||
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " sent unknown IMC message with key '" + msg.key + ".'");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(!found)
|
||||
{
|
||||
Mekanism.logger.error("[Mekanism] " + msg.getSender() + " sent unknown IMC message with key '" + msg.key + ".'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
@@ -17,13 +20,17 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
public class RecipeUtils
|
||||
{
|
||||
@@ -289,41 +296,9 @@ public class RecipeUtils
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static boolean removeRecipes(ItemStack stack)
|
||||
{
|
||||
// List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
//
|
||||
// for(Iterator<IRecipe> iter = recipes.iterator(); iter.hasNext();)
|
||||
// {
|
||||
// IRecipe iterRecipe = iter.next();
|
||||
//
|
||||
// if(iterRecipe instanceof ShapedMekanismRecipe || iterRecipe instanceof ShapelessMekanismRecipe)
|
||||
// {
|
||||
// if(StackUtils.equalsWildcard(stack, iterRecipe.getRecipeOutput()))
|
||||
// {
|
||||
// iter.remove();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world)
|
||||
{
|
||||
// List<IRecipe> list = new ArrayList<IRecipe>(CraftingManager.getInstance().getRecipeList());
|
||||
//
|
||||
// for(Iterator<IRecipe> iter = list.iterator(); iter.hasNext();)
|
||||
// {
|
||||
// IRecipe recipe = iter.next();
|
||||
//
|
||||
// if(recipe.matches(inv, world))
|
||||
// {
|
||||
// return recipe;
|
||||
// }
|
||||
// }
|
||||
|
||||
return null;
|
||||
return CraftingManager.findMatchingRecipe(inv, world);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user