use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class OpenSynthesis method process.
@Override
public void process(EntityPlayer player, Side side) {
PacketDispatcher.sendTo(new SyncMunnyData(player.getCapability(ModCapabilities.MUNNY, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncFreeDevRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMaterialData 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.common.network.packet.client.SyncMaterialData 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.common.network.packet.client.SyncMaterialData 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.common.network.packet.client.SyncMaterialData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class BlockSynthesisTable method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, ModSounds.kupo, SoundCategory.BLOCKS, 0.5F, 1.0F);
if (world.isRemote)
PacketDispatcher.sendToServer(new OpenSynthesis());
player.openGui(KingdomKeys.instance, GuiIDs.GUI_SYNTHESISTABLE, world, pos.getX(), pos.getY(), pos.getZ());
if (!world.isRemote) {
PacketDispatcher.sendTo(new SyncRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncFreeDevRecipeData(player.getCapability(ModCapabilities.SYNTHESIS_RECIPES, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncMaterialData(player.getCapability(ModCapabilities.SYNTHESIS_MATERIALS, null)), (EntityPlayerMP) player);
}
return true;
}
Aggregations