Search in sources :

Example 1 with OpenOrgGUI

use of uk.co.wehavecookies56.kk.common.network.packet.client.OpenOrgGUI in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class EntityEvents method onPlayerTick.

@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() == Utils.OrgMember.NONE) {
        if (!ItemStack.areItemStacksEqual(player.inventory.armorInventory.get(0), ItemStack.EMPTY) && player.inventory.armorInventory.get(1) != ItemStack.EMPTY && player.inventory.armorInventory.get(2) != ItemStack.EMPTY && player.inventory.armorInventory.get(3) != ItemStack.EMPTY) {
            boolean isWearingOrgArmor = player.inventory.armorInventory.get(0).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(1).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(2).getItem() instanceof ItemOrganizationRobe && player.inventory.armorInventory.get(3).getItem() instanceof ItemOrganizationRobe;
            // boolean isWearingXemnasArmor = player.inventory.armorInventory.get(0).getItem() == ModItems.Xemnas_Boots && player.inventory.armorInventory.get(1).getItem() == ModItems.Xemnas_Leggings && player.inventory.armorInventory.get(2).getItem() == ModItems.Xemnas_Chestplate && player.inventory.armorInventory.get(3).getItem() == ModItems.Xemnas_Helmet;
            if (isWearingOrgArmor) {
                if (!player.world.isRemote) {
                    if (!player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getOpenedGUI()) {
                        player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setOpenedGUI(true);
                        PacketDispatcher.sendTo(new OpenOrgGUI(), (EntityPlayerMP) player);
                    }
                }
            }
        } else {
            if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() == Utils.OrgMember.NONE)
                player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setOpenedGUI(false);
        }
    }
    if (player.getCapability(ModCapabilities.Xemnas, null).getMember() == Utils.OrgMember.NONE) {
        if (!ItemStack.areItemStacksEqual(player.inventory.armorInventory.get(0), ItemStack.EMPTY) && player.inventory.armorInventory.get(1) != ItemStack.EMPTY && player.inventory.armorInventory.get(2) != ItemStack.EMPTY && player.inventory.armorInventory.get(3) != ItemStack.EMPTY) {
            boolean isWearingXemnasArmor = player.inventory.armorInventory.get(0).getItem() == ModItems.Xemnas_Boots && player.inventory.armorInventory.get(1).getItem() == ModItems.Xemnas_Leggings && player.inventory.armorInventory.get(2).getItem() == ModItems.Xemnas_Chestplate && player.inventory.armorInventory.get(3).getItem() == ModItems.Xemnas_Helmet;
            if (isWearingXemnasArmor) {
                if (!player.world.isRemote) {
                    if (!player.getCapability(ModCapabilities.Xemnas, null).getOpenedGUI()) {
                        player.getCapability(ModCapabilities.Xemnas, null).setOpenedGUI(true);
                        PacketDispatcher.sendTo(new OpenOrgGUI(), (EntityPlayerMP) player);
                    }
                }
            }
        } else {
            if (player.getCapability(ModCapabilities.Xemnas, null).getMember() == Utils.OrgMember.NONE)
                player.getCapability(ModCapabilities.Xemnas, null).setOpenedGUI(false);
        }
    }
    // Choices
    IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
    if (!event.player.world.isRemote) {
        if (player.dimension == ModDimensions.diveToTheHeartID) {
            if (player.getPosition().getX() == -13 && player.getPosition().getZ() == -1 && player.getPosition().getY() == 66) {
                if (!STATS.getChoice1().equals(Strings.Choice_Shield)) {
                    STATS.setChoice1(Strings.Choice_Shield);
                    TextComponentTranslation shield = new TextComponentTranslation("Shield");
                    shield.getStyle().setColor(TextFormatting.YELLOW);
                    player.sendMessage(shield);
                }
            } else if (player.getPosition().getX() == 11 && player.getPosition().getZ() == -1 && player.getPosition().getY() == 66) {
                if (!STATS.getChoice1().equals(Strings.Choice_Staff)) {
                    STATS.setChoice1(Strings.Choice_Staff);
                    TextComponentTranslation staff = new TextComponentTranslation("Staff");
                    staff.getStyle().setColor(TextFormatting.YELLOW);
                    player.sendMessage(staff);
                }
            } else if (player.getPosition().getX() == -1 && player.getPosition().getZ() == -13 && player.getPosition().getY() == 66) {
                if (!STATS.getChoice1().equals(Strings.Choice_Sword)) {
                    STATS.setChoice1(Strings.Choice_Sword);
                    TextComponentTranslation sword = new TextComponentTranslation("Sword");
                    sword.getStyle().setColor(TextFormatting.YELLOW);
                    player.sendMessage(sword);
                }
            } else if (player.getPosition().getX() == -1 && player.getPosition().getZ() == +10 && player.getPosition().getY() == 65) {
                if (((EntityPlayer) player).dimension == ModDimensions.diveToTheHeartID) {
                    if (!STATS.getChoice1().equals("") && !STATS.getChoice1().equals("door")) {
                        // if (!player.world.isRemote) {
                        switch(STATS.getChoice1()) {
                            case Strings.Choice_Shield:
                                STATS.addDefense(2);
                                break;
                            case Strings.Choice_Staff:
                                STATS.addMagic(2);
                                break;
                            case Strings.Choice_Sword:
                                STATS.addStrength(2);
                                break;
                        }
                        PacketDispatcher.sendTo(new SyncLevelData(STATS), (EntityPlayerMP) player);
                        new TeleporterOverworld(event.player.world.getMinecraftServer().getServer().getWorld(0)).teleport((player), player.world);
                    // }
                    } else {
                        if (!STATS.getChoice1().equals("door")) {
                            TextComponentTranslation needChoice = new TextComponentTranslation("You must make a choice");
                            needChoice.getStyle().setColor(TextFormatting.RED);
                            player.sendMessage(needChoice);
                            STATS.setChoice1("door");
                        }
                    }
                }
            }
        } else if (player.dimension == ModDimensions.traverseTownID) {
            if (player.getPosition().getX() == 193 && player.getPosition().getZ() == 161 && player.getPosition().getY() == 6) {
                new TeleporterOverworld(event.player.world.getMinecraftServer().getServer().getWorld(0)).teleport((player), player.world);
            }
        }
    }
    DriveStateCapability.IDriveState DS = event.player.getCapability(ModCapabilities.DRIVE_STATE, null);
    if (!DS.getInDrive())
        if (STATS.getMP() <= 0 || STATS.getRecharge()) {
            STATS.setRecharge(true);
            if (STATS.getMP() != STATS.getMaxMP()) {
                STATS.addMP(0.1);
                if (STATS.getMP() > STATS.getMaxMP())
                    STATS.setMP(STATS.getMaxMP());
            } else {
                STATS.setMP(STATS.getMaxMP());
                STATS.setRecharge(false);
                if (event.side.isServer()) {
                    PacketDispatcher.sendTo(new SyncMagicData(event.player.getCapability(ModCapabilities.MAGIC_STATE, null), event.player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) event.player);
                }
            }
        }
    if (!DS.getActiveDriveName().equals("none") && DriveFormRegistry.isDriveFormRegistered(DS.getActiveDriveName())) {
        DriveFormRegistry.get(DS.getActiveDriveName()).update(event.player);
    }
    List<Entity> entities = event.player.world.getEntitiesWithinAABBExcludingEntity(event.player, event.player.getEntityBoundingBox().grow(16.0D, 10.0D, 16.0D).offset(-8.0D, -5.0D, -8.0D));
    List<Entity> bossEntities = event.player.world.getEntitiesWithinAABBExcludingEntity(event.player, event.player.getEntityBoundingBox().grow(150.0D, 100.0D, 150.0D).offset(-75.0D, -50.0D, -75.0D));
    if (!bossEntities.isEmpty()) {
        for (int i = 0; i < bossEntities.size(); i++) {
            if (bossEntities.get(i) instanceof EntityDragon || bossEntities.get(i) instanceof EntityWither) {
                isBoss = true;
                break;
            } else {
                isBoss = false;
            }
        }
    } else {
        isBoss = false;
    }
    if (!entities.isEmpty()) {
        for (int i = 0; i < entities.size(); i++) {
            if (entities.get(i) instanceof EntityMob) {
                isHostiles = true;
                break;
            } else {
                isHostiles = false;
            }
        }
    } else {
        isHostiles = false;
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityDragon(net.minecraft.entity.boss.EntityDragon) OpenOrgGUI(uk.co.wehavecookies56.kk.common.network.packet.client.OpenOrgGUI) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) TeleporterOverworld(uk.co.wehavecookies56.kk.common.world.dimension.TeleporterOverworld) SyncLevelData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData) IPlayerStats(uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats) EntityMob(net.minecraft.entity.monster.EntityMob) DriveStateCapability(uk.co.wehavecookies56.kk.common.capability.DriveStateCapability) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemOrganizationRobe(uk.co.wehavecookies56.kk.common.item.ItemOrganizationRobe) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SyncMagicData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData) EntityWither(net.minecraft.entity.boss.EntityWither) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Entity (net.minecraft.entity.Entity)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 DriveStateCapability (uk.co.wehavecookies56.kk.common.capability.DriveStateCapability)1 IPlayerStats (uk.co.wehavecookies56.kk.common.capability.PlayerStatsCapability.IPlayerStats)1 ItemOrganizationRobe (uk.co.wehavecookies56.kk.common.item.ItemOrganizationRobe)1 OpenOrgGUI (uk.co.wehavecookies56.kk.common.network.packet.client.OpenOrgGUI)1 SyncLevelData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData)1 SyncMagicData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData)1 TeleporterOverworld (uk.co.wehavecookies56.kk.common.world.dimension.TeleporterOverworld)1