Search in sources :

Example 71 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class GCPlayerHandler method onPlayerCloned.

// @SubscribeEvent
// public void onPlayerLogout(PlayerLoggedOutEvent event)
// {
// if (event.player instanceof EntityPlayerMP)
// {
// this.onPlayerLogout((EntityPlayerMP) event.player);
// }
// }
// 
// @SubscribeEvent
// public void onPlayerRespawn(PlayerRespawnEvent event)
// {
// if (event.player instanceof EntityPlayerMP)
// {
// this.onPlayerRespawn((EntityPlayerMP) event.player);
// }
// }
@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone event) {
    GCPlayerStats oldStats = GCPlayerStats.get(event.getOriginal());
    GCPlayerStats newStats = GCPlayerStats.get(event.getEntityPlayer());
    newStats.copyFrom(oldStats, !event.isWasDeath() || event.getOriginal().world.getGameRules().getBoolean("keepInventory"));
    if (event.getOriginal() instanceof EntityPlayerMP && event.getEntityPlayer() instanceof EntityPlayerMP) {
        TileEntityTelemetry.updateLinkedPlayer((EntityPlayerMP) event.getOriginal(), (EntityPlayerMP) event.getEntityPlayer());
    }
    if (event.isWasDeath() && event.getOriginal() instanceof EntityPlayerMP) {
        UUID uu = event.getOriginal().getPersistentID();
        if (event.getOriginal().world.provider instanceof IGalacticraftWorldProvider) {
            Integer timeA = deathTimes.get(uu);
            int bb = ((EntityPlayerMP) event.getOriginal()).mcServer.getTickCounter();
            if (timeA != null && (bb - timeA) < 1500) {
                String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.help.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.help.2");
                event.getOriginal().sendMessage(new TextComponentString(msg));
            }
            deathTimes.put(uu, bb);
        } else {
            deathTimes.remove(uu);
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) UUID(java.util.UUID) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 72 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class GCPlayerHandler method onPlayerLogin.

// @SubscribeEvent
// public void onEntityConstructing(EntityEvent.EntityConstructing event)
// {
// if (event.getEntity() instanceof EntityPlayerMP && GCPlayerStats.get((EntityPlayerMP) event.getEntity()) == null)
// {
// GCPlayerStats.register((EntityPlayerMP) event.getEntity());
// }
// 
// if (event.entity instanceof EntityPlayer && event.entity.world.isRemote)
// {
// this.onEntityConstructingClient(event);
// }
// }
// 
// @SideOnly(Side.CLIENT)
// public void onEntityConstructingClient(EntityEvent.EntityConstructing event)
// {
// if (event.getEntity() instanceof EntityPlayerSP)
// {
// if (GCPlayerStatsClient.get((EntityPlayerSP) event.getEntity()) == null)
// {
// GCPlayerStatsClient.register((EntityPlayerSP) event.getEntity());
// }
// 
// Minecraft.getMinecraft().gameSettings.sendSettingsToServer();
// }
// }
private void onPlayerLogin(EntityPlayerMP player) {
    // GCPlayerStats oldData = this.playerStatsMap.remove(player.getPersistentID());
    // if (oldData != null)
    // {
    // oldData.saveNBTData(player.getEntityData());
    // }
    GCPlayerStats stats = GCPlayerStats.get(player);
    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_GET_CELESTIAL_BODY_LIST, GCCoreUtil.getDimensionID(player.world), new Object[] {}), player);
    int repeatCount = stats.getBuildFlags() >> 9;
    if (repeatCount < 3) {
        stats.setBuildFlags(stats.getBuildFlags() & 1536);
    }
    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_STATS, GCCoreUtil.getDimensionID(player.world), stats.getMiscNetworkedStats()), player);
    ColorUtil.sendUpdatedColorsToPlayer(stats);
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint)

Example 73 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class GCPlayerHandler method checkShield.

protected void checkShield(EntityPlayerMP playerMP, GCPlayerStats playerStats) {
    if (playerMP.ticksExisted % 20 == 0 && playerMP.world.provider instanceof IGalacticraftWorldProvider) {
        if (((IGalacticraftWorldProvider) playerMP.world.provider).shouldCorrodeArmor()) {
            ItemStack shieldController = playerStats.getExtendedInventory().getStackInSlot(10);
            boolean valid = false;
            if (!shieldController.isEmpty()) {
                int gearID = GalacticraftRegistry.findMatchingGearID(shieldController, EnumExtendedInventorySlot.SHIELD_CONTROLLER);
                if (gearID != -1) {
                    valid = true;
                }
            }
            if (!valid) {
                for (ItemStack armor : playerMP.getArmorInventoryList()) {
                    if (!armor.isEmpty() && armor.getItem() instanceof ItemArmor && !(armor.getItem() instanceof IArmorCorrosionResistant)) {
                        armor.damageItem(1, playerMP);
                    }
                }
            }
        }
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) ItemArmor(net.minecraft.item.ItemArmor) ItemStack(net.minecraft.item.ItemStack) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IArmorCorrosionResistant(micdoodle8.mods.galacticraft.api.item.IArmorCorrosionResistant)

Example 74 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class GCPlayerHandler method setUsingParachute.

public static void setUsingParachute(EntityPlayerMP player, GCPlayerStats playerStats, boolean tf) {
    playerStats.setUsingParachute(tf);
    if (tf) {
        int subtype = GCPlayerHandler.GEAR_NOT_PRESENT;
        if (!playerStats.getParachuteInSlot().isEmpty()) {
            subtype = playerStats.getParachuteInSlot().getItemDamage();
        }
        GCPlayerHandler.sendGearUpdatePacket(player, EnumModelPacketType.ADD, EnumExtendedInventorySlot.PARACHUTE, subtype);
    } else {
        GCPlayerHandler.sendGearUpdatePacket(player, EnumModelPacketType.REMOVE, EnumExtendedInventorySlot.PARACHUTE);
    }
}
Also used : TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint)

Example 75 with GCPlayerStats

use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.

the class TeleportTypeVenus method onSpaceDimensionChanged.

@Override
public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) {
    if (!ridingAutoRocket && player != null) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        if (stats.getTeleportCooldown() <= 0) {
            if (player.capabilities.isFlying) {
                player.capabilities.isFlying = false;
            }
            if (!newWorld.isRemote) {
                EntityEntryPodVenus entryPod = new EntityEntryPodVenus(player);
                boolean previous = CompatibilityManager.forceLoadChunks((WorldServer) newWorld);
                entryPod.forceSpawn = true;
                newWorld.spawnEntity(entryPod);
                CompatibilityManager.forceLoadChunksEnd((WorldServer) newWorld, previous);
            }
            stats.setTeleportCooldown(10);
        }
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityEntryPodVenus(micdoodle8.mods.galacticraft.planets.venus.entities.EntityEntryPodVenus)

Aggregations

GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)88 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)55 ItemStack (net.minecraft.item.ItemStack)43 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)19 CommandException (net.minecraft.command.CommandException)16 WrongUsageException (net.minecraft.command.WrongUsageException)16 TextComponentString (net.minecraft.util.text.TextComponentString)16 TargetPoint (net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)14 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)12 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)12 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)12 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)10 TileEntity (net.minecraft.tileentity.TileEntity)10 BlockPos (net.minecraft.util.math.BlockPos)10 WorldServer (net.minecraft.world.WorldServer)10 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)8 Entity (net.minecraft.entity.Entity)7 PotionEffect (net.minecraft.potion.PotionEffect)7 ChatComponentText (net.minecraft.util.ChatComponentText)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6