Search in sources :

Example 16 with GCPlayerStats

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

the class ItemCreativeSpaceKit method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    if (player instanceof EntityPlayerMP) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        InventoryExtended inv = stats.getExtendedInventory();
        // Oxygen Mask
        inv.setInventorySlotContents(0, new ItemStack(GCItems.oxMask));
        // Oxygen Gear
        inv.setInventorySlotContents(1, new ItemStack(GCItems.oxygenGear));
        // Creative Oxygen Tank
        inv.setInventorySlotContents(2, new ItemStack(GCItems.oxygenCanisterInfinite));
        // Creative Oxygen Tank
        inv.setInventorySlotContents(3, new ItemStack(GCItems.oxygenCanisterInfinite));
        // Parachute
        inv.setInventorySlotContents(4, new ItemStack(GCItems.parachute));
        // Frequency Module
        inv.setInventorySlotContents(5, new ItemStack(GCItems.basicItem, 1, 19));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(6, new ItemStack(VenusItems.thermalPaddingTier2, 1, 0));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(7, new ItemStack(VenusItems.thermalPaddingTier2, 1, 1));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(8, new ItemStack(VenusItems.thermalPaddingTier2, 1, 2));
        // Thermal Armor Tier 2
        inv.setInventorySlotContents(9, new ItemStack(VenusItems.thermalPaddingTier2, 1, 3));
        // Shield Controller
        inv.setInventorySlotContents(10, new ItemStack(VenusItems.basicItem, 1, 0));
    }
    return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
Also used : InventoryExtended(micdoodle8.mods.galacticraft.core.inventory.InventoryExtended) ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 17 with GCPlayerStats

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

the class EventHandlerGC method schematicUnlocked.

@SubscribeEvent
public void schematicUnlocked(Unlock event) {
    GCPlayerStats stats = GCPlayerStats.get(event.player);
    if (!stats.getUnlockedSchematics().contains(event.page)) {
        stats.getUnlockedSchematics().add(event.page);
        Collections.sort(stats.getUnlockedSchematics());
        if (event.player != null && event.player.connection != null) {
            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(event.player.world), objList), event.player);
        }
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 18 with GCPlayerStats

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

the class EventHandlerGC method onPlayerRightClickedBlock.

@SubscribeEvent
public void onPlayerRightClickedBlock(PlayerInteractEvent.RightClickBlock event) {
    // Skip events triggered from Thaumcraft Golems and other non-players
    if (event.getEntityPlayer() == null || event.getEntityPlayer().inventory == null || event.getPos() == null || (event.getPos().getX() == 0 && event.getPos().getY() == 0 && event.getPos().getZ() == 0)) {
        return;
    }
    final World worldObj = event.getEntityPlayer().world;
    if (worldObj == null) {
        return;
    }
    final Block idClicked = worldObj.getBlockState(event.getPos()).getBlock();
    if (idClicked == Blocks.BED && worldObj.provider instanceof IGalacticraftWorldProvider && !worldObj.isRemote && !((IGalacticraftWorldProvider) worldObj.provider).hasBreathableAtmosphere()) {
        if (GalacticraftCore.isPlanetsLoaded) {
            GCPlayerStats stats = GCPlayerStats.get(event.getEntityPlayer());
            if (!stats.hasReceivedBedWarning()) {
                event.getEntityPlayer().sendMessage(new TextComponentString(GCCoreUtil.translate("gui.bed_fail.message")));
                stats.setReceivedBedWarning(true);
            }
        }
        if (worldObj.provider instanceof WorldProviderSpaceStation) {
            // On space stations simply block the bed activation => no explosion
            event.setCanceled(true);
            return;
        }
        // Optionally prevent beds from exploding - depends on canRespawnHere() in the WorldProvider interacting with this
        EventHandlerGC.bedActivated = true;
        if (worldObj.provider.canRespawnHere() && !EventHandlerGC.bedActivated) {
            EventHandlerGC.bedActivated = true;
            // On planets allow the bed to be used to designate a player spawn point
            event.getEntityPlayer().setSpawnChunk(event.getPos(), false, GCCoreUtil.getDimensionID(event.getWorld()));
        } else {
            EventHandlerGC.bedActivated = false;
        }
    }
    final ItemStack heldStack = event.getEntityPlayer().inventory.getCurrentItem();
    final TileEntity tileClicked = worldObj.getTileEntity(event.getPos());
    if (!heldStack.isEmpty()) {
        if (tileClicked != null && tileClicked instanceof IKeyable) {
            if (heldStack.getItem() instanceof IKeyItem) {
                if (((IKeyItem) heldStack.getItem()).getTier(heldStack) == -1 || ((IKeyable) tileClicked).getTierOfKeyRequired() == -1 || ((IKeyItem) heldStack.getItem()).getTier(heldStack) == ((IKeyable) tileClicked).getTierOfKeyRequired()) {
                    event.setCanceled(((IKeyable) tileClicked).onValidKeyActivated(event.getEntityPlayer(), heldStack, event.getFace()));
                } else if (!event.getEntityPlayer().isSneaking()) {
                    event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
                }
            } else {
                event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
            }
        }
        if (heldStack.getItem() instanceof ItemFlintAndSteel || heldStack.getItem() instanceof ItemFireball) {
            if (!worldObj.isRemote) {
                if (idClicked != Blocks.TNT && OxygenUtil.noAtmosphericCombustion(event.getEntityPlayer().world.provider) && !OxygenUtil.isAABBInBreathableAirBlock(event.getEntityLiving().world, new AxisAlignedBB(event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), event.getPos().getX() + 1, event.getPos().getY() + 2, event.getPos().getZ() + 1))) {
                    event.setCanceled(true);
                }
            }
        }
    } else if (tileClicked != null && tileClicked instanceof IKeyable) {
        event.setCanceled(((IKeyable) tileClicked).onActivatedWithoutKey(event.getEntityPlayer(), event.getFace()));
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ItemFireball(net.minecraft.item.ItemFireball) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IKeyItem(micdoodle8.mods.galacticraft.api.item.IKeyItem) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) IKeyable(micdoodle8.mods.galacticraft.api.item.IKeyable) World(net.minecraft.world.World) TextComponentString(net.minecraft.util.text.TextComponentString) TileEntity(net.minecraft.tileentity.TileEntity) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) ItemFlintAndSteel(net.minecraft.item.ItemFlintAndSteel) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 19 with GCPlayerStats

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

the class EventHandlerGC method onPlayerDeath.

@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayerMP) {
        GCPlayerStats stats = GCPlayerStats.get(event.getEntityPlayer());
        if (!event.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
            event.getEntityPlayer().captureDrops = true;
            for (int i = stats.getExtendedInventory().getSizeInventory() - 1; i >= 0; i--) {
                ItemStack stack = stats.getExtendedInventory().getStackInSlot(i);
                if (!stack.isEmpty()) {
                    event.getEntityPlayer().dropItem(stack, true, false);
                    stats.getExtendedInventory().setInventorySlotContents(i, ItemStack.EMPTY);
                }
            }
            event.getEntityLiving().captureDrops = false;
        }
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 20 with GCPlayerStats

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

the class GCPlayerHandler method sendAirRemainingPacket.

protected static void sendAirRemainingPacket(EntityPlayerMP player, GCPlayerStats stats) {
    final float f1 = stats.getTankInSlot1().isEmpty() ? 0.0F : stats.getTankInSlot1().getMaxDamage() / 90.0F;
    final float f2 = stats.getTankInSlot2().isEmpty() ? 0.0F : stats.getTankInSlot2().getMaxDamage() / 90.0F;
    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_AIR_REMAINING, GCCoreUtil.getDimensionID(player.world), new Object[] { MathHelper.floor(stats.getAirRemaining() / f1), MathHelper.floor(stats.getAirRemaining2() / f2), PlayerUtil.getName(player) }), player);
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple)

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