use of uk.co.wehavecookies56.kk.common.network.packet.client.ShowOverlayPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method onItemTossEvent.
@SubscribeEvent
public void onItemTossEvent(ItemTossEvent event) {
if (!event.getPlayer().world.isRemote)
if (event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive() && !event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Anti)) {
event.setCanceled(true);
return;
}
if (event.getEntityItem().getItem().getItem() instanceof ItemKeyblade && (event.getEntityItem().getItem().getItem() != ModItems.WoodenKeyblade && event.getEntityItem().getItem().getItem() != ModItems.WoodenStick && event.getEntityItem().getItem().getItem() != ModItems.DreamSword && event.getEntityItem().getItem().getItem() != ModItems.DreamStaff)) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (!ItemStack.areItemStacksEqual(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0), ItemStack.EMPTY))
PacketDispatcher.sendTo(new SyncKeybladeData(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getPlayer());
} else if (event.getEntityItem().getItem().getItem() instanceof ItemMunny) {
event.setCanceled(true);
if (!event.getPlayer().world.isRemote) {
PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getEntityItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getPlayer());
event.getPlayer().getCapability(ModCapabilities.MUNNY, null).addMunny(event.getEntityItem().getItem().getTagCompound().getInteger("amount"));
}
}
if (event.getEntityItem().getItem().getItem() == event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(EnumHand.MAIN_HAND, false);
PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getPlayer());
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.ShowOverlayPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method onEntityItemPickUp.
@SubscribeEvent
public void onEntityItemPickUp(EntityItemPickupEvent event) {
IPlayerStats STATS = event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null);
IDriveState DRIVE = event.getEntityPlayer().getCapability(ModCapabilities.DRIVE_STATE, null);
if (event.getItem().getItem().getItem() instanceof ItemMunny) {
final MunnyCapability.IMunny munny = event.getEntityPlayer().getCapability(ModCapabilities.MUNNY, null);
MunnyPickup packet = new MunnyPickup(event.getItem().getItem());
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
munny.addMunny(event.getItem().getItem().getTagCompound().getInteger("amount"));
PacketDispatcher.sendTo(new SyncMunnyData(munny), (EntityPlayerMP) event.getEntityPlayer());
PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getEntityPlayer());
} else if (event.getItem().getItem().getItem() instanceof ItemHpOrb) {
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
return;
HpOrbPickup packet = new HpOrbPickup(event.getItem().getItem());
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (event.getEntityPlayer().getHealth() >= event.getEntityPlayer().getMaxHealth()) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
return;
}
if (event.getEntityPlayer().getHealth() < event.getEntityPlayer().getMaxHealth() - 1)
event.getEntityPlayer().heal(2);
else
event.getEntityPlayer().heal(1);
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
}
} else if (event.getItem().getItem().getItem() == ModItems.DriveOrb) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
DRIVE.addDP(event.getItem().getItem().getTagCompound().getInteger("amount"));
EntityPlayer player = event.getEntityPlayer();
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncDriveInventory(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) event.getEntityPlayer());
}
} else if (event.getItem().getItem().getItem() == ModItems.MagicOrb) {
double mp = STATS.getMP();
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND), ItemStack.EMPTY))
if (event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.EmptyBottle)
return;
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
event.getItem().getItem().setCount(event.getItem().getItem().getCount() - 1);
;
STATS.addMP(event.getItem().getItem().getTagCompound().getInteger("amount"));
PacketDispatcher.sendTo(new SyncMagicData(event.getEntityPlayer().getCapability(ModCapabilities.MAGIC_STATE, null), STATS), (EntityPlayerMP) event.getEntityPlayer());
}
} else if (event.getItem().getItem().getItem() instanceof ItemSynthesisMaterial) {
for (int i = 0; i < event.getEntityPlayer().inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(event.getEntityPlayer().inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagL) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
} else if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagM) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
}
if (event.getEntityPlayer().inventory.getStackInSlot(i).getItem() == ModItems.SynthesisBagS) {
IItemHandler inv = event.getEntityPlayer().inventory.getStackInSlot(i).getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
addSynthesisMaterialToBag(inv, event);
}
}
}
}
}
Aggregations