use of uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class EntityEvents method onLivingDrops.
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
for (int i = 0; i < entityDrops.size(); i++) {
if (entityDrops.get(i).getDroppedFrom().isInstance(event.getEntity())) {
addEntityDrop(event, entityDrops.get(i));
}
}
// Remove any summoned keyblades or org weapons on death
if (event.getEntity() instanceof EntityPlayer) {
for (int i = 0; i < event.getDrops().size(); i++) {
if (event.getDrops().get(i).getItem().getItem() instanceof ItemKeyblade && (event.getDrops().get(i).getItem().getItem() != ModItems.WoodenKeyblade && event.getDrops().get(i).getItem().getItem() != ModItems.WoodenStick)) {
event.getDrops().remove(i);
event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
i = 0;
}
if (event.getDrops().get(i).getItem().getItem() == event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
event.getDrops().remove(i);
event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(((EntityPlayer) event.getEntity()).getActiveHand(), false);
i = 0;
}
}
}
if (!MainConfig.entities.disableDrops) {
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
if (event.getEntity() instanceof EntityMob)
if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
dropRecipe(event);
}
}
if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
if (event.getEntity() instanceof EntityMob)
if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
dropRecipe(event);
}
}
if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemRealKeyblade) {
if (event.getEntity() instanceof EntityAnimal) {
if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
} else if (event.getEntity() instanceof EntityMob) {
if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart")) {
if (!(event.getEntityLiving() instanceof IKHMob && ((IKHMob) event.getEntityLiving()).getType() == MobType.HEARTLESS_PUREBLOOD))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
}
if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
int rand;
rand = Utils.randomWithRange(1, 30);
if (rand == 1)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
else if (rand == 5)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
else if (rand == 9)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
else if (rand == 13)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
else if (rand == 17) {
// event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
} else if (rand == 21)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
else if (rand == 25)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
}
} else if (event.getEntity() instanceof EntityAgeable)
if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
}
}
}
if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
if (player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof ItemRealKeyblade) {
if (event.getEntity() instanceof EntityAnimal)
if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
else if (event.getEntity() instanceof EntityMob) {
if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
int rand;
rand = Utils.randomWithRange(1, 30);
if (rand == 1)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
else if (rand == 5)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
else if (rand == 9)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
else if (rand == 13)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
else if (rand == 17) {
// event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
} else if (rand == 21)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
else if (rand == 25)
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
}
} else if (event.getEntity() instanceof EntityAgeable)
if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
}
}
}
ItemStack munny = new ItemStack(ModItems.Munny, 1);
munny.setTagCompound(new NBTTagCompound());
ItemStack driveOrb = new ItemStack(ModItems.DriveOrb, 1);
driveOrb.setTagCompound(new NBTTagCompound());
ItemStack magicOrb = new ItemStack(ModItems.MagicOrb, 1);
magicOrb.setTagCompound(new NBTTagCompound());
ItemStack HPOrb = new ItemStack(ModItems.HpOrb, 1);
if (event.getEntity() instanceof EntityAnimal) {
munny.getTagCompound().setInteger("amount", Utils.randomWithRange(1, 20));
if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
event.getEntityLiving().entityDropItem(munny, 1);
driveOrb.getTagCompound().setInteger("amount", 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
event.getEntityLiving().entityDropItem(driveOrb, 1);
magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(2, 8));
if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
event.getEntityLiving().entityDropItem(magicOrb, 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
event.getEntityLiving().entityDropItem(HPOrb, 1);
} else if (event.getEntity() instanceof EntityMob) {
munny.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 50));
if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
event.getEntityLiving().entityDropItem(munny, 1);
driveOrb.getTagCompound().setInteger("amount", 5);
if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
event.getEntityLiving().entityDropItem(driveOrb, 1);
magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 15));
if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
event.getEntityLiving().entityDropItem(magicOrb, 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
event.getEntityLiving().entityDropItem(HPOrb, 1);
} else if (event.getEntity() instanceof EntityAgeable) {
munny.getTagCompound().setInteger("amount", Utils.randomWithRange(50, 100));
if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
event.getEntityLiving().entityDropItem(munny, 1);
driveOrb.getTagCompound().setInteger("amount", 5);
if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
event.getEntityLiving().entityDropItem(driveOrb, 1);
magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(10, 25));
if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
event.getEntityLiving().entityDropItem(magicOrb, 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
event.getEntityLiving().entityDropItem(HPOrb, 1);
} else if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
munny.getTagCompound().setInteger("amount", Utils.randomWithRange(500, 1000));
if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
event.getEntityLiving().entityDropItem(munny, 1);
driveOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(200, 250));
if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
event.getEntityLiving().entityDropItem(driveOrb, 1);
magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(100, 140));
if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
event.getEntityLiving().entityDropItem(magicOrb, 1);
if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
event.getEntityLiving().entityDropItem(HPOrb, 1);
}
}
}
}
use of uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class EntityEvents method onLivingDeathEvent.
@SubscribeEvent
public void onLivingDeathEvent(LivingDeathEvent event) {
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
SummonKeybladeCapability.ISummonKeyblade SUMMON = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
IOrganizationXIII ORG = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
if (SUMMON.getIsKeybladeSummoned(EnumHand.MAIN_HAND)) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
PacketDispatcher.sendToServer(new DeSummonKeyblade());
PacketDispatcher.sendTo(new SyncKeybladeData(SUMMON), (EntityPlayerMP) player);
} else {
SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (player.inventory.getStackInSlot(i).getItem() instanceof ItemRealKeyblade) {
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
}
} else if (ORG.summonedWeapon(EnumHand.MAIN_HAND)) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
PacketDispatcher.sendToServer(new DeSummonOrgWeapon());
PacketDispatcher.sendTo(new SyncOrgXIIIData(ORG), (EntityPlayerMP) player);
} else {
SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (player.inventory.getStackInSlot(i).getItem() instanceof IOrgWeapon) {
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
}
}
}
if (event.getEntity() instanceof EntityDragon) {
WorldSavedDataKingdomKeys.get(DimensionManager.getWorld(DimensionType.OVERWORLD.getId())).setSpawnHeartless(true);
}
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityMob)
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
EntityMob mob = (EntityMob) event.getEntity();
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, (int) (mob.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getAttributeValue() / 2));
if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).enderDragonDefeated()) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
TextComponentTranslation driMessage = new TextComponentTranslation(Strings.Chat_DriveBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel()));
driMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(driMessage);
player.getCapability(ModCapabilities.PLAYER_STATS, null).setEnderDragonDefeated(true);
}
if (event.getEntity() instanceof EntityDragon) {
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 2000);
}
if (event.getEntity() instanceof EntityWither) {
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 1500);
}
PacketDispatcher.sendTo(new SyncLevelData(player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
}
use of uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class Utils method summonWeapon.
/**
* Summon a weapon in a player's hand
* @param player
* @param hand
* @param keychainSlot
* @return
*/
public static boolean summonWeapon(EntityPlayer player, EnumHand hand, int keychainSlot) {
SummonKeybladeCapability.ISummonKeyblade summonCap = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
OrganizationXIIICapability.IOrganizationXIII organizationXIIICap = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
if (organizationXIIICap.getMember() == Utils.OrgMember.NONE) {
if (ItemStack.areItemStacksEqual(summonCap.getInventoryKeychain().getStackInSlot(keychainSlot), ItemStack.EMPTY)) {
player.sendMessage(new TextComponentTranslation(TextFormatting.RED + "Missing keychain to summon"));
return false;
}
if (!summonCap.getIsKeybladeSummoned(hand) && ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && summonCap.getInventoryKeychain().getStackInSlot(0).getItem() instanceof ItemKeychain) {
summonCap.setActiveSlot(player.inventory.currentItem);
ItemStack keychain = summonCap.getInventoryKeychain().getStackInSlot(keychainSlot);
ItemStack keyblade = new ItemStack(((ItemKeychain) (keychain.getItem())).getKeyblade());
if (hand == EnumHand.MAIN_HAND) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, keyblade);
} else {
player.inventory.offHandInventory.set(0, keyblade);
}
if (player.world.isRemote)
PacketDispatcher.sendToServer(new SummonKeyblade(hand, keychainSlot));
return true;
} else if (!ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof ItemRealKeyblade && summonCap.getIsKeybladeSummoned(hand)) {
if (player.world.isRemote)
PacketDispatcher.sendToServer(new DeSummonKeyblade(hand));
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
player.inventory.offHandInventory.set(0, ItemStack.EMPTY);
return true;
} else {
return false;
}
} else {
if (!organizationXIIICap.summonedWeapon(hand) && ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY)) {
if (player.world.isRemote)
PacketDispatcher.sendToServer(new SummonOrgWeapon(hand, organizationXIIICap.currentWeapon()));
if (hand == EnumHand.MAIN_HAND)
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(organizationXIIICap.currentWeapon()));
else
player.inventory.offHandInventory.set(0, new ItemStack(organizationXIIICap.currentWeapon()));
organizationXIIICap.setWeaponSummoned(hand, true);
return true;
} else if (!ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof IOrgWeapon || (organizationXIIICap.getMember() == Utils.OrgMember.ROXAS && !ItemStack.areItemStacksEqual(player.getHeldItem(hand), ItemStack.EMPTY) && player.getHeldItem(hand).getItem() instanceof ItemKeyblade)) {
if (player.world.isRemote) {
PacketDispatcher.sendToServer(new DeSummonOrgWeapon(hand));
}
organizationXIIICap.setWeaponSummoned(hand, false);
if (hand == EnumHand.MAIN_HAND)
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
else
player.inventory.offHandInventory.set(0, ItemStack.EMPTY);
return true;
} else {
return false;
}
}
}
Aggregations