Search in sources :

Example 76 with GCPlayerStats

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

the class TeleportTypeVenus method getPlayerSpawnLocation.

@Override
public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) {
    if (player != null) {
        GCPlayerStats stats = GCPlayerStats.get(player);
        double x = stats.getCoordsTeleportedFromX();
        double z = stats.getCoordsTeleportedFromZ();
        int limit = ConfigManagerCore.otherPlanetWorldBorders - 2;
        if (limit > 20) {
            if (x > limit) {
                z *= limit / x;
                x = limit;
            } else if (x < -limit) {
                z *= -limit / x;
                x = -limit;
            }
            if (z > limit) {
                x *= limit / z;
                z = limit;
            } else if (z < -limit) {
                x *= -limit / z;
                z = -limit;
            }
        }
        return new Vector3(x, 900.0, z);
    }
    return null;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 77 with GCPlayerStats

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

the class EntityTieredRocket method onReachAtmosphere.

@Override
public void onReachAtmosphere() {
    // Launch controlled
    if (this.destinationFrequency != -1) {
        if (this.world.isRemote) {
            // stop the sounds on the client - but do not reset, the rocket may start again
            this.stopRocketSound();
            return;
        }
        this.setTarget(true, this.destinationFrequency);
        if (this.targetVec != null) {
            if (this.targetDimension != this.world.provider.getDimension()) {
                WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
                if (targetDim != null && targetDim.world instanceof WorldServer) {
                    boolean dimensionAllowed = this.targetDimension == ConfigManagerCore.idDimensionOverworld;
                    if (targetDim instanceof IGalacticraftWorldProvider) {
                        if (((IGalacticraftWorldProvider) targetDim).canSpaceshipTierPass(this.getRocketTier()))
                            dimensionAllowed = true;
                        else
                            dimensionAllowed = false;
                    } else // No rocket flight to non-Galacticraft dimensions other than the Overworld allowed unless config
                    if ((this.targetDimension > 1 || this.targetDimension < -1) && marsConfigAllDimsAllowed != null) {
                        try {
                            if (marsConfigAllDimsAllowed.getBoolean(null)) {
                                dimensionAllowed = true;
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (dimensionAllowed) {
                        if (!this.getPassengers().isEmpty()) {
                            for (Entity passenger : this.getPassengers()) {
                                if (passenger instanceof EntityPlayerMP) {
                                    WorldUtil.transferEntityToDimension(passenger, this.targetDimension, (WorldServer) targetDim.world, false, this);
                                }
                            }
                        } else {
                            Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.world, false, null);
                            if (e instanceof EntityAutoRocket) {
                                e.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5f);
                                ((EntityAutoRocket) e).setLaunchPhase(EnumLaunchPhase.LANDING);
                                ((EntityAutoRocket) e).setWaitForPlayer(false);
                            } else {
                                GCLog.info("Error: failed to recreate the unmanned rocket in landing mode on target planet.");
                                e.setDead();
                                this.setDead();
                            }
                        }
                        return;
                    }
                }
            // No destination world found - in this situation continue into regular take-off (as if Not launch controlled)
            } else {
                // Same dimension controlled rocket flight
                this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
                // Stop any lateral motion, otherwise it will update to an incorrect x,z position first tick after spawning above target
                this.motionX = this.motionZ = 0.0D;
                // Small upward motion initially, to keep clear of own flame trail from launch
                this.motionY = 0.1D;
                for (Entity passenger : this.getPassengers()) {
                    if (passenger instanceof EntityPlayerMP) {
                        WorldUtil.forceMoveEntityToPos(passenger, (WorldServer) this.world, new Vector3(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F), false);
                        this.setWaitForPlayer(true);
                        GCLog.debug("Rocket repositioned, waiting for player");
                    }
                }
                this.setLaunchPhase(EnumLaunchPhase.LANDING);
                // Do not destroy the rocket, we still need it!
                return;
            }
        } else {
            // Launch controlled launch but no valid target frequency = rocket loss [INVESTIGATE]
            GCLog.info("Error: the launch controlled rocket failed to find a valid landing spot when it reached space.");
            this.fuelTank.drain(Integer.MAX_VALUE, true);
            this.posY = Math.max(255, (this.world.provider instanceof IExitHeight ? ((IExitHeight) this.world.provider).getYCoordinateToTeleport() : 1200) - 200);
            return;
        }
    }
    // Not launch controlled
    if (!this.world.isRemote) {
        for (Entity e : this.getPassengers()) {
            if (e instanceof EntityPlayerMP) {
                EntityPlayerMP player = (EntityPlayerMP) e;
                this.onTeleport(player);
                GCPlayerStats stats = GCPlayerStats.get(player);
                WorldUtil.toCelestialSelection(player, stats, this.getRocketTier());
            }
        }
        // Destroy any rocket which reached the top of the atmosphere and is not controlled by a Launch Controller
        this.setDead();
    }
// Client side, non-launch controlled, do nothing - no reason why it can't continue flying until the GUICelestialSelection activates
}
Also used : ICameraZoomEntity(micdoodle8.mods.galacticraft.api.entity.ICameraZoomEntity) Entity(net.minecraft.entity.Entity) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) WorldServer(net.minecraft.world.WorldServer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) IExitHeight(micdoodle8.mods.galacticraft.api.world.IExitHeight)

Example 78 with GCPlayerStats

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

the class GuiHandler method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase == null) {
        player.sendMessage(new TextComponentString("Galacticraft player instance null server-side. This is a bug."));
        return null;
    }
    GCPlayerStats stats = GCPlayerStats.get(playerBase);
    if (ID == GuiIdsCore.ROCKET_INVENTORY && player.getRidingEntity() instanceof EntityTieredRocket) {
        return new ContainerRocketInventory(player.inventory, (EntityTieredRocket) player.getRidingEntity(), ((EntityTieredRocket) player.getRidingEntity()).getType(), player);
    } else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
        return new ContainerExtendedInventory(player, stats.getExtendedInventory());
    }
    BlockPos pos = new BlockPos(x, y, z);
    TileEntity tile = world.getTileEntity(pos);
    if (tile != null) {
        if (tile instanceof TileEntityCrafting) {
            return new ContainerCrafting(player.inventory, (TileEntityCrafting) tile);
        } else if (tile instanceof TileEntityRefinery) {
            return new ContainerRefinery(player.inventory, (TileEntityRefinery) tile, player);
        } else if (tile instanceof TileEntityOxygenCollector) {
            return new ContainerOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
        } else if (tile instanceof TileEntityOxygenDistributor) {
            return new ContainerOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
        } else if (tile instanceof TileEntityFuelLoader) {
            return new ContainerFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
        } else if (tile instanceof TileEntityOxygenSealer) {
            return new ContainerOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
        } else if (tile instanceof TileEntityCargoLoader) {
            return new ContainerCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
        } else if (tile instanceof TileEntityCargoUnloader) {
            return new ContainerCargoLoader(player.inventory, (TileEntityCargoUnloader) tile);
        } else if (tile instanceof TileEntityParaChest) {
            return new ContainerParaChest(player.inventory, (TileEntityParaChest) tile, player);
        } else if (tile instanceof TileEntitySolar) {
            return new ContainerSolar(player.inventory, (TileEntitySolar) tile);
        } else if (tile instanceof TileEntityEnergyStorageModule) {
            return new ContainerEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
        } else if (tile instanceof TileEntityCoalGenerator) {
            return new ContainerCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
        } else if (tile instanceof TileEntityElectricFurnace) {
            return new ContainerElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
        } else if (tile instanceof TileEntityIngotCompressor) {
            return new ContainerIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
        } else if (tile instanceof TileEntityElectricIngotCompressor) {
            return new ContainerElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
        } else if (tile instanceof TileEntityCircuitFabricator) {
            return new ContainerCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
        } else if (tile instanceof TileEntityOxygenStorageModule) {
            return new ContainerOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
        } else if (tile instanceof TileEntityOxygenCompressor) {
            return new ContainerOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile, player);
        } else if (tile instanceof TileEntityOxygenDecompressor) {
            return new ContainerOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile, player);
        } else if (tile instanceof TileEntityDeconstructor) {
            return new ContainerDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
        } else if (tile instanceof TileEntityPainter) {
            return new ContainerPainter(player.inventory, (TileEntityPainter) tile);
        }
    }
    for (ISchematicPage page : stats.getUnlockedSchematics()) {
        if (ID == page.getGuiID()) {
            return page.getResultContainer(playerBase, new BlockPos(x, y, z));
        }
    }
    return null;
}
Also used : EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TileEntity(net.minecraft.tileentity.TileEntity) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)

Example 79 with GCPlayerStats

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

the class BlockPanelLighting method setColor.

@Override
public int setColor(int color, EntityPlayer p, Side side) {
    if (side == Side.CLIENT) {
        BlockPanelLighting.color = ColorUtil.lighten(ColorUtil.lightenFully(color, 255), 0.1F);
    } else {
        GCPlayerStats stats = GCPlayerStats.get(p);
        stats.setPanelLightingColor(color);
    }
    return 1;
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)

Example 80 with GCPlayerStats

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

the class TeleportTypeAsteroids method setupAdventureSpawn.

@Override
public void setupAdventureSpawn(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));
    // Knows how to build Astro Miner
    SchematicRegistry.unlockNewPage(player, new ItemStack(MarsItems.schematic, 1, 2));
    NonNullList<ItemStack> rocketStacks = NonNullList.create();
    stats.setFuelLevel(1000);
    rocketStacks.add(new ItemStack(GCItems.oxMask));
    rocketStacks.add(new ItemStack(GCItems.oxygenGear));
    rocketStacks.add(new ItemStack(GCItems.oxTankMedium));
    rocketStacks.add(new ItemStack(GCItems.oxTankHeavy));
    rocketStacks.add(new ItemStack(GCItems.oxTankHeavy));
    rocketStacks.add(new ItemStack(AsteroidsItems.canisterLOX));
    rocketStacks.add(new ItemStack(AsteroidsItems.canisterLOX));
    rocketStacks.add(new ItemStack(AsteroidsItems.canisterLOX));
    rocketStacks.add(new ItemStack(AsteroidsItems.basicItem, 32, 7));
    rocketStacks.add(new ItemStack(Blocks.GLASS_PANE, 16));
    rocketStacks.add(new ItemStack(Blocks.PLANKS, 32, 2));
    // Desh ingot
    rocketStacks.add(new ItemStack(MarsItems.marsItemBasic, 16, 2));
    // Basic Wafer
    rocketStacks.add(new ItemStack(GCItems.basicItem, 8, 13));
    // Solar Panels
    rocketStacks.add(new ItemStack(GCItems.basicItem, 2, 1));
    // Canned food
    rocketStacks.add(new ItemStack(GCItems.foodItem, 16, 0));
    rocketStacks.add(new ItemStack(Items.EGG, 12));
    ItemStack spawnEgg = new ItemStack(Items.SPAWN_EGG, 2);
    ResourceLocation name = EntityList.getKey(EntityCow.class);
    ItemMonsterPlacer.applyEntityIdToItemStack(spawnEgg, name);
    rocketStacks.add(spawnEgg);
    // Night Vision Potion
    rocketStacks.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 4), PotionTypes.LONG_NIGHT_VISION));
    // Cryogenic Chamber
    rocketStacks.add(new ItemStack(MarsBlocks.machine, 1, 4));
    rocketStacks.add(new ItemStack(MarsItems.rocketMars, 1, IRocketType.EnumRocketType.INVENTORY36.ordinal()));
    stats.setRocketStacks(rocketStacks);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) 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