use of tonius.simplyjetpacks.item.ItemPack in project SimplyJetpacks by Tonius.
the class PlatingReturnHandler method onItemCrafted.
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent evt) {
if (evt.player.worldObj.isRemote || !(evt.crafting.getItem() instanceof ItemPack)) {
return;
}
PackBase outputPack = ((ItemPack) evt.crafting.getItem()).getPack(evt.crafting);
if (outputPack.isArmored) {
return;
}
for (int i = 0; i < evt.craftMatrix.getSizeInventory(); i++) {
ItemStack input = evt.craftMatrix.getStackInSlot(i);
if (input == null || !(input.getItem() instanceof ItemPack)) {
continue;
}
PackBase inputPack = ((ItemPack) input.getItem()).getPack(input);
if (inputPack != null && inputPack.isArmored && inputPack.platingMeta != null) {
EntityItem item = evt.player.entityDropItem(new ItemStack(ModItems.armorPlatings, 1, inputPack.platingMeta), 0.0F);
item.delayBeforeCanPickup = 0;
break;
}
}
}
use of tonius.simplyjetpacks.item.ItemPack in project SimplyJetpacks by Tonius.
the class UpgradingRecipe method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
int addedEnergy = 0;
ParticleType particleType = null;
NBTTagCompound tags = null;
boolean enderiumUpgrade = false;
ItemStack slotStack;
for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) {
slotStack = inventoryCrafting.getStackInSlot(i);
if (slotStack != null && slotStack.getItem() != null) {
if (slotStack.getItem() instanceof ItemPack) {
tags = (NBTTagCompound) NBTHelper.getNBT(slotStack).copy();
}
if (slotStack.getItem() instanceof IEnergyContainerItem) {
addedEnergy += ((IEnergyContainerItem) slotStack.getItem()).getEnergyStored(slotStack);
} else if (slotStack.getItem() == ModItems.particleCustomizers) {
particleType = ParticleType.values()[slotStack.getItemDamage()];
} else if (ModItems.enderiumUpgrade != null && slotStack.getItem() == ModItems.enderiumUpgrade.getItem() && slotStack.getItemDamage() == ModItems.enderiumUpgrade.getItemDamage()) {
enderiumUpgrade = true;
}
}
}
ItemStack result = new ItemStack((Item) this.resultItem, 1, this.resultMeta);
if (tags != null) {
result.setTagCompound(tags);
}
NBTHelper.getNBT(result).setInteger("Energy", Math.min(addedEnergy, this.resultItem.getMaxEnergyStored(result)));
if (this.resultItem instanceof ItemJetpack && particleType != null) {
((ItemJetpack) this.resultItem).getPack(result).setParticleType(result, particleType);
}
if (enderiumUpgrade && this.resultItem instanceof ItemPack) {
PackBase pack = ((ItemPack) this.resultItem).getPack(result);
if (pack instanceof JetPlate) {
((JetPlate) pack).setEnderiumUpgrade(result, true);
}
}
return result;
}
use of tonius.simplyjetpacks.item.ItemPack in project SimplyJetpacks by Tonius.
the class GuiHandler method getServerGuiElement.
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case PACK:
ItemStack chestplate = player.getCurrentArmor(2);
if (chestplate != null && chestplate.getItem() instanceof ItemPack) {
ItemPack packItem = (ItemPack) chestplate.getItem();
PackBase pack = packItem.getPack(chestplate);
if (pack != null) {
return new ContainerPack(chestplate, packItem, pack);
}
}
}
return null;
}
use of tonius.simplyjetpacks.item.ItemPack in project SimplyJetpacks by Tonius.
the class GuiHandler method getClientGuiElement.
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID) {
case PACK:
ItemStack chestplate = player.getCurrentArmor(2);
if (chestplate != null && chestplate.getItem() instanceof ItemPack) {
ItemPack packItem = (ItemPack) chestplate.getItem();
PackBase pack = packItem.getPack(chestplate);
if (pack != null) {
return new GuiPack(new ContainerPack(chestplate, packItem, pack));
}
}
}
return null;
}
Aggregations