Adding CompressionHandler for superAwesomeSigilOfAwesome!

This commit is contained in:
WayofTime 2014-11-20 07:57:08 -05:00
parent 90aeaac6e2
commit 75dcf143d5
6 changed files with 330 additions and 3 deletions

View file

@ -1,5 +1,5 @@
#
#Tue Nov 18 15:51:47 EST 2014
#Wed Nov 19 19:11:08 EST 2014
mod_name=BloodMagic
forge_version=10.13.2.1232
ccc_version=1.0.4.29
@ -8,5 +8,5 @@ nei_version=1.0.3.64
package_group=com.wayoftime.bloodmagic
mod_version=1.2.1-Beta
minetweaker_version=Dev-1.7.10-3.0.9B
build_number=4
mc_version=1.7.10
build_number=3

View file

@ -785,6 +785,7 @@ public class AlchemicalWizardry
ItemStack costCoreStack = new ItemStack(ModItems.baseItems, 1, 23);
ItemStack potencyCoreStack = new ItemStack(ModItems.baseItems, 1, 24);
ItemStack obsidianBraceStack = new ItemStack(ModItems.baseItems, 1, 25);
ItemStack etherealSlateStack = new ItemStack(ModItems.baseItems, 1, 27);
ItemStack magicalesCraftedCableStack = new ItemStack(ModItems.baseItems, 5, 2);
ItemStack crackedRunicPlateStackCrafted = new ItemStack(ModItems.baseItems, 2, 15);
@ -821,6 +822,10 @@ public class AlchemicalWizardry
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(costCoreStack, "msm", "geg", "mom", 'm', reductusStack, 'e', emptyCoreStack, 'o', masterBloodOrbStack, 's', weakBloodShardStack, 'g', goldIngotStack));
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(potencyCoreStack, "msm", "geg", "mom", 'm', potentiaStack, 'e', emptyCoreStack, 'o', masterBloodOrbStack, 's', weakBloodShardStack, 'g', goldIngotStack));
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(ModItems.itemHarvestSigil), "mgm", "gsg", "mom", 's', etherealSlateStack, 'o', archmageBloodOrbStack, 'g', new ItemStack(Items.golden_hoe), 'm', new ItemStack(Blocks.dirt)));
AltarRecipeRegistry.registerAltarRecipe(etherealSlateStack, demonSlateStack, 5, 30000, 40, 100, false);
GameRegistry.addRecipe(new ShapedBloodOrbRecipe(new ItemStack(ModBlocks.bloodRune, 1, 5), "bsb", "grg", "bob", 's', etherealSlateStack, 'o', archmageBloodOrbStack, 'r', speedRuneStack, 'b', emptyBucketStack, 'g', goldIngotStack));
AlchemyRecipeRegistry.registerRecipe(crackedRunicPlateStackCrafted, 10, new ItemStack[]{imbuedSlateStack, imbuedSlateStack, concentratedCatalystStack}, 4);
AlchemyRecipeRegistry.registerRecipe(runicPlateStack, 30, new ItemStack[]{crackedRunicPlateStack, terraeStack}, 5);
AlchemyRecipeRegistry.registerRecipe(imbuedRunicPlateStack, 100, new ItemStack[]{magicalesStack, incendiumStack, runicPlateStack, runicPlateStack, aquasalusStack}, 5);
@ -1001,7 +1006,6 @@ public class AlchemicalWizardry
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.clay_ball), Potion.moveSlowdown.id, 450);
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.redstone), Potion.digSpeed.id, 2 * 60 * 20);
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.potionitem, 1, 0), AlchemicalWizardry.customPotionDrowning.id, 450);
//AlchemicalPotionCreationHandler.addPotion(new ItemStack(Item.goldenCarrot),Potion.nightVision.id,2*60*20);
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.glass_bottle), Potion.invisibility.id, 2 * 60 * 20);
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.diamond), Potion.resistance.id, 2 * 60 * 20);
AlchemicalPotionCreationHandler.addPotion(new ItemStack(Items.poisonous_potato), Potion.field_76443_y.id, 2); //saturation

View file

@ -0,0 +1,17 @@
package WayofTime.alchemicalWizardry.api.compress;
import net.minecraft.item.ItemStack;
public abstract class CompressionHandler
{
public abstract ItemStack getResultStack();
public abstract ItemStack getRequiredStack();
/**
* Called to look at the inventory and syphons the required stack. Returns getResultStack if successful, and null if not.
* @param inv The inventory iterated through
* @return The result of the compression
*/
public abstract ItemStack compressInventory(ItemStack[] inv);
}

View file

@ -0,0 +1,34 @@
package WayofTime.alchemicalWizardry.api.compress;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
/**
* A registry aimed to help compress items in an inventory into its compressible form.
*
*/
public class CompressionRegistry
{
public static List<CompressionHandler> compressionRegistry = new ArrayList();
public static void registerHandler(CompressionHandler handler)
{
compressionRegistry.add(handler);
}
public static ItemStack compressInventory(ItemStack[] inv)
{
for(CompressionHandler handler : compressionRegistry)
{
ItemStack stack = handler.compressInventory(inv);
if(stack != null)
{
return stack;
}
}
return null;
}
}

View file

@ -0,0 +1,58 @@
package WayofTime.alchemicalWizardry.common.compress;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.api.compress.CompressionHandler;
public class BaseCompressionHandler extends CompressionHandler
{
private final ItemStack required;
private final ItemStack result;
private final int leftover;
public BaseCompressionHandler(ItemStack requested, ItemStack result, int leftover)
{
super();
this.required = requested;
this.result = result;
this.leftover = leftover;
}
@Override
public ItemStack getResultStack()
{
return this.result.copy();
}
@Override
public ItemStack getRequiredStack()
{
return this.required.copy();
}
@Override
public ItemStack compressInventory(ItemStack[] inv)
{
int needed = this.required.stackSize;
int kept = this.getLeftover();
for(ItemStack invStack : inv)
{
if(invStack == null)
{
continue;
}
if(invStack.equals(invStack))
{
}
}
return null;
}
public int getLeftover()
{
return this.leftover;
}
}

View file

@ -0,0 +1,214 @@
package WayofTime.alchemicalWizardry.common.items.sigil;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.harvest.HarvestRegistry;
import WayofTime.alchemicalWizardry.api.items.interfaces.ArmourUpgrade;
import WayofTime.alchemicalWizardry.api.items.interfaces.IHolding;
import WayofTime.alchemicalWizardry.common.items.EnergyItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemPackRatSigil extends EnergyItems implements IHolding, ArmourUpgrade
{
@SideOnly(Side.CLIENT)
private static IIcon activeIcon;
@SideOnly(Side.CLIENT)
private static IIcon passiveIcon;
public ItemPackRatSigil()
{
super();
this.maxStackSize = 1;
setEnergyUsed(500);
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("You sow what you reap");
if (!(par1ItemStack.stackTagCompound == null))
{
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
{
par3List.add("Activated");
} else
{
par3List.add("Deactivated");
}
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:HarvestGoddessSigil_deactivated");
this.activeIcon = iconRegister.registerIcon("AlchemicalWizardry:HarvestGoddessSigil_activated");
this.passiveIcon = iconRegister.registerIcon("AlchemicalWizardry:HarvestGoddessSigil_deactivated");
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (stack.stackTagCompound == null)
{
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = stack.stackTagCompound;
if (tag.getBoolean("isActive"))
{
return this.activeIcon;
} else
{
return this.passiveIcon;
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1)
{
if (par1 == 1)
{
return this.activeIcon;
} else
{
return this.passiveIcon;
}
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer);
if (par3EntityPlayer.isSneaking())
{
return par1ItemStack;
}
if (par1ItemStack.stackTagCompound == null)
{
par1ItemStack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = par1ItemStack.stackTagCompound;
tag.setBoolean("isActive", !(tag.getBoolean("isActive")));
if (tag.getBoolean("isActive"))
{
par1ItemStack.setItemDamage(1);
tag.setInteger("worldTimeDelay", (int) (par2World.getWorldTime() - 1) % 200);
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if (!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
tag.setBoolean("isActive", false);
}
}
} else
{
par1ItemStack.setItemDamage(par1ItemStack.getMaxDamage());
}
return par1ItemStack;
}
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
if (!(par3Entity instanceof EntityPlayer) || par2World.isRemote)
{
return;
}
EntityPlayer par3EntityPlayer = (EntityPlayer) par3Entity;
if (par1ItemStack.stackTagCompound == null)
{
par1ItemStack.setTagCompound(new NBTTagCompound());
}
if (par1ItemStack.stackTagCompound.getBoolean("isActive"))
{
int range = 3;
int verticalRange = 1;
int posX = (int) Math.round(par3Entity.posX - 0.5f);
int posY = (int) par3Entity.posY;
int posZ = (int) Math.round(par3Entity.posZ - 0.5f);
for (int ix = posX - range; ix <= posX + range; ix++)
{
for (int iz = posZ - range; iz <= posZ + range; iz++)
{
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
{
HarvestRegistry.harvestBlock(par2World, ix, iy, iz);
}
}
}
}
if (par2World.getWorldTime() % 200 == par1ItemStack.stackTagCompound.getInteger("worldTimeDelay") && par1ItemStack.stackTagCompound.getBoolean("isActive"))
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
{
if(!EnergyItems.syphonBatteries(par1ItemStack, par3EntityPlayer, getEnergyUsed()))
{
par1ItemStack.stackTagCompound.setBoolean("isActive", false);
}
}
}
return;
}
@Override
public void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack)
{
int range = 3;
int verticalRange = 1;
int posX = (int) Math.round(player.posX - 0.5f);
int posY = (int) player.posY;
int posZ = (int) Math.round(player.posZ - 0.5f);
for (int ix = posX - range; ix <= posX + range; ix++)
{
for (int iz = posZ - range; iz <= posZ + range; iz++)
{
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
{
HarvestRegistry.harvestBlock(world, ix, iy, iz);
}
}
}
}
@Override
public boolean isUpgrade()
{
return true;
}
@Override
public int getEnergyForTenSeconds()
{
return 500;
}
}