ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/communication/InterModCommunications.java

105 lines
5.8 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("InterModCommunications.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* <EFBFBD> 2015 Ellpeck
*/
2015-06-28 03:12:32 +02:00
package ellpeck.actuallyadditions.communication;
import cpw.mods.fml.common.event.FMLInterModComms;
import ellpeck.actuallyadditions.items.ItemCoffee;
import ellpeck.actuallyadditions.recipe.HairyBallHandler;
2015-07-10 13:08:20 +02:00
import ellpeck.actuallyadditions.recipe.TreasureChestHandler;
2015-06-28 03:12:32 +02:00
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import java.util.List;
2015-10-03 22:09:53 +02:00
2015-06-28 03:12:32 +02:00
public class InterModCommunications{
public static void processIMC(List<FMLInterModComms.IMCMessage> messages){
for(FMLInterModComms.IMCMessage message : messages){
//TODO This
/*if(message.key.equalsIgnoreCase("registerCrusherRecipe")){
2015-06-28 03:12:32 +02:00
NBTTagCompound compound = message.getNBTValue();
if(compound != null){
ItemStack input = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("input"));
ItemStack outputOne = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("outputOne"));
ItemStack outputTwo = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("outputTwo"));
int secondChance = compound.getInteger("secondChance");
if(input != null && outputOne != null){
CrusherRecipeManualRegistry.registerRecipe(input, outputOne, outputTwo, secondChance);
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Crusher Recipe that was sent from Mod "+message.getSender()+" has been registered successfully: "+input.toString()+" -> "+outputOne.toString()+(outputTwo != null ? " + "+outputTwo.toString()+", Second Chance: "+secondChance : ""));
2015-06-28 03:12:32 +02:00
}
2015-10-02 16:48:01 +02:00
else{
ModUtil.LOGGER.error("Crusher Recipe that was sent from Mod "+message.getSender()+" could not be registered: It's missing an Input or an Output!");
}
2015-06-28 03:12:32 +02:00
}
}*/
2015-06-28 03:12:32 +02:00
if(message.key.equalsIgnoreCase("registerCoffeeMachineRecipe")){
NBTTagCompound compound = message.getNBTValue();
if(compound != null){
ItemStack input = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("input"));
int potionID = compound.getInteger("id");
int duration = compound.getInteger("duration");
int amplifier = compound.getInteger("amplifier");
int maxAmp = compound.getInteger("maxAmp");
if(input != null && potionID > 0 && duration > 0 && maxAmp > 0){
PotionEffect effect = new PotionEffect(potionID, duration, amplifier);
ItemCoffee.registerIngredient(new ItemCoffee.Ingredient(input, new PotionEffect[]{effect}, maxAmp));
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Coffee Machine Recipe that was sent from Mod "+message.getSender()+" has been registered successfully: "+input.toString()+" -> "+effect.toString());
2015-06-28 03:12:32 +02:00
}
2015-10-02 16:48:01 +02:00
else{
ModUtil.LOGGER.error("Coffee Machine Recipe that was sent from Mod "+message.getSender()+" could not be registered: It's missing an Input, a Potion ID, a Duration or a max Amplifier!");
}
2015-06-28 03:12:32 +02:00
}
}
if(message.key.equalsIgnoreCase("registerBallOfHairRecipe")){
NBTTagCompound compound = message.getNBTValue();
if(compound != null){
ItemStack output = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("output"));
int chance = compound.getInteger("chance");
if(output != null && chance > 0){
HairyBallHandler.addReturn(output, chance);
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Ball Of Hair Recipe that was sent from Mod "+message.getSender()+" has been registered successfully: "+output.toString()+", Chance: "+chance);
2015-06-28 03:12:32 +02:00
}
2015-10-02 16:48:01 +02:00
else{
ModUtil.LOGGER.error("Ball Of Hair Recipe that was sent from Mod "+message.getSender()+" could not be registered: It's missing an Output or a Chance!");
}
2015-06-28 03:12:32 +02:00
}
}
2015-07-10 13:08:20 +02:00
if(message.key.equalsIgnoreCase("registerTreasureChestRecipe")){
NBTTagCompound compound = message.getNBTValue();
if(compound != null){
ItemStack output = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("output"));
int chance = compound.getInteger("chance");
int minAmount = compound.getInteger("minAmount");
int maxAmount = compound.getInteger("maxAmount");
if(output != null && chance > 0 && minAmount > 0 && maxAmount >= minAmount){
TreasureChestHandler.addReturn(output, chance, minAmount, maxAmount);
ModUtil.LOGGER.info("Treasure Chest Recipe that was sent from Mod "+message.getSender()+" has been registered successfully: "+output.toString()+", Chance: "+chance+", Min Amount: "+minAmount+", Max Amount: "+maxAmount);
}
2015-10-02 16:48:01 +02:00
else{
ModUtil.LOGGER.error("Treasure Chest Recipe that was sent from Mod "+message.getSender()+" could not be registered: It's missing an Output, a Chance or minimum and maximum Amounts!");
}
2015-07-10 13:08:20 +02:00
}
}
2015-06-28 03:12:32 +02:00
}
}
}