use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class CreateFromSynthesisRecipe method process.
@Override
public void process(EntityPlayer player, Side side) {
boolean freeDev = false;
if (FreeDevRecipeRegistry.isFreeDevRecipeRegistered(name)) {
freeDev = true;
}
if (!freeDev) {
if (RecipeRegistry.get(name).getResult().getItem() instanceof ItemKeychain)
player.inventory.addItemStackToInventory(RecipeRegistry.get(name).getResult());
Recipe r = RecipeRegistry.get(name);
SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
Iterator it = r.getRequirements().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
MATS.removeMaterial(pair.getKey(), pair.getValue());
}
} else {
player.inventory.addItemStackToInventory(FreeDevRecipeRegistry.get(name).getResult());
Recipe r = FreeDevRecipeRegistry.get(name);
SynthesisMaterialCapability.ISynthesisMaterial MATS = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
Iterator it = r.getRequirements().entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Material, Integer> pair = (Map.Entry<Material, Integer>) it.next();
MATS.removeMaterial(pair.getKey(), pair.getValue());
}
}
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class DepositMaterialsFromBag method removeMaterial.
public void removeMaterial(IItemHandler bag, EntityPlayer player, int i) {
for (int j = 0; j < bag.getSlots(); j++) {
ItemStack bagItem = bag.getStackInSlot(j);
if (!ItemStack.areItemStacksEqual(bagItem, ItemStack.EMPTY)) {
if (bagItem.hasTagCompound()) {
String s = bagItem.getTagCompound().getString("material");
if (MaterialRegistry.isMaterialRegistered(s)) {
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), bag.getStackInSlot(j).getCount());
}
bag.extractItem(j, bag.getStackInSlot(j).getCount(), false);
}
} else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName())) {
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName()), player.inventory.mainInventory.get(i).getCount());
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
}
use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class OpenMaterials method process.
@Override
public void process(EntityPlayer player, Side side) {
for (int i = 0; i < 36; i++) {
if (!ItemStack.areItemStacksEqual(player.inventory.mainInventory.get(i), ItemStack.EMPTY)) {
if (player.inventory.mainInventory.get(i).getItem() instanceof ItemSynthesisMaterial) {
if (player.inventory.mainInventory.get(i).hasTagCompound()) {
String s = player.inventory.mainInventory.get(i).getTagCompound().getString("material");
if (MaterialRegistry.isMaterialRegistered(s)) {
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), player.inventory.mainInventory.get(i).getCount());
}
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
} else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName().toString())) {
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory.get(i).getItem().getUnlocalizedName()), player.inventory.mainInventory.get(i).getCount());
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
}
/*for (int i = 0; i < 36; i++)
if (player.inventory.mainInventory[i] != null) if (player.inventory.mainInventory[i].getItem() instanceof ItemSynthesisMaterial) {
if (player.inventory.mainInventory[i].hasTagCompound()) {
String s = player.inventory.mainInventory[i].getTagCompound().getString("material");
if (MaterialRegistry.isMaterialRegistered(s)) player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(s), player.inventory.mainInventory[i].stackSize);
player.inventory.setInventorySlotContents(i, null);
}
} else if (MaterialRegistry.isMaterialRegistered(player.inventory.mainInventory[i].getItem().getUnlocalizedName().toString())) {
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).addMaterial(MaterialRegistry.get(player.inventory.mainInventory[i].getItem().getUnlocalizedName()), player.inventory.mainInventory[i].stackSize);
player.inventory.setInventorySlotContents(i, null);
}
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
*/
}
use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class SyncMaterialData method process.
@Override
public void process(EntityPlayer player, Side side) {
final ISynthesisMaterial material = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null);
Iterator<Entry<String, Integer>> it = materials.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Integer> pair = (Map.Entry<String, Integer>) it.next();
material.setMaterial(MaterialRegistry.get(pair.getKey().toString()), pair.getValue());
}
}
use of uk.co.wehavecookies56.kk.api.materials.Material in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class TakeMaterials method process.
@Override
public void process(EntityPlayer player, Side side) {
if (amount > player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).getMaterialAmount(MaterialRegistry.get(materialName)))
amount = player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).getMaterialAmount(MaterialRegistry.get(materialName));
if (materialName.startsWith("sm.")) {
ItemStack material = new ItemStack(ModItems.SynthesisMaterial, amount);
material.setTagCompound(new NBTTagCompound());
material.getTagCompound().setString("material", materialName);
if (materialName.endsWith("shard"))
material.getTagCompound().setString("rank", "sm.rank.c");
else if (materialName.endsWith("stone"))
material.getTagCompound().setString("rank", "sm.rank.b");
else if (materialName.endsWith("gem") || materialName.equals(Strings.SM_ManifestIllusion) || materialName.equals(Strings.SM_Orichalcum))
material.getTagCompound().setString("rank", "sm.rank.a");
else if (materialName.endsWith("crystal") || materialName.equals(Strings.SM_LostIllusion) || materialName.equals(Strings.SM_OrichalcumPlus))
material.getTagCompound().setString("rank", "sm.rank.s");
player.inventory.addItemStackToInventory(material);
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).removeMaterial(MaterialRegistry.get(materialName), amount);
} else if (materialName.startsWith("item.")) {
if (ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, materialName.replace("item.", ""))) != null) {
player.inventory.addItemStackToInventory(new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(Reference.MODID, materialName.replace("item.", ""))), amount));
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).removeMaterial(MaterialRegistry.get(materialName), amount);
} else {
// VANILLA ITEMS HERE
if (materialName.equals(Items.WOODEN_SWORD.getUnlocalizedName())) {
player.inventory.addItemStackToInventory(new ItemStack(Items.WOODEN_SWORD, amount));
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).removeMaterial(MaterialRegistry.get(materialName), amount);
}
if (materialName.equals(Items.STICK.getUnlocalizedName())) {
player.inventory.addItemStackToInventory(new ItemStack(Items.STICK, amount));
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).removeMaterial(MaterialRegistry.get(materialName), amount);
}
}
} else if (materialName.startsWith("tile."))
if (ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Reference.MODID, materialName.replace("tile.", ""))) != null) {
player.inventory.addItemStackToInventory(new ItemStack(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Reference.MODID, materialName.replace("tile.", ""))), amount));
player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null).removeMaterial(MaterialRegistry.get(materialName), amount);
} else {
// VANILLA BLOCKS HERE
}
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
Aggregations