Search in sources :

Example 26 with GCPlayerStats

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

the class ColorUtil method sendUpdatedColorsToPlayer.

public static void sendUpdatedColorsToPlayer(GCPlayerStats stats) {
    int dimID = stats.getPlayer().get().dimension;
    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RECOLOR_ALL_GLASS, dimID, new Object[] { Integer.valueOf(stats.getGlassColor1()), Integer.valueOf(stats.getGlassColor2()), Integer.valueOf(stats.getGlassColor3()) }), stats.getPlayer().get());
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint)

Example 27 with GCPlayerStats

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

the class TileEntityPanelLight method initialise.

public void initialise(int type, EnumFacing facing, EntityPlayer player, boolean isRemote, IBlockState superStateClient) {
    this.meta = facing.ordinal();
    if (isRemote) {
        this.superState = superStateClient;
        this.color = BlockPanelLighting.color;
    } else {
        GCPlayerStats stats = GCPlayerStats.get(player);
        this.superState = stats.getPanelLightingBases()[type];
        this.color = stats.getPanelLightingColor();
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)

Example 28 with GCPlayerStats

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

the class EntitySlimeling method processInteract.

@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
    ItemStack itemstack = player.inventory.getCurrentItem();
    if (this.isTamed()) {
        if (!itemstack.isEmpty()) {
            if (itemstack.getItem() == this.getFavoriteFood()) {
                if (this.isOwner(player)) {
                    itemstack.shrink(1);
                    if (itemstack.isEmpty()) {
                        player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
                    }
                    if (this.world.isRemote) {
                        MarsModuleClient.openSlimelingGui(this, 1);
                    }
                    if (this.rand.nextInt(3) == 0) {
                        this.setRandomFavFood();
                    }
                } else {
                    if (player instanceof EntityPlayerMP) {
                        GCPlayerStats stats = GCPlayerStats.get(player);
                        if (stats.getChatCooldown() == 0) {
                            player.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.slimeling.chat.wrong_player")));
                            stats.setChatCooldown(100);
                        }
                    }
                }
            } else {
                if (this.world.isRemote) {
                    MarsModuleClient.openSlimelingGui(this, 0);
                }
            }
        } else {
            if (this.world.isRemote) {
                MarsModuleClient.openSlimelingGui(this, 0);
            }
        }
        return true;
    } else if (!itemstack.isEmpty() && itemstack.getItem() == Items.SLIME_BALL) {
        if (!player.capabilities.isCreativeMode) {
            itemstack.shrink(1);
        }
        if (itemstack.isEmpty()) {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
        }
        if (!this.world.isRemote) {
            if (this.rand.nextInt(3) == 0) {
                this.setTamed(true);
                this.getNavigator().clearPath();
                this.setAttackTarget(null);
                this.setSittingAI(true);
                this.setHealth(20.0F);
                this.setOwnerId(player.getUniqueID());
                this.setOwnerUsername(player.getName());
                this.playTameEffect(true);
                this.world.setEntityState(this, (byte) 7);
            } else {
                this.playTameEffect(false);
                this.world.setEntityState(this, (byte) 6);
            }
        }
        return true;
    }
    return super.processInteract(player, hand);
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 29 with GCPlayerStats

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

the class EntityAutoRocket method onLaunch.

@Override
public void onLaunch() {
    if (!(this.world.provider.getDimension() == GalacticraftCore.planetOverworld.getDimensionID() || this.world.provider instanceof IGalacticraftWorldProvider)) {
        if (ConfigManagerCore.disableRocketLaunchAllNonGC) {
            this.cancelLaunch();
            return;
        }
        // No rocket flight in the Nether, the End etc
        for (int i = ConfigManagerCore.disableRocketLaunchDimensions.length - 1; i >= 0; i--) {
            if (ConfigManagerCore.disableRocketLaunchDimensions[i] == this.world.provider.getDimension()) {
                this.cancelLaunch();
                return;
            }
        }
    }
    super.onLaunch();
    if (!this.world.isRemote) {
        GCPlayerStats stats = null;
        if (!this.getPassengers().isEmpty()) {
            for (Entity player : this.getPassengers()) {
                if (player instanceof EntityPlayerMP) {
                    stats = GCPlayerStats.get(player);
                    stats.setLaunchpadStack(null);
                    if (!(this.world.provider instanceof IOrbitDimension)) {
                        stats.setCoordsTeleportedFromX(player.posX);
                        stats.setCoordsTeleportedFromZ(player.posZ);
                    }
                }
            }
            Entity playerMain = this.getPassengers().get(0);
            if (playerMain instanceof EntityPlayerMP)
                stats = GCPlayerStats.get(playerMain);
        }
        int amountRemoved = 0;
        PADSEARCH: for (int x = MathHelper.floor(this.posX) - 1; x <= MathHelper.floor(this.posX) + 1; x++) {
            for (int y = MathHelper.floor(this.posY) - 3; y <= MathHelper.floor(this.posY) + 1; y++) {
                for (int z = MathHelper.floor(this.posZ) - 1; z <= MathHelper.floor(this.posZ) + 1; z++) {
                    BlockPos pos = new BlockPos(x, y, z);
                    final Block block = this.world.getBlockState(pos).getBlock();
                    if (block != null && block instanceof BlockLandingPadFull) {
                        if (amountRemoved < 9) {
                            EventLandingPadRemoval event = new EventLandingPadRemoval(this.world, pos);
                            MinecraftForge.EVENT_BUS.post(event);
                            if (event.allow) {
                                this.world.setBlockToAir(pos);
                                amountRemoved = 9;
                            }
                            break PADSEARCH;
                        }
                    }
                }
            }
        }
        // Set the player's launchpad item for return on landing - or null if launchpads not removed
        if (stats != null && amountRemoved == 9) {
            stats.setLaunchpadStack(new ItemStack(GCBlocks.landingPad, 9, 0));
        }
        this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EventLandingPadRemoval(micdoodle8.mods.galacticraft.core.event.EventLandingPadRemoval) Block(net.minecraft.block.Block) BlockLandingPadFull(micdoodle8.mods.galacticraft.core.blocks.BlockLandingPadFull) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos) IOrbitDimension(micdoodle8.mods.galacticraft.api.world.IOrbitDimension) ItemStack(net.minecraft.item.ItemStack)

Example 30 with GCPlayerStats

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

the class EntityTieredRocket method processInitialInteract.

@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
    if (hand != EnumHand.MAIN_HAND) {
        return false;
    }
    if (this.launchPhase >= EnumLaunchPhase.LAUNCHED.ordinal()) {
        return false;
    }
    if (!this.getPassengers().isEmpty() && this.getPassengers().contains(player)) {
        if (!this.world.isRemote) {
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_RESET_THIRD_PERSON, this.world.provider.getDimension(), new Object[] {}), (EntityPlayerMP) player);
            GCPlayerStats stats = GCPlayerStats.get(player);
            stats.setChatCooldown(0);
            // Prevent player being dropped from the top of the rocket...
            float heightBefore = this.height;
            this.height = this.height / 2.0F;
            this.removePassengers();
            this.height = heightBefore;
        }
        return true;
    } else if (player instanceof EntityPlayerMP) {
        if (!this.world.isRemote) {
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_DISPLAY_ROCKET_CONTROLS, this.world.provider.getDimension(), new Object[] {}), (EntityPlayerMP) player);
            GCPlayerStats stats = GCPlayerStats.get(player);
            stats.setChatCooldown(0);
            player.startRiding(this);
        }
        return true;
    }
    return false;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

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