Search in sources :

Example 21 with GCPlayerStats

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

the class GCPlayerHandler method updateSchematics.

protected void updateSchematics(EntityPlayerMP player, GCPlayerStats stats) {
    SchematicRegistry.addUnlockedPage(player, SchematicRegistry.getMatchingRecipeForID(0));
    SchematicRegistry.addUnlockedPage(player, SchematicRegistry.getMatchingRecipeForID(Integer.MAX_VALUE));
    Collections.sort(stats.getUnlockedSchematics());
    if (player.connection != null && (stats.getUnlockedSchematics().size() != stats.getLastUnlockedSchematics().size() || (player.ticksExisted - 1) % 100 == 0)) {
        Integer[] iArray = new Integer[stats.getUnlockedSchematics().size()];
        for (int i = 0; i < iArray.length; i++) {
            ISchematicPage page = stats.getUnlockedSchematics().get(i);
            iArray[i] = page == null ? -2 : page.getPageID();
        }
        List<Object> objList = new ArrayList<Object>();
        objList.add(iArray);
        GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SCHEMATIC_LIST, GCCoreUtil.getDimensionID(player.world), objList), player);
    }
}
Also used : ArrayList(java.util.ArrayList) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)

Example 22 with GCPlayerStats

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

the class EntityAstroMiner method setDead.

@Override
public void setDead() {
    if (!this.world.isRemote && this.playerMP != null) {
        GCPlayerStats stats = GCPlayerStats.get(this.playerMP);
        if (!this.spawnedInCreative) {
            int astroCount = stats.getAstroMinerCount();
            if (astroCount > 0) {
                stats.setAstroMinerCount(stats.getAstroMinerCount() - 1);
            }
        }
        AsteroidsTickHandlerServer.removeChunkData(stats, this);
    }
    super.setDead();
    if (posBase != null) {
        TileEntity tileEntity = posBase.getTileEntity(this.world);
        if (tileEntity instanceof TileEntityMinerBase) {
            ((TileEntityMinerBase) tileEntity).unlinkMiner();
        }
    }
    if (this.soundUpdater != null) {
        this.soundUpdater.update();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) TileEntityMinerBase(micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityMinerBase)

Example 23 with GCPlayerStats

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

the class ItemParaChute method onItemRightClick.

public ItemStack onItemRightClick(ItemStack itemStack, World worldIn, EntityPlayer player) {
    GCPlayerStats stats = GCPlayerStats.get(player);
    ItemStack gear = stats.getExtendedInventory().getStackInSlot(4);
    if (gear.isEmpty()) {
        stats.getExtendedInventory().setInventorySlotContents(4, itemStack.copy());
        itemStack = ItemStack.EMPTY;
    }
    return itemStack;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) ItemStack(net.minecraft.item.ItemStack)

Example 24 with GCPlayerStats

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

the class ItemBlockPanel method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (!player.isSneaking()) {
        return EnumActionResult.PASS;
    }
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock().isOpaqueCube(state) && !(state.getBlock() instanceof BlockPanelLighting)) {
        ItemStack stack;
        if (hand == EnumHand.OFF_HAND) {
            stack = player.inventory.offHandInventory.get(0);
        } else {
            stack = player.inventory.getStackInSlot(player.inventory.currentItem);
        }
        if (stack.getItem() != this) {
            return EnumActionResult.FAIL;
        }
        if (world.isRemote) {
            BlockPanelLighting.updateClient(stack.getItemDamage(), state);
        } else {
            int meta = stack.getItemDamage();
            if (meta >= BlockPanelLighting.PANELTYPES_LENGTH)
                meta = 0;
            GCPlayerStats stats = GCPlayerStats.get(player);
            IBlockState[] panels = stats.getPanelLightingBases();
            panels[meta] = state;
        }
    }
    return EnumActionResult.PASS;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) ItemStack(net.minecraft.item.ItemStack) BlockPanelLighting(micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)

Example 25 with GCPlayerStats

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

the class ItemBasic method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
    ItemStack itemStackIn = playerIn.getHeldItem(hand);
    if (itemStackIn.getItemDamage() == 19) {
        if (playerIn instanceof EntityPlayerMP) {
            GCPlayerStats stats = GCPlayerStats.get(playerIn);
            ItemStack gear = stats.getExtendedInventory().getStackInSlot(5);
            if (gear.isEmpty() && itemStackIn.getTagCompound() == null) {
                stats.getExtendedInventory().setInventorySlotContents(5, itemStackIn.copy());
                itemStackIn = ItemStack.EMPTY;
            }
        }
    }
    return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) 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