Search in sources :

Example 11 with GCPlayerStats

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

the class ItemCanisterOxygenInfinite method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    if (player instanceof EntityPlayerMP) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        ItemStack gear = stats.getExtendedInventory().getStackInSlot(2);
        ItemStack gear1 = stats.getExtendedInventory().getStackInSlot(3);
        if (gear == null) {
            stats.getExtendedInventory().setInventorySlotContents(2, itemStack.copy());
            itemStack.stackSize = 0;
        } else if (gear1 == null) {
            stats.getExtendedInventory().setInventorySlotContents(3, itemStack.copy());
            itemStack.stackSize = 0;
        }
    }
    return itemStack;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 12 with GCPlayerStats

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

the class ItemBasic method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (par1ItemStack.getItemDamage() == 19) {
        if (par3EntityPlayer instanceof EntityPlayerMP) {
            GCPlayerStats stats = GCPlayerStats.get(par3EntityPlayer);
            ItemStack gear = stats.getExtendedInventory().getStackInSlot(5);
            if (gear == null && par1ItemStack.getTagCompound() == null) {
                stats.getExtendedInventory().setInventorySlotContents(5, par1ItemStack.copy());
                par1ItemStack.stackSize = 0;
            }
        }
    }
    return par1ItemStack;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 13 with GCPlayerStats

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

the class EntityAlienVillager method interact.

@Override
public boolean interact(EntityPlayer player) {
    ItemStack itemstack = player.inventory.getCurrentItem();
    boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg;
    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) {
        PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
        if (!this.worldObj.isRemote && (this.buyingList == null || this.buyingList.size() > 0)) {
            if (gearData != null && gearData.getFrequencyModule() != GCPlayerHandler.GEAR_NOT_PRESENT) {
                this.setCustomer(player);
                player.displayVillagerTradeGui(this);
            } else {
                if (player instanceof EntityPlayerMP) {
                    EntityPlayerMP playerMP = (EntityPlayerMP) player;
                    GCPlayerStats stats = GCPlayerStats.get(playerMP);
                    if (stats.getChatCooldown() == 0) {
                        player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.village.warning.no_freq_mod")));
                        stats.setChatCooldown(20);
                    }
                }
            }
        }
        player.triggerAchievement(StatList.timesTalkedToVillagerStat);
        return true;
    } else {
        return super.interact(player);
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) PlayerGearData(micdoodle8.mods.galacticraft.core.wrappers.PlayerGearData)

Example 14 with GCPlayerStats

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

the class PacketSimpleMP method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    EntityPlayerMP playerMP = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    GCPlayerStats stats = GCPlayerStats.get(playerMP);
    World world = player.world;
    TileEntity tile;
    String type;
    switch(this.type) {
        case S_BLACK_HOLE_STORAGE_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            type = (String) this.data.get(1);
            if (tile instanceof TileEntityBlackHoleStorage) {
                TileEntityBlackHoleStorage storage = (TileEntityBlackHoleStorage) tile;
                switch(type) {
                    case "disable":
                        storage.disableBlackHole = !storage.disableBlackHole;
                        break;
                    case "collect_mode":
                        storage.modeInt++;
                        storage.modeInt %= 3;
                        switch(storage.modeInt) {
                            case 0:
                                storage.collectMode = "item";
                                break;
                            case 1:
                                storage.collectMode = "xp";
                                break;
                            case 2:
                                storage.collectMode = "item_and_xp";
                                break;
                        }
                        break;
                    case "use_hopper":
                        storage.useHopper = !storage.useHopper;
                        break;
                }
            }
            break;
        case S_SHIELD_VISIBLE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.setBubbleVisible((boolean) this.data.get(1));
            }
            break;
        case S_ENABLE_SHIELD:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableShield = !shield.enableShield;
            }
            break;
        case S_ENABLE_SHIELD_DAMAGE:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                shield.enableDamage = !shield.enableDamage;
            }
            break;
        case S_SHIELD_GENERATOR_OPTION:
            tile = world.getTileEntity((BlockPos) this.data.get(0));
            int value = (int) this.data.get(1);
            type = (String) this.data.get(2);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                switch(type) {
                    case "damage":
                        shield.shieldDamage = value;
                        break;
                    case "size":
                        shield.maxShieldSize = value;
                        break;
                }
            }
            break;
        case S_SWITCH_SHIELD_GENERATOR_GUI:
            tile = player.world.getTileEntity((BlockPos) this.data.get(0));
            boolean isConfig = (boolean) this.data.get(1);
            if (tile instanceof TileEntityShieldGenerator) {
                TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                PacketSimpleMP.openShieldGeneratorConfig(playerMP, shield, isConfig);
            }
            break;
        case S_FAILED_UNLOCK_CHEST:
            if (stats.getChatCooldown() == 0) {
                player.sendMessage(new TextComponentString(LangUtils.translate("gui.valid_key.message", this.data.get(0))));
                stats.setChatCooldown(100);
            }
            break;
        case S_START_SURVIVAL_PLANET:
            if (WorldTickEventHandler.survivalPlanetData != null && !WorldTickEventHandler.survivalPlanetData.hasSurvivalPlanetData) {
                int sourceDimId = (int) this.data.get(0);
                String celestialName = (String) this.data.get(1);
                LoggerMP.info("Start survival planet at: {}, Dimension: {}", celestialName, WorldUtil.getProviderForNameServer(celestialName).getDimension());
                WorldTickEventHandler.survivalPlanetData.hasSurvivalPlanetData = true;
                WorldTickEventHandler.survivalPlanetData.survivalPlanetName = celestialName;
                WorldTickEventHandler.survivalPlanetData.setDirty(true);
                TeleportUtils.teleportPlayerToPlanet(playerMP, playerMP.getServer(), sourceDimId, WorldUtil.getProviderForNameServer(celestialName).getDimension());
            }
            break;
        case S_UPDATE_NIBIRU_WEATHER:
            int i = (300 + world.rand.nextInt(600)) * 20;
            boolean thunder = (boolean) this.data.get(0);
            WorldInfo worldinfo = playerMP.server.worlds[0].getWorldInfo();
            worldinfo.setCleanWeatherTime(0);
            worldinfo.setRainTime(i);
            worldinfo.setThunderTime(i);
            worldinfo.setRaining(true);
            worldinfo.setThundering(thunder);
            break;
        case S_SAVE_DISABLE_MESSAGE:
            if (WorldTickEventHandler.survivalPlanetData != null && !WorldTickEventHandler.survivalPlanetData.disableMessage) {
                WorldTickEventHandler.survivalPlanetData.disableMessage = true;
                WorldTickEventHandler.survivalPlanetData.setDirty(true);
            }
            break;
        case S_TRANSFER_PLAYER:
            int dimID = (int) this.data.get(0);
            playerMP.server.getPlayerList().transferPlayerToDimension(playerMP, dimID, new TeleporterSpaceNether(playerMP.server.getWorld(dimID), player.getPosition(), player.world.provider));
            GalacticraftCore.packetPipeline.sendTo(new PacketSimpleMP(EnumSimplePacketMP.C_RELOAD_RENDERER, player.dimension), playerMP);
            break;
        default:
            break;
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) TextComponentString(net.minecraft.util.text.TextComponentString) World(net.minecraft.world.World) TeleporterSpaceNether(stevekung.mods.moreplanets.utils.TeleporterSpaceNether) TileEntityBlackHoleStorage(stevekung.mods.moreplanets.tileentity.TileEntityBlackHoleStorage) TextComponentString(net.minecraft.util.text.TextComponentString) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityShieldGenerator(stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator) WorldInfo(net.minecraft.world.storage.WorldInfo) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 15 with GCPlayerStats

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

the class WorldProviderMP method setup.

@Override
public void setup(EntityPlayerMP player) {
    GCPlayerStats stats = GCPlayerStats.get(player);
    // Knows how to build T2 rocket
    SchematicRegistry.unlockNewPage(player, new ItemStack(GCItems.schematic, 1, 1));
    // Knows how to build T3 rocket
    SchematicRegistry.unlockNewPage(player, new ItemStack(MarsItems.schematic, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(0, new ItemStack(GCItems.oxMask, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(2, new ItemStack(GCItems.oxTankHeavy, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(3, new ItemStack(GCItems.oxTankHeavy, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
    stats.getExtendedInventory().setInventorySlotContents(6, new ItemStack(AsteroidsItems.thermalPadding, 1, 0));
    stats.getExtendedInventory().setInventorySlotContents(7, new ItemStack(AsteroidsItems.thermalPadding, 1, 1));
    stats.getExtendedInventory().setInventorySlotContents(8, new ItemStack(AsteroidsItems.thermalPadding, 1, 2));
    stats.getExtendedInventory().setInventorySlotContents(9, new ItemStack(AsteroidsItems.thermalPadding, 1, 3));
    player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
    player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
    player.inventory.addItemStackToInventory(new ItemStack(AsteroidsItems.canisterLOX));
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) ItemStack(net.minecraft.item.ItemStack)

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